1
- # Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
2
- # Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
3
- # All Rights reserved. See files LICENSE and NOTICE for details.
1
+ # Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2
+ # All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
4
3
#
5
- # This file is part of CEED, a collection of benchmarks, miniapps, software
6
- # libraries and APIs for efficient high-order finite element and spectral
7
- # element discretizations for exascale applications. For more information and
8
- # source code availability see http://github.com/ceed
4
+ # SPDX-License-Identifier: BSD-2-Clause
9
5
#
10
- # The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11
- # a collaborative effort of two U.S. Department of Energy organizations (Office
12
- # of Science and the National Nuclear Security Administration) responsible for
13
- # the planning and preparation of a capable exascale ecosystem, including
14
- # software, applications, hardware, advanced system engineering and early
15
- # testbed platforms, in support of the nation's exascale computing imperative.
6
+ # This file is part of CEED: http://github.com/ceed
16
7
17
8
CONFIG ?= config.mk
18
9
-include $(CONFIG )
@@ -45,7 +36,13 @@ SED ?= sed
45
36
# ASAN must be left empty if you don't want to use it
46
37
ASAN ?=
47
38
48
- LDFLAGS ?=
39
+ # These are the values automatically detected here in the makefile. They are
40
+ # augmented with LDFLAGS and LDLIBS from the environment/passed by command line,
41
+ # if any. If the user sets CEED_LDFLAGS or CEED_LDLIBS, they are used *instead
42
+ # of* what we populate here (thus that's advanced usage and not recommended).
43
+ CEED_LDFLAGS ?=
44
+ CEED_LDLIBS ?=
45
+
49
46
UNDERSCORE ?= 1
50
47
51
48
# Verbose mode, V or VERBOSE
@@ -145,14 +142,14 @@ FFLAGS ?= $(OPT) $(FFLAGS.$(FC_VENDOR))
145
142
ifeq ($(COVERAGE ) , 1)
146
143
CFLAGS += --coverage
147
144
CXXFLAGS += --coverage
148
- LDFLAGS += --coverage
145
+ CEED_LDFLAGS += --coverage
149
146
endif
150
147
151
148
CFLAGS += $(if $(ASAN ) ,$(AFLAGS ) )
152
149
FFLAGS += $(if $(ASAN ) ,$(AFLAGS ) )
153
- LDFLAGS += $(if $(ASAN ) ,$(AFLAGS ) )
150
+ CEED_LDFLAGS += $(if $(ASAN ) ,$(AFLAGS ) )
154
151
CPPFLAGS += -I./include
155
- LDLIBS = -lm
152
+ CEED_LDLIBS = -lm
156
153
OBJDIR := build
157
154
LIBDIR := lib
158
155
@@ -275,8 +272,8 @@ info:
275
272
$(info FFLAGS = $(value FFLAGS) )
276
273
$(info NVCCFLAGS = $(value NVCCFLAGS) )
277
274
$(info HIPCCFLAGS = $(value HIPCCFLAGS) )
278
- $(info LDFLAGS = $(value LDFLAGS ) )
279
- $(info LDLIBS = $(LDLIBS ) )
275
+ $(info CEED_LDFLAGS = $(value CEED_LDFLAGS ) )
276
+ $(info CEED_LDLIBS = $(value CEED_LDLIBS ) )
280
277
$(info AR = $(AR ) )
281
278
$(info ARFLAGS = $(ARFLAGS ) )
282
279
$(info OPT = $(OPT ) )
@@ -309,7 +306,7 @@ info-backends-all:
309
306
$(info make: 'lib' with backends: $(filter-out $(TEST_BACKENDS ) ,$(BACKENDS ) ) )
310
307
@true
311
308
312
- $(libceed.so ) : LDFLAGS += $(if $(DARWIN ) , -install_name @rpath/$(notdir $(libceed.so ) ) )
309
+ $(libceed.so ) : CEED_LDFLAGS += $(if $(DARWIN ) , -install_name @rpath/$(notdir $(libceed.so ) ) )
313
310
314
311
# Standard Backends
315
312
libceed.c += $(ref.c )
@@ -339,6 +336,8 @@ endif
339
336
340
337
# Collect list of libraries and paths for use in linking and pkg-config
341
338
PKG_LIBS =
339
+ # Stubs that will not be RPATH'd
340
+ PKG_STUBS_LIBS =
342
341
343
342
# libXSMM Backends
344
343
XSMM_BACKENDS = /cpu/self/xsmm/serial /cpu/self/xsmm/blocked
@@ -386,6 +385,7 @@ CUDA_BACKENDS = /gpu/cuda/ref /gpu/cuda/shared /gpu/cuda/gen
386
385
ifneq ($(CUDA_LIB_DIR ) ,)
387
386
$(libceeds ) : CPPFLAGS += -I$(CUDA_DIR ) /include
388
387
PKG_LIBS += -L$(abspath $(CUDA_LIB_DIR ) ) -lcudart -lnvrtc -lcuda -lcublas
388
+ PKG_STUBS_LIBS += -L$(CUDA_LIB_DIR_STUBS )
389
389
LIBCEED_CONTAINS_CXX = 1
390
390
libceed.c += interface/ceed-cuda.c
391
391
libceed.c += $(cuda.c ) $(cuda-ref.c ) $(cuda-shared.c ) $(cuda-gen.c )
@@ -458,18 +458,18 @@ export BACKENDS
458
458
459
459
_pkg_ldflags = $(filter -L% ,$(PKG_LIBS ) )
460
460
_pkg_ldlibs = $(filter-out -L% ,$(PKG_LIBS ) )
461
- $(libceeds ) : LDFLAGS += $(_pkg_ldflags ) $(_pkg_ldflags:-L%=-Wl,-rpath,% )
462
- $(libceeds ) : LDLIBS += $(_pkg_ldlibs )
461
+ $(libceeds ) : CEED_LDFLAGS += $(_pkg_ldflags ) $(_pkg_ldflags:-L%=-Wl,-rpath,% ) $( PKG_STUBS_LIBS )
462
+ $(libceeds ) : CEED_LDLIBS += $(_pkg_ldlibs )
463
463
ifeq ($(STATIC ) ,1)
464
- $(examples ) $(tests ) : LDFLAGS += $(_pkg_ldflags ) $(_pkg_ldflags:-L%=-Wl,-rpath,% )
465
- $(examples ) $(tests ) : LDLIBS += $(_pkg_ldlibs )
464
+ $(examples ) $(tests ) : CEED_LDFLAGS += $(_pkg_ldflags ) $(_pkg_ldflags:-L%=-Wl,-rpath,% ) $( PKG_STUBS_LIBS )
465
+ $(examples ) $(tests ) : CEED_LDLIBS += $(_pkg_ldlibs )
466
466
endif
467
467
468
468
pkgconfig-libs-private = $(PKG_LIBS )
469
469
ifeq ($(LIBCEED_CONTAINS_CXX ) ,1)
470
470
$(libceeds ) : LINK = $(CXX )
471
471
ifeq ($(STATIC),1)
472
- $(examples ) $(tests ) : LDLIBS += $(LIBCXX )
472
+ $(examples ) $(tests ) : CEED_LDLIBS += $(LIBCXX )
473
473
pkgconfig-libs-private += $(LIBCXX )
474
474
endif
475
475
endif
@@ -482,7 +482,7 @@ libceed.o = $(libceed.c:%.c=$(OBJDIR)/%.o) $(libceed.cpp:%.cpp=$(OBJDIR)/%.o) $(
482
482
$(filter % fortran.o,$(libceed.o ) ) : CPPFLAGS += $(if $(filter 1,$(UNDERSCORE ) ) ,-DUNDERSCORE)
483
483
$(libceed.o ) : | info-backends
484
484
$(libceed.so ) : $(call weak_last,$(libceed.o ) ) | $$(@D ) /.DIR
485
- $(call quiet,LINK) $(LDFLAGS ) -shared -o $@ $^ $(LDLIBS )
485
+ $(call quiet,LINK) $(LDFLAGS ) $( CEED_LDFLAGS ) -shared -o $@ $^ $( CEED_LDLIBS ) $(LDLIBS )
486
486
487
487
$(libceed.a ) : $(call weak_last,$(libceed.o ) ) | $$(@D ) /.DIR
488
488
$(call quiet,AR) $(ARFLAGS ) $@ $^
@@ -500,16 +500,16 @@ $(OBJDIR)/%.o : $(CURDIR)/%.hip.cpp | $$(@D)/.DIR
500
500
$(call quiet,HIPCC) $(HIPCCFLAGS ) -c -o $@ $(abspath $< )
501
501
502
502
$(OBJDIR ) /% : tests/% .c | $$(@D ) /.DIR
503
- $(call quiet,LINK.c) $(CEED_LDFLAGS ) -o $@ $(abspath $< ) $(CEED_LIBS ) $(LDLIBS )
503
+ $(call quiet,LINK.c) $(CEED_LDFLAGS ) -o $@ $(abspath $< ) $(CEED_LIBS ) $(CEED_LDLIBS ) $( LDLIBS )
504
504
505
505
$(OBJDIR ) /% : tests/% .f90 | $$(@D ) /.DIR
506
- $(call quiet,LINK.F) -DSOURCE_DIR=' "$(abspath $(<D))/"' $(CEED_LDFLAGS ) -o $@ $(abspath $< ) $(CEED_LIBS ) $(LDLIBS )
506
+ $(call quiet,LINK.F) -DSOURCE_DIR=' "$(abspath $(<D))/"' $(CEED_LDFLAGS ) -o $@ $(abspath $< ) $(CEED_LIBS ) $(CEED_LDLIBS ) $( LDLIBS )
507
507
508
508
$(OBJDIR ) /% : examples/ceed/% .c | $$(@D ) /.DIR
509
- $(call quiet,LINK.c) $(CEED_LDFLAGS ) -o $@ $(abspath $< ) $(CEED_LIBS ) $(LDLIBS )
509
+ $(call quiet,LINK.c) $(CEED_LDFLAGS ) -o $@ $(abspath $< ) $(CEED_LIBS ) $(CEED_LDLIBS ) $( LDLIBS )
510
510
511
511
$(OBJDIR ) /% : examples/ceed/% .f | $$(@D ) /.DIR
512
- $(call quiet,LINK.F) -DSOURCE_DIR=' "$(abspath $(<D))/"' $(CEED_LDFLAGS ) -o $@ $(abspath $< ) $(CEED_LIBS ) $(LDLIBS )
512
+ $(call quiet,LINK.F) -DSOURCE_DIR=' "$(abspath $(<D))/"' $(CEED_LDFLAGS ) -o $@ $(abspath $< ) $(CEED_LIBS ) $(CEED_LDLIBS ) $( LDLIBS )
513
513
514
514
$(OBJDIR ) /mfem-% : examples/mfem/% .cpp $(libceed ) | $$(@D ) /.DIR
515
515
+$(MAKE ) -C examples/mfem CEED_DIR=` pwd` \
@@ -553,7 +553,7 @@ $(OBJDIR)/solids-% : examples/solids/%.c examples/solids/%.h \
553
553
554
554
$(examples ) : $(libceed )
555
555
$(tests ) : $(libceed )
556
- $(tests ) $(examples ) : LDFLAGS += -Wl,-rpath,$(abspath $(LIBDIR ) ) -L$(LIBDIR )
556
+ $(tests ) $(examples ) : override LDFLAGS += -Wl,-rpath,$(abspath $(LIBDIR ) ) -L$(LIBDIR )
557
557
558
558
run-% : $(OBJDIR ) /%
559
559
@tests/tap.sh $(<:$(OBJDIR ) /%=% )
0 commit comments