diff --git a/Makefile b/Makefile index fa3245c40..0be03da61 100644 --- a/Makefile +++ b/Makefile @@ -3,23 +3,23 @@ include scripts/config.mak # Disable default Make rules .SUFFIXES: -OUTPUT_DIRECTORY = outputs -object_for = $(addprefix $(OUTPUT_DIRECTORY)/,$(addsuffix .o,$(basename $(1)))) +build_dir = build +object_for = $(addprefix $(build_dir)/,$(addsuffix .o,$(basename $(1)))) -default: $(OUTPUT_DIRECTORY)/epsilon.$(EXE) +default: $(build_dir)/epsilon.$(EXE) # Define a standard rule helper # If passed a last parameter value of with_local_version, we also define an -# extra rule that can build source files within the $(OUTPUT_DIRECTORY). This is -# useful for rules that can be applied for intermediate objects (for example, -# when going .png -> .cpp -> .o). +# extra rule that can build source files within the $(build_dir). This is useful +# for rules that can be applied for intermediate objects (for example, when +# going .png -> .cpp -> .o). define rule_for -$(addprefix $$(OUTPUT_DIRECTORY)/,$(strip $(2))): $(strip $(3)) | $$$$(@D)/. - @ echo "$(shell printf "%-8s" $(strip $(1)))$$(@:$$(OUTPUT_DIRECTORY)/%=%)" +$(addprefix $$(build_dir)/,$(strip $(2))): $(strip $(3)) | $$$$(@D)/. + @ echo "$(shell printf "%-8s" $(strip $(1)))$$(@:$$(build_dir)/%=%)" $(Q) $(4) ifeq ($(strip $(5)),with_local_version) -$(addprefix $$(OUTPUT_DIRECTORY)/,$(strip $(2))): $(addprefix $$(OUTPUT_DIRECTORY)/,$(strip $(3))) - @ echo "$(shell printf "%-8s" $(strip $(1)))$$(@:$$(OUTPUT_DIRECTORY)/%=%)" +$(addprefix $$(build_dir)/,$(strip $(2))): $(addprefix $$(build_dir)/,$(strip $(3))) + @ echo "$(shell printf "%-8s" $(strip $(1)))$$(@:$$(build_dir)/%=%)" $(Q) $(4) endif endef @@ -37,8 +37,8 @@ info: # "output/foo/bar.o" because the directory "output/foo" doesn't exist). # We need to mark those directories as precious, otherwise Make will try to get # rid of them upon completion (and fail, since those folders won't be empty). -.PRECIOUS: $(OUTPUT_DIRECTORY)/. $(OUTPUT_DIRECTORY)%/. -$(OUTPUT_DIRECTORY)/. $(OUTPUT_DIRECTORY)%/.: +.PRECIOUS: $(build_dir)/. $(build_dir)%/. +$(build_dir)/. $(build_dir)%/.: $(Q) mkdir -p $(dir $@) # To make objects dependent on their directory, we need a second expansion @@ -75,8 +75,8 @@ objs = $(call object_for,$(src)) -include $(objs:.o=.d) .SECONDARY: $(objs) -$(OUTPUT_DIRECTORY)/epsilon.$(EXE): $(objs) -$(OUTPUT_DIRECTORY)/test.$(EXE): $(objs) +$(build_dir)/epsilon.$(EXE): $(objs) +$(build_dir)/test.$(EXE): $(objs) # Define standard compilation rules @@ -105,7 +105,7 @@ $(eval $(call rule_for, \ .PHONY: clean clean: @echo "CLEAN" - $(Q) rm -rf $(OUTPUT_DIRECTORY) + $(Q) rm -rf $(build_dir) .PHONY: cowsay_% cowsay_%: diff --git a/apps/Makefile b/apps/Makefile index 6c0d0a4cf..3b247ce34 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -47,7 +47,7 @@ $(call object_for,apps/apps_container_storage.cpp apps/main.cpp): CXXFLAGS += $( # I18n file generation # The header is refered to as so make sure it's findable this way -SFLAGS += -I$(OUTPUT_DIRECTORY) +SFLAGS += -I$(build_dir) i18n_files += $(addprefix apps/language_,$(addsuffix .universal.i18n, $(EPSILON_I18N))) i18n_files += $(addprefix apps/,\ @@ -81,9 +81,9 @@ $(eval $(call rule_for, \ # by the object_for function. app_src += apps/i18n.py -$(OUTPUT_DIRECTORY)/apps/i18n.h: $(OUTPUT_DIRECTORY)/apps/i18n.cpp +$(build_dir)/apps/i18n.h: $(build_dir)/apps/i18n.cpp -$(call object_for,$(app_src)): $(OUTPUT_DIRECTORY)/apps/i18n.h +$(call object_for,$(app_src)): $(build_dir)/apps/i18n.h # Handle PNG files @@ -96,8 +96,8 @@ $(eval $(call depends_on_image,apps/title_bar_view.cpp,apps/exam_icon.png)) # As a shortcut, we simply say that every app file depends on every image. In # practice, this forces all the images to be before the app. -#app_image_objs := $(OUTPUT_DIRECTORY)/$(app_images:.png=.o) -#.SECONDARY: $(OUTPUT_DIRECTORY)/$(app_images:.png=.cpp) +#app_image_objs := $(build_dir)/$(app_images:.png=.o) +#.SECONDARY: $(build_dir)/$(app_images:.png=.cpp) #$(app_objs): $(app_image_objs) #app_image_src := $(app_images:.png=.cpp) diff --git a/escher/Makefile b/escher/Makefile index 12aee399e..9f0607e99 100644 --- a/escher/Makefile +++ b/escher/Makefile @@ -95,9 +95,9 @@ $(eval $(call rule_for, \ $$(HOSTCC) -std=c99 `libpng-config --cflags` $$^ `libpng-config --ldflags` -o $$@ \ )) -INLINER := $(OUTPUT_DIRECTORY)/escher/image/inliner +INLINER := $(build_dir)/escher/image/inliner -.PRECIOUS: $(OUTPUT_DIRECTORY)/%.h $(OUTPUT_DIRECTORY)/%.cpp +.PRECIOUS: $(build_dir)/%.h $(build_dir)/%.cpp $(eval $(call rule_for, \ INLINER, \ %.h %.cpp, \ diff --git a/ion/src/device/Makefile b/ion/src/device/Makefile index d6f784acc..ca71adb6c 100644 --- a/ion/src/device/Makefile +++ b/ion/src/device/Makefile @@ -41,10 +41,10 @@ src += $(addprefix ion/src/device/, \ ifneq ($(DEBUG),1) ifneq ($(COMPILER),llvm) -$(OUTPUT_DIRECTORY)/ion/src/device/led.o: SFLAGS+=-O3 -$(OUTPUT_DIRECTORY)/ion/src/device/console.o: SFLAGS+=-O3 -$(OUTPUT_DIRECTORY)/ion/src/device/display.o: SFLAGS+=-O3 -$(OUTPUT_DIRECTORY)/ion/src/device/swd.o: SFLAGS+=-O3 +$(build_dir)/ion/src/device/led.o: SFLAGS+=-O3 +$(build_dir)/ion/src/device/console.o: SFLAGS+=-O3 +$(build_dir)/ion/src/device/display.o: SFLAGS+=-O3 +$(build_dir)/ion/src/device/swd.o: SFLAGS+=-O3 endif endif diff --git a/ion/src/device/usb/Makefile b/ion/src/device/usb/Makefile index aca2218de..eb539a3ad 100644 --- a/ion/src/device/usb/Makefile +++ b/ion/src/device/usb/Makefile @@ -52,8 +52,8 @@ dfu_src += ion/src/device/base64.cpp dfu_src += ion/src/device/flash.cpp dfu_src += ion/src/device/timing.cpp -$(OUTPUT_DIRECTORY)/ion/src/device/usb/dfu.elf: LDSCRIPT = ion/src/device/usb/dfu.ld -$(OUTPUT_DIRECTORY)/ion/src/device/usb/dfu.elf: $(call object_for,$(usb_src)) $(call object_for,$(dfu_src)) +$(build_dir)/ion/src/device/usb/dfu.elf: LDSCRIPT = ion/src/device/usb/dfu.ld +$(build_dir)/ion/src/device/usb/dfu.elf: $(call object_for,$(usb_src)) $(call object_for,$(dfu_src)) # This command embeds a binary file into an object one. # This allows us to embed standalone code (the dfu routines) into the final @@ -62,7 +62,7 @@ $(OUTPUT_DIRECTORY)/ion/src/device/usb/dfu.elf: $(call object_for,$(usb_src)) $( # and end), but prefixes them with a mangled file path. To have consistent names # we simply "cd" into the directory. This assumes input and output lives in the # same directory. -$(OUTPUT_DIRECTORY)/ion/src/device/usb/dfu.o: $(OUTPUT_DIRECTORY)/ion/src/device/usb/dfu.bin +$(build_dir)/ion/src/device/usb/dfu.o: $(build_dir)/ion/src/device/usb/dfu.bin @echo "OBJCOPY $@" $(Q) cd $(dir $<) ; $(OBJCOPY) -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata --redefine-sym _binary_dfu_bin_start=_dfu_bootloader_flash_start --redefine-sym _binary_dfu_bin_end=_dfu_bootloader_flash_end $(notdir $<) $(notdir $@) diff --git a/kandinsky/Makefile b/kandinsky/Makefile index d9d3793ea..7e7ab6a48 100644 --- a/kandinsky/Makefile +++ b/kandinsky/Makefile @@ -41,7 +41,7 @@ $(eval $(call rule_for, \ $$(HOSTCC) $$(RASTERIZER_CFLAGS) $$^ $$(RASTERIZER_LDFLAGS) -o $$@ \ )) -RASTERIZER := $(OUTPUT_DIRECTORY)/kandinsky/fonts/rasterizer +RASTERIZER := $(build_dir)/kandinsky/fonts/rasterizer $(eval $(call rule_for, \ RASTER, \ diff --git a/python/Makefile b/python/Makefile index 35c23812c..ee277e8d6 100644 --- a/python/Makefile +++ b/python/Makefile @@ -1,6 +1,6 @@ SFLAGS += -Ipython/src SFLAGS += -Ipython/port -SFLAGS += -I$(OUTPUT_DIRECTORY)/python/port +SFLAGS += -I$(build_dir)/python/port # How to maintain this Makefile # - Copy PY_CORE_O_BASENAME from py.mk into py_objs @@ -177,6 +177,6 @@ $(eval $(call rule_for, \ $$(PYTHON) python/src/py/makeqstrdata.py $$< > $$@ \ )) -$(call object_for,$(python_src)): $(OUTPUT_DIRECTORY)/python/port/genhdr/qstrdefs.generated.h +$(call object_for,$(python_src)): $(build_dir)/python/port/genhdr/qstrdefs.generated.h src += $(python_src)