take mass into account
[dosdemo] / Makefile
1 src = $(wildcard src/*.c) $(wildcard src/scr/*.c) $(wildcard src/dos/*.c)
2 asmsrc = $(wildcard src/*.asm) $(wildcard src/scr/*.asm) $(wildcard src/dos/*.asm)
3 obj = $(src:.c=.odj) $(asmsrc:.asm=.odj)
4 dep = $(obj:.odj=.dep)
5 bin = demo.exe
6
7 asmsrc += cspr/dbgfont.asm cspr/confont.asm
8 bindata = data/loading.img
9
10 ifeq ($(findstring COMMAND.COM, $(SHELL)), COMMAND.COM)
11         hostsys = dos
12 else
13         hostsys = unix
14         TOOLPREFIX = i586-pc-msdosdjgpp-
15 endif
16
17 inc = -Isrc -Isrc/scr -Isrc/dos -Ilibs -Ilibs/imago/src -Ilibs/anim/src
18 opt = -O3 -ffast-math -fno-strict-aliasing
19 warn = -pedantic -Wall -Wno-unused-function -Wno-unused-variable
20
21 ifdef RELEASE
22         dbg = -g
23         def = -DNDEBUG -DNO_MUSIC
24 else
25         def = -DNO_MUSIC
26 endif
27 #prof = -pg
28
29 CC = $(TOOLPREFIX)gcc
30 AR = $(TOOLPREFIX)ar
31 CFLAGS = $(warn) -march=pentium $(dbg) $(opt) $(prof) $(inc) $(def)
32 LDFLAGS = libs/imago/imago.dja libs/anim/anim.dja
33
34 ifneq ($(hostsys), dos)
35 .PHONY: all
36 all: data $(bin)
37 endif
38
39 $(bin): $(obj) imago anim
40         $(CC) -o $@ -Wl,-Map=ld.map $(prof) $(obj) $(LDFLAGS)
41
42 %.odj: %.asm
43         nasm -f coff -o $@ $<
44
45 src/data.odj: src/data.asm $(bindata)
46
47 ifneq ($(hostsys), dos)
48 -include $(dep)
49 endif
50
51 %.odj: %.c
52         $(CC) $(CFLAGS) -o $@ -c $<
53
54 %.dep: %.c
55         @echo dep $@
56         @$(CPP) $(CFLAGS) $< -MM -MT $(@:.dep=.odj) >$@
57
58 .PHONY: imago
59 imago:
60         $(MAKE) -C libs/imago -f Makefile
61
62 .PHONY: anim
63 anim:
64         $(MAKE) -C libs/anim -f Makefile
65
66 .PHONY: cleanlibs
67 cleanlibs:
68         $(MAKE) -C libs/imago -f Makefile clean
69         $(MAKE) -C libs/anim -f Makefile clean
70
71 .PHONY: clean
72 .PHONY: cleandep
73
74 ifeq ($(hostsys), dos)
75 clean:
76         del src\*.odj
77         del src\dos\*.odj
78         del $(bin)
79
80 cleandep:
81         del src\*.dep
82         del src\dos\*.dep
83 else
84 clean:
85         rm -f $(obj) $(bin)
86
87 cleandep:
88         rm -f $(dep)
89
90 .PHONY: data
91 data:
92         @tools/procdata
93 endif
94
95 .PHONY: strip
96 strip: $(bin)
97         $(TOOLPREFIX)strip $(bin)