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
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