Skip to content

Commit

Permalink
build: Use COMMON_CXXFLAGS not to conflict with .config
Browse files Browse the repository at this point in the history
Since CXXFLAGS is used with override keyword in .config, Makefile has to
use different name not to make a conflict with it.

Signed-off-by: Honggyu Kim <[email protected]>
  • Loading branch information
honggyukim authored and Bojun-Seo committed Dec 3, 2022
1 parent 0d993a5 commit 27d5734
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ifneq ($(wildcard $(objdir)/.config),)
include $(objdir)/.config
endif

export CC CXX LD srcdir objdir LDFLAGS
export CC CXX LD srcdir objdir CXXFLAGS LDFLAGS

ifdef CROSS_COMPILE
CC := $(CROSS_COMPILE)gcc
Expand All @@ -28,15 +28,15 @@ else
CXX ?= g++
endif

CXXFLAGS := -std=c++11
COMMON_CXXFLAGS = $(CXXFLAGS) -std=c++11
ifeq ($(DEBUG), 1)
CXXFLAGS += -O0 -g
COMMON_CXXFLAGS += -O0 -g
else
CXXFLAGS += -O2 -g
COMMON_CXXFLAGS += -O2 -g
endif

LIB_CXXFLAGS := $(CXXFLAGS) -fPIC -fno-omit-frame-pointer -fvisibility=hidden
LIB_LDFLAGS := -ldl
LIB_CXXFLAGS := $(COMMON_CXXFLAGS) -fPIC -fno-omit-frame-pointer -fvisibility=hidden
LIB_LDFLAGS := $(LDFLAGS) -ldl

ifndef $(DEPTH)
# default backtrace depth is 8
Expand All @@ -45,9 +45,9 @@ endif
LIB_CXXFLAGS += -DDEPTH=$(DEPTH)

ifeq ($(M32), 1)
CXXFLAGS += -m32
LIB_CXXFLAGS += -m32
LIB_LDFLAGS += -m32
COMMON_CXXFLAGS += -m32
LIB_CXXFLAGS += -m32
LIB_LDFLAGS += -m32
endif

TARGETS := heaptrace libheaptrace.so
Expand All @@ -65,13 +65,13 @@ all: $(TARGETS)
$(MAKE) -C samples

heaptrace: $(HEAPTRACE_OBJS)
$(QUIET_CXX)$(CXX) $(CXXFLAGS) -o $(objdir)/$@ $(HEAPTRACE_OBJS)
$(QUIET_CXX)$(CXX) $(COMMON_CXXFLAGS) -o $(objdir)/$@ $(HEAPTRACE_OBJS)

$(LIB_OBJS): $(objdir)/%.o: $(srcdir)/%.cc
$(QUIET_CXX)$(CXX) $(LIB_CXXFLAGS) -c -o $@ $<

$(HEAPTRACE_OBJS): $(objdir)/%.o: $(srcdir)/%.cc
$(QUIET_CXX)$(CXX) $(CXXFLAGS) -c -o $@ $<
$(QUIET_CXX)$(CXX) $(COMMON_CXXFLAGS) -c -o $@ $<

libheaptrace.so: $(LIB_OBJS)
$(QUIET_LINK)$(CXX) -shared -o $(objdir)/$@ $^ $(LIB_LDFLAGS)
Expand Down
18 changes: 9 additions & 9 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ EOF

cat >>$output <<EOF
override CC := $CC
override CXX := $CXX
override LD := $LD
override CFLAGS = $CFLAGS
override CXXLAGS = $CXXLAGS
override LDFLAGS = $LDFLAGS
override srcdir := $srcdir
override objdir := $objdir
override CC := $CC
override CXX := $CXX
override LD := $LD
override CFLAGS = $CFLAGS
override CXXFLAGS = $CXXFLAGS
override LDFLAGS = $LDFLAGS
override srcdir := $srcdir
override objdir := $objdir
EOF

if [ "$srcdir" != "$objdir" ]; then
Expand Down

0 comments on commit 27d5734

Please sign in to comment.