workaround a problem with the harmattan gcc
[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 else ifeq ($(ARCH),amd64)
21         CONF_BUILD_ASM_CPU?=0
22         CONF_BUILD_ASM_SPC700?=0
23         CONF_BUILD_ASM_SA1?=0
24         CONF_BUILD_MISC_ROUTINES?=misc_amd64
25 endif
26 # PNG screenshot support (requires libpng)
27 CONF_PNG?=1
28 # Hardware pixel doubling (in N8x0)
29 CONF_XSP?=0
30 # Hildon Desktop compositing (in Fremantle)
31 CONF_HD?=0
32 # Link to libzeemote
33 CONF_ZEEMOTE?=0
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 font.o fxemu.o fxinst.o gfx.o globals.o loadzip.o memmap.o 
38 OBJS += ppu.o 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
67 OBJS += platform/sdl.o platform/sdlv.o platform/sdla.o platform/sdli.o
68 OBJS += platform/sdlvscalers.o
69
70 ifeq ($(CONF_PNG), 1)
71         CPPFLAGS += -DCONF_PNG=1 $(shell pkg-config --cflags libpng)
72         LDLIBS += $(shell pkg-config --libs libpng)
73         OBJS += screenshot.o
74 endif
75 ifeq ($(CONF_XSP), 1)
76         CPPFLAGS += -DCONF_XSP=1 $(shell pkg-config --cflags xsp)
77         LDLIBS += $(shell pkg-config --libs xsp)
78 endif
79 ifeq ($(CONF_HD), 1)
80         CPPFLAGS += -DCONF_HD=1
81         LDLIBS += -lSDL_haa
82         CONF_EXIT_BUTTON ?= 1
83 endif
84 ifeq ($(CONF_GUI), 1)
85         CPPFLAGS += -DCONF_GUI=1 $(shell pkg-config --cflags libosso gconf-2.0)
86         LDLIBS += $(shell pkg-config --libs libosso gconf-2.0)
87         OBJS += platform/osso.o
88 endif
89 ifeq ($(CONF_EXIT_BUTTON), 1)
90         CPPFLAGS += -DCONF_EXIT_BUTTON=1
91         LDLIBS += -lSDL_image
92         OBJS += platform/sdlvexit.o
93 endif
94 ifeq ($(CONF_ZEEMOTE), 1)
95         CPPFLAGS += -DCONF_ZEEMOTE=1
96         LDLIBS += -lzeemote -lzeemote-conf -lbluetooth
97         OBJS += platform/zeemote.o
98 endif
99
100 # automatic dependencies
101 DEPS := $(OBJS:.o=.d)
102
103 all: drnoksnes
104
105 clean:
106         rm -f drnoksnes *.o *.d platform/*.o platform/*.d
107         rm -f build-stamp configure-stamp
108         echo "$(OBJS)"
109
110 remake: clean deps all
111
112 -include $(DEPS)
113
114 drnoksnes: $(OBJS)
115         $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
116
117 install: drnoksnes
118         install drnoksnes $(DESTDIR)/usr/games
119
120 deps: $(DEPS)
121 %.d: %.cpp
122         @$(CXX) $(CPPFLAGS) -MM $^ -MF $@ -MT $@ -MT $*.o
123 %.d: %.c
124         @$(CC) $(CPPFLAGS) -MM $^ -MF $@ -MT $@ -MT $*.o
125 %.d: %.s
126         @touch $@
127
128 # GUI
129 gui:
130         $(MAKE) -C gui all
131
132 gui_clean:
133         $(MAKE) -C gui clean
134         
135 gui_install:
136         $(MAKE) -C gui install DESTDIR="$(DESTDIR)"
137         
138 ifeq ($(CONF_GUI), 1)
139 all: gui
140 clean: gui_clean
141 install: gui_install
142 endif
143
144 profclean: clean
145         find . -name '*.gcno' -delete
146         find . -name '*.gcda' -delete
147
148 distclean: profclean clean
149         rm -f config.mk
150
151 .PHONY: all clean remake deps install gui gui_clean distclean
152