xref: /libCEED/Makefile (revision 8827639d115747a6aed044c2b0300df43f9c7cb4)
1# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3# reserved. See files LICENSE and NOTICE for details.
4#
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.
9#
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.
16
17CFLAGS = -std=c99 -Wall -Wextra -Wno-unused-parameter -fPIC -MMD -MP
18CFLAGS += $(if $(NDEBUG),-O2,-g)
19CPPFLAGS = -I.
20LDLIBS = -lm
21
22DARWIN := $(filter Darwin,$(shell uname -s))
23SO_EXT := $(if $(DARWIN),dylib,so)
24
25libceed := libceed.$(SO_EXT)
26libceed.c := $(wildcard ceed*.c)
27tests.c   := $(sort $(wildcard t/t[0-9][0-9]-*.c))
28tests     := $(tests.c:%.c=%)
29
30.SUFFIXES:
31.SUFFIXES: .c .o .d
32
33$(libceed) : $(libceed.c:%.c=%.o)
34	$(CC) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS)
35
36$(tests) : $(libceed)
37$(tests) : LDFLAGS += -Wl,-rpath,. -L.
38t/t% : t/t%.c $(libceed)
39
40run-t% : t/t%
41	@./tap.sh $(<:t/%=%)
42
43test : $(tests:t/%=run-%)
44
45.PHONY: clean print
46clean :
47	$(RM) *.o t/*.o *.d t/*.d $(libceed) $(tests.c:%.c=%)
48	$(RM) -r *.dSYM
49
50print :
51	@echo $(VAR)=$($(VAR))
52
53print-%:
54	$(info [ variable name]: $*)
55	$(info [        origin]: $(origin $*))
56	$(info [         value]: $(value $*))
57	$(info [expanded value]: $($*))
58	$(info )
59	@true
60
61-include $(libceed.c:%.c=%.d) $(tests.c:%.c=%.d)
62