xref: /libCEED/Makefile (revision 2c6ea02f2fb8b8b050b68c11c67ccb50960f8881)
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=%)
29examples.c := $(sort $(wildcard examples/*.c))
30examples  := $(examples.c:%.c=%)
31
32.SUFFIXES:
33.SUFFIXES: .c .o .d
34
35$(libceed) : $(libceed.c:%.c=%.o)
36	$(CC) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS)
37
38$(tests) $(examples) : $(libceed)
39$(tests) $(examples) : LDFLAGS += -Wl,-rpath,. -L.
40t/t% : t/t%.c $(libceed)
41examples/% : examples/%.c $(libceed)
42
43run-t% : t/t%
44	@./tap.sh $(<:t/%=%)
45
46test : $(tests:t/%=run-%)
47
48examples : $(examples)
49
50.PHONY: clean print test examples
51clean :
52	$(RM) *.o t/*.o *.d t/*.d $(libceed) $(tests.c:%.c=%)
53	$(RM) -r *.dSYM
54
55print :
56	@echo $(VAR)=$($(VAR))
57
58print-%:
59	$(info [ variable name]: $*)
60	$(info [        origin]: $(origin $*))
61	$(info [         value]: $(value $*))
62	$(info [expanded value]: $($*))
63	$(info )
64	@true
65
66-include $(libceed.c:%.c=%.d) $(tests.c:%.c=%.d)
67