-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·516 lines (396 loc) · 15.2 KB
/
Makefile
File metadata and controls
executable file
·516 lines (396 loc) · 15.2 KB
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
# Makefile for SIOD TR - The Reawakening
# George J. Carrette, gjc@alum.mit.edu
# Modifications by Scáth
#
# 2025-12-30 - Cleanup of a lot of old build targets.
# - The historical Makefile is in the attic directory
#
#
# Note: The recursive call to make attempts to set LD_LIBRARY_PATH
# to include the current directory, which is required for the execution
# of the SIOD compiler. If you are debugging in the current directory
# you must also set environment LD_LIBRARY_PATH=.
# Otherwise SIOD won't work at all, or whats worse, the previously
# installed libsiod will override the local copy you are trying to debug.
#
# For debug builds, use make XXX CDEBUG=-g
#
# You might also need "make SHELL=/bin/sh target" if your default shell
# is not compatible with sh or ksh.
#
# Static executable 'sample' is built for comparison purposes
# on some platforms.
#
#
IROOT=/usr/local
MANSEC=1
MANDIR=$(IROOT)/man/man$(MANSEC)
BINDIR=$(IROOT)/bin
INCDIR=$(IROOT)/include
LIBDIR=$(IROOT)/lib
LIBSIODDIR=$(LIBDIR)/siod
CP_F=cp -f
# -Wmissing-prototypes
GCCW=-Wall -Wstrict-prototypes
#
SAMPLE_OBJS = sample.o slib.o sliba.o trace.o
SIOD_OBJS_COMMON = slib.o sliba.o trace.o slibu.o md5.o \
siod_json.o siod_readline.o baroque.o
HS_REGEX_OBJS=regcomp.o regerror.o regexec.o regfree.o
# Raylib graphics support (optional)
# Check both local build and system installation
RAYLIB_LOCAL := $(shell test -f raylib/build/raylib/libraylib.so && echo yes || echo no)
RAYLIB_SYSTEM := $(shell test -f /usr/local/lib/libraylib.so && echo yes || echo no)
ifeq ($(RAYLIB_LOCAL),yes)
RAYLIB_CFLAGS = -Iraylib/src -DHAVE_RAYLIB
RAYLIB_LDFLAGS = -Lraylib/build/raylib -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
else ifeq ($(RAYLIB_SYSTEM),yes)
RAYLIB_CFLAGS = -I/usr/local/include -DHAVE_RAYLIB
RAYLIB_LDFLAGS = -L/usr/local/lib -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
endif
# PLplot plotting support (optional)
PLPLOT_AVAILABLE := $(shell pkg-config --exists plplot && echo yes || echo no)
ifeq ($(PLPLOT_AVAILABLE),yes)
PLPLOT_CFLAGS := $(shell pkg-config --cflags plplot)
PLPLOT_LIBS := $(shell pkg-config --libs plplot)
else
$(warning PlPlot not found)
endif
CJSON_AVAILABLE := $(shell pkg-config --exists libcjson && echo yes || echo no)
ifeq ($(CJSON_AVAILABLE), yes)
JSON_CFLAGS = `pkg-config --cflags libcjson`
JSON_LDFLAGS = `pkg-config --libs libcjson`
endif
# Readline support (optional but recommended)
# Check if readline is available
READLINE_AVAILABLE := $(shell pkg-config --exists readline && echo yes || echo no)
ifeq ($(READLINE_AVAILABLE),yes)
READLINE_CFLAGS = `pkg-config --cflags readline` -DHAVE_READLINE
READLINE_LDFLAGS = `pkg-config --libs readline`
else
READLINE_CFLAGS =
READLINE_LDFLAGS =
endif
#
#
default:
@echo "*****************************************************"
@echo "* Please specify target from operating system list: *"
@echo "* osf1 hpux solaris linux sgi sco unknown *"
@echo "* gccflags hpuxgcc *"
@echo "*****************************************************"
@echo
@echo " dist ... siod-nt.tar.gz"
@echo " install ... copies to $(BINDIR) etc, see Makefile for doc"
@echo " clean ... delete objects and binaries."
.SUFFIXES: .o .so .man .txt .sl .dylib .smd
# the build_driver is the target of the recursive call to make.
CMDFILES = csiod snapshot-dir snapshot-compare http-get cp-build \
ftp-cp ftp-put ftp-test ftp-get http-stress proxy-server
# Submodule build targets
.PHONY: submodules cqrlib liboctonion symengine raylib-submodule
submodules: cqrlib liboctonion symengine raylib-submodule
cqrlib:
@echo "Building CQRlib submodule..."
cd CQRlib && $(MAKE) clean && $(MAKE) all
@echo "CQRlib build complete."
liboctonion:
@echo "Building LibOctonion submodule..."
cd LibOctonion && $(MAKE) CC=$(CC) CFLAGS="$(CDEBUG) -fPIC -O2"
@echo "LibOctonion build complete."
symengine:
@echo "Building symengine submodule..."
@if [ ! -d "symengine/build" ]; then \
mkdir -p symengine/build; \
fi
cd symengine/build && cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DWITH_LLVM=OFF \
-DWITH_MPFR=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_BENCHMARKS=OFF \
.. && $(MAKE)
@echo "symengine build complete."
raylib-submodule:
@echo "Building raylib submodule..."
@if [ ! -d "raylib/build" ]; then \
mkdir -p raylib/build; \
fi
cd raylib/build && cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DBUILD_EXAMPLES=OFF \
-DBUILD_GAMES=OFF \
.. && $(MAKE)
@echo "raylib build complete."
build_driver: submodules $(PROGS) $(EXTRA_PROGS) $(CMDFILES)
@echo "Build done."
LDLP=LD_LIBRARY_PATH=.:CQRlib/lib/.libs:LibOctonion:symengine/build/symengine:raylib/build/raylib:$$LD_LIBRARY_PATH
SLD=-DSIOD_LIB_DEFAULT=\\\"$(LIBSIODDIR)\\\"
# Tested by DDC on an OrangePi running Linux 6.1.43-rockchip-rk3588
# under Ubuntu 22.04. Additional modules such as ndbm.c
# may work without modification in other environments.
#
# sqllite3 support has been added and tested under the above
#
# uname = Linux
# Build the program list conditionally based on available libraries
LINUX_PROGS = siod tar.so parser_pratt.so ss.so gd.so raylib.so regex.so acct.so sql_sqlite3.so pthreads.so symengine.so
LINUX_EXTRA_PROGS = siod-raylib
ifeq ($(PLPLOT_AVAILABLE),yes)
LINUX_PROGS += plplot.so
endif
linux:
$(MAKE) $(LDLP) \
PROGS="$(LINUX_PROGS)" \
EXTRA_PROGS="$(LINUX_EXTRA_PROGS)" \
CC="gcc" \
LD="gcc" \
CFLAGS="$(GCCW) $(CDEBUG) -fPIC -O2 -D__USE_MISC -D__USE_GNU -D__USE_SVID -D__USE_XOPEN_EXTENDED -D__USE_XOPEN $(SLD) $(READLINE_CFLAGS) -ICQRlib -ILibOctonion -Isymengine -Isymengine/build -Iraylib/src" \
RAYLIB_CFLAGS="-Iraylib/src -DHAVE_RAYLIB" \
RAYLIB_LDFLAGS="-Wl,-rpath=\$$ORIGIN/raylib/build/raylib -Lraylib/build/raylib -lraylib -lGL -lm -lpthread -ldl -lrt -lX11" \
LD_EXE_FLAGS="-rdynamic -Xlinker -rpath -Xlinker $(LIBDIR) -Xlinker -rpath -Xlinker $(LIBSIODDIR) -LCQRlib/lib/.libs -LLibOctonion -Lsymengine/build/symengine -Lraylib/build/raylib" \
LD_EXE_LIBS="-ldl" \
LD_LIB_FLAGS="-shared -LCQRlib/lib/.libs -LLibOctonion -Lsymengine/build/symengine -Lraylib/build/raylib" \
LD_LIB_LIBS="-lm -lc -ldl -lcrypt -lsqlite3 -lpthread -lCQRlib -loct $(JSON_LDFLAGS) $(READLINE_LDFLAGS)" \
SO="so" \
build_driver
# macOS / Darwin
# Install dependencies with: brew install libgd sqlite3
# uname = Darwin
darwin:
$(MAKE) $(LDLP) \
PROGS="siod tar.dylib parser_pratt.dylib ss.dylib gd.dylib raylib.dylib \
regex.dylib sql_sqlite3.dylib pthreads.dylib" \
CC="clang" \
LD="clang" \
CFLAGS="$(GCCW) $(CDEBUG) -Ddarwin -fPIC -O2 $(SLD) -ILibOctonion -Isymengine -Isymengine/build" \
LD_EXE_FLAGS=" -Xlinker -rpath -Xlinker $(LIBDIR) -Xlinker -rpath -Xlinker $(LIBSIODDIR) -LLibOctonion -Lsymengine/build/symengine" \
LD_EXE_LIBS="" \
LD_LIB_FLAGS="-dynamiclib -L/usr/local/lib -LLibOctonion -Lsymengine/build/symengine" \
LD_LIB_LIBS="-lm -lsqlite3 -lpthread -lCQRlib -loct" \
SO="dylib" \
build_driver
macos: darwin
unknown:
-ln -s ssiod siod
$(MAKE) \
PROGS="sample ssiod" \
CFLAGS="$(CDEBUG) -U__osf__ -Usun -USUN5 -Ulinux" \
LD_EXE_LIBS="-lm" \
build_driver
### Finally, the actual compilation and linking commands.
libsiod.$(SO): $(SIOD_OBJS_COMMON)
@echo LD_LIBRARY_PATH = $$LD_LIBRARY_PATH
$(LD) -o libsiod.$(SO) $(LD_LIB_FLAGS) $(SIOD_OBJS_COMMON) \
$(LD_LIB_LIBS)
ssiod: siod.o $(SIOD_OBJS_COMMON)
$(CC) -o ssiod $(LD_EXE_FLAGS) siod.o \
$(SIOD_OBJS_COMMON) $(LD_EXE_LIBS)
siod: siod.o libsiod.$(SO)
$(CC) -o siod $(LD_EXE_FLAGS) siod.o libsiod.$(SO) $(LD_EXE_LIBS) -lCQRlib -loct
# siod-raylib: version with raylib statically linked for graphics examples
siod-raylib: siod.o libsiod.$(SO) raylib.$(SO)
$(CC) -o siod-raylib $(LD_EXE_FLAGS) \
-Wl,-rpath,'$$ORIGIN' -Wl,-rpath,. \
-Wl,-rpath,'$$ORIGIN/CQRlib/lib/.libs' -Wl,-rpath,CQRlib/lib/.libs \
-Wl,-rpath,'$$ORIGIN/LibOctonion' -Wl,-rpath,LibOctonion \
-Wl,-rpath,'$$ORIGIN/symengine/build/symengine' -Wl,-rpath,symengine/build/symengine \
-Wl,-rpath,'$$ORIGIN/raylib/build/raylib' -Wl,-rpath,raylib/build/raylib \
siod.o libsiod.$(SO) raylib.$(SO) \
$(LD_EXE_LIBS) -lCQRlib -loct -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
sample: $(SAMPLE_OBJS)
$(CC) -o sample $(LD_EXE_FLAGS) $(SAMPLE_OBJS) $(LD_EXE_LIBS)
.o.$(SO):
$(LD) -o $@ $(LD_LIB_FLAGS) $< libsiod.$(SO) $(LD_LIB_LIBS)
.o.dylib:
$(LD) -o $@ $(LD_LIB_FLAGS) $< libsiod.dylib $(LD_LIB_LIBS)
#.o.so:
# $(LD) -o $@ $(LD_LIB_FLAGS) $< libsiod.so $(LD_LIB_LIBS)
# Now the build rules for the extensions
tar.$(SO): tar.o libsiod.$(SO)
ss.$(SO): ss.o libsiod.$(SO)
acct.$(SO): acct.o libsiod.$(SO)
# Note: libgd 2.3.3+ from https://libgd.github.io/
gd.o: gd.c
$(CC) $(CFLAGS) `pkg-config --cflags gdlib` -c gd.c
gd.$(SO): gd.o libsiod.$(SO)
$(LD) -o gd.$(SO) $(LD_LIB_FLAGS) gd.o libsiod.$(SO) \
`pkg-config --libs gdlib` $(LD_LIB_LIBS)
# Raylib graphics library integration
raylib.o: raylib.c
$(CC) $(CFLAGS) $(RAYLIB_CFLAGS) -c raylib.c
raylib.$(SO): raylib.o libsiod.$(SO)
$(LD) -o raylib.$(SO) $(LD_LIB_FLAGS) raylib.o libsiod.$(SO) \
$(RAYLIB_LDFLAGS) $(LD_LIB_LIBS)
regex.$(SO): regex.o libsiod.$(SO) $(HS_REGEX_OBJS_NEEDED)
$(LD) -o regex.$(SO) $(LD_LIB_FLAGS) regex.o $(HS_REGEX_OBJS_NEEDED) \
libsiod.$(SO) $(LD_LIB_LIBS)
pthreads.$(SO): pthreads.o libsiod.$(SO)
$(LD) -o pthreads.$(SO) $(LD_LIB_FLAGS) pthreads.o libsiod.$(SO) \
-lpthread $(LD_LIB_LIBS)
sql_sqlite3.$(SO): sql_sqlite3.o libsiod.$(SO)
$(LD) -o sql_sqlite3.$(SO) $(LD_LIB_FLAGS) sql_sqlite3.o libsiod.$(SO) \
-lsqlite3 $(LD_LIB_LIBS)
plplot.$(SO): siod_plplot.o libsiod.$(SO)
$(LD) -o plplot.$(SO) $(LD_LIB_FLAGS) siod_plplot.o libsiod.$(SO) \
-lplplot $(LD_LIB_LIBS)
SYMENGINE_CFLAGS := -Isymengine -Isymengine/build
SYMENGINE_LIBS := -Lsymengine/build/symengine -lsymengine -lstdc++ -lgmp
symengine.o: symengine.c siod.h
$(CC) $(CFLAGS) $(SYMENGINE_CFLAGS) -c symengine.c
symengine.$(SO): symengine.o libsiod.$(SO)
$(LD) -o symengine.$(SO) $(LD_LIB_FLAGS) symengine.o libsiod.$(SO) \
$(SYMENGINE_LIBS) $(LD_LIB_LIBS)
siod_json.o: siod_json.c siod_json.h siod.h
$(CC) $(CFLAGS) $(JSON_CFLAGS) -c siod_json.c
siod_readline.o: siod_readline.c siod_readline.h siod.h
$(CC) $(CFLAGS) $(READLINE_CFLAGS) -c siod_readline.c
siod_plplot.o: siod_plplot.c siod.h
$(CC) $(CFLAGS) $(PLPLOT_CFLAGS) -c siod_plplot.c
baroque.o: baroque.c
$(CC) $(CFLAGS) -c baroque.c
siod.o: siod.c siod.h
sample.o: sample.c siod.h
slib.o: slib.c siod.h siodp.h
sliba.o: sliba.c siod.h siodp.h
trace.o: trace.c siod.h siodp.h
slibu.o: slibu.c siod.h siodp.h md5.h
ss.o: ss.c siod.h ss.h
md5.o: md5.c md5.h
statfs.o: statfs.c siod.h
tar.o: tar.c siod.h
regex.o: regex.c siod.h
acct.o: acct.c siod.h
parser_pratt.o: parser_pratt.c siod.h
MANPAGES = siod snapshot-dir snapshot-compare http-get \
cp-build ftp-cp csiod ftp-put ftp-test ftp-get \
http-stress proxy-server
LIBFILES = http-server.scm http-stress.scm http.scm \
maze-support.scm pratt.scm siod.scm smtp.scm \
cgi-echo.scm find-files.scm \
parser_pratt.scm pop3.scm selfdoc.scm \
sample.c siod.html piechart.scm cgi.scm ftp.scm \
sql_sqlite3-utils.scm gd-utils.scm \
pthreads-utils.scm help.scm qol.scm \
plplot-utils.scm compat.scm
SOLIBFILES=gd tar ss regex acct parser_pratt \
statfs sql_sqlite3 raylib plplot symengine
PUBINCS = siod.h
COMMON_SRCS=README.md siod.c siod.h \
siodm.c siodp.h slib.c sliba.c slibu.c \
ss.c ss.h trace.c md5.c md5.h \
gd.c tar.c regex.c acct.c statfs.c \
parser_pratt.c sql_sqlite3.c siod_readline.c siod_readline.h raylib.c
REGEX_SRCS=siod_regex.html cclass.h regcomp.c regex2.h regfree.c \
cname.h regerror.c utils.h engine.c regex.h regexec.c
UNIX_MK=Makefile
NT_MK=libsiod.def parser_pratt.def \
tar.def ss.def regex.def release.bat
CMDSRCS = $(CMDFILES:=.smd)
SRCFILES= $(COMMON_SRCS) $(UNIX_MK) $(NT_MK) fixcrlf.smd \
siod-dist.sh $(REGEX_SRCS)
DISTFILES= $(CMDSRCS) $(LIBFILES) $(SRCFILES) $(MANPAGES:=.man) \
$(MANPAGES:=.txt)
INTO_BINDIR=$(CMDFILES) siod
INTO_LIBDIR=libsiod.so
install: $(DISTFILES)
@echo "Note: This does not do a build. Only installs what already"
@echo " sits in the directory."
-mkdir -p $(MANDIR)
-mkdir -p $(BINDIR)
-mkdir -p $(LIBDIR)
-mkdir -p $(INCDIR)
-mkdir -p $(LIBSIODDIR)
-for X in $(INTO_BINDIR) ; do \
$(CP_F) $$X $(BINDIR) ;\
done
-for X in $(LIBFILES) ; do \
$(CP_F) $$X $(LIBSIODDIR) ;\
done
-for X in $(SOLIBFILES) ; do \
for E in so ; do \
$(CP_F) $$X.$$E $(LIBSIODDIR) ;\
done ;\
done
-for X in $(INTO_LIBDIR) ; do \
$(CP_F) $$X $(LIBDIR) ;\
done
-for X in $(MANPAGES) ; do \
$(CP_F) $$X.man $(MANDIR)/$$X.$(MANSEC) ;\
done
-for X in $(PUBINCS) ; do \
$(CP_F) $$X $(INCDIR) ;\
done
@echo "Install done."
clean:
-rm -f *.o *.so *.sl *.dylib *~ $(MANPAGES:.man=.txt) so_locations \
siod sample siod.tar siod.tar.gz siod.zip selfdoc.txt TAGS \
*.db *.gif $(CMDFILES)
clean-submodules:
@echo "Cleaning LibOctonion..."
-cd LibOctonion && $(MAKE) clean
@echo "Cleaning symengine..."
-rm -rf symengine/build
@echo "Submodules cleaned."
clean-all: clean clean-submodules
@echo "Complete clean done."
# make manpage txt files for distribution to people who do not have
# nroff.
.man.txt:
nroff -man $< | col -bx > $@
siod.tar: $(DISTFILES)
tar cvf siod.tar $(DISTFILES)
siod.tar.gz: $(DISTFILES)
tar cvf - $(DISTFILES) | gzip -c -v > siod.tar.gz
dist: siod.tar.gz siod.zip
@echo "distribution kit created."
siod.zip: $(DISTFILES)
zip siod.zip $(DISTFILES)
fixcrlf_problems: $(DISTFILES)
./siod -v01,-m2 fixcrlf.smd :action=write $(DISTFILES)
# another case of makefile trouble. I need the binding of $(SO)
# here.
selfdoc:
./selfdoc.scm *.so > selfdoc.txt
#
WIN95BIN=./release/libsiod.dll ./release/libsiod.lib ./release/siod.exe \
./release/parser_pratt.dll
win95bin.zip: $(WIN95BIN)
zip -rj win95bin.zip $(WIN95BIN)
whatsup:
@rlog -R -L RCS/*
csiod: csiod.smd
./siod -v01,-m2 csiod.smd csiod.smd \
:o=csiod :i=$(BINDIR)/siod :p=read
snapshot-dir: snapshot-dir.smd
snapshot-compare: snapshot-compare.smd
http-get: http-get.smd
http-stress: http-stress.smd
cp-build: cp-build.smd
ftp-cp: ftp-cp.smd
ftp-put: ftp-put.smd
ftp-test: ftp-test.smd
ftp-get: ftp-get.smd
proxy-server: proxy-server.smd
gccflags:
@echo "*********************************"
@echo "*** built-in gcc defines are: ***"
gcc -E -dM -x c /dev/null
@echo "*********************************"
# Note: You can use the following default rule in your
# own makefiles, but it doesn't work here until siod has
# been installed to its BINDIR
#
#.smd:
# csiod $< :o=$@
#
.smd:
./siod -v01,-m2 csiod.smd :o=$@ :i=$(BINDIR)/siod $<
# Instead of copying additional files to the winsiod folder
# these rules pull these extra files in.
EXTRA_SRC_FOLDER=../archive
EXTRA_SRC_FILES=acct.c cp-build.smd test-fork.scm \
release.bat \
siod-dist.sh $(MANPAGES:=.man)
$(EXTRA_SRC_FILES):
cp -v $(EXTRA_SRC_FOLDER)/$@ $@