]> rtime.felk.cvut.cz Git - omk.git/blob - tests/programs-cflags
Simplify CFLAGS test and check for CFLAGS overriding AM_CFLAGS
[omk.git] / tests / programs-cflags
1 #!/bin/bash
2
3 . ./wvtest.sh
4
5 create_files() {
6     cat > 'test.c' <<'EOF'
7 #include <stdio.h>
8
9 int main()
10 {
11 #ifdef NUMBER
12         printf("NUMBER is %d\n", NUMBER);
13 #endif
14         return 0;
15 }
16 EOF
17     cat > 'Makefile.omk' <<'EOF'
18 bin_PROGRAMS = test
19 test_SOURCES = test.c
20 EOF
21 }
22
23 grepout() {
24     if [ $OMK_RULES = linux ]; then
25         # The following should work only with Linux rules
26         _compiled/bin/test|grep $@
27     fi
28 }
29
30 set -o pipefail
31
32 WVSTART "AM_CFLAGS"
33 create_files
34 needs_valid_CC
35 WVPASS make AM_CFLAGS=-DNUMBER=123
36 WVPASS grepout 123
37
38 WVSTART "CFLAGS override AM_CFLAGS"
39 create_files
40 WVPASS make AM_CFLAGS=-DNUMBER=123 CFLAGS=-DNUMBER=321
41 WVPASS grepout 321
42
43
44 WVSTART "AM_CFLAGS in config.omk"
45 create_files
46 echo "AM_CFLAGS=-DNUMBER=123" > config.omk
47 WVPASS make
48 WVPASS grepout 123