diff --git a/Makefile b/Makefile index 051e11682..9d5177d17 100644 --- a/Makefile +++ b/Makefile @@ -184,12 +184,22 @@ else endif # GSL (GNU Scientific Library) -LDFLAGS += $(shell pkg-config --libs gsl) CXXFLAGS += $(shell pkg-config --cflags gsl) -# GSL option 1: Use pkg-config or gsl-config to find GSL -# -# GSL option 2: Use default search paths to find GSL -# LDFLAGS += -lgsl -lgslcblas -lm + +ifeq ($(STATICGSL),) + # default to dynamic linking + STATICGSL := OFF +endif + +ifeq ($(STATICGSL),ON) + gsllibdir := $(shell pkg-config --variable=libdir gsl) + gsl_objects = $(gsllibdir)/libgsl.a $(gsllibdir)/libgslcblas.a + BUILD_DIR := $(BUILD_DIR)_staticgsl +else ifeq ($(STATICGSL),OFF) + LDFLAGS += $(shell pkg-config --libs gsl) +else + $(error bad value for STATICGSL option. Should be ON or OFF) +endif # Use GSL inline functions CXXFLAGS += -DHAVE_INLINE -DGSL_C99_INLINE @@ -288,21 +298,21 @@ check: $(sn3d_files) run-clang-tidy $(sn3d_files) $(BUILD_DIR)/sn3d: $(sn3d_objects) - $(CXX) $(CXXFLAGS) $(sn3d_objects) $(LDFLAGS) -o $(BUILD_DIR)/sn3d + $(CXX) $(CXXFLAGS) $(sn3d_objects) $(gsl_objects) $(LDFLAGS) -o $(BUILD_DIR)/sn3d -include $(sn3d_dep) sn3d: $(BUILD_DIR)/sn3d ln -sf $(BUILD_DIR)/sn3d sn3d $(BUILD_DIR)/sn3dwhole: $(sn3d_files) version.h artisoptions.h Makefile $(BUILD_DIR)/compiler.txt - $(CXX) $(CXXFLAGS) -g $(sn3d_files) $(LDFLAGS) -o $(BUILD_DIR)/sn3dwhole + $(CXX) $(CXXFLAGS) -g $(sn3d_files) $(gsl_objects) $(LDFLAGS) -o $(BUILD_DIR)/sn3dwhole -include $(sn3d_dep) sn3dwhole: $(BUILD_DIR)/sn3dwhole ln -sf $(BUILD_DIR)/sn3dwhole sn3d $(BUILD_DIR)/exspec: $(exspec_objects) - $(CXX) $(CXXFLAGS) $(exspec_objects) $(LDFLAGS) -o $(BUILD_DIR)/exspec + $(CXX) $(CXXFLAGS) $(exspec_objects) $(gsl_objects) $(LDFLAGS) -o $(BUILD_DIR)/exspec -include $(exspec_dep) exspec: $(BUILD_DIR)/exspec