1015733ce33dca8d2a0248e4b4f185fa9640cc3b
[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 AS = $(TOOLPREFIX)as
21 CC = $(TOOLPREFIX)gcc
22 AR = $(TOOLPREFIX)ar
23 CFLAGS = $(warn) -march=pentium $(dbg) $(opt) $(inc)
24 LDFLAGS =
25
26 $(bin): $(obj)
27         $(CC) -o $@ -Wl,-Map=ld.map $(obj) $(LDFLAGS)
28
29 %.o: %.asm
30         nasm -f coff -o $@ $<
31
32 -include $(dep)
33
34 %.o: %.c
35         $(CC) $(CFLAGS) -o $@ -c $<
36
37 %.d: %.c
38         @echo "gen dep $< -> $@" && $(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
39
40 .PHONY: clean
41 .PHONY: cleandep
42
43 ifeq ($(hostsys), dos)
44 clean:
45         del src\*.o
46         del $(bin)
47
48 cleandep:
49         del src\*.d
50 else
51 clean:
52         rm -f $(obj) $(bin)
53
54 cleandep:
55         rm -f $(dep)
56 endif