Add script to generate dependencies. Use it in makefile.
Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
parent
7124852093
commit
7fc44367d0
141
build/makefile
141
build/makefile
@ -1,3 +1,12 @@
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# directories indicating where the source files are, where the object files
|
||||
# should be created and where to save the resulting executable file
|
||||
|
||||
SRCSDIR := ../src
|
||||
OBJSDIR := ./obj
|
||||
DESTDIR := .
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# include configuration
|
||||
@ -42,17 +51,16 @@ endif
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# check flag conditions
|
||||
# generate new makedeps file if does not exists
|
||||
#
|
||||
$(info Generating dependencies.)
|
||||
$(shell ./mkdeps.sh $(SRCSDIR) $(OBJSDIR) > makedeps)
|
||||
$(shell sleep 1)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# directories indicating where the source files are, where the object files
|
||||
# should be created and where to save the resulting executable file
|
||||
|
||||
SRCSDIR := ../src
|
||||
OBJSDIR := ./obj
|
||||
DESTDIR := .
|
||||
# check flag conditions
|
||||
#
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
@ -77,7 +85,7 @@ FFLAGS += ${CPPPREFIX}-D${OUTPUT}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
name = amun
|
||||
name = amun
|
||||
|
||||
modules = algebra blocks boundaries constants coordinates domains driver \
|
||||
equations error evolution gravity integrals interpolations io mesh \
|
||||
@ -89,15 +97,12 @@ objects := $(addprefix $(OBJSDIR)/,$(addsuffix .o, $(modules)))
|
||||
|
||||
all: $(name).x
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJSDIR) $(DESTDIR)/$(name).x
|
||||
|
||||
$(OBJSDIR)/%.o : $(SRCSDIR)/%.F90 makefile
|
||||
$(FC) -c $(FFLAGS) -J $(OBJSDIR) $< -o $@
|
||||
|
||||
$(name).x: $(objects) | $(DESTDIR)
|
||||
$(name).x: $(deps) $(objects) | $(DESTDIR)
|
||||
$(LD) $(LDFLAGS) $(objects) $(LIBS) -o $(DESTDIR)/$(name).x
|
||||
|
||||
$(OBJSDIR)/%.o : $(SRCSDIR)/%.F90
|
||||
$(FC) -c $(FFLAGS) -J $(OBJSDIR) $< -o $@
|
||||
|
||||
$(objects): | $(OBJSDIR)
|
||||
|
||||
$(OBJSDIR):
|
||||
@ -106,103 +111,13 @@ $(OBJSDIR):
|
||||
$(DESTDIR):
|
||||
mkdir -p $(DESTDIR)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# object files dependencies
|
||||
#
|
||||
algebra_deps = constants error
|
||||
blocks_deps = error timers
|
||||
boundaries_deps = blocks coordinates equations error gravity \
|
||||
interpolations mpitools timers user_problem
|
||||
constants_deps =
|
||||
coordinates_deps = parameters
|
||||
driver_deps = blocks coordinates equations evolution gravity integrals \
|
||||
interpolations io mesh mpitools operators parameters \
|
||||
problems random refinement schemes shapes sources \
|
||||
user_problem
|
||||
equations_deps = algebra coordinates error parameters timers
|
||||
error_deps =
|
||||
evolution_deps = blocks boundaries coordinates equations mesh mpitools \
|
||||
parameters schemes shapes sources
|
||||
domains_deps = blocks boundaries coordinates parameters
|
||||
gravity_deps = parameters timers user_problem
|
||||
integrals_deps = blocks coordinates equations error evolution mpitools \
|
||||
parameters timers
|
||||
interpolations_deps = algebra blocks coordinates error parameters timers
|
||||
io_deps = blocks coordinates equations error evolution mesh \
|
||||
mpitools random refinement timers
|
||||
mesh_deps = blocks coordinates domains equations error \
|
||||
interpolations mpitools problems refinement timers
|
||||
mpitools_deps = error timers
|
||||
operators_deps = timers
|
||||
parameters_deps = mpitools
|
||||
problems_deps = blocks constants coordinates equations error parameters \
|
||||
random timers user_problem
|
||||
random_deps = mpitools parameters
|
||||
refinement_deps = blocks coordinates equations operators parameters timers
|
||||
schemes_deps = algebra coordinates equations interpolations timers
|
||||
shapes_deps = blocks constants coordinates equations parameters timers \
|
||||
user_problem
|
||||
sources_deps = blocks coordinates equations gravity operators \
|
||||
parameters timers user_problem
|
||||
timers_deps =
|
||||
user_problem_deps = blocks constants coordinates equations error operators \
|
||||
parameters random timers
|
||||
utils_deps = error
|
||||
|
||||
$(OBJSDIR)/algebra.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(algebra_deps)))
|
||||
$(OBJSDIR)/blocks.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(blocks_deps)))
|
||||
$(OBJSDIR)/boundaries.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(boundaries_deps)))
|
||||
$(OBJSDIR)/constants.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(constants_deps)))
|
||||
$(OBJSDIR)/coordinates.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(coordinates_deps)))
|
||||
$(OBJSDIR)/driver.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(driver_deps)))
|
||||
$(OBJSDIR)/equations.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(equations_deps)))
|
||||
$(OBJSDIR)/error.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(error_deps)))
|
||||
$(OBJSDIR)/evolution.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(evolution_deps)))
|
||||
$(OBJSDIR)/domains.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(domains_deps)))
|
||||
$(OBJSDIR)/gravity.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(gravity_deps)))
|
||||
$(OBJSDIR)/integrals.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(integrals_deps)))
|
||||
$(OBJSDIR)/interpolations.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(interpolations_deps)))
|
||||
$(OBJSDIR)/io.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(io_deps)))
|
||||
$(OBJSDIR)/mesh.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(mesh_deps)))
|
||||
$(OBJSDIR)/mpitools.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(mpitools_deps)))
|
||||
$(OBJSDIR)/operators.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(operators_deps)))
|
||||
$(OBJSDIR)/parameters.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(parameters_deps)))
|
||||
$(OBJSDIR)/problems.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(problems_deps)))
|
||||
$(OBJSDIR)/random.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(random_deps)))
|
||||
$(OBJSDIR)/refinement.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(refinement_deps)))
|
||||
$(OBJSDIR)/schemes.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(schemes_deps)))
|
||||
$(OBJSDIR)/shapes.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(shapes_deps)))
|
||||
$(OBJSDIR)/sources.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(sources_deps)))
|
||||
$(OBJSDIR)/timers.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(timers_deps)))
|
||||
$(OBJSDIR)/user_problem.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(user_problem_deps)))
|
||||
$(OBJSDIR)/utils.o : $(addprefix $(OBJSDIR)/,$(addsuffix .o, \
|
||||
$(utils_deps)))
|
||||
clean:
|
||||
rm -rf $(OBJSDIR) $(DESTDIR)/$(name).x
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# object files dependencies (generated using mkdeps.sh script)
|
||||
#
|
||||
include makedeps
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
14
build/mkdeps.sh
Executable file
14
build/mkdeps.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
files=`ls $1/*.F90`
|
||||
for src in $files; do
|
||||
deps=`grep -i ' use ' $src | awk '{ print $2 }' | sed 's/,//g' | sort | uniq`
|
||||
fname=`basename $src .F90`
|
||||
output="$2/${fname}.o: $src"
|
||||
for dep in $deps; do
|
||||
if [ $dep != "mpi" -a $dep != "hdf5" ]; then
|
||||
output="${output} $2/$dep.o"
|
||||
fi
|
||||
done
|
||||
echo $output
|
||||
done
|
Loading…
x
Reference in New Issue
Block a user