From 03134342cf491dc7238cba163cdef1203dc2a15e Mon Sep 17 00:00:00 2001 From: Florian Wittkamp Date: Sun, 21 Feb 2016 13:37:11 +0100 Subject: [PATCH] Maintenance Makefiles (1.) IFOS Makefile Introduce dependencies files, which contain dependencied of each objective file. Therefore, it is possible to allow a more accurate rebuilt of the objective files. New standard target is IFOS2D. Moreover a new target install is available. (2.) Contrib Fixed the problem with the dependencies files if the hole IFOS folder is copied over to a different hardware architecture. You may now the error by ".d" files. --- contrib/aff/Makefile | 2 + contrib/fourier/Makefile | 2 + contrib/libcseife/Makefile | 8 +++- contrib/stfinv/Makefile | 2 + par/Makefile | 4 +- src/Makefile | 82 +++++++++++++++++++++++++------------- 6 files changed, 69 insertions(+), 31 deletions(-) diff --git a/contrib/aff/Makefile b/contrib/aff/Makefile index 32ccba7..ef0efdd 100644 --- a/contrib/aff/Makefile +++ b/contrib/aff/Makefile @@ -166,7 +166,9 @@ libaff.so: $(INSTHEADER) $(LIBOBS) > $@; \ [ -s $@ ] || rm -f $@' +ifneq ($(MAKECMDGOALS),clean) include $(patsubst %.cc,%.d,$(SRC)) +endif # this include will be used once we initiate the precompiled library version # until then it's just waiting here diff --git a/contrib/fourier/Makefile b/contrib/fourier/Makefile index b46d945..86ec8ea 100644 --- a/contrib/fourier/Makefile +++ b/contrib/fourier/Makefile @@ -200,7 +200,9 @@ libfourierxx.so: install-include libfourier.a $(LIBOBSXX) > $@; \ [ -s $@ ] || rm -f $@' +ifneq ($(MAKECMDGOALS),clean) include $(patsubst %.cc,%.d,$(SRC)) +endif #====================================================================== # header files diff --git a/contrib/libcseife/Makefile b/contrib/libcseife/Makefile index c27221d..8f516f9 100644 --- a/contrib/libcseife/Makefile +++ b/contrib/libcseife/Makefile @@ -113,14 +113,16 @@ SUBS=$(patsubst %.f,%.o,$(wildcard subs/*.f)) # Fortran include dependencies %.d: %.f echo $<: $(addprefix subs/,$(shell cat $< | egrep '^ +include' | cut -f 2 -d \' | sort | uniq)) > $@ -include $(patsubst %.f,%.d,$(wildcard subs/*.f)) +ifneq ($(MAKECMDGOALS),clean) +include $(patsubst %.f,%.d,$(wildcard subs/*.f)) +endif #====================================================================== $(INCINSTALLPATH)/%.h: %.h mkdir -p $(INCINSTALLPATH) -rm -fv $@ - /bin/cp -vpd $< $@ + /bin/cp -vp $< $@ .PHONY: install-include install-include: $(INSTHEADER) @@ -152,7 +154,9 @@ reinstall: # library part # ------------ +ifneq ($(MAKECMDGOALS),clean) include $(patsubst %.c,%.d,$(CLIBSRC)) +endif libcseife.a: $(patsubst %.c,%.o,$(CLIBSRC)) libseife.a: $(SUBS) diff --git a/contrib/stfinv/Makefile b/contrib/stfinv/Makefile index a96ec30..8e2e610 100644 --- a/contrib/stfinv/Makefile +++ b/contrib/stfinv/Makefile @@ -170,8 +170,10 @@ clean: ; # library part # ------------ +ifneq ($(MAKECMDGOALS),clean) include $(patsubst %.cc,%.d,$(LIBCCSRC) $(TESTCCSRC)) \ $(patsubst %.c,%.d,$(LIBCSRC) $(TESTCSRC)) +endif libstfinv.a: $(patsubst %.cc,%.o,$(LIBCCSRC)) \ $(patsubst %.c,%.o,$(LIBCSRC)) diff --git a/par/Makefile b/par/Makefile index d4e474c..943a74b 100644 --- a/par/Makefile +++ b/par/Makefile @@ -25,10 +25,12 @@ else $(MAKE) -C ../src/ IFOS2D endif +.PHONY: install +install: clean IFOS2D .PHONY: clean clean: - rm -rf ../bin/IFOS2D + rm -rf ../bin/* $(MAKE) -C ../contrib/aff clean $(MAKE) -C ../contrib/fourier clean $(MAKE) -C ../contrib/stfinv clean diff --git a/src/Makefile b/src/Makefile index ff2e6ea..ba0674d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -32,12 +32,29 @@ IFLAGS=-I./../contrib/libcseife -I./../contrib/header -I. #SFLAGS=-L./../contrib/libcseife -L./../contrib/bin #IFLAGS=-I./../contrib/libcseife -I./../contrib/header -I. +ifeq ($(TERM_PROGRAM),Apple_Terminal) +LFLAGS=-lm -lcseife -lstfinv -laff -lfourierxx -lfftw3 -lc++ +CC=mpicc +endif # after this line, no further editing should be necessary # -------------------------------------------------------- -.c.o: +# ------------- +# pattern rules +# ------------- + +%.o: %.c $(CC) $(CFLAGS) -o $@ -c $< $(IFLAGS) + $(CC) $(CFLAGS) -MM $*.c $(IFLAGS) > $*.d + +SNAPMERGE_OBJ = $(SNAPMERGE_SCR:%.c=%.o) + +IFOS_OBJ = $(IFOS2D:%.c=%.o) + +# ------------- +# Dependencies +# ------------- SNAPMERGE_SCR = \ snapmerge.c \ @@ -54,9 +71,9 @@ IFOS2D= \ stf.c \ window_cos.c \ calc_mat_change_test.c \ - calc_res.c \ + calc_res.c \ calc_misfit.c \ - calc_opt_step.c \ + calc_opt_step.c \ calc_energy.c \ checkfd.c \ checkfd_ssg_elastic.c \ @@ -70,7 +87,7 @@ IFOS2D= \ exchange_s.c \ exchange_p.c \ snap_ssg.c \ - snap_ssg_SH.c \ + snap_ssg_SH.c \ seismo_ssg.c \ surface_elastic_PML.c \ surface_acoustic_PML.c \ @@ -83,9 +100,9 @@ IFOS2D= \ update_p_PML.c \ update_s_elastic_ssg.c \ update_s_elastic_PML.c \ - update_s_elastic_PML_SH.c \ + update_s_elastic_PML_SH.c \ update_s_visc_PML.c \ - update_s_visc_PML_SH.c \ + update_s_visc_PML_SH.c \ av_mue.c \ av_rho.c \ av_tau.c \ @@ -102,7 +119,7 @@ IFOS2D= \ $(MODEL) \ $(MODEL_AC) \ $(MODEL_EL) \ - $(MODEL_VAC) \ + $(MODEL_VAC) \ matcopy.c \ matcopy_elastic.c \ matcopy_acoustic.c \ @@ -122,10 +139,10 @@ IFOS2D= \ readmod.c \ readmod_elastic.c \ readmod_acoustic.c \ - receiver.c \ + receiver.c \ rd_sour.c \ - read_workflow.c \ - apply_workflow.c \ + read_workflow.c \ + apply_workflow.c \ saveseis_glob.c \ sources.c \ solvelin.c \ @@ -150,33 +167,42 @@ IFOS2D= \ zero_fdveps_ac.c \ zero_fdveps_visc.c \ calc_envelope.c \ - joint_inversion.c \ - matrix_operations.c \ - wolfe_condition.c \ - calc_hilbert.c \ + joint_inversion.c \ + matrix_operations.c \ + wolfe_condition.c \ + calc_hilbert.c \ eprecond.c \ eprecond1.c \ - zero_fdveps_viscac.c \ - update_p_visc_PML.c \ - matcopy_viscac.c \ - prepare_update_p.c \ - readmod_viscac.c \ - time_window_glob.c \ - create_trkill_table.c \ - filter_frequencies.c - -SNAPMERGE_OBJ = $(SNAPMERGE_SCR:%.c=%.o) + zero_fdveps_viscac.c \ + update_p_visc_PML.c \ + matcopy_viscac.c \ + prepare_update_p.c \ + readmod_viscac.c \ + time_window_glob.c \ + create_trkill_table.c \ + filter_frequencies.c + +# ------------- +# Targes +# ------------- + +IFOS2D: $(IFOS_OBJ) fd.h + $(CC) $(SFLAGS) $(IFOS_OBJ) -o $(EXEC)/IFOS2D $(LFLAGS) -IFOS_OBJ = $(IFOS2D:%.c=%.o) +all: IFOS2D snapmerge snapmerge: $(SNAPMERGE_OBJ) $(CC) $(SFLAGS) $(SNAPMERGE_OBJ) -o ../bin/snapmerge $(LFLAGS) -IFOS2D: $(IFOS_OBJ) - $(CC) $(SFLAGS) $(IFOS_OBJ) -o $(EXEC)/IFOS2D $(LFLAGS) - +.PHONY: clean clean: + find . -name "*.d" -exec rm {} \; find . -name "*.o" -exec rm {} \; find . -name "*.c%" -exec rm {} \; find . -name "*.bck" -exec rm {} \; find ../genmod -name "*.o" -exec rm {} \; + find ../genmod -name "*.d" -exec rm {} \; + +install: clean all + +-include $(IFOS_OBJ:.o=.d) \ No newline at end of file -- GitLab