Skip to content

Commit 8acfd21

Browse files
committed
examples/Makefile: test on windows
- test the Makefile on windows - skip DOS files on OS=Windows_NT - add DLLEXT variable to discriminate .so versus .dll - add export specifier in examples/threads/timer-lib/timer.bas allowing source to be compiled as static or shared (on windows) note: Makfile always compiles as shared
1 parent 202ed75 commit 8acfd21

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

examples/Makefile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
OS := $(shell uname)
1818
ifeq ($(OS),Linux)
1919
EXEEXT :=
20+
DLLEXT := .so
2021
else
2122
EXEEXT := .exe
23+
DLLEXT := .dll
2224
endif
2325

2426
FBC := fbc$(EXEEXT)
@@ -32,7 +34,7 @@ CONSOLE := $(subst .bas,,$(wildcard console/*.bas)) \
3234
$(subst .bas,,$(wildcard console/curses/*.bas)) \
3335
$(subst .bas,,$(wildcard console/caca/*.bas))
3436
DATABASE := $(subst .bas,,$(wildcard database/*.bas))
35-
DLL := dll/dylib dll/libmydll.so dll/test
37+
DLL := dll/dylib dll/libmydll$(DLLEXT) dll/test
3638
DOS := $(subst .bas,,$(wildcard DOS/*.bas))
3739
FILES := $(subst .bas,,$(wildcard files/*.bas files/*/*.bas))
3840
GRAPHICS := $(subst .bas,,$(wildcard graphics/*.bas graphics/*/*.bas))
@@ -46,7 +48,7 @@ NETWORK := $(subst .bas,,$(wildcard network/*.bas network/*/*.bas \
4648
#REGEX := $(subst .bas,,$(wildcard regex/*/*.bas))
4749
SOUND := $(subst .bas,,$(wildcard sound/*/*.bas))
4850
THREADS := $(subst .bas,,$(wildcard threads/*.bas)) \
49-
threads/timer-lib/libtimer.so threads/timer-lib/test
51+
threads/timer-lib/libtimer$(DLLEXT) threads/timer-lib/test
5052
UNICODE := $(subst .bas,,$(wildcard unicode/*.bas))
5153
#WIN32 := $(subst .bas,,$(wildcard sound/*/*.bas))
5254
XML := $(subst .bas,,$(wildcard xml/*.bas))
@@ -86,24 +88,29 @@ checklib.%:
8688
@ldconfig -p | grep "lib$*.so" > /dev/null
8789

8890

89-
dll/libmydll.so: dll/mydll.bas
91+
dll/libmydll$(DLLEXT): dll/mydll.bas
9092
$(FBC) -dylib $<
9193

92-
dll/test: dll/test.bas dll/libmydll.so
94+
dll/test: dll/test.bas dll/libmydll$(DLLEXT)
9395
$(FBC) -p dll dll/test.bas
9496

9597
ifeq ($(OS),Linux)
9698
DOS/%: DOS/%.bas
9799
@echo "SKIP $@ on Linux"
100+
else
101+
ifeq ($(OS),Windows_NT)
102+
DOS/%: DOS/%.bas
103+
@echo "SKIP $@ on Windows"
98104
else
99105
DOS/%: DOS/%.bas
100106
$(FBC) $<
101107
endif
108+
endif
102109

103-
threads/timer-lib/libtimer.so: threads/timer-lib/timer.bas
110+
threads/timer-lib/libtimer$(DLLEXT): threads/timer-lib/timer.bas
104111
$(FBC) -dylib -mt $<
105112

106-
threads/timer-lib/test: threads/timer-lib/test.bas threads/timer-lib/libtimer.so
113+
threads/timer-lib/test: threads/timer-lib/test.bas threads/timer-lib/libtimer$(DLLEXT)
107114
$(FBC) -p $(dir $@) -mt $<
108115

109116
%: %.bas

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

0 commit comments

Comments
 (0)