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