xref: /libCEED/examples/fluids/Makefile (revision ce18bed930e8f3bfebcf709a18844aba97fe4630)
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
17COMMON ?= ../../common.mk
18-include $(COMMON)
19
20PETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc
21CEED_DIR ?= ../..
22ceed.pc := $(CEED_DIR)/lib/pkgconfig/ceed.pc
23
24CC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc))
25CFLAGS = -std=c99 \
26  $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) \
27  $(call pkgconf, --cflags-only-other $(PETSc.pc)) \
28  $(OPT)
29CPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc)) \
30  $(call pkgconf, --variable=cflags_dep $(PETSc.pc))
31LDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc))
32LDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc)))
33LDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm
34
35OBJDIR := build
36SRCDIR := src
37PROBLEMDIR := problems
38
39src.c := navierstokes.c $(sort $(wildcard $(PROBLEMDIR)/*.c)) $(sort $(wildcard $(SRCDIR)/*.c))
40src.o = $(src.c:%.c=$(OBJDIR)/%.o)
41
42all: navierstokes
43
44navierstokes: $(src.o) | $(PETSc.pc) $(ceed.pc)
45	$(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
46
47.SECONDEXPANSION: # to expand $$(@D)/.DIR
48%/.DIR :
49	@mkdir -p $(@D)
50	@touch $@
51
52# Quiet, color output
53quiet ?= $($(1))
54
55$(OBJDIR)/%.o : %.c | $$(@D)/.DIR
56	$(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<)
57
58# Rules for building the examples
59#%: %.c
60
61print: $(PETSc.pc) $(ceed.pc)
62	$(info CC      : $(CC))
63	$(info CFLAGS  : $(CFLAGS))
64	$(info CPPFLAGS: $(CPPFLAGS))
65	$(info LDFLAGS : $(LDFLAGS))
66	$(info LDLIBS  : $(LDLIBS))
67	$(info OPT     : $(OPT))
68	@true
69
70clean:
71	$(RM) -r $(OBJDIR) navierstokes *.vtu *.bin* *.csv *.png
72
73$(PETSc.pc):
74	$(if $(wildcard $@),,$(error \
75	  PETSc config not found. Please set PETSC_DIR and PETSC_ARCH))
76
77.PHONY: all print clean
78
79pkgconf = $(shell pkg-config $1 | sed -e 's/^"//g' -e 's/"$$//g')
80
81-include $(src.o:%.o=%.d)
82