From c35d5ccf64cbf4b928cb5935cfe2abf5fd4078f7 Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Sat, 31 Mar 2018 11:33:06 -0300 Subject: [PATCH] Improve slightly makefile for makedeps generation and cleaning. File 'makedeps' is now generated automatically if it does not exist or any of source files has been modified. Improve the cleaning of compilation files. Only files created during the compilation are removed. Also if the OBJDIR is empty, it is removed as well. Signed-off-by: Grzegorz Kowal --- build/makefile | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/build/makefile b/build/makefile index b1ed814..0ce77fd 100644 --- a/build/makefile +++ b/build/makefile @@ -49,16 +49,6 @@ $(info ) $(shell sleep 15) endif -#------------------------------------------------------------------------------- -# -# generate object file dependencies -# -ifneq ($(wildcard makedeps),makedeps) -$(info Generating dependencies.) -$(shell ./mkdeps.sh $(SRCSDIR) $(OBJSDIR) > makedeps) -$(info ) -endif - #------------------------------------------------------------------------------- # # check flag conditions @@ -89,17 +79,18 @@ FFLAGS += ${CPPPREFIX}-D${OUTPUT} name = amun -modules = algebra blocks boundaries constants coordinates domains driver \ +files = algebra blocks boundaries constants coordinates domains driver \ equations error evolution gravity integrals interpolations io mesh \ mpitools operators parameters problems random refinement schemes \ shapes sources timers user_problem utils -sources := $(addprefix $(SRCSDIR)/,$(addsuffix .F90, $(modules))) -objects := $(addprefix $(OBJSDIR)/,$(addsuffix .o, $(modules))) +sources := $(addprefix $(SRCSDIR)/,$(addsuffix .F90, $(files))) +objects := $(addprefix $(OBJSDIR)/,$(addsuffix .o, $(files))) +modules := $(addprefix $(OBJSDIR)/,$(addsuffix .mod, $(files))) all: $(name).x -$(name).x: $(deps) $(objects) | $(DESTDIR) +$(name).x: $(objects) | $(DESTDIR) $(LD) $(LDFLAGS) $(objects) $(LIBS) -o $(DESTDIR)/$(name).x $(OBJSDIR)/%.o : $(SRCSDIR)/%.F90 @@ -113,8 +104,15 @@ $(OBJSDIR): $(DESTDIR): mkdir -p $(DESTDIR) -clean: - rm -rf $(OBJSDIR) $(DESTDIR)/$(name).x +makedeps: $(sources) + ./mkdeps.sh $(SRCSDIR) $(OBJSDIR) > makedeps + +.PHONY: clean + +clean: $(OBJSDIR) + rm -f $(objects) $(modules) $(DESTDIR)/$(name).x + rmdir $(OBJSDIR) + rm -f makedeps #------------------------------------------------------------------------------- #