Skip to content

Commit

Permalink
build: Allow out of tree builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
orbea committed Dec 30, 2020
1 parent ebb38f6 commit 09b0786
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 55 deletions.
22 changes: 12 additions & 10 deletions bsnes/GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
srcdir := $(abspath $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))))

target := bsnes
binary := application
build := performance
openmp := true
local := true
flags += -I. -I..
flags += -I$(srcdir)/. -I$(srcdir)/..

# in order for this to work, obj/lzma.o must be omitted or bsnes will hang on startup.
# further, only the X-Video driver works reliably. OpenGL 3.2, OpenGL 2.0, and XShm crash bsnes.
Expand All @@ -17,7 +19,7 @@ ifeq ($(local),true)
flags += -march=native
endif

nall.path := ../nall
nall.path := $(srcdir)/../nall
include $(nall.path)/GNUmakefile

ifeq ($(platform),windows)
Expand Down Expand Up @@ -46,16 +48,16 @@ endif

objects := libco emulator filter lzma

obj/libco.o: ../libco/libco.c
obj/emulator.o: emulator/emulator.cpp
obj/filter.o: filter/filter.cpp
obj/lzma.o: lzma/lzma.cpp
obj/libco.o: $(srcdir)/../libco/libco.c maketree
obj/emulator.o: $(srcdir)/emulator/emulator.cpp maketree
obj/filter.o: $(srcdir)/filter/filter.cpp maketree
obj/lzma.o: $(srcdir)/lzma/lzma.cpp maketree

include sfc/GNUmakefile
include gb/GNUmakefile
include processor/GNUmakefile
include $(srcdir)/sfc/GNUmakefile
include $(srcdir)/gb/GNUmakefile
include $(srcdir)/processor/GNUmakefile

