summaryrefslogtreecommitdiffhomepage
path: root/patches/p2c-2.02.local.patch
blob: 207ae68a5dac2c381c9ec2ace9d1404434ed938e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
diff -ru p2c-2.02.orig/Makefile p2c-2.02/Makefile
--- p2c-2.02.orig/Makefile	1993-12-08 06:37:05.000000000 +0100
+++ p2c-2.02/Makefile	2024-03-20 10:32:36.899062261 +0100
@@ -24,25 +24,7 @@
 # and src/Makefile.
 
 test:
-	@echo "Compiling p2c, installing in `pwd`/home..."
-	cd src; make install
-	@echo ""
-	@echo "Translating and compiling example files..."
-	cd examples; make comp
-	@echo ""
-	@echo "Running the factorial example..."
-	examples/fact
-	@echo ""
-	@echo "Running the 'e' computation example..."
-	examples/e
-	@echo ""
-	@echo "Running the self-printing Pascal example..."
-	examples/self >examples/self.out
-	cat examples/self.out
-	diff examples/self.p examples/self.out
-	@echo ""
-	@echo "Also try 'cref' and 'basic' in the examples directory."
-
+	cd src; make
 
 install:
 	cd src; make install
diff -ru p2c-2.02.orig/src/Makefile p2c-2.02/src/Makefile
--- p2c-2.02.orig/src/Makefile	2015-11-18 21:12:06.000000000 +0100
+++ p2c-2.02/src/Makefile	2024-03-20 10:32:36.899062261 +0100
@@ -19,25 +19,21 @@
 SHELL = /bin/sh
 
 # Directories (private version)
-HOMEDIR = ../home
-INCDIR = ../home/p2c
-BINDIR = ..
-LIBDIR = ../home
-MANDIR = ../home
-MANFILE = p2c.cat          # human-readable manual (for cat.1)
 #MANFILE = p2c.man.inst    # uncompressed nroff source (for man.1)
 #MANFILE = p2c.man.Z       # compressed nroff source (for man.1.Z)
 
 # Directories (public version)
-#HOMEDIR = /usr/lib/p2c
-#INCDIR = /usr/include/p2c
-#BINDIR = /usr/bin
-#LIBDIR = /usr/lib
-#MANDIR = /usr/man/man1
-#MANFILE = p2c.man.inst
+HOMEDIR = /usr/lib/p2c
+INCDIR = /usr/include/p2c
+BINDIR = /usr/bin
+LIBDIR = /usr/lib
+MANDIR = /usr/man/man1
+MANFILE = p2c.man.inst
+DESTDIR ?=
 
 # Compiler options
 CC = cc                    # you may wish to use gcc here instead
+AR = ar
 OPT = # -O		   # uncomment this for optimization
 DEB = # -g		   # uncomment this for debugging
 DEFS =	-DTEST_MALLOC      # place other -D types of things here # TDS 2015nov18
@@ -74,7 +70,7 @@
 
 
 # Top-level targets
-all: proto p2c libp2c.a p2c.cat
+all: proto p2c libp2c.a p2c.cat proto
 proto: $(PROTOS)
 
 
@@ -86,7 +82,7 @@
 	$(CC) -c $(CFLAGS) $(CUSTDEFS) dir.c
 
 trans.o: trans.c trans.h
-	$(CC) -c $(CFLAGS) -DHASDUMPS -DP2C_HOME=\"$(ABSHOMEDIR)\" trans.c
+	$(CC) -c $(CFLAGS) -DHASDUMPS -DP2C_HOME=\"/usr/lib/p2c\" trans.c
 
 
 # Making and using makeproto
@@ -97,12 +93,12 @@
 	./makeproto -n -m -h -t16 -a35 -s1 -i $(SRCS) -o p2c.proto
 
 makeproto: makeproto.c
-	$(CC) $(CFLAGS) $(LFLAGS) makeproto.c -o makeproto
+	$(HOST_CC) $(CFLAGS) $(LFLAGS) makeproto.c -o makeproto
 
 
 # Making the p2c runtime library
 libp2c.a: $(LIBOBJS)
-	ar r libp2c.a $(LIBOBJS) $(OTHERLIBOBJS)
+	$(AR) r libp2c.a $(LIBOBJS) $(OTHERLIBOBJS)
 
 p2clib.o: p2clib.c
 	$(CC) -c $(CFLAGS) p2clib.c
@@ -145,61 +141,23 @@
 newhome:
 	rm -f trans.o     # force trans.c to be recompiled (if HOMEDIR changes)
 
