diff --git a/Cahn_Hilliard_FFT_2D/Makefile b/Cahn_Hilliard_FFT_2D/Makefile index 66397f2..b81bebb 100644 --- a/Cahn_Hilliard_FFT_2D/Makefile +++ b/Cahn_Hilliard_FFT_2D/Makefile @@ -1,29 +1,67 @@ -FDIR=functions -SDIR=solverloop -CC=gcc -CFLAGS=-I. - -_FUNCTION_DEPS = global_vars.h functions.h matrix.h utility_functions.h \ - filling.h reading_input_parameters.h free_variables.h fill_domain.h - +SHELL ?= /bin/sh + +# Toolchain (Spack injects compiler wrapper) +CC ?= cc + +# Directories +FDIR ?= functions +SDIR ?= solverloop + +# Flags (do not overwrite Spack flags) +CFLAGS ?= +CPPFLAGS ?= +LDFLAGS ?= +LIBS ?= + +# Local includes +CPPFLAGS += -I. + +# ------------------------------------------------------------------------------ +# Dependencies +# ------------------------------------------------------------------------------ + +_FUNCTION_DEPS = global_vars.h functions.h matrix.h utility_functions.h \ + filling.h reading_input_parameters.h free_variables.h \ + fill_domain.h + DEPS = $(patsubst %,$(FDIR)/%,$(_FUNCTION_DEPS)) -_SOLVERLOOP_DEPS = serialinfo_xy.h GibbsEnergyData.h functions_fftw.h file_writer.h +_SOLVERLOOP_DEPS = serialinfo_xy.h GibbsEnergyData.h \ + functions_fftw.h file_writer.h DEPS += $(patsubst %,$(SDIR)/%,$(_SOLVERLOOP_DEPS)) +# ------------------------------------------------------------------------------ +# Libraries (FFTW provided by Spack) +# ------------------------------------------------------------------------------ +LIBS += -lfftw3 -lm -LIBS =-lfftw3 -lm +# ------------------------------------------------------------------------------ +# Targets +# ------------------------------------------------------------------------------ +TARGET = microsim_ch_fft -microsim_ch_fft : microsim_ch_fft.o - $(CC) -o microsim_ch_fft microsim_ch_fft.o $(CFLAGS) $(LIBS) +all: $(TARGET) -microsim_ch_fft.o : $(DEPS) +$(TARGET): microsim_ch_fft.o + $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) -.PHONY : clean +microsim_ch_fft.o: $(DEPS) -clean : +# ------------------------------------------------------------------------------ +# Install (required by Spack) +# ------------------------------------------------------------------------------ +PREFIX ?= /usr/local +BINDIR ?= $(PREFIX)/bin - rm -r microsim_ch_fft.o microsim_ch_fft +install: $(TARGET) + mkdir -p $(DESTDIR)$(BINDIR) + cp $(TARGET) $(DESTDIR)$(BINDIR)/ +# ------------------------------------------------------------------------------ +# Cleanup +# ------------------------------------------------------------------------------ +clean: + rm -f microsim_ch_fft.o $(TARGET) +.PHONY: all install clean