summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-04-13 09:04:40 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2021-04-13 09:04:40 +0200
commitb1355998c859cf4a1531b1035ca0ccb4a9e97409 (patch)
tree066c2860c5df095645beb9af057ddeb617277e80
parent168ea4b5641eb08ef24c70e94e332aaabf7e2e81 (diff)
prepare for switch to config.h instead of CFLAGS defines
-rw-r--r--Makefile3
-rw-r--r--script/conf2h.awk35
-rw-r--r--src/arch/arduino-nano/Makefile.inc4
-rw-r--r--src/arch/atmega2560/Makefile.inc4
-rw-r--r--src/arch/blinkenrocket/Makefile.inc4
-rw-r--r--src/arch/esp8266/Makefile.inc4
-rw-r--r--src/arch/lm4f120h5qr-stellaris/Makefile.inc8
-rw-r--r--src/arch/msp430fr5969lp/Makefile.inc6
-rw-r--r--src/arch/msp430fr5994lp/Makefile.inc6
-rw-r--r--src/arch/posix/Makefile.inc4
-rw-r--r--src/arch/stm32f446re-nucleo/Makefile.inc8
11 files changed, 62 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index abd4dca..3625462 100644
--- a/Makefile
+++ b/Makefile
@@ -380,6 +380,9 @@ endif
default: build/system.elf
+include/config.h: .config
+ ${QUIET}awk -f script/conf2h.awk .config > include/config.h
+
stack: default
${QUIET}test -n "${OBJDUMP}"
${QUIET}test -n "${ARCH_SHORTNAME}"
diff --git a/script/conf2h.awk b/script/conf2h.awk
new file mode 100644
index 0000000..818beea
--- /dev/null
+++ b/script/conf2h.awk
@@ -0,0 +1,35 @@
+#! /usr/bin/gawk -f
+#
+# Copyright 2021 AG Eingebettete Softwaresysteme, Universität Osnabrück
+#
+# SPDX-License-Identicier: CC0-1.0
+
+BEGIN {
+ print "// config.h generated from " ARGV[1] "\n" \
+ "#ifndef CONFIG_H\n" \
+ "#define CONFIG_H"
+}
+
+/^CONFIG_.*?_INSTANCES=/ { next }
+
+/^#/ { sub(/^#/,"//") }
+
+/^CONFIG_.*?=/ {
+ if (/=n$/) {
+ sub(/^/,"// ");
+ } else {
+ sub(/^/,"#define ")
+ if (/=y$/) {
+ sub(/=.*$/,"")
+ } else if (/=".*"$/) {
+ sub(/="/, " ")
+ sub(/"$/, "")
+ } else {
+ sub(/=/," ")
+ }
+ }
+}
+
+{ print }
+
+END { print "#endif" }
diff --git a/src/arch/arduino-nano/Makefile.inc b/src/arch/arduino-nano/Makefile.inc
index 12777d9..0ce2ef7 100644
--- a/src/arch/arduino-nano/Makefile.inc
+++ b/src/arch/arduino-nano/Makefile.inc
@@ -140,10 +140,10 @@ COMMON_FLAGS += -DBAUD=${uart_baud}UL
OBJECTS = ${CXX_TARGETS:.cc=.o} ${C_TARGETS:.c=.o}
-.cc.o:
+%.o : %.cc | include/config.h
${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc}
-.c.o:
+%.o : %.c | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} ${CFLAGS} -c -o $@ ${@:.o=.c}
build/system.elf: ${OBJECTS}
diff --git a/src/arch/atmega2560/Makefile.inc b/src/arch/atmega2560/Makefile.inc
index d78db66..acfd65a 100644
--- a/src/arch/atmega2560/Makefile.inc
+++ b/src/arch/atmega2560/Makefile.inc
@@ -135,10 +135,10 @@ COMMON_FLAGS += -DBAUD=${uart_baud}UL
OBJECTS = ${CXX_TARGETS:.cc=.o} ${C_TARGETS:.c=.o}
-.cc.o:
+%.o : %.cc | include/config.h
${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc}
-.c.o:
+%.o : %.c | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} ${CFLAGS} -c -o $@ ${@:.o=.c}
build/system.elf: ${OBJECTS}
diff --git a/src/arch/blinkenrocket/Makefile.inc b/src/arch/blinkenrocket/Makefile.inc
index 41e1de3..64e87f5 100644
--- a/src/arch/blinkenrocket/Makefile.inc
+++ b/src/arch/blinkenrocket/Makefile.inc
@@ -54,10 +54,10 @@ endif
OBJECTS = ${CXX_TARGETS:.cc=.o} ${C_TARGETS:.c=.o}
-.cc.o:
+%.o : %.cc | include/config.h
${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc}
-.c.o:
+%.o : %.c | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} ${CFLAGS} -c -o $@ ${@:.o=.c}
build/system.elf: ${OBJECTS}
diff --git a/src/arch/esp8266/Makefile.inc b/src/arch/esp8266/Makefile.inc
index 18877ee..7bbc2f1 100644
--- a/src/arch/esp8266/Makefile.inc
+++ b/src/arch/esp8266/Makefile.inc
@@ -64,11 +64,11 @@ ifdef CONFIG_arch_esp8266_driver_uptime
CXX_TARGETS += src/arch/esp8266/driver/uptime.cc
endif
-.cc.o:
+%.o : %.cc | include/config.h
${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc}
${QUIET}${OBJCOPY} --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal $@
-.c.o:
+%.o : %.c | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} ${CFLAGS} -c -o $@ ${@:.o=.c}
${QUIET}${OBJCOPY} --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal $@
diff --git a/src/arch/lm4f120h5qr-stellaris/Makefile.inc b/src/arch/lm4f120h5qr-stellaris/Makefile.inc
index d49391b..7d1e5e9 100644
--- a/src/arch/lm4f120h5qr-stellaris/Makefile.inc
+++ b/src/arch/lm4f120h5qr-stellaris/Makefile.inc
@@ -73,16 +73,16 @@ endif
OBJECTS = ${CXX_TARGETS:.cc=.o} ${C_TARGETS:.c=.o} ${ASM_TARGETS:.S=.o}
-.cc.o:
+%.o : %.cc | include/config.h
${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc}
-.c.o:
+%.o : %.c | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} ${CFLAGS} -c -o $@ ${@:.o=.c}
-.S.o:
+%.o : %.S | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} -c -o $@ ${@:.o=.S}
-.s.o:
+%.o : %.s | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} -c -o $@ ${@:.o=.S}
ext/libopencm3/Makefile:
diff --git a/src/arch/msp430fr5969lp/Makefile.inc b/src/arch/msp430fr5969lp/Makefile.inc
index f9d9a28..d6f4d9f 100644
--- a/src/arch/msp430fr5969lp/Makefile.inc
+++ b/src/arch/msp430fr5969lp/Makefile.inc
@@ -112,13 +112,13 @@ endif
OBJECTS = ${CXX_TARGETS:.cc=.o} ${C_TARGETS:.c=.o} ${ASM_TARGETS:.S=.o}
-.cc.o:
+%.o : %.cc | include/config.h
${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc}
-.c.o:
+%.o : %.c | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} ${CFLAGS} -c -o $@ ${@:.o=.c}
-.S.o:
+%.o : %.S | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} -Wa,-gstabs,-ggdb -x assembler-with-cpp -c -o $@ ${@:.o=.S}
build/system.elf: ${OBJECTS}
diff --git a/src/arch/msp430fr5994lp/Makefile.inc b/src/arch/msp430fr5994lp/Makefile.inc
index 57a7d2c..cffb395 100644
--- a/src/arch/msp430fr5994lp/Makefile.inc
+++ b/src/arch/msp430fr5994lp/Makefile.inc
@@ -154,13 +154,13 @@ endif
OBJECTS = ${CXX_TARGETS:.cc=.o} ${C_TARGETS:.c=.o} ${ASM_TARGETS:.S=.o}
-.cc.o:
+%.o : %.cc | include/config.h
${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc}
-.c.o:
+%.o : %.c | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} ${CFLAGS} -c -o $@ ${@:.o=.c}
-.S.o:
+%.o : %.S | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} -Wa,-gstabs,-ggdb -x assembler-with-cpp -c -o $@ ${@:.o=.S}
build/system.elf: ${OBJECTS}
diff --git a/src/arch/posix/Makefile.inc b/src/arch/posix/Makefile.inc
index 32a56cc..5e7e7ee 100644
--- a/src/arch/posix/Makefile.inc
+++ b/src/arch/posix/Makefile.inc
@@ -45,10 +45,10 @@ ifdef CONFIG_gpio_trace
COMMON_FLAGS += -DGPIO_TRACE
endif
-.cc.o:
+%.o : %.cc | include/config.h
${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc}
-.c.o:
+%.o: %.c | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} ${CFLAGS} -c -o $@ ${@:.o=.c}
build/system.elf: ${OBJECTS}
diff --git a/src/arch/stm32f446re-nucleo/Makefile.inc b/src/arch/stm32f446re-nucleo/Makefile.inc
index dd0de00..2aec12b 100644
--- a/src/arch/stm32f446re-nucleo/Makefile.inc
+++ b/src/arch/stm32f446re-nucleo/Makefile.inc
@@ -72,16 +72,16 @@ endif
OBJECTS = ${CXX_TARGETS:.cc=.o} ${C_TARGETS:.c=.o} ${ASM_TARGETS:.S=.o}
-.cc.o:
+%.o : %.cc | include/config.h
${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc}
-.c.o:
+%.o : %.c | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} ${CFLAGS} -c -o $@ ${@:.o=.c}
-.S.o:
+%.o : %.S | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} -c -o $@ ${@:.o=.S}
-.s.o:
+%.o : %.s | include/config.h
${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} -c -o $@ ${@:.o=.S}
ext/libopencm3/Makefile: