-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
282 lines (227 loc) · 7.52 KB
/
Makefile
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# Scheme 9 from Empty Space
# Makefile (obviously)
# By Nils M Holm, 2007-2018
# In the public domain
# Change at least this line:
PREFIX= /u
# Base version and Release
BASE= 20181115
RELEASE= 20181205
# Override default compiler and flags
CC= cc
CFLAGS= -g -Wall -std=c99 -pedantic -O2
# Which OS are we using (unix or plan9)?
OSDEF= -Dunix
# Uncomment these to include the Unix extensions
EXTRA_SCM+= -l ext/sys-unix/unix.scm -l ext/sys-unix/unix-tools.scm
EXTRA_OBJS+= unix.o
EXTRA_INIT+= sys_init();
EXTRA_LIBS+=
# Uncomment these to include the Curses extensions
EXTRA_SCM+= -l ext/curses/curses.scm
EXTRA_OBJS+= curses.o
EXTRA_INIT+= curs_init();
EXTRA_LIBS+= -lncurses
# Uncomment these to include the CSV extensions
EXTRA_SCM+= -l ext/csv/csv.scm
EXTRA_OBJS+= csv.o
EXTRA_INIT+= csv_init();
EXTRA_LIBS+=
# Options to be added to $(DEFS)
# -DLIBRARY_PATH="\"dir:...\""
# # search path for LOCATE-FILE, etc
# -DIMAGE_DIR="\"dir\"" # location of image file
# -DNETWORK # include socket code in the Unix extension
# -DCURSES_COLOR # enable the CURS:SET-COLOR primitive
# -DCURSES_RESET # automatically run CURS:ENDWIN on the REPL
# # (requires the Curses extension)
DEFS= $(OSDEF) \
-DLIBRARY_PATH="\".:~/s9fes:$(S9DIR)\"" \
-DIMAGE_DIR="\"$(S9DIR)\"" \
-DEXTENSIONS="$(EXTRA_INIT)" \
-DNETWORK \
-DCURSES_COLOR \
-DCURSES_RESET
# Where to install the stuff
S9DIR= $(PREFIX)/share/s9fes
BINDIR= $(PREFIX)/bin
INCDIR= $(PREFIX)/include
LIBDIR= $(PREFIX)/lib
MANDIR= $(PREFIX)/man/man1
# Set up environment to be used during the build process
BUILD_ENV= env S9FES_LIBRARY_PATH=.:lib:ext/sys-unix:ext/curses:ext/csv:contrib S9FES_IMAGE_DIR=.
SETPREFIX= sed -e "s|^\#! /usr/local|\#! $(PREFIX)|"
default: s9 s9.image s9.1.gz s9.1.txt libs9core.a
all: default
s9: s9.o s9core.o $(EXTRA_OBJS)
$(CC) -o s9 $(LDFLAGS) s9.o s9core.o $(EXTRA_OBJS) $(EXTRA_LIBS)
s9.o: s9.c s9core.h s9import.h s9ext.h
$(CC) -o s9.o $(CFLAGS) $(DEFS) -c s9.c
s9core.o: s9core.c s9core.h
$(CC) -o s9core.o $(CFLAGS) $(DEFS) -c s9core.c
s9.image: s9 s9.scm ext/sys-unix/unix.scm ext/curses/curses.scm \
ext/csv/csv.scm config.scm
$(BUILD_ENV) ./s9 -i - $(EXTRA_SCM) -l config.scm -d s9.image
libs9core.a: s9core.o
ar q libs9core.a s9core.o
s9.1.gz: s9.1
sed -e "s,@S9DIR@,$(S9DIR)," <s9.1 |gzip -9 >s9.1.gz
unix.o: ext/sys-unix/unix.c s9core.h s9import.h s9ext.h
$(CC) $(CFLAGS) $(DEFS) -I . -o unix.o -c ext/sys-unix/unix.c
curses.o: ext/curses/curses.c s9core.h s9import.h s9ext.h
$(CC) $(CFLAGS) $(DEFS) -I . -o curses.o -c ext/curses/curses.c
csv.o: ext/csv/csv.c s9core.h s9import.h s9ext.h
$(CC) $(CFLAGS) $(DEFS) -I . -o csv.o -c ext/csv/csv.c
lint:
cc -g -Wall -ansi -pedantic -O3 s9.c s9core.c && rm a.out
test: s9 test.image
$(BUILD_ENV) ./s9 -i test.image util/test.scm
libtest: s9 test.image
$(BUILD_ENV) sh util/libtest.sh
systest: s9 test.image s9.image
$(BUILD_ENV) ./s9 -i test.image util/systest.scm
srtest: s9 test.image
$(BUILD_ENV) ./s9 -i test.image util/srtest.scm
realtest: s9 test.image
$(BUILD_ENV) ./s9 -i test.image util/realtest.scm
coretest: s9core.c s9core.h s9import.h
$(CC) $(CFLAGS) $(DEFS) -DTEST s9core.c && ./a.out && rm -f a.out
test.image: s9 s9.scm
$(BUILD_ENV) ./s9 -i - $(EXTRA_SCM) -d test.image
tests: coretest test realtest srtest libtest systest
install: install-s9 install-util
install-all: install-s9 install-util install-progs
# old version of install(1) may need -c
#C=-c
install-s9: s9 s9.scm s9.image s9.1.gz libs9core.a
install -d -m 0755 $(S9DIR)
install -d -m 0755 $(S9DIR)/help
install -d -m 0755 $(S9DIR)/help/sys-unix
install -d -m 0755 $(S9DIR)/help/curses
install -d -m 0755 $(S9DIR)/help/csv
install -d -m 0755 $(BINDIR)
install -d -m 0755 $(LIBDIR)
install -d -m 0755 $(INCDIR)
install -d -m 0755 $(MANDIR)
install $C -m 0755 s9 $(BINDIR)
strip $(BINDIR)/s9
install $C -m 0644 s9.scm $(S9DIR)
install $C -m 0644 s9.image $(S9DIR)
install $C -m 0644 lib/* $(S9DIR)
install $C -m 0644 ext/sys-unix/*.scm $(S9DIR)
install $C -m 0644 ext/curses/*.scm $(S9DIR)
install $C -m 0644 ext/csv/*.scm $(S9DIR)
install $C -m 0644 contrib/* $(S9DIR)
install $C -m 0644 s9.1.gz $(MANDIR)
(tar cf - help | tar xfC - $(S9DIR))
install $C -m 0644 libs9core.a $(LIBDIR)
install $C -m 0644 s9core.h $(INCDIR)
install $C -m 0644 s9import.h $(INCDIR)
install-util:
$(SETPREFIX) <prog/s9help.scm >$(BINDIR)/s9help
$(SETPREFIX) <prog/s9resolve.scm >$(BINDIR)/s9resolve
$(SETPREFIX) <prog/scm2html1.scm >$(BINDIR)/scm2html
$(SETPREFIX) <prog/scmpp.scm >$(BINDIR)/scmpp
-chmod +x $(BINDIR)/s9help \
$(BINDIR)/s9resolve \
$(BINDIR)/scm2html \
$(BINDIR)/scmpp
install-progs:
$(SETPREFIX) <prog/advgen.scm >$(BINDIR)/advgen
$(SETPREFIX) <prog/c2html1.scm >$(BINDIR)/c2html
$(SETPREFIX) <prog/cols.scm >$(BINDIR)/cols
$(SETPREFIX) <prog/dupes.scm >$(BINDIR)/dupes
$(SETPREFIX) <prog/edoc.scm.edoc >$(BINDIR)/edoc
$(SETPREFIX) <prog/htmlify.scm >$(BINDIR)/htmlify
$(SETPREFIX) <prog/s9hts.scm >$(BINDIR)/s9hts
$(SETPREFIX) <prog/soccat.scm >$(BINDIR)/soccat
-chmod +x $(BINDIR)/advgen \
$(BINDIR)/c2html \
$(BINDIR)/cols \
$(BINDIR)/dupes \
$(BINDIR)/edoc \
$(BINDIR)/htmlify \
$(BINDIR)/s9hts \
$(BINDIR)/soccat
deinstall: deinstall-s9 deinstall-util deinstall-progs
deinstall-s9:
rm -f $(S9DIR)/help/* && rmdir $(S9DIR)/help
rm -f $(S9DIR)/* && rmdir $(S9DIR)
rm -f $(BINDIR)/s9
-rmdir $(BINDIR)
-rmdir $(MANDIR)
deinstall-util:
rm -f $(BINDIR)/s9help \
$(BINDIR)/s9resolve \
$(BINDIR)/scm2html \
$(BINDIR)/scmpp
deinstall-progs:
rm -f $(BINDIR)/advgen \
$(BINDIR)/c2html \
$(BINDIR)/cols \
$(BINDIR)/dupes \
$(BINDIR)/edoc \
$(BINDIR)/htmlify \
$(BINDIR)/s9hts \
$(BINDIR)/soccat
tabs:
@find . -name \*.scm -exec grep -l " " {} \;
cd:
./s9 -i ./s9.image -f util/check-descr.scm
clean:
rm -f s9 s9.image libs9core.a test.image s9.1.gz *.o *.core a.out \
CATEGORIES.html HACKING.html core s9fes-$(RELEASE).tgz \
s9fes-$(BASE).tgz s9core-$(RELEASE).tgz __testfile__ \
_meta _toc.tr _xref.tr _ndx.tr
new-version:
vi Makefile s9.c HISTORY
make s9.c
update-library:
vi util/make-docs
sh util/make-docs
vi util/descriptions util/categories.html
@echo
@echo "Now copy the new help pages from help-new to help"
s9.1.txt: s9.1
$(CC) -o rpp util/rpp.c
nroff -c -mdoc s9.1 | ./rpp -a >s9.1.txt
rm -f rpp
docs: lib ext/sys-unix ext/curses ext/csv contrib
sh util/make-docs
mv -f help-new/sys-unix/* help/sys-unix
mv -f help-new/curses/* help/curses
# mv -f help-new/csv/* help/csv
rmdir help-new/sys-unix help-new/curses help-new/csv
mv -f help-new/* help
rmdir help-new
webdump:
sh util/make-html -r $(RELEASE)
advdump: prog/advgen.scm prog/adventure.adv prog/adventure.intro
sed -e 's/@dir/quest/' -e 's/@file/index/g' <util/pagehead >pagehead
prog/advgen.scm -rv \
-P terminal:session \
-p pagehead \
-e util/pagetail \
-i prog/adventure.intro \
-t "The Quest for S9fES" \
-y ../t3x.css \
prog/adventure.adv
rm -f pagehead
cp MASCOT.png advdump
csums:
csum -u <_csums >_csums.new
mv _csums.new _csums
mksums: clean
find . -type f | grep -v _csums | csum >_csums
dist: clean s9.1.txt
make clean
cd .. && tar cf - s9 | gzip -9 > s9fes-$(RELEASE).tgz && \
mv s9fes-$(RELEASE).tgz s9
ls -l s9fes-$(RELEASE).tgz | awk '{print int($$5/1024+.5)}'
cdist:
tar cf - s9core.[ch] s9import.h s9core.txt README.s9core \
| gzip -9 > s9core-$(RELEASE).tgz
arc: clean
cd .. && tar cf - s9 | gzip -9 > s9fes-$(BASE).tgz && \
mv s9fes-$(BASE).tgz s9
ls -l s9fes-$(BASE).tgz | awk '{print int($$5/1024+.5)}'