Commit 03134342 authored by Florian Wittkamp's avatar Florian Wittkamp

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.
parent 09c5aa3d
...@@ -166,7 +166,9 @@ libaff.so: $(INSTHEADER) $(LIBOBS) ...@@ -166,7 +166,9 @@ libaff.so: $(INSTHEADER) $(LIBOBS)
> $@; \ > $@; \
[ -s $@ ] || rm -f $@' [ -s $@ ] || rm -f $@'
ifneq ($(MAKECMDGOALS),clean)
include $(patsubst %.cc,%.d,$(SRC)) include $(patsubst %.cc,%.d,$(SRC))
endif
# this include will be used once we initiate the precompiled library version # this include will be used once we initiate the precompiled library version
# until then it's just waiting here # until then it's just waiting here
......
...@@ -200,7 +200,9 @@ libfourierxx.so: install-include libfourier.a $(LIBOBSXX) ...@@ -200,7 +200,9 @@ libfourierxx.so: install-include libfourier.a $(LIBOBSXX)
> $@; \ > $@; \
[ -s $@ ] || rm -f $@' [ -s $@ ] || rm -f $@'
ifneq ($(MAKECMDGOALS),clean)
include $(patsubst %.cc,%.d,$(SRC)) include $(patsubst %.cc,%.d,$(SRC))
endif
#====================================================================== #======================================================================
# header files # header files
......
...@@ -113,14 +113,16 @@ SUBS=$(patsubst %.f,%.o,$(wildcard subs/*.f)) ...@@ -113,14 +113,16 @@ SUBS=$(patsubst %.f,%.o,$(wildcard subs/*.f))
# Fortran include dependencies # Fortran include dependencies
%.d: %.f %.d: %.f
echo $<: $(addprefix subs/,$(shell cat $< | egrep '^ +include' | cut -f 2 -d \' | sort | uniq)) > $@ 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 $(INCINSTALLPATH)/%.h: %.h
mkdir -p $(INCINSTALLPATH) mkdir -p $(INCINSTALLPATH)
-rm -fv $@ -rm -fv $@
/bin/cp -vpd $< $@ /bin/cp -vp $< $@
.PHONY: install-include .PHONY: install-include
install-include: $(INSTHEADER) install-include: $(INSTHEADER)
...@@ -152,7 +154,9 @@ reinstall: ...@@ -152,7 +154,9 @@ reinstall:
# library part # library part
# ------------ # ------------
ifneq ($(MAKECMDGOALS),clean)
include $(patsubst %.c,%.d,$(CLIBSRC)) include $(patsubst %.c,%.d,$(CLIBSRC))
endif
libcseife.a: $(patsubst %.c,%.o,$(CLIBSRC)) libcseife.a: $(patsubst %.c,%.o,$(CLIBSRC))
libseife.a: $(SUBS) libseife.a: $(SUBS)
......
...@@ -170,8 +170,10 @@ clean: ; ...@@ -170,8 +170,10 @@ clean: ;
# library part # library part
# ------------ # ------------
ifneq ($(MAKECMDGOALS),clean)
include $(patsubst %.cc,%.d,$(LIBCCSRC) $(TESTCCSRC)) \ include $(patsubst %.cc,%.d,$(LIBCCSRC) $(TESTCCSRC)) \
$(patsubst %.c,%.d,$(LIBCSRC) $(TESTCSRC)) $(patsubst %.c,%.d,$(LIBCSRC) $(TESTCSRC))
endif
libstfinv.a: $(patsubst %.cc,%.o,$(LIBCCSRC)) \ libstfinv.a: $(patsubst %.cc,%.o,$(LIBCCSRC)) \
$(patsubst %.c,%.o,$(LIBCSRC)) $(patsubst %.c,%.o,$(LIBCSRC))
......
...@@ -25,10 +25,12 @@ else ...@@ -25,10 +25,12 @@ else
$(MAKE) -C ../src/ IFOS2D $(MAKE) -C ../src/ IFOS2D
endif endif
.PHONY: install
install: clean IFOS2D
.PHONY: clean .PHONY: clean
clean: clean:
rm -rf ../bin/IFOS2D rm -rf ../bin/*
$(MAKE) -C ../contrib/aff clean $(MAKE) -C ../contrib/aff clean
$(MAKE) -C ../contrib/fourier clean $(MAKE) -C ../contrib/fourier clean
$(MAKE) -C ../contrib/stfinv clean $(MAKE) -C ../contrib/stfinv clean
......
...@@ -32,12 +32,29 @@ IFLAGS=-I./../contrib/libcseife -I./../contrib/header -I. ...@@ -32,12 +32,29 @@ IFLAGS=-I./../contrib/libcseife -I./../contrib/header -I.
#SFLAGS=-L./../contrib/libcseife -L./../contrib/bin #SFLAGS=-L./../contrib/libcseife -L./../contrib/bin
#IFLAGS=-I./../contrib/libcseife -I./../contrib/header -I. #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 # after this line, no further editing should be necessary
# -------------------------------------------------------- # --------------------------------------------------------
.c.o: # -------------
# pattern rules
# -------------
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $< $(IFLAGS) $(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_SCR = \
snapmerge.c \ snapmerge.c \
...@@ -54,9 +71,9 @@ IFOS2D= \ ...@@ -54,9 +71,9 @@ IFOS2D= \
stf.c \ stf.c \
window_cos.c \ window_cos.c \
calc_mat_change_test.c \ calc_mat_change_test.c \
calc_res.c \ calc_res.c \
calc_misfit.c \ calc_misfit.c \
calc_opt_step.c \ calc_opt_step.c \
calc_energy.c \ calc_energy.c \
checkfd.c \ checkfd.c \
checkfd_ssg_elastic.c \ checkfd_ssg_elastic.c \
...@@ -70,7 +87,7 @@ IFOS2D= \ ...@@ -70,7 +87,7 @@ IFOS2D= \
exchange_s.c \ exchange_s.c \
exchange_p.c \ exchange_p.c \
snap_ssg.c \ snap_ssg.c \
snap_ssg_SH.c \ snap_ssg_SH.c \
seismo_ssg.c \ seismo_ssg.c \
surface_elastic_PML.c \ surface_elastic_PML.c \
surface_acoustic_PML.c \ surface_acoustic_PML.c \
...@@ -83,9 +100,9 @@ IFOS2D= \ ...@@ -83,9 +100,9 @@ IFOS2D= \
update_p_PML.c \ update_p_PML.c \
update_s_elastic_ssg.c \ update_s_elastic_ssg.c \
update_s_elastic_PML.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.c \
update_s_visc_PML_SH.c \ update_s_visc_PML_SH.c \
av_mue.c \ av_mue.c \
av_rho.c \ av_rho.c \
av_tau.c \ av_tau.c \
...@@ -102,7 +119,7 @@ IFOS2D= \ ...@@ -102,7 +119,7 @@ IFOS2D= \
$(MODEL) \ $(MODEL) \
$(MODEL_AC) \ $(MODEL_AC) \
$(MODEL_EL) \ $(MODEL_EL) \
$(MODEL_VAC) \ $(MODEL_VAC) \
matcopy.c \ matcopy.c \
matcopy_elastic.c \ matcopy_elastic.c \
matcopy_acoustic.c \ matcopy_acoustic.c \
...@@ -122,10 +139,10 @@ IFOS2D= \ ...@@ -122,10 +139,10 @@ IFOS2D= \
readmod.c \ readmod.c \
readmod_elastic.c \ readmod_elastic.c \
readmod_acoustic.c \ readmod_acoustic.c \
receiver.c \ receiver.c \
rd_sour.c \ rd_sour.c \
read_workflow.c \ read_workflow.c \
apply_workflow.c \ apply_workflow.c \
saveseis_glob.c \ saveseis_glob.c \
sources.c \ sources.c \
solvelin.c \ solvelin.c \
...@@ -150,33 +167,42 @@ IFOS2D= \ ...@@ -150,33 +167,42 @@ IFOS2D= \
zero_fdveps_ac.c \ zero_fdveps_ac.c \
zero_fdveps_visc.c \ zero_fdveps_visc.c \
calc_envelope.c \ calc_envelope.c \
joint_inversion.c \ joint_inversion.c \
matrix_operations.c \ matrix_operations.c \
wolfe_condition.c \ wolfe_condition.c \
calc_hilbert.c \ calc_hilbert.c \
eprecond.c \ eprecond.c \
eprecond1.c \ eprecond1.c \
zero_fdveps_viscac.c \ zero_fdveps_viscac.c \
update_p_visc_PML.c \ update_p_visc_PML.c \
matcopy_viscac.c \ matcopy_viscac.c \
prepare_update_p.c \ prepare_update_p.c \
readmod_viscac.c \ readmod_viscac.c \
time_window_glob.c \ time_window_glob.c \
create_trkill_table.c \ create_trkill_table.c \
filter_frequencies.c filter_frequencies.c
SNAPMERGE_OBJ = $(SNAPMERGE_SCR:%.c=%.o) # -------------
# 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) snapmerge: $(SNAPMERGE_OBJ)
$(CC) $(SFLAGS) $(SNAPMERGE_OBJ) -o ../bin/snapmerge $(LFLAGS) $(CC) $(SFLAGS) $(SNAPMERGE_OBJ) -o ../bin/snapmerge $(LFLAGS)
IFOS2D: $(IFOS_OBJ) .PHONY: clean
$(CC) $(SFLAGS) $(IFOS_OBJ) -o $(EXEC)/IFOS2D $(LFLAGS)
clean: clean:
find . -name "*.d" -exec rm {} \;
find . -name "*.o" -exec rm {} \; find . -name "*.o" -exec rm {} \;
find . -name "*.c%" -exec rm {} \; find . -name "*.c%" -exec rm {} \;
find . -name "*.bck" -exec rm {} \; find . -name "*.bck" -exec rm {} \;
find ../genmod -name "*.o" -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment