Makefile: link gray to libgray

This changes gray to always link to libgray, either statically or dynamically.
This commit is contained in:
Michele Guerini Rocco 2023-10-17 11:05:36 +02:00
parent af1ed7d1b6
commit b25cdf5f35
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450

View File

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