Skip to content

Commit 7549ea7

Browse files
committed
examples: Add makefile for all examples
When reading the examples, it's helpful to have them compiled already to compare output. This makefile attempts to compile as many examples as possible and ignores failures due to missing libraries or different targets.
1 parent 4aa649a commit 7549ea7

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

examples/Makefile

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/usr/bin/make -f
2+
#
3+
# examples makefile - attempts to build all examples
4+
#
5+
# Several examples will not build if their libraries are not
6+
# present.
7+
#
8+
# To make all examples:
9+
# $ make
10+
# To make a subset, use the dirname in lower case
11+
# $ make unicode
12+
#
13+
# If fbc[.exe] is not in your path, pass it to make
14+
# $ make FBC=d:/path/to/fbc
15+
#
16+
17+
OS := $(shell uname)
18+
ifeq ($(OS),Linux)
19+
EXEEXT :=
20+
else
21+
EXEEXT := .exe
22+
endif
23+
24+
FBC := fbc$(EXEEXT)
25+
STOP_ON_ERROR := n
26+
27+
28+
29+
BASICS := $(subst .bas,,$(wildcard *.bas))
30+
COMPRESSION := $(subst .bas,,$(wildcard compression/*.bas))
31+
CONSOLE := $(subst .bas,,$(wildcard console/*.bas)) \
32+
$(subst .bas,,$(wildcard console/curses/*.bas)) \
33+
$(subst .bas,,$(wildcard console/caca/*.bas))
34+
DATABASE := $(subst .bas,,$(wildcard database/*.bas))
35+
DLL := dll/dylib dll/libmydll.so dll/test
36+
DOS := $(subst .bas,,$(wildcard DOS/*.bas))
37+
FILES := $(subst .bas,,$(wildcard files/*.bas files/*/*.bas))
38+
GRAPHICS := $(subst .bas,,$(wildcard graphics/*.bas graphics/*/*.bas))
39+
GUI := $(subst .bas,,$(wildcard GUI/*/*.bas GUI/*/*/*.bas))
40+
MANUAL := $(subst .bas,,$(wildcard manual/*.bas manual/*/*.bas))
41+
MATH := $(subst .bas,,$(wildcard math/*.bas math/*/*.bas))
42+
MISC := $(subst .bas,,$(wildcard misc/*/*.bas))
43+
NETWORK := $(subst .bas,,$(wildcard network/*.bas network/*/*.bas \
44+
network/*/*/*.bas))
45+
#OPTIMIZE := $(subst .bas,,$(wildcard OptimizePureAbstractTypes/*.bas))
46+
#REGEX := $(subst .bas,,$(wildcard regex/*/*.bas))
47+
SOUND := $(subst .bas,,$(wildcard sound/*/*.bas))
48+
THREADS := $(subst .bas,,$(wildcard threads/*.bas)) \
49+
threads/timer-lib/libtimer.so threads/timer-lib/test
50+
UNICODE := $(subst .bas,,$(wildcard unicode/*.bas))
51+
#WIN32 := $(subst .bas,,$(wildcard sound/*/*.bas))
52+
XML := $(subst .bas,,$(wildcard xml/*.bas))
53+
54+
55+
ALL_FILES := \
56+
$(BASICS) $(COMPRESSION) $(CONSOLE) $(DATABASE) \
57+
$(DLL) $(DOS) $(FILES) $(GRAPHICS) $(GUI) $(MANUAL) \
58+
$(MATH) $(MISC) $(NETWORK) $(OPTIMIZE) $(SOUND) \
59+
$(THREADS) $(UNICODE) $(XML)
60+
61+
all: $(ALL_FILES)
62+
63+
basics: $(BASICS)
64+
compression: $(COMPRESSION)
65+
console: $(CONSOLE)
66+
database: $(DATABASE)
67+
dll: $(DLL)
68+
dos: $(DOS)
69+
files: $(FILES)
70+
graphics: $(GRAPHICS)
71+
gui: $(GUI)
72+
manual: $(MANUAL)
73+
math: $(MATH)
74+
misc: $(MISC)
75+
#network: checklib.curl checklib.CHttp .WAIT $(NETWORK)
76+
network: $(NETWORK)
77+
optimize: $(OPTIMIZE)
78+
sound: $(SOUND)
79+
threads: $(THREADS)
80+
unicode: $(UNICODE)
81+
xml: $(XML)
82+
83+
84+
checklib.%:
85+
@echo check library: "lib$*"
86+
@ldconfig -p | grep "lib$*.so" > /dev/null
87+
88+
89+
dll/libmydll.so: dll/mydll.bas
90+
$(FBC) -dylib $<
91+
92+
dll/test: dll/test.bas dll/libmydll.so
93+
$(FBC) -p dll dll/test.bas
94+
95+
ifeq ($(OS),Linux)
96+
DOS/%: DOS/%.bas
97+
@echo "SKIP $@ on Linux"
98+
else
99+
DOS/%: DOS/%.bas
100+
$(FBC) $<
101+
endif
102+
103+
threads/timer-lib/libtimer.so: threads/timer-lib/timer.bas
104+
$(FBC) -dylib -mt $<
105+
106+
threads/timer-lib/test: threads/timer-lib/test.bas threads/timer-lib/libtimer.so
107+
$(FBC) -p $(dir $@) -mt $<
108+
109+
%: %.bas
110+
ifeq ($(STOP_ON_ERROR),n)
111+
@echo fbc -p $(dir $@) $<
112+
@$(FBC) -p $(dir $@) $< || \
113+
echo "Failed to compile '$<' - check for missing libraries"
114+
else
115+
$(FBC) -p $(dir $@) $<
116+
endif
117+
118+
clean:
119+
@echo CLEAN binary files
120+
@rm -fv $(ALL_FILES)

0 commit comments

Comments
 (0)