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 21OBJDIR := build 22LIBDIR := . 23 24PROVE ?= prove 25DARWIN := $(filter Darwin,$(shell uname -s)) 26SO_EXT := $(if $(DARWIN),dylib,so) 27 28libceed := $(LIBDIR)/libceed.$(SO_EXT) 29libceed.c := $(wildcard ceed*.c) 30tests.c := $(sort $(wildcard tests/t[0-9][0-9]-*.c)) 31tests := $(tests.c:tests/%.c=$(OBJDIR)/%) 32examples.c := $(sort $(wildcard examples/*.c)) 33examples := $(examples.c:examples/%.c=$(OBJDIR)/%) 34 35.SUFFIXES: 36.SUFFIXES: .c .o .d 37.SECONDEXPANSION: # to expand $$(@D)/.DIR 38 39%/.DIR : 40 @mkdir -p $(@D) 41 @touch $@ 42 43.PRECIOUS: %/.DIR 44 45$(libceed) : LDFLAGS += $(if $(DARWIN), -install_name $(abspath $(libceed))) 46$(libceed) : $(libceed.c:%.c=$(OBJDIR)/%.o) 47 $(CC) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS) 48 49$(OBJDIR)/%.o : %.c | $$(@D)/.DIR 50 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $^ 51 52$(OBJDIR)/% : tests/%.c | $$(@D)/.DIR 53 $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) 54 55$(OBJDIR)/%.o : examples/%.c | $$(@D)/.DIR 56 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $^ 57 58$(tests) $(examples) : $(libceed) 59$(tests) $(examples) : LDFLAGS += -Wl,-rpath,$(LIBDIR) -L$(LIBDIR) 60$(OBJDIR)/t% : tests/t%.c $(libceed) 61$(OBJDIR)/ex% : examples/ex%.c $(libceed) 62 63run-t% : $(OBJDIR)/t% 64 @tests/tap.sh $(<:build/%=%) 65 66test : $(tests:$(OBJDIR)/t%=run-t%) 67 68prove : $(tests) 69 $(PROVE) --exec tests/tap.sh $(CEED_PROVE_OPTS) $(tests:$(OBJDIR)/%=%) 70 71examples : $(examples) 72 73.PHONY: clean print test examples astyle 74clean : 75 $(RM) *.o $(OBJDIR)/*.o *.d $(OBJDIR)/*.d $(libceed) $(tests.c:%.c=%) 76 $(RM) -r *.dSYM 77 $(MAKE) -C examples/mfem clean 78 79astyle : 80 astyle --style=google --indent=spaces=2 --max-code-length=80 \ 81 --keep-one-line-statements --keep-one-line-blocks --lineend=linux \ 82 --suffix=none --preserve-date --formatted \ 83 *.[ch] tests/*.[ch] examples/*.[ch] examples/mfem/*.[ch]pp 84 85 86print : 87 @echo $(VAR)=$($(VAR)) 88 89print-%: 90 $(info [ variable name]: $*) 91 $(info [ origin]: $(origin $*)) 92 $(info [ value]: $(value $*)) 93 $(info [expanded value]: $($*)) 94 $(info ) 95 @true 96 97-include $(libceed.c:%.c=%.d) $(tests.c:%.c=%.d) 98