Basilisk source code (http://basilisk.fr/src/)

root / src / Makefile.defs

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
# -*-Makefile-*-

PNG = png
GENSUM = md5sum
CHECKSUM = md5sum -c --status

include $(BASILISK)/config
include Makefile.tests

export GENSUM
export CHECKSUM
export CC99
export CFLAGS
export CC

QCC = $(BASILISK)/qcc

check: $(subst .c,.tst,$(filter-out $(TESTS),$(filter-out $(EXCLUDE),$(ALLTESTS)))) Makefile.deps

tags: $(subst .page,.tags,$(ALLPAGES))

itags: $(subst .h.page,.h.itags,$(ALLPAGES))

links:
	sh $(BASILISK)/links.sh

clean:
	rm -f *.o *.s *.*tst *.d *.prof Makefile.deps

.PRECIOUS: %.prof %.s %.c %.h %.plot

.DELETE_ON_ERROR:

%.3D.c: %.c
	ln -s $< $@

%.3D.tst: %.3D.s %.3D.c
	@CFLAGS="$(CFLAGS) -grid=octree" LIBS="$(LIBS)" OPENGLIBS="$(OPENGLIBS)"\
		$(BASILISK)/runtest $@

%.CADNA.c: %.c
	ln -s $< $@

%.CADNA.tst: %.CADNA.s %.CADNA.c
	@CFLAGS="$(CFLAGS) -cadna" LIBS="$(LIBS) $(CADNALIBS)" OPENGLIBS="$(OPENGLIBS)"\
		$(BASILISK)/runtest $@

%.tst: %.s %.c
	@PNG=$(PNG) LIBS="$(LIBS)" OPENGLIBS="$(OPENGLIBS)" \
		$(BASILISK)/runtest $@

%.ctst: %.s %.c
	@PNG=$(PNG) LIBS="$(LIBS)" OPENGLIBS="$(OPENGLIBS)" \
		CFLAGS="-grid=multigrid $(CFLAGS)" \
		$(BASILISK)/runtest $@

%.vtst: %.s %.c
	@PNG=$(PNG) LIBS="$(LIBS)" OPENGLIBS="$(OPENGLIBS)" \
		EXEC="$(VALGRIND)" \
		$(BASILISK)/runtest $@

%.h: %.h.page
	ln -s $< $@

%.c: %.c.page
	ln -s $< $@

%.plot: %.plot.page
	ln -s $< $@

%.3D.s: %.3D.c $(QCC) Makefile
	@echo qcc -autolink $(CFLAGS) -grid=octree -o $*/$* $*.c $(LIBS) -lm
	@rm -f $*/warn
	@OPENGLIBS="$(OPENGLIBS)" $(QCC) -autolink -nolineno $(STRIPFLAGS) $(subst -g ,,$(subst -O2 ,,$(CFLAGS) -grid=octree)) $< -o $@ $(LIBS) -lm

%.s: %.c $(QCC) Makefile
	@echo qcc -autolink $(CFLAGS) -o $*/$* $*.c $(LIBS) -lm
	@rm -f $*/warn
	@OPENGLIBS="$(OPENGLIBS)" $(QCC) -autolink -nolineno $(STRIPFLAGS) $(subst -g ,,$(subst -O2 ,,$(CFLAGS))) $< -o $@ $(LIBS) -lm

%.prof: %.c
	$(QCC) -autolink $(subst -DTRASH=1,,$(CFLAGS)) -g -pg $< -o $*/$* -lm
	cd $* && ./$* 2> log > out
	gprof $*/$* $*/gmon.out > $@

%.dot: %.prof
	gprof2dot.py < $< > $@

%.dot.png: %.dot
	dot -Tpng -o $@ < $<

%/plot.png: %.plot
	cd $* && gnuplot -e "batch=1; PNG=\"$(PNG)\"; set term $(PNG) enhanced font \",10\"; set output 'plot.png'; set macros;" ../$< || rm -f plot.png

%/plots: %.c
	cd $* && awk -f $(BASILISK)/gnuplot.awk < ../$*.c > plots && \
	PNG=$(PNG) sh $(BASILISK)/gnuplot.sh || rm -f plots
	cd $* && awk -f $(BASILISK)/python.awk < ../$*.c > plots.py && \
	python plots.py || rm -f plots
	@test -f $*/plots || exit 1

%.gnu: %.eps
	pstoedit -f gnuplot -flat 0.1 $< $@

%.pdf: %.h
	pandoc -o $@ $<

%.pdf: %.c
	pandoc -o $@ $<

%.tags: %.page $(QCC)
	$(QCC) -tags $<
	( ! test -d $(BASILISK_WIKI)/cache ) || \
	rm -f $(subst $(BASILISK_WIKI),$(BASILISK_WIKI)/cache,$(PWD))/$<

%.itags: %.tags $(subst .page,.tags,$(ALLPAGES)) $(BASILISK)/includedin.sh
	sh $(BASILISK)/includedin.sh $* > $@
	rm -f $*.html
	( ! test -d $(BASILISK_WIKI)/cache ) || \
	rm -f $(subst $(BASILISK_WIKI),$(BASILISK_WIKI)/cache,$(PWD))/$(subst .tags,.page,$<)

# lists external symbols of executables
extern = nm -u $(1) | sed -n 's/^[ ]*U \(.*\)/\1/p' | sort | uniq

whitelist: $(subst .c,.exe,$(filter-out $(EXCLUDE),$(ALLTESTS))) \
	$(subst .ctst,.cexe,$(SPECIAL_TESTS))
	@echo "updating whitelist"
	@$(call extern,$^) > whitelist

# checks that an executable only links against whitelisted external symbols
%.wexe: %.exe
	@( $(call extern,$<) | diff $(BASILISK)/test/whitelist - | \
		(sed -n 's/^> *\(.*\)/error: \1 not whitelisted/p') | \
		grep 'not whitelisted' && rm -f $@ ) || cp -f $< $@
	@test -f $@

# python modules
%.i: %.c $(QCC) $(BASILISK)/python.h
	$(QCC) $(CFLAGS) -python -c $(MDFLAGS) -I$(PYTHONINCLUDE) $<

%.py: %.i
	swig -I$(BASILISK) -python $(subst python3,-py3,$(findstring python3, $(PYTHONINCLUDE))) $*.i
	$(CC) $(CFLAGS) -c $(MDFLAGS) -I$(PYTHONINCLUDE) $*_wrap.c
	$(CC) -shared $*.o $*_wrap.o -o _$*.so

# HTML
%.html: %.page %.tags $(BASILISK)/Makefile.defs 	\
		$(BASILISK)/templates/page.static 	\
		$(BASILISK)/plugins/literate-c		\
		$(BASILISK)/plugins/codeblock		\
		$(BASILISK)/page2html
	$(BASILISK)/page2html $< > $@
	@test -s $@ || exit 1

LINKCHECKER = linkchecker --no-warnings --no-status --anchors	\
	--ignore-url='.*/$$'					\
	--ignore-url='http://groups.google.com/'		\
	--ignore-url='http://basilisk.fr/_'

%.html.check: %.html
	$(LINKCHECKER) -r 1 $<

# generated makefiles
Makefile.tests: Makefile $(BASILISK)/tests.sh
	sh $(BASILISK)/tests.sh

%.s.d: %.c $(QCC)
	$(QCC) -MD -o $@ $<

%.tags.d: %.page $(QCC)
	$(QCC) -MD -tags $<

Makefile.deps: 	Makefile.tests \
		$(subst .c,.s.d,$(filter-out $(EXCLUDE),$(ALLTESTS) $(TESTS))) \
		$(subst .page,.tags.d,$(ALLPAGES))
	@echo "updating Makefile.deps"
	@cat /dev/null $^ > Makefile.deps

include Makefile.deps