41dea5d2fe482153d32300437800cb1514558294
[LbmBenchmarkKernelsPublic.git] / src / config.linux-gcc.mk
1 # --------------------------------------------------------------------------
2 #
3 # Copyright
4 #   Markus Wittmann, 2016-2017
5 #   RRZE, University of Erlangen-Nuremberg, Germany
6 #   markus.wittmann -at- fau.de or hpc -at- rrze.fau.de
7 #
8 #   Viktor Haag, 2016
9 #   LSS, University of Erlangen-Nuremberg, Germany
10 #
11 #  This file is part of the Lattice Boltzmann Benchmark Kernels (LbmBenchKernels).
12 #
13 #  LbmBenchKernels is free software: you can redistribute it and/or modify
14 #  it under the terms of the GNU General Public License as published by
15 #  the Free Software Foundation, either version 3 of the License, or
16 #  (at your option) any later version.
17 #
18 #  LbmBenchKernels is distributed in the hope that it will be useful,
19 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 #  GNU General Public License for more details.
22 #
23 #  You should have received a copy of the GNU General Public License
24 #  along with LbmBenchKernels.  If not, see <http://www.gnu.org/licenses/>.
25 #
26 # --------------------------------------------------------------------------
27
28
29 # ------------------------------------------------------------------------
30 # C ompiler/linker to use.
31 # Flags are specified at the end of the file.
32 # ------------------------------------------------------------------------
33 CC              = gcc
34 LD              = gcc
35
36 # ------------------------------------------------------------------------
37
38 # Preprocessing variables.
39 D          = -D
40 I          = -I
41 PP_FLAGS  +=
42
43 # Architecture to optimize for.
44 TARCH      ?= -mavx
45
46 # Generated dependencies, can be left empty.
47 MAKE_DEPEND = $(CC) -MM -MQ'$(OBJECT_DIR)/$(<:%.c=%.o)' -MF'$(DEP_DIR)/$(<:%.c=%.d)' $(PP_FLAGS) $< > /dev/null
48
49 # Generates dependencies, can be left empty.
50 # $(call make_depend,<source-file>,<source-file-to-generate-dependency-for)
51 define make_depend
52         $(CC) -MM -MQ'$(OBJECT_DIR)/$(2:%.c=%.o)' -MF'$(DEP_DIR)/$(2:%.c=%.d)' $(PP_FLAGS) $1 > /dev/null
53 endef
54
55
56 ifeq (on,$(OPENMP))
57   OPENMP_C_FLAGS  += -fopenmp
58   OPENMP_LD_FLAGS += -fopenmp
59 endif
60
61
62 ifeq (release,$(BUILD))
63
64   C_FLAGS      += -O3 $(TARCH)
65   LD_FLAGS     += -O3 $(TARCH)
66
67   PP_FLAGS     +=
68
69 else
70 ifeq (debug,$(BUILD))
71
72   C_FLAGS      += -O0 $(TARCH) -g -ggdb
73   LD_FLAGS     += -O0 $(TARCH) -g -ggdb
74
75   PP_FLAGS     += $(D)DEBUG
76
77 else
78   $(error unknown BUILD=$(BUILD), specify release or debug)
79 endif
80 endif
81
82 ifeq (on,$(ADDRESS_SANITIZER))
83   # see https://github.com/google/sanitizers/wiki/AddressSanitizerFlags for details
84   C_FLAGS      += -fsanitize=address
85   LD_FLAGS     += -fsanitize=address
86 endif
87
88 ifeq (on,$(DEBUG_SYMBOLS))
89   C_FLAGS      += -g -ggdb
90   LD_FLAGS     += -g -ggdb
91 endif
92
93 C_FLAGS        += -Wall -Wuninitialized -Wunused-variable -Wshadow -fargument-noalias -fargument-noalias-anything -std=c99 \
94  -MT $@ -MF $(patsubst $(OBJECT_DIR)/%.o,$(DEP_DIR)/%.d,$@) -MMD $(OPENMP_C_FLAGS)
95 LD_FLAGS       += -Wall $(OPENMP_LD_FLAGS)
96 LD_LIBS        += -lm
97
This page took 0.046777 seconds and 3 git commands to generate.