From e6431d8fffcffff74dc1ac640599a0b631806dfc Mon Sep 17 00:00:00 2001 From: "Peter A. Bigot" Date: Thu, 20 Jun 2013 12:20:50 -0500 Subject: [PATCH 1/2] Makefile.include: support extending CLEAN with directories Use recursive remove for $(CLEAN) to support applications that extended it with directories that should be removed. --- Makefile.include | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile.include b/Makefile.include index f80757b5b..306b223b9 100644 --- a/Makefile.include +++ b/Makefile.include @@ -175,11 +175,12 @@ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ rm -f $(@:.o=.$$$$) endef - clean: +clean: rm -f *~ *core core *.srec \ *.lst *.map \ *.cprg *.bin *.data contiki*.a *.firmware core-labels.S *.ihex *.ini \ - *.ce *.co $(CLEAN) + *.ce *.co + rm -rf $(CLEAN) -rm -rf $(OBJECTDIR) ifndef CUSTOM_RULE_C_TO_CE From 5fc0575e99bb316046505dae732fe922a48edfb4 Mon Sep 17 00:00:00 2001 From: "Peter A. Bigot" Date: Thu, 20 Jun 2013 17:45:41 -0500 Subject: [PATCH 2/2] Makefile.include: support make clean all Historically $(OBJECTDIR) was created when Makefile.include is read. A consequence is that combining "clean" with "all" (or any other build target) results in an error because the clean removes the object directory that is required to exist when building dependencies. Creating $(OBJECTDIR) on-demand ensures it is present when needed. Removed creation of $(OBJECTDIR) on initial read, and added an order-only dependency forcing its creation all Makefile* rules where the target is explicitly or implicitly in $(OBJECTDIR). --- Makefile.include | 11 ++++++----- cpu/6502/Makefile.6502 | 2 +- cpu/arm/at91sam7s/Makefile.at91sam7s | 12 ++++++------ cpu/arm/stm32f103/Makefile.stm32f103 | 6 +++--- cpu/avr/Makefile.avr | 2 +- cpu/cc2430/Makefile.cc2430 | 9 +++++---- cpu/cc2538/Makefile.cc2538 | 5 +++-- cpu/cc253x/Makefile.cc253x | 9 +++++---- cpu/mc1322x/Makefile.mc1322x | 14 +++++++------- cpu/msp430/Makefile.msp430 | 2 +- cpu/stm32w108/Makefile.stm32w108 | 6 +++--- cpu/z80/Makefile.z80 | 4 ++-- platform/cooja/Makefile.cooja | 11 ++++++++--- platform/win32/Makefile.win32 | 2 +- tools/z80/hex2bin/Makefile | 9 ++++----- 15 files changed, 56 insertions(+), 48 deletions(-) diff --git a/Makefile.include b/Makefile.include index 306b223b9..278f73fa4 100644 --- a/Makefile.include +++ b/Makefile.include @@ -86,6 +86,10 @@ CONTIKI_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CONTIKI_SOURCEFI PROJECT_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(PROJECT_SOURCEFILES)}} +# Provide way to create $(OBJECTDIR) if it has been removed by make clean +$(OBJECTDIR): + mkdir $@ + ### Include application makefiles ifdef APPS @@ -108,9 +112,6 @@ target_makefile := $(wildcard $(CONTIKI)/platform/$(TARGET)/Makefile.$(TARGET) $ ifeq ($(strip $(target_makefile)),) ${error The target platform "$(TARGET)" does not exist (maybe it was misspelled?)} else - ifeq (${wildcard $(OBJECTDIR)},) - DUMMY := ${shell mkdir $(OBJECTDIR)} - endif ifneq (1, ${words $(target_makefile)}) ${error More than one TARGET Makefile found: $(target_makefile)} endif @@ -190,13 +191,13 @@ ifndef CUSTOM_RULE_C_TO_CE endif ifndef CUSTOM_RULE_C_TO_OBJECTDIR_O -$(OBJECTDIR)/%.o: %.c +$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR) $(CC) $(CFLAGS) -MMD -c $< -o $@ @$(FINALIZE_DEPENDENCY) endif ifndef CUSTOM_RULE_S_TO_OBJECTDIR_O -$(OBJECTDIR)/%.o: %.S +$(OBJECTDIR)/%.o: %.S | $(OBJECTDIR) $(AS) $(ASFLAGS) -o $@ $< endif diff --git a/cpu/6502/Makefile.6502 b/cpu/6502/Makefile.6502 index 70c9890c8..60186feea 100644 --- a/cpu/6502/Makefile.6502 +++ b/cpu/6502/Makefile.6502 @@ -73,7 +73,7 @@ AROPTS = a .SUFFIXES: CUSTOM_RULE_C_TO_OBJECTDIR_O = 1 -$(OBJECTDIR)/%.o: %.c +$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR) $(CC) -c -o $@ $(CFLAGS) --create-dep $(@:.o=.d) $< CUSTOM_RULE_C_TO_CO = 1 diff --git a/cpu/arm/at91sam7s/Makefile.at91sam7s b/cpu/arm/at91sam7s/Makefile.at91sam7s index 488191267..95f30a36c 100644 --- a/cpu/arm/at91sam7s/Makefile.at91sam7s +++ b/cpu/arm/at91sam7s/Makefile.at91sam7s @@ -95,29 +95,29 @@ CUSTOM_RULE_C_TO_O=yes %-interrupt.o: %-interrupt.c $(CC) $(CFLAGS) $(ARM_FLAGS) $< -c -$(OBJECTDIR)/%-interrupt.o: %-interrupt.c +$(OBJECTDIR)/%-interrupt.o: %-interrupt.c | $(OBJECTDIR) $(CC) $(CFLAGS) $(ARM_FLAGS) -c $< -o $@ %-arm.o: %-arm.c $(CC) $(CFLAGS) $(ARM_FLAGS) $< -c -$(OBJECTDIR)/%-arm.o: %-arm.c +$(OBJECTDIR)/%-arm.o: %-arm.c | $(OBJECTDIR) $(CC) $(CFLAGS) $(ARM_FLAGS) -c $< -o $@ -$(OBJECTDIR)/interrupt-utils.o: interrupt-utils.c +$(OBJECTDIR)/interrupt-utils.o: interrupt-utils.c | $(OBJECTDIR) $(CC) $(CFLAGS) $(ARM_FLAGS) $< -c -o $@ %.o: %.c $(CC) $(CFLAGS) $(THUMB_FLAGS) $< -c -$(OBJECTDIR)/%.o: %.c +$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR) $(CC) $(CFLAGS) $(THUMB_FLAGS) -c $< -o $@ CUSTOM_RULE_S_TO_OBJECTDIR_O = yes %.o: %.S $(CC) $(CFLAGS) $(ARM_FLAGS) $< -c -$(OBJECTDIR)/%.o: %.S +$(OBJECTDIR)/%.o: %.S | $(OBJECTDIR) $(CC) $(CFLAGS) $(ARM_FLAGS) $< -c -o $@ @@ -188,7 +188,7 @@ ocd_reset: cd $(CONTIKI_CPU)/openocd;$(OPENOCD) -f $(OPENOCD_CFG) -c init -c reset -c exit # Don't use core/loader/elfloader.c, use elfloader-otf.c instead -$(OBJECTDIR)/elfloader.o: +$(OBJECTDIR)/elfloader.o: | $(OBJECTDIR) echo -n >$@ clean: clean_cpu diff --git a/cpu/arm/stm32f103/Makefile.stm32f103 b/cpu/arm/stm32f103/Makefile.stm32f103 index bff191c64..cfba80f5b 100644 --- a/cpu/arm/stm32f103/Makefile.stm32f103 +++ b/cpu/arm/stm32f103/Makefile.stm32f103 @@ -94,7 +94,7 @@ CUSTOM_RULE_C_TO_O=yes %.o: %.c $(CC) $(CFLAGS) $< -c -$(OBJECTDIR)/%.o: %.c +$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR) $(CC) $(CFLAGS) -c $< -o $@ @@ -102,7 +102,7 @@ CUSTOM_RULE_S_TO_OBJECTDIR_O = yes %.o: %.S $(CC) $(CFLAGS) $< -c -$(OBJECTDIR)/%.o: %.S +$(OBJECTDIR)/%.o: %.S | $(OBJECTDIR) $(CC) $(CFLAGS) $< -c -o $@ @@ -175,7 +175,7 @@ ocd_reset: $(OPENOCD) -s $(OPENOCD_DIR) -f $(OPENOCD_CFG) -c init -c "reset halt;resume" -c exit # Don't use core/loader/elfloader.c, use elfloader-otf.c instead -$(OBJECTDIR)/elfloader.o: +$(OBJECTDIR)/elfloader.o: | $(OBJECTDIR) echo -n >$@ clean: clean_cpu diff --git a/cpu/avr/Makefile.avr b/cpu/avr/Makefile.avr index 17f4c9b56..f1b09e82f 100644 --- a/cpu/avr/Makefile.avr +++ b/cpu/avr/Makefile.avr @@ -122,7 +122,7 @@ CONTIKI_TARGET_DIRS_CONCAT = ${addprefix $(CONTIKI)/platform/$(TARGET)/, \ ### Compilation rules -$(OBJECTDIR)/%.o: %.c +$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR) $(CC) $(CFLAGS) -c $< -o $@ %.o: %.c diff --git a/cpu/cc2430/Makefile.cc2430 b/cpu/cc2430/Makefile.cc2430 index 0f67e880b..4101416ab 100644 --- a/cpu/cc2430/Makefile.cc2430 +++ b/cpu/cc2430/Makefile.cc2430 @@ -116,7 +116,8 @@ PROJECT_OBJECTFILES = $(addprefix $(OBJECTDIR)/, \ SEGMENT_RULE_FILES = $(foreach dir, . $(CONTIKI_PLATFORM_DIRS) \ $(CONTIKI_CPU_DIRS_LIST), $(wildcard $(dir)/segment.rules) ) -$(SEGMENT_RULES): $(SEGMENT_RULE_FILES) +# NB: Assumes SEGMENT_RULES was not overridden and is in $(OBJECTDIR) +$(SEGMENT_RULES): $(SEGMENT_RULE_FILES) | $(OBJECTDIR) cat $(SEGMENT_RULE_FILES) | \ sed -e 's/#.*$$//' -e 's/^\s*//' -e '/^$$/d' > $@ @@ -124,11 +125,11 @@ CUSTOM_RULE_LINK=1 CUSTOM_RULE_C_TO_OBJECTDIR_O=1 CUSTOM_RULE_ALLOBJS_TO_TARGETLIB=1 -$(OBJECTDIR)/%.rel: %.c $(SEGMENT_RULES) +$(OBJECTDIR)/%.rel: %.c $(SEGMENT_RULES) | $(OBJECTDIR) $(CC) $(call c_seg,$<,$@) $(CFLAGS) -c $< -o $@ -Wp,-MMD,$(@:.rel=.d),-MQ,$@ @$(FINALIZE_SDCC_DEPENDENCY) -$(OBJECTDIR)/%.rel: %.cS +$(OBJECTDIR)/%.rel: %.cS | $(OBJECTDIR) cp $< $(OBJECTDIR)/$*.c $(CC) $(CFLAGS) -E $(OBJECTDIR)/$*.c > $(OBJECTDIR)/tmp perl -pe "s/^#(.*)/;$$1/" $(OBJECTDIR)/tmp > $(OBJECTDIR)/$*.S @@ -144,7 +145,7 @@ contiki-$(TARGET).lib: $(CONTIKI_OBJECTFILES) $(PROJECT_OBJECTFILES) \ # build app/example local object files. We need a separate rule so that we can # pass -DAUTOSTART_ENABLE for those files only -$(OBJECTDIR)/%.app.rel: %.c $(SEGMENT_RULES) +$(OBJECTDIR)/%.app.rel: %.c $(SEGMENT_RULES) | $(OBJECTDIR) $(CC) $(call c_seg,$<,$@) -DAUTOSTART_ENABLE $(CFLAGS) -c $< -o $@ # .ihx is the sdcc binary output file diff --git a/cpu/cc2538/Makefile.cc2538 b/cpu/cc2538/Makefile.cc2538 index e47090696..05ae7257d 100644 --- a/cpu/cc2538/Makefile.cc2538 +++ b/cpu/cc2538/Makefile.cc2538 @@ -59,7 +59,7 @@ CONTIKI_SOURCEFILES += $(USB_CORE_SOURCEFILES) $(USB_ARCH_SOURCEFILES) ### Always re-build ieee-addr.o in case the command line passes a new NODEID FORCE: -$(OBJECTDIR)/ieee-addr.o: ieee-addr.c FORCE +$(OBJECTDIR)/ieee-addr.o: ieee-addr.c FORCE | $(OBJECTDIR) $(CC) $(CFLAGS) -c $< -o $@ ### Compilation rules @@ -82,5 +82,6 @@ LDGENFLAGS += $(addprefix -I,$(SOURCEDIRS)) LDGENFLAGS += -imacros "contiki-conf.h" LDGENFLAGS += -P -E -$(LDSCRIPT): $(CONTIKI_CPU)/cc2538.lds FORCE +# NB: Assumes LDSCRIPT was not overridden and is in $(OBJECTDIR) +$(LDSCRIPT): $(CONTIKI_CPU)/cc2538.lds FORCE | $(OBJECTDIR) $(CPP) $(LDGENFLAGS) $< -o $@ diff --git a/cpu/cc253x/Makefile.cc253x b/cpu/cc253x/Makefile.cc253x index 673cc2b3b..f919285c2 100644 --- a/cpu/cc253x/Makefile.cc253x +++ b/cpu/cc253x/Makefile.cc253x @@ -137,7 +137,8 @@ PROJECT_OBJECTFILES = $(addprefix $(OBJECTDIR)/, \ SEGMENT_RULE_FILES = $(foreach dir, . $(CONTIKI_PLATFORM_DIRS) \ $(CONTIKI_CPU_DIRS_LIST), $(wildcard $(dir)/segment.rules) ) -$(SEGMENT_RULES): $(SEGMENT_RULE_FILES) +# NB: Assumes SEGMENT_RULES was not overridden and is in $(OBJECTDIR) +$(SEGMENT_RULES): $(SEGMENT_RULE_FILES) | $(OBJECTDIR) cat $(SEGMENT_RULE_FILES) | \ sed -e 's/#.*$$//' -e 's/^\s*//' -e '/^$$/d' > $@ @@ -145,11 +146,11 @@ CUSTOM_RULE_LINK=1 CUSTOM_RULE_C_TO_OBJECTDIR_O=1 CUSTOM_RULE_ALLOBJS_TO_TARGETLIB=1 -$(OBJECTDIR)/%.rel: %.c $(SEGMENT_RULES) +$(OBJECTDIR)/%.rel: %.c $(SEGMENT_RULES) | $(OBJECTDIR) $(CC) $(call c_seg,$<,$@) $(CFLAGS) -c $< -o $@ -Wp,-MMD,$(@:.rel=.d),-MQ,$@ @$(FINALIZE_SDCC_DEPENDENCY) -$(OBJECTDIR)/%.rel: %.cS +$(OBJECTDIR)/%.rel: %.cS | $(OBJECTDIR) cp $< $(OBJECTDIR)/$*.c $(CC) $(CFLAGS) -E $(OBJECTDIR)/$*.c > $(OBJECTDIR)/tmp perl -pe "s/^#(.*)/;$$1/" $(OBJECTDIR)/tmp > $(OBJECTDIR)/$*.S @@ -165,7 +166,7 @@ contiki-$(TARGET).lib: $(CONTIKI_OBJECTFILES) $(PROJECT_OBJECTFILES) \ # build app/example local object files. We need a separate rule so that we can # pass -DAUTOSTART_ENABLE for those files only -$(OBJECTDIR)/%.app.rel: %.c $(SEGMENT_RULES) +$(OBJECTDIR)/%.app.rel: %.c $(SEGMENT_RULES) | $(OBJECTDIR) $(CC) $(call c_seg,$<,$@) -DAUTOSTART_ENABLE $(CFLAGS) -c $< -o $@ # .ihx is the sdcc binary output file diff --git a/cpu/mc1322x/Makefile.mc1322x b/cpu/mc1322x/Makefile.mc1322x index 05f936439..d04e3ecf7 100644 --- a/cpu/mc1322x/Makefile.mc1322x +++ b/cpu/mc1322x/Makefile.mc1322x @@ -73,28 +73,28 @@ CFLAGS += -I$(OBJECTDIR) -I$(CONTIKI_CPU)/board -DBOARD=$(TARGET) CPPFLAGS += -P -C ${addprefix -D,${subst $(COMMA), ,$(DEFINES)}} -$(OBJECTDIR)/board.h: $(OBJECTDIR) +$(OBJECTDIR)/board.h: $(CONTIKI_CPU)/board/board.h | $(OBJECTDIR) ifeq ($(HOST_OS),Windows) - ln -f $(CONTIKI_CPU)/board/board.h $(OBJECTDIR)/board.h + ln -f $< $@ else - ln -sf ../$(CONTIKI_CPU)/board/board.h $(OBJECTDIR)/board.h + ln -sf ../$< $@ endif -$(OBJECTDIR)/%.lds: $(CONTIKI_CPU)/%.lds.S +$(OBJECTDIR)/%.lds: $(CONTIKI_CPU)/%.lds.S | $(OBJECTDIR) $(CPP) $(CPPFLAGS) $< > $@ -$(OBJECTDIR)/isr.o: $(CONTIKI_CPU)/src/isr.c +$(OBJECTDIR)/isr.o: $(CONTIKI_CPU)/src/isr.c | $(OBJECTDIR) $(CC) $(CFLAGS) $(ARM_FLAGS) $< -c -o $@ %.o: %.c $(CC) $(CFLAGS) $(THUMB_FLAGS) $< -c -$(OBJECTDIR)/%.o: %.c +$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR) $(CC) $(CFLAGS) $(THUMB_FLAGS) -c $< -o $@ CUSTOM_RULE_S_TO_OBJECTDIR_O = yes -$(OBJECTDIR)/%.o: %.S +$(OBJECTDIR)/%.o: %.S | $(OBJECTDIR) $(CC) $(CFLAGS) $(AFLAGS) $(ARM_FLAGS) $< -c -o $@ CUSTOM_RULE_C_TO_CO=yes diff --git a/cpu/msp430/Makefile.msp430 b/cpu/msp430/Makefile.msp430 index e34c1e6cd..a1d58bf73 100644 --- a/cpu/msp430/Makefile.msp430 +++ b/cpu/msp430/Makefile.msp430 @@ -97,7 +97,7 @@ rm -f $(@:.o=.P) endef CUSTOM_RULE_C_TO_OBJECTDIR_O = 1 -$(OBJECTDIR)/%.o: %.c +$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR) $(CC) $(CFLAGS) $< --dependencies=m $(@:.o=.P) -o $@ ifeq ($(HOST_OS),Windows) @$(FINALIZE_CYGWIN_DEPENDENCY) diff --git a/cpu/stm32w108/Makefile.stm32w108 b/cpu/stm32w108/Makefile.stm32w108 index c5748d84f..2b4c1b3b8 100644 --- a/cpu/stm32w108/Makefile.stm32w108 +++ b/cpu/stm32w108/Makefile.stm32w108 @@ -216,7 +216,7 @@ endif CUSTOM_RULE_C_TO_OBJECTDIR_O = 1 -$(OBJECTDIR)/%.o: %.c +$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR) $(CC) $(CFLAGS) $< --dependencies=m $(@:.o=.P) -o $@ @$(SEDCOMMAND); rm -f $(@:.o=.P) @$(FINALIZE_DEPENDENCY) @@ -270,10 +270,10 @@ stm-motelist: stm-motes: @echo $(MOTES) -$(OBJECTDIR)/%.o: %.s79 +$(OBJECTDIR)/%.o: %.s79 | $(OBJECTDIR) $(AS) $(ASFLAGS) -o $@ $< -$(OBJECTDIR)/%.o: %.s +$(OBJECTDIR)/%.o: %.s | $(OBJECTDIR) $(AS) $(ASFLAGS) -o $@ $< %.bin: %.$(TARGET) diff --git a/cpu/z80/Makefile.z80 b/cpu/z80/Makefile.z80 index 7d8e420c9..47a705b47 100644 --- a/cpu/z80/Makefile.z80 +++ b/cpu/z80/Makefile.z80 @@ -56,11 +56,11 @@ CONTIKI_PLATFORM_DIRS = $(PLATFORM_APPDIRS) \ vpath %.cS $(CONTIKI_PLATFORM_DIRS) #option -MMD doesn't work well on SDCC as of 2.9.0 -$(OBJECTDIR)/%.o: %.c +$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR) $(CC) $(CFLAGS) -c $< -o $@ ifndef CUSTOM_RULE_CS_TO_OBJECTDIR_O -$(OBJECTDIR)/%.o: %.cS +$(OBJECTDIR)/%.o: %.cS | $(OBJECTDIR) cp $< $(OBJECTDIR)/$*.c $(CC) $(CFLAGS) -E $(OBJECTDIR)/$*.c > $(OBJECTDIR)/tmp perl -pe "s/^#(.*)/;$$1/" $(OBJECTDIR)/tmp > $(OBJECTDIR)/$*.S diff --git a/platform/cooja/Makefile.cooja b/platform/cooja/Makefile.cooja index 2e61093d4..46f775a9b 100644 --- a/platform/cooja/Makefile.cooja +++ b/platform/cooja/Makefile.cooja @@ -91,10 +91,13 @@ endif # UIP_CONF_IPV6 REDEF_PRINTF=1 # Redefine functions to enable printf()s inside Cooja ### Define custom targets -$(ARCHIVE): ${addprefix $(OBJECTDIR)/, $(CONTIKI_SOURCEFILES:.c=.o)} + +# NB: Assumes ARCHIVE was not overridden and is in $(OBJECTDIR) +$(ARCHIVE): ${addprefix $(OBJECTDIR)/, $(CONTIKI_SOURCEFILES:.c=.o)} | $(OBJECTDIR) $(AR_COMMAND_1) $^ $(AR_COMMAND_2) -$(JNILIB): $(CONTIKI_APP_OBJ) $(MAIN_OBJ) $(PROJECT_OBJECTFILES) $(ARCHIVE) +# NB: Assumes JNILIB was not overridden and is in $(OBJECTDIR) +$(JNILIB): $(CONTIKI_APP_OBJ) $(MAIN_OBJ) $(PROJECT_OBJECTFILES) $(ARCHIVE) | $(OBJECTDIR) ifdef SYMBOLS @echo Generating symbols # Recreate symbols file and relink with final memory layout (twice) @@ -117,7 +120,9 @@ $(CONTIKI_APP).cooja: $(JNILIB) cp $(JNILIB) $@ rm $(CONTIKI_APP_OBJ) -mtype%.o: contiki-cooja-main.o +# Trickiness: GNU make matches this against the file base name. +# Assume that the directory part is the standard location. +mtype%.o: contiki-cooja-main.o | $(OBJECTDIR) mv contiki-cooja-main.o $@ symbols.c: diff --git a/platform/win32/Makefile.win32 b/platform/win32/Makefile.win32 index 423d6e387..3759df8c5 100644 --- a/platform/win32/Makefile.win32 +++ b/platform/win32/Makefile.win32 @@ -83,7 +83,7 @@ ifdef VCINSTALLDIR VCFLAGS = -Od -Z7 $(filter-out -Wall -g -O,$(CFLAGS)) CUSTOM_RULE_C_TO_OBJECTDIR_O = 1 -$(OBJECTDIR)/%.o: %.c +$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR) cl -nologo $(VCFLAGS) -c $< -Fo$@ @makedepend $(CFLAGS) -o.o -f- $< 2> nul: | sed -e s!$(<:.c=.o)!$@! -e s!\\!/!g > $(@:.o=.d) diff --git a/tools/z80/hex2bin/Makefile b/tools/z80/hex2bin/Makefile index fc6bbe659..6a7b04921 100644 --- a/tools/z80/hex2bin/Makefile +++ b/tools/z80/hex2bin/Makefile @@ -14,10 +14,6 @@ OBJECTS = ${addprefix $(OBJECTDIR)/,$(SOURCES:.c=.o)} vpath %.c $(SOURCEDIR) -ifeq (${wildcard $(OBJECTDIR)},) - DUMMY := ${shell mkdir $(OBJECTDIR)} -endif - hexameter: $(OBJECTS) $(CC) $(CFLAGS) -o $@ $(OBJECTS) @@ -26,6 +22,9 @@ clean: rm -f *~ *.stackdump rm -f *~ hexameter hexameter.exe -$(OBJECTDIR)/%.o: %.c +$(OBJECTDIR): + mkdir $@ + +$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR) $(CC) $(CFLAGS) -c $< -o $@