#!/bin/bash . ./wvtest.sh create_files() { cat > 'test.c' <<'EOF' #include 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 } grepbinout() { if [ $OMK_RULES = linux ]; then # The following should work only with Linux rules local bin=$1 shift _compiled/bin/$bin|grep $@ fi } grepout() { grepbinout test $@ } set -o pipefail WVSTART "OMK_CFLAGS" create_files needs_valid_CC WVPASS make OMK_CFLAGS=-DNUMBER=123 WVPASS grepout 123 WVSTART "CFLAGS override OMK_CFLAGS" create_files WVPASS make OMK_CFLAGS=-DNUMBER=123 CFLAGS=-DNUMBER=321 WVPASS grepout 321 WVSTART "OMK_CFLAGS in config.omk" create_files echo "OMK_CFLAGS=-DNUMBER=123" > config.omk WVPASS make WVPASS grepout 123 WVSTART "Target specific CFLAGS" create_files cat > 'Makefile.omk' <<'EOF' bin_PROGRAMS = test test_SOURCES = test.c test_CFLAGS = -DNUMBER=123 EOF WVPASS make V=1 WVPASS grepout 123 WVSTART "Target specific CFLAGS override OMK_CFLAGS" create_files cat > 'Makefile.omk' <<'EOF' bin_PROGRAMS = test test_SOURCES = test.c test_CFLAGS = -DNUMBER=123 OMK_CFLAGS = -DNUMBER=456 EOF WVPASS make V=1 WVPASS grepout 123 WVSTART "Same source compiled twice with different CFLAGS" create_files cat > 'Makefile.omk' <<'EOF' bin_PROGRAMS = a b a_SOURCES = test.c a_CFLAGS = -DNUMBER=123 b_SOURCES = test.c b_CFLAGS = -DNUMBER=456 EOF WVPASS make V=1 WVPASS grepbinout a 123 WVPASS grepbinout b 456