From 926c72a88b753c028073ff86d968078984682167 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Fri, 17 Mar 2017 16:06:29 -0500 Subject: [PATCH] Fancy general Makefile --- example/Makefile | 8 ++++++-- src/templates/general.make | 10 ++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/example/Makefile b/example/Makefile index a274703..6653b88 100644 --- a/example/Makefile +++ b/example/Makefile @@ -59,16 +59,20 @@ ARCH = $(addprefix $(CURDIR)/,IRPF90_temp/irpf90.a) all: $(EXE) +define run + $(BUILD_SYSTEM) -C $(dir $(BUILD_FILE) ) -f $(notdir $(BUILD_FILE) ) $(1) +endef + $(EXE): $(ARCH) @printf "%b" "\033[0;32m Build $@...\033[m\n" - @$(BUILD_SYSTEM) -C $(dir $< ) -f $(notdir $(BUILD_FILE)) $(addprefix $(CURDIR)/, $@) && touch $@ + @$(call run, $(addprefix $(CURDIR)/, $@)) && touch $@ .NOTPARALLEL: $(BUILD_FILE) $(ARCH) $(ARCH): $(BUILD_FILE) @printf "%b" "\033[0;32m Creating the archive...\033[m\n" - @$(BUILD_SYSTEM) -C $(dir $< ) -f $(notdir $< ) $(ARCH) + @$(call run, $@) && touch $@ $(BUILD_FILE): $(shell find . -maxdepth 2 -path ./IRPF90_temp -prune -o -name '*.irp.f' -print) @printf "%b" "\033[0;32m Running the IRPF90-compiler...\033[m\n" diff --git a/src/templates/general.make b/src/templates/general.make index 0659820..1822c84 100644 --- a/src/templates/general.make +++ b/src/templates/general.make @@ -59,16 +59,22 @@ ARCH = $(addprefix $(CURDIR)/,IRPF90_temp/irpf90.a) all: $(EXE) +define run + $(BUILD_SYSTEM) -C $(dir $(BUILD_FILE) ) -f $(notdir $(BUILD_FILE) ) $(1)", +endef + +#We allow for the user to ask for 'relative' path +#But the IRPF90 build system use absolute path. $(EXE): $(ARCH) @printf "%b" "\033[0;32m Build $@...\033[m\n" - @$(BUILD_SYSTEM) -C $(dir $< ) -f $(notdir $(BUILD_FILE)) $(addprefix $(CURDIR)/, $@) && touch $@ + @$(call run, $(addprefix $(CURDIR)/, $@)) && touch $@ .NOTPARALLEL: $(BUILD_FILE) $(ARCH) $(ARCH): $(BUILD_FILE) @printf "%b" "\033[0;32m Creating the archive...\033[m\n" - @$(BUILD_SYSTEM) -C $(dir $< ) -f $(notdir $< ) $(ARCH) + @$(call run, $@) && touch $@ $(BUILD_FILE): $(shell find . -maxdepth 2 -path ./IRPF90_temp -prune -o -name '*.irp.f' -print) @printf "%b" "\033[0;32m Running the IRPF90-compiler...\033[m\n"