From f074114d1343a5955ac7dab2d01aa66505800132 Mon Sep 17 00:00:00 2001 From: Krzysiek Egzmont Date: Wed, 1 Nov 2023 20:05:59 +0100 Subject: [PATCH] Makefile improvements --- Makefile | 40 +++++++++++++++++++++++++++++++++++++--- win_make.bat | 17 ----------------- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 2766d05..01dcb83 100644 --- a/Makefile +++ b/Makefile @@ -352,10 +352,44 @@ LIBS = DEPS = $(OBJS:.o=.d) +ifdef OS + RM = del /Q + FixPath = $(subst /,\,$1) + WHERE = where +else + ifeq ($(shell uname), Linux) + RM = rm -f + FixPath = $1 + WHERE = which + endif +endif + +ifneq (, $(shell $(WHERE) python)) + MY_PYTHON := python +else ifneq (, $(shell $(WHERE) python3)) + MY_PYTHON := python3 +endif + +ifdef MY_PYTHON + HAS_CRCMOD := $(shell $(MY_PYTHON) -c "import crcmod" 2>&1) +endif + all: $(TARGET) $(OBJCOPY) -O binary $< $<.bin - -python fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin - -python3 fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin + +ifndef MY_PYTHON + $(info ) + $(info !!!!!!!! PYTHON NOT FOUND, *.PACKED.BIN WON'T BE BUILT) + $(info ) +else ifneq (,$(HAS_CRCMOD)) + $(info ) + $(info !!!!!!!! CRCMOD NOT INSTALLED, *.PACKED.BIN WON'T BE BUILT) + $(info !!!!!!!! run: pip install crcmod) + $(info ) +else + -$(MY_PYTHON) fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin +endif + $(SIZE) $< debug: @@ -382,4 +416,4 @@ bsp/dp32g030/%.h: hardware/dp32g030/%.def -include $(DEPS) clean: - rm -f $(TARGET).bin $(TARGET).packed.bin $(TARGET) $(OBJS) $(DEPS) + $(RM) $(call FixPath, $(TARGET).bin $(TARGET).packed.bin $(TARGET) $(OBJS) $(DEPS)) diff --git a/win_make.bat b/win_make.bat index 80c5998..80b0350 100644 --- a/win_make.bat +++ b/win_make.bat @@ -18,15 +18,6 @@ - - -:: Delete any left over files from previous compile -:: -del /S /Q *.o >nul 2>nul -del /S /Q *.d >nul 2>nul -del /Q firmware >nul 2>nul -del /Q *.bin >nul 2>nul - :: You may need to edit/change these three paths to suit your setup :: :: Temporarily add the compiler and make program directories to the system PATH .. @@ -40,14 +31,6 @@ del /Q *.bin >nul 2>nul make clean make -:: Delete the spent files -:: -del /S /Q *.o >nul 2>nul -del /S /Q *.d >nul 2>nul -del /Q firmware >nul 2>nul - - - :: If you have python installed, you can create a 'packed' .bin from the compiled firmware.bin file. :: The Quansheng windows upload-to-radio program requires a 'packed' .bin file.