xref: /libCEED/examples/fluids/Makefile (revision 5c7b696c8582f667cb0fcf7d02b9ef3156803fee)
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
17PETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc
18CEED_DIR ?= ../..
19ceed.pc := $(CEED_DIR)/lib/pkgconfig/ceed.pc
20
21CC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc))
22CFLAGS = -std=c99 $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) $(call pkgconf, --cflags-only-other $(PETSc.pc)) $(OPT) -Wno-unused-variable
23CPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc))
24LDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc))
25LDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc)))
26LDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm
27
28navierstokes.c := $(wildcard navierstokes*.c)
29navierstokes := $(navierstokes.c:%.c=%)
30
31all: $(navierstokes)
32$(navierstokes): | $(PETSc.pc) $(ceed.pc)
33
34# Rules for building the example
35%: %.c
36	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(CEED_LDFLAGS) $(abspath $<) -o $@ $(LDLIBS)
37
38print: $(PETSc.pc) $(ceed.pc)
39	$(info CC      : $(CC))
40	$(info CFLAGS  : $(CFLAGS))
41	$(info CPPFLAGS: $(CPPFLAGS))
42	$(info LDFLAGS : $(LDFLAGS))
43	$(info LDLIBS  : $(LDLIBS))
44	$(info OPT     : $(OPT))
45	@true
46
47clean:
48	$(RM) $(navierstokes) *.vtr *.vts *.vtu *.bin*
49
50$(PETSc.pc):
51	$(if $(wildcard $@),,$(error \
52	  PETSc config not found. Please set PETSC_DIR and PETSC_ARCH))
53
54.PHONY: all print clean
55
56pkgconf = $(shell pkg-config $1 | sed -e 's/^"//g' -e 's/"$$//g')
57