From 5f41468ba85deca14747b9dd23ca7a1cf6bdd2a4 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 23 Nov 2021 07:57:15 +0100 Subject: [PATCH] modify main Makefile to build tools using cmake --- Makefile | 50 ++++++++++++++++++++++++-------------------- tools/CMakeLists.txt | 2 +- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index ddd26c61..ba320ada 100644 --- a/Makefile +++ b/Makefile @@ -82,14 +82,14 @@ LDFLAGS = -Map ../../$(MAP) LIB := -L ../../tools/agbcc/lib -lc SHA1 := $(shell { command -v sha1sum || command -v shasum; } 2>/dev/null) -c -GFX := tools/gbagfx/gbagfx -AIF := tools/aif2pcm/aif2pcm -MID := tools/mid2agb/mid2agb -SCANINC := tools/scaninc/scaninc +GFX := tools/bin/gbagfx +AIF := tools/bin/aif2pcm +MID := tools/bin/mid2agb +SCANINC := tools/bin/scaninc # TODO: use charmap? -PREPROC := tools/preproc/preproc -FIX := tools/gbafix/gbafix -ASSET_PROCESSOR := tools/asset_processor/asset_processor +PREPROC := tools/bin/preproc +FIX := tools/bin/gbafix +ASSET_PROCESSOR := tools/bin/asset_processor ASSET_CONFIGS = assets/assets.json assets/gfx.json assets/map.json assets/samples.json assets/sounds.json TRANSLATIONS = translations/USA.bin translations/English.bin translations/French.bin translations/German.bin translations/Spanish.bin translations/Italian.bin @@ -149,11 +149,7 @@ SUBDIRS := $(sort $(dir $(OBJS))) $(shell mkdir -p $(SUBDIRS)) -TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*)) -TOOLBASE = $(TOOLDIRS:tools/%=%) -TOOLS = $(foreach tool,$(TOOLBASE),tools/$(tool)/$(tool)$(EXE)) - -.PHONY: all setup clean-tools mostlyclean clean tidy $(TOOLDIRS) extractassets +.PHONY: all setup clean-tools mostlyclean clean tidy tools extractassets MAKEFLAGS += --no-print-directory @@ -170,8 +166,18 @@ target: $(ROM) compare: $(ROM) @$(SHA1) $(BUILD_NAME).sha1 -setup: $(TOOLDIRS) +setup: tools +# all tools are build at once +# FIXME figure out why make builds multiple times when specifying all tools here +tools: $(GFX) + +$(GFX) $(AIF) $(MID) $(SCANINC) $(PREPROC) $(FIX) $(ASSET_PROCESSOR) tools/bin/agb2mid tools/bin/tmc_strings tools/bin/bin2c &: + mkdir tools/cmake-build + unset CC CXX AS LD && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=tools -S tools -B tools/cmake-build + cmake --build tools/cmake-build -j + cmake --install tools/cmake-build + # Automatically extract binary data build/extracted_assets_%: $(ASSET_CONFIGS) $(TRANSLATIONS) $(ASSET_PROCESSOR) extract $(GAME_VERSION) $(ASSET_BUILDDIR) @@ -181,9 +187,6 @@ build/extracted_assets_%: $(ASSET_CONFIGS) $(TRANSLATIONS) extractassets: $(ASSET_PROCESSOR) convert $(GAME_VERSION) $(ASSET_BUILDDIR) -$(TOOLDIRS): - @$(MAKE) -C $@ - mostlyclean: tidy rm -f sound/direct_sound_samples/*.bin rm -f $(SONG_OBJS) $(MID_SUBDIR)/*.s @@ -191,7 +194,8 @@ mostlyclean: tidy rm -f $(AUTO_GEN_TARGETS) clean-tools: - @$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);) + rm -rf tools/bin + rm -rf tools/cmake-build clean: mostlyclean clean-tools @@ -217,12 +221,12 @@ tidy: %.lz: % ; $(GFX) $< $@ %.rl: % ; $(GFX) $< $@ cd $(@D) && ../../$(MID) $(