1#! /bin/sh 2# Copyright (C) 1996-2021 Free Software Foundation, Inc. 3# 4# This program is free software; you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation; either version 2, or (at your option) 7# any later version. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program. If not, see <https://www.gnu.org/licenses/>. 16 17# Test per-target flags in vala support. 18 19required="pkg-config valac gcc GNUmake" 20. test-init.sh 21 22mkdir src 23 24cat >> configure.ac <<'END' 25AC_PROG_CC 26AM_PROG_VALAC([0.7.0]) 27PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.4]) 28AC_CONFIG_FILES([src/Makefile]) 29AC_OUTPUT 30END 31 32cat > Makefile.am <<'END' 33SUBDIRS = src 34END 35 36cat > src/Makefile.am <<'END' 37bin_PROGRAMS = foo bar 38foo_CFLAGS = $(GOBJECT_CFLAGS) 39foo_LDADD = $(GOBJECT_LIBS) 40foo_SOURCES = xfoo.vala 41bar_SOURCES = xbar.vala 42bar_VALAFLAGS = -D BAR 43bar_CFLAGS = $(GOBJECT_CFLAGS) 44bar_LDADD = $(GOBJECT_LIBS) 45END 46 47cat > src/xfoo.vala <<'END' 48int main () 49{ 50 stdout.printf ("foo\n"); 51 return 0; 52} 53END 54 55cat > src/xbar.vala <<'END' 56void main () 57{ 58#if BAR 59 stdout.printf ("bar\n"); 60#else 61 stdout.oops_an_invalid_method (); 62#endif 63} 64END 65 66$ACLOCAL 67$AUTOCONF 68$AUTOMAKE -a 69 70./configure 71$MAKE 72 73if ! cross_compiling; then 74 ./src/foo 75 ./src/bar 76 test "$(./src/foo)" = foo 77 test "$(./src/bar)" = bar 78fi 79 80# Test clean rules. 81 82cp config.status config.sav 83 84$MAKE clean 85test -f src/xfoo.c 86test -f src/xbar.c 87 88$MAKE distclean 89test ! -e src/xfoo.c 90test ! -e src/xbar.c 91 92# Re-create Makefile. 93mv config.sav config.status 94./config.status 95 96$MAKE maintainer-clean 97test ! -e src/xfoo.c 98test ! -e src/xbar.c 99 100: 101