cb6a3d6312be958d13cb7291184217d22cefe102
[dos_sbtest] / Makefile
1 src = $(wildcard src/*.c)
2 ssrc = $(wildcard src/*.s)
3 asmsrc = $(wildcard src/*.asm)
4 obj = $(src:.c=.o) $(ssrc:.s=.o) $(asmsrc:.asm=.o)
5 dep = $(src:.c=.d)
6 bin = sbtest.exe
7
8 ifeq ($(findstring COMMAND.COM, $(SHELL)), COMMAND.COM)
9         hostsys = dos
10 else
11         hostsys = unix
12         TOOLPREFIX = i586-pc-msdosdjgpp-
13 endif
14
15 inc = -Isrc
16 opt = -O3 -ffast-math -fno-strict-aliasing
17 dbg = -g
18 warn = -pedantic -Wall -Wno-unused-function -Wno-unused-variable
19
20 CC = $(TOOLPREFIX)gcc
21 AR = $(TOOLPREFIX)ar
22 CFLAGS = $(warn) -march=pentium $(dbg) $(opt) $(inc)
23 LDFLAGS =
24
25 $(bin): $(obj)
26         $(CC) -o $@ -Wl,-Map=ld.map $(obj) $(LDFLAGS)
27
28 %.o: %.asm
29         nasm -f coff -o $@ $<
30
31 -include $(dep)
32
33 %.o: %.c
34         $(CC) $(CFLAGS) -o $@ -c $<
35
36 %.d: %.c
37         @echo "gen dep $< -> $@" && $(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
38
39 .PHONY: clean
40 .PHONY: cleandep
41
42 ifeq ($(hostsys), dos)
43 clean:
44         del src\*.o
45         del $(bin)
46
47 cleandep:
48         del src\*.d
49 else
50 clean:
51         rm -f $(obj) $(bin)
52
53 cleandep:
54         rm -f $(dep)
55 endif