diff --git a/Makefile b/Makefile index a4e0266..7419c5f 100644 --- a/Makefile +++ b/Makefile @@ -45,9 +45,9 @@ MODULES = $(filter-out $(OBJDIR)/main%,$(OBJECTS)) # Build outputs GRAY = $(BINDIR)/gray -LIBGRAY = $(LIBDIR)/libgray +LIBGRAY = $(LIBDIR)/libgray.so BINARIES = $(GRAY) -LIBRARIES = $(LIBGRAY).so +LIBRARIES = $(LIBGRAY) ## ## Git information (used in the version string) @@ -67,6 +67,7 @@ GIT_DIRTY ?= $(shell test -n "$$(git status --porcelain)" && echo "-dirty") FC = gfortran LD = gfortran FFLAGS += -J$(OBJDIR) -I$(INCDIR) -ffree-line-length-none -fPIC +LDFLAGS += -L$(LIBDIR) CPPFLAGS += -DREVISION=\"$(GIT_REV)$(GIT_DIRTY)\" -DPREFIX=\"$(PREFIX)\" ifndef DETERMINISTIC @@ -78,8 +79,11 @@ endif # Static build options ifdef STATIC +LIBGRAY := $(LIBGRAY:so=a) LIBRARIES := $(LIBRARIES:so=a) LDFLAGS += -static +else +LDFLAGS += -Wl,-rpath '$$ORIGIN/../lib/' endif # Debug build options @@ -119,20 +123,20 @@ install: $(BINARIES) $(LIBRARIES) $(SHAREDIR)/doc $(SHAREDIR)/gray.1 $(OBJDIR)/%.o: $(OBJDIR)/%.d # GRAY binary -$(GRAY): $(OBJDIR)/main.o $(LIBGRAY).a | $(BINDIR) - $(LD) $(LDFLAGS) -o '$@' $^ +$(GRAY): $(OBJDIR)/main.o $(LIBGRAY) | $(BINDIR) + $(LD) $(LDFLAGS) -o '$@' $< -lgray # GRAY shared library -$(LIBGRAY).so: $(MODULES) | $(LIBDIR) +$(LIBDIR)/libgray.so: $(MODULES) | $(LIBDIR) $(LD) -shared $(LDFLAGS) -o '$@' $^ # GRAY static library -$(LIBGRAY).a($(MODULES)): | $(LIBDIR) -$(LIBGRAY).a: $(LIBGRAY).a($(MODULES)) +$(LIBDIR)/libgray.a($(MODULES)): | $(LIBDIR) +$(LIBDIR)/libgray.a: $(LIBDIR)/libgray.a($(MODULES)) # GRAY static library when compiling from JETTO -include ../include.mk -$(JLIBDIR)/libgray.a: $(LIBGRAY).a +$(JLIBDIR)/libgray.a: $(LIBDIR)/libgray.a install -Dm755 '$<' '$@' # All documentation