-#!/bin/sh
+#!/bin/bash
-. ./functions.sh
+. ./wvtest.sh
-touch config.omk-default
-make
+
+WVSTART "Compile a single source C program"
+cat > 'test.c' <<'EOF'
+int main() { return 0; }
+EOF
+cat > 'Makefile.omk' <<'EOF' # OMK manual includes this file - do not modify it
+bin_PROGRAMS = test
+test_SOURCES = test.c
+EOF
+needs_valid_CC
+WVPASS make V=1
+
+WVSTART "Compile a multiple source C program"
+cat > 'func.c' <<< "void func() { }"
+cat > 'test.c' <<< "void func(); int main() { func(); return 0; }"
+cat > 'Makefile.omk' <<'EOF'
+bin_PROGRAMS = test
+test_SOURCES = test.c func.c
+EOF
+needs_valid_CC
+WVPASS make V=1
+
+WVSTART "Two programs sharing a source"
+cat > 'func.c' <<< "void func() { }"
+cat > 'p1.c' <<< "void func(); int main() { func(); return 0; }"
+cat > 'p2.c' <<< "void func(); int main() { func(); return 0; }"
+cat > 'Makefile.omk' <<'EOF'
+bin_PROGRAMS = p1 p2
+p1_SOURCES = p1.c func.c
+p2_SOURCES = p2.c func.c
+EOF
+needs_valid_CC
+WVPASS make
+
+
+WVSTART "Generated sources"
+cat > 'Makefile.omk' <<'EOF'
+bin_PROGRAMS = p
+p_GEN_SOURCES = gen.c
+
+gen.c:
+ echo "int main() { return 0; }" > $@
+EOF
+needs_valid_CC
+WVPASS make
+
+WVSTART "Compile a single source C program twice"
+cat > 'test.c' <<'EOF'
+int main() { return 0; }
+EOF
+cat > 'Makefile.omk' <<'EOF' # OMK manual includes this file - do not modify it
+bin_PROGRAMS = test
+test_SOURCES = test.c
+EOF
+needs_valid_CC
+WVPASS make
+touch test.c
+WVPASS make