]> git.draconx.ca Git - dxcommon.git/blob - tests/scripts.at
gen-strtab.awk: Add options to tweak the output.
[dxcommon.git] / tests / scripts.at
1 dnl Copyright © 2021-2023 Nick Bowler
2 dnl
3 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
4 dnl This is free software: you are free to do what the fuck you want to.
5 dnl There is NO WARRANTY, to the extent permitted by law.
6
7 AT_BANNER([Script tests])
8
9 AT_SETUP([gen-options.awk])
10 AT_KEYWORDS([gen-options awk script scripts])
11
12 AT_DATA([options.def],
13 [[--option-only
14 --option-with-val (5)
15 --option-with-flagval (&x, 5)
16 --option-with-arg=ARG
17 some "text" goes here
18 --option-with-optional-arg[=OPTIONAL]
19
20 hello
21 -a, --option-with-sopt
22
23 -b, --option-with-sopt-and-arg=SOPTARG
24 -c, --option-with-sopt-and-optional-arg[=SOPTOPTIONAL]
25 --option-with-arg-and-val=ARGVAL (42)
26 --option-with-arg-and-flagval=ARGFLAGVAL (&a[1], 'x')
27 --option-with-optional-arg-and-val[=OPTIONALARGVAL] (54)
28 --option-with-optional-arg-and-flagval[=OPTIONALFLAGVAL] (0, 0)
29 --with-sopt
30 Here is a help string
31     that has a line randomly indented
32 # with a comment
33     @&t@
34 and a blank line
35 --with-arg=ARG
36 do stuff with ARG
37 --flagval
38 ]])
39
40 AT_CHECK([$AWK -f "$builddir/scripts/gen-options.awk" <options.def >options.h])
41
42 AT_DATA([context.h],
43 [[struct option { const char *name; int has_arg; int *flag; int val; };
44 int x, a[5];
45 ]])
46
47 # test 0: sanity test
48 AT_DATA([test0.c],
49 [[#include "context.h"
50 #include "options.h"
51
52 static const char sopts[] = SOPT_STRING;
53 static const struct option opts[] = { LOPTS_INITIALIZER, {0} };
54
55 int main(void)
56 {
57   return 0;
58 }
59 ]])
60 AT_CHECK([$CC -o test0$EXEEXT test0.c && ./test0$EXEEXT], [0], [], [ignore])
61
62 # test 1: long option names and help text
63 AT_DATA([test1.c],
64 [[#include <stdio.h>
65 #include <stdlib.h>
66
67 #include "context.h"
68 #include "options.h"
69
70 static const struct option opts[] = { LOPTS_INITIALIZER };
71
72 int main(void)
73 {
74   unsigned i;
75
76   for (i = 0; i < sizeof opts / sizeof opts[0]; i++) {
77     struct lopt_help help = { "INVALID", "INVALID" };
78
79     if (!lopt_get_help(&opts[i], &help))
80       return EXIT_FAILURE;
81
82     printf("--%s", opts[i].name);
83     if (opts[i].has_arg)
84       printf("=%s", help.arg);
85     printf("\n%s", help.desc);
86     if (help.desc[0])
87       putchar('\n');
88   }
89
90   return 0;
91 }
92 ]])
93
94 # pick out interesting bits from the definitions file
95 sed -n '/^-/s/^.*--\([[^\= @<:@]]*\).*$/\1/p' options.def >options
96 sed -n '/^-/{
97   s/[[^=]]*\(=[[^@:>@ ]]*\).*$/\1/
98   s/^[[^=]].*//
99   s/^=//
100   p
101 }' options.def >argnames
102
103 AS_ECHO(["-"]) | sed -n '1s/^-.*//p
104 1,/^-/d
105 t clear
106 :clear
107 s/^-.*//p
108 t
109 s/^#.*//
110 s/^ *//
111 t next
112 :next
113 N
114 s/\n-.*//
115 t done
116 s/\n#.*//
117 s/\n */\n/g
118 t next
119 :done
120 s/"/\\\\"/g
121 s/[[^\n]][[^\n]]*/\\"&\\"/g
122 s/^\n*//
123 s/\n*$//
124 s/\n\n*/ /g
125 p
126 ' options.def - >helptext
127
128 exec 3<options 4<argnames 5<helptext 6>expout
129 while read opt <&3 && read arg <&4 && read help <&5; do
130   if test ${arg:+y}; then
131     AS_ECHO(["--$opt=$arg"]) >&6
132   else
133     AS_ECHO(["--$opt"]) >&6
134   fi
135   eval "set x $help"; shift
136   for arg
137   do
138     AS_ECHO(["$arg"]) >&6
139   done
140 done
141 exec 3<&- 4<&- 5<&- 6>&-
142
143 AT_CHECK([$CC -o test1$EXEEXT test1.c && ./test1$EXEEXT],
144   [0], [expout], [ignore])
145
146 # test 2: short option string
147 AT_DATA([test2.c],
148 [[#include <stdio.h>
149 #include <stdlib.h>
150
151 #include "context.h"
152 #include "options.h"
153
154 int main(void)
155 {
156   struct option lopts[] = {LOPTS_INITIALIZER};
157   unsigned i, j;
158
159   for (i = 0; i < sizeof SOPT_STRING - 1; i++) {
160     if (SOPT_STRING[i] != ':') {
161       for (j = 0; j < sizeof lopts / sizeof lopts[0]; j++) {
162         if (lopts[j].val == SOPT_STRING[i]) {
163           printf("--%s ", lopts[j].name);
164           break;
165         }
166       }
167     }
168     putchar(SOPT_STRING[i]);
169     if (SOPT_STRING[i+1] != ':')
170       putchar('\n');
171   }
172 }
173 ]])
174
175 sed -n '/^-/{
176   s/=.*/:/
177   s/[[@<:@]]/:/
178   s/^-\([[^-]]\)[[^:]]*/\1/p
179   s/^-.*//p
180 }' options.def >sopts
181
182 exec 3<options 4<sopts 5>expout
183 while read lopt <&3 && read sopt <&4; do
184   if test ${sopt:+y}; then
185     AS_ECHO(["--$lopt $sopt"]) >&5
186   fi
187 done
188 exec 3<&- 4<&- 5>&-
189
190 AT_CHECK([$CC -o test2$EXEEXT test2.c && ./test2$EXEEXT],
191   [0], [expout], [ignore])
192
193 # Check that all help strings are translatable
194 sed 's/\([[^\\]]\\\)" /\1\\n\\" /g' helptext >help-po
195 exec 3<options 4<argnames 5<help-po 6>expected.po
196 while read opt <&3 && read arg <&4 && read help <&5; do
197   if test ${arg:+y}; then
198     AS_ECHO(["msgctxt \"$opt\" msgid \"$arg\""]) >&6
199   fi
200   AS_ECHO(["msgctxt \"$opt\" msgid${help:+ }$help"]) >&6
201 done
202 exec 3<&- 4<&- 5<&- 6>&-
203
204 AT_CHECK([xgettext --keyword=PN_:1c,2 options.h
205   test -f messages.po || exit 77])
206
207 LC_ALL=C sort expected.po >expout
208 AT_CHECK([sed -n '/^msgctxt/{
209 t next
210 :next
211 N
212 s/\nmsgstr.*//
213 t done
214 s/\s*""//
215 s/\n/ /
216 t next
217 :done
218 p
219 }' messages.po | LC_ALL=C sort], [0], [expout])
220
221 AT_CLEANUP
222
223 AT_SETUP([gen-strtab.awk])
224 AT_KEYWORDS([gen-strtab awk script scripts])
225
226 AT_DATA([test.def],
227 [[
228 &a world
229 &b
230 hello world
231 &c
232 hello
233 world
234 &d world\n
235 &e
236 \\not a newline
237 &f
238 \not a newline
239 &g inline
240 continued
241 &h    no\
242 newline\
243 &i
244 \   leading whitespace
245 &j oneline
246 # with a comment
247 ]])
248
249 AT_CHECK([$AWK -f "$builddir/scripts/gen-strtab.awk" <test.def >test.h])
250
251 sed -n 's/^[[&]]\([[^ ]]*\).*/\1/p' test.def >identifiers
252
253 # test 0: sanity test
254 AT_DATA([test0.c],
255 [[#include "test.h"
256 #include <stdio.h>
257
258 int main(void)
259 {
260   printf("---\n");
261 ]])
262 exec 3<identifiers 4>>test0.c
263 while read ident <&3; do
264   AS_ECHO(['  printf("%s\n---\n", '"strtab+$ident);"]) >&4
265 done
266 AS_ECHO(['  return 0;']) >&4
267 AS_ECHO(['}']) >&4
268 exec 3<&- 4>&-
269
270 AT_CHECK([$CC -o test0$EXEEXT test0.c && ./test0$EXEEXT], [0], [---
271 world
272 ---
273 hello world
274
275 ---
276 hello
277 world
278
279 ---
280 world
281
282 ---
283 \not a newline
284
285 ---
286
287 ot a newline
288
289 ---
290 inline
291 continued
292
293 ---
294 nonewline
295 ---
296    leading whitespace
297
298 ---
299 oneline
300 ---
301 ], [ignore])
302
303 AT_CLEANUP
304
305 AT_SETUP([gen-strtab.awk @nozero option])
306 AT_KEYWORDS([gen-strtab awk script scripts])
307
308 AT_DATA([test0.def],
309 [[&hello hello
310 ]])
311 AT_CHECK([$AWK -f "$builddir/scripts/gen-strtab.awk" <test0.def >test0.h])
312
313 AT_DATA([test1.def],
314 [[@nozero
315 &hello hello
316 ]])
317 AT_CHECK([$AWK -f "$builddir/scripts/gen-strtab.awk" <test1.def >test1.h])
318
319 AT_DATA([test.c],
320 [[#include <stdio.h>
321 #include HEADER
322 int main(void) { printf("%d %s\n", hello, strtab+hello); return 0; }
323 ]])
324 AT_CHECK([$CC -DHEADER='"test0.h"' -o test0$EXEEXT test.c && ./test0$EXEEXT],
325   [0], [[0 hello
326 ]])
327 AT_CHECK([$CC -DHEADER='"test1.h"' -o test1$EXEEXT test.c && ./test1$EXEEXT],
328   [0], [[1 hello
329 ]])
330
331 AT_CLEANUP
332
333 AT_SETUP([gen-tree.awk])
334 AT_KEYWORDS([gen-tree awk script scripts])
335
336 AT_DATA([tree.def],
337 [[# comment
338 ROOT0
339   r0a, r0a_OFFSET
340     r0b, r0b_OFFSET
341       r0c
342     r0d
343   r0e, r0e_OFFSET
344     r0f
345     r0g
346 # comment
347 ROOT1
348   r1a, r1a_OFFSET
349     r1b, r1b_OFFSET
350       r1b
351       r1e
352       r1b
353   r1c, r1c_OFFSET
354     r1d, r1d_OFFSET
355       r1e
356       r1b
357       r1e
358 # comment
359 ]])
360
361 AT_CHECK([$AWK -f "$builddir/scripts/gen-tree.awk" <tree.def >tree.h])
362
363 AT_DATA([test0.c],
364 [[#include "tree.h"
365 #include <stdio.h>
366
367 struct tree { unsigned id, subtree; };
368
369 static const struct tree tree0[] = {
370   ROOT0_INITIALIZER
371 };
372 static const struct tree tree1[] = {
373   ROOT1_INITIALIZER
374 };
375
376 void print_subtree(const struct tree *root, unsigned offset, int depth)
377 {
378   const struct tree *node;
379
380   for (node = &root[offset]; node->id; node++) {
381     printf("%*s%s", 2*depth, "", &tree_strtab[node->id]);
382     if (node->subtree) {
383       printf(", %s_OFFSET\n", &tree_strtab[node->id]);
384       print_subtree(root, node->subtree, depth+1);
385     } else {
386       putchar('\n');
387     }
388   }
389 }
390
391 int main(void)
392 {
393   printf("ROOT0\n");
394   print_subtree(tree0, 0, 1);
395   printf("ROOT1\n");
396   print_subtree(tree1, 0, 1);
397   return 0;
398 }
399 ]])
400 sed '/^#/d' tree.def >expout
401 AT_CHECK([$CC -o test0$EXEEXT test0.c && ./test0$EXEEXT], [0], [expout])
402
403 AT_CLEANUP
404
405 # Test the gen-tree features that avoid creating string labels for nodes.
406 AT_SETUP([gen-tree.awk @nostrtab option])
407 AT_KEYWORDS([gen-tree awk script scripts])
408
409 AT_DATA([tree.def],
410 [[@nostrtab
411 ROOT
412  a 1, a_OFFSET
413   b 1
414   c 2
415  d 2, d_OFFSET
416   e 1
417   f 2
418 ]])
419 AT_CHECK([$AWK -f "$builddir/scripts/gen-tree.awk" <tree.def >tree.h])
420
421 AT_DATA([test0.c],
422 [[float tree_strtab = 0;
423 #define a []
424 #define b []
425 #define c []
426 #define e []
427 #define f []
428 #include "tree.h"
429 #include <stdio.h>
430
431 static struct { int num, offset; } root[] = { ROOT_INITIALIZER };
432
433 int main(void)
434 {
435   unsigned i;
436   for (i = 0; i < sizeof root / sizeof root[0]; i++) {
437     printf("%d, %d\n", root[i].num, root[i].offset);
438   }
439 }
440 ]])
441
442 AT_CHECK([$CC -o test0$EXEEXT test0.c && ./test0$EXEEXT], [0],
443 [[1, 3
444 2, 6
445 0, 0
446 1, 0
447 2, 0
448 0, 0
449 1, 0
450 2, 0
451 0, 0
452 ]])
453
454 AT_DATA([flat.def],
455 [[FLAT
456  a 1
457  b 2
458  c 3
459 @nostrtab
460 ]])
461 AT_CHECK([$AWK -f "$builddir/scripts/gen-tree.awk" <flat.def >flat.h])
462
463 sed -e 's/tree\.h/flat.h/' -e 's/ROOT/FLAT/' test0.c >test1.c
464 AT_CHECK([$CC -o test1$EXEEXT test1.c && ./test1$EXEEXT], [0],
465 [[1, 0
466 2, 0
467 3, 0
468 0, 0
469 ]])
470
471 AT_CLEANUP
472
473 AT_SETUP([join.awk])
474 AT_KEYWORDS([join awk script scripts])
475
476 JOIN="$AWK -f $builddir/scripts/join.awk --"
477
478 AT_DATA([a],
479 [[1 a
480 3 a1 x
481 3 a2 x
482 5 a
483 6 a
484 8 a1 x
485 8 a2 x
486 9 a1
487 9 a2
488 9 a3
489 ]])
490
491 AT_DATA([b],
492 [[2 b
493 2 b
494 3 b y
495 4 b
496 6 b1 y
497 6 b2 y
498 7 b
499 8 b1 y
500 8 b2 y
501 ]])
502
503 AT_CHECK([$JOIN a b], [0],
504 [[3 a1 x b y
505 3 a2 x b y
506 6 a b1 y
507 6 a b2 y
508 8 a1 x b1 y
509 8 a1 x b2 y
510 8 a2 x b1 y
511 8 a2 x b2 y
512 ]])
513
514 AT_CHECK([$JOIN -v1 a b], [0],
515 [[1 a
516 5 a
517 9 a1
518 9 a2
519 9 a3
520 ]])
521
522 AT_CHECK([$JOIN -v2 a b], [0],
523 [[2 b
524 2 b
525 4 b
526 7 b
527 ]])
528
529 AT_CHECK([$JOIN -v1 -v2 a b], [0],
530 [[1 a
531 2 b
532 2 b
533 4 b
534 5 a
535 7 b
536 9 a1
537 9 a2
538 9 a3
539 ]])
540
541 AT_CHECK([$JOIN -a1 a b], [0],
542 [[1 a
543 3 a1 x b y
544 3 a2 x b y
545 5 a
546 6 a b1 y
547 6 a b2 y
548 8 a1 x b1 y
549 8 a1 x b2 y
550 8 a2 x b1 y
551 8 a2 x b2 y
552 9 a1
553 9 a2
554 9 a3
555 ]])
556
557 AT_CHECK([$JOIN -a2 a b], [0],
558 [[2 b
559 2 b
560 3 a1 x b y
561 3 a2 x b y
562 4 b
563 6 a b1 y
564 6 a b2 y
565 7 b
566 8 a1 x b1 y
567 8 a1 x b2 y
568 8 a2 x b1 y
569 8 a2 x b2 y
570 ]])
571
572 AT_CHECK([$JOIN -a1 -a2 a b], [0],
573 [[1 a
574 2 b
575 2 b
576 3 a1 x b y
577 3 a2 x b y
578 4 b
579 5 a
580 6 a b1 y
581 6 a b2 y
582 7 b
583 8 a1 x b1 y
584 8 a1 x b2 y
585 8 a2 x b1 y
586 8 a2 x b2 y
587 9 a1
588 9 a2
589 9 a3
590 ]])
591
592 AT_CHECK([$JOIN b a], [0],
593 [[3 b y a1 x
594 3 b y a2 x
595 6 b1 y a
596 6 b2 y a
597 8 b1 y a1 x
598 8 b1 y a2 x
599 8 b2 y a1 x
600 8 b2 y a2 x
601 ]])
602
603 AT_CHECK([$JOIN -v1 b a], [0],
604 [[2 b
605 2 b
606 4 b
607 7 b
608 ]])
609
610 AT_CHECK([$JOIN -v2 b a], [0],
611 [[1 a
612 5 a
613 9 a1
614 9 a2
615 9 a3
616 ]])
617
618 AT_CHECK([$JOIN -v1 -v2 b a], [0],
619 [[1 a
620 2 b
621 2 b
622 4 b
623 5 a
624 7 b
625 9 a1
626 9 a2
627 9 a3
628 ]])
629
630 AT_CHECK([$JOIN -a1 b a], [0],
631 [[2 b
632 2 b
633 3 b y a1 x
634 3 b y a2 x
635 4 b
636 6 b1 y a
637 6 b2 y a
638 7 b
639 8 b1 y a1 x
640 8 b1 y a2 x
641 8 b2 y a1 x
642 8 b2 y a2 x
643 ]])
644
645 AT_CHECK([$JOIN -a2 b a], [0],
646 [[1 a
647 3 b y a1 x
648 3 b y a2 x
649 5 a
650 6 b1 y a
651 6 b2 y a
652 8 b1 y a1 x
653 8 b1 y a2 x
654 8 b2 y a1 x
655 8 b2 y a2 x
656 9 a1
657 9 a2
658 9 a3
659 ]])
660
661 AT_CHECK([$JOIN -a1 -a2 b a], [0],
662 [[1 a
663 2 b
664 2 b
665 3 b y a1 x
666 3 b y a2 x
667 4 b
668 5 a
669 6 b1 y a
670 6 b2 y a
671 7 b
672 8 b1 y a1 x
673 8 b1 y a2 x
674 8 b2 y a1 x
675 8 b2 y a2 x
676 9 a1
677 9 a2
678 9 a3
679 ]])
680
681 AT_CHECK([echo wat | $JOIN -v1 - /dev/null], [0],
682 [[wat
683 ]])
684
685 AT_CLEANUP
686
687 m4_divert_push([PREPARE_TESTS])dnl
688 test_fix_ltdl () {
689   $PERL -e 'my $x = 42; exit $x;'; test $? = 42 || exit 77
690   $PERL -f "$srcdir/scripts/fix-ltdl.pl" "$@"
691 }
692 test_fix_gnulib () {
693   $PERL -e 'my $x = 42; exit $x;'; test $? = 42 || exit 77
694   $PERL -f "$srcdir/scripts/fix-gnulib.pl" "$@"
695 }
696 test_gnulib_mk () {
697   echo;
698   for arg
699   do
700     sed -n -f - "$srcdir/tests/data/gnulib.mk" <<EOF
701 /^## begin gnulib module $arg/,/^## end   gnulib module $arg/p
702 EOF
703   done
704 }
705 m4_divert_pop([PREPARE_TESTS])
706
707 AT_SETUP([fix-gnulib.pl SED_HEADER variables])
708
709 test_gnulib_mk gen-header >test.mk.in
710 AT_CHECK([grep SED_HEADER test.mk.in >expout || exit 99])
711 AT_CHECK([test_fix_gnulib -i test.mk.in -o test.mk || exit
712 grep SED_HEADER test.mk], [0], [expout])
713
714 AT_CLEANUP
715
716 AT_SETUP([fix-gnulib.pl %reldir% substitution])
717
718 test_gnulib_mk sys_types >test.mk.in
719 AT_CHECK([grep '%reldir%' test.mk.in >/dev/null || exit 99])
720
721 sed -n -f - test.mk.in >expout <<'EOF'
722 ${G;p;b}
723 /^## begin gnulib/,/^## end   gnulib/!b
724 /^#/{p;b}
725 s|(srcdir)|(top_srcdir)|
726 s|%reldir%|lib|
727 s|BUILT_SOURCES|gnulib_core_headers|
728 s|sys[[/_]]|lib/&|g
729 /^MOSTLYCLEANFILES/{h;b}
730 p
731 EOF
732
733 AT_CHECK([test_fix_gnulib -i test.mk.in -o test.mk || exit
734 sed -n -e '/^## begin gnulib/,/^## end   gnulib/p' \
735        -e '/CLEANFILES/p' test.mk],
736 [0], [expout])
737
738 AT_CLEANUP
739
740 AT_SETUP([fix-gnulib.pl warning removal])
741
742 AT_DATA([test.mk.in], [[
743 ## test begin
744 noinst_LTLIBRARIES += libgnu.la
745 libgnu_la_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS)
746 noinst_LIBRARIES += libgnu.a
747 libgnu_a_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS)
748 ## test end
749 ]])
750 AT_CHECK([test_fix_gnulib -i test.mk.in -o test.mk || exit
751 sed -n '/^## test begin/,/^## test end/p' test.mk], [0], [## test begin
752 EXTRA_LTLIBRARIES += libgnu.la
753 EXTRA_LIBRARIES += libgnu.a
754 ## test end
755 ])
756
757 AT_CLEANUP
758
759 AT_SETUP([fix-gnulib.pl header directory creation])
760
761 AT_DATA([extract.sed],
762 [[/AM_V_GEN/b ok
763 /gl_V_at/b ok
764 s/:.*/:/
765 h
766 b
767 :ok
768 s/'//g
769 x
770 G
771 p
772 n
773 s/[)].*/)/
774 p
775 ]])
776
777 test_gnulib_mk alloca-opt sys_types stddef >test.mk.in
778 AT_CHECK([test_fix_gnulib -i test.mk.in -o test.mk || exit
779 sed -n -f extract.sed test.mk], [0],
780 [[lib/alloca.h:
781         $(AM_V_GEN)$(MKDIR_P) lib
782         $(AM_V_at)
783 lib/sys/types.h:
784         $(AM_V_GEN)$(MKDIR_P) lib/sys
785         $(AM_V_at)
786 lib/stddef.h:
787         $(AM_V_GEN)$(MKDIR_P) lib
788         $(AM_V_at)
789 ]])
790
791 AT_CLEANUP
792
793 dnl TEST_FIND_AUTOMAKE_VER([to-check], [test-action])
794 dnl
795 dnl For each whitespace-separated version token in to-check, check if we can
796 dnl run the programs automake-VER and aclocal-VER.  The special token 'default'
797 dnl also checks the unversioned automake and aclocal (or, if set in the
798 dnl environment, $AUTOMAKE and $ACLOCAL).
799 dnl
800 dnl Then test-action is expanded such that shell variables $ac and $am refer to
801 dnl the aclocal and automake programs, and $amver is the actual version
802 dnl reported by --version.  The action should do nothing if the version is
803 dnl acceptable, or "continue" if the version is unacceptable.
804 dnl
805 dnl If an acceptable version is found, the AUTOMAKE and ACLOCAL environment
806 dnl variables are set accordingly.  Otherwise, the test group is skipped.
807 m4_define([TEST_FIND_AUTOMAKE],
808 [have_am=false
809 for am in $1; do
810   AS_CASE([$am],
811     [default], [ac=${ACLOCAL-aclocal} am=${AUTOMAKE-automake}],
812     [ac=aclocal-$am; am=automake-$am])
813   amver=`$am --version | sed -n '1s/.* //p'`
814   acver=`$ac --version | sed -n '1s/.* //p'`
815   set x $amver $acver; shift; test x"$[]#" = x"2" || continue
816   test x"$amver" = x"$acver" || continue
817   $2
818   have_am=:; break
819 done
820 AT_CHECK([$have_am || exit 77])
821 AUTOMAKE=$am; export AUTOMAKE
822 ACLOCAL=$ac; export ACLOCAL
823 AT_CHECK([$ACLOCAL --version && $AUTOMAKE --version], [0], [stdout])
824 ])
825
826 m4_define([TEST_LTDL_LIBOBJ_MANGLING],
827 [TEST_CONFIGURE_AC([[AM_INIT_AUTOMAKE([foreign subdir-objects])
828 AC_PROG_CC
829 LT_INIT
830 AC_SUBST([ltdl_LTLIBOBJS], [libltdl/test.lo])
831 AC_CONFIG_FILES([Makefile])
832 ]])
833
834 mkdir libltdl
835 AT_DATA([ltdl.mk.in], [[
836 AM_CPPFLAGS += -DSTRING=\"helloworld\"
837
838 noinst_LTLIBRARIES = libltdl/libltdl.la
839 libltdl_libltdl_la_SOURCES = libltdl/ltdl.c
840 libltdl_libltdl_la_LIBADD = $(ltdl_LTLIBOBJS)
841 libltdl_libltdl_la_DEPENDENCIES = $(ltdl_LTLIBOBJS)
842
843 EXTRA_DIST += libltdl/test.c
844 ]])
845 AT_DATA([Makefile.am], [[AM_CPPFLAGS =
846 include $(top_srcdir)/ltdl.mk
847 AM_LIBTOOLFLAGS = --quiet
848 bin_PROGRAMS = test
849 test_SOURCES =
850 test_LDADD = libltdl/libltdl.la
851 all-local: ; @printf '%s\n' $(AM_CPPFLAGS)
852 ]])
853 AT_DATA([libltdl/test.c], [[#include <stdio.h>
854 int foo(void) { printf("%s\n", STRING); return 0; }
855 ]])
856 AT_DATA([libltdl/ltdl.c], [[int foo(void); int main(void) { return foo(); }
857 ]])
858
859 AT_CHECK([test_fix_ltdl -i ltdl.mk.in -o ltdl.mk])
860 libtoolize; TEST_AUTORECONF
861 TEST_CONFIGURE([--disable-shared])
862 AT_CHECK([make -s && ./test], [0], [
863 helloworld
864 ])])
865
866 AT_SETUP([fix-ltdl.pl LIBOBJ mangling (<automake-1.16)])
867
868 TEST_FIND_AUTOMAKE([default 1.10 1.11 1.12 1.13 1.14 1.15],
869   [AS_VERSION_COMPARE(["$amver"], [1.16], [], [continue], [continue])])
870 TEST_LTDL_LIBOBJ_MANGLING
871
872 AT_CLEANUP
873
874 AT_SETUP([fix-ltdl.pl LIBOBJ mangling (>=automake-1.16)])
875
876 TEST_FIND_AUTOMAKE([default 1.16 1.17 1.18 1.19],
877   [AS_VERSION_COMPARE(["$amver"], [1.16], [continue])])
878 TEST_LTDL_LIBOBJ_MANGLING
879
880 AT_CLEANUP