-install: proto \
-	makedirs \
-	$(BINDIR)/p2c         \
-	$(BINDIR)/p2cc        \
-	$(LIBDIR)/libp2c.a    \
-	$(MANDIR)/p2c.1	      \
-	$(INCDIR)/p2c.h	      \
-	$(HOMEDIR)/p2crc      \
-	$(HOMEDIR)/loc.p2crc  \
-	$(HOMEDIR)/system.imp \
-	$(HOMEDIR)/system.m2  \
-	$(HOMEDIR)/turbo.imp  \
-	$(HOMEDIR)/string.pas
-
-SHELL=/bin/sh
-makedirs:
-	if [ ! -d $(HOMEDIR) ]; then mkdir $(HOMEDIR); else true; fi
-	if [ ! -d $(BINDIR) ]; then mkdir $(BINDIR); else true; fi
-	if [ ! -d $(LIBDIR) ]; then mkdir $(LIBDIR); else true; fi
-	if [ ! -d $(MANDIR) ]; then mkdir $(MANDIR); else true; fi
-	if [ ! -d $(INCDIR) ]; then mkdir $(INCDIR); else true; fi
-
-$(BINDIR)/p2c: p2c
-	$(COPY)  p2c          $(BINDIR)/p2c
-
-$(BINDIR)/p2cc: p2cc
-	$(COPY)  p2cc         $(BINDIR)/p2cc
-
-$(LIBDIR)/libp2c.a: libp2c.a
-	$(COPY)  libp2c.a     $(LIBDIR)/libp2c.a
-	if [ -f /usr/bin/ranlib -o -f /bin/ranlib ]; then ranlib $(LIBDIR)/libp2c.a; fi
-
-$(MANDIR)/p2c.1: $(MANFILE)
-	$(COPY)  $(MANFILE)   $(MANDIR)/p2c.1
-
-$(INCDIR)/p2c.h: p2c.h
-	$(COPY)  p2c.h        $(INCDIR)/p2c.h
-
-$(HOMEDIR)/p2crc: sys.p2crc
-	$(COPY)  sys.p2crc    $(HOMEDIR)/p2crc
-
-$(HOMEDIR)/loc.p2crc: loc.p2crc
-	$(COPY)  loc.p2crc    $(HOMEDIR)/loc.p2crc
-
-$(HOMEDIR)/system.imp: system.imp
-	$(COPY)  system.imp   $(HOMEDIR)/system.imp
-
-$(HOMEDIR)/system.m2: system.m2
-	$(COPY)  system.m2    $(HOMEDIR)/system.m2
-
-$(HOMEDIR)/turbo.imp: turbo.imp
-	$(COPY)  turbo.imp    $(HOMEDIR)/turbo.imp
-
-$(HOMEDIR)/string.pas: string.pas
-	$(COPY)  string.pas   $(HOMEDIR)/string.pas
+install:
+	if [ ! -d $(DESTDIR)$(HOMEDIR) ]; then mkdir $(DESTDIR)$(HOMEDIR); else true; fi
+	if [ ! -d $(DESTDIR)$(BINDIR) ]; then mkdir $(DESTDIR)$(BINDIR); else true; fi
+	if [ ! -d $(DESTDIR)$(LIBDIR) ]; then mkdir $(DESTDIR)$(LIBDIR); else true; fi
+	if [ ! -d $(DESTDIR)$(MANDIR) ]; then mkdir $(DESTDIR)$(MANDIR); else true; fi
+	if [ ! -d $(DESTDIR)$(INCDIR) ]; then mkdir $(DESTDIR)$(INCDIR); else true; fi
+	$(COPY)  p2c          $(DESTDIR)$(BINDIR)/p2c
+	$(COPY)  libp2c.a     $(DESTDIR)$(LIBDIR)/libp2c.a
+	$(AR) -s $(DESTDIR)$(LIBDIR)/libp2c.a
+	$(COPY)  $(MANFILE)   $(DESTDIR)$(MANDIR)/p2c.1
+	$(COPY)  p2c.h        $(DESTDIR)$(INCDIR)/p2c.h
+	$(COPY)  sys.p2crc    $(DESTDIR)$(HOMEDIR)/p2crc
+	$(COPY)  loc.p2crc    $(DESTDIR)$(HOMEDIR)/loc.p2crc
+	$(COPY)  system.imp   $(DESTDIR)$(HOMEDIR)/system.imp
+	$(COPY)  system.m2    $(DESTDIR)$(HOMEDIR)/system.m2
+	$(COPY)  turbo.imp    $(DESTDIR)$(HOMEDIR)/turbo.imp
+	$(COPY)  string.pas   $(DESTDIR)$(HOMEDIR)/string.pas
 
 
 
diff -ru p2c-2.02.orig/src/stuff.c p2c-2.02/src/stuff.c
--- p2c-2.02.orig/src/stuff.c	1993-12-08 06:36:48.000000000 +0100
+++ p2c-2.02/src/stuff.c	2024-03-20 10:43:13.059760161 +0100
@@ -316,7 +316,7 @@
     cp = my_strrchr(fn, '.');
     if (!cp)
         return;
-#if defined(unix) || defined(__unix)
+#if defined(unix) || defined(__unix) || defined(__midipix__)
     cp2 = my_strrchr(fn, '/');
     if (cp2 && cp < cp2)
         return;
diff -ru p2c-2.02.orig/src/trans.c p2c-2.02/src/trans.c
--- p2c-2.02.orig/src/trans.c	2015-10-02 19:52:53.000000000 +0200
+++ p2c-2.02/src/trans.c	2024-03-20 10:45:31.173956389 +0100
@@ -558,7 +558,7 @@
 void saveoldfile(fname)
 char *fname;
 {
-#if defined(unix) || defined(__unix) || defined(CAN_LINK)
+#if defined(unix) || defined(__unix) || defined(CAN_LINK) || defined(__midipix__)
     (void) unlink(format_s("%s~", fname));
     if (link(fname, format_s("%s~", fname)) == 0)
         (void) unlink(fname);