xref: /netbsd-src/external/gpl2/gmake/dist/tests/scripts/functions/suffix (revision 69606e3f5c9388e52aed8c120ad63c049ca45d8f)
1*69606e3fSchristos$description = "The following test creates a makefile to test the suffix\n"
2*69606e3fSchristos              ."function. \n";
3*69606e3fSchristos
4*69606e3fSchristos$details = "The suffix function will return the string following the last _._\n"
5*69606e3fSchristos          ."the list provided. It will provide all of the unique suffixes found\n"
6*69606e3fSchristos          ."in the list. The long strings are sorted to remove duplicates.\n";
7*69606e3fSchristos
8*69606e3fSchristos# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
9*69606e3fSchristos# THE NAME OF THE MAKEFILE.  THIS INSURES CONSISTENCY AND KEEPS TRACK OF
10*69606e3fSchristos# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
11*69606e3fSchristos# EXAMPLE: $makefile2 = &get_tmpfile;
12*69606e3fSchristos
13*69606e3fSchristos
14*69606e3fSchristosopen(MAKEFILE,"> $makefile");
15*69606e3fSchristos
16*69606e3fSchristos# The Contents of the MAKEFILE ...
17*69606e3fSchristos
18*69606e3fSchristosprint MAKEFILE "string  := word.pl general_test2.pl1 FORCE.pl word.pl3 generic_test.perl /tmp.c/bar foo.baz/bar.c MAKEFILES_variable.c\n"
19*69606e3fSchristos              ."string2 := \$(string) \$(string) \$(string) \$(string) \$(string) \$(string) \$(string)\n"
20*69606e3fSchristos              ."string3 := \$(string2) \$(string2) \$(string2) \$(string2) \$(string2) \$(string2) \$(string2)\n"
21*69606e3fSchristos              ."string4 := \$(string3) \$(string3) \$(string3) \$(string3) \$(string3) \$(string3) \$(string3)\n"
22*69606e3fSchristos              ."all: \n"
23*69606e3fSchristos              ."\t\@echo \$(suffix \$(string)) \n"
24*69606e3fSchristos              ."\t\@echo \$(sort \$(suffix \$(string4))) \n"
25*69606e3fSchristos              ."\t\@echo \$(suffix \$(string) a.out) \n"
26*69606e3fSchristos              ."\t\@echo \$(sort \$(suffix \$(string3))) \n";
27*69606e3fSchristos
28*69606e3fSchristos
29*69606e3fSchristos
30*69606e3fSchristos# END of Contents of MAKEFILE
31*69606e3fSchristos
32*69606e3fSchristosclose(MAKEFILE);
33*69606e3fSchristos
34*69606e3fSchristos&run_make_with_options($makefile,"",&get_logfile,0);
35*69606e3fSchristos
36*69606e3fSchristos# Create the answer to what should be produced by this Makefile
37*69606e3fSchristos
38*69606e3fSchristos# COMPARE RESULTS
39*69606e3fSchristos$answer = ".pl .pl1 .pl .pl3 .perl .c .c\n"
40*69606e3fSchristos         .".c .perl .pl .pl1 .pl3\n"
41*69606e3fSchristos         .".pl .pl1 .pl .pl3 .perl .c .c .out\n"
42*69606e3fSchristos         .".c .perl .pl .pl1 .pl3\n";
43*69606e3fSchristos
44*69606e3fSchristos# In this call to compare output, you should use the call &get_logfile(1)
45*69606e3fSchristos# to send the name of the last logfile created.  You may also use
46*69606e3fSchristos# the special call &get_logfile(1) which returns the same as &get_logfile(1).
47*69606e3fSchristos
48*69606e3fSchristos&compare_output($answer,&get_logfile(1));
49*69606e3fSchristos
50*69606e3fSchristos# This tells the test driver that the perl test script executed properly.
51*69606e3fSchristos1;
52*69606e3fSchristos
53*69606e3fSchristos
54*69606e3fSchristos
55*69606e3fSchristos
56*69606e3fSchristos
57*69606e3fSchristos
58