4326 |
12 Mar 23 |
peter |
#! /bin/sh |
4326 |
12 Mar 23 |
peter |
# $Id$ |
4326 |
12 Mar 23 |
peter |
3 |
# |
4326 |
12 Mar 23 |
peter |
# Copyright (C) 2023 Peter Johansson |
4326 |
12 Mar 23 |
peter |
5 |
# |
4326 |
12 Mar 23 |
peter |
# This file is part of the yat library, https://dev.thep.lu.se/yat |
4326 |
12 Mar 23 |
peter |
7 |
# |
4326 |
12 Mar 23 |
peter |
# The yat library is free software; you can redistribute it |
4326 |
12 Mar 23 |
peter |
# and/or modify it under the terms of the GNU General Public License as |
4326 |
12 Mar 23 |
peter |
# published by the Free Software Foundation; either version 3 of the |
4326 |
12 Mar 23 |
peter |
# License, or (at your option) any later version. |
4326 |
12 Mar 23 |
peter |
12 |
# |
4326 |
12 Mar 23 |
peter |
# The yat library is distributed in the hope that it will be useful, |
4326 |
12 Mar 23 |
peter |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4326 |
12 Mar 23 |
peter |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4326 |
12 Mar 23 |
peter |
# General Public License for more details. |
4326 |
12 Mar 23 |
peter |
17 |
# |
4326 |
12 Mar 23 |
peter |
# You should have received a copy of the GNU General Public License |
4326 |
12 Mar 23 |
peter |
# along with yat. If not, see <https://www.gnu.org/licenses/>. |
4326 |
12 Mar 23 |
peter |
20 |
|
4326 |
12 Mar 23 |
peter |
21 |
|
4326 |
12 Mar 23 |
peter |
# test macro YAT_AC_WRITE_TO_FILE |
4326 |
12 Mar 23 |
peter |
23 |
|
4326 |
12 Mar 23 |
peter |
24 |
required="autoconf" |
4326 |
12 Mar 23 |
peter |
25 |
|
4326 |
12 Mar 23 |
peter |
26 |
set -e |
4326 |
12 Mar 23 |
peter |
27 |
|
4326 |
12 Mar 23 |
peter |
# avoid removal of m4 dir in bootstrap() |
4326 |
12 Mar 23 |
peter |
29 |
RM=true |
4326 |
12 Mar 23 |
peter |
30 |
. test/init.sh || exit 99 |
4326 |
12 Mar 23 |
peter |
31 |
|
4326 |
12 Mar 23 |
peter |
32 |
cat >> configure.ac <<EOF |
4326 |
12 Mar 23 |
peter |
33 |
m4_define([my_content], [aha]) |
4326 |
12 Mar 23 |
peter |
34 |
YAT_AC_WRITE_TO_FILE([foo1.txt], [Hello World! my_content]) |
4326 |
12 Mar 23 |
peter |
35 |
YAT_AC_APPEND_TO_FILE([foo1.txt], [Hi again; it's me... ]my_content) |
4326 |
12 Mar 23 |
peter |
# create foo2.txt |
4326 |
12 Mar 23 |
peter |
37 |
YAT_AC_WRITE_TO_FILE(foo2.txt, [ |
4326 |
12 Mar 23 |
peter |
38 |
one: \$1 |
4326 |
12 Mar 23 |
peter |
39 |
two: \$2 |
4326 |
12 Mar 23 |
peter |
40 |
at: \$@ |
4326 |
12 Mar 23 |
peter |
41 |
]) |
4326 |
12 Mar 23 |
peter |
42 |
|
4326 |
12 Mar 23 |
peter |
# configure.ac call MY_WRITE |
4326 |
12 Mar 23 |
peter |
44 |
MY_WRITE([foo3.txt], [header yada yada], [foo3 stuff]) |
4326 |
12 Mar 23 |
peter |
# configure.ac |
4326 |
12 Mar 23 |
peter |
46 |
|
4326 |
12 Mar 23 |
peter |
# configure.ac call MY_WRITE |
4326 |
12 Mar 23 |
peter |
48 |
MY_WRITE([foo4.txt], [my header], [test -e \$1]) |
4326 |
12 Mar 23 |
peter |
# configure.ac |
4326 |
12 Mar 23 |
peter |
50 |
|
4326 |
12 Mar 23 |
peter |
51 |
m4_define([my_text], [my expanded, macro text]) |
4326 |
12 Mar 23 |
peter |
52 |
MY_WRITE([foo5.txt], m4_defn([my_text])) |
4326 |
12 Mar 23 |
peter |
53 |
|
4326 |
12 Mar 23 |
peter |
54 |
MY_WRITE([foo6.txt], [ |
4326 |
12 Mar 23 |
peter |
55 |
target: source |
4326 |
12 Mar 23 |
peter |
56 |
cp source \$@ |
4326 |
12 Mar 23 |
peter |
57 |
]) |
4326 |
12 Mar 23 |
peter |
58 |
|
4326 |
12 Mar 23 |
peter |
59 |
YOUR_WRITE([foo7.txt]) |
4326 |
12 Mar 23 |
peter |
60 |
|
4326 |
12 Mar 23 |
peter |
61 |
AC_CONFIG_FILES([Makefile]) |
4326 |
12 Mar 23 |
peter |
62 |
AC_OUTPUT |
4326 |
12 Mar 23 |
peter |
63 |
EOF |
4326 |
12 Mar 23 |
peter |
64 |
|
4326 |
12 Mar 23 |
peter |
65 |
$mkdir_p m4 |
4326 |
12 Mar 23 |
peter |
66 |
cat > m4/my_write.m4 <<EOF |
4326 |
12 Mar 23 |
peter |
67 |
AC_DEFUN([MY_WRITE], |
4326 |
12 Mar 23 |
peter |
68 |
[ |
4326 |
12 Mar 23 |
peter |
69 |
YAT_AC_WRITE_TO_FILE([\$1], [\$2]) |
4326 |
12 Mar 23 |
peter |
70 |
YAT_AC_APPEND_TO_FILE([\$1], [\$3]) |
4326 |
12 Mar 23 |
peter |
71 |
]) # end MY_WRITE |
4326 |
12 Mar 23 |
peter |
72 |
EOF |
4326 |
12 Mar 23 |
peter |
73 |
|
4326 |
12 Mar 23 |
peter |
74 |
cat > m4/your_write.m4 <<EOF |
4326 |
12 Mar 23 |
peter |
75 |
AC_DEFUN([YOUR_WRITE], |
4326 |
12 Mar 23 |
peter |
76 |
[ |
4326 |
12 Mar 23 |
peter |
77 |
YAT_AC_WRITE_TO_FILE([\$1], [# header |
4326 |
12 Mar 23 |
peter |
78 |
dollar-one: ]\$[1 |
4326 |
12 Mar 23 |
peter |
#dollar-one: ]\$[1 |
4326 |
12 Mar 23 |
peter |
80 |
dollar-at: ]\$[@ |
4326 |
12 Mar 23 |
peter |
#dollar-at: ]\$[@ |
4326 |
12 Mar 23 |
peter |
82 |
dollar-bracket: ]\$[# |
4326 |
12 Mar 23 |
peter |
#dollar-bracket: ]\$[# |
4326 |
12 Mar 23 |
peter |
84 |
my_target: \$(srcdir) |
4326 |
12 Mar 23 |
peter |
#my_target: \$(srcdir) |
4326 |
12 Mar 23 |
peter |
86 |
srcdir: \${srcdir} |
4326 |
12 Mar 23 |
peter |
#srcdir: \${srcdir} |
4326 |
12 Mar 23 |
peter |
88 |
my-cmd: \$(my command) |
4326 |
12 Mar 23 |
peter |
89 |
my-cmd2: \`my command2\` |
4326 |
12 Mar 23 |
peter |
90 |
expand: \$1 |
4326 |
12 Mar 23 |
peter |
91 |
single-quote: 'Hello' |
4326 |
12 Mar 23 |
peter |
92 |
]) |
4326 |
12 Mar 23 |
peter |
93 |
]) # end MY_WRITE |
4326 |
12 Mar 23 |
peter |
94 |
EOF |
4326 |
12 Mar 23 |
peter |
95 |
|
4326 |
12 Mar 23 |
peter |
96 |
rm -f foo*.txt |
4326 |
12 Mar 23 |
peter |
97 |
|
4326 |
12 Mar 23 |
peter |
98 |
cat configure.ac |
4326 |
12 Mar 23 |
peter |
99 |
bootstrap |
4326 |
12 Mar 23 |
peter |
100 |
test -e foo1.txt || exit_fail no file foo1.txt |
4326 |
12 Mar 23 |
peter |
101 |
cat foo1.txt |
4326 |
12 Mar 23 |
peter |
102 |
grep 'Hello World! my_content' foo1.txt || exit_fail incorrect output |
4326 |
12 Mar 23 |
peter |
103 |
grep "Hi again; it's me... aha" foo1.txt || exit_fail incorrect output |
4326 |
12 Mar 23 |
peter |
104 |
|
4326 |
12 Mar 23 |
peter |
105 |
test -e foo2.txt || exit_fail no file foo2.txt |
4326 |
12 Mar 23 |
peter |
106 |
cat foo2.txt |
4326 |
12 Mar 23 |
peter |
107 |
grep '^one: $1' foo2.txt || exit_fail incorrect output |
4326 |
12 Mar 23 |
peter |
108 |
grep '^two: $2' foo2.txt || exit_fail incorrect output |
4326 |
12 Mar 23 |
peter |
109 |
grep '^at: $@' foo2.txt || exit_fail incorrect output |
4326 |
12 Mar 23 |
peter |
110 |
|
4326 |
12 Mar 23 |
peter |
111 |
test -e m4/my_write.m4 || exit_fail |
4326 |
12 Mar 23 |
peter |
112 |
grep my_write aclocal.m4 || exit_fail |
4326 |
12 Mar 23 |
peter |
113 |
test -e foo3.txt || exit_fail no file foo3.txt |
4326 |
12 Mar 23 |
peter |
114 |
cat foo3.txt |
4326 |
12 Mar 23 |
peter |
115 |
|
4326 |
12 Mar 23 |
peter |
116 |
grep '^header yada yada' foo3.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
117 |
grep 'foo3 stuff' foo3.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
118 |
|
4326 |
12 Mar 23 |
peter |
119 |
grep 'foo4.txt' configure.ac || exit_fail |
4326 |
12 Mar 23 |
peter |
# check that configure.ac contains 'test -e \$1' |
4326 |
12 Mar 23 |
peter |
121 |
grep 'test -e \$1' configure.ac || exit_fail |
4326 |
12 Mar 23 |
peter |
122 |
test -e foo4.txt || exit_fail no file foo4.txt |
4326 |
12 Mar 23 |
peter |
123 |
cat foo4.txt |
4326 |
12 Mar 23 |
peter |
124 |
grep '^test -e $1' foo4.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
125 |
|
4326 |
12 Mar 23 |
peter |
126 |
test -e foo5.txt || exit_fail no file foo5.txt |
4326 |
12 Mar 23 |
peter |
127 |
cat foo5.txt |
4326 |
12 Mar 23 |
peter |
128 |
grep 'my expanded, macro text' foo5.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
129 |
|
4326 |
12 Mar 23 |
peter |
130 |
test -e foo6.txt || exit_fail no file foo6.txt |
4326 |
12 Mar 23 |
peter |
131 |
cat foo6.txt |
4326 |
12 Mar 23 |
peter |
132 |
grep 'cp source $@' foo6.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
133 |
|
4326 |
12 Mar 23 |
peter |
134 |
grep 'dollar' m4/your_write.m4 |
4326 |
12 Mar 23 |
peter |
135 |
test -e foo7.txt || exit_fail no file foo7.txt |
4326 |
12 Mar 23 |
peter |
136 |
cat foo7.txt |
4326 |
12 Mar 23 |
peter |
137 |
grep '^dollar-one: $1' foo7.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
138 |
grep '^#dollar-one: $1' foo7.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
139 |
grep '^dollar-at: $@' foo7.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
140 |
grep '^#dollar-at: $@' foo7.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
141 |
grep '^dollar-bracket: $#' foo7.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
142 |
grep '^#dollar-bracket: $#' foo7.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
143 |
grep '^my_target: $(srcdir)' foo7.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
144 |
grep '^#my_target: $(srcdir)' foo7.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
145 |
grep '^srcdir: ${srcdir}' foo7.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
146 |
grep '^#srcdir: ${srcdir}' foo7.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
147 |
grep '^my-cmd: $(my command)' foo7.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
148 |
grep '^my-cmd2: `my command2`' foo7.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
149 |
grep '^expand: $1' m4/your_write.m4 || exit_fail |
4326 |
12 Mar 23 |
peter |
150 |
grep '^expand: foo7.txt' foo7.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
151 |
grep "^single-quote: 'Hello'" foo7.txt || exit_fail |
4326 |
12 Mar 23 |
peter |
152 |
exit_success; |