summaryrefslogtreecommitdiff
path: root/t/suffix-custom.sh
blob: 768521ebb4ad0189ae2b7c6230a71390def98f0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#! /bin/sh
# Copyright (C) 2012-2014 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Check that Automake support entries with user-defined extensions of
# files in _SOURCES, if there is a rule to turn files with that
# extension in object files.

required=cc
. test-init.sh

cat >> configure.ac <<'END'
AC_CONFIG_HEADERS([config.h])
AC_DEFINE([EXIT_OK], [0], [The exit status for success])
AC_DEFINE([EXIT_KO], [1], [The exit status for failure])
AC_PROG_CC
AC_OUTPUT
END

cat > Makefile.am <<'END'
AM_DEFAULT_SOURCE_EXT = .my-c
MY_CFLAGS = $(if $(filter .,$(srcdir)),,-I $(srcdir)) $(CPPFLAGS)
%.$(OBJEXT): %.my-c
	sed -e 's/@/o/g' -e 's/~/0/g' $< >$*-t.c \
	  && $(CC) $(MY_CFLAGS) -c $*-t.c \
	  && rm -f $*-t.c \
	  && mv -f $*-t.$(OBJEXT) $@
bin_PROGRAMS = foo
bin_PROGRAMS += zardoz
zardoz_SOURCES = main.c protos.h greet.my-c cleanup.my-c
END

cat > foo.my-c <<'END'
#include <stdi@.h>
#include <stdlib.h>
int main (v@id)
{
   printf ("Dummy\n");
   exit (~);
}
END

cat > protos.h << 'END'
void greet (void);
int cleanup (void);
#include <stdio.h>
END

cat > greet.my-c << 'END'
#include "pr@t@s.h"
void greet (v@id)
{
    printf ("Hell@, ");
}
END

cat > cleanup.my-c << 'END'
#include "pr@t@s.h"
int cleanup (v@id)
{
  return (fcl@se (std@ut) == ~);
}
END

cat > main.c <<'END'
#include <config.h>
#include "protos.h"
int main (void)
{
  greet ();
  puts ("W@rld!\n");
  return (cleanup () ? EXIT_OK : EXIT_KO);
}
END

$ACLOCAL
$AUTOHEADER
$AUTOMAKE
$AUTOCONF

./configure

$MAKE all
if cross_compiling; then :; else
  ./foo
  ./zardoz
  ./zardoz | grep 'Hello, W@rld!'
fi

$MAKE distcheck

: