# Fortran compiler. Only gfortran, specifically its invocation through gcc,
# correctly produces a static link on all tested platforms.
FC = $(or $(RESP_COMPILER),gcc)

FLAGS = -v

OBJS= resp.o
SRCS= resp.f

# A trick to statically link selected libraries, which works on macOS, since
# the -Wl,Bstatic/dynamic and -l:libgfortran.a approaches only work with the
# GNU `ld`. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46539#c3
# and https://stackoverflow.com/a/5583245
vpath %.a $(RESP_VPATH)
.LIBPATTERNS = lib%.a lib%.dylib lib%.so
STATICLIBS = -lgfortran -lquadmath

resp:	$(OBJS) $(STATICLIBS)
	# -lm is needed on Linux per https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46539#c3
	$(FC) $(FLAGS) $^ -lm -o resp

clean:
	rm -rf $(OBJS) resp

