backported fixes from rtxon: BSP tree construction and mouse handling
[dosdemo] / Makefile.dj
1 src = $(wildcard src/*.c) $(wildcard src/dos/*.c)
2 asmsrc = $(wildcard src/*.asm) $(wildcard src/dos/*.asm)
3 obj = $(src:.c=.cof) $(asmsrc:.asm=.cof)
4 dep = $(obj:.cof=.dep)
5 bin = demo.exe
6
7 ifeq ($(findstring COMMAND.COM, $(SHELL)), COMMAND.COM)
8         hostsys = dos
9 else
10         hostsys = unix
11         TOOLPREFIX = i586-pc-msdosdjgpp-
12 endif
13
14 inc = -Isrc -Isrc/dos -Ilibs/imago/src -Ilibs/mikmod/include
15 opt = -O3 -ffast-math -fno-strict-aliasing
16 dbg = -g
17 warn = -pedantic -Wall -Wno-unused-function -Wno-unused-variable
18
19 CC = $(TOOLPREFIX)gcc
20 AR = $(TOOLPREFIX)ar
21 CFLAGS = $(warn) -march=pentium $(dbg) $(opt) $(inc)
22 LDFLAGS = libs/imago/imago.dja libs/mikmod/dos/libmikmod.a
23
24 $(bin): $(obj) imago mikmod
25         $(CC) -o $@ -Wl,-Map=ld.map $(obj) $(LDFLAGS)
26
27 %.cof: %.asm
28         nasm -f coff -o $@ $<
29
30 -include $(dep)
31
32 %.cof: %.c
33         $(CC) $(CFLAGS) -o $@ -c $<
34
35 %.dep: %.c
36         @$(CPP) $(CFLAGS) $< -MM -MT $(@:.dep=.cof) >$@
37
38 .PHONY: imago
39 imago:
40         $(MAKE) -C libs/imago -f Makefile.dj
41
42 .PHONY: mikmod
43 mikmod:
44         $(MAKE) -C libs/mikmod/dos -f Makefile.dj
45
46 .PHONY: cleanlibs
47 cleanlibs:
48         $(MAKE) -C libs/imago -f Makefile.dj clean
49         $(MAKE) -C libs/mikmod/dos -f Makefile.dj clean
50
51 .PHONY: clean
52 .PHONY: cleandep
53
54 ifeq ($(hostsys), dos)
55 clean:
56         del src\*.cof
57         del src\dos\*.cof
58         del $(bin)
59
60 cleandep:
61         del src\*.dep
62         del src\dos\*.dep
63 else
64 clean:
65         rm -f $(obj) $(bin)
66
67 cleandep:
68         rm -f $(dep)
69 endif