ui := target-$(target)
ui := $(srcdir)/target-$(target)
include $(ui)/GNUmakefile
-include obj/*.d

Expand Down
36 changes: 18 additions & 18 deletions bsnes/gb/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ objects += gb-memory gb-printer gb-random gb-rewind gb-save_state gb-sgb
objects += gb-sm83_cpu gb-symbol_hash gb-timing
#objects+= gb-debugger gb-sm83_disassembler

obj/gb-apu.o: gb/Core/apu.c
obj/gb-camera.o: gb/Core/camera.c
obj/gb-debugger.o: gb/Core/debugger.c
obj/gb-rumble.o: gb/Core/rumble.c
obj/gb-display.o: gb/Core/display.c
obj/gb-gb.o: gb/Core/gb.c
obj/gb-joypad.o: gb/Core/joypad.c
obj/gb-mbc.o: gb/Core/mbc.c
obj/gb-memory.o: gb/Core/memory.c
obj/gb-printer.o: gb/Core/printer.c
obj/gb-random.o: gb/Core/random.c
obj/gb-rewind.o: gb/Core/rewind.c
obj/gb-save_state.o: gb/Core/save_state.c
obj/gb-sgb.o: gb/Core/sgb.c
obj/gb-sm83_cpu.o: gb/Core/sm83_cpu.c
obj/gb-sm83_disassembler.o: gb/Core/sm83_disassembler.c
obj/gb-symbol_hash.o: gb/Core/symbol_hash.c
obj/gb-timing.o: gb/Core/timing.c
obj/gb-apu.o: $(srcdir)/gb/Core/apu.c
obj/gb-camera.o: $(srcdir)/gb/Core/camera.c
obj/gb-debugger.o: $(srcdir)/gb/Core/debugger.c
obj/gb-rumble.o: $(srcdir)/gb/Core/rumble.c
obj/gb-display.o: $(srcdir)/gb/Core/display.c
obj/gb-gb.o: $(srcdir)/gb/Core/gb.c
obj/gb-joypad.o: $(srcdir)/gb/Core/joypad.c
obj/gb-mbc.o: $(srcdir)/gb/Core/mbc.c
obj/gb-memory.o: $(srcdir)/gb/Core/memory.c
obj/gb-printer.o: $(srcdir)/gb/Core/printer.c
obj/gb-random.o: $(srcdir)/gb/Core/random.c
obj/gb-rewind.o: $(srcdir)/gb/Core/rewind.c
obj/gb-save_state.o: $(srcdir)/gb/Core/save_state.c
obj/gb-sgb.o: $(srcdir)/gb/Core/sgb.c
obj/gb-sm83_cpu.o: $(srcdir)/gb/Core/sm83_cpu.c
obj/gb-sm83_disassembler.o: $(srcdir)/gb/Core/sm83_disassembler.c
obj/gb-symbol_hash.o: $(srcdir)/gb/Core/symbol_hash.c
obj/gb-timing.o: $(srcdir)/gb/Core/timing.c
14 changes: 7 additions & 7 deletions bsnes/processor/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ objects += $(if $(findstring spc700,$(processors)),processor-spc700)
objects += $(if $(findstring upd96050,$(processors)),processor-upd96050)
objects += $(if $(findstring wdc65816,$(processors)),processor-wdc65816)

obj/processor-arm7tdmi.o: processor/arm7tdmi/arm7tdmi.cpp
obj/processor-gsu.o: processor/gsu/gsu.cpp
obj/processor-hg51b.o: processor/hg51b/hg51b.cpp
obj/processor-sm83.o: processor/sm83/sm83.cpp
obj/processor-spc700.o: processor/spc700/spc700.cpp
obj/processor-upd96050.o: processor/upd96050/upd96050.cpp
obj/processor-wdc65816.o: processor/wdc65816/wdc65816.cpp
obj/processor-arm7tdmi.o: $(srcdir)/processor/arm7tdmi/arm7tdmi.cpp
obj/processor-gsu.o: $(srcdir)/processor/gsu/gsu.cpp
obj/processor-hg51b.o: $(srcdir)/processor/hg51b/hg51b.cpp
obj/processor-sm83.o: $(srcdir)/processor/sm83/sm83.cpp
obj/processor-spc700.o: $(srcdir)/processor/spc700/spc700.cpp
obj/processor-upd96050.o: $(srcdir)/processor/upd96050/upd96050.cpp
obj/processor-wdc65816.o: $(srcdir)/processor/wdc65816/wdc65816.cpp
26 changes: 13 additions & 13 deletions bsnes/sfc/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ objects += sfc-cartridge sfc-memory
objects += sfc-cpu sfc-smp sfc-dsp sfc-ppu sfc-ppu-fast
objects += sfc-expansion sfc-coprocessor sfc-slot

obj/sfc-interface.o: sfc/interface/interface.cpp
obj/sfc-system.o: sfc/system/system.cpp
obj/sfc-controller.o: sfc/controller/controller.cpp
obj/sfc-cartridge.o: sfc/cartridge/cartridge.cpp
obj/sfc-memory.o: sfc/memory/memory.cpp
obj/sfc-interface.o: $(srcdir)/sfc/interface/interface.cpp maketree
obj/sfc-system.o: $(srcdir)/sfc/system/system.cpp maketree
obj/sfc-controller.o: $(srcdir)/sfc/controller/controller.cpp maketree
obj/sfc-cartridge.o: $(srcdir)/sfc/cartridge/cartridge.cpp maketree
obj/sfc-memory.o: $(srcdir)/sfc/memory/memory.cpp maketree

obj/sfc-cpu.o: sfc/cpu/cpu.cpp
obj/sfc-smp.o: sfc/smp/smp.cpp
obj/sfc-dsp.o: sfc/dsp/dsp.cpp
obj/sfc-ppu.o: sfc/ppu/ppu.cpp
obj/sfc-ppu-fast.o: sfc/ppu-fast/ppu.cpp
obj/sfc-cpu.o: $(srcdir)/sfc/cpu/cpu.cpp maketree
obj/sfc-smp.o: $(srcdir)/sfc/smp/smp.cpp maketree
obj/sfc-dsp.o: $(srcdir)/sfc/dsp/dsp.cpp maketree
obj/sfc-ppu.o: $(srcdir)/sfc/ppu/ppu.cpp maketree
obj/sfc-ppu-fast.o: $(srcdir)/sfc/ppu-fast/ppu.cpp maketree

obj/sfc-expansion.o: sfc/expansion/expansion.cpp
obj/sfc-coprocessor.o: sfc/coprocessor/coprocessor.cpp
obj/sfc-slot.o: sfc/slot/slot.cpp
obj/sfc-expansion.o: $(srcdir)/sfc/expansion/expansion.cpp maketree
obj/sfc-coprocessor.o: $(srcdir)/sfc/coprocessor/coprocessor.cpp maketree
obj/sfc-slot.o: $(srcdir)/sfc/slot/slot.cpp maketree
8 changes: 4 additions & 4 deletions bsnes/target-bsnes/GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name := bsnes

hiro.path := ../hiro
hiro.path := $(srcdir)/../hiro
hiro.resource := $(ui)/resource/bsnes.rc
include $(hiro.path)/GNUmakefile

ruby.path := ../ruby
ruby.path := $(srcdir)/../ruby
include $(ruby.path)/GNUmakefile

objects += ui-bsnes ui-program ui-input ui-presentation
Expand Down Expand Up @@ -58,8 +58,8 @@ else ifneq ($(filter $(platform),linux bsd),)
cp $(ui)/resource/$(name).desktop $(DESTDIR)$(datarootdir)/applications/$(name).desktop
cp $(ui)/resource/$(name).png $(DESTDIR)$(datarootdir)/icons/hicolor/256x256/apps/$(name).png
cp $(ui)/resource/$(name).svg $(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/$(name).svg
cp Database/* $(DESTDIR)$(datadir)/$(name)/Database/
cp -r ../shaders/* $(DESTDIR)$(datadir)/$(name)/Shaders/
cp $(srcdir)/Database/* $(DESTDIR)$(datadir)/$(name)/Database/
cp -r $(srcdir)/../shaders/* $(DESTDIR)$(datadir)/$(name)/Shaders/
endif

uninstall:
Expand Down
4 changes: 2 additions & 2 deletions hiro/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ hiro.objects := \
$(object.path)/hiro-$(hiro).o \
$(if $(filter windows,$(hiro)),$(object.path)/hiro-resource.o)

$(object.path)/hiro-$(hiro).o: $(hiro.path)/hiro.cpp
$(object.path)/hiro-$(hiro).o: $(hiro.path)/hiro.cpp maketree
$(if $(filter qt%,$(hiro)),$(info Compiling $(hiro.path)/qt/qt.moc ...))
$(if $(filter qt%,$(hiro)),@$(moc) -i -o $(hiro.path)/qt/qt.moc $(hiro.path)/qt/qt.hpp)
$(info Compiling $< ...)
@$(compiler) $(hiro.flags) $(flags) $(flags.deps) -c $< -o $@

$(object.path)/hiro-resource.o: $(hiro.resource)
$(object.path)/hiro-resource.o: $(hiro.resource) maketree
$(info Compiling $< ...)
@$(windres) $< $@

Expand Down
10 changes: 10 additions & 0 deletions nall/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ endif
# rules
default: all;
maketree: $(object.path)/.tag out/.tag
$(object.path)/.tag:
@mkdir -p obj
@touch $@
out/.tag:
@mkdir -p out
@touch $@
nall.verbose:
$(info Compiler Flags:)
$(foreach n,$(sort $(call unique,$(flags))),$(if $(filter-out -I%,$n),$(info $([space]) $n)))
Expand Down
2 changes: 1 addition & 1 deletion ruby/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ endif

ruby.objects := $(object.path)/ruby.o

$(object.path)/ruby.o: $(ruby.path)/ruby.cpp $(call rwildcard,$(ruby.path))
$(object.path)/ruby.o: $(ruby.path)/ruby.cpp $(call rwildcard,$(ruby.path)) maketree
$(info Compiling $< ...)
@$(compiler) $(ruby.flags) $(flags) $(flags.deps) -c $< -o $@

Expand Down

0 comments on commit 09b0786

Please sign in to comment.