[apparmor] [PATCH 3/9] Use CXXFLAGS instead of CFLAGS

John Johansen john.johansen at canonical.com
Tue Sep 15 03:11:15 UTC 2015


Now that we build using the C++ compiler use CXXFLAGS

Signed-off-by: John Johansen <john.johansen at canonical.com>
---
 parser/Makefile                | 82 +++++++++++++++++++++---------------------
 parser/libapparmor_re/Makefile |  8 ++---
 2 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/parser/Makefile b/parser/Makefile
index 1f0db8d..ab9f9bd 100644
--- a/parser/Makefile
+++ b/parser/Makefile
@@ -39,19 +39,18 @@ CXX_WARNINGS = ${WARNINGS} $(shell for warning in ${EXTRA_WARNINGS} ; do \
 			fi ; \
 		done)
 CPP_WARNINGS =
-ifndef CFLAGS
-CFLAGS	= -g -O2 -pipe
+ifndef CXXFLAGS
+CXXFLAGS	= -g -O2 -pipe
 
 ifdef DEBUG
-CFLAGS += -pg -D DEBUG
+CXXFLAGS += -pg -D DEBUG
 endif
 ifdef COVERAGE
-CFLAGS = -g -pg -fprofile-arcs -ftest-coverage
+CXXFLAGS = -g -pg -fprofile-arcs -ftest-coverage
 endif
-endif #CFLAGS
+endif #CXXFLAGS
 
-EXTRA_CXXFLAGS = ${CFLAGS} ${CPPFLAGS} ${CXX_WARNINGS} -std=gnu++0x -D_GNU_SOURCE
-EXTRA_CFLAGS = ${EXTRA_CXXFLAGS} ${CPP_WARNINGS}
+EXTRA_CXXFLAGS += $(CXXFLAGS) ${CPPFLAGS} ${CXX_WARNINGS} -std=gnu++0x -D_GNU_SOURCE
 
 #LEXLIB	:= -lfl
 
@@ -61,14 +60,14 @@ EXTRA_CFLAGS = ${EXTRA_CXXFLAGS} ${CPP_WARNINGS}
 INCLUDEDIR =
 
 ifdef INCLUDEDIR
-	CFLAGS += -I$(INCLUDEDIR)
+	EXTRA_CXXFLAGS += -I$(INCLUDEDIR)
 endif
 
 # Internationalization support. Define a package and a LOCALEDIR
-EXTRA_CFLAGS+=-DPACKAGE=\"${NAME}\" -DLOCALEDIR=\"${LOCALEDIR}\"
+EXTRA_CXXFLAGS+=-DPACKAGE=\"${NAME}\" -DLOCALEDIR=\"${LOCALEDIR}\"
 
 # Compile-time configuration of the location of the config file
-EXTRA_CFLAGS+=-DSUBDOMAIN_CONFDIR=\"${CONFDIR}\"
+EXTRA_CXXFLAGS+=-DSUBDOMAIN_CONFDIR=\"${CONFDIR}\"
 
 SRCS = parser_common.c parser_include.c parser_interface.c parser_lex.c \
        parser_main.c parser_misc.c parser_merge.c parser_symtab.c \
@@ -89,6 +88,7 @@ AAREOBJECTS = $(AAREOBJECT)
 AARE_LDFLAGS = -static-libgcc -static-libstdc++ -L.
 AALIB = -Wl,-Bstatic -lapparmor -Wl,-Bdynamic -lpthread
 
+CXXFLAGS_NOINCLUDE := $(EXTRA_CXXFLAGS)
 ifdef USE_SYSTEM
   # Using the system libapparmor so Makefile dependencies can't be used
   LIBAPPARMOR_A =
@@ -104,13 +104,13 @@ else
   AARE_LDFLAGS += -L$(LOCAL_LIBAPPARMOR_LDPATH)
   APPARMOR_H = $(LOCAL_LIBAPPARMOR_INCLUDE)/sys/apparmor.h
 endif
