Skip to content

Commit bcf9115

Browse files
Merge pull request #123 from PFLAREProject/conda_linking
Build update for mac osx and shared libraries
2 parents 5fd79ed + d059d19 commit bcf9115

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Makefile

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ ifneq (,$(findstring PETSC_HAVE_KOKKOS 1,$(CONTENTS)))
5959
export PETSC_HAVE_KOKKOS := 1
6060
endif
6161

62+
# To prevent overlinking with conda builds, only explicitly link
63+
# to the libraries we use in pflare
64+
ifeq ($(CONDA_BUILD),1)
65+
PETSC_LINK_LIBS = -L${PETSC_DIR}/${PETSC_ARCH}/lib -lpetsc ${BLASLAPACK_LIB}
66+
ifeq ($(PETSC_HAVE_KOKKOS),1)
67+
PETSC_LINK_LIBS += ${KOKKOS_LIB} ${KOKKOS_KERNELS_LIB}
68+
endif
69+
# Otherwise just use everything petsc uses to be safe
70+
else
71+
PETSC_LINK_LIBS = $(LDLIBS)
72+
endif
73+
6274
# ~~~~~~~~~~~~~~~~~~~~~~~~
6375
# ~~~~~~~~~~~~~~~~~~~~~~~~
6476

@@ -158,8 +170,14 @@ $(OUT): $(OBJS)
158170
ifeq ($(PETSC_USE_SHARED_LIBRARIES),0)
159171
$(AR) $(AR_FLAGS) $(OUT) $(OBJS)
160172
$(RANLIB) $(OUT)
173+
else
174+
ifeq ($(findstring darwin,$(PETSC_ARCH)),darwin)
175+
# macOS: Use -dynamiclib and set a relocatable @rpath install_name.
176+
$(LINK.F) -dynamiclib -o $(OUT) $(OBJS) $(PETSC_LINK_LIBS) -install_name @rpath/$(notdir $(OUT))
161177
else
162-
$(LINK.F) -shared -o $(OUT) $(OBJS) $(LDLIBS)
178+
# Linux: Use -shared and set the soname.
179+
$(LINK.F) -shared -o $(OUT) $(OBJS) $(PETSC_LINK_LIBS) -Wl,-soname,$(notdir $(OUT))
180+
endif
163181
endif
164182

165183
# Generate dependencies for parallel build with makedepf90

0 commit comments

Comments
 (0)