#!/bin/bash
-. ./functions.sh
+. ./wvtest.sh
-touch config.omk-default
-echo "CFLAGS=-DNUMBER=123" > config.omk
+create_files() {
+ cat > 'test.c' <<'EOF'
+#include <stdio.h>
+
+int main()
+{
+#ifdef NUMBER
+ printf("NUMBER is %d\n", NUMBER);
+#endif
+ return 0;
+}
+EOF
+ cat > 'Makefile.omk' <<'EOF'
+bin_PROGRAMS = test
+test_SOURCES = test.c
+EOF
+}
+
+grepout() {
+ if [ $OMK_RULES = linux ]; then
+ # The following should work only with Linux rules
+ _compiled/bin/test|grep $@
+ fi
+}
+
+set -o pipefail
+
+WVSTART "AM_CFLAGS"
+create_files
needs_valid_CC
-make||error "Can't compile"
-if [ $OMK_RULES = linux ]; then
- # The following should work only with Linux rules
- _compiled/bin/test|grep 123 || error "Custom CFLAGS didn't influence the output"
-fi
+WVPASS make AM_CFLAGS=-DNUMBER=123
+WVPASS grepout 123
+
+WVSTART "CFLAGS override AM_CFLAGS"
+create_files
+WVPASS make AM_CFLAGS=-DNUMBER=123 CFLAGS=-DNUMBER=321
+WVPASS grepout 321
+
+
+WVSTART "AM_CFLAGS in config.omk"
+create_files
+echo "AM_CFLAGS=-DNUMBER=123" > config.omk
+WVPASS make
+WVPASS grepout 123