]> rtime.felk.cvut.cz Git - omk.git/commitdiff
CFLAGS and CXXFLAGS can be overridden in config.omk.
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 23 Jul 2007 15:39:00 +0000 (15:39 +0000)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 23 Jul 2007 15:39:00 +0000 (15:39 +0000)
darcs-hash:20070723153952-f2ef6-f9b89e331ea841133e685a02f66980a5af1dec14.gz

snippets/linux
tests/programs/runtest-cflags [new file with mode: 0755]
tests/programs/test.c

index 10bb06667c48f6d0a619c3ce15561af83b7e5d4b..4b4688533093649924ece157bd9d02c855eef594 100644 (file)
@@ -23,6 +23,8 @@
 #
 # LINUX_DIR        .. location of Linux kernel sources
 # RTL_DIR          .. location of RT-Linux sources
+# CFLAGS           .. C compiler flags
+# CXXFLAGS         .. C++ compiler flags
 
 # Hack to check RT-Linux rules
 #LINUX_DIR := /home/cvs/ocera/ocera-build/kernel/linux
 #CONFIG_RTLINUX = y
 #OCERA_DIR := $(shell ( cd -L $(MAKERULES_DIR)/../../.. ; pwd -L ) )
 
-#CFLAGS += -ggdb
-CFLAGS += -O2 
-CFLAGS += -Wall
-#CXXFLAGS += -ggdb
-CXXFLAGS += -O2
-CXXFLAGS += -Wall
+# Assign default values to CFLAGS variable. If the variable is defined
+# earlier (i.g. in config.omk), it is not overriden here.
+CFLAGS ?= -O2 -Wall
+CXXFLAGS ?= -O2 -Wall
 
 
 CPPFLAGS  += -I $(USER_INCLUDE_DIR)
diff --git a/tests/programs/runtest-cflags b/tests/programs/runtest-cflags
new file mode 100755 (executable)
index 0000000..1de66ee
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+source ../functions.sh
+
+touch config.omk-default
+echo "CFLAGS=-DNUMBER=123" > config.omk
+make||error "Can't compile program with custom CFLAGS"
+_compiled/bin/test|grep 123 || error "Custom CFLAGS didn't influence the output"
index 4be4888df49bf413ca47a480c4e3375a43128d0c..f24b7bdf1cc8c8825b6652da79bae07b8c67a865 100644 (file)
@@ -1,4 +1,9 @@
+#include <stdio.h>
+
 int main()
 {
+#ifdef NUMBER
+        printf("NUMBER is %d\n", NUMBER);
+#endif
         return 0;
 }