From 548fab978602edaae4428320dda7f80581fea34a Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 27 Nov 2020 14:50:07 +0100 Subject: [PATCH] Fix compiling in via docker, always recompile if sd_loader has changes --- .gitignore | 1 - Makefile | 16 ++++++++-------- sd_loader/.gitignore | 4 ++++ sd_loader/Makefile | 17 +++++++++++++++-- src/entry.c | 4 ++-- 5 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 sd_loader/.gitignore diff --git a/.gitignore b/.gitignore index b8e616f..7f4bdcc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ build/ *.elf -src/sd_loader.h *.cbp payload.bin .idea/ diff --git a/Makefile b/Makefile index 6180a41..c03a24b 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,8 @@ export OBJCOPY := $(PREFIX)objcopy TARGET := payload BUILD := build BUILD_DBG := $(TARGET)_dbg -SOURCES := src +SOURCES := src \ + sd_loader DATA := INCLUDES := @@ -71,7 +72,7 @@ export DEPSDIR := $(CURDIR)/$(BUILD) #--------------------------------------------------------------------------------- # automatically build a list of object files for our project #--------------------------------------------------------------------------------- -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) sd_loader.c CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) @@ -110,21 +111,20 @@ export OUTPUT := $(CURDIR)/$(TARGET) .PHONY: $(BUILD) clean install #--------------------------------------------------------------------------------- -$(BUILD): src/sd_loader.h +$(BUILD): sd_loader/sd_loader.h @[ -d $@ ] || mkdir -p $@ + @$(MAKE) -j1 --no-print-directory -C $(CURDIR)/sd_loader -f $(CURDIR)/sd_loader/Makefile @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile -sd_loader_elf := sd_loader/sd_loader.elf -src/sd_loader.h: $(sd_loader_elf) - xxd -i $< | sed "s/unsigned/static const unsigned/g;s/loader/loader/g;s/build_//g" > $@ +sd_loader_elf := sd_loader/sd_loader.h $(sd_loader_elf): make -C sd_loader - #--------------------------------------------------------------------------------- clean: @echo clean ... + @$(MAKE) --no-print-directory -C $(CURDIR)/sd_loader -f $(CURDIR)/sd_loader/Makefile clean @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf #--------------------------------------------------------------------------------- @@ -140,7 +140,7 @@ $(OUTPUT).elf: $(OFILES) #--------------------------------------------------------------------------------- # This rule links in binary data with the .jpg extension #--------------------------------------------------------------------------------- -%.elf: link.ld $(OFILES) +%.elf: link.ld $(OFILES) @echo "linking ... $(TARGET).elf" $(Q)$(LD) -n -T $^ $(LDFLAGS) -o ../$(BUILD_DBG).elf $(LIBPATHS) $(LIBS) $(Q)$(OBJCOPY) -S -R .comment -R .gnu.attributes ../$(BUILD_DBG).elf $@ diff --git a/sd_loader/.gitignore b/sd_loader/.gitignore new file mode 100644 index 0000000..0935e8f --- /dev/null +++ b/sd_loader/.gitignore @@ -0,0 +1,4 @@ +build/ +*.elf +sd_loader.c +sd_loader.h diff --git a/sd_loader/Makefile b/sd_loader/Makefile index a59f8a6..ef0bed0 100644 --- a/sd_loader/Makefile +++ b/sd_loader/Makefile @@ -102,6 +102,12 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ -I$(CURDIR)/$(BUILD) -I$(LIBOGC_INC) \ -I$(PORTLIBS)/include -I$(PORTLIBS)/include/freetype2 +#--------------------------------------------------------------------------------- +# path to tools +#--------------------------------------------------------------------------------- +DEVKITPATH=$(shell echo "$(DEVKITPRO)" | sed -e 's/^\([a-zA-Z]\):/\/\1/') +export PATH := $(DEVKITPATH)/tools/bin:$(DEVKITPATH)/devkitPPC/bin:$(PATH) + #--------------------------------------------------------------------------------- # build a list of library paths #--------------------------------------------------------------------------------- @@ -119,7 +125,7 @@ $(BUILD): #--------------------------------------------------------------------------------- clean: @echo clean ... - @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf + @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf $(BUILD_DBG).c $(BUILD_DBG).h #--------------------------------------------------------------------------------- else @@ -129,7 +135,14 @@ DEPENDS := $(OFILES:.o=.d) #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- -$(OUTPUT).elf: $(OFILES) +$(OUTPUT).h: $(OFILES) + +$(OUTPUT).c: $(OUTPUT).elf + @raw2c $< + @cp $(TARGET).c $@ + +$(OUTPUT).h: $(OUTPUT).c + @cp $(TARGET).h $@ #--------------------------------------------------------------------------------- # This rule links in binary data with the .jpg extension diff --git a/src/entry.c b/src/entry.c index de94000..6d85954 100644 --- a/src/entry.c +++ b/src/entry.c @@ -1,6 +1,6 @@ #include "elf_abi.h" -#include "sd_loader.h" #include "../sd_loader/src/common.h" +#include "../sd_loader/sd_loader.h" #include #define OSDynLoad_Acquire ((void (*)(char* rpl, unsigned int *handle))0x0102A3B4) @@ -190,7 +190,7 @@ int _start(int argc, char **argv) { InstallPatches(&private_data); - unsigned char * pElfBuffer = (unsigned char *) sd_loader_sd_loader_elf; // use this address as temporary to load the elf + unsigned char * pElfBuffer = (unsigned char *) sd_loader; // use this address as temporary to load the elf unsigned int mainEntryPoint = load_elf_image(&private_data, pElfBuffer);