Skip to content

Commit

Permalink
Correctly handle external *FLAGS. Fixes #10.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasb-eyer committed Nov 4, 2017
1 parent 8700e68 commit c002e44
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@ CC?=gcc
CXX?=g++
AR?=ar

# Set the default optional flags if none are specified

# Release mode (If just dropping the lib into your project, check out -flto too.)
#
# Note1: OpenMP is (currently) not required by the lib, just benchmarking.
# Note1: OpenMP is (currently) not required by the lib, just for precise benchmarking.
# Note2: the -Wa,-ahl=... part only generates .s assembly so one can see generated code.
# Note3: When using `-flto`, you should add the same -O to LDFLAGS as to FLAGS.
FLAGS=-fPIC -Wall -Wextra -I. -O3 -g -DNDEBUG -fopenmp -Wa,-ahl=$(@:.o=.s)
LDFLAGS=-fopenmp -O3 -lm
# Note3: If you want to add `-flto`, you should add the same -O to LDFLAGS as to FLAGS.
DEFAULT_FLAGS=-O3 -g -DNDEBUG -fopenmp -Wall -Wextra -Wa,-ahl=$(@:.o=.s)
DEFAULT_LDFLAGS=-fopenmp

# Debug mode
# FLAGS=-fPIC -Wall -Wextra -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -I. -O0 -g -fopenmp -Wa,-ahl=$(@:.o=.s)
# LDFLAGS=-fopenmp -O0 -g -lm
# TODO: Play with -D_GLIBCXX_PARALLEL
# TODO: Play with -D_GLIBCXX_PROFILE
# DEFAULT_FLAGS=-fPIC -Wall -Wextra -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -I. -O0 -g -fopenmp -Wa,-ahl=$(@:.o=.s)
# DEFAULT_LDFLAGS=-fopenmp -g

# First set the flags to their defaults if not supplied externally.
CFLAGS?=$(DEFAULT_FLAGS)
CXXFLAGS?=$(DEFAULT_FLAGS)
LDFLAGS?=$(DEFAULT_LDFLAGS)

# Then add those flags we can't live without, unconditionally.
CFLAGS+=-fPIC -I. -pedantic
CXXFLAGS+=-fPIC -I. -std=c++0x
LDFLAGS+=-lm

CFLAGS=$(FLAGS) -pedantic
CXXFLAGS=$(FLAGS) -std=c++0x

.PHONY: all benchmarks samples clean

Expand Down

0 comments on commit c002e44

Please sign in to comment.