From 6e182577e39d5f17673ca0bed297e9b325e71104 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Wed, 13 May 2015 18:15:01 +0200 Subject: [PATCH] Cleaning makefile --- scripts/module/build_modules.sh | 3 --- scripts/module/module_handler.py | 20 +++++++++++++++----- src/Makefile.common | 7 +++++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/scripts/module/build_modules.sh b/scripts/module/build_modules.sh index 03fa5d7a..92238b99 100755 --- a/scripts/module/build_modules.sh +++ b/scripts/module/build_modules.sh @@ -21,9 +21,6 @@ do # Update Makefile.depend ${QPACKAGE_ROOT}/scripts/module/check_module.sh - # Update Makefile.depend - ${QPACKAGE_ROOT}/scripts/module/module_handler.py save_makefile_depend - # Update EZFIO interface (create the irp.f90 and the ocaml) ${QPACKAGE_ROOT}/scripts/ezfio_interface/ei_handler.py --irpf90 --ocaml diff --git a/scripts/module/module_handler.py b/scripts/module/module_handler.py index c47fc639..60b4b82b 100755 --- a/scripts/module/module_handler.py +++ b/scripts/module/module_handler.py @@ -165,11 +165,21 @@ def get_list_depend(l_module): def save_makefile_depend(l_src, l_obj): header = "# This file was created by the module_handler.py script. Do not modify it by hand." - with open("Makefile.depend", "w") as f: - f.write(header + "\n"*2) - f.write("SRC+= {0}".format(" ".join(l_src)) + "\n") - f.write("OBJ+= {0}".format(" ".join(l_obj)) + "\n") - f.write("\n") + try: + with open("Makefile.depend", "r") as f: + old_output = f.read() + except IOError: + old_output = None + + output = "\n".join([header, + "\n", + "SRC+= {0}".format(" ".join(l_src)), + "OBJ+= {0}".format(" ".join(l_obj)), + "\n"]) + + if output != old_output: + with open("Makefile.depend", "w+") as f: + f.write(output) def create_png_from_path(path): diff --git a/src/Makefile.common b/src/Makefile.common index 606e6f7c..466181ea 100644 --- a/src/Makefile.common +++ b/src/Makefile.common @@ -24,7 +24,6 @@ NEEDED_CHILDREN_MODULES=$(shell module_handler.py print_genealogy) # Check and update dependencies include Makefile.depend - # Define the Makefile common variables EZFIO_DIR=$(QPACKAGE_ROOT)/EZFIO EZFIO=$(EZFIO_DIR)/lib/libezfio_irp.a @@ -36,7 +35,11 @@ clean_links: LIB+=$(EZFIO) $(MKL) IRPF90+=$(patsubst %, -I %, $(INCLUDE_DIRS)) $(IRPF90_FLAGS) -irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) NEEDED_CHILDREN_MODULES $(wildcard *.py) +# Update Makefile.depend +Makefile.depend: $(wildcart */Makefile) + ${QPACKAGE_ROOT}/scripts/module/module_handler.py save_makefile_depend + +irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile.depend Makefile $(EZFIO) NEEDED_CHILDREN_MODULES $(wildcard *.py) - $(IRPF90) - update_README.py