mirror of
https://github.com/clearlinux/graphene.git
synced 2026-10-03 15:39:36 +00:00
[Makefile] handle DEBUG more cleanly
Handle DEBUG more cleanly. - DEBUG undefined: -O2 (same as before) - DEBUG=0: same as undefined DEBUG (newly supported) - DEBUG=1: enable debug symbol + -DDEBUG with -O2 enabled - DEBUG=2: debug symbol + -DDEBUG + turn off -O2 (newly supported) - other: explicit error
This commit is contained in:
@@ -23,22 +23,37 @@ OBJCOPY ?= objcopy
|
||||
SYS ?= $(shell $(CC) -dumpmachine)
|
||||
export SYS
|
||||
|
||||
DEBUG ?=
|
||||
export DEBUG
|
||||
|
||||
CFLAGS += -Wall -std=c11
|
||||
CXXFLAGS += -Wall -std=c++14
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
DEBUG ?=
|
||||
export DEBUG
|
||||
|
||||
# make DEBUG=0 synonym for undefined DEBUG
|
||||
ifeq ($(DEBUG),0)
|
||||
override DEBUG =
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG),)
|
||||
# -O2: yes -DDEBUG: no
|
||||
CFLAGS += -O2
|
||||
CXXFLAGS += -O2
|
||||
else ifeq ($(DEBUG),1)
|
||||
# -O2: yes -DDEBUG: yes
|
||||
CFLAGS += -O2 -gdwarf-2 -g3
|
||||
CXXFLAGS += -O2 -gdwarf-2 -g3
|
||||
CFLAGS += -DDEBUG
|
||||
ASFLAGS += -DDEBUG
|
||||
else ifeq ($(DEBUG),2)
|
||||
# -O2: no -DDEBUG: yes
|
||||
CFLAGS += -gdwarf-2 -g3
|
||||
CXXFLAGS += -gdwarf-2 -g3
|
||||
CFLAGS += -DDEBUG
|
||||
ASFLAGS += -DDEBUG
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG),)
|
||||
CFLAGS += -O2
|
||||
CXXFLAGS += -O2
|
||||
# other makefiles assumes only DEBUG=1 for debug
|
||||
override DEBUG = 1
|
||||
else
|
||||
$(error unknown DEBUG value "$(DEBUG)")
|
||||
endif
|
||||
|
||||
ifeq ($(WERROR),1)
|
||||
|
||||
Reference in New Issue
Block a user