モジュールファイルの依存関係を考えてMakeする方法.
#Makefile considering module dependency F90=gfortran FFLAGS=-fopenmp TARGET=a.out DEPS=deps.d .SUFFIXES : .SUFFIXES : .o .f90 .mod .f90.o: ${F90} -c $< ${FFLAGS} .f90.mod: touch $@ OBJ= modc.o modb.o moda.o main.o SRC=$(OBJ:.o=.f90) .PHONY:all all:${DEPS} ${TARGET} ${TARGET}:${OBJ} ${F90} $^ ${FFLAGS} ${DEPS}:${SRC} gfortran -cpp -MM $^ > $@ # sed -i -e 's/pardiso\.mod//g' $@ -include ${DEPS} .PHONY:clean clean: rm -rf *.o *.mod *.f90~
linux環境とosx環境で使い分ける.
UNAME := $(shell uname) ifeq ($(UNAME), Linux) F90 = gfortran FFLAGS+=-llapack else ifeq ($(UNAME), Darwin) F90 = gfortran FFLAGS+=-framework Accelerate else $(error uname is not Linux nor Darwin) endif