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 17CC = gcc 18 19NDEBUG ?= 20LDFLAGS ?= 21LOADLIBES ?= 22TARGET_ARCH ?= 23 24pwd = $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST))))) 25 26SANTIZ = -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer 27CFLAGS = -std=c99 -Wall -Wextra -Wno-unused-parameter -fPIC -MMD -MP -march=native 28CFLAGS += $(if $(NDEBUG),,)#$(SANTIZ)) 29CFLAGS += $(if $(NDEBUG),-O2,-g) 30LDFLAGS += $(if $(NDEBUG),,)#$(SANTIZ)) 31CPPFLAGS = -I. -I/home/camier1/home/occa/occa-1.0/include #-I/usr/local/cuda-8.0/include 32LDLIBS = -lm 33LDLIBS += -L/home/camier1/home/occa/occa-1.0/lib -locca -lrt -ldl 34#LDLIBS += -L/usr/local/cuda/lib64 -lcuda 35OBJDIR := build 36LIBDIR := . 37NPROCS := $(shell getconf _NPROCESSORS_ONLN) 38MFLAGS := --no-print-directory -j $(NPROCS) --warn-undefined-variables 39 40PROVE ?= prove 41DARWIN := $(filter Darwin,$(shell uname -s)) 42SO_EXT := $(if $(DARWIN),dylib,so) 43 44libceed := $(LIBDIR)/libceed.$(SO_EXT) 45libceed.c := $(wildcard ceed*.c) 46tests.c := $(sort $(wildcard tests/t[0-9][0-9]-*.c)) 47tests := $(tests.c:tests/%.c=$(OBJDIR)/%) 48examples.c := $(sort $(wildcard examples/*.c)) 49examples := $(examples.c:examples/%.c=$(OBJDIR)/%) 50 51.SUFFIXES: 52.SUFFIXES: .c .o .d 53.SECONDEXPANSION: # to expand $$(@D)/.DIR 54 55%/.DIR : 56 @mkdir -p $(@D) 57 @touch $@ 58 59.PRECIOUS: %/.DIR 60 61all dbg:;$(MAKE) $(MFLAGS) $(libceed) $(tests) Makefile 62opt:;NDEBUG=1 $(MAKE) $(MFLAGS) $(libceed) $(tests) Makefile 63 64$(libceed) : $(libceed.c:%.c=$(OBJDIR)/%.o) 65 $(CC) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS) 66 67$(OBJDIR)/%.o : $(pwd)/%.c | $$(@D)/.DIR 68 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $^ 69 70$(OBJDIR)/%.o : $(pwd)/tests/%.c | $$(@D)/.DIR 71 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< 72 73$(OBJDIR)/%.o : $(pwd)/examples/%.c | $$(@D)/.DIR 74 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $^ 75 76$(tests) $(examples) : $(libceed) 77$(tests) $(examples) : LDFLAGS += -Wl,-rpath,$(LIBDIR) -L$(LIBDIR) 78$(OBJDIR)/t% : tests/t%.c $(libceed) 79$(OBJDIR)/ex% : examples/ex%.c $(libceed) 80 81run-t% : $(OBJDIR)/t% 82 tests/tap.sh $(<:build/%=%) 83 84test : $(tests:$(OBJDIR)/t%=run-t%) 85tst:;@$(MAKE) $(MFLAGS) test 86 87prove : $(tests) 88 $(PROVE) --exec tests/tap.sh $(CEED_PROVE_OPTS) $(tests:$(OBJDIR)/%=%) 89 90examples : $(examples) 91 92.PHONY: clean print test examples astyle 93cln clean : 94 $(RM) *.o $(OBJDIR)/*.o *.d $(OBJDIR)/*.d $(libceed) $(tests.c:%.c=%) 95 $(RM) -r *.dSYM 96 97astyle : 98 astyle --style=google --indent=spaces=2 --max-code-length=80 \ 99 --keep-one-line-statements --keep-one-line-blocks --lineend=linux \ 100 --suffix=none --preserve-date --formatted \ 101 *.[ch] tests/*.[ch] examples/*.[ch] 102 103 104print : 105 @echo $(VAR)=$($(VAR)) 106 107print-%: 108 $(info [ variable name]: $*) 109 $(info [ origin]: $(origin $*)) 110 $(info [ value]: $(value $*)) 111 $(info [expanded value]: $($*)) 112 $(info ) 113 @true 114 115-include $(libceed.c:%.c=%.d) $(tests.c:%.c=%.d) 116