fixed crash with unmapped buttons
[drnoksnes] / Makefile
index b4137b4..6b09edf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,93 +1,66 @@
+#!/usr/bin/make
 
-APPNAME = DrPocketSnes
+CPPFLAGS := -I. $(shell sdl-config --cflags) $(shell pkg-config --cflags x11 xsp) -I/usr/include/hgw
+LDLIBS := -lz $(shell sdl-config --libs) $(shell pkg-config --libs x11 xsp) -lpopt -lhgw
 
-COPT = -IC:/cygwin/opt/cegcc/arm-wince-cegcc/include -I .
-COPT += -mcpu=arm920 -mtune=arm920t -O3 -ffast-math -fexpensive-optimizations -finline -finline-functions -msoft-float -falign-functions=32 -falign-loops -falign-labels -falign-jumps -fomit-frame-pointer
-COPT += -D__GIZ__
+# Default CFLAGS for building in N8x0
+CFLAGS ?= -march=armv6j -mtune=arm1136jf-s -mfpu=vfp -mfloat-abi=softfp -O2 -g -Wall -static-libgcc
+ASFLAGS ?= -march=armv6j -mfpu=vfp -mfloat-abi=softfp -g
+CXXFLAGS ?= $(CFLAGS)
 
-GCC = gcc
-STRIP = strip
+GAME_VERSION ?= $(shell head -n 1 debian/changelog | sed 's/[^0-9.-]//g')-git
+export GAME_VERSION
+export DESTDIR
 
-#
-# SNES stuff (c-based)
-# memset.o memcpy.o 
-OBJS = 2xsaiwin.o apu.o c4.o c4emu.o cheats.o cheats2.o clip.o cpu.o cpuexec.o data.o 
-OBJS += dma.o dsp1.o fxemu.o fxinst.o gfx.o globals.o loadzip.o memmap.o ppu.o  
+# SNES stuff
+OBJS = 2xsaiwin.o apu.o c4.o c4emu.o cheats.o cheats2.o clip.o cpu.o cpuexec.o data.o
+OBJS += dma.o dsp1.o fxemu.o fxinst.o gfx.o globals.o loadzip.o memmap.o netplay.o ppu.o
 OBJS += sdd1.o sdd1emu.o snapshot.o soundux.o spc700.o srtc.o tile.o
-#
 # ASM CPU Core, ripped from Yoyo's OpenSnes9X
-#
 OBJS += os9x_asm_cpu.o os9x_65c816.o spc700a.o
-#
 # and some asm from LJP...
-#
 OBJS += m3d_func.o misc.o
-# 
-# Dave's minimal SDK
-#
-OBJS += giz_sdk.o menu.o input.o gp2x_menutile.o gp2x_highlightbar.o \
-                       gp2x_menu_header.o unzip.o zip.o ioapi.o giz_kgsdkasm.o
+# from open-whatever sdk
+OBJS += unzip.o ioapi.o
+# my own extensions to snes9x
+OBJS += hacks.o
+# the glue code that sticks it all together in a monstruous way
+OBJS += platform/path.o platform/statef.o platform/config.o
+OBJS += platform/sdl.o platform/sdlv.o platform/sdla.o platform/sdli.o
+OBJS += platform/hgw.o
 
-#
-# and the glue code that sticks it all together :)
-#
-OBJS += main.o
+# automatic dependencies
+DEPS := $(OBJS:.o=.d)
 
-# Inopia's menu system, hacked for the GP2X under rlyeh's sdk
-PRELIBS = -LC:/cygwin/opt/cegcc/arm-wince-cegcc/lib -lz -lGizSdk $(LIBS) 
+all: drnoksnes gui
 
-all: $(APPNAME).exe
-clean: tidy $(APPNAME).exe
+clean: gui_clean
+       rm -f drnoksnes *.o *.d platform/*.o platform/*.d
+       rm -f build-stamp configure-stamp
 
-.c.o:
-       $(GCC) $(COPT) -c $< -o $@
+remake: clean deps all
 
-.cpp.o:
-       $(GCC) $(COPT) -c $< -o $@
+-include $(DEPS)
 
-# make seems to lowercase the extensions, so files with '.S' end up being passed to the compiler as '.s', which means thousands of errors.
-# this is a small workaround. 
+drnoksnes: $(OBJS)
+       $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
 
-spc700a.o: spc700a.s
-       $(GCC) $(COPT) -c $< -o $@
-       
-os9x_65c816.o: os9x_65c816.s
-       $(GCC) $(COPT) -c $< -o $@
-
-osnes9xgp_asmfunc.o: osnes9xgp_asmfunc.s
-       $(GCC) $(COPT) -c $< -o $@
-
-m3d_func.o: m3d_func.S
-       $(GCC) $(COPT) -c $< -o $@
+install: drnoksnes
+       install drnoksnes $(DESTDIR)/usr/games
+       $(MAKE) -C gui install
 
-spc_decode.o: spc_decode.s
-       $(GCC) $(COPT) -c $< -o $@
+deps: $(DEPS)
+%.d: %.cpp
+       @$(CXX) $(CPPFLAGS) -MM $^ -MF $@ -MT $@ -MT $*.o
+%.d: %.c
+       @$(CC) $(CPPFLAGS) -MM $^ -MF $@ -MT $@ -MT $*.o
+%.d: %.s
+       @touch $@
 
-misc.o: misc.s
-       $(GCC) $(COPT) -c $< -o $@
-
-memset.o: memset.s
-       $(GCC) $(COPT) -c $< -o $@
+gui:
+       $(MAKE) -C gui all
        
-memcpy.o: memcpy.s
-       $(GCC) $(COPT) -c $< -o $@
-
-dspMixer.o: dspMixer.s
-       $(GCC) $(COPT) -c $< -o $@
+gui_clean:
+       $(MAKE) -C gui clean
        
-giz_kgsdkasm.o: giz_kgsdkasm.s
-       $(GCC) $(COPT) -c $< -o $@
-
-RenderASM/render8.o: RenderASM/render8.S
-       $(GCC) $(COPT) -c $< -o $@
-
-$(APPNAME)d.exe: $(OBJS)
-       $(GCC) $(COPT) $(OBJS) -static $(PRELIBS) -o $@ -lstdc++ -lm
-
-$(APPNAME).exe: $(APPNAME)d.exe
-       $(STRIP) $(APPNAME)d.exe -o $(APPNAME).exe
-
-tidy:
-       rm *.o
-       rm $(APPNAME)d.exe
-       rm $(APPNAME).exe
+.PHONY: all clean remake deps install gui gui_clean