Skip to content

Commit e72986a

Browse files
authored
Merge pull request #438 from thekhalifa/feat-examples-makefile
Add examples makefile
2 parents 4aa649a + 8acfd21 commit e72986a

File tree

4 files changed

+136
-9
lines changed

4 files changed

+136
-9
lines changed

examples/Makefile

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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+
DLLEXT := .so
21+
else
22+
EXEEXT := .exe
23+
DLLEXT := .dll
24+
endif
25+
26+
FBC := fbc$(EXEEXT)
27+
STOP_ON_ERROR := n
28+
29+
30+
31+
BASICS := $(subst .bas,,$(wildcard *.bas))
32+
COMPRESSION := $(subst .bas,,$(wildcard compression/*.bas))
33+
CONSOLE := $(subst .bas,,$(wildcard console/*.bas)) \
34+
$(subst .bas,,$(wildcard console/curses/*.bas)) \
35+
$(subst .bas,,$(wildcard console/caca/*.bas))
36+
DATABASE := $(subst .bas,,$(wildcard database/*.bas))
37+
DLL := dll/dylib dll/libmydll$(DLLEXT) dll/test
38+
DOS := $(subst .bas,,$(wildcard DOS/*.bas))
39+
FILES := $(subst .bas,,$(wildcard files/*.bas files/*/*.bas))
40+
GRAPHICS := $(subst .bas,,$(wildcard graphics/*.bas graphics/*/*.bas))
41+
GUI := $(subst .bas,,$(wildcard GUI/*/*.bas GUI/*/*/*.bas))
42+
MANUAL := $(subst .bas,,$(wildcard manual/*.bas manual/*/*.bas))
43+
MATH := $(subst .bas,,$(wildcard math/*.bas math/*/*.bas))
44+
MISC := $(subst .bas,,$(wildcard misc/*/*.bas))
45+
NETWORK := $(subst .bas,,$(wildcard network/*.bas network/*/*.bas \
46+
network/*/*/*.bas))
47+
#OPTIMIZE := $(subst .bas,,$(wildcard OptimizePureAbstractTypes/*.bas))
48+
#REGEX := $(subst .bas,,$(wildcard regex/*/*.bas))
49+
SOUND := $(subst .bas,,$(wildcard sound/*/*.bas))
50+
THREADS := $(subst .bas,,$(wildcard threads/*.bas)) \
51+
threads/timer-lib/libtimer$(DLLEXT) threads/timer-lib/test
52+
UNICODE := $(subst .bas,,$(wildcard unicode/*.bas))
53+
#WIN32 := $(subst .bas,,$(wildcard sound/*/*.bas))
54+
XML := $(subst .bas,,$(wildcard xml/*.bas))
55+
56+
57+
ALL_FILES := \
58+
$(BASICS) $(COMPRESSION) $(CONSOLE) $(DATABASE) \
59+
$(DLL) $(DOS) $(FILES) $(GRAPHICS) $(GUI) $(MANUAL) \
60+
$(MATH) $(MISC) $(NETWORK) $(OPTIMIZE) $(SOUND) \
61+
$(THREADS) $(UNICODE) $(XML)
62+
63+
all: $(ALL_FILES)
64+
65+
basics: $(BASICS)
66+
compression: $(COMPRESSION)
67+
console: $(CONSOLE)
68+
database: $(DATABASE)
69+
dll: $(DLL)
70+
dos: $(DOS)
71+
files: $(FILES)
72+
graphics: $(GRAPHICS)
73+
gui: $(GUI)
74+
manual: $(MANUAL)
75+
math: $(MATH)
76+
misc: $(MISC)
77+
#network: checklib.curl checklib.CHttp .WAIT $(NETWORK)
78+
network: $(NETWORK)
79+
optimize: $(OPTIMIZE)
80+
sound: $(SOUND)
81+
threads: $(THREADS)
82+
unicode: $(UNICODE)
83+
xml: $(XML)
84+
85+
86+
checklib.%:
87+
@echo check library: "lib$*"
88+
@ldconfig -p | grep "lib$*.so" > /dev/null
89+
90+
91+
dll/libmydll$(DLLEXT): dll/mydll.bas
92+
$(FBC) -dylib $<
93+
94+
dll/test: dll/test.bas dll/libmydll$(DLLEXT)
95+
$(FBC) -p dll dll/test.bas
96+
97+
ifeq ($(OS),Linux)
98+
DOS/%: DOS/%.bas
99+
@echo "SKIP $@ on Linux"
100+
else
101+
ifeq ($(OS),Windows_NT)
102+
DOS/%: DOS/%.bas
103+
@echo "SKIP $@ on Windows"
104+
else
105+
DOS/%: DOS/%.bas
106+
$(FBC) $<
107+
endif
108+
endif
109+
110+
threads/timer-lib/libtimer$(DLLEXT): threads/timer-lib/timer.bas
111+
$(FBC) -dylib -mt $<
112+
113+
threads/timer-lib/test: threads/timer-lib/test.bas threads/timer-lib/libtimer$(DLLEXT)
114+
$(FBC) -p $(dir $@) -mt $<
115+
116+
%: %.bas
117+
ifeq ($(STOP_ON_ERROR),n)
118+
@echo fbc -p $(dir $@) $<
119+
@$(FBC) -p $(dir $@) $< || \
120+
echo "Failed to compile '$<' - check for missing libraries"
121+
else
122+
$(FBC) -p $(dir $@) $<
123+
endif
124+
125+
clean:
126+
@echo CLEAN binary files
127+
@rm -fv $(ALL_FILES)

examples/compression/libzip.bas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ End Sub
2424

2525
'' Asks libzip for information on file number 'i' in the .zip file,
2626
'' and then extracts it, while creating directories as needed.
27-
Private Sub unpack_zip_file(ByVal zip As zip Ptr, ByVal i As Integer)
27+
Private Sub unpack_zip_file(ByVal zip As zip_t Ptr, ByVal i As Integer)
2828
#define BUFFER_SIZE (1024 * 512)
2929
Static As UByte chunk(0 To (BUFFER_SIZE - 1))
3030
#define buffer (@chunk(0))
@@ -58,7 +58,7 @@ Private Sub unpack_zip_file(ByVal zip As zip Ptr, ByVal i As Integer)
5858
End If
5959

6060
'' Input for the file comes from libzip
61-
Dim As zip_file Ptr fi = zip_fopen_index(zip, i, 0)
61+
Dim As zip_file_t Ptr fi = zip_fopen_index(zip, i, 0)
6262
Do
6363
'' Write out the file content as returned by zip_fread(), which
6464
'' also does the decoding and everything.
@@ -88,7 +88,7 @@ Private Sub unpack_zip_file(ByVal zip As zip Ptr, ByVal i As Integer)
8888
End Sub
8989

9090
Sub unpack_zip(ByRef archive As String)
91-
Dim As zip Ptr zip = zip_open(archive, ZIP_CHECKCONS, NULL)
91+
Dim As zip_t Ptr zip = zip_open(archive, ZIP_CHECKCONS, NULL)
9292
If (zip = NULL) Then
9393
Print "could not open input file " & archive
9494
Return

examples/threads/timer-lib/timer.bas

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include once "timer.bi"
88

9-
sub CTimer.threadcb( byval ctx as CTimer ptr )
9+
sub CTimer.threadcb( byval ctx as CTimer ptr ) export
1010
do
1111
select case ctx->state
1212
case TIMER_STATE_EXITING
@@ -43,7 +43,7 @@ constructor CTimer _
4343
byval interval as integer, _
4444
byval callback as TIMER_CALLBACK, _
4545
byval userdata as integer = 0 _
46-
)
46+
) export
4747
this.state = TIMER_STATE_STOPPED
4848
this.interval = interval
4949
this.callback = callback
@@ -54,7 +54,7 @@ constructor CTimer _
5454
this.waiting = -1
5555
end constructor
5656

57-
sub CTimer.on( )
57+
sub CTimer.on( ) export
5858
if( this.state = TIMER_STATE_KILLED ) then
5959
exit sub
6060
end if
@@ -66,14 +66,14 @@ sub CTimer.on( )
6666
mutexunlock( this.cond_mutex )
6767
end sub
6868

69-
sub CTimer.off( )
69+
sub CTimer.off( ) export
7070
if( this.state = TIMER_STATE_KILLED ) then
7171
exit sub
7272
end if
7373
this.state = TIMER_STATE_STOPPED
7474
end sub
7575

76-
destructor CTimer( )
76+
destructor CTimer( ) export
7777
if( this.state = TIMER_STATE_KILLED ) then
7878
return
7979
end if

inc/quicklz.bi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type ui16 as ushort
6767
#endif
6868

6969
' Detect if pointer size is 64-bit. It's not fatal if some 64-bit target is not detected because this is only for adding an optional 64-bit optimization.
70-
#if __FB_64BIT__
70+
#if defined(__FB_64BIT__)
7171
#define QLZ_PTR_64
7272
#endif
7373

0 commit comments

Comments
 (0)