fixed procdata and 32bit build
[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 dbg = -g
20 #prof = -pg
21 warn = -pedantic -Wall -Wno-unused-function -Wno-unused-variable
22 def = -DNO_MUSIC
23
24 CC = $(TOOLPREFIX)gcc
25 AR = $(TOOLPREFIX)ar
26 CFLAGS = $(warn) -march=pentium $(dbg) $(opt) $(prof) $(inc) $(def)
27 LDFLAGS = libs/imago/imago.dja libs/anim/anim.dja
28
29 ifneq ($(hostsys), dos)
30 .PHONY: all
31 all: data $(bin)
32 endif
33
34 $(bin): $(obj) imago anim
35         $(CC) -o $@ -Wl,-Map=ld.map $(prof) $(obj) $(LDFLAGS)
36
37 %.odj: %.asm
38         nasm -f coff -o $@ $<
39
40 src/data.odj: src/data.asm $(bindata)
41
42 ifneq ($(hostsys), dos)
43 -include $(dep)
44 endif
45
46 %.odj: %.c
47         $(CC) $(CFLAGS) -o $@ -c $<
48
49 %.dep: %.c
50         @echo dep $@
51         @$(CPP) $(CFLAGS) $< -MM -MT $(@:.dep=.odj) >$@
52
53 .PHONY: imago
54 imago:
55         $(MAKE) -C libs/imago -f Makefile
56
57 .PHONY: anim
58 anim:
59         $(MAKE) -C libs/anim -f Makefile
60
61 .PHONY: cleanlibs
62 cleanlibs:
63         $(MAKE) -C libs/imago -f Makefile clean
64         $(MAKE) -C libs/anim -f Makefile clean
65
66 .PHONY: clean
67 .PHONY: cleandep
68
69 ifeq ($(hostsys), dos)
70 clean:
71         del src\*.odj
72         del src\dos\*.odj
73         del $(bin)
74
75 cleandep:
76         del src\*.dep
77         del src\dos\*.dep
78 else
79 clean:
80         rm -f $(obj) $(bin)
81
82 cleandep:
83         rm -f $(dep)
84
85 .PHONY: data
86 data:
87         @tools/procdata
88 endif