xref: /netbsd-src/external/gpl2/gmake/dist/tests/scripts/features/mult_rules (revision 69606e3f5c9388e52aed8c120ad63c049ca45d8f)
1*69606e3fSchristos$description = "\
2*69606e3fSchristosThe following test creates a makefile to test the presence
3*69606e3fSchristosof multiple rules for one target.  One file can be the
4*69606e3fSchristostarget of several rules if at most one rule has commands;
5*69606e3fSchristosthe other rules can only have dependencies.";
6*69606e3fSchristos
7*69606e3fSchristos$details = "\
8*69606e3fSchristosThe makefile created in this test contains two hardcoded rules
9*69606e3fSchristosfor foo.o and bar.o.  It then gives another multiple target rule
10*69606e3fSchristoswith the same names as above but adding more dependencies.
11*69606e3fSchristosAdditionally, another variable extradeps is listed as a
12*69606e3fSchristosdependency but is defined to be null.  It can however be defined
13*69606e3fSchristoson the make command line as extradeps=extra.h which adds yet
14*69606e3fSchristosanother dependency to the targets.";
15*69606e3fSchristos
16*69606e3fSchristosopen(MAKEFILE,"> $makefile");
17*69606e3fSchristos
18*69606e3fSchristos# The Contents of the MAKEFILE ...
19*69606e3fSchristos
20*69606e3fSchristosprint MAKEFILE <<EOF;
21*69606e3fSchristosobjects = foo.o bar.o
22*69606e3fSchristosfoo.o : defs.h
23*69606e3fSchristosbar.o : defs.h test.h
24*69606e3fSchristosextradeps =
25*69606e3fSchristos\$(objects) : config.h \$(extradeps)
26*69606e3fSchristos\t\@echo EXTRA EXTRA
27*69606e3fSchristosEOF
28*69606e3fSchristos
29*69606e3fSchristos# END of Contents of MAKEFILE
30*69606e3fSchristos
31*69606e3fSchristosclose(MAKEFILE);
32*69606e3fSchristos
33*69606e3fSchristos&touch("defs.h","test.h","config.h");
34*69606e3fSchristos
35*69606e3fSchristosif ($vos)
36*69606e3fSchristos{
37*69606e3fSchristos   $error_code = 3307;
38*69606e3fSchristos}
39*69606e3fSchristoselse
40*69606e3fSchristos{
41*69606e3fSchristos   $error_code = 512;
42*69606e3fSchristos}
43*69606e3fSchristos
44*69606e3fSchristos&run_make_with_options($makefile,
45*69606e3fSchristos                       "extradeps=extra.h",
46*69606e3fSchristos                       &get_logfile,
47*69606e3fSchristos                       $error_code);
48*69606e3fSchristos
49*69606e3fSchristos# Create the answer to what should be produced by this Makefile
50*69606e3fSchristos$answer = "$make_name: *** No rule to make target `extra.h', needed by `foo.o'.  Stop.\n";
51*69606e3fSchristos
52*69606e3fSchristos&compare_output($answer,&get_logfile(1));
53*69606e3fSchristos
54*69606e3fSchristos
55*69606e3fSchristos# TEST #2
56*69606e3fSchristos# -------
57*69606e3fSchristos
58*69606e3fSchristos&touch("extra.h");
59*69606e3fSchristos
60*69606e3fSchristos&run_make_with_options($makefile,
61*69606e3fSchristos                       "extradeps=extra.h",
62*69606e3fSchristos                       &get_logfile,
63*69606e3fSchristos                       0);
64*69606e3fSchristos
65*69606e3fSchristos# Create the answer to what should be produced by this Makefile
66*69606e3fSchristos$answer = "EXTRA EXTRA\n";
67*69606e3fSchristos
68*69606e3fSchristos&compare_output($answer,&get_logfile(1));
69*69606e3fSchristos
70*69606e3fSchristosunlink("defs.h","test.h","config.h","extra.h");
71*69606e3fSchristos
72*69606e3fSchristos1;
73*69606e3fSchristos
74*69606e3fSchristos
75*69606e3fSchristos
76*69606e3fSchristos
77*69606e3fSchristos
78*69606e3fSchristos
79