ebda569801cbd78d74258d152261c02c159c5d49
[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 # Hardware pixel doubling (in N8x0)
27 CONF_XSP?=0
28 # Hildon Desktop compositing (in Fremantle)
29 CONF_HD?=0
30 # Link to libzeemote
31 CONF_ZEEMOTE?=0
32
33 # SNES stuff
34 OBJS = apu.o c4.o c4emu.o cheats.o cheats2.o clip.o cpu.o cpuexec.o data.o
35 OBJS += dma.o dsp1.o font.o fxemu.o fxinst.o gfx.o globals.o loadzip.o memmap.o 
36 OBJS += ppu.o sa1.o sdd1.o sdd1emu.o snapshot.o soundux.o spc700.o srtc.o tile.o
37
38 ifeq ($(CONF_BUILD_ASM_CPU), 1)
39         # ASM CPU Core from yoyofr's OpenSnes9X
40         OBJS += os9x_asm_cpu.o os9x_65c816.o
41         CPPFLAGS += -DCONF_BUILD_ASM_CPU=1
42 else
43         OBJS += cpuops.o
44 endif
45
46 ifeq ($(CONF_BUILD_ASM_SPC700), 1)
47         OBJS += spc700a.o
48         CPPFLAGS += -DCONF_BUILD_ASM_SPC700=1
49 endif
50
51 ifeq ($(CONF_BUILD_ASM_SA1), 1)
52         crash
53 else
54         OBJS += sa1cpu.o
55 endif
56
57 OBJS += $(CONF_BUILD_MISC_ROUTINES).o
58
59 # from open-whatever sdk
60 OBJS += unzip.o ioapi.o
61 # my extensions to snes9x (speedhacks support)
62 OBJS += hacks.o
63 # the glue code that sticks it all together in a monstruous way
64 OBJS += platform/path.o platform/config.o
65 OBJS += platform/sdl.o platform/sdlv.o platform/sdla.o platform/sdli.o
66 OBJS += platform/sdlvscalers.o
67
68 ifeq ($(CONF_XSP), 1)
69         CPPFLAGS += -DCONF_XSP=1 $(shell pkg-config --cflags xsp)
70         LDLIBS += $(shell pkg-config --libs xsp)
71 endif
72 ifeq ($(CONF_HD), 1)
73         CPPFLAGS += -DCONF_HD=1
74         LDLIBS += -lSDL_haa
75         CONF_EXIT_BUTTON ?= 1
76 endif
77 ifeq ($(CONF_GUI), 1)
78         CPPFLAGS += -DCONF_GUI=1 $(shell pkg-config --cflags libosso gconf-2.0)
79         LDLIBS += $(shell pkg-config --libs libosso gconf-2.0)
80         OBJS += platform/osso.o
81 endif
82 ifeq ($(CONF_EXIT_BUTTON), 1)
83         CPPFLAGS += -DCONF_EXIT_BUTTON=1
84         LDLIBS += -lSDL_image
85         OBJS += platform/sdlvexit.o
86 endif
87 ifeq ($(CONF_ZEEMOTE), 1)
88         CPPFLAGS += -DCONF_ZEEMOTE=1
89         LDLIBS += -lzeemote -lzeemote-conf -lbluetooth
90         OBJS += platform/zeemote.o
91 endif
92
93 # automatic dependencies
94 DEPS := $(OBJS:.o=.d)
95
96 all: drnoksnes
97
98 clean:
99         rm -f drnoksnes *.o *.d platform/*.o platform/*.d
100         rm -f build-stamp configure-stamp
101         echo "$(OBJS)"
102
103 remake: clean deps all
104
105 -include $(DEPS)
106
107 drnoksnes: $(OBJS)
108         $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
109
110 install: drnoksnes
111         install drnoksnes $(DESTDIR)/usr/games
112
113 deps: $(DEPS)
114 %.d: %.cpp
115         @$(CXX) $(CPPFLAGS) -MM $^ -MF $@ -MT $@ -MT $*.o
116 %.d: %.c
117         @$(CC) $(CPPFLAGS) -MM $^ -MF $@ -MT $@ -MT $*.o
118 %.d: %.s
119         @touch $@
120
121 # GUI
122 gui:
123         $(MAKE) -C gui all
124
125 gui_clean:
126         $(MAKE) -C gui clean
127         
128 gui_install:
129         $(MAKE) -C gui install DESTDIR="$(DESTDIR)"
130         
131 ifeq ($(CONF_GUI), 1)
132 all: gui
133 clean: gui_clean
134 install: gui_install
135 endif
136
137 profclean: clean
138         find . -name '*.gcno' -delete
139         find . -name '*.gcda' -delete
140
141 distclean: profclean clean
142         rm -f config.mk
143
144 .PHONY: all clean remake deps install gui gui_clean distclean
145