X-Git-Url: http://rtime.felk.cvut.cz/gitweb/omk.git/blobdiff_plain/4d100bb69cc3d8320bb3e83ea68dc396e148d47c..0bde9f4e78d242399980fb7445aebc49e58f184d:/tests/programs-cflags diff --git a/tests/programs-cflags b/tests/programs-cflags index 6ad2223..73d0b36 100755 --- a/tests/programs-cflags +++ b/tests/programs-cflags @@ -1,9 +1,91 @@ -#!/bin/sh +#!/bin/bash -. ./functions.sh +. ./wvtest.sh -touch config.omk-default -echo "CFLAGS=-DNUMBER=123" > config.omk -make||error "Can't compile" -[ $OMK_RULES != linux ] && canttest "Should work only with Linux rules" -_compiled/bin/test|grep 123 || error "Custom CFLAGS didn't influence the output" +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 + +WVSTART "CFLAGS is not set by default" +create_files +WVPASS sh -c '! make -qp|grep "^CFLAGS ="'