new build system; package can be built in i386
[drnoksnes] / Makefile
1 #!/usr/bin/make
2
3 CPPFLAGS := -I. $(shell sdl-config --cflags) $(shell pkg-config --cflags x11) -I/usr/include/hgw
4 LDLIBS := -lz $(shell sdl-config --libs) $(shell pkg-config --libs x11) -lpopt -lhgw
5
6 -include config.mk
7
8 # GUI needs this
9 export DESTDIR
10
11 # Configuration settings
12 CONF_BUILD_ASM_CPU=0
13 CONF_BUILD_ASM_SPC700=0
14 CONF_BUILD_ASM_SA1=0    # Still not there
15 CONF_XSP=0
16
17 # Sane defaults (override if needed)
18 ifeq ($(ARCH),armel)
19         CONF_BUILD_ASM_CPU=1
20         CONF_BUILD_ASM_SPC700=1
21         CONF_XSP=1
22         CONF_BUILD_MISC_ROUTINES=misc_armel
23 else ifeq ($(ARCH),i386)
24         CONF_BUILD_MISC_ROUTINES=misc_i386
25 endif
26
27 # SNES stuff
28 OBJS = apu.o c4.o c4emu.o cheats.o cheats2.o clip.o cpu.o cpuexec.o data.o
29 OBJS += dma.o dsp1.o fxemu.o fxinst.o gfx.o globals.o loadzip.o memmap.o netplay.o ppu.o
30 OBJS += sa1.o sdd1.o sdd1emu.o snapshot.o soundux.o spc700.o srtc.o tile.o
31
32 ifeq ($(CONF_BUILD_ASM_CPU), 1)
33         # ASM CPU Core from yoyofr's OpenSnes9X
34         OBJS += os9x_asm_cpu.o os9x_65c816.o
35         CPPFLAGS += -DCONF_BUILD_ASM_CPU=1
36 else
37         OBJS += cpuops.o
38 endif
39
40 ifeq ($(CONF_BUILD_ASM_SPC700), 1)
41         OBJS += spc700a.o
42         CPPFLAGS += -DCONF_BUILD_ASM_SPC700=1
43 endif
44
45 ifeq ($(CONF_BUILD_ASM_SA1), 1)
46         crash
47 else
48         OBJS += sa1cpu.o
49 endif
50
51 ifeq ($(CONF_XSP), 1)
52         CPPFLAGS += -DCONF_XSP=1 $(shell pkg-config --cflags xsp)
53         LDLIBS += $(shell pkg-config --libs xsp)
54 endif
55
56 OBJS += $(CONF_BUILD_MISC_ROUTINES).o
57
58 # from open-whatever sdk
59 OBJS += unzip.o ioapi.o
60 # my extensions to snes9x (speedhacks support)
61 OBJS += hacks.o
62 # the glue code that sticks it all together in a monstruous way
63 OBJS += platform/path.o platform/config.o platform/hgw.o
64 OBJS += platform/sdl.o platform/sdlv.o platform/sdla.o platform/sdli.o
65
66 # automatic dependencies
67 DEPS := $(OBJS:.o=.d)
68
69 all: drnoksnes gui
70
71 clean: gui_clean
72         rm -f drnoksnes *.o *.d platform/*.o platform/*.d
73         rm -f build-stamp configure-stamp
74
75 remake: clean deps all
76
77 -include $(DEPS)
78
79 drnoksnes: $(OBJS)
80         $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
81
82 install: drnoksnes
83         install drnoksnes $(DESTDIR)/usr/games
84         $(MAKE) -C gui install
85
86 deps: $(DEPS)
87 %.d: %.cpp
88         @$(CXX) $(CPPFLAGS) -MM $^ -MF $@ -MT $@ -MT $*.o
89 %.d: %.c
90         @$(CC) $(CPPFLAGS) -MM $^ -MF $@ -MT $@ -MT $*.o
91 %.d: %.s
92         @touch $@
93
94 gui:
95         $(MAKE) -C gui all
96
97 gui_clean:
98         $(MAKE) -C gui clean
99
100 .PHONY: all clean remake deps install gui gui_clean
101