random bug fixes
[drnoksnes] / Makefile
1 #!/usr/bin/make
2
3 CPPFLAGS := -I. $(shell sdl-config --cflags) $(shell pkg-config --cflags x11)
4 LDLIBS := -lz $(shell sdl-config --libs) $(shell pkg-config --libs x11) -lpopt
5
6 -include config.mk
7
8 # Sane defaults
9 CONF_GUI?=1
10 ifeq ($(ARCH),armel)
11         CONF_BUILD_ASM_CPU?=1
12         CONF_BUILD_ASM_SPC700?=1
13         CONF_BUILD_ASM_SA1?=0   # Still not there
14         CONF_BUILD_MISC_ROUTINES?=misc_armel
15 else ifeq ($(ARCH),i386)
16         CONF_BUILD_ASM_CPU?=0
17         CONF_BUILD_ASM_SPC700?=0
18         CONF_BUILD_ASM_SA1?=0
19         CONF_BUILD_MISC_ROUTINES?=misc_i386
20 endif
21 # Hardware pixel doubling (in N8x0)
22 CONF_XSP?=0
23 # Hildon Desktop compositing (in Fremantle)
24 CONF_HD?=0
25
26 # SNES stuff
27 OBJS = apu.o c4.o c4emu.o cheats.o cheats2.o clip.o cpu.o cpuexec.o data.o
28 OBJS += dma.o dsp1.o font.o fxemu.o fxinst.o gfx.o globals.o loadzip.o memmap.o 
29 OBJS += ppu.o sa1.o sdd1.o sdd1emu.o snapshot.o soundux.o spc700.o srtc.o tile.o
30
31 ifeq ($(CONF_BUILD_ASM_CPU), 1)
32         # ASM CPU Core from yoyofr's OpenSnes9X
33         OBJS += os9x_asm_cpu.o os9x_65c816.o
34         CPPFLAGS += -DCONF_BUILD_ASM_CPU=1
35 else
36         OBJS += cpuops.o
37 endif
38
39 ifeq ($(CONF_BUILD_ASM_SPC700), 1)
40         OBJS += spc700a.o
41         CPPFLAGS += -DCONF_BUILD_ASM_SPC700=1
42 endif
43
44 ifeq ($(CONF_BUILD_ASM_SA1), 1)
45         crash
46 else
47         OBJS += sa1cpu.o
48 endif
49
50 OBJS += $(CONF_BUILD_MISC_ROUTINES).o
51
52 # from open-whatever sdk
53 OBJS += unzip.o ioapi.o
54 # my extensions to snes9x (speedhacks support)
55 OBJS += hacks.o
56 # the glue code that sticks it all together in a monstruous way
57 OBJS += platform/path.o platform/config.o
58 OBJS += platform/sdl.o platform/sdlv.o platform/sdla.o platform/sdli.o
59 OBJS += platform/sdlvscalers.o
60
61 ifeq ($(CONF_XSP), 1)
62         CPPFLAGS += -DCONF_XSP=1 $(shell pkg-config --cflags xsp)
63         LDLIBS += $(shell pkg-config --libs xsp)
64 endif
65 ifeq ($(CONF_HD), 1)
66         CPPFLAGS += -DCONF_HD=1
67         LDLIBS += -lSDL_haa
68         CONF_EXIT_BUTTON ?= 1
69 endif
70 ifeq ($(CONF_GUI), 1)
71         CPPFLAGS += -DCONF_GUI=1 $(shell pkg-config --cflags libosso gconf-2.0)
72         LDLIBS += $(shell pkg-config --libs libosso gconf-2.0)
73         OBJS += platform/osso.o
74 endif
75 ifeq ($(CONF_EXIT_BUTTON), 1)
76         CPPFLAGS += -DCONF_EXIT_BUTTON=1
77         LDLIBS += -lSDL_image
78         OBJS += platform/sdlvexit.o
79 endif
80
81 # automatic dependencies
82 DEPS := $(OBJS:.o=.d)
83
84 all: drnoksnes
85
86 clean:
87         rm -f drnoksnes *.o *.d platform/*.o platform/*.d
88         rm -f build-stamp configure-stamp
89
90 remake: clean deps all
91
92 -include $(DEPS)
93
94 drnoksnes: $(OBJS)
95         $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
96
97 install: drnoksnes
98         install drnoksnes $(DESTDIR)/usr/games
99
100 deps: $(DEPS)
101 %.d: %.cpp
102         @$(CXX) $(CPPFLAGS) -MM $^ -MF $@ -MT $@ -MT $*.o
103 %.d: %.c
104         @$(CC) $(CPPFLAGS) -MM $^ -MF $@ -MT $@ -MT $*.o
105 %.d: %.s
106         @touch $@
107
108 # GUI
109 gui:
110         $(MAKE) -C gui all
111
112 gui_clean:
113         $(MAKE) -C gui clean
114         
115 gui_install:
116         $(MAKE) -C gui install DESTDIR="$(DESTDIR)"
117         
118 ifeq ($(CONF_GUI), 1)
119 all: gui
120 clean: gui_clean
121 install: gui_install
122 endif
123
124 distclean: clean
125         rm -f config.mk
126
127 .PHONY: all clean remake deps install gui gui_clean distclean
128