-EXTRA_CFLAGS += $(INCLUDE_APPARMOR)
+EXTRA_CXXFLAGS += $(INCLUDE_APPARMOR)
 
 LEX_C_FILES	= parser_lex.c
 YACC_C_FILES	= parser_yacc.c parser_yacc.h
 
 TESTS = tst_regex tst_misc tst_symtab tst_variable tst_lib
-TEST_CFLAGS = $(EXTRA_CFLAGS) -DUNIT_TEST -Wno-unused-result
+TEST_CXXFLAGS = $(EXTRA_CXXFLAGS) -DUNIT_TEST -Wno-unused-result
 TEST_OBJECTS = $(filter-out \
 			parser_lex.o \
 			parser_yacc.o \
@@ -183,7 +183,7 @@ $(LIBAPPARMOR_A):
 endif
 
 apparmor_parser: $(OBJECTS) $(AAREOBJECTS) $(LIBAPPARMOR_A)
-	$(CXX) $(LDFLAGS) $(EXTRA_CFLAGS) -o $@ $(OBJECTS) $(LIBS) \
+	$(CXX) $(LDFLAGS) $(EXTRA_CXXFLAGS) -o $@ $(OBJECTS) $(LIBS) \
 	      ${LEXLIB}  $(AAREOBJECTS) $(AARE_LDFLAGS) $(AALIB)
 
 parser_yacc.c parser_yacc.h: parser_yacc.y parser.h profile.h
@@ -193,79 +193,79 @@ parser_lex.c: parser_lex.l parser_yacc.h parser.h profile.h mount.h dbus.h polic
 	$(LEX) ${LEXFLAGS} -o$@ $<
 
 parser_lex.o: parser_lex.c parser.h parser_yacc.h
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 parser_misc.o: parser_misc.c parser.h parser_yacc.h profile.h cap_names.h $(APPARMOR_H)
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 parser_yacc.o: parser_yacc.c parser_yacc.h $(APPARMOR_H)
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 parser_main.o: parser_main.c parser.h parser_version.h policy_cache.h libapparmor_re/apparmor_re.h $(APPARMOR_H)
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 parser_interface.o: parser_interface.c parser.h profile.h libapparmor_re/apparmor_re.h
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 parser_include.o: parser_include.c parser.h parser_include.h
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 parser_merge.o: parser_merge.c parser.h profile.h
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 parser_regex.o: parser_regex.c parser.h profile.h libapparmor_re/apparmor_re.h libapparmor_re/aare_rules.h $(APPARMOR_H)
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 parser_symtab.o: parser_symtab.c parser.h
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 parser_variable.o: parser_variable.c parser.h profile.h
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 parser_policy.o: parser_policy.c parser.h parser_yacc.h profile.h
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 parser_alias.o: parser_alias.c parser.h profile.h
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 parser_common.o: parser_common.c parser.h
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 mount.o: mount.cc mount.h parser.h immunix.h rule.h
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 common_optarg.o: common_optarg.c common_optarg.h parser.h libapparmor_re/apparmor_re.h
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 policy_cache.o: policy_cache.c policy_cache.h parser.h lib.h
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 lib.o: lib.c lib.h parser.h
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 dbus.o: dbus.cc dbus.h parser.h immunix.h parser_yacc.h rule.h $(APPARMOR_H)
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 signal.o: signal.cc signal.h parser.h immunix.h parser_yacc.h rule.h $(APPARMOR_H)
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 ptrace.o: ptrace.cc ptrace.h parser.h immunix.h parser_yacc.h rule.h $(APPARMOR_H)
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 network.o: network.c network.h parser.h immunix.h parser_yacc.h rule.h af_names.h $(APPARMOR_H)
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 af_rule.o: af_rule.cc af_rule.h network.h parser.h profile.h immunix.h parser_yacc.h rule.h $(APPARMOR_H)
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 af_unix.o: af_unix.cc af_unix.h network.h af_rule.h parser.h profile.h immunix.h parser_yacc.h $(APPARMOR_H)
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 profile.o: profile.cc profile.h parser.h network.h
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 rule.o: rule.cc rule.h policydb.h
-	$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
+	$(CXX) $(EXTRA_CXXFLAGS) -c -o $@ $<
 
 parser_version.h: Makefile
 	@echo \#define PARSER_VERSION \"$(VERSION)\" > .ver
@@ -285,9 +285,9 @@ cap_names.h: /usr/include/linux/capability.h
 	echo "$(CAPABILITIES)" | LC_ALL=C sed -n -e "s/[ \\t]\\?CAP_\\([A-Z0-9_]\\+\\)/\{\"\\L\\1\", \\UCAP_\\1\},\\n/pg" > $@
 
 tst_lib: lib.c parser.h $(filter-out lib.o, ${TEST_OBJECTS})
-	$(CXX) $(TEST_CFLAGS) -o $@ $< $(filter-out $(<:.c=.o), ${TEST_OBJECTS}) $(TEST_LDFLAGS) $(TEST_LDLIBS)
+	$(CXX) $(TEST_CXXFLAGS) -o $@ $< $(filter-out $(<:.c=.o), ${TEST_OBJECTS}) $(TEST_LDFLAGS) $(TEST_LDLIBS)
 tst_%: parser_%.c parser.h $(filter-out parser_%.o, ${TEST_OBJECTS})
-	$(CXX) $(TEST_CFLAGS) -o $@ $< $(filter-out $(<:.c=.o), ${TEST_OBJECTS}) $(TEST_LDFLAGS) $(TEST_LDLIBS)
+	$(CXX) $(TEST_CXXFLAGS) -o $@ $< $(filter-out $(<:.c=.o), ${TEST_OBJECTS}) $(TEST_LDFLAGS) $(TEST_LDLIBS)
 
 .SILENT: check
 .PHONY: check
@@ -302,7 +302,7 @@ tests: apparmor_parser ${TESTS}
 .SILENT: $(AAREOBJECT)
 .PHONY: $(AAREOBJECT)
 $(AAREOBJECT):
-	$(MAKE) -C $(AAREDIR) CFLAGS="$(EXTRA_CXXFLAGS)"
+	$(MAKE) -C $(AAREDIR) CXXFLAGS="$(EXTRA_CXXFLAGS)" USE_SYSTEM=$(USE_SYSTEM)
 
 .PHONY: install-rhel4
 install-rhel4: install-redhat
diff --git a/parser/libapparmor_re/Makefile b/parser/libapparmor_re/Makefile
index c8d9db6..1c341a5 100644
--- a/parser/libapparmor_re/Makefile
+++ b/parser/libapparmor_re/Makefile
@@ -1,17 +1,16 @@
 # Profiling:
-#EXTRA_CFLAGS = -pg
+#EXTRA_CXXFLAGS += -pg
 
 ifdef USE_SYSTEM
   # Using the system libapparmor
   INCLUDE_APPARMOR =
 else
-  INCLUDE_APPARMOR = -I../../libraries/libapparmor/include
+  INCLUDE_APPARMOR := -I../../libraries/libapparmor/include
 endif
 
 TARGET=libapparmor_re.a
 
-CFLAGS ?= -g -Wall -O2 ${EXTRA_CFLAGS} -std=gnu++0x
-CXXFLAGS := ${CFLAGS} ${INCLUDE_APPARMOR}
+CXXFLAGS ?= -g -Wall -O2 ${EXTRA_CXXFLAGS} -std=gnu++0x
 
 ARFLAGS=-rcs
 
@@ -28,6 +27,7 @@ libapparmor_re.a: $(OBJS)
 	ar ${ARFLAGS} $@ $^
 
 %.o: %.cc $(HDRS)
+	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDE_APPARMOR) -c $< -o $@
 
 parse.cc : parse.y parse.h flex-tables.h ../immunix.h
 	${BISON} -o $@ $<
-- 
2.1.4




More information about the AppArmor mailing list