commit e971b8e

shrub  ·  2026-04-08 21:24:51 +0000 UTC
parent 44ed1ac
license and gnu make test suite
165 files changed,  +24127, -0
R README
+1, -0
1@@ -2,3 +2,4 @@ config.mak
2 test-musl.mk
3 *.o
4 shin
5+tests/work
+20, -0
 1@@ -0,0 +1,20 @@
 2+shinobi is public domain software. here's some legal bullshit for 
 3+your lawyer, if you need some: 
 4+------------------------------
 5+Copyright 2026 everyone! 
 6+
 7+permission to use, copy, modify, and distribute this software for any
 8+purpose with or without fee is hereby granted.
 9+
10+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17+------------------------------
18+
19+the 'tests/' directory is licensed under a GPLv3 license. it is not part 
20+of shinobi or any distributed binaries in any way, shape, or form. it is
21+used for development and testing purposes.
R readme => README
+0, -0
+3, -0
1@@ -0,0 +1,3 @@
2+.test-result
3+config-flags.pm
4+work
+674, -0
  1@@ -0,0 +1,674 @@
  2+                    GNU GENERAL PUBLIC LICENSE
  3+                       Version 3, 29 June 2007
  4+
  5+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
  6+ Everyone is permitted to copy and distribute verbatim copies
  7+ of this license document, but changing it is not allowed.
  8+
  9+                            Preamble
 10+
 11+  The GNU General Public License is a free, copyleft license for
 12+software and other kinds of works.
 13+
 14+  The licenses for most software and other practical works are designed
 15+to take away your freedom to share and change the works.  By contrast,
 16+the GNU General Public License is intended to guarantee your freedom to
 17+share and change all versions of a program--to make sure it remains free
 18+software for all its users.  We, the Free Software Foundation, use the
 19+GNU General Public License for most of our software; it applies also to
 20+any other work released this way by its authors.  You can apply it to
 21+your programs, too.
 22+
 23+  When we speak of free software, we are referring to freedom, not
 24+price.  Our General Public Licenses are designed to make sure that you
 25+have the freedom to distribute copies of free software (and charge for
 26+them if you wish), that you receive source code or can get it if you
 27+want it, that you can change the software or use pieces of it in new
 28+free programs, and that you know you can do these things.
 29+
 30+  To protect your rights, we need to prevent others from denying you
 31+these rights or asking you to surrender the rights.  Therefore, you have
 32+certain responsibilities if you distribute copies of the software, or if
 33+you modify it: responsibilities to respect the freedom of others.
 34+
 35+  For example, if you distribute copies of such a program, whether
 36+gratis or for a fee, you must pass on to the recipients the same
 37+freedoms that you received.  You must make sure that they, too, receive
 38+or can get the source code.  And you must show them these terms so they
 39+know their rights.
 40+
 41+  Developers that use the GNU GPL protect your rights with two steps:
 42+(1) assert copyright on the software, and (2) offer you this License
 43+giving you legal permission to copy, distribute and/or modify it.
 44+
 45+  For the developers' and authors' protection, the GPL clearly explains
 46+that there is no warranty for this free software.  For both users' and
 47+authors' sake, the GPL requires that modified versions be marked as
 48+changed, so that their problems will not be attributed erroneously to
 49+authors of previous versions.
 50+
 51+  Some devices are designed to deny users access to install or run
 52+modified versions of the software inside them, although the manufacturer
 53+can do so.  This is fundamentally incompatible with the aim of
 54+protecting users' freedom to change the software.  The systematic
 55+pattern of such abuse occurs in the area of products for individuals to
 56+use, which is precisely where it is most unacceptable.  Therefore, we
 57+have designed this version of the GPL to prohibit the practice for those
 58+products.  If such problems arise substantially in other domains, we
 59+stand ready to extend this provision to those domains in future versions
 60+of the GPL, as needed to protect the freedom of users.
 61+
 62+  Finally, every program is threatened constantly by software patents.
 63+States should not allow patents to restrict development and use of
 64+software on general-purpose computers, but in those that do, we wish to
 65+avoid the special danger that patents applied to a free program could
 66+make it effectively proprietary.  To prevent this, the GPL assures that
 67+patents cannot be used to render the program non-free.
 68+
 69+  The precise terms and conditions for copying, distribution and
 70+modification follow.
 71+
 72+                       TERMS AND CONDITIONS
 73+
 74+  0. Definitions.
 75+
 76+  "This License" refers to version 3 of the GNU General Public License.
 77+
 78+  "Copyright" also means copyright-like laws that apply to other kinds of
 79+works, such as semiconductor masks.
 80+
 81+  "The Program" refers to any copyrightable work licensed under this
 82+License.  Each licensee is addressed as "you".  "Licensees" and
 83+"recipients" may be individuals or organizations.
 84+
 85+  To "modify" a work means to copy from or adapt all or part of the work
 86+in a fashion requiring copyright permission, other than the making of an
 87+exact copy.  The resulting work is called a "modified version" of the
 88+earlier work or a work "based on" the earlier work.
 89+
 90+  A "covered work" means either the unmodified Program or a work based
 91+on the Program.
 92+
 93+  To "propagate" a work means to do anything with it that, without
 94+permission, would make you directly or secondarily liable for
 95+infringement under applicable copyright law, except executing it on a
 96+computer or modifying a private copy.  Propagation includes copying,
 97+distribution (with or without modification), making available to the
 98+public, and in some countries other activities as well.
 99+
100+  To "convey" a work means any kind of propagation that enables other
101+parties to make or receive copies.  Mere interaction with a user through
102+a computer network, with no transfer of a copy, is not conveying.
103+
104+  An interactive user interface displays "Appropriate Legal Notices"
105+to the extent that it includes a convenient and prominently visible
106+feature that (1) displays an appropriate copyright notice, and (2)
107+tells the user that there is no warranty for the work (except to the
108+extent that warranties are provided), that licensees may convey the
109+work under this License, and how to view a copy of this License.  If
110+the interface presents a list of user commands or options, such as a
111+menu, a prominent item in the list meets this criterion.
112+
113+  1. Source Code.
114+
115+  The "source code" for a work means the preferred form of the work
116+for making modifications to it.  "Object code" means any non-source
117+form of a work.
118+
119+  A "Standard Interface" means an interface that either is an official
120+standard defined by a recognized standards body, or, in the case of
121+interfaces specified for a particular programming language, one that
122+is widely used among developers working in that language.
123+
124+  The "System Libraries" of an executable work include anything, other
125+than the work as a whole, that (a) is included in the normal form of
126+packaging a Major Component, but which is not part of that Major
127+Component, and (b) serves only to enable use of the work with that
128+Major Component, or to implement a Standard Interface for which an
129+implementation is available to the public in source code form.  A
130+"Major Component", in this context, means a major essential component
131+(kernel, window system, and so on) of the specific operating system
132+(if any) on which the executable work runs, or a compiler used to
133+produce the work, or an object code interpreter used to run it.
134+
135+  The "Corresponding Source" for a work in object code form means all
136+the source code needed to generate, install, and (for an executable
137+work) run the object code and to modify the work, including scripts to
138+control those activities.  However, it does not include the work's
139+System Libraries, or general-purpose tools or generally available free
140+programs which are used unmodified in performing those activities but
141+which are not part of the work.  For example, Corresponding Source
142+includes interface definition files associated with source files for
143+the work, and the source code for shared libraries and dynamically
144+linked subprograms that the work is specifically designed to require,
145+such as by intimate data communication or control flow between those
146+subprograms and other parts of the work.
147+
148+  The Corresponding Source need not include anything that users
149+can regenerate automatically from other parts of the Corresponding
150+Source.
151+
152+  The Corresponding Source for a work in source code form is that
153+same work.
154+
155+  2. Basic Permissions.
156+
157+  All rights granted under this License are granted for the term of
158+copyright on the Program, and are irrevocable provided the stated
159+conditions are met.  This License explicitly affirms your unlimited
160+permission to run the unmodified Program.  The output from running a
161+covered work is covered by this License only if the output, given its
162+content, constitutes a covered work.  This License acknowledges your
163+rights of fair use or other equivalent, as provided by copyright law.
164+
165+  You may make, run and propagate covered works that you do not
166+convey, without conditions so long as your license otherwise remains
167+in force.  You may convey covered works to others for the sole purpose
168+of having them make modifications exclusively for you, or provide you
169+with facilities for running those works, provided that you comply with
170+the terms of this License in conveying all material for which you do
171+not control copyright.  Those thus making or running the covered works
172+for you must do so exclusively on your behalf, under your direction
173+and control, on terms that prohibit them from making any copies of
174+your copyrighted material outside their relationship with you.
175+
176+  Conveying under any other circumstances is permitted solely under
177+the conditions stated below.  Sublicensing is not allowed; section 10
178+makes it unnecessary.
179+
180+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
181+
182+  No covered work shall be deemed part of an effective technological
183+measure under any applicable law fulfilling obligations under article
184+11 of the WIPO copyright treaty adopted on 20 December 1996, or
185+similar laws prohibiting or restricting circumvention of such
186+measures.
187+
188+  When you convey a covered work, you waive any legal power to forbid
189+circumvention of technological measures to the extent such circumvention
190+is effected by exercising rights under this License with respect to
191+the covered work, and you disclaim any intention to limit operation or
192+modification of the work as a means of enforcing, against the work's
193+users, your or third parties' legal rights to forbid circumvention of
194+technological measures.
195+
196+  4. Conveying Verbatim Copies.
197+
198+  You may convey verbatim copies of the Program's source code as you
199+receive it, in any medium, provided that you conspicuously and
200+appropriately publish on each copy an appropriate copyright notice;
201+keep intact all notices stating that this License and any
202+non-permissive terms added in accord with section 7 apply to the code;
203+keep intact all notices of the absence of any warranty; and give all
204+recipients a copy of this License along with the Program.
205+
206+  You may charge any price or no price for each copy that you convey,
207+and you may offer support or warranty protection for a fee.
208+
209+  5. Conveying Modified Source Versions.
210+
211+  You may convey a work based on the Program, or the modifications to
212+produce it from the Program, in the form of source code under the
213+terms of section 4, provided that you also meet all of these conditions:
214+
215+    a) The work must carry prominent notices stating that you modified
216+    it, and giving a relevant date.
217+
218+    b) The work must carry prominent notices stating that it is
219+    released under this License and any conditions added under section
220+    7.  This requirement modifies the requirement in section 4 to
221+    "keep intact all notices".
222+
223+    c) You must license the entire work, as a whole, under this
224+    License to anyone who comes into possession of a copy.  This
225+    License will therefore apply, along with any applicable section 7
226+    additional terms, to the whole of the work, and all its parts,
227+    regardless of how they are packaged.  This License gives no
228+    permission to license the work in any other way, but it does not
229+    invalidate such permission if you have separately received it.
230+
231+    d) If the work has interactive user interfaces, each must display
232+    Appropriate Legal Notices; however, if the Program has interactive
233+    interfaces that do not display Appropriate Legal Notices, your
234+    work need not make them do so.
235+
236+  A compilation of a covered work with other separate and independent
237+works, which are not by their nature extensions of the covered work,
238+and which are not combined with it such as to form a larger program,
239+in or on a volume of a storage or distribution medium, is called an
240+"aggregate" if the compilation and its resulting copyright are not
241+used to limit the access or legal rights of the compilation's users
242+beyond what the individual works permit.  Inclusion of a covered work
243+in an aggregate does not cause this License to apply to the other
244+parts of the aggregate.
245+
246+  6. Conveying Non-Source Forms.
247+
248+  You may convey a covered work in object code form under the terms
249+of sections 4 and 5, provided that you also convey the
250+machine-readable Corresponding Source under the terms of this License,
251+in one of these ways:
252+
253+    a) Convey the object code in, or embodied in, a physical product
254+    (including a physical distribution medium), accompanied by the
255+    Corresponding Source fixed on a durable physical medium
256+    customarily used for software interchange.
257+
258+    b) Convey the object code in, or embodied in, a physical product
259+    (including a physical distribution medium), accompanied by a
260+    written offer, valid for at least three years and valid for as
261+    long as you offer spare parts or customer support for that product
262+    model, to give anyone who possesses the object code either (1) a
263+    copy of the Corresponding Source for all the software in the
264+    product that is covered by this License, on a durable physical
265+    medium customarily used for software interchange, for a price no
266+    more than your reasonable cost of physically performing this
267+    conveying of source, or (2) access to copy the
268+    Corresponding Source from a network server at no charge.
269+
270+    c) Convey individual copies of the object code with a copy of the
271+    written offer to provide the Corresponding Source.  This
272+    alternative is allowed only occasionally and noncommercially, and
273+    only if you received the object code with such an offer, in accord
274+    with subsection 6b.
275+
276+    d) Convey the object code by offering access from a designated
277+    place (gratis or for a charge), and offer equivalent access to the
278+    Corresponding Source in the same way through the same place at no
279+    further charge.  You need not require recipients to copy the
280+    Corresponding Source along with the object code.  If the place to
281+    copy the object code is a network server, the Corresponding Source
282+    may be on a different server (operated by you or a third party)
283+    that supports equivalent copying facilities, provided you maintain
284+    clear directions next to the object code saying where to find the
285+    Corresponding Source.  Regardless of what server hosts the
286+    Corresponding Source, you remain obligated to ensure that it is
287+    available for as long as needed to satisfy these requirements.
288+
289+    e) Convey the object code using peer-to-peer transmission, provided
290+    you inform other peers where the object code and Corresponding
291+    Source of the work are being offered to the general public at no
292+    charge under subsection 6d.
293+
294+  A separable portion of the object code, whose source code is excluded
295+from the Corresponding Source as a System Library, need not be
296+included in conveying the object code work.
297+
298+  A "User Product" is either (1) a "consumer product", which means any
299+tangible personal property which is normally used for personal, family,
300+or household purposes, or (2) anything designed or sold for incorporation
301+into a dwelling.  In determining whether a product is a consumer product,
302+doubtful cases shall be resolved in favor of coverage.  For a particular
303+product received by a particular user, "normally used" refers to a
304+typical or common use of that class of product, regardless of the status
305+of the particular user or of the way in which the particular user
306+actually uses, or expects or is expected to use, the product.  A product
307+is a consumer product regardless of whether the product has substantial
308+commercial, industrial or non-consumer uses, unless such uses represent
309+the only significant mode of use of the product.
310+
311+  "Installation Information" for a User Product means any methods,
312+procedures, authorization keys, or other information required to install
313+and execute modified versions of a covered work in that User Product from
314+a modified version of its Corresponding Source.  The information must
315+suffice to ensure that the continued functioning of the modified object
316+code is in no case prevented or interfered with solely because
317+modification has been made.
318+
319+  If you convey an object code work under this section in, or with, or
320+specifically for use in, a User Product, and the conveying occurs as
321+part of a transaction in which the right of possession and use of the
322+User Product is transferred to the recipient in perpetuity or for a
323+fixed term (regardless of how the transaction is characterized), the
324+Corresponding Source conveyed under this section must be accompanied
325+by the Installation Information.  But this requirement does not apply
326+if neither you nor any third party retains the ability to install
327+modified object code on the User Product (for example, the work has
328+been installed in ROM).
329+
330+  The requirement to provide Installation Information does not include a
331+requirement to continue to provide support service, warranty, or updates
332+for a work that has been modified or installed by the recipient, or for
333+the User Product in which it has been modified or installed.  Access to a
334+network may be denied when the modification itself materially and
335+adversely affects the operation of the network or violates the rules and
336+protocols for communication across the network.
337+
338+  Corresponding Source conveyed, and Installation Information provided,
339+in accord with this section must be in a format that is publicly
340+documented (and with an implementation available to the public in
341+source code form), and must require no special password or key for
342+unpacking, reading or copying.
343+
344+  7. Additional Terms.
345+
346+  "Additional permissions" are terms that supplement the terms of this
347+License by making exceptions from one or more of its conditions.
348+Additional permissions that are applicable to the entire Program shall
349+be treated as though they were included in this License, to the extent
350+that they are valid under applicable law.  If additional permissions
351+apply only to part of the Program, that part may be used separately
352+under those permissions, but the entire Program remains governed by
353+this License without regard to the additional permissions.
354+
355+  When you convey a copy of a covered work, you may at your option
356+remove any additional permissions from that copy, or from any part of
357+it.  (Additional permissions may be written to require their own
358+removal in certain cases when you modify the work.)  You may place
359+additional permissions on material, added by you to a covered work,
360+for which you have or can give appropriate copyright permission.
361+
362+  Notwithstanding any other provision of this License, for material you
363+add to a covered work, you may (if authorized by the copyright holders of
364+that material) supplement the terms of this License with terms:
365+
366+    a) Disclaiming warranty or limiting liability differently from the
367+    terms of sections 15 and 16 of this License; or
368+
369+    b) Requiring preservation of specified reasonable legal notices or
370+    author attributions in that material or in the Appropriate Legal
371+    Notices displayed by works containing it; or
372+
373+    c) Prohibiting misrepresentation of the origin of that material, or
374+    requiring that modified versions of such material be marked in
375+    reasonable ways as different from the original version; or
376+
377+    d) Limiting the use for publicity purposes of names of licensors or
378+    authors of the material; or
379+
380+    e) Declining to grant rights under trademark law for use of some
381+    trade names, trademarks, or service marks; or
382+
383+    f) Requiring indemnification of licensors and authors of that
384+    material by anyone who conveys the material (or modified versions of
385+    it) with contractual assumptions of liability to the recipient, for
386+    any liability that these contractual assumptions directly impose on
387+    those licensors and authors.
388+
389+  All other non-permissive additional terms are considered "further
390+restrictions" within the meaning of section 10.  If the Program as you
391+received it, or any part of it, contains a notice stating that it is
392+governed by this License along with a term that is a further
393+restriction, you may remove that term.  If a license document contains
394+a further restriction but permits relicensing or conveying under this
395+License, you may add to a covered work material governed by the terms
396+of that license document, provided that the further restriction does
397+not survive such relicensing or conveying.
398+
399+  If you add terms to a covered work in accord with this section, you
400+must place, in the relevant source files, a statement of the
401+additional terms that apply to those files, or a notice indicating
402+where to find the applicable terms.
403+
404+  Additional terms, permissive or non-permissive, may be stated in the
405+form of a separately written license, or stated as exceptions;
406+the above requirements apply either way.
407+
408+  8. Termination.
409+
410+  You may not propagate or modify a covered work except as expressly
411+provided under this License.  Any attempt otherwise to propagate or
412+modify it is void, and will automatically terminate your rights under
413+this License (including any patent licenses granted under the third
414+paragraph of section 11).
415+
416+  However, if you cease all violation of this License, then your
417+license from a particular copyright holder is reinstated (a)
418+provisionally, unless and until the copyright holder explicitly and
419+finally terminates your license, and (b) permanently, if the copyright
420+holder fails to notify you of the violation by some reasonable means
421+prior to 60 days after the cessation.
422+
423+  Moreover, your license from a particular copyright holder is
424+reinstated permanently if the copyright holder notifies you of the
425+violation by some reasonable means, this is the first time you have
426+received notice of violation of this License (for any work) from that
427+copyright holder, and you cure the violation prior to 30 days after
428+your receipt of the notice.
429+
430+  Termination of your rights under this section does not terminate the
431+licenses of parties who have received copies or rights from you under
432+this License.  If your rights have been terminated and not permanently
433+reinstated, you do not qualify to receive new licenses for the same
434+material under section 10.
435+
436+  9. Acceptance Not Required for Having Copies.
437+
438+  You are not required to accept this License in order to receive or
439+run a copy of the Program.  Ancillary propagation of a covered work
440+occurring solely as a consequence of using peer-to-peer transmission
441+to receive a copy likewise does not require acceptance.  However,
442+nothing other than this License grants you permission to propagate or
443+modify any covered work.  These actions infringe copyright if you do
444+not accept this License.  Therefore, by modifying or propagating a
445+covered work, you indicate your acceptance of this License to do so.
446+
447+  10. Automatic Licensing of Downstream Recipients.
448+
449+  Each time you convey a covered work, the recipient automatically
450+receives a license from the original licensors, to run, modify and
451+propagate that work, subject to this License.  You are not responsible
452+for enforcing compliance by third parties with this License.
453+
454+  An "entity transaction" is a transaction transferring control of an
455+organization, or substantially all assets of one, or subdividing an
456+organization, or merging organizations.  If propagation of a covered
457+work results from an entity transaction, each party to that
458+transaction who receives a copy of the work also receives whatever
459+licenses to the work the party's predecessor in interest had or could
460+give under the previous paragraph, plus a right to possession of the
461+Corresponding Source of the work from the predecessor in interest, if
462+the predecessor has it or can get it with reasonable efforts.
463+
464+  You may not impose any further restrictions on the exercise of the
465+rights granted or affirmed under this License.  For example, you may
466+not impose a license fee, royalty, or other charge for exercise of
467+rights granted under this License, and you may not initiate litigation
468+(including a cross-claim or counterclaim in a lawsuit) alleging that
469+any patent claim is infringed by making, using, selling, offering for
470+sale, or importing the Program or any portion of it.
471+
472+  11. Patents.
473+
474+  A "contributor" is a copyright holder who authorizes use under this
475+License of the Program or a work on which the Program is based.  The
476+work thus licensed is called the contributor's "contributor version".
477+
478+  A contributor's "essential patent claims" are all patent claims
479+owned or controlled by the contributor, whether already acquired or
480+hereafter acquired, that would be infringed by some manner, permitted
481+by this License, of making, using, or selling its contributor version,
482+but do not include claims that would be infringed only as a
483+consequence of further modification of the contributor version.  For
484+purposes of this definition, "control" includes the right to grant
485+patent sublicenses in a manner consistent with the requirements of
486+this License.
487+
488+  Each contributor grants you a non-exclusive, worldwide, royalty-free
489+patent license under the contributor's essential patent claims, to
490+make, use, sell, offer for sale, import and otherwise run, modify and
491+propagate the contents of its contributor version.
492+
493+  In the following three paragraphs, a "patent license" is any express
494+agreement or commitment, however denominated, not to enforce a patent
495+(such as an express permission to practice a patent or covenant not to
496+sue for patent infringement).  To "grant" such a patent license to a
497+party means to make such an agreement or commitment not to enforce a
498+patent against the party.
499+
500+  If you convey a covered work, knowingly relying on a patent license,
501+and the Corresponding Source of the work is not available for anyone
502+to copy, free of charge and under the terms of this License, through a
503+publicly available network server or other readily accessible means,
504+then you must either (1) cause the Corresponding Source to be so
505+available, or (2) arrange to deprive yourself of the benefit of the
506+patent license for this particular work, or (3) arrange, in a manner
507+consistent with the requirements of this License, to extend the patent
508+license to downstream recipients.  "Knowingly relying" means you have
509+actual knowledge that, but for the patent license, your conveying the
510+covered work in a country, or your recipient's use of the covered work
511+in a country, would infringe one or more identifiable patents in that
512+country that you have reason to believe are valid.
513+
514+  If, pursuant to or in connection with a single transaction or
515+arrangement, you convey, or propagate by procuring conveyance of, a
516+covered work, and grant a patent license to some of the parties
517+receiving the covered work authorizing them to use, propagate, modify
518+or convey a specific copy of the covered work, then the patent license
519+you grant is automatically extended to all recipients of the covered
520+work and works based on it.
521+
522+  A patent license is "discriminatory" if it does not include within
523+the scope of its coverage, prohibits the exercise of, or is
524+conditioned on the non-exercise of one or more of the rights that are
525+specifically granted under this License.  You may not convey a covered
526+work if you are a party to an arrangement with a third party that is
527+in the business of distributing software, under which you make payment
528+to the third party based on the extent of your activity of conveying
529+the work, and under which the third party grants, to any of the
530+parties who would receive the covered work from you, a discriminatory
531+patent license (a) in connection with copies of the covered work
532+conveyed by you (or copies made from those copies), or (b) primarily
533+for and in connection with specific products or compilations that
534+contain the covered work, unless you entered into that arrangement,
535+or that patent license was granted, prior to 28 March 2007.
536+
537+  Nothing in this License shall be construed as excluding or limiting
538+any implied license or other defenses to infringement that may
539+otherwise be available to you under applicable patent law.
540+
541+  12. No Surrender of Others' Freedom.
542+
543+  If conditions are imposed on you (whether by court order, agreement or
544+otherwise) that contradict the conditions of this License, they do not
545+excuse you from the conditions of this License.  If you cannot convey a
546+covered work so as to satisfy simultaneously your obligations under this
547+License and any other pertinent obligations, then as a consequence you may
548+not convey it at all.  For example, if you agree to terms that obligate you
549+to collect a royalty for further conveying from those to whom you convey
550+the Program, the only way you could satisfy both those terms and this
551+License would be to refrain entirely from conveying the Program.
552+
553+  13. Use with the GNU Affero General Public License.
554+
555+  Notwithstanding any other provision of this License, you have
556+permission to link or combine any covered work with a work licensed
557+under version 3 of the GNU Affero General Public License into a single
558+combined work, and to convey the resulting work.  The terms of this
559+License will continue to apply to the part which is the covered work,
560+but the special requirements of the GNU Affero General Public License,
561+section 13, concerning interaction through a network will apply to the
562+combination as such.
563+
564+  14. Revised Versions of this License.
565+
566+  The Free Software Foundation may publish revised and/or new versions of
567+the GNU General Public License from time to time.  Such new versions will
568+be similar in spirit to the present version, but may differ in detail to
569+address new problems or concerns.
570+
571+  Each version is given a distinguishing version number.  If the
572+Program specifies that a certain numbered version of the GNU General
573+Public License "or any later version" applies to it, you have the
574+option of following the terms and conditions either of that numbered
575+version or of any later version published by the Free Software
576+Foundation.  If the Program does not specify a version number of the
577+GNU General Public License, you may choose any version ever published
578+by the Free Software Foundation.
579+
580+  If the Program specifies that a proxy can decide which future
581+versions of the GNU General Public License can be used, that proxy's
582+public statement of acceptance of a version permanently authorizes you
583+to choose that version for the Program.
584+
585+  Later license versions may give you additional or different
586+permissions.  However, no additional obligations are imposed on any
587+author or copyright holder as a result of your choosing to follow a
588+later version.
589+
590+  15. Disclaimer of Warranty.
591+
592+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
593+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
594+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
595+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
596+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
597+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
598+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
599+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
600+
601+  16. Limitation of Liability.
602+
603+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
604+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
605+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
606+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
607+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
608+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
609+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
610+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
611+SUCH DAMAGES.
612+
613+  17. Interpretation of Sections 15 and 16.
614+
615+  If the disclaimer of warranty and limitation of liability provided
616+above cannot be given local legal effect according to their terms,
617+reviewing courts shall apply local law that most closely approximates
618+an absolute waiver of all civil liability in connection with the
619+Program, unless a warranty or assumption of liability accompanies a
620+copy of the Program in return for a fee.
621+
622+                     END OF TERMS AND CONDITIONS
623+
624+            How to Apply These Terms to Your New Programs
625+
626+  If you develop a new program, and you want it to be of the greatest
627+possible use to the public, the best way to achieve this is to make it
628+free software which everyone can redistribute and change under these terms.
629+
630+  To do so, attach the following notices to the program.  It is safest
631+to attach them to the start of each source file to most effectively
632+state the exclusion of warranty; and each file should have at least
633+the "copyright" line and a pointer to where the full notice is found.
634+
635+    <one line to give the program's name and a brief idea of what it does.>
636+    Copyright (C) <year>  <name of author>
637+
638+    This program is free software: you can redistribute it and/or modify
639+    it under the terms of the GNU General Public License as published by
640+    the Free Software Foundation, either version 3 of the License, or
641+    (at your option) any later version.
642+
643+    This program is distributed in the hope that it will be useful,
644+    but WITHOUT ANY WARRANTY; without even the implied warranty of
645+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
646+    GNU General Public License for more details.
647+
648+    You should have received a copy of the GNU General Public License
649+    along with this program.  If not, see <https://www.gnu.org/licenses/>.
650+
651+Also add information on how to contact you by electronic and paper mail.
652+
653+  If the program does terminal interaction, make it output a short
654+notice like this when it starts in an interactive mode:
655+
656+    <program>  Copyright (C) <year>  <name of author>
657+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
658+    This is free software, and you are welcome to redistribute it
659+    under certain conditions; type `show c' for details.
660+
661+The hypothetical commands `show w' and `show c' should show the appropriate
662+parts of the General Public License.  Of course, your program's commands
663+might be different; for a GUI interface, you would use an "about box".
664+
665+  You should also get your employer (if you work as a programmer) or school,
666+if any, to sign a "copyright disclaimer" for the program, if necessary.
667+For more information on this, and how to apply and follow the GNU GPL, see
668+<https://www.gnu.org/licenses/>.
669+
670+  The GNU General Public License does not permit incorporating your program
671+into proprietary programs.  If your program is a subroutine library, you
672+may consider it more useful to permit linking proprietary applications with
673+the library.  If this is what you want to do, use the GNU Lesser General
674+Public License instead of this License.  But first, please read
675+<https://www.gnu.org/philosophy/why-not-lgpl.html>.
+1429, -0
   1@@ -0,0 +1,1429 @@
   2+2013-10-09  Paul Smith  <psmith@gnu.org>
   3+
   4+	* scripts/features/patspecific_vars: Typo fixes.
   5+
   6+2013-10-05  Paul Smith  <psmith@gnu.org>
   7+
   8+	* test_driver.pl (run_all_tests): Rewrite to be more clear.
   9+	* scripts/features/jobserver: Avoid using $ENV{HOME} as it doesn't
  10+	exist everywhere.
  11+	* scripts/features/default_names: End with 1;
  12+
  13+	* scripts/features/loadapi: Use new calling signatures.  Verify
  14+	the NOEXPAND flag works.  Test with all valid function name
  15+	characters.
  16+
  17+2013-09-29  Paul Smith  <psmith@gnu.org>
  18+
  19+	* scripts/variables/SHELL: Solaris /bin/sh can't handle options in
  20+	multiple words; skip that test.
  21+	* scripts/targets/ONESHELL: Ditto.
  22+
  23+	* scripts/variables/GNUMAKEFLAGS: Verify that GNUMAKEFLAGS is
  24+	cleared and options are not duplicated.
  25+
  26+2013-09-23  Paul Smith  <psmith@gnu.org>
  27+
  28+	* scripts/options/print-directory: Rename dash-w to
  29+	print-directory to avoid conflicts with dash-W on case-insensitive
  30+	filesystems.
  31+
  32+2013-09-22  Paul Smith  <psmith@gnu.org>
  33+
  34+	* scripts/features/se_implicit: Verify that order-only tokens
  35+	inside second expansion are parsed correctly.
  36+	Test for Savannah bug #31155.
  37+
  38+	* run_make_tests.pl (set_more_defaults): If we can't find
  39+	gnumake.h based on the make program we might be running from a
  40+	remote build directory.  Parse the Makefile for the right path.
  41+
  42+	Fix some test issues on Solaris.
  43+
  44+	* scripts/features/archives: Determine what output ar gives when
  45+	adding and replacing objects and compare with that.
  46+	* scripts/features/escape: Solaris /bin/sh doesn't properly handle
  47+	backslashes inside single quotes, so don't rely on it.
  48+	* scripts/features/output-sync: false(1) gives different exit
  49+	codes on different systems; use "exit 1" instead.
  50+	* scripts/features/parallelism: Increase the timeout for slower systems.
  51+
  52+2013-09-21  Paul Smith  <psmith@gnu.org>
  53+
  54+	* scripts/features/archives: Some versions of ar (MacOSX) generate
  55+	different output when creating archives.  Run it and verify the
  56+	real output.
  57+	* scripts/features/default_names: MacOSX is, like Windows,
  58+	case-preserving / case-insensitive.  Redo the test to avoid
  59+	checking for "UNIX".
  60+	* test_driver.pl (attach_default_output): Don't dup stdout into
  61+	stderr.  Reported by Denis Excoffier <bug-tar@Denis-Excoffier.org>
  62+
  63+	* scripts/features/se_explicit: Fix a test that behaves
  64+	differently with/without archive capability enabled.
  65+	* scripts/features/output-sync: Don't test output-sync if it's not
  66+	enabled.  We also skip it if parallelism is not enabled, although
  67+	strictly speaking some of the output-sync tests are valid even
  68+	without parallelism.
  69+	* scripts/features/jobserver: Move some tests that require the
  70+	jobserver from features/parallelism to a separate suite.  Only run
  71+	this if jobserver mode is enabled.
  72+
  73+	* scripts/features/output-sync: Test shell functions writing to
  74+	stderr in recipes: ensure it's captured via output-sync.  Test
  75+	output generated while reading makefiles and make sure it's
  76+	captured via output-sync.  Make sure that fatal errors dump the
  77+	output so it's not lost.
  78+
  79+	* scripts/options/dash-w: Add a test for -w flag.
  80+
  81+2013-09-15  Paul Smith  <psmith@gnu.org>
  82+
  83+	* scripts/misc/fopen-fail: Check for failure on infinite recursion.
  84+	* run_make_tests.pl (run_make_test): Allow the answer string to be
  85+	undef, which means that we shouldn't compare it at all.  Only the
  86+	exit code matters in this case.
  87+	* test_driver.pl (compare_output): Ditto.
  88+	Test for Savannah bug #27374.
  89+
  90+	* scripts/features/parallelism: Test broken jobserver on recursion.
  91+	Test for Savannah bug #39934.
  92+
  93+	* scripts/options/eval: Verify --eval during restart.
  94+	Test for Savannah bug #39203.
  95+
  96+2013-09-14  Paul Smith  <psmith@gnu.org>
  97+
  98+	* scripts/features/output-sync: Verify -Orecurse properly.
  99+
 100+2013-09-12  Paul Smith  <psmith@gnu.org>
 101+
 102+	* scripts/features/output-sync: Modify for output sync behavior.
 103+	* scripts/variables/MAKE_RESTARTS: Ditto.
 104+	* scripts/variables/MAKEFLAGS: Remove mode for --trace.
 105+	* scripts/variables/GNUMAKEFLAGS: Ditto.
 106+
 107+2013-07-22  Paul Smith  <psmith@gnu.org>
 108+
 109+	* scripts/features/rule_glob: Add tests for wildcards in rules.
 110+	Test for Savannah bug #39310.
 111+
 112+2013-07-09  Paul Smith  <psmith@gnu.org>
 113+
 114+	* scripts/features/se_implicit: Add a test for SE rules depending
 115+	on other SE rules to be built.
 116+
 117+2013-05-26  Paul Smith  <psmith@gnu.org>
 118+
 119+	* scripts/features/archives: Test for Savannah bug #38442.
 120+
 121+	* scripts/misc/bs-nl: Test for Savannah bug #39035.
 122+	Add a test for Savannah bug #38945.
 123+
 124+2013-05-22  Paul Smith  <psmith@gnu.org>
 125+
 126+	* scripts/options/dash-n: Fix results after MAKEFLAGS fixes.
 127+	* scripts/variables/MAKEFLAGS: Ditto.
 128+	* scripts/variables/GNUMAKEFLAGS: Ditto.
 129+
 130+2013-05-14  Paul Smith  <psmith@gnu.org>
 131+
 132+	* scripts/features/loadapi: Add plugin_is_GPL_compatible symbol.
 133+	* scripts/features/load: Ditto.
 134+
 135+2013-05-13  Paul Smith  <psmith@gnu.org>
 136+
 137+	* scripts/features/output-sync (output_sync_set): Update for new
 138+	--trace behavior.
 139+
 140+2013-05-05  Paul Smith  <psmith@gnu.org>
 141+
 142+	* scripts/features/output-sync (output_sync_set): Remove
 143+	extraneous enter/leave lines, which are no longer printed.
 144+	Add tests for syncing command line printing.
 145+	(output_sync_set): Rename options: "job"->"line"; "make"->"recurse"
 146+
 147+2013-05-04  Paul Smith  <psmith@gnu.org>
 148+
 149+	* scripts/features/loadapi: Use the new alloc functions.
 150+
 151+	* scripts/features/output-sync (output_sync_set): New test for
 152+	ordered recursive output for -Ojob / -Otarget.
 153+
 154+2013-05-03  Eli Zaretskii  <eliz@gnu.org>
 155+
 156+	* scripts/features/load: Fix signatures of testload_gmk_setup and
 157+	explicit_setup, to bring them in line with the documentation.
 158+
 159+2013-04-28  Paul Smith  <psmith@gnu.org>
 160+
 161+	* scripts/features/output-sync (output_sync_set): Add tests for
 162+	the per-job syntax mode.
 163+	(output_sync_set): Test improved error message location.
 164+
 165+2013-04-15  Paul Smith  <psmith@gnu.org>
 166+
 167+	* scripts/features/output-sync (output_sync_set): New arg syntax.
 168+
 169+2013-04-14  Paul Smith  <psmith@gnu.org>
 170+
 171+	* scripts/features/output-sync: Rewrite to be more reliable.
 172+
 173+	* test_driver.pl (_run_command): Don't set SIGALRM until after we
 174+	start the child.  Print errors to the top-level output, which will
 175+	be stderr.
 176+	(attach_default_output): Use a list of file handles as the stack.
 177+	(detach_default_output): Ditto.
 178+
 179+	* scripts/features/output-sync: Add a test for output-sync.
 180+
 181+2013-02-25  Paul Smith  <psmith@gnu.org>
 182+
 183+	* run_make_tests.pl (valid_option): Support the -srcdir flag.
 184+	(set_more_defaults): Set up $srcdir if it's not set yet.
 185+
 186+	* scripts/functions/guile: Verify gmk-eval doesn't expand twice.
 187+	* scripts/features/load: Rework to test just the load capability.
 188+	* scripts/features/loadapi: New set of tests for the load API.
 189+
 190+2013-01-19  Paul Smith  <psmith@gnu.org>
 191+
 192+	* scripts/features/load: Test loaded files with and without "./"
 193+	prefix.  Add tests for automatically rebuilding loaded files if
 194+	they are out of date or non-existent.
 195+
 196+2013-01-13  Paul Smith  <psmith@gnu.org>
 197+
 198+	* scripts/features/archives: Add a check targets that have parens,
 199+	but are not archives.  See Savannah bug #37878.
 200+
 201+	* scripts/options/dash-n: Verify -n is preserved after recursive /
 202+	re-exec.  See Savannah bug #38051.
 203+
 204+2013-01-12  Paul Smith  <psmith@gnu.org>
 205+
 206+	* scripts/features/parallelism: Change rule so it doesn't depend
 207+	on invocation order, etc.
 208+
 209+2012-10-29  Paul Smith  <psmith@gnu.org>
 210+
 211+	* scripts/features/load: New test suite for the "load" directive.
 212+
 213+2012-09-09  Paul Smith  <psmith@gnu.org>
 214+
 215+	* scripts/functions/file: Get errors in the C locale, not the
 216+	current locale.  Fixes Savannah bug #35764.
 217+
 218+	* scripts/features/escape: Check that backslashes before
 219+	non-special characters are not removed.
 220+
 221+	* scripts/features/utf8: New test for UTF-8 support.
 222+	See Savannah bug #36529.
 223+
 224+	* scripts/targets/POSIX: Add tests for default macro values as
 225+	specified by IEEE Std 1003.1-2008.  See Savannah bug #37069.
 226+
 227+2012-03-04  Paul Smith  <psmith@gnu.org>
 228+
 229+	* scripts/features/se_explicit: Test $(x:%=%) format in secondary
 230+	expansion prerequisite lists.  See Savannah bug #16545.
 231+
 232+	* scripts/features/escape: Test escaped ":" in prerequisite lists.
 233+	See Savannah bug #12126.
 234+
 235+	* scripts/variables/private: Test appending private variables in
 236+	pattern-specific target rules.  See Savannah bug #35468.
 237+
 238+2012-03-03  Paul Smith  <psmith@gnu.org>
 239+
 240+	* scripts/variables/SHELL: Ensure .SHELLFLAGS works with options
 241+	separated by whitespace.
 242+
 243+	* scripts/targets/ONESHELL: Try .ONESHELL in combination with
 244+	whitespace-separated options in .SHELLFLAGS.  See Savannah bug #35397.
 245+
 246+	* scripts/functions/filter-out: Add filter tests and test escape
 247+	operations.  See Savannah bug #35410.
 248+
 249+	* guile.supp: Suppress valgrind errors from Guile
 250+	* run_make_tests.pl: Use the Guile suppression file.
 251+
 252+	* scripts/misc/bs-nl: Check for POSIX and non-POSIX
 253+	backslash/newline handling.  Addresses Savannah bug #16670.
 254+
 255+2012-01-29  Paul Smith  <psmith@gnu.org>
 256+
 257+	* scripts/variables/flavors: Add tests for ::=
 258+	* scripts/variables/define: Ditto
 259+
 260+	* scripts/functions/file: Test the new $(file ...) function.
 261+
 262+2012-01-12  Paul Smith  <psmith@gnu.org>
 263+
 264+	* scripts/functions/guile: New regression tests for Guile support.
 265+
 266+2011-12-10  Paul Smith  <psmith@gnu.org>
 267+
 268+	* scripts/targets/SECONDARY: Add prereq statements to ensure rules
 269+	are printed in the right order for test #9
 270+
 271+2011-11-14  Paul Smith  <psmith@gnu.org>
 272+
 273+	* scripts/features/double_colon: Check double-colon with escaped
 274+	filenames.  See Savannah bug #33399.
 275+
 276+2011-09-18  Paul Smith  <psmith@gnu.org>
 277+
 278+	* scripts/features/parallelism: On re-exec make sure we preserve
 279+	the value of MAKEFLAGS when necessary.  See Savannah bug #33873.
 280+
 281+	* scripts/features/vpath3: Verify handling of -lfoo libraries
 282+	found via vpath vs. the standard directory search.
 283+	See Savannah bug #32511.
 284+
 285+2011-09-12  Paul Smith  <psmith@gnu.org>
 286+
 287+	* scripts/functions/call: Verify that using export in a $(call ...)
 288+	context creates a global variable.  See Savannah bug #32498.
 289+
 290+2011-09-02  Paul Smith  <psmith@gnu.org>
 291+
 292+	* scripts/options/dash-n: Verify that in "-n -t", the -n takes
 293+	priority.  Patch from Michael Witten <mfwitten@gmail.com>.
 294+
 295+2011-08-29  Paul Smith  <psmith@gnu.org>
 296+
 297+	* scripts/features/varnesting: Test resetting of variables while
 298+	expanding them.  See Savannah patch #7534
 299+
 300+2011-06-12  Paul Smith  <psmith@gnu.org>
 301+
 302+	* scripts/features/archives: Check archives with whitespace at the
 303+	beginning, end, and extra in the middle.
 304+	Another test for Savannah bug #30612.
 305+
 306+2011-05-07  Paul Smith  <psmith@gnu.org>
 307+
 308+	* scripts/variables/private: Ensure we skip private variables when
 309+	appending.  Test for Savannah bug #32872.
 310+
 311+	* scripts/functions/wildcard: Verify wildcard used to test for
 312+	file existence/non-existence.
 313+
 314+2011-05-02  Paul Smith  <psmith@gnu.org>
 315+
 316+	* scripts/functions/sort: Add a test for Savannah bug #33125.
 317+
 318+2011-04-17  David A. Wheeler  <dwheeler@dwheeler.com>
 319+
 320+	* scripts/features/shell_assignment: Regression for "!=" feature
 321+
 322+2010-11-06  Paul Smith  <psmith@gnu.org>
 323+
 324+	* scripts/features/targetvars: Fix known-good output for BS/NL changes.
 325+	* scripts/functions/call: Ditto.
 326+	* scripts/variables/special: Ditto.
 327+
 328+	* scripts/misc/bs-nl: New test suite for backslash/newline testing.
 329+
 330+2010-08-29  Paul Smith  <psmith@gnu.org>
 331+
 332+	* scripts/features/errors: Add new error message to output text.
 333+	* scripts/variables/SHELL: Ditto.
 334+	* scripts/targets/POSIX: Ditto.
 335+	* scripts/options/dash-k: Ditto.
 336+	* scripts/features/vpathplus: Ditto.
 337+	* scripts/features/patternrules: Ditto.
 338+	* scripts/features/parallelism: Ditto.
 339+
 340+2010-08-13  Paul Smith  <psmith@gnu.org>
 341+
 342+	* scripts/features/archives: New regression tests for archive
 343+	support.  Test for fix to Savannah bug #30612.
 344+
 345+	* run_make_tests.pl (set_more_defaults): Set a %FEATURES hash to
 346+	the features available in $(.FEATURES).
 347+
 348+2010-08-10  Paul Smith  <psmith@gnu.org>
 349+
 350+	* scripts/features/reinvoke: Ensure command line variable settings
 351+	are preserved across make re-exec.  Tests Savannah bug #30723.
 352+
 353+2010-07-28  Paul Smith  <psmith@gnu.org>
 354+
 355+	* scripts/targets/POSIX: Compatibility issues with Solaris (and
 356+	Tru64?); "false" returns different exit codes, and set -x shows
 357+	output with extra whitespace.  Run the commands by hand first to
 358+	find out what the real shell would do, then compare what make does.
 359+	* scripts/variables/SHELL: Ditto.
 360+
 361+2010-07-12  Paul Smith  <psmith@gnu.org>
 362+
 363+	* test_driver.pl: Add a new $perl_name containing the path to Perl.
 364+	* run_make_tests.pl (run_make_test): Replace the special string
 365+	#PERL# in a makefile etc. with the path the Perl executable so
 366+	makefiles can use it.
 367+
 368+	* scripts/targets/ONESHELL: Add a new set of regression tests for
 369+	the .ONESHELL feature.
 370+
 371+2010-07-06  Paul Smith  <psmith@gnu.org>
 372+
 373+	* scripts/variables/SHELL: Test the new .SHELLFLAGS variable.
 374+
 375+	* scripts/targets/POSIX: New file.  Test the .POSIX special target.
 376+	Verify that enabling .POSIX changes the shell flags to set -e.
 377+
 378+2010-07-01  Paul Smith  <psmith@gnu.org>
 379+
 380+	* scripts/features/recursion: Add a space to separate command-line
 381+	args.  Fixes Savannah bug #29968.
 382+
 383+2009-11-12  Boris Kolpackov  <boris@codesynthesis.com>
 384+
 385+	* scripts/features/vpath3: Test for the new library search
 386+	behavior.
 387+
 388+2009-10-06  Boris Kolpackov  <boris@codesynthesis.com>
 389+
 390+	* scripts/features/se_explicit: Enable the test for now fixed
 391+	Savannah bug 25780.
 392+
 393+2009-10-06  Boris Kolpackov  <boris@codesynthesis.com>
 394+
 395+	* scripts/variables/undefine: Tests for the new undefine feature.
 396+
 397+2009-10-03  Paul Smith  <psmith@gnu.org>
 398+
 399+	* scripts/features/parallelism: Test for open Savannah bug #26846.
 400+
 401+	* scripts/variables/MAKE: Rewrite for new run_make_test() format.
 402+
 403+	* scripts/variables/MAKEFLAGS: Created.
 404+	Add test for Savannah bug #2216 (still open).
 405+
 406+	* scripts/features/include: Test for Savannah bug #102 (still open).
 407+
 408+2009-09-30  Boris Kolpackov  <boris@codesynthesis.com>
 409+
 410+	* scripts/features/include: Add diagnostics issuing tests for
 411+	cases where targets have been updated and failed with the
 412+	dontcare flag. Savannah bugs #15110, #25493, #12686, #17740.
 413+
 414+2009-09-28  Paul Smith  <psmith@gnu.org>
 415+
 416+	* scripts/functions/shell: Add regression test for Savannah bug
 417+	#20513 (still open).
 418+
 419+	* scripts/features/se_explicit: Add regression tests for Savannah
 420+	bug #25780 (still open).
 421+
 422+	* run_make_tests.pl (valid_option): Add a new flag, -all([-_]?tests)?
 423+	that runs tests we know will fail.  This allows us to add
 424+	regression tests to the test suite for bugs that haven't been
 425+	fixed yet.
 426+
 427+2009-09-28  Boris Kolpackov  <boris@codesynthesis.com>
 428+
 429+	* scripts/features/patspecific_vars: Add a test for the shortest
 430+	stem first order.
 431+
 432+	* scripts/features/patternrules: Add a test for the shortest stem
 433+	first order.
 434+
 435+2009-09-24  Paul Smith  <psmith@gnu.org>
 436+
 437+	* scripts/features/se_implicit: Add a test for order-only
 438+	secondary expansion prerequisites.
 439+
 440+2009-09-23  Paul Smith  <psmith@gnu.org>
 441+
 442+	* scripts/features/patternrules: Test that we can remove pattern
 443+	rules, both single and multiple prerequisites.  Savannah bug #18622.
 444+
 445+	* scripts/features/echoing: Rework for run_make_test().
 446+
 447+2009-06-14  Paul Smith  <psmith@gnu.org>
 448+
 449+	* scripts/features/vpath: Verify we don't get bogus circular
 450+	dependency warnings if we choose a different file via vpath during
 451+	update.  Savannah bug #13529.
 452+
 453+2009-06-13  Paul Smith  <psmith@gnu.org>
 454+
 455+	* scripts/variables/MAKEFILES: Verify that MAKEFILES included
 456+	files (and files included by them) don't set the default goal.
 457+	Savannah bug #13401.
 458+
 459+	* scripts/functions/wildcard: Test that wildcards with
 460+	non-existent glob matchers return empty.
 461+
 462+2009-06-09  Paul Smith  <psmith@gnu.org>
 463+
 464+	* scripts/options/dash-B: Test the $? works correctly with -B.
 465+	Savannah bug #17825.
 466+
 467+	* scripts/features/patternrules: Test that dependencies of
 468+	"also_make" targets are created properly.  Savannah bug #19108.
 469+
 470+	* test_driver.pl (compare_output): Create a "run" file for failed
 471+	tests containing the command that was run.
 472+	(get_runfile): New function.
 473+
 474+	* run_make_tests.pl (valid_option): Enhanced support for valgrind:
 475+	allow memcheck and massif tools.
 476+
 477+	* scripts/features/patternrules: Have to comment out a line in the
 478+	first test due to backing out a change that broke the implicit
 479+	rule search algorithm.  Savannah bug #17752.
 480+	* scripts/misc/general4: Remove a test that is redundant with
 481+	patternrules.
 482+
 483+	* scripts/features/parallelism: Add a test for re-exec with
 484+	jobserver master override.  Savannah bug #18124.
 485+
 486+2009-06-08  Paul Smith  <psmith@gnu.org>
 487+
 488+	* scripts/features/targetvars: Add a test for continued target
 489+	vars after a semicolon.  Savannah bug #17521.
 490+
 491+2009-06-07  Paul Smith  <psmith@gnu.org>
 492+
 493+	* scripts/features/se_explicit: Make sure we catch defining
 494+	prereqs during snap_deps().  Savannah bug #24622.
 495+
 496+	* scripts/variables/automatic: Check prereq ordering when the
 497+	target with the recipe has no prereqs.  Savannah bug #21198.
 498+
 499+	* scripts/variables/LIBPATTERNS: Add a new set of test for
 500+	$(.LIBPATTERNS) (previously untested!)
 501+
 502+2009-06-04  Paul Smith  <psmith@gnu.org>
 503+
 504+	* scripts/variables/SHELL: The export target-specific SHELL test
 505+	has an incorrect known-good-value.
 506+
 507+	* scripts/misc/general4: Check for whitespace (ffeed, vtab, etc.)
 508+
 509+	* scripts/features/se_explicit: Add tests for Savannah bug #24588.
 510+
 511+2009-05-31  Paul Smith  <psmith@gnu.org>
 512+
 513+	* scripts/variables/DEFAULT_GOAL: Add tests for Savannah bug #25697.
 514+
 515+	* scripts/features/targetvars: Add tests of overrides for Savannah
 516+	bug #26207.
 517+	* scripts/features/patspecific_vars: Ditto.
 518+
 519+	* scripts/features/patternrules: Add a test for Savannah bug #26593.
 520+
 521+2009-05-30  Paul Smith  <psmith@gnu.org>
 522+
 523+	* scripts/variables/flavors: Update with new variable flavor tests.
 524+	* scripts/variables/define: Create a new set of tests for
 525+	define/endef and move those aspects of the flavors suite here.
 526+
 527+2009-05-25  Paul Smith  <psmith@gnu.org>
 528+
 529+	* scripts/features/targetvars: Ditto.
 530+
 531+	* scripts/features/export: Test new variable parsing abilities.
 532+
 533+2009-02-23  Ramon Garcia  <ramon.garcia.f@gmail.com>
 534+
 535+	* scripts/variables/private: Create a new suite of tests for 'private'.
 536+
 537+2007-11-04  Paul Smith  <psmith@gnu.org>
 538+
 539+	* scripts/functions/eval: Update error message for command -> recipe.
 540+
 541+	* test_driver.pl (compare_output): Allow the answer to be a regex,
 542+	if surrounded by '/'.
 543+	* scripts/misc/close_stdout: Use a regex for the answer, since
 544+	sometimes the error will have a description and sometimes it won't.
 545+
 546+2007-09-10  Paul Smith  <psmith@gnu.org>
 547+
 548+	* scripts/variables/special: Add tests for .RECIPEPREFIX variable.
 549+
 550+2007-08-15  Paul Smith  <psmith@gnu.org>
 551+
 552+	These test cases were contributed by
 553+	Icarus Sparry <savannah@icarus.freeuk.com> and J. David Bryan for
 554+	Savannah bugs #3330 and #15919.
 555+
 556+	* scripts/targets/SECONDARY: Add tests for Savannah bugs 3330 and
 557+	15919.
 558+
 559+	* scripts/features/parallelism: Add tests for wrong answer/hang
 560+	combining INTERMEDIATE, order-only prereqs, and parallelism.
 561+	See Savannah bugs 3330 and 15919.
 562+
 563+2007-07-13  Paul Smith  <psmith@gnu.org>
 564+
 565+	Install a timeout so tests can never loop infinitely.
 566+	Original idea and patch for a single-test version provided by
 567+	Icarus Sparry <savannah@icarus.freeuk.com>
 568+
 569+	* test_driver.pl (_run_command): New function: this is called by
 570+	other functions to actually run a command.  Before we run it,
 571+	install a SIGALRM handler and set up a timer to go off in the
 572+	future (default is 5s; this can be overridden by individual tests).
 573+	(run_command): Call it.
 574+	(run_command_with_output): Call it.
 575+
 576+	* run_make_tests.pl (run_make_with_options): Override the default
 577+	timeout if the caller requests it.
 578+	(run_make_test): Pass any timeout override to run_make_with_options.
 579+
 580+	* scripts/features/parallelism: Increase the timeout for long tests.
 581+	* scripts/options/dash-l: Ditto.
 582+
 583+2006-10-01  Paul Smith  <psmith@paulandlesley.org>
 584+
 585+	* run_make_tests.pl (set_more_defaults): Remove setting of LANG in
 586+	ENV here.  This doesn't always work.
 587+	* test_driver.pl (toplevel): Set LC_ALL to 'C' in the make
 588+	environment.  Fixes Savannah bug #16698.
 589+
 590+2006-09-30  Paul Smith  <psmith@paulandlesley.org>
 591+
 592+	* scripts/variables/automatic: Add back the test for bug #8154.
 593+
 594+2006-04-01  Paul D. Smith  <psmith@gnu.org>
 595+
 596+	* scripts/functions/realpath: Don't run tests with multiple
 597+	initial slashes on Windows: those paths mean something different.
 598+
 599+2006-03-19  Paul D. Smith  <psmith@gnu.org>
 600+
 601+	* scripts/features/parallelism: Test that the jobserver is
 602+	properly managed when we have to re-exec the master instance of
 603+	make.
 604+
 605+2006-03-17  Boris Kolpackov  <boris@kolpackov.net>
 606+
 607+	* scripts/features/statipattrules: Add tests for bug #16053.
 608+
 609+2006-03-09  Paul Smith  <psmith@gnu.org>
 610+
 611+	* scripts/features/escape: Use "pre:" not "p:" to avoid conflicts
 612+	with DOS drive letters.  Fixes Savannah bug #15947.
 613+
 614+	* test_driver.pl (run_each_test): Set the status properly even
 615+	when a test fails to execute.  Fixes Savannah bug #15942.
 616+
 617+	* scripts/functions/foreach: Use a different environment variable
 618+	other than PATH to avoid differences with Windows platforms.
 619+	Fixes Savannah bug #15938.
 620+
 621+2006-03-05  Paul D. Smith  <psmith@gnu.org>
 622+
 623+	* run_make_tests.pl (set_more_defaults): Add CYGWIN_NT as a port
 624+	type W32.  Fixed Savannah bug #15937.
 625+
 626+	* scripts/features/default_names: Don't call error() when the test
 627+	fails.  Fixes Savannah bug #15941.
 628+
 629+2006-02-17  Paul D. Smith  <psmith@gnu.org>
 630+
 631+	* scripts/features/targetvars: Test a complex construction which
 632+	guarantees that we have to merge variable lists of different
 633+	sizes.  Tests for Savannah bug #15757.
 634+
 635+2006-02-15  Paul D. Smith  <psmith@gnu.org>
 636+
 637+	* scripts/functions/error: Make sure filename/lineno information
 638+	is related to where the error is expanded, not where it's set.
 639+	* scripts/functions/warning: Ditto.
 640+	* scripts/functions/foreach: Check for different error conditions.
 641+	* scripts/functions/word: Ditto.
 642+	* scripts/variables/negative: Test some variable reference failure
 643+	conditions.
 644+	* scripts/options/warn-undefined-variables: Test the
 645+	--warn-undefined-variables flag.
 646+
 647+2006-02-09  Paul D. Smith  <psmith@gnu.org>
 648+
 649+	* run_make_tests.pl (set_more_defaults): Update valgrind support
 650+	for newer versions.
 651+	* test_driver.pl (toplevel): Skip all hidden files/directories (ones
 652+	beginning with ".").
 653+
 654+	* scripts/functions/andor: Tests for $(and ...) and $(or ...)
 655+	functions.
 656+
 657+2006-02-08  Boris Kolpackov  <boris@kolpackov.net>
 658+
 659+	* scripts/features/parallelism: Add a test for bug #15641.
 660+
 661+2006-02-06  Paul D. Smith  <psmith@gnu.org>
 662+
 663+	* scripts/options/dash-W: Add a test for bug #15341.
 664+
 665+2006-01-03  Paul D. Smith  <psmith@gnu.org>
 666+
 667+	* scripts/variables/automatic: Add a test for bug #8154.
 668+
 669+	* README: Update to reflect the current state of the test suite.
 670+
 671+2005-12-12  Paul D. Smith  <psmith@gnu.org>
 672+
 673+	* scripts/features/parallelism, scripts/functions/wildcard,
 674+	scripts/targets/FORCE, scripts/targets/PHONY,
 675+	scripts/targets/SILENT: Use the default setting for
 676+	$delete_command.  Fixes bug #15085.
 677+
 678+	* run_make_tests.pl (get_this_pwd) [VMS]: Use -no_ask with delete_file.
 679+
 680+2005-12-11  Paul D. Smith  <psmith@gnu.org>
 681+
 682+	* scripts/misc/general4: Test implicit rules with '$' in the
 683+	prereq list & prereq patterns.
 684+	* scripts/features/se_implicit: Add in .SECONDEXPANSION settings.
 685+
 686+2005-12-09  Boris Kolpackov  <boris@kolpackov.net>
 687+
 688+	* scripts/features/patternrules: Add a test for bug #13022.
 689+
 690+2005-12-07  Boris Kolpackov  <boris@kolpackov.net>
 691+
 692+	* scripts/features/double_colon: Add a test for bug #14334.
 693+
 694+2005-11-17  Boris Kolpackov  <boris@kolpackov.net>
 695+
 696+	* scripts/functions/flavor: Add a test for the flavor function.
 697+
 698+2005-11-14  Boris Kolpackov  <boris@kolpackov.net>
 699+
 700+	* scripts/variables/INCLUDE_DIRS: Add a test for the .INCLUDE_DIRS
 701+	special variable.
 702+
 703+2005-10-24  Paul D. Smith  <psmith@gnu.org>
 704+
 705+	* scripts/misc/general4: Test '$$' in prerequisites list.
 706+	* scripts/features/statipattrules: Rewrite to use run_make_test().
 707+	Add various static pattern info.
 708+	* scripts/features/se_statpat: Enable .SECONDEXPANSION target.
 709+	* scripts/features/se_explicit: Add tests for handling '$$' in
 710+	prerequisite lists with and without setting .SECONDEXPANSION.
 711+	* scripts/features/order_only: Convert to run_make_test().
 712+	* run_make_tests.pl (set_more_defaults): If we can't get the value
 713+	of $(MAKE) from make, then fatal immediately.
 714+
 715+2005-08-31  Paul D. Smith  <psmith@gnu.org>
 716+
 717+	* run_make_tests.pl (get_this_pwd): Require the POSIX module (in
 718+	an eval to trap errors) and if it exists, use POSIX::getcwd to
 719+	find the working directory.  If it doesn't exist, go back to the
 720+	previous methods.  This tries to be more accurate on Windows
 721+	systems.
 722+
 723+2005-08-29  Paul D. Smith  <psmith@gnu.org>
 724+
 725+	* scripts/functions/abspath: Add some text to the error messages
 726+	to get a better idea of what's wrong.  Make warnings instead of
 727+	errors.
 728+
 729+	* scripts/features/patspecific_vars: Don't use "test", which is
 730+	UNIX specific.  Print the values and let the test script match
 731+	them.
 732+
 733+2005-08-25  Paul Smith  <psmith@gnu.org>
 734+
 735+	* scripts/variables/SHELL: Use a /./ prefix instead of //: the
 736+	former works better with non-UNIX environments.  Fixes Savannah
 737+	bug #14129.
 738+
 739+2005-08-13  Boris Kolpackov  <boris@kolpackov.net>
 740+
 741+	* scripts/functions/wildcard: Wrap calls to $(wildcard) with
 742+	$(sort) so that the resulting order is no longer filesystem-
 743+	dependent.
 744+
 745+2005-08-10  Boris Kolpackov  <boris@kolpackov.net>
 746+
 747+	* scripts/features/statipattrules: Add a test for Savannah bug #13881.
 748+
 749+2005-08-07  Paul D. Smith  <psmith@gnu.org>
 750+
 751+	* scripts/features/parallelism: Add a test for a bug reported by
 752+	Michael Matz (matz@suse.de) in which make exits without waiting
 753+	for all its children in some situations during parallel builds.
 754+
 755+2005-07-08  Paul D. Smith  <psmith@gnu.org>
 756+
 757+	* test_driver.pl: Reset the environment to a clean value every
 758+	time before we invoke make.  I'm suspicious that the environment
 759+	isn't handled the same way in Windows as it is in UNIX, and some
 760+	variables are leaking out beyond the tests they are intended for.
 761+	Create an %extraENV hash tests can set to add more env. vars.
 762+	* tests/scripts/features/export: Change to use %extraENV.
 763+	* tests/scripts/functions/eval: Ditto.
 764+	* tests/scripts/functions/origin: Ditto.
 765+	* tests/scripts/options/dash-e: Ditto.
 766+	* tests/scripts/variables/SHELL: Ditto.
 767+
 768+2005-06-27  Paul D. Smith  <psmith@gnu.org>
 769+
 770+	* scripts/options/dash-W: Use 'echo >>' instead of touch to update
 771+	files.
 772+	* scripts/features/reinvoke: Rewrite to be safer on systems with
 773+	subsecond timestamps.
 774+	* scripts/features/patternrules: False exits with different error
 775+	codes on different systems (for example, Linux => 1, Solaris => 255).
 776+
 777+	* scripts/options/dash-W: Set the timestamp to foo.x in the future,
 778+	to be sure it will be considered updated when it's remade.
 779+
 780+2005-06-26  Paul D. Smith  <psmith@gnu.org>
 781+
 782+	* scripts/functions/shell: New test suite for the shell function.
 783+
 784+2005-06-25  Paul D. Smith  <psmith@gnu.org>
 785+
 786+	* scripts/features/include: Test include/-include/sinclude with no
 787+	arguments.  Tests fix for Savannah bug #1761.
 788+
 789+	* scripts/misc/general3: Implement comprehensive testing of
 790+	backslash-newline behavior in command scripts: various types of
 791+	quoting, fast path / slow path, etc.
 792+	Tests fix for Savannah bug #1332.
 793+
 794+	* scripts/options/symlinks: Test symlinks to non-existent files.
 795+	Tests fix for Savannah bug #13280.
 796+
 797+	* scripts/misc/general3: Test semicolons in variable references.
 798+	Tests fix for Savannah bug #1454.
 799+
 800+	* scripts/variables/MAKE_RESTARTS: New file: test the
 801+	MAKE_RESTARTS variable.
 802+	* scripts/options/dash-B: Test re-exec doesn't loop infinitely.
 803+	Tests fix for Savannah bug #7566.
 804+	* scripts/options/dash-W: New file: test the -W flag, including
 805+	re-exec infinite looping.
 806+
 807+2005-06-12  Paul D. Smith  <psmith@gnu.org>
 808+
 809+	* scripts/misc/close_stdout: Add a test for Savannah bug #1328.
 810+	This test only works on systems that have /dev/full (e.g., Linux).
 811+
 812+2005-06-09  Paul D. Smith  <psmith@gnu.org>
 813+
 814+	* scripts/functions/foreach: Add a test for Savannah bug #11913.
 815+
 816+2005-05-31  Boris Kolpackov  <boris@kolpackov.net>
 817+
 818+	* scripts/features/include: Add a test for Savannah bug #13216.
 819+	* scripts/features/patternrules: Add a test for Savannah bug #13218.
 820+
 821+2005-05-13  Paul D. Smith  <psmith@gnu.org>
 822+
 823+	* scripts/features/conditionals: Add tests for the new if... else
 824+	if... endif syntax.
 825+
 826+2005-05-03  Paul D. Smith  <psmith@gnu.org>
 827+
 828+	* scripts/variables/DEFAULT_GOAL: Rename DEFAULT_TARGET to
 829+	DEFAULT_GOAL.
 830+
 831+2005-05-02  Paul D. Smith  <psmith@gnu.org>
 832+
 833+	* scripts/features/parallelism: Add a test for exporting recursive
 834+	variables containing $(shell) calls.  Rewrite this script to use
 835+	run_make_test() everywhere.
 836+
 837+2005-04-07  Paul D. Smith  <psmith@gnu.org>
 838+
 839+	* scripts/targets/SECONDARY: Add a test for Savannah bug #12331.
 840+
 841+2005-03-15  Boris Kolpackov  <boris@kolpackov.net>
 842+
 843+	* scripts/variables/automatic: Add a test for Savannah bug #12320.
 844+
 845+2005-03-10  Boris Kolpackov  <boris@kolpackov.net>
 846+
 847+	* scripts/features/patternrules: Add a test for Savannah bug #12267.
 848+
 849+2005-03-09  Boris Kolpackov  <boris@kolpackov.net>
 850+
 851+	* scripts/variables/DEFAULT_TARGET: Add a test for Savannah
 852+	bug #12266.
 853+
 854+2005-03-04  Boris Kolpackov  <boris@kolpackov.net>
 855+
 856+	* scripts/features/patternrules: Add a test for Savannah bug #12202.
 857+
 858+2005-03-03  Boris Kolpackov  <boris@kolpackov.net>
 859+
 860+	* scripts/features/se_implicit: Add a test for stem
 861+	termination bug. Add a test for stem triple-expansion bug.
 862+
 863+	* scripts/features/se_statpat: Add a test for stem
 864+	triple-expansion bug.
 865+
 866+	* scripts/features/statipattrules: Change test #4 to reflect
 867+	new way empty prerequisite list is handled.
 868+
 869+
 870+2005-03-01  Boris Kolpackov  <boris@kolpackov.net>
 871+
 872+	* scripts/features/statipattrules: Add a test for
 873+	Savannah bug #12180.
 874+
 875+2005-02-28  Paul D. Smith  <psmith@gnu.org>
 876+
 877+	* scripts/options/dash-q: Add a test for Savannah bug # 7144.
 878+
 879+	* scripts/options/symlinks: New file to test checking of symlink
 880+	timestamps.  Can't use filename dash-L because it conflicts with
 881+	dash-l on case-insensitive filesystems.
 882+
 883+	* scripts/variables/MAKEFILE_LIST, scripts/variables/MFILE_LIST:
 884+	Rename MAKEFILE_LIST test to MFILE_LIST, for systems that need 8.3
 885+	unique filenames.
 886+
 887+2005-02-28  Boris Kolpackov  <boris@kolpackov.net>
 888+
 889+	* scripts/variables/DEFAULT_TARGET: Test the .DEFAULT_TARGET
 890+	special variable.
 891+
 892+2005-02-27  Boris Kolpackov  <boris@kolpackov.net>
 893+
 894+	* scripts/features/se_explicit: Test the second expansion in
 895+	explicit rules.
 896+	* scripts/features/se_implicit: Test the second expansion in
 897+	implicit rules.
 898+	* scripts/features/se_statpat: Test the second expansion in
 899+	static pattern rules.
 900+	* scripts/variables/automatic: Fix to work with the second
 901+	expansion.
 902+
 903+	* scripts/misc/general4: Add a test for bug #12091.
 904+
 905+2005-02-27  Paul D. Smith  <psmith@gnu.org>
 906+
 907+	* scripts/functions/eval: Check that eval of targets within
 908+	command scripts fails.  See Savannah bug # 12124.
 909+
 910+2005-02-26  Paul D. Smith  <psmith@gnu.org>
 911+
 912+	* test_driver.pl (compare_output): If a basic comparison of the
 913+	log and answer doesn't match, try harder: change all backslashes
 914+	to slashes and all CRLF to LF.  This helps on DOS/Windows systems.
 915+
 916+2005-02-09  Paul D. Smith  <psmith@gnu.org>
 917+
 918+	* scripts/features/recursion: Test command line variable settings:
 919+	only one instance of a given variable should be provided.
 920+
 921+2004-11-30  Boris Kolpackov  <boris@kolpackov.net>
 922+
 923+	* tests/scripts/functions/abspath: New file: test `abspath'
 924+	built-in function.
 925+
 926+	* tests/scripts/functions/realpath: New file: test `realpath'
 927+	built-in function.
 928+
 929+2004-11-28  Paul D. Smith  <psmith@gnu.org>
 930+
 931+	* scripts/options/dash-C [WINDOWS32]: Add a test for bug #10252;
 932+	this doesn't really test anything useful in UNIX but...
 933+
 934+	* scripts/variables/SHELL: New file: test proper handling of SHELL
 935+	according to POSIX rules.  Fixes bug #1276.
 936+
 937+2004-10-21  Boris Kolpackov  <boris@kolpackov.net>
 938+
 939+	* scripts/functions/word: Test $(firstword ) and $(lastword ).
 940+
 941+2004-10-05  Boris Kolpackov  <boris@kolpackov.net>
 942+
 943+	* scripts/features/patspecific_vars: Test simple/recursive
 944+	variable expansion.
 945+
 946+2004-09-28  Boris Kolpackov  <boris@kolpackov.net>
 947+
 948+	* scripts/features/include: Test dontcare flag inheritance
 949+	when rebuilding makefiles.
 950+
 951+2004-09-27  Boris Kolpackov  <boris@kolpackov.net>
 952+
 953+	* scripts/features/patspecific_vars: Test exported variables.
 954+
 955+2004-09-22  Paul D. Smith  <psmith@gnu.org>
 956+
 957+	* run_make_tests.pl (run_make_test): Don't add newlines to the
 958+	makestring or answer if they are completely empty.
 959+
 960+	* scripts/features/patternrules: Rename from implicit_prereq_eval.
 961+
 962+	* scripts/test_template: Rework the template.
 963+
 964+2004-09-21  Boris Kolpackov  <boris@kolpackov.net>
 965+
 966+	* run_make_tests.pl: Change `#!/usr/local/bin/perl' to be
 967+	`#!/usr/bin/env perl'.
 968+
 969+	* scripts/features/implicit_prereq_eval: Test implicit rule
 970+	prerequisite evaluation code.
 971+
 972+2004-09-21  Paul D. Smith  <psmith@gnu.org>
 973+
 974+	* run_make_tests.pl (run_make_test): Enhance to allow the make
 975+	string to be undef: in that case it reuses the previous make
 976+	string.  Allows multiple tests on the same makefile.
 977+
 978+	* scripts/variables/flavors: Add some tests for prefix characters
 979+	interacting with define/endef variables.
 980+
 981+2004-09-20  Paul D. Smith  <psmith@gnu.org>
 982+
 983+	* scripts/functions/substitution: Rewrite to use run_make_test()
 984+	interface, and add test for substitution failures reported by
 985+	Markus Mauhart <qwe123@chello.at>.
 986+
 987+2004-03-22  Paul D. Smith  <psmith@gnu.org>
 988+
 989+	* test_driver.pl (run_each_test, toplevel, compare_output): Change
 990+	to track both the testing categories _AND_ the number of
 991+	individual tests, and report both sets of numbers.
 992+
 993+2004-02-21  Paul D. Smith  <psmith@gnu.org>
 994+
 995+	* scripts/functions/origin: Set our own environment variable
 996+	rather than relying on $HOME.
 997+
 998+2004-01-21  Paul D. Smith  <psmith@gnu.org>
 999+
1000+	* scripts/features/conditionals: Test arguments to ifn?def which
1001+	contain whitespace (such as a function that is evaluated).  Bug
1002+	#7257.
1003+
1004+2004-01-07  Paul D. Smith  <psmith@gnu.org>
1005+
1006+	* scripts/features/order_only: Test order-only prerequisites in
1007+	pattern rules (patch #2349).
1008+
1009+2003-11-02  Paul D. Smith  <psmith@gnu.org>
1010+
1011+	* scripts/functions/if: Test if on conditionals with trailing
1012+	whitespace--bug #5798.
1013+
1014+	* scripts/functions/eval: Test eval in a non-file context--bug #6195.
1015+
1016+2003-04-19  Paul D. Smith  <psmith@gnu.org>
1017+
1018+	* scripts/features/patspecific_vars: Test multiple patterns
1019+	matching the same target--Bug #1405.
1020+
1021+2003-04-09  Paul D. Smith  <psmith@gnu.org>
1022+
1023+	* run_make_tests.pl (set_more_defaults): A new $port_type of
1024+	'OS/2' for (surprise!) OS/2.  Also choose a wait time of 2 seconds
1025+	for OS/2.
1026+
1027+2003-03-28  Paul D. Smith  <psmith@gnu.org>
1028+
1029+	* scripts/targets/SECONDARY: Test the "global" .SECONDARY (with
1030+	not prerequisites)--Bug #2515.
1031+
1032+2003-01-30  Paul D. Smith  <psmith@gnu.org>
1033+
1034+	* scripts/features/targetvars: Test very long target-specific
1035+	variable definition lines (longer than the default make buffer
1036+	length).  Tests patch # 1022.
1037+
1038+	* scripts/functions/eval: Test very recursive $(eval ...) calls
1039+	with simple variable expansion (bug #2238).
1040+
1041+	* scripts/functions/word: Test error handling for word and
1042+	wordlist functions (bug #2407).
1043+
1044+2003-01-22  Paul D. Smith  <psmith@gnu.org>
1045+
1046+	* scripts/functions/call: Test recursive argument masking (bug
1047+	#1744).
1048+
1049+2002-10-25  Paul D. Smith  <psmith@gnu.org>
1050+
1051+	* scripts/functions/eval: Test using $(eval ...) inside
1052+	conditionals (Bug #1516).
1053+
1054+2002-10-14  Paul D. Smith  <psmith@gnu.org>
1055+
1056+	* scripts/options/dash-t: Add a test for handling -t on targets
1057+	with no commands (Bug #1418).
1058+
1059+2002-10-13  Paul D. Smith  <psmith@gnu.org>
1060+
1061+	* scripts/features/targetvars: Add a test for exporting
1062+	target-specific vars (Bug #1391).
1063+
1064+2002-10-05  Paul D. Smith  <psmith@gnu.org>
1065+
1066+	* scripts/variables/automatic: Add tests for $$(@), $${@}, $${@D},
1067+	and $${@F}.
1068+
1069+2002-09-23  Paul D. Smith  <psmith@gnu.org>
1070+
1071+	* scripts/features/escape: Test handling of escaped comment
1072+	characters in targets and prerequisites.
1073+
1074+2002-09-18  Paul D. Smith  <psmith@gnu.org>
1075+
1076+	* scripts/features/export: Test export/unexport of multiple
1077+	variables in a single command.
1078+
1079+2002-09-17  Paul D. Smith  <psmith@gnu.org>
1080+
1081+	* scripts/features/targetvars: Tests for Bug #940: test
1082+	target-specific and pattern-specific variables in conjunction with
1083+	double-colon targets.
1084+
1085+2002-09-10  Paul D. Smith  <psmith@gnu.org>
1086+
1087+	* test_driver.pl (compare_output): Match the new format for time
1088+	skew error messages.
1089+
1090+	* scripts/features/export: Created.  Add tests for export/unexport
1091+	capabilities, including exporting/unexporting expanded variables.
1092+
1093+	* scripts/features/conditionals: Add a test for expanded variables
1094+	in ifdef conditionals.
1095+
1096+2002-09-04  Paul D. Smith  <psmith@gnu.org>
1097+
1098+	* scripts/features/reinvoke: Change touch/sleep combos to utouch
1099+	invocations.
1100+	* scripts/features/vpathgpath: Ditto.
1101+	* scripts/features/vpathplus: Ditto.
1102+	* scripts/options/dash-n: Ditto.
1103+	* scripts/targets/INTERMEDIATE: Ditto.
1104+	* scripts/targets/SECONDARY: Ditto.
1105+
1106+	* scripts/options/dash-t: Added a test for the -t bug fixed by
1107+	Henning Makholm.  This test was also contributed by Henning.
1108+
1109+	* scripts/misc/general4: Add a test suite for obscure algorithmic
1110+	features of make.  First test: make sure creation subdirectories
1111+	as prerequisites of targets works properly.
1112+
1113+	* scripts/misc/version: Remove this bogus test.
1114+
1115+2002-08-07  Paul D. Smith  <psmith@gnu.org>
1116+
1117+	* scripts/misc/general3: Add a test for makefiles that don't end
1118+	in newlines.
1119+
1120+	* scripts/variables/special: Create tests for the special
1121+	variables (.VARIABLES and .TARGETS).  Comment out .TARGETS test
1122+	for now as it's not yet supported.
1123+
1124+2002-08-01  Paul D. Smith  <psmith@gnu.org>
1125+
1126+	* scripts/options/dash-B: Add a test for the new -B option.
1127+
1128+2002-07-11  Paul D. Smith  <psmith@gnu.org>
1129+
1130+	* run_make_tests.pl (valid_option): Add support for Valgrind.  Use
1131+	-valgrind option to the test suite.
1132+	(set_more_defaults): Set up the file descriptor to capture
1133+	Valgrind output.  We have to unset its close-on-exec flag; we
1134+	hardcode the value for F_SETFD (2) rather than load it; hopefully
1135+	this will help us avoid breaking the Windows/DOS test suite.
1136+
1137+2002-07-10  Paul D. Smith  <psmith@gnu.org>
1138+
1139+	* scripts/variables/automatic: Add some tests for $$@, $$(@D), and
1140+	$$(@F).
1141+
1142+	* test_driver.pl (utouch): Create a new function that creates a
1143+	file with a specific timestamp offset.  Use of this function will
1144+	let us avoid lots of annoying sleep() invocations in the tests
1145+	just to get proper timestamping, which will make the tests run a
1146+	lot faster.  So far it's only used in the automatic test suite.
1147+
1148+2002-07-09  Paul D. Smith  <psmith@gnu.org>
1149+
1150+	* scripts/variables/automatic: Create a test for automatic variables.
1151+
1152+2002-07-08  Paul D. Smith  <psmith@gnu.org>
1153+
1154+	* scripts/features/order_only: Test new order-only prerequisites.
1155+
1156+2002-07-07  Paul D. Smith  <psmith@gnu.org>
1157+
1158+	* scripts/functions/eval: Test new function.
1159+	* scripts/functions/value: Test new function.
1160+	* scripts/variables/MAKEFILE_LIST: Test new variable.
1161+
1162+2002-04-28  Paul D. Smith  <psmith@gnu.org>
1163+
1164+	* scripts/functions/call: New test: transitive closure
1165+	implementation using $(call ...) to test variable recursion.
1166+
1167+2002-04-21  Paul D. Smith  <psmith@gnu.org>
1168+
1169+	* test_driver.pl (compare_dir_tree): Ignore CVS and RCS
1170+	directories in the script directories.
1171+
1172+2001-05-02  Paul D. Smith  <psmith@gnu.org>
1173+
1174+	* scripts/variables/flavors: Test define/endef scripts where only
1175+	one of the command lines is quiet.
1176+
1177+2000-06-22  Paul D. Smith  <psmith@gnu.org>
1178+
1179+	* scripts/options/dash-q: New file; test the -q option.  Includes
1180+	a test for PR/1780.
1181+
1182+2000-06-21  Paul D. Smith  <psmith@gnu.org>
1183+
1184+	* scripts/features/targetvars: Added a test for PR/1709: allowing
1185+	semicolons in target-specific variable values.
1186+
1187+2000-06-19  Paul D. Smith  <psmith@gnu.org>
1188+
1189+	* scripts/functions/addsuffix: Test for an empty final argument.
1190+	Actually this bug might have happened for any function, but this
1191+	one was handy.
1192+
1193+2000-06-17  Eli Zaretskii  <eliz@is.elta.co.il>
1194+
1195+	* scripts/options/general: If parallel jobs are not supported,
1196+	expect a warning message from Make.
1197+
1198+2000-06-15  Eli Zaretskii  <eliz@is.elta.co.il>
1199+
1200+	* scripts/options/general: Don't try -jN with N != 1 if parallel
1201+	jobs are not supported.
1202+
1203+2000-05-24  Paul D. Smith  <psmith@gnu.org>
1204+
1205+	* scripts/options/general: Test general option processing (PR/1716).
1206+
1207+2000-04-11  Paul D. Smith  <psmith@gnu.org>
1208+
1209+	* scripts/functions/strip: Test empty value to strip (PR/1689).
1210+
1211+2000-04-08  Eli Zaretskii  <eliz@is.elta.co.il>
1212+
1213+	* scripts/features/reinvoke: Sleep before updating the target
1214+	files in the first test, to ensure its time stamp really gets
1215+	newer; otherwise Make might re-exec more than once.
1216+
1217+2000-04-07  Eli Zaretskii  <eliz@is.elta.co.il>
1218+
1219+	* scripts/features/double_colon: Don't run the parallel tests if
1220+	parallel jobs aren't supported.
1221+
1222+2000-04-04  Paul D. Smith  <psmith@gnu.org>
1223+
1224+	* scripts/functions/word: wordlist doesn't swap arguments anymore.
1225+
1226+2000-03-27  Paul D. Smith  <psmith@gnu.org>
1227+
1228+	* scripts/features/statipattrules: Test that static pattern rules
1229+	whose prerequisite patterns resolve to empty strings throw an
1230+	error (instead of dumping core).  Fixes PR/1670.
1231+
1232+	* scripts/features/reinvoke: Make more robust by touching "b"
1233+	first, to ensure it's not newer than "a".
1234+	Reported by Marco Franzen <Marco.Franzen@Thyron.com>.
1235+	* scripts/options/dash-n: Ditto.
1236+
1237+	* scripts/functions/call: Whoops.  The fix to PR/1527 caused
1238+	recursive invocations of $(call ...) to break.  I can't come up
1239+	with any way to get both working at the same time, so I backed out
1240+	the fix to 1527 and added a test case for recursive calls.  This
1241+	also tests the fix for PR/1610.
1242+
1243+	* scripts/features/double_colon: Test that circular dependencies
1244+	in double-colon rule sets are detected correctly (PR/1671).
1245+
1246+2000-03-26  Paul D. Smith  <psmith@gnu.org>
1247+
1248+	* scripts/targets/INTERMEDIATE: Test that make doesn't remove
1249+	.INTERMEDIATE files when given on the command line (PR/1669).
1250+
1251+2000-03-08  Paul D. Smith  <psmith@gnu.org>
1252+
1253+	* scripts/options/dash-k: Add a test for error detection by
1254+	multiple targets depending on the same prerequisite with -k.
1255+	For PR/1634.
1256+
1257+2000-02-07  Paul D. Smith  <psmith@gnu.org>
1258+
1259+	* scripts/features/escape: Add a test for backslash-escaped spaces
1260+	in a target name (PR/1586).
1261+
1262+2000-02-04  Paul D. Smith  <psmith@gnu.org>
1263+
1264+	* scripts/features/patspecific_vars: Add a test for pattern-specific
1265+	target variables inherited from the parent target (PR/1407).
1266+
1267+2000-02-02  Paul D. Smith  <psmith@gnu.org>
1268+
1269+	* run_make_tests.pl (set_more_defaults): Hard-code the LANG to C
1270+	to make sure sorting order, etc. is predictable.
1271+	Reported by Andreas Jaeger <aj@suse.de>.
1272+
1273+	* run_make_tests.pl (set_more_defaults): Set the $wtime variable
1274+	depending on the OS.  Eli Zaretskii <eliz@is.elta.co.il> reports
1275+	this seems to need to be *4* on DOS/Windows, not just 2.  Keep it
1276+	1 for other systems.
1277+	* scripts/features/vpathplus (touchfiles): Use the $wtime value
1278+	instead of hardcoding 2.
1279+	* scripts/targets/SECONDARY: Ditto.
1280+	* scripts/targets/INTERMEDIATE: Ditto.
1281+
1282+2000-01-27  Paul D. Smith  <psmith@gnu.org>
1283+
1284+	* test_driver.pl (toplevel): Don't try to run test scripts which
1285+	are really directories.
1286+
1287+2000-01-23  Paul D. Smith  <psmith@gnu.org>
1288+
1289+	* scripts/features/include: Remove a check; the fix caused more
1290+	problems than the error, so I removed it and removed the test for
1291+	it.
1292+
1293+2000-01-11  Paul D. Smith  <psmith@gnu.org>
1294+
1295+	* scripts/functions/call: Add a test for PR/1517 and PR/1527: make
1296+	sure $(call ...) doesn't eval its arguments and that you can
1297+	invoke foreach from it without looping forever.
1298+
1299+1999-12-15  Paul D. Smith  <psmith@gnu.org>
1300+
1301+	* scripts/targets/INTERMEDIATE: Add a test for PR/1423: make sure
1302+	.INTERMEDIATE settings on files don't disable them as implicit
1303+	intermediate possibilities.
1304+
1305+1999-12-01  Paul D. Smith  <psmith@gnu.org>
1306+
1307+	* scripts/features/double_colon: Add a test for PR/1476: Try
1308+	double-colon rules as non-goal targets and during parallel builds
1309+	to make sure they're handled serially.
1310+
1311+1999-11-17  Paul D. Smith  <psmith@gnu.org>
1312+
1313+	* scripts/functions/if: Add a test for PR/1429: put some text
1314+	after an if-statement to make sure it works.
1315+
1316+	* scripts/features/targetvars: Add a test for PR/1380: handling +=
1317+	in target-specific variable definitions correctly.
1318+
1319+1999-10-15  Paul D. Smith  <psmith@gnu.org>
1320+
1321+	* scripts/variables/MAKEFILES: This was really broken: it didn't
1322+	test anything at all, really.  Rewrote it, plus added a test for
1323+	PR/1394.
1324+
1325+1999-10-13  Paul D. Smith  <psmith@gnu.org>
1326+
1327+	* scripts/options/dash-n: Add a test for PR/1379: "-n doesn't
1328+	behave properly when used with recursive targets".
1329+
1330+1999-10-08  Paul D. Smith  <psmith@gnu.org>
1331+
1332+	* scripts/features/targetvars: Add a check for PR/1378:
1333+	"Target-specific vars don't inherit correctly"
1334+
1335+1999-09-29  Paul D. Smith  <psmith@gnu.org>
1336+
1337+	* test_driver.pl (get_osname): Change $fancy_file_names to
1338+	$short_filenames and reverse the logic.
1339+	(run_each_test): Change test of non-existent $port_host to use
1340+	$short_filenames--problem reported by Eli Zaretskii.
1341+
1342+1999-09-23  Paul D. Smith  <psmith@gnu.org>
1343+
1344+	* scripts/features/parallelism: Add a check to ensure that the
1345+	jobserver works when we re-invoke.  Also cleaned up the tests a
1346+	little, reducing the number of rules we use so the test won't need
1347+	as many "sleep" commands.
1348+
1349+1999-09-16  Paul D. Smith  <psmith@gnu.org>
1350+
1351+	* scripts/features/reinvoke: Remove invocations of "touch" in
1352+	makefiles.  See the comments on the touch function rewrite below.
1353+	Note that UNIX touch behaves the same way if the file already
1354+	exists: it sets the time to the _local_ time.  We don't want
1355+	this.  This is probably a good tip for makefile writers in
1356+	general, actually... where practical.
1357+	* scripts/options/dash-l: Ditto.
1358+	* scripts/options/dash-n: Ditto.
1359+
1360+	* test_driver.pl (run_each_test): In retrospect, I don't like the
1361+	.lN/.bN/.dN postfix required by DOS.  So, for non-DOS systems I
1362+	changed it back to use .log, .base, and .diff.
1363+
1364+	* run_make_tests.pl (set_more_defaults): Move the check for the
1365+	make pathname to here from set_defaults (that's too early since it
1366+	happens before the command line processing).
1367+	Create a new variable $port_type, calculated from $osname, to
1368+	specify what kind of system we're running on.  We should integrate
1369+	the VOS stuff here, too.
1370+	(valid_option): Comment out the workdir/-work stuff so people
1371+	won't be fooled into thinking it works... someone needs to fix
1372+	this, though!
1373+
1374+	* scripts/functions/origin: Use $port_type instead of $osname.
1375+	* scripts/functions/foreach: Ditto.
1376+	* scripts/features/default_names: Ditto.
1377+
1378+1999-09-15  Paul D. Smith  <psmith@gnu.org>
1379+
1380+	* test_driver.pl (touch): Rewrite this function.  Previously it
1381+	used to use utime() to hard-set the time based on the current
1382+	local clock, or, if the file didn't exist, it merely created it.
1383+	This mirrors exactly what real UNIX touch does, but it fails badly
1384+	on networked filesystems where the FS server clock is skewed from
1385+	the local clock: normally modifying a file causes it to get a mod
1386+	time based on the _server's_ clock.  Hard-setting it based on the
1387+	_local_ clock causes gratuitous errors and makes the tests
1388+	unreliable except on local filesystems.  The new function will
1389+	simply modify the file, allowing the filesystem to set the mod
1390+	time as it sees fit.
1391+
1392+	* scripts/features/parallelism: The second test output could
1393+	change depending on how fast some scripts completed; use "sleep"
1394+	to force the order we want.
1395+
1396+	* test_driver.pl (toplevel): A bug in Perl 5.000 to Perl 5.004
1397+	means that "%ENV = ();" doesn't do the right thing.  This worked
1398+	in Perl 4 and was fixed in Perl 5.004_01, but use a loop to delete
1399+	the environment rather than require specific versions.
1400+
1401+	* run_make_tests.pl (set_more_defaults): Don't use Perl 5 s///
1402+	modifier "s", so the tests will run with Perl 4.
1403+	(set_more_defaults): Set $pure_log to empty if there's no -logfile
1404+	option in PURIFYOPTIONS.
1405+	(setup_for_test): Don't remove any logs unless $pure_log is set.
1406+
1407+1999-09-15  Eli Zaretskii  <eliz@is.elta.co.il>
1408+
1409+	* scripts/features/reinvoke: Put the SHELL definition in the right
1410+	test makefile.
1411+
1412+1999-09-15  Paul D. Smith  <psmith@gnu.org>
1413+
1414+	ChangeLog file for the test suite created.
1415+
1416+
1417+Copyright (C) 1992-2017 Free Software Foundation, Inc.
1418+This file is part of GNU Make.
1419+
1420+GNU Make is free software; you can redistribute it and/or modify it under the
1421+terms of the GNU General Public License as published by the Free Software
1422+Foundation; either version 3 of the License, or (at your option) any later
1423+version.
1424+
1425+GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
1426+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
1427+A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
1428+
1429+You should have received a copy of the GNU General Public License along with
1430+this program.  If not, see <https://www.gnu.org/licenses/>.
+178, -0
  1@@ -0,0 +1,178 @@
  2+Changes from 0.4.9 to 3.78 (Sep 6, 1999):
  3+
  4+    Lots of new tests.  Renamed to follow the GNU Make scheme.  Also
  5+    added some support for using Purify with make.
  6+
  7+    Rob Tulloh contributed some changes to get the test suite running on
  8+    NT; I tweaked them a bit (hopefully I didn't break anything!)  Note
  9+    that NT doesn't grok the self-exec funkiness that Unix shells use,
 10+    so instead I broke that out into a separate shell script
 11+    "run_make_tests" that invokes perl with the (renamed) script
 12+    run_make_tests.pl.
 13+
 14+    Eli Zaretski contributed changes to get the test suite running on
 15+    DOS with DJGPP.  I also meddled in these somewhat.
 16+
 17+    If you're on DOS or NT you should run "perl.exe run_make_tests.pl ..."
 18+    If you're on Unix, you can continue to run "./run_make_tests ..." as
 19+    before.
 20+
 21+Changes from 0.4.8 to 0.4.9 (May 14, 1998):
 22+
 23+    Release by Paul D. Smith <psmith@baynetworks.com>; I'm the one to
 24+    blame for problems in this version :).
 25+
 26+    Add some perl to test_driver.pl to strip out GNU Make clock skew
 27+    warning messages from the output before comparing it to the
 28+    known-good output.
 29+
 30+    A new test for escaped :'s in filenames (someone on VMS found this
 31+    didn't work anymore in 3.77): scripts/features/escape.
 32+
 33+Changes from 0.4.7 to 0.4.8 (May 14, 1998):
 34+
 35+    Release by Paul D. Smith <psmith@baynetworks.com>; I'm the one to
 36+    blame for problems in this version :).
 37+
 38+    New tests for features to be included in GNU Make 3.77.
 39+
 40+Changes from 0.4.6 to 0.4.7 (August 18, 1997):
 41+
 42+    Release by Paul D. Smith <psmith@baynetworks.com>; I'm the one to
 43+    blame for problems in this version :).
 44+
 45+    Reworked some tests to make sure they all work with both perl4 and perl5.
 46+
 47+    Work around a bug in perl 5.004 which doesn't clean the environment
 48+    correctly in all cases (fixed in at least 5.004_02).
 49+
 50+    Updated functions/strip to test for newline stripping.
 51+
 52+    Keep a $PURIFYOPTIONS env variable if present.
 53+
 54+Changes from 0.4.5 to 0.4.6 (April 07, 1997):
 55+
 56+    Release by Paul D. Smith <psmith@baynetworks.com>; I'm the one to
 57+    blame for problems in this version :).
 58+
 59+    Updated to work with GNU Make 3.76 (and pretests).
 60+
 61+    Added new tests and updated existing ones.  Note that the new tests
 62+    weren't tested with perl 4, however I think they should work.
 63+
 64+    Ignore any tests whose filenames end in "~", so that Emacs backup
 65+    files aren't run.
 66+
 67+Changes from 0.4.4 to 0.4.5 (April 29, 1995):
 68+
 69+    Updated to be compatible with perl 5.001 as well as 4.036.
 70+
 71+    Note: the test suite still won't work on 14-char filesystems
 72+    (sorry, Kaveh), but I will get to it.
 73+
 74+    Also, some tests and stuff still haven't made it in because I
 75+    haven't had time to write the test scripts for them.  But they,
 76+    too, will get in eventually.  Contributions of scripts (i.e., tests
 77+    that I can just drop in) are particularly welcome and will be
 78+    incorporated immediately.
 79+
 80+Changes from 0.4.3 to 0.4.4 (March 1995):
 81+
 82+    Updated for changes in make 3.72.12, and to ignore CVS directories
 83+    (thanks go to Jim Meyering for the patches for this).
 84+
 85+    Fixed uname call to not make a mess on BSD/OS 2.0 (whose uname -a
 86+    is very verbose).  Let me know if this doesn't work correctly on
 87+    your system.
 88+
 89+    Changed to display test name while it is running, not just when it
 90+    finishes.
 91+
 92+    Note: the test suite still won't work on 14-char filesystems
 93+    (sorry, Kaveh), but I will get to it.
 94+
 95+    Also, some tests and stuff still haven't made it in because I
 96+    haven't had time to write the test scripts for them.  But they,
 97+    too, will get in eventually.
 98+
 99+Changes from 0.4 to 0.4.3 (October 1994):
100+
101+    Fixed bugs (like dependencies on environment variables).
102+
103+    Caught up with changes in make.
104+
105+    The load_limit test should now silently ignore a failure due to
106+    make not being able to read /dev/kmem.
107+
108+    Reorganized tests into subdirs and renamed lots of things so that
109+    those poor souls who still have to deal with 14-char filename
110+    limits won't hate me any more.  Thanks very much to Kaveh R. Ghazi
111+    <ghazi@noc.rutgers.edu> for helping me with the implementation and
112+    testing of these changes, and for putting up with all my whining
113+    about it...
114+
115+    Added a $| = 1 so that systems that don't seem to automatically
116+    flush their output for some reason will still print all the
117+    output.  I'd hate for someone to miss out on the smiley that
118+    you're supposed to get when all the tests pass... :-)
119+
120+Changes from 0.3 to 0.4 (August 1993):
121+
122+    Lost in the mists of time (and my hurry to get it out before I
123+    left my job).
124+
125+Changes from 0.2 to 0.3 (9-30-92):
126+
127+    Several tests fixed to match the fact that MAKELEVEL > 0 or -C now
128+    imply -w.
129+
130+    parallel_execution test fixed to not use double colon rules any
131+    more since their behavior has changed.
132+
133+    errors_in_commands test fixed to handle different error messages
134+    and return codes from rm.
135+
136+    Several tests fixed to handle -make_path with a relative path
137+    and/or a name other than "make" for make.
138+
139+    dash-e-option test fixed to use $PATH instead of $USER (since the
140+    latter does not exist on some System V systems).  This also
141+    removes the dependency on getlogin (which fails under certain
142+    weird conditions).
143+
144+    test_driver_core changed so that you can give a test name like
145+    scripts/errors_in_commands and it will be handled correctly (handy
146+    if you have a shell with filename completion).
147+
148+Changes from 0.1 to 0.2 (5-4-92):
149+
150+    README corrected to require perl 4.019, not 4.010.
151+
152+    -make_path replaces -old.
153+
154+    errors_in_commands test updated for change in format introduced in
155+    make 3.62.6.
156+
157+    test_driver_core now uses a better way of figuring what OS it is
158+    running on (thanks to meyering@cs.utexas.edu (Jim Meyering) for
159+    suggesting this, as well as discovering the hard way that the old
160+    way (testing for /mnt) fails on his machine).
161+
162+    Some new tests were added.
163+
164+
165+-------------------------------------------------------------------------------
166+Copyright (C) 1992-2025 Free Software Foundation, Inc.
167+This file is part of GNU Make.
168+
169+GNU Make is free software; you can redistribute it and/or modify it under the
170+terms of the GNU General Public License as published by the Free Software
171+Foundation; either version 3 of the License, or (at your option) any later
172+version.
173+
174+GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
175+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
176+A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
177+
178+You should have received a copy of the GNU General Public License along with
179+this program.  If not, see <https://www.gnu.org/licenses/>.
+99, -0
  1@@ -0,0 +1,99 @@
  2+The test suite was originally written by Steve McGee and Chris Arthur.
  3+It is covered by the GNU General Public License (Version 2), described
  4+in the file COPYING.  It has been maintained as part of GNU make proper
  5+since GNU make 3.78.
  6+
  7+This entire test suite, including all test files, are copyright and
  8+distributed under the following terms:
  9+
 10+ -----------------------------------------------------------------------------
 11+ Copyright (C) 1992-2025 Free Software Foundation, Inc.
 12+ This file is part of GNU Make.
 13+
 14+ GNU Make is free software; you can redistribute it and/or modify it under the
 15+ terms of the GNU General Public License as published by the Free Software
 16+ Foundation; either version 3 of the License, or (at your option) any later
 17+ version.
 18+
 19+ GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
 20+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 21+ A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 22+
 23+ You should have received a copy of the GNU General Public License along with
 24+ this program.  If not, see <http://www.gnu.org/licenses/>.
 25+ -----------------------------------------------------------------------------
 26+
 27+The test suite requires Perl.  These days, you should have at least Perl 5.6.
 28+Newer versions may be required: I don't test regularly with older versions
 29+than what is installed by default on my development systems.
 30+
 31+The test suite assumes that the first "diff" it finds on your PATH is
 32+GNU diff, but that only matters if a test fails.
 33+
 34+To run the test suite on a UNIX system, use "perl ./run_make_tests"
 35+(or just "./run_make_tests" if you have a perl on your PATH).
 36+
 37+To run the test suite on Windows NT or DOS systems, use
 38+"perl.exe ./run_make-tests.pl".
 39+
 40+By default, the test engine picks up the first executable called "make" that
 41+it finds in your path.  You may use the -make option (i.e.,
 42+"perl run_make_tests -make /usr/local/src/make-latest/make") if you want to
 43+run a particular copy.  This now works correctly with relative paths and
 44+when make is called something other than "make" (like "gmake").
 45+
 46+Tests cannot end with a "~" character, as the test suite will ignore any
 47+that do (I was tired of having it run my Emacs backup files as tests :))
 48+
 49+Also, sometimes the tests may behave strangely on networked
 50+filesystems.  You can use mkshadow to create a copy of the test suite in
 51+/tmp or similar, and try again.  If the error disappears, it's an issue
 52+with your network or file server, not GNU make (I believe).  This
 53+shouldn't happen very often anymore: I've done a lot of work on the
 54+tests to reduce the impacts of this situation.
 55+
 56+A directory named "work" will be created when the tests are run which
 57+will contain any makefiles and "diff" files of tests that fail so that
 58+you may look at them afterward to see the output of make and the
 59+expected result.
 60+
 61+There is a -help option which will give you more information about the
 62+other possible options for the test suite.
 63+
 64+
 65+Open Issues
 66+-----------
 67+
 68+The test suite has a number of problems which should be addressed.  One VERY
 69+serious one is that there is no real documentation.  You just have to see the
 70+existing tests.  Use the newer tests: many of the tests haven't been updated
 71+to use the latest/greatest test methods.  See the ChangeLogs for pointers.
 72+
 73+The second serious problem is that it's not relocatable: when you build out of
 74+the source tree it creates symlinks, which doesn't work on every system and is
 75+just bogus to boot.
 76+
 77+The third serious problem is that it's not parallelizable: it scribbles all
 78+over its installation directory and so can only test one make at a time.
 79+
 80+The fourth serious problem is that since the tests scribble all over the same
 81+directory (a) they can interfere with each other and (b) we cannot preserve
 82+the full environment for every test, if it involves creating temporary files
 83+etc. as they must be deleted before the next test.
 84+
 85+To solve these the suite should create a separate directory for EVERY test,
 86+local to the build directory, and all temporary files should exist in that
 87+directory.  The directory can be preserved on error, or removed if the test
 88+succeeds (unless --keep is given).
 89+
 90+
 91+Bugs
 92+----
 93+
 94+Any complaints/suggestions/bugs/etc. for the test suite itself should be
 95+handled the same way as normal GNU make bugs/problems (see the README for GNU
 96+make).
 97+
 98+
 99+                                                Paul D. Smith
100+						Chris Arthur
+0, -0
+9, -0
 1@@ -0,0 +1,9 @@
 2+# This is a -*-perl-*- script
 3+#
 4+# Set variables for Windows systems.
 5+
 6+%CONFIG_FLAGS = (
 7+    USE_SYSTEM_GLOB => 'no'
 8+);
 9+
10+1;
+20, -0
 1@@ -0,0 +1,20 @@
 2+# This is a -*-perl-*- script
 3+#
 4+# Set variables that were defined by configure, in case we need them
 5+# during the tests.
 6+
 7+%CONFIG_FLAGS = (
 8+    AM_LDFLAGS      => '@AM_LDFLAGS@',
 9+    AR              => '@AR@',
10+    CC              => '@CC@',
11+    CFLAGS          => '@CFLAGS@',
12+    CPP             => '@CPP@',
13+    CPPFLAGS        => '@CPPFLAGS@',
14+    GUILE_CFLAGS    => '@GUILE_CFLAGS@',
15+    GUILE_LIBS      => '@GUILE_LIBS@',
16+    LDFLAGS         => '@LDFLAGS@',
17+    LIBS            => '@LIBS@',
18+    USE_SYSTEM_GLOB => '@USE_SYSTEM_GLOB@'
19+);
20+
21+1;
+54, -0
 1@@ -0,0 +1,54 @@
 2+$!
 3+$! config_flags_pm.com  - Build config-flags.pm on VMS.
 4+$!
 5+$! Just good enough to run the self tests for now.
 6+$!
 7+$! Copyright (C) 2014-2025 Free Software Foundation, Inc.
 8+$! This file is part of GNU Make.
 9+$!
10+$! GNU Make is free software; you can redistribute it and/or modify it under
11+$! the terms of the GNU General Public License as published by the Free Software
12+$! Foundation; either version 3 of the License, or (at your option) any later
13+$! version.
14+$!
15+$! GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
16+$! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17+$! FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
18+$! details.
19+$!
20+$! You should have received a copy of the GNU General Public License along with
21+$! this program.  If not, see <https://www.gnu.org/licenses/>.
22+$!
23+$!
24+$ open/read cfpm_in config-flags.pm.in
25+$!
26+$ outfile = "sys$disk:[]config-flags.pm"
27+$!
28+$ cflags = "/include=([],[.lib]"
29+$!
30+$ create 'outfile'
31+$ open/append cfpm 'outfile'
32+$!
33+$cfpm_read_loop:
34+$   read cfpm_in/end=cfpm_read_loop_end line_in
35+$   line_in_len = f$length(line_in)
36+$   if f$locate("@", line_in) .lt. line_in_len
37+$   then
38+$       part1 = f$element(0, "@", line_in)
39+$       key = f$element(1, "@", line_in)
40+$       part2 = f$element(2, "@", line_in)
41+$       value = ""
42+$       if key .eqs. "CC" then value = "CC"
43+$       if key .eqs. "CPP" then value = "CPP"
44+$       if key .eqs. "CFLAGS" then value = cflags
45+$       if key .eqs. "GUILE_CFLAGS" then value = cflags
46+$       if key .eqs. "USE_SYSTEM_GLOB" then value = "no"
47+$       write cfpm part1, value, part2
48+$       goto cfpm_read_loop
49+$   endif
50+$   write cfpm line_in
51+$   goto cfpm_read_loop
52+$cfpm_read_loop_end:
53+$ close cfpm_in
54+$ close cfpm
55+$!
+31, -0
 1@@ -0,0 +1,31 @@
 2+# Guile valgrind suppression file
 3+# Created with Guile 1.8.7
 4+
 5+# --- Garbage collection
 6+{
 7+  guilegc
 8+  Memcheck:Cond
 9+  ...
10+  fun:scm_gc_for_newcell
11+}
12+{
13+  guilegc
14+  Memcheck:Value4
15+  ...
16+  fun:scm_gc_for_newcell
17+}
18+{
19+  guilegc
20+  Memcheck:Value8
21+  ...
22+  fun:scm_gc_for_newcell
23+}
24+
25+
26+# -- scm_alloc_struct
27+{
28+  guileheap
29+  Memcheck:Leak
30+  ...
31+  fun:scm_alloc_struct
32+}
+57, -0
 1@@ -0,0 +1,57 @@
 2+#!/bin/sh
 3+#
 4+# Simple script to make a "shadow" test directory, using symbolic links.
 5+# Typically you'd put the shadow in /tmp or another local disk
 6+#
 7+# Copyright (C) 1992-2025 Free Software Foundation, Inc.
 8+# This file is part of GNU Make.
 9+#
10+# GNU Make is free software; you can redistribute it and/or modify it under
11+# the terms of the GNU General Public License as published by the Free Software
12+# Foundation; either version 3 of the License, or (at your option) any later
13+# version.
14+#
15+# GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
16+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
18+# details.
19+#
20+# You should have received a copy of the GNU General Public License along with
21+# this program.  If not, see <https://www.gnu.org/licenses/>.
22+
23+case "$1" in
24+  "") echo 'Usage: mkshadow <destdir>'; exit 1 ;;
25+esac
26+
27+dest="$1"
28+
29+if [ ! -d "$dest" ]; then
30+  echo "Destination directory '$dest' must exist!"
31+  exit 1
32+fi
33+
34+if [ ! -f run_make_tests ]; then
35+  echo "The current directory doesn't appear to contain the test suite!"
36+  exit 1
37+fi
38+
39+suite=`pwd | sed 's%^/tmp_mnt%%'`
40+name=`basename "$suite"`
41+
42+files=`echo *`
43+
44+set -e
45+
46+mkdir "$dest/$name"
47+cd "$dest/$name"
48+
49+ln -s "$suite" .testdir
50+
51+for f in $files; do
52+  ln -s .testdir/$f .
53+done
54+
55+rm -rf work
56+
57+echo "Shadow test suite created in '$dest/$name'."
58+exit 0
+2, -0
1@@ -0,0 +1,2 @@
2+#!/bin/sh
3+exec perl $0.pl ${1+"$@"}
+21, -0
 1@@ -0,0 +1,21 @@
 2+@echo off
 3+rem Copyright (C) 2017-2025 Free Software Foundation, Inc.
 4+rem This file is part of GNU Make.
 5+rem
 6+rem GNU Make is free software; you can redistribute it and/or modify it under
 7+rem the terms of the GNU General Public License as published by the Free
 8+rem Software Foundation; either version 3 of the License, or (at your option)
 9+rem any later version.
10+rem
11+rem GNU Make is distributed in the hope that it will be useful, but WITHOUT
12+rem ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+rem FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for.
14+rem more details.
15+rem
16+rem You should have received a copy of the GNU General Public License along
17+rem with this program.  If not, see <https://www.gnu.org/licenses/>.
18+
19+setlocal
20+cd "%~dp0"
21+
22+perl -I. .\run_make_tests.pl %*
+272, -0
  1@@ -0,0 +1,272 @@
  2+$! Test_make.com
  3+$!
  4+$! This is a wrapper for the GNU Make perl test programs on VMS.
  5+$!
  6+$! Parameter "-help" for description on how to use described below.
  7+$!
  8+$! Copyright (C) 2014-2025 Free Software Foundation, Inc.
  9+$! This file is part of GNU Make.
 10+$!
 11+$! GNU Make is free software; you can redistribute it and/or modify it under
 12+$! the terms of the GNU General Public License as published by the Free Software
 13+$! Foundation; either version 3 of the License, or (at your option) any later
 14+$! version.
 15+$!
 16+$! GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
 17+$! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 18+$! FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 19+$! details.
 20+$!
 21+$! You should have received a copy of the GNU General Public License along with
 22+$! this program.  If not, see <https://www.gnu.org/licenses/>.
 23+$!
 24+$!
 25+$! Allow more than 8 parameters with using commas as a delimiter.
 26+$!
 27+$ params = "''p1',''p2',''p3',''p4',''p5',''p6',''p7',''p8'"
 28+$!
 29+$ test_flags = ",verbose,detail,keep,usage,help,debug,"
 30+$ test_flags_len = f$length(test_flags)
 31+$ verbose_flag = ""
 32+$ detail_flag = ""
 33+$ keep_flag = ""
 34+$ usage_flag = ""
 35+$ help_flag = ""
 36+$ debug_flag = ""
 37+$!
 38+$ ignored_options = "profile,make,srcdir,valgrind,memcheck,massif,"
 39+$ ignored_option_len = f$length(ignored_options)
 40+$!
 41+$ testname = ""
 42+$ make :== $bin:make.exe"
 43+$!
 44+$ i = 0
 45+$param_loop:
 46+$ param = f$element(i, ",", params)
 47+$ i = i + 1
 48+$ if param .eqs. "" then goto param_loop
 49+$ if param .eqs. "," then goto param_loop_end
 50+$ param_len = f$length(param)
 51+$ if f$locate("/", param) .lt. param_len
 52+$ then
 53+$   if testname .nes. ""
 54+$   then
 55+$       write sys$output "Only the last test name specified will be run!"
 56+$   endif
 57+$   testname = param
 58+$   goto param_loop
 59+$ endif
 60+$ lc_param = f$edit(param,"LOWERCASE") - "-"
 61+$ if f$locate(",''lc_param',", ignored_options) .lt. ignored_option_len
 62+$ then
 63+$   write sys$output "parameter ''param' is ignored on VMS for now."
 64+$   goto param_loop
 65+$ endif
 66+$ if f$locate(",''lc_param',", test_flags) .lt. test_flags_len
 67+$ then
 68+$   'lc_param'_flag = "-" + lc_param
 69+$   goto param_loop
 70+$ endif
 71+$   write sys$output "parameter ''param' is not known to VMS."
 72+$ goto param_loop
 73+$!
 74+$param_loop_end:
 75+$!
 76+$no_gnv = 1
 77+$no_perl = 1
 78+$!
 79+$!  Find GNV 2.1.3 + manditory updates
 80+$!  If properly updated, the GNV$GNU logical name is present.
 81+$!  Updated GNV utilities have a gnv$ prefix on them.
 82+$   gnv_root = f$trnlnm("GNV$GNU", "LNM$SYSTEM_TABLE")
 83+$   if gnv_root .nes. ""
 84+$   then
 85+$       no_gnv = 0
 86+$       ! Check for update ar utility.
 87+$       new_ar = "gnv$gnu:[usr.bin]gnv$ar.exe"
 88+$       if f$search(new_ar) .nes. ""
 89+$       then
 90+$           ! See if a new port of ar exists.
 91+$           ar :== $'new_ar'
 92+$       else
 93+$           ! Fall back to legacy GNV AR wrapper.
 94+$           old_ar = "gnv$gnu:[bin]ar.exe"
 95+$           if f$search(old_ar) .nes. ""
 96+$           then
 97+$               ar :== $'old_ar'
 98+$           else
 99+$               no_gnv = 1
100+$           endif
101+$       endif
102+$       ! Check for updated bash
103+$       if no_gnv .eq. 0
104+$       then
105+$           new_bash = "gnv$gnu:[bin]gnv$bash.exe"
106+$           if f$search(new_bash) .nes. ""
107+$           then
108+$               bash :== $'new_bash'
109+$               sh :== $'new_bash'
110+$           else
111+$               no_gnv = 1
112+$           endif
113+$       endif
114+$       ! Check for updated coreutils
115+$       if no_gnv .eq. 0
116+$       then
117+$           new_cat = "gnv$gnu:[bin]gnv$cat.exe"
118+$           if f$search(new_cat) .nes. ""
119+$           then
120+$               cat :== $'new_cat'
121+$               cp :== $gnv$gnu:[bin]gnv$cp.exe
122+$               echo :== $gnv$gnu:[bin]gnv$echo.exe
123+$               false :== $gnv$gnu:[bin]gnv$false.exe
124+$               true :== $gnv$gnu:[bin]gnv$true.exe
125+$               touch :== $gnv$gnu:[bin]gnv$touch.exe
126+$               mkdir :== $gnv$gnu:[bin]gnv$mkdir.exe
127+$               rm :== $gnv$gnu:[bin]gnv$rm.exe
128+$               sleep :== $gnv$gnu:[bin]gnv$sleep.exe
129+$           else
130+$               no_gnv = 1
131+$           endif
132+$       endif
133+$       ! Check for updated diff utility.
134+$       if no_gnv .eq. 0
135+$       then
136+$           new_diff = "gnv$gnu:[usr.bin]gnv$diff.exe"
137+$           if f$search(new_diff) .nes. ""
138+$           then
139+$               ! See if a new port of diff exists.
140+$               diff :== $'new_diff'
141+$           else
142+$               ! Fall back to legacy GNV diff
143+$               old_diff = "gnv$gnu:[bin]diff.exe"
144+$               if f$search(old_diff) .nes. ""
145+$               then
146+$                   diff :== $'old_diff'
147+$               else
148+$                   no_gnv = 1
149+$               endif
150+$           endif
151+$       endif
152+$   endif
153+$!
154+$if no_gnv
155+$then
156+$   write sys$output "Could not find an up to date GNV installed!"
157+$   help_flag = 1
158+$endif
159+$!
160+$! Find perl 5.18.1 or later.
161+$!
162+$! look in perl_root:[000000]perl_setup.com
163+$ perl_root = f$trnlnm("perl_root")
164+$ ! This works with known perl installed from PCSI kits.
165+$ if perl_root .nes. ""
166+$ then
167+$   perl_ver = f$element(1, ".", perl_root)
168+$   if f$locate("-", perl_ver) .lt. f$length(perl_ver)
169+$   then
170+$       no_perl = 0
171+$   endif
172+$ endif
173+$ if no_perl
174+$ then
175+$!  look for sys$common:[perl-*]perl_setup.com
176+$   perl_setup = f$search("sys$common:[perl-*]perl_setup.com")
177+$   if perl_setup .eqs. ""
178+$   then
179+$       if gnv_root .nes. ""
180+$       then
181+$           gnv_device = f$parse(gnv_root,,,"DEVICE")
182+$           perl_templ = "[vms$common.perl-*]perl_setup.com"
183+$           perl_search = f$parse(perl_templ, gnv_device)
184+$           perl_setup = f$search(perl_search)
185+$       endif
186+$   endif
187+$   if perl_setup .nes. ""
188+$   then
189+$       @'perl_setup'
190+$       no_perl = 0
191+$   endif
192+$ endif
193+$!
194+$ if no_perl
195+$ then
196+$   write sys$output "Could not find an up to date Perl installed!"
197+$   help_flag = "-help"
198+$ endif
199+$!
200+$!
201+$ if help_flag .nes. ""
202+$ then
203+$   type sys$input
204+$DECK
205+This is a test script wrapper for the run_make_tests.pl script.
206+
207+This wrapper makes sure that the DCL symbols and logical names needed to
208+run the perl script are in place.
209+
210+The test wrapper currently requires that the DCL symbols be global symbols.
211+Those symbols will be left behind after the procedure is run.
212+
213+The PERL_ROOT will be set to a compatible perl if such a perl is found and
214+is not the default PERL_ROOT:.  This setting will persist after the test.
215+
216+This wrapper should be run with the default set to the base directory
217+of the make source.
218+
219+The HELP parameter will bring up this text and then run the help script
220+for the Perl wrapper.  Not all options for the perl script have been
221+implemented, such as valgrind or specifying the make path or source path.
222+
223+Running the wrapper script requires:
224+  Perl 5.18 or later.
225+  PCSI kits available from https://sourceforge.net/projects/vmsperlkit/files/
226+
227+  GNV 2.1.3 or later.  GNV 3.0.1 has not tested with this script.
228+  Bash 4.2.47 or later.
229+  Coreutils 8.21 or later.
230+  https://sourceforge.net/projects/gnv/files/
231+  Read before installing:
232+     https://sourceforge.net/p/gnv/wiki/InstallingGNVPackages/
233+  As updates for other GNV components get posted, those updates should
234+  be used.
235+
236+$EOD
237+$ endif
238+$!
239+$ if no_gnv .or. no_perl then exit 44
240+$!
241+$!
242+$ default = f$environment("DEFAULT")
243+$ default_dev = f$element(0, ":", default) + ":"
244+$ this = f$environment("PROCEDURE")
245+$ on error then goto all_error
246+$ set default 'default_dev''f$parse(this,,,"DIRECTORY")'
247+$!
248+$! Need to make sure that the config-flags.pm exists.
249+$ if f$search("config-flags.pm") .eqs. ""
250+$ then
251+$   @config_flags_pm.com
252+$ endif
253+$ define/user bin 'default_dev'[-],gnv$gnu:[bin]
254+$ define/user decc$filename_unix_noversion enable
255+$ define/user decc$filename_unix_report enable
256+$ define/user decc$readdir_dropdotnotype enable
257+$ flags = ""
258+$ if verbose_flag .nes. "" then flags = verbose_flag
259+$ if detail_flag .nes. "" then flags = flags + " " + detail_flag
260+$ if keep_flag .nes. "" then flags = flags + " " + keep_flag
261+$ if usage_flag .nes. "" then flags = flags + " " + usage_flag
262+$ if help_flag .nes. "" then flags = flags + " " + help_flag
263+$ if debug_flag .nes. "" then flags = flags + " " + debug_flag
264+$ flags = f$edit(flags, "TRIM, COMPRESS")
265+$ if testname .nes. ""
266+$ then
267+$   perl run_make_tests.pl "''testname'" 'flags'
268+$ else
269+$   perl run_make_tests.pl 'flags'
270+$ endif
271+$all_error:
272+$ set default 'default'
273+$!
+668, -0
  1@@ -0,0 +1,668 @@
  2+#!/usr/bin/env perl
  3+# -*-perl-*-
  4+
  5+# Test driver for the Make test suite
  6+
  7+# Usage:  run_make_tests  [testname]
  8+#                         [-debug]
  9+#                         [-help]
 10+#                         [-verbose]
 11+#                         [-keep]
 12+#                         [-make <make prog>]
 13+#                        (and others)
 14+
 15+# Copyright (C) 1992-2025 Free Software Foundation, Inc.
 16+# This file is part of GNU Make.
 17+#
 18+# GNU Make is free software; you can redistribute it and/or modify it under
 19+# the terms of the GNU General Public License as published by the Free Software
 20+# Foundation; either version 3 of the License, or (at your option) any later
 21+# version.
 22+#
 23+# GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
 24+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 25+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 26+# details.
 27+#
 28+# You should have received a copy of the GNU General Public License along with
 29+# this program.  If not, see <https://www.gnu.org/licenses/>.
 30+
 31+# Add the working directory to @INC and load the test driver
 32+use FindBin;
 33+use lib "$FindBin::Bin";
 34+
 35+our $testsroot = $FindBin::Bin;
 36+
 37+require "test_driver.pl";
 38+
 39+use File::Spec;
 40+
 41+use Cwd;
 42+$cwdpath = cwd();
 43+($cwdvol, $cwddir, $_) = File::Spec->splitpath($cwdpath, 1);
 44+
 45+# Some target systems might not have the POSIX module...
 46+$has_POSIX = eval { require "POSIX.pm" };
 47+
 48+%FEATURES = ();
 49+%DEFVARS = (
 50+    AR => undef,
 51+    CC => undef
 52+);
 53+
 54+$valgrind = 0;              # invoke make with valgrind
 55+$valgrind_args = '';
 56+$memcheck_args = '--num-callers=15 --tool=memcheck --leak-check=full --suppressions=guile.supp';
 57+$massif_args = '--num-callers=15 --tool=massif --alloc-fn=xmalloc --alloc-fn=xcalloc --alloc-fn=xrealloc --alloc-fn=xstrdup --alloc-fn=xstrndup';
 58+$pure_log = undef;
 59+
 60+$make_path = undef;
 61+@make_command = ();
 62+
 63+$command_string = '';
 64+
 65+$all_tests = 0;
 66+
 67+# Shell commands
 68+
 69+$sh_name = '/bin/sh';
 70+$is_posix_sh = 1;
 71+
 72+$CMD_rmfile = 'rm -f';
 73+
 74+# rmdir broken in some Perls on VMS.
 75+if ($^O eq 'VMS')
 76+{
 77+  require VMS::Filespec;
 78+  VMS::Filespec->import();
 79+
 80+  sub vms_rmdir {
 81+    my $vms_file = vmspath($_[0]);
 82+    $vms_file = fileify($vms_file);
 83+    my $ret = unlink(vmsify($vms_file));
 84+    return $ret
 85+  };
 86+
 87+  *CORE::GLOBAL::rmdir = \&vms_rmdir;
 88+
 89+  $CMD_rmfile = 'delete_file -no_ask';
 90+}
 91+
 92+%CONFIG_FLAGS = ();
 93+
 94+# Find the strings that will be generated for various error codes.
 95+# We want them from the C locale regardless of our current locale.
 96+
 97+$ERR_no_such_file = undef;
 98+$ERR_no_such_file_code = "2";
 99+$ERR_read_only_file = undef;
100+$ERR_unreadable_file = undef;
101+$ERR_nonexe_file = undef;
102+$ERR_exe_dir = undef;
103+$ERR_command_not_found = undef;
104+
105+#$SIG{INT} = sub { print STDERR "Caught a signal!\n"; die @_; };
106+
107+sub valid_option
108+{
109+   local($option) = @_;
110+
111+   if ($option =~ /^-make([-_]?path)?$/i) {
112+       $make_path = shift @argv;
113+       if (! -f $make_path) {
114+           print "$option $make_path: Not found.\n";
115+           exit 1;
116+       }
117+       return 1;
118+   }
119+
120+   if ($option =~ /^-all([-_]?tests)?$/i) {
121+       $all_tests = 1;
122+       return 1;
123+   }
124+
125+   if ($option =~ /^-(valgrind|memcheck)$/i) {
126+       $valgrind = 1;
127+       $valgrind_args = $memcheck_args;
128+       return 1;
129+   }
130+
131+   if ($option =~ /^-massif$/i) {
132+       $valgrind = 1;
133+       $valgrind_args = $massif_args;
134+       return 1;
135+   }
136+
137+# This doesn't work--it _should_!  Someone badly needs to fix this.
138+#
139+#   elsif ($option =~ /^-work([-_]?dir)?$/)
140+#   {
141+#      $workdir = shift @argv;
142+#      return 1;
143+#   }
144+
145+   return 0;
146+}
147+
148+
149+# This is an "all-in-one" function.  Arguments are as follows:
150+#
151+#  [0] (string):  The makefile to be tested.  undef means use the last one.
152+#  [1] (string):  Arguments to pass to make.
153+#  [2] (string):  Answer we should get back.
154+#  [3] (integer): Exit code we expect.  A missing code means 0 (success)
155+
156+$makefile = undef;
157+$old_makefile = undef;
158+$mkpath = undef;
159+$make_name = undef;
160+$helptool = undef;
161+
162+sub subst_make_string
163+{
164+    my $wd = cwd();
165+    local $_ = shift;
166+    $makefile and s/#MAKEFILE#/$makefile/g;
167+    s/#MAKEPATH#/$mkpath/g;
168+    s/#MAKE#/$make_name/g;
169+    s/#TAB#/\t/g;
170+    s/#SPACE#/ /g;
171+    s/#PERL#/$perl_name/g;
172+    s/#PWD#/$wd/g;
173+    s/#HELPER#/$perl_name $helptool/g;
174+    return $_;
175+}
176+
177+sub run_make_test
178+{
179+  local ($makestring, $options, $answer, $err_code, $timeout) = @_;
180+  my @call = caller;
181+
182+  # If the user specified a makefile string, create a new makefile to contain
183+  # it.  If the first value is not defined, use the last one (if there is
184+  # one).
185+
186+  if (! defined $makestring) {
187+    defined $old_makefile
188+      or die "run_make_test(undef) invoked before run_make_test('...')\n";
189+    $makefile = $old_makefile;
190+  } elsif ($makestring) {
191+    if (! defined($makefile)) {
192+      $makefile = &get_tmpfile();
193+    }
194+
195+    # Make sure it ends in a newline and substitute any special tokens.
196+    $makestring && $makestring !~ /\n$/s and $makestring .= "\n";
197+    $makestring = subst_make_string($makestring);
198+
199+    # Populate the makefile!
200+    open(MAKEFILE, "> $makefile") or die "Failed to open $makefile: $!\n";
201+    print MAKEFILE $makestring;
202+    close(MAKEFILE) or die "Failed to write $makefile: $!\n";
203+  }
204+
205+  # Do the same processing on $answer as we did on $makestring.
206+  if (defined $answer) {
207+      $answer && $answer !~ /\n$/s and $answer .= "\n";
208+      $answer = subst_make_string($answer);
209+  }
210+
211+  run_make_with_options($makefile, $options, &get_logfile(0),
212+                        $err_code, $timeout, @call);
213+  &compare_output($answer, &get_logfile(1));
214+
215+  $old_makefile = $makefile;
216+  $makefile = undef;
217+}
218+
219+sub add_options {
220+  my $cmd = shift;
221+
222+  foreach (@_) {
223+    if (ref($cmd)) {
224+      push(@$cmd, ref($_) ? @$_ : $_);
225+    } else {
226+      $cmd .= ' '.(ref($_) ? "@$_" : $_);
227+    }
228+  }
229+
230+  return $cmd;
231+}
232+
233+sub create_command {
234+  return !$_[0] || ref($_[0]) ? [@make_command] : join(' ', @make_command);
235+}
236+
237+# The old-fashioned way...
238+# $options can be a scalar (string) or a ref to an array of options
239+# If it's a scalar the entire argument is passed to system/exec etc. as
240+# a single string.  If it's a ref then the array is passed to system/exec.
241+# Using a ref should be preferred as it's more portable but all the older
242+# invocations use strings.
243+sub run_make_with_options {
244+  my ($filename, $options, $logname, $expected_code, $timeout, @call) = @_;
245+  @call = caller unless @call;
246+  my $code;
247+  my $command = create_command($options);
248+
249+  $expected_code = 0 unless defined($expected_code);
250+
251+  # Reset to reflect this one test.
252+  $test_passed = 1;
253+
254+  if ($filename) {
255+    $command = add_options($command, '-f', $filename);
256+  }
257+
258+  if ($options) {
259+    if (!ref($options) && $^O eq 'VMS') {
260+      # Try to make sure arguments are properly quoted.
261+      # This does not handle all cases.
262+      # We should convert the tests to use array refs not strings
263+
264+      # VMS uses double quotes instead of single quotes.
265+      $options =~ s/\'/\"/g;
266+
267+      # If the leading quote is inside non-whitespace, then the
268+      # quote must be doubled, because it will be enclosed in another
269+      # set of quotes.
270+      $options =~ s/(\S)(\".*\")/$1\"$2\"/g;
271+
272+      # Options must be quoted to preserve case if not already quoted.
273+      $options =~ s/(\S+)/\"$1\"/g;
274+
275+      # Special fixup for embedded quotes.
276+      $options =~ s/(\"\".+)\"(\s+)\"(.+\"\")/$1$2$3/g;
277+
278+      $options =~ s/(\A)(?:\"\")(.+)(?:\"\")/$1\"$2\"/g;
279+
280+      # Special fixup for misc/general4 test.
281+      $options =~ s/""\@echo" "cc""/\@echo cc"/;
282+      $options =~ s/"\@echo link"""/\@echo link"/;
283+
284+      # Remove shell escapes expected to be removed by bash
285+      if ($options !~ /path=pre/) {
286+        $options =~ s/\\//g;
287+      }
288+
289+      # special fixup for options/eval
290+      $options =~ s/"--eval=\$\(info" "eval/"--eval=\$\(info eval/;
291+
292+      print ("Options fixup = -$options-\n") if $debug;
293+    }
294+
295+    $command = add_options($command, $options);
296+  }
297+
298+  my $cmdstr = cmd2str($command);
299+  $command_string = "# $call[1]:$call[2]:\n$cmdstr\n";
300+
301+  if ($valgrind) {
302+    print VALGRIND "\n\nExecuting: $cmdstr\n";
303+  }
304+
305+  {
306+      my $old_timeout = $test_timeout;
307+      $timeout and $test_timeout = $timeout;
308+
309+      # If valgrind is enabled, turn off the timeout check
310+      $valgrind and $test_timeout = 0;
311+
312+      if (ref($command)) {
313+          $code = run_command_with_output($logname, @$command);
314+      } else {
315+          $code = run_command_with_output($logname, $command);
316+      }
317+      $test_timeout = $old_timeout;
318+  }
319+
320+  # Check to see if we have Purify errors.  If so, keep the logfile.
321+  # For this to work you need to build with the Purify flag -exit-status=yes
322+
323+  if ($pure_log && -f $pure_log) {
324+    if ($code & 0x7000) {
325+      $code &= ~0x7000;
326+
327+      # If we have a purify log, save it
328+      $tn = $pure_testname . ($num_of_logfiles ? ".$num_of_logfiles" : "");
329+      print("Renaming purify log file to $tn\n") if $debug;
330+      rename($pure_log, "$tn") or die "Can't rename $pure_log to $tn: $!\n";
331+      ++$purify_errors;
332+    } else {
333+      unlink($pure_log);
334+    }
335+  }
336+
337+  if ($code != $expected_code) {
338+    print "Error running @make_command (expected $expected_code; got $code)\n$call[1]:$call[2]: $cmdstr\n";
339+    $test_passed = 0;
340+    &create_file(get_runfile(), $command_string);
341+    # If it's a SIGINT, stop here
342+    if ($code & 127) {
343+      print STDERR "\nCaught signal ".($code & 127)."!\n";
344+      ($code & 127) == 2 and exit($code);
345+    }
346+    return 0;
347+  }
348+
349+  if ($profile & $vos) {
350+    system "add_profile @make_command";
351+  }
352+
353+  return 1;
354+}
355+
356+sub print_usage
357+{
358+   &print_standard_usage ("run_make_tests",
359+                          "[-make MAKE_PATHNAME] [-memcheck] [-massif]",);
360+}
361+
362+sub print_help
363+{
364+   &print_standard_help (
365+        "-make",
366+        "\tYou may specify the pathname of the copy of make to run.",
367+        "-valgrind",
368+        "-memcheck",
369+        "\tRun the test suite under valgrind's memcheck tool.",
370+        "\tChange the default valgrind args with the VALGRIND_ARGS env var.",
371+        "-massif",
372+        "\tRun the test suite under valgrind's massif tool.",
373+        "\tChange the default valgrind args with the VALGRIND_ARGS env var."
374+       );
375+}
376+
377+sub set_defaults
378+{
379+  # $profile = 1;
380+  $testee = "GNU Make";
381+  $make_path = "make";
382+  $tmpfilesuffix = "mk";
383+  if ($port_type eq 'UNIX') {
384+    $scriptsuffix = '.sh';
385+  } elsif ($port_type eq 'VMS') {
386+    $scriptsuffix = '.com';
387+  } else {
388+    $scriptsuffix = '.bat';
389+  }
390+
391+  $ENV{LC_ALL} = $makeENV{LC_ALL};
392+  $ENV{LANG} = $makeENV{LANG};
393+  $ENV{LANGUAGE} = $makeENV{LANGUAGE};
394+
395+  use locale;
396+
397+  my $loc = undef;
398+  if ($has_POSIX) {
399+      POSIX->import(qw(locale_h));
400+      # Windows has POSIX locale, but only LC_ALL not LC_MESSAGES
401+      $loc = POSIX::setlocale(&POSIX::LC_ALL);
402+      POSIX::setlocale(&POSIX::LC_ALL, 'C');
403+  }
404+
405+  if (open(my $F, '<', 'file.none')) {
406+      print "Opened non-existent file! Skipping related tests.\n";
407+  } else {
408+      $ERR_no_such_file = "$!";
409+      if ($osname eq 'os390') {
410+          $ERR_no_such_file_code = "129";
411+      }
412+  }
413+
414+  unlink('file.out');
415+  touch('file.out');
416+
417+  chmod(0444, 'file.out');
418+  if (open(my $F, '>', 'file.out')) {
419+      print "Opened read-only file! Skipping related tests.\n";
420+      close($F);
421+  } else {
422+      $ERR_read_only_file = "$!";
423+  }
424+
425+  $_ = `./file.out 2>&1`;
426+  if ($? == 0) {
427+      print "Executed non-executable file!  Skipping related tests.\n";
428+  } else {
429+      $ERR_nonexe_file = "$!";
430+  }
431+
432+  if ($^O =~ /cygwin/i) {
433+      # For some reason the execute here gives a different answer than make's
434+      print "Skipping directory execution on $^O\n";
435+  } else {
436+      $_ = `./. 2>&1`;
437+      if ($? == 0) {
438+          print "Executed directory!  Skipping related tests.\n";
439+      } else {
440+          $ERR_exe_dir = "$!";
441+      }
442+  }
443+
444+  chmod(0000, 'file.out');
445+  if (open(my $F, '<', 'file.out')) {
446+      print "Opened unreadable file!  Skipping related tests.\n";
447+      close($F);
448+  } else {
449+      $ERR_unreadable_file = "$!";
450+  }
451+
452+  unlink('file.out') or die "Failed to delete file.out: $!\n";
453+
454+  $_ = `/bin/sh -c 'bad-command 2>&1'`;
455+  if ($? == 0) {
456+      print "Invoked invalid file!  Skipping related tests.\n";
457+  } else {
458+      s/\r?\n//g;
459+      s/bad-command/#CMDNAME#/g;
460+      $ERR_command_not_found = $_;
461+  }
462+
463+  $loc and POSIX::setlocale(&POSIX::LC_ALL, $loc);
464+
465+  $ENV{LC_ALL} = $origENV{LC_ALL};
466+  $ENV{LANG} = $origENV{LANG};
467+  $ENV{LANGUAGE} = $origENV{LANGUAGE};
468+}
469+
470+# This is no longer used: we import config-flags.pm instead
471+# sub parse_status
472+# {
473+#   if (open(my $fh, '<', "$_[0]/config.status")) {
474+#     while (my $line = <$fh>) {
475+#       $line =~ m/^[SD]\["([^\"]+)"\]=" *(.*)"/ and $CONFIG_FLAGS{$1} = $2;
476+#     }
477+#     return 1;
478+#   }
479+#   return 0;
480+# }
481+
482+sub find_prog
483+{
484+  my $prog = $_[0];
485+  my ($v, $d, $f) = File::Spec->splitpath($prog);
486+
487+  # If there's no directory then we need to search the PATH
488+  if (! $d) {
489+    foreach my $e (File::Spec->path()) {
490+      $prog = File::Spec->catfile($e, $f);
491+      if (-x $prog) {
492+        ($v, $d, $f) = File::Spec->splitpath($prog);
493+        last;
494+      }
495+    }
496+  }
497+
498+  return ($v, $d, $f);
499+}
500+
501+sub get_config
502+{
503+  return exists($CONFIG_FLAGS{$_[0]}) ? $CONFIG_FLAGS{$_[0]} : '';
504+}
505+
506+sub set_more_defaults
507+{
508+  my $string;
509+
510+  # Try to find and load config-flags.pm.  They may be in the local directory
511+  # or in the $srcpath if we're remote.
512+
513+  my $d = $cwd;
514+  my $cfg = File::Spec->catfile($d, 'config-flags.pm');
515+  if (! -f $cfg) {
516+      # Nope, so look in the srcpath
517+      my $d = $srcpath;
518+      $cfg = File::Spec->catfile($d, 'config-flags.pm');
519+  }
520+
521+  -f $cfg or die "Can't locate config-flags.pm in $cwd" . ($cwd eq $srcpath ? '' : " or $srcpath") . "\n";
522+
523+  unshift(@INC, $d);
524+  require "config-flags.pm";
525+
526+  # Find the full pathname of Make.  For DOS systems this is more
527+  # complicated, so we ask make itself.
528+  if ($osname eq 'VMS') {
529+    $port_type = 'VMS-DCL' unless defined $ENV{"SHELL"};
530+    # On VMS pre-setup make to be found with simply 'make'.
531+    $make_path = 'make';
532+  } else {
533+    create_file('make.mk', 'all:;$(info $(MAKE))');
534+    my $mk = `"$make_path" -sf make.mk`;
535+    unlink('make.mk');
536+    $mk =~ s/\r?\n$//;
537+    $mk or die "FATAL ERROR: Cannot determine the value of \$(MAKE)\n";
538+    $make_path = $mk;
539+  }
540+  ($mpv, $mpd, $mpf) = File::Spec->splitpath($make_path);
541+
542+  # Ask make what shell to use
543+  create_file('shell.mk', 'all:;$(info $(SHELL))');
544+  $sh_name = `"$make_path" -sf shell.mk`;
545+  unlink('shell.mk');
546+  $sh_name =~ s/\r?\n$//;
547+  if (! $sh_name) {
548+      print "Cannot determine shell\n";
549+      $is_posix_sh = 0;
550+  } else {
551+      my $o = `"$sh_name" -c ': do nothing' 2>&1`;
552+      $is_posix_sh = $? == 0 && $o eq '';
553+  }
554+
555+  $string = `"$make_path" -v`;
556+  $string =~ /^(GNU Make [^,\n]*)/ or die "$make_path is not GNU Make.  Version:\n$string";
557+  $testee_version = "$1\n";
558+
559+  create_file('null.mk', '');
560+
561+  my $redir = '2>&1';
562+  $redir = '' if os_name eq 'VMS';
563+  $string = `"$make_path" -f null.mk $redir`;
564+  if ($string =~ /(.*): \*\*\* No targets\.  Stop\./) {
565+    $make_name = $1;
566+  } else {
567+    $make_name = $mpf;
568+  }
569+
570+  # prepend pwd if this is a relative path (ie, does not
571+  # start with a slash, but contains one).  Thanks for the
572+  # clue, Roland.
573+
574+  if ($mpd && !File::Spec->file_name_is_absolute($make_path) && $cwdvol eq $mpv) {
575+     $mkpath = File::Spec->catpath($cwdvol, File::Spec->catdir($cwd, $mpd), $mpf);
576+  } else {
577+     $mkpath = $make_path;
578+  }
579+
580+  # Find the helper tool
581+  $helptool = File::Spec->catfile($srcpath, 'thelp.pl');
582+
583+  # It's difficult to quote this properly in all the places it's used so
584+  # ensure it doesn't need to be quoted.
585+  $helptool =~ s,\\,/,g if $port_type eq 'W32';
586+  $helptool =~ s, ,\\ ,g;
587+
588+  # Get Purify log info--if any.
589+
590+  if (exists $ENV{PURIFYOPTIONS}
591+      && $ENV{PURIFYOPTIONS} =~ /.*-logfile=([^ ]+)/) {
592+    $pure_log = $1 || '';
593+    $pure_log =~ s/%v/$make_name/;
594+    $purify_errors = 0;
595+  }
596+
597+  $string = `"$make_path" -j 2 -f null.mk $redir`;
598+  if ($string =~ /not supported/) {
599+    $parallel_jobs = 0;
600+  }
601+  else {
602+    $parallel_jobs = 1;
603+  }
604+
605+  unlink('null.mk');
606+
607+  create_file('features.mk', 'all:;$(info $(.FEATURES))');
608+  %FEATURES = map { $_ => 1 } split /\s+/, `"$make_path" -sf features.mk`;
609+  print "$make_path FEATURES: @{[%FEATURES]}\n" if $verbose;
610+  unlink('features.mk');
611+
612+  # Find the default values for different built-in variables
613+  my $s = "all:;\n";
614+  foreach (keys %DEFVARS) {
615+      $s .= "\$(info $_=\$($_))\n";
616+  }
617+  create_file('defvars.mk', $s);
618+  foreach (split "\n", `"$make_path" -sf defvars.mk`) {
619+      my @e = split /=/, $_, 2;
620+      $DEFVARS{$e[0]} = $e[1];
621+  }
622+  unlink('defvars.mk');
623+
624+  # Set up for valgrind, if requested.
625+
626+  @make_command = ($make_path);
627+
628+  if ($valgrind) {
629+    my $args = $valgrind_args;
630+    open(VALGRIND, "> valgrind.out") or die "Cannot open valgrind.out: $!\n";
631+    #  -q --leak-check=yes
632+    exists $ENV{VALGRIND_ARGS} and $args = $ENV{VALGRIND_ARGS};
633+    @make_command = ('valgrind', '--log-fd='.fileno(VALGRIND));
634+    push(@make_command, split(' ', $args));
635+    push(@make_command, $make_path);
636+    # F_SETFD is 2
637+    fcntl(VALGRIND, 2, 0) or die "fcntl(setfd) failed: $!\n";
638+    system("echo Starting on `date` 1>&".fileno(VALGRIND));
639+    print "Enabled valgrind support.\n";
640+  }
641+
642+  if ($debug) {
643+    print "Port type:    $port_type\n";
644+    print "Make command: @make_command\n";
645+    print "Shell path:   $sh_name".($is_posix_sh ? ' (POSIX)' : '')."\n";
646+    print "#PWD#:        $cwdpath\n";
647+    print "#PERL#:       $perl_name\n";
648+    print "#MAKEPATH#:   $mkpath\n";
649+    print "#MAKE#:       $make_name\n";
650+  }
651+}
652+
653+sub setup_for_test
654+{
655+  $makefile = &get_tmpfile;
656+  if (-f $makefile) {
657+    unlink $makefile;
658+  }
659+
660+  # Get rid of any Purify logs.
661+  if ($pure_log) {
662+    ($pure_testname = $testname) =~ tr,/,_,;
663+    $pure_testname = "$pure_log.$pure_testname";
664+    system("rm -f $pure_testname*");
665+    print("Purify testfiles are: $pure_testname*\n") if $debug;
666+  }
667+}
668+
669+exit !&toplevel;
+283, -0
  1@@ -0,0 +1,283 @@
  2+#                                                              -*-mode: perl-*-
  3+
  4+$description = "Test GNU Make's archive management features.";
  5+
  6+$details = "\
  7+This only works on systems that support it.";
  8+
  9+# If this instance of make doesn't support archives, skip it
 10+exists $FEATURES{archives} or return -1;
 11+
 12+# In theory archive support exists on Windows but it doesn't use ar;
 13+# someone will need to port this test.
 14+$port_type eq 'W32' and return -1;
 15+
 16+# Create some .o files to work with
 17+if ($osname eq 'VMS') {
 18+  # VMS AR needs real object files at this time.
 19+  foreach $afile ('a1', 'a2', 'a3') {
 20+    # Use non-standard extension to prevent implicit rules from recreating
 21+    # objects when the test tampers with the timestamp.
 22+    1 while unlink "$afile.c1";
 23+    1 while unlink "$afile.o";
 24+    create_file("$afile.c1", "int $afile(void) {return 1;}\n");
 25+    system("cc $afile.c1 /object=$afile.o");
 26+  }
 27+} else {
 28+  utouch(-60, qw(a1.o a2.o a3.o));
 29+}
 30+
 31+# Fallback if configure did not find AR
 32+my $ar = get_config('AR') || 'ar';
 33+
 34+my $redir = '2>&1';
 35+$redir = '' if $osname eq 'VMS';
 36+
 37+# This is the value from src/default.c
 38+my $arflags = $osname eq 'aix' ? '-Xany -rv' : '-rv';
 39+my $arvar = "AR=\"$ar\"";
 40+
 41+# Newer versions of binutils can be built with --enable-deterministic-archives
 42+# which forces all timestamps (among other things) to always be 0, defeating
 43+# GNU Make's archive support.  See if ar supports the U option to disable it.
 44+unlink('libxx.a');
 45+$_ = `"$ar" ${arflags}U libxx.a a1.o $redir`;
 46+if ($? == 0) {
 47+    $arflags = "${arflags}U";
 48+    $arvar = "$arvar ARFLAGS=\"$arflags\"";
 49+}
 50+
 51+# Some versions of ar print different things on creation.  Find out.
 52+unlink('libxx.a');
 53+my $created = `"$ar" $arflags libxx.a a1.o $redir`;
 54+$created =~ s/a1\.o/#OBJECT#/g;
 55+
 56+# Some versions of ar print different things on add.  Find out.
 57+my $add = `"$ar" $arflags libxx.a a2.o $redir`;
 58+$add =~ s/a2\.o/#OBJECT#/g;
 59+
 60+# Some versions of ar print different things on replacement.  Find out.
 61+my $repl = `"$ar" $arflags libxx.a a2.o $redir`;
 62+$repl =~ s/a2\.o/#OBJECT#/g;
 63+
 64+unlink('libxx.a');
 65+
 66+# Very simple
 67+($_ = $created) =~ s/#OBJECT#/a1.o/g;
 68+my $answer = "$ar $arflags libxx.a a1.o\n$_";
 69+if ($port_type eq 'VMS-DCL') {
 70+  $answer = 'library /replace libxx.a a1.o';
 71+}
 72+run_make_test('all: libxx.a(a1.o)', $arvar, $answer);
 73+
 74+# Multiple .o's.  Add a new one to the existing library
 75+($_ = $add) =~ s/#OBJECT#/a2.o/g;
 76+
 77+$answer = "$ar $arflags libxx.a a2.o\n$_";
 78+if ($port_type eq 'VMS-DCL') {
 79+  $answer = 'library /replace libxx.a a2.o';
 80+}
 81+run_make_test('all: libxx.a(a1.o a2.o)', $arvar, $answer);
 82+
 83+# Touch one of the .o's so it's rebuilt
 84+if ($port_type eq 'VMS-DCL') {
 85+  # utouch is not changing what VMS library compare is testing for.
 86+  # So do a real change by regenerating the file.
 87+  1 while unlink('a1.o');
 88+  # Later time stamp than last insertion.
 89+  sleep(2);
 90+  system('cc a1.c1 /object=a1.o');
 91+  # Next insertion will have a later timestamp.
 92+  sleep(2);
 93+} else {
 94+  utouch(-40, 'a1.o');
 95+}
 96+
 97+($_ = $repl) =~ s/#OBJECT#/a1.o/g;
 98+$answer = "$ar $arflags libxx.a a1.o\n$_";
 99+if ($port_type eq 'VMS-DCL') {
100+  $answer = 'library /replace libxx.a a1.o';
101+}
102+run_make_test(undef, $arvar, $answer);
103+
104+# Use wildcards
105+$answer = "#MAKE#: Nothing to be done for 'all'.\n";
106+run_make_test('all: libxx.a(*.o)', $arvar, $answer);
107+
108+# Touch one of the .o's so it's rebuilt
109+if ($port_type eq 'VMS-DCL') {
110+  # utouch is not changing what VMS library compare is testing for.
111+  # So do a real change by regenerating the file.
112+  1 while unlink('a1.o');
113+  # Make timestamp later than last insertion.
114+  sleep(2);
115+  system('cc a1.c1 /object=a1.o');
116+} else {
117+  utouch(-30, 'a1.o');
118+}
119+($_ = $repl) =~ s/#OBJECT#/a1.o/g;
120+$answer = "$ar $arflags libxx.a a1.o\n$_";
121+if ($port_type eq 'VMS-DCL') {
122+  $answer = 'library /replace libxx.a a1.o';
123+}
124+run_make_test(undef, $arvar, $answer);
125+
126+# Use both wildcards and simple names
127+if ($port_type eq 'VMS-DCL') {
128+  # utouch is not changing what VMS library compare is testing for.
129+  # So do a real change by regenerating the file.
130+  1 while unlink('a2.o');
131+  sleep(2);
132+  system('cc a2.c1 /object=a2.o');
133+} else {
134+  utouch(-50, 'a2.o');
135+}
136+($_ = $add) =~ s/#OBJECT#/a3.o/g;
137+$_ .= "$ar $arflags libxx.a a2.o\n";
138+($_ .= $repl) =~ s/#OBJECT#/a2.o/g;
139+$answer = "$ar $arflags libxx.a a3.o\n$_";
140+if ($port_type eq 'VMS-DCL') {
141+  $answer = 'library /replace libxx.a a3.o';
142+}
143+
144+run_make_test('all: libxx.a(a3.o *.o)', $arvar, $answer);
145+
146+# Check whitespace handling
147+if ($port_type eq 'VMS-DCL') {
148+  # utouch is not changing what VMS library compare is testing for.
149+  # So do a real change by regenerating the file.
150+  1 while unlink('a2.o');
151+  sleep(2);
152+  system('cc a2.c1 /object=a2.o');
153+} else {
154+  utouch(-40, 'a2.o');
155+}
156+($_ = $repl) =~ s/#OBJECT#/a2.o/g;
157+$answer = "$ar $arflags libxx.a a2.o\n$_";
158+if ($port_type eq 'VMS-DCL') {
159+  $answer = 'library /replace libxx.a a2.o';
160+}
161+run_make_test('all: libxx.a(  a3.o    *.o     )', $arvar, $answer);
162+
163+rmfiles(qw(a1.c1 a2.c1 a3.c1 a1.o a2.o a3.o libxx.a));
164+
165+# Check non-archive targets
166+# See Savannah bug #37878
167+$mk_string = q!
168+all: foo(bar).baz
169+foo(bar).baz: ; @echo '$@'
170+!;
171+
172+if ($port_type eq 'VMS-DCL') {
173+    $mk_string =~ s/echo/write sys\$\$output/;
174+    $mk_string =~ s/\'/\"/g;
175+}
176+run_make_test($mk_string, $arvar, "foo(bar).baz\n");
177+
178+# Check renaming of archive targets.
179+# See Savannah bug #38442
180+
181+mkdir('artest', 0777);
182+touch('foo.vhd');
183+$mk_string = q!
184+DIR = artest
185+vpath % $(DIR)
186+default: lib(foo)
187+(%): %.vhd ; @cd $(DIR) && touch $(*F) && $(AR) $(ARFLAGS) $@ $(*F) >/dev/null 2>&1 && rm $(*F)
188+.PHONY: default
189+!;
190+if ($port_type eq 'VMS-DCL') {
191+  $mk_string =~ s#= artest#= sys\$\$disk:\[.artest\]#;
192+  $mk_string =~ s#lib\(foo\)#lib.tlb\(foo\)#;
193+  $mk_string =~ s#; \@cd#; pipe SET DEFAULT#;
194+  $mk_string =~
195+    s#touch \$\(\*F\)#touch \$\(\*F\) && library/create/text sys\$\$disk:\$\@#;
196+  $mk_string =~
197+    s#library#if f\$\$search(\"\$\@\") \.eqs\. \"\" then library#;
198+  # VMS needs special handling for null extension
199+  $mk_string =~ s#\@ \$\(\*F\)#\@ \$\(\*F\)\.#;
200+  $mk_string =~ s#>/dev/null 2>&1 ##;
201+}
202+run_make_test($mk_string, $arvar, "");
203+
204+run_make_test(undef, $arvar, "#MAKE#: Nothing to be done for 'default'.\n");
205+
206+unlink('foo.vhd');
207+if ($osname eq 'VMS') {
208+  remove_directory_tree("$cwdpath/artest");
209+} else {
210+  remove_directory_tree('artest');
211+}
212+
213+# Check long names for archive members.
214+# See Savannah bug #54395
215+
216+if ($osname ne 'VMS' && $osname ne 'os390') {
217+    my $pre = '1234567890123456';
218+    my $lib = 'libxx.a';
219+    my $cr = $created;
220+    $cr =~ s/#OBJECT#/${pre}a/g;
221+    my $ad = $add;
222+    $ad =~ s/#OBJECT#/${pre}b/g;
223+
224+    run_make_test(qq!
225+# Both member names > 16 characters long
226+default: $lib(${pre}a) $lib(${pre}b)
227+
228+(%): % ; \$(AR) \$(ARFLAGS) \$@ \$%
229+
230+$pre%: ; touch \$\@
231+!,
232+                  $arvar, "touch ${pre}a\n$ar $arflags $lib ${pre}a\n${cr}touch ${pre}b\n$ar $arflags $lib ${pre}b\n${ad}rm ${pre}a ${pre}b\n");
233+
234+    # Run it again; nothing should happen
235+    run_make_test(undef, $arvar, "#MAKE#: Nothing to be done for 'default'.\n");
236+
237+    unlink($lib);
238+}
239+
240+# SV 61436 : Allow redefining archive rules to propagate timestamps
241+
242+# These don't work right on z/OS for some reason: archives not fully supported?
243+
244+if ($osname ne 'os390') {
245+# Find the output when creating an archive from multiple files
246+
247+utouch(-10, 'a.o', 'b.o');
248+my $create2 = `"$ar" $arflags mylib.a a.o b.o $redir`;
249+touch('b.o');
250+my $add2 = `"$ar" $arflags mylib.a b.o $redir`;
251+unlink('a.o', 'b.o', 'mylib.a');
252+
253+# Some systems complain when compiling empty files
254+create_file('a.c', 'int i;');
255+create_file('b.c', 'int j;');
256+utouch(-20, 'a.c', 'b.c');
257+
258+my $cc = get_config('CC') || 'cc';
259+my $vars = "CC=\"$cc\" $arvar";
260+
261+run_make_test(q!
262+mylib.a: mylib.a(a.o b.o)
263+(%): % ;
264+%.a: ; $(AR) $(ARFLAGS) $@ $?
265+%.o : %.c ; @echo Compile $<; $(COMPILE.c) -o $@ $<
266+!,
267+              $vars, "Compile a.c\nCompile b.c\n$ar $arflags mylib.a a.o b.o\n${create2}rm b.o a.o");
268+
269+run_make_test(undef, $vars, "#MAKE#: 'mylib.a' is up to date.");
270+
271+# Now update one of the source files and it should be compiled and archived
272+
273+sleep(2);
274+touch('b.c');
275+
276+run_make_test(undef, $vars, "Compile b.c\n$ar $arflags mylib.a b.o\n${add2}rm b.o");
277+
278+run_make_test(undef, $vars, "#MAKE#: 'mylib.a' is up to date.");
279+
280+unlink('a.c', 'b.c', 'a.o', 'b.o', 'mylib.a');
281+}
282+
283+# This tells the test driver that the perl test script executed properly.
284+1;
+34, -0
 1@@ -0,0 +1,34 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "The following test creates a makefile to test comments\n"
 5+              ."and comment continuation to the next line using a \n"
 6+              ."backslash within makefiles.";
 7+
 8+$details = "To test comments within a makefile, a semi-colon was placed \n"
 9+          ."after a comment was started.  This should not be reported as\n"
10+          ."an error since it is within a comment.  We then continue the \n"
11+          ."comment to the next line using a backslash.  To test whether\n"
12+          ."the comment really continued, we place an echo command with some\n"
13+          ."text on the line which should never execute since it should be \n"
14+          ."within a comment\n";
15+
16+open(MAKEFILE,"> $makefile");
17+
18+# The Contents of the MAKEFILE ...
19+
20+print MAKEFILE <<\EOF;
21+EOF
22+
23+# END of Contents of MAKEFILE
24+
25+close(MAKEFILE);
26+
27+run_make_test(q!
28+# Test comment vs semicolon parsing and line continuation
29+target: # this ; is just a comment \
30+#TAB#@echo This is within a comment.#SPACE#
31+#TAB#@echo There should be no errors for this makefile.
32+!,
33+              '', "There should be no errors for this makefile.\n");
34+
35+1;
+312, -0
  1@@ -0,0 +1,312 @@
  2+#                                                                    -*-perl-*-
  3+$description = "Check GNU Make conditionals.";
  4+
  5+$details = "Attempt various different flavors of GNU Make conditionals.";
  6+
  7+run_make_test(q!
  8+arg1 = first
  9+arg2 = second
 10+arg3 = third
 11+arg4 = cc
 12+arg5 = second
 13+
 14+all:
 15+ifeq ($(arg1),$(arg2))
 16+#TAB#@echo arg1 equals arg2
 17+else
 18+#TAB#@echo arg1 NOT equal arg2
 19+endif
 20+
 21+ifeq '$(arg2)' "$(arg5)"
 22+#TAB#@echo arg2 equals arg5
 23+else
 24+#TAB#@echo arg2 NOT equal arg5
 25+endif
 26+
 27+ifneq '$(arg3)' '$(arg4)'
 28+#TAB#@echo arg3 NOT equal arg4
 29+else
 30+#TAB#@echo arg3 equal arg4
 31+endif
 32+
 33+ifndef undefined
 34+#TAB#@echo variable is undefined
 35+else
 36+#TAB#@echo variable undefined is defined
 37+endif
 38+ifdef arg4
 39+#TAB#@echo arg4 is defined
 40+else
 41+#TAB#@echo arg4 is NOT defined
 42+endif!,
 43+              '',
 44+              'arg1 NOT equal arg2
 45+arg2 equals arg5
 46+arg3 NOT equal arg4
 47+variable is undefined
 48+arg4 is defined');
 49+
 50+
 51+# Test expansion of variables inside ifdef.
 52+
 53+run_make_test(q!
 54+foo = 1
 55+
 56+FOO = foo
 57+F = f
 58+
 59+DEF = no
 60+DEF2 = no
 61+
 62+ifdef $(FOO)
 63+DEF = yes
 64+endif
 65+
 66+ifdef $(F)oo
 67+DEF2 = yes
 68+endif
 69+
 70+
 71+DEF3 = no
 72+FUNC = $1
 73+ifdef $(call FUNC,DEF)3
 74+  DEF3 = yes
 75+endif
 76+
 77+all:; @echo DEF=$(DEF) DEF2=$(DEF2) DEF3=$(DEF3)!,
 78+              '',
 79+              'DEF=yes DEF2=yes DEF3=yes');
 80+
 81+
 82+# Test all the different "else if..." constructs
 83+
 84+run_make_test(q!
 85+arg1 = first
 86+arg2 = second
 87+arg3 = third
 88+arg4 = cc
 89+arg5 = fifth
 90+
 91+result =
 92+
 93+ifeq ($(arg1),$(arg2))
 94+  result += arg1 equals arg2
 95+else ifeq '$(arg2)' "$(arg5)"
 96+  result += arg2 equals arg5
 97+else ifneq '$(arg3)' '$(arg3)'
 98+  result += arg3 NOT equal arg4
 99+else ifndef arg5
100+  result += variable is undefined
101+else ifdef undefined
102+  result += arg4 is defined
103+else
104+  result += success
105+endif
106+
107+
108+all: ; @echo $(result)!,
109+              '',
110+              'success');
111+
112+
113+# Test some random "else if..." construct nesting
114+
115+run_make_test(q!
116+arg1 = first
117+arg2 = second
118+arg3 = third
119+arg4 = cc
120+arg5 = second
121+
122+ifeq ($(arg1),$(arg2))
123+  $(info failed 1)
124+else ifeq '$(arg2)' "$(arg2)"
125+  ifdef undefined
126+    $(info failed 2)
127+  else
128+    $(info success)
129+  endif
130+else ifneq '$(arg3)' '$(arg3)'
131+  $(info failed 3)
132+else ifdef arg5
133+  $(info failed 4)
134+else ifdef undefined
135+  $(info failed 5)
136+else
137+  $(info failed 6)
138+endif
139+
140+.PHONY: all
141+all: ; @:!,
142+              '',
143+              'success');
144+
145+# SV 47960 : ensure variable assignments in non-taken legs don't cause problems
146+run_make_test(q!
147+ifneq ($(FOO),yes)
148+target:
149+else
150+BAR = bar
151+target:
152+endif
153+#TAB#@echo one
154+!,
155+              '', "one\n");
156+
157+# SV 64085: Ensure tab-prefixed conditional directives are warned about
158+# In a future release these will become errors: according to the docs this
159+# was never allowed, but unfortunately the code didn't check for it.
160+my @defcond = ('ifdef', 'ifndef');
161+my @eqcond = ('ifeq', 'ifneq');
162+
163+for my $d (@defcond) {
164+    run_make_test(qq!
165+blah=1
166+#TAB#$d blah
167+endif
168+all:;
169+!,
170+    '', "#MAKEFILE#:3: warning: conditional directive lines cannot start with TAB\n#MAKE#: 'all' is up to date.");
171+}
172+
173+for my $d (@eqcond) {
174+    run_make_test(qq!
175+blah=1
176+#TAB#$d (a,b)
177+endif
178+all:;
179+!,
180+    '', "#MAKEFILE#:3: warning: conditional directive lines cannot start with TAB\n#MAKE#: 'all' is up to date.");
181+}
182+
183+run_make_test(q!
184+ifeq (a, b)
185+#TAB## noop
186+else
187+#TAB#ifeq (a, b)
188+#TAB##TAB## noop
189+#TAB#endif
190+endif
191+
192+all:
193+#TAB#@echo foo
194+!,
195+              '', "#MAKEFILE#:5: warning: conditional directive lines cannot start with TAB\n#MAKEFILE#:7: warning: conditional directive lines cannot start with TAB\nfoo");
196+
197+run_make_test(q!
198+all:
199+
200+$(info hello)
201+ifdef blah
202+junk:
203+#TAB#else
204+else
205+endif
206+!,
207+              '', "hello\n#MAKEFILE#:7: warning: conditional directive lines cannot start with TAB\n#MAKEFILE#:8: *** only one 'else' per conditional.  Stop.",
208+              512);
209+
210+run_make_test(q!
211+blah=1
212+ifdef blah
213+else
214+#TAB#else
215+endif
216+all:;
217+!,
218+              '', "#MAKEFILE#:5: warning: conditional directive lines cannot start with TAB\n#MAKEFILE#:5: *** only one 'else' per conditional.  Stop.",
219+              512);
220+
221+run_make_test(q!
222+blah=1
223+ifdef blah
224+else
225+#TAB#endif
226+endif
227+all:;
228+!,
229+              '', "#MAKEFILE#:5: warning: conditional directive lines cannot start with TAB\n#MAKEFILE#:6: *** extraneous 'endif'.  Stop.",
230+              512);
231+
232+run_make_test(q!
233+blah=1
234+ifdef blah
235+else
236+#TAB#ifdef blah
237+endif
238+all:;
239+!,
240+              '', "#MAKEFILE#:5: warning: conditional directive lines cannot start with TAB\n#MAKEFILE#:8: *** missing 'endif'.  Stop.",
241+              512);
242+
243+run_make_test(q!
244+blah=1
245+all:;
246+foo:
247+ifdef blah
248+#TAB#ifdef blah
249+endif
250+!,
251+    '', "#MAKE#: 'all' is up to date.");
252+
253+run_make_test(q!
254+blah=1
255+all:;
256+foo:
257+ifdef blah
258+#TAB#endif
259+endif
260+!,
261+    '', "#MAKE#: 'all' is up to date.");
262+
263+run_make_test(q!
264+blah=1
265+all:;
266+foo:
267+ifdef blah
268+#TAB#else
269+else
270+endif
271+!,
272+    '', "#MAKE#: 'all' is up to date.");
273+
274+# SV 64402: parse braces in ifeq/ifneq properly
275+
276+run_make_test(q!
277+ifeq ($(and a,b),)
278+endif
279+ifeq (${and a,b},)
280+endif
281+ifeq (${and $(x),${or $(z),${q}}},)
282+endif
283+ifeq (${and ),(},)
284+endif
285+ifeq ($(and },{),)
286+endif
287+# We can hide the comma in a variable
288+C = ,
289+ifeq ((and a$Cb),)
290+endif
291+all:;
292+!,
293+    '', "#MAKE#: 'all' is up to date.");
294+
295+# The "," in "$," is a variable name not a comma
296+run_make_test(q!
297+ifeq ($,,)
298+$(info ok)
299+endif
300+all:;
301+!,
302+    '', "ok\n#MAKE#: 'all' is up to date.");
303+
304+# Without variable references we don't do anything special with parens
305+run_make_test(q!
306+ifeq ((and a,b),)
307+endif
308+all:;
309+!,
310+    '', "#MAKEFILE#:2: extraneous text after 'ifeq' directive\n#MAKE#: 'all' is up to date.");
311+
312+# This tells the test driver that the perl test script executed properly.
313+1;
+44, -0
 1@@ -0,0 +1,44 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "This script tests to make sure that Make looks for
 5+default makefiles in the correct order (GNUmakefile,makefile,Makefile)";
 6+
 7+# Create a makefile called "GNUmakefile"
 8+$makefile = "GNUmakefile";
 9+
10+open(MAKEFILE,"> $makefile");
11+print MAKEFILE "FIRST: ; \@echo It chose GNUmakefile\n";
12+close(MAKEFILE);
13+
14+# Create another makefile called "makefile"
15+open(MAKEFILE,"> makefile");
16+print MAKEFILE "SECOND: ; \@echo It chose makefile\n";
17+close(MAKEFILE);
18+
19+# DOS/W32/MacOSX platforms are case-insensitive / case-preserving, so
20+# Makefile is the same file as makefile.  Just test what we can here.
21+
22+my $case_sensitive = 0;
23+if (! -f 'Makefile') {
24+    # Create another makefile called "Makefile"
25+    $case_sensitive = 1;
26+    open(MAKEFILE,"> Makefile");
27+    print MAKEFILE "THIRD: ; \@echo It chose Makefile\n";
28+    close(MAKEFILE);
29+}
30+
31+run_make_with_options("","",&get_logfile);
32+compare_output("It chose GNUmakefile\n",&get_logfile(1));
33+unlink($makefile);
34+
35+run_make_with_options("","",&get_logfile);
36+compare_output("It chose makefile\n",&get_logfile(1));
37+unlink("makefile");
38+
39+if ($case_sensitive) {
40+    run_make_with_options("","",&get_logfile);
41+    compare_output("It chose Makefile\n",&get_logfile(1));
42+    unlink("Makefile");
43+}
44+
45+1;
+31, -0
 1@@ -0,0 +1,31 @@
 2+#                                                               -*-mode: perl-*-
 3+
 4+$description = "Test the directory cache behavior.";
 5+
 6+# The first wildcard should bring the entire directory into the cache Then we
 7+# create a new file "behind make's back" then see if the next wildcard detects
 8+# it.
 9+
10+run_make_test(q!
11+_orig := $(wildcard ./*)
12+$(shell echo > anewfile)
13+_new := $(wildcard ./*)
14+$(info diff=$(filter-out $(_orig),$(_new)))
15+all:;@:
16+!,
17+              '', "diff=./anewfile\n");
18+
19+rmfiles('anewfile');
20+
21+run_make_test(q!
22+_orig := $(wildcard ./*)
23+$(file >anewfile)
24+_new := $(wildcard ./*)
25+$(info diff=$(filter-out $(_orig),$(_new)))
26+all:;@:
27+!,
28+              '', "diff=./anewfile\n");
29+
30+rmfiles('anewfile');
31+
32+1;
+239, -0
  1@@ -0,0 +1,239 @@
  2+#                                                                    -*-perl-*-
  3+$description = "Test handling of double-colon rules.";
  4+
  5+$details = "\
  6+We test these features:
  7+
  8+  - Multiple commands for the same (double-colon) target
  9+  - Different prerequisites for targets: only out-of-date
 10+    ones are rebuilt.
 11+  - Double-colon targets that aren't the goal target.
 12+
 13+Then we do the same thing for parallel builds: double-colon
 14+targets should always be built serially.";
 15+
 16+# TEST 0: A simple double-colon rule that isn't the goal target.
 17+
 18+run_make_test(q!
 19+all: baz
 20+
 21+foo:: f1.h ; @echo foo FIRST
 22+foo:: f2.h ; @echo foo SECOND
 23+
 24+bar:: ; @echo aaa; sleep 1; echo aaa done
 25+bar:: ; @echo bbb
 26+
 27+baz:: ; @echo aaa
 28+baz:: ; @echo bbb
 29+
 30+biz:: ; @echo aaa
 31+biz:: two ; @echo bbb
 32+
 33+two: ; @echo two
 34+
 35+f1.h f2.h: ; @echo $@
 36+
 37+d :: ; @echo ok
 38+d :: d ; @echo oops
 39+!,
 40+              "all", "aaa\nbbb\n");
 41+
 42+# TEST 1: As above, in parallel
 43+
 44+if ($parallel_jobs) {
 45+  run_make_test(undef, "-j10 all", "aaa\nbbb\n");
 46+}
 47+
 48+# TEST 2: A simple double-colon rule that is the goal target
 49+
 50+run_make_test(undef, "bar", "aaa\naaa done\nbbb\n");
 51+
 52+# TEST 3: As above, in parallel
 53+
 54+if ($parallel_jobs) {
 55+  run_make_test(undef, "-j10 bar", "aaa\naaa done\nbbb\n");
 56+}
 57+
 58+# TEST 4: Each double-colon rule is supposed to be run individually
 59+
 60+&utouch(-5, 'f2.h');
 61+&touch('foo');
 62+
 63+run_make_test(undef, "foo", "f1.h\nfoo FIRST\n");
 64+
 65+# TEST 5: Again, in parallel.
 66+
 67+if ($parallel_jobs) {
 68+  run_make_test(undef, "-j10 foo", "f1.h\nfoo FIRST\n");
 69+}
 70+
 71+# TEST 6: Each double-colon rule is supposed to be run individually
 72+
 73+&utouch(-5, 'f1.h');
 74+unlink('f2.h');
 75+&touch('foo');
 76+
 77+run_make_test(undef, "foo", "f2.h\nfoo SECOND\n");
 78+
 79+# TEST 7: Again, in parallel.
 80+
 81+if ($parallel_jobs) {
 82+  run_make_test(undef, "-j10 foo", "f2.h\nfoo SECOND\n");
 83+}
 84+
 85+# TEST 8: Test circular dependency check; PR/1671
 86+
 87+run_make_test(undef, "d", "ok\n$make_name: circular d <- d dependency dropped\noops\n");
 88+
 89+# TEST 8: I don't grok why this is different than the above, but it is...
 90+#
 91+# Hmm... further testing indicates this might be timing-dependent?
 92+#
 93+#if ($parallel_jobs) {
 94+#  run_make_test(undef, "-j10 biz", "aaa\ntwo\nbbb\n");
 95+#}
 96+
 97+unlink('foo','f1.h','f2.h');
 98+
 99+
100+# TEST 9: make sure all rules in s double colon family get executed
101+#         (Savannah bug #14334).
102+#
103+
104+&touch('one');
105+&touch('two');
106+
107+run_make_test('
108+.RECIPEPREFIX = >
109+.PHONY: all
110+all: result
111+
112+result:: one
113+> @echo $^ >>$@
114+> @echo $^
115+
116+result:: two
117+> @echo $^ >>$@
118+> @echo $^
119+
120+',
121+'',
122+'one
123+two');
124+
125+unlink('result','one','two');
126+
127+# TEST 10: SV 33399 : check for proper backslash handling
128+
129+run_make_test('
130+a\ xb :: ; @echo one
131+a\ xb :: ; @echo two
132+',
133+              '', "one\ntwo\n");
134+
135+# Test 11: SV 44742 : All double-colon rules should be run in parallel build.
136+
137+run_make_test('
138+.RECIPEPREFIX = >
139+result :: 01
140+> @echo update
141+> @touch $@
142+result :: 02
143+> @echo update
144+> @touch $@
145+result :: 03
146+> @echo update
147+> @touch $@
148+result :: 04
149+> @echo update
150+> @touch $@
151+result :: 05
152+> @echo update
153+> @touch $@
154+01 02 03 04 05:
155+> @touch 01 02 03 04 05
156+',
157+              '-j10 result', "update\nupdate\nupdate\nupdate\nupdate\n");
158+
159+unlink('result', '01', '02', '03', '04', '05');
160+
161+# Test 12: SV 44742 : Double-colon rules with parallelism
162+
163+run_make_test('
164+root: all ; echo root
165+all:: ; echo all_one
166+all:: 3 ; echo all_two
167+%: ; sleep $*
168+',
169+              '-rs -j2 1 2 root', "all_one\nall_two\nroot\n");
170+
171+# SV 47995 : Parallel double-colon rules with FORCE
172+
173+run_make_test('
174+all:: ; @echo one
175+
176+all:: joe ; @echo four
177+
178+joe: FORCE ; touch joe-is-forced
179+
180+FORCE:
181+',
182+              '-j5', "one\ntouch joe-is-forced\nfour\n");
183+
184+unlink('joe-is-forced');
185+
186+# sv 60188.
187+# Even though test.x is explicitly mentioned, terminal pattern rules still
188+# apply only if the prerequisite exists.
189+touch('hello.z');
190+
191+# subtest 1. test.x is explicitly mentioned.
192+run_make_test(q!
193+all: hello.z
194+%.z:: test.x ; touch $@
195+%.x: ;
196+!,
197+              '', "#MAKE#: Nothing to be done for 'all'.\n");
198+
199+unlink('hello.z');
200+
201+# subtest 2. hello.x is derived from the stem.
202+touch('hello.z');
203+
204+run_make_test(q!
205+all: hello.z
206+%.z:: %.x; touch $@
207+%.x: ; touch $@
208+!,
209+              '', "#MAKE#: Nothing to be done for 'all'.\n");
210+
211+unlink('hello.z');
212+
213+# subtest 3
214+# hello.x is explicitly mentioned on an unrelated rule and thus is not an
215+# intermediate file.
216+# Terminal pattern rules do not apply anyway and there is no rule to built
217+# 'hello.x'.
218+touch('hello.z');
219+run_make_test(q!
220+all: hello.z
221+%.z:: %.x; touch $@
222+%.x: ;
223+unrelated: hello.x
224+!,
225+              '', "#MAKE#: *** No rule to make target 'hello.x', needed by 'hello.z'.  Stop.\n", 512);
226+
227+# SV 64016.
228+# Test that update_goal_chain moves to the next target while the current
229+# target is being built: hello.x recipe is started and update_goal_chain
230+# begins to update bye.x.
231+
232+run_make_test(q!
233+hello.x::; @#HELPER# -q wait bye.x out $@
234+bye.x::; @#HELPER# sleep 1 file $@
235+!,
236+              '-j2 hello.x bye.x', "sleep 1\nfile bye.x\nhello.x");
237+
238+
239+# This tells the test driver that the perl test script executed properly.
240+1;
+64, -0
 1@@ -0,0 +1,64 @@
 2+#                                                                    -*-perl-*-
 3+$description = "The following test creates a makefile to test command
 4+echoing.  It tests that when a command line starts with
 5+a '\@', the echoing of that line is suppressed.  It also
 6+tests the -n option which tells make to ONLY echo the
 7+commands and no execution happens.  In this case, even
 8+the commands with '\@' are printed. Lastly, it tests the
 9+-s flag which tells make to prevent all echoing, as if
10+all commands started with a '\@'.";
11+
12+$details = "This test is similar to the 'clean' test except that a '\@' has
13+been placed in front of the delete command line.  Four tests
14+are run here.  First, make is run normally and the first echo
15+command should be executed.  In this case there is no '\@' so
16+we should expect make to display the command AND display the
17+echoed message.  Secondly, make is run with the clean target,
18+but since there is a '\@' at the beginning of the command, we
19+expect no output; just the deletion of a file which we check
20+for.  Third, we give the clean target again except this time
21+we give make the -n option.  We now expect the command to be
22+displayed but not to be executed.  In this case we need only
23+to check the output since an error message would be displayed
24+if it actually tried to run the delete command again and the
25+file didn't exist. Lastly, we run the first test again with
26+the -s option and check that make did not echo the echo
27+command before printing the message.\n";
28+
29+$example = "EXAMPLE_FILE";
30+
31+touch($example);
32+
33+# TEST #1
34+# -------
35+
36+run_make_test("
37+all:
38+\techo This makefile did not clean the dir... good
39+clean:
40+\t\@$CMD_rmfile $example\n",
41+              '', 'echo This makefile did not clean the dir... good
42+This makefile did not clean the dir... good');
43+
44+# TEST #2
45+# -------
46+
47+run_make_test(undef, 'clean', '');
48+if (-f $example) {
49+  $test_passed = 0;
50+  unlink($example);
51+}
52+
53+# TEST #3
54+# -------
55+
56+run_make_test(undef, '-n clean', "$CMD_rmfile $example\n");
57+
58+
59+# TEST #4
60+# -------
61+
62+run_make_test(undef, '-s', "This makefile did not clean the dir... good\n");
63+
64+
65+1;
+129, -0
  1@@ -0,0 +1,129 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test ignored failures in recipe command lines";
  5+
  6+run_make_test(qq!
  7+one:
  8+\t-exit 1
  9+\texit 0
 10+two:
 11+\texit 1
 12+\texit 0
 13+!,
 14+              "one", "exit 1\n#MAKE#: [#MAKEFILE#:3: one] Error 1 (ignored)\nexit 0\n");
 15+
 16+# TEST #1
 17+# -------
 18+
 19+run_make_test(undef, " -i two",
 20+              "exit 1\n#MAKE#: [#MAKEFILE#:6: two] Error 1 (ignored)\nexit 0\n");
 21+
 22+# TEST #2
 23+# -------
 24+
 25+# Test that error line offset works
 26+
 27+run_make_test(qq!
 28+all:
 29+\t\@echo hi
 30+\t\@echo there
 31+\t\@exit 1
 32+!,
 33+              '', "hi\nthere\n#MAKE#: *** [#MAKEFILE#:5: all] Error 1", 512);
 34+
 35+# Windows error look completely different :-/
 36+
 37+sub errors_getinfo
 38+{
 39+    my ($cmd, $args, $err) = @_;
 40+    if ($port_type eq 'W32') {
 41+        return (2, "process_begin: CreateProcess(NULL, $cmd$args, ...) failed.\nmake (e=2): The system cannot find the file specified.");
 42+    }
 43+
 44+    if (!$err) { $err = $ERR_no_such_file; }
 45+    return (127, "#MAKE#: $cmd: $err");
 46+}
 47+
 48+# TEST #3
 49+# -------
 50+
 51+# Try failing due to unknown command
 52+my $unk = './foobarbazbozblat';
 53+unlink($unk);
 54+
 55+my ($ernum, $erstr) = errors_getinfo($unk, " xx yy");
 56+run_make_test(qq!
 57+one: ; -$unk xx yy
 58+!, 'one',
 59+              "$unk xx yy\n$erstr\n#MAKE#: [#MAKEFILE#:2: one] Error $ernum (ignored)\n");
 60+
 61+# TEST #4
 62+# -------
 63+
 64+($ernum, $erstr) = errors_getinfo($unk, " aa bb");
 65+run_make_test(qq!
 66+two: ; $unk aa bb
 67+!, 'two -i',
 68+              "$unk aa bb\n$erstr\n#MAKE#: [#MAKEFILE#:2: two] Error $ernum (ignored)\n");
 69+
 70+# TEST #5
 71+# -------
 72+
 73+run_make_test(undef, 'two',
 74+              "$unk aa bb\n$erstr\n#MAKE#: *** [#MAKEFILE#:2: two] Error $ernum\n", 512);
 75+
 76+# SV #56918 : Test the unknown command as the second recipe line
 77+
 78+($ernum, $erstr) = errors_getinfo($unk, " qq rr");
 79+run_make_test(qq!
 80+three:
 81+\t\@echo one
 82+\t$unk qq rr
 83+!, 'three',
 84+              "one\n$unk qq rr\n$erstr\n#MAKE#: *** [#MAKEFILE#:4: three] Error $ernum\n", 512);
 85+
 86+# Try failing due to non-executable file
 87+
 88+if ($ERR_nonexe_file) {
 89+    my $noexe = './barfooblatboz';
 90+    touch($noexe);
 91+
 92+    run_make_test(qq!
 93+    one: ; -$noexe xx yy
 94+    two: ; $noexe aa bb
 95+    !,
 96+                  'one', "$noexe xx yy\n#MAKE#: $noexe: $ERR_nonexe_file\n#MAKE#: [#MAKEFILE#:2: one] Error 127 (ignored)\n");
 97+
 98+    unlink($noexe);
 99+}
100+
101+# Try failing by "running" a directory
102+
103+if ($ERR_exe_dir) {
104+    mkdir('sd', 0775) or print "mkdir: sd: $!\n";
105+
106+    ($ernum, $erstr) = errors_getinfo('sd', '', $ERR_exe_dir);
107+
108+    run_make_test(q!
109+PATH := .
110+all: ; sd
111+!,
112+              '', "sd\n$erstr\n#MAKE#: *** [#MAKEFILE#:3: all] Error $ernum", 512);
113+
114+    if ($port_type eq 'W32') {
115+        $ernum = 5;
116+        $erstr = "process_begin: CreateProcess(NULL, ./sd, ...) failed.\nmake (e=5): Access is denied.";
117+    } else {
118+        $ernum = 127;
119+        $erstr = "#MAKE#: ./sd: $ERR_exe_dir";
120+    }
121+
122+    run_make_test(q!
123+all: ; ./sd
124+!,
125+              '', "./sd\n$erstr\n#MAKE#: *** [#MAKEFILE#:2: all] Error $ernum", 512);
126+
127+    rmdir('sd');
128+}
129+
130+1;
+103, -0
  1@@ -0,0 +1,103 @@
  2+#                                                                    -*-perl-*-
  3+$description = "Test various types of escaping in makefiles.";
  4+
  5+$details = "\
  6+Make sure that escaping of ':' works in target names.
  7+Make sure escaping of whitespace works in target names.
  8+Make sure that escaping of '#' works.
  9+Make sure that backslash before non-special characters are kept.";
 10+
 11+
 12+# TEST 1
 13+
 14+run_make_test(q!
 15+ifdef NOESC
 16+path = pre:
 17+endif
 18+ifdef ONEESC
 19+path = pre\:
 20+endif
 21+ifdef TWOESC
 22+path = pre\\\\:
 23+endif
 24+
 25+$(path)foo : ; @echo "touch ($@)"
 26+
 27+foo\ bar: ; @echo "touch ($@)"
 28+
 29+sharp: foo\#bar.ext
 30+foo\#bar.ext: ; @echo "foo#bar.ext = ($@)"
 31+!,
 32+              '',
 33+              'touch (foo)');
 34+
 35+# TEST 2: This one should fail, since the ":" is unquoted.
 36+
 37+run_make_test(undef,
 38+              'NOESC=1',
 39+              "#MAKEFILE#:12: *** target pattern contains no '%'.  Stop.",
 40+              512);
 41+
 42+# TEST 3: This one should work, since we escape the ":".
 43+
 44+run_make_test(undef,
 45+              'ONEESC=1',
 46+              'touch (pre:foo)');
 47+
 48+# TEST 4: This one should fail, since the escape char is escaped.
 49+
 50+run_make_test(undef,
 51+              'TWOESC=1',
 52+              "#MAKEFILE#:12: *** target pattern contains no '%'.  Stop.",
 53+              512);
 54+
 55+# TEST 5: This one should work
 56+
 57+run_make_test(undef,
 58+              ['foo bar'],
 59+              'touch (foo bar)');
 60+
 61+# TEST 6: Test escaped comments
 62+
 63+run_make_test(undef,
 64+              'sharp',
 65+              'foo#bar.ext = (foo#bar.ext)');
 66+
 67+# Test escaped colons in prerequisites
 68+# Quoting of backslashes in q!! is kind of messy.
 69+# Solaris sh does not properly handle backslashes even in '' so just
 70+# check the output make prints, not what the shell interprets.
 71+run_make_test(q!
 72+foo: foo\\:bar foo\\\\\\:bar foo\\\\\\\\\\:bar
 73+foo foo\\:bar foo\\\\\\:bar foo\\\\\\\\\\:bar: ; : '$@'
 74+!,
 75+              '', ": 'foo:bar'\n: 'foo\\:bar'\n: 'foo\\\\:bar'\n: 'foo'\n");
 76+
 77+# Test backslash before non-special chars: should be kept as-is
 78+
 79+run_make_test(q!
 80+all: ..\foo
 81+.DEFAULT: ; : '$@'
 82+!,
 83+              '', ": '..\\foo'\n");
 84+
 85+# Test escaped comments in variable assignments
 86+run_make_test(q!
 87+self = $1
 88+foo := $(call self,#foo#)#foo
 89+bar := $(call self,\#bar\#)#bar
 90+all:;@echo '$(foo) $(bar)'
 91+!,
 92+               '',"#foo# \\#bar\\#");
 93+
 94+# Test escaped comments in variable assignments in a variable
 95+run_make_test(q!
 96+C = \#
 97+self = $1
 98+foo := $(call self,$Cfoo$C)#foo
 99+all:;@echo '$(foo)'
100+!,
101+               '',"#foo#");
102+
103+# This tells the test driver that the perl test script executed properly.
104+1;
+76, -0
 1@@ -0,0 +1,76 @@
 2+#                                                                    -*-perl-*-
 3+
 4+use warnings;
 5+
 6+my $description = "Test that make can execute binaries as well as scripts with"
 7+                 ." various shabangs and without a shbang";
 8+my $details = "The various shells that this test uses are the default"
 9+             ." /bin/sh, \$SHELL and the perl interpreter that is"
10+             ." executing this test program. The shells are used for the value"
11+             ." of SHELL inside the test makefile and also as a shbang in the"
12+             ." executed script. There is also a test which executes a script"
13+             ." that has no shbang.";
14+
15+# Only bother with this on UNIX systems
16+$port_type eq 'UNIX' or return -1;
17+$^O =~ /cygwin/ and return -1;
18+
19+my @shbangs = ('#!/bin/sh', "#!$perl_name");
20+
21+# The exec in Valgrind's VM doesn't allow starting commands without any shbang
22+$valgrind or push @shbangs, '';
23+
24+my @shells = ('', 'SHELL=/bin/sh');
25+
26+# Try whatever shell the user has, as long as it's not a C shell.
27+# The C shell is not usable with make, due to not correctly handling
28+# file descriptors and possibly other issues.
29+my $usersh = $origENV{SHELL};
30+if ($usersh !~ /csh/) {
31+    push @shbangs, ("#!$usersh");
32+    push @shells, ("SHELL=$usersh");
33+}
34+
35+my $answer = 'hello, world';
36+
37+# tests [0-11]
38+# Have a makefile with various SHELL= exec a shell program with varios
39+# shbangs or without a shbang at all.
40+my $stem = './exec.cmd';
41+my $k = 0;
42+for my $shbang (@shbangs) {
43+    for my $shell (@shells) {
44+        my $cmd = $k ? "$stem.$k" : $stem;
45+        ++$k;
46+        unlink $cmd;
47+        open(CMD,"> $cmd");
48+        print CMD "$shbang\n";
49+        print CMD "printf \"$answer\\n\";\n";
50+        close(CMD);
51+        chmod 0700, $cmd;
52+
53+        run_make_test("# shbang=$shbang\n# shell=$shell" . q!
54+all:; @$(CMD)
55+!, "$shell CMD=$cmd", "$answer\n");
56+
57+        rmfiles($cmd);
58+    }
59+}
60+
61+# tests [12-14]
62+# Exec a binary from a makefile that has SHELL=.
63+for my $shell (@shells) {
64+    run_make_test(q!
65+all:; @#PERL# -e 'printf "$(ANSWER)\n"';
66+!, "$shell ANSWER='$answer'", "$answer\n");
67+}
68+
69+# test 15
70+# Use perl as a shell.
71+run_make_test(q!
72+SHELL = #PERL#
73+.SHELLFLAGS = -e
74+all:; @printf "$(ANSWER)\n";
75+!, "ANSWER='$answer'", "$answer\n");
76+
77+1;
+26, -0
 1@@ -0,0 +1,26 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test variable expansion.";
 5+
 6+# sv 64124.
 7+# Expand a variable whose value exceeds 200 bytes.
 8+# 200 is the initial size of variable_buffer.
 9+# Value bigger than 200 bytes causes a realloc of variable_buffer.
10+# In this test the variable being expanded is MAKEFLAGS and its value occupies
11+# 12, 600 and 120000 bytes.
12+
13+my $s = "hello_world\n";
14+my @mult = (1, 50, 10000);
15+
16+for my $m (@mult) {
17+    my $answer = $s x $m;
18+    $ENV{'MAKEFLAGS'} = " -- hello=$answer";
19+    run_make_test(q!
20+$(info x$(hello)y)
21+all:
22+!,
23+              '', "x${answer}y\n#MAKE#: Nothing to be done for 'all'.\n");
24+}
25+
26+# This tells the test driver that the perl test script executed properly.
27+1;
+210, -0
  1@@ -0,0 +1,210 @@
  2+#                                                                    -*-perl-*-
  3+$description = "Check GNU Make export/unexport commands.";
  4+
  5+$details = "";
  6+
  7+# The test driver cleans out our environment for us so we don't have to worry
  8+# about that here.
  9+
 10+&run_make_test('
 11+FOO = foo
 12+BAR = bar
 13+BOZ = boz
 14+
 15+export BAZ = baz
 16+export BOZ
 17+
 18+BITZ = bitz
 19+BOTZ = botz
 20+
 21+export BITZ BOTZ
 22+unexport BOTZ
 23+
 24+ifdef EXPORT_ALL
 25+export
 26+endif
 27+
 28+ifdef UNEXPORT_ALL
 29+unexport
 30+endif
 31+
 32+ifdef EXPORT_ALL_PSEUDO
 33+.EXPORT_ALL_VARIABLES:
 34+endif
 35+
 36+.RECIPEPREFIX := >
 37+all:
 38+> @echo "FOO=$(FOO) BAR=$(BAR) BAZ=$(BAZ) BOZ=$(BOZ) BITZ=$(BITZ) BOTZ=$(BOTZ)"
 39+> @echo "FOO=$$FOO BAR=$$BAR BAZ=$$BAZ BOZ=$$BOZ BITZ=$$BITZ BOTZ=$$BOTZ"
 40+',
 41+           '', "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
 42+FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n");
 43+
 44+# TEST 1: make sure vars inherited from the parent are exported
 45+
 46+$ENV{FOO} = 1;
 47+
 48+&run_make_test(undef, '', "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
 49+FOO=foo BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n");
 50+
 51+# TEST 2: global export.  Explicit unexport takes precedence.
 52+
 53+run_make_test(undef, "EXPORT_ALL=1" ,
 54+              "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
 55+FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n");
 56+
 57+# TEST 3: global unexport.  Explicit export takes precedence.
 58+
 59+&run_make_test(undef, "UNEXPORT_ALL=1",
 60+               "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
 61+FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n");
 62+
 63+# TEST 4: both: in the above makefile the unexport comes last so that rules.
 64+
 65+&run_make_test(undef, "EXPORT_ALL=1 UNEXPORT_ALL=1",
 66+               "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
 67+FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n");
 68+
 69+# TEST 5: test the pseudo target.
 70+
 71+&run_make_test(undef, "EXPORT_ALL_PSEUDO=1",
 72+               "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
 73+FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n");
 74+
 75+# TEST 6: Test the expansion of variables inside export
 76+
 77+&run_make_test('
 78+foo = f-ok
 79+bar = b-ok
 80+
 81+FOO = foo
 82+F = f
 83+
 84+BAR = bar
 85+B = b
 86+
 87+export $(FOO)
 88+export $(B)ar
 89+
 90+.RECIPEPREFIX := >
 91+all:
 92+> @echo foo=$(foo) bar=$(bar)
 93+> @echo foo=$$foo bar=$$bar
 94+',
 95+             "", "foo=f-ok bar=b-ok\nfoo=f-ok bar=b-ok\n");
 96+
 97+# TEST 7: Test the expansion of variables inside unexport
 98+
 99+&run_make_test('
100+foo = f-ok
101+bar = b-ok
102+
103+FOO = foo
104+F = f
105+
106+BAR = bar
107+B = b
108+
109+export foo bar
110+
111+unexport $(FOO)
112+unexport $(B)ar
113+
114+.RECIPEPREFIX := >
115+all:
116+> @echo foo=$(foo) bar=$(bar)
117+> @echo foo=$$foo bar=$$bar
118+',
119+              '', "foo=f-ok bar=b-ok\nfoo= bar=\n");
120+
121+# TEST 7: Test exporting multiple variables on the same line
122+
123+&run_make_test('
124+A = a
125+B = b
126+C = c
127+D = d
128+E = e
129+F = f
130+G = g
131+H = h
132+I = i
133+J = j
134+
135+SOME = A B C
136+
137+export F G H I J
138+
139+export D E $(SOME)
140+
141+all: ; @echo A=$$A B=$$B C=$$C D=$$D E=$$E F=$$F G=$$G H=$$H I=$$I J=$$J
142+',
143+               '', "A=a B=b C=c D=d E=e F=f G=g H=h I=i J=j\n");
144+
145+# TEST 8: Test unexporting multiple variables on the same line
146+
147+@args{qw(A B C D E F G H I J)} = qw(1 2 3 4 5 6 7 8 9 10);
148+%ENV = (%ENV, %args);
149+
150+&run_make_test('
151+A = a
152+B = b
153+C = c
154+D = d
155+E = e
156+F = f
157+G = g
158+H = h
159+I = i
160+J = j
161+
162+SOME = A B C
163+
164+unexport F G H I J
165+
166+unexport D E $(SOME)
167+
168+all: ; @echo A=$$A B=$$B C=$$C D=$$D E=$$E F=$$F G=$$G H=$$H I=$$I J=$$J
169+',
170+               '', "A= B= C= D= E= F= G= H= I= J=\n");
171+
172+# TEST 9: Check setting a variable named "export"
173+
174+&run_make_test('
175+export = 123
176+export export
177+export export = 456
178+a: ; @echo "\$$(export)=$(export) / \$$export=$$export"
179+',
180+               '', "\$(export)=456 / \$export=456\n");
181+
182+# TEST 10: Check "export" as a target
183+
184+&run_make_test('
185+a: export
186+export: ; @echo "$@"
187+',
188+               '', "export\n");
189+
190+# Check export and assignment of a variable on the same line
191+
192+$ENV{hello} = 'moon';
193+
194+run_make_test(q!
195+all: ; @echo hello=$(hello) hello=$$hello
196+export hello=sun
197+!,
198+              '', "hello=sun hello=sun\n");
199+
200+# Check unexport and assignment of a variable on the same line
201+
202+$ENV{hello} = 'moon';
203+
204+run_make_test(q!
205+all: ; @echo hello=$(hello) hello=$$hello
206+unexport hello=sun
207+!,
208+              '', "hello=sun hello=\n");
209+
210+# This tells the test driver that the perl test script executed properly.
211+1;
+207, -0
  1@@ -0,0 +1,207 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "This test is about grouped multiple targets indicated by &:";
  5+$details = "Here we test for requirements like\n"
  6+          ."- if multiple such targets are updated, the recipe is run once\n"
  7+          ."- parsing issues related to the &: syntax itself\n";
  8+
  9+# Parsing: &: allowed without any targets.
 10+run_make_test(q{
 11+.PHONY: all
 12+&:;
 13+all: ;@printf ''
 14+},
 15+'', "");
 16+
 17+# Parsing: &: works not preceded by whitespace.
 18+run_make_test(q{
 19+foo&:;@echo foo
 20+},
 21+'foo', "foo");
 22+
 23+# Ordinary rule runs recipe four times for t1 t2 t3 t4.
 24+# Grouped target rule runs recipe once; others are considered updated.
 25+run_make_test(q{
 26+.PHONY: t1 t2 t3 t4 g1 g2 g3 g4
 27+t1 t2 t3 t4: ; @echo $@
 28+g1 g2 g3 g4 &: ; @echo $@
 29+},
 30+'t1 t2 t3 t4 g1 g2 g3 g4',
 31+"t1\n"
 32+."t2\n"
 33+."t3\n"
 34+."t4\n"
 35+."g1\n"
 36+."#MAKE#: Nothing to be done for 'g2'.\n"
 37+."#MAKE#: Nothing to be done for 'g3'.\n"
 38+."#MAKE#: Nothing to be done for 'g4'.");
 39+
 40+# Similar to previous test, but targets come from m1 phony
 41+# rather than from the command line. We don't see "Nothing to
 42+# be done for" messages. Also, note reversed order g4 g3 ...
 43+# Thus the auto variable $@ is "g4" when that rule fires.
 44+run_make_test(q{
 45+.PHONY: m1 t1 t2 t3 t4 g1 g2 g3 g4
 46+m1: t1 t2 t3 t4 g4 g3 g2 g1
 47+t1 t2 t3 t4: ; @echo $@
 48+g1 g2 g3 g4&: ; @echo $@
 49+},
 50+'',
 51+"t1\nt2\nt3\nt4\ng4");
 52+
 53+# Set a grouped target recipe for existing targets
 54+run_make_test(q{
 55+.PHONY: M a b
 56+M: a b
 57+a:
 58+a b&: ; @echo Y
 59+b:
 60+},
 61+'',
 62+"Y");
 63+
 64+# grouped targets require a recipe
 65+run_make_test(q{
 66+.PHONY: M a b
 67+M: a b
 68+a b&:
 69+},
 70+'',
 71+"#MAKEFILE#:4: *** grouped targets must provide a recipe.  Stop.", 512);
 72+
 73+# Pattern rules use grouped targets anyway so it's a no-op
 74+run_make_test(q{
 75+.PHONY: M
 76+M: a.q b.q
 77+a.% b.%&: ; @echo Y
 78+},
 79+'',
 80+"Y");
 81+
 82+# Double-colon grouped target rules.
 83+run_make_test(q{
 84+.PHONY: M a b c d e f g h
 85+M: a b
 86+a b c&:: ; @echo X
 87+c d e&:: ; @echo Y
 88+f g h&:: ; @echo Z
 89+},
 90+'',
 91+"X");
 92+
 93+run_make_test(q{
 94+.PHONY: M a b c d e f g h
 95+M: c
 96+a b c&:: ; @echo X
 97+c d e&:: ; @echo Y
 98+f g h&:: ; @echo Z
 99+},
100+'',
101+"X\nY");
102+
103+run_make_test(q{
104+.PHONY: M a b c d e f g h
105+M: a b c d e
106+a b c&:: ; @echo X
107+c d e&:: ; @echo Y
108+f g h&:: ; @echo Z
109+},
110+'',
111+"X\nY");
112+
113+run_make_test(q{
114+.PHONY: M a b c d e f g h
115+M: d e
116+a b c&:: ; @echo X
117+c d e&:: ; @echo Y
118+f g h&:: ; @echo Z
119+},
120+'',
121+"Y");
122+
123+run_make_test(q{
124+.PHONY: M a b c d e f g h
125+M: f g h
126+a b c&:: ; @echo X
127+c d e&:: ; @echo Y
128+f g h&:: ; @echo Z
129+},
130+'',
131+"Z");
132+
133+# sv 60188.
134+# Test that a file explicitly mentioned by the user and made by an implicit
135+# rule is not considered intermediate.
136+
137+touch('hello.z');
138+touch('hello.q');
139+
140+# subtest 1
141+# hello.x is not explicitly mentioned and thus is an intermediate file.
142+run_make_test(q!
143+all: hello.z
144+%.z %.q: %.x ; touch $*.z $*.q
145+%.x: ;
146+!, '', "#MAKE#: Nothing to be done for 'all'.\n");
147+
148+# subtest 2
149+# test.x is explicitly mentioned and thus is not an intermediate file.
150+run_make_test(q!
151+all: hello.z
152+%.z %.q: %.x test.x ; @echo $*.z $*.q
153+%.x: ;
154+!, '', "hello.z hello.q\n");
155+
156+# subtest 3
157+# hello.x is explicitly mentioned on an unrelated rule and thus is not an
158+# intermediate file.
159+run_make_test(q!
160+all: hello.z
161+%.z %.q: %.x; @echo $*.z $*.q
162+%.x: ;
163+unrelated: hello.x
164+!, '', "hello.z hello.q\n");
165+
166+unlink('hello.z');
167+unlink('hello.q');
168+
169+# SV 62809: Missing grouped target peer causes remake regardless of which
170+# target caused the rule to run.
171+touch(qw(gta));  # but not gtb
172+run_make_test(q!
173+gta gtb &: ; touch gta gtb
174+!,
175+              'gta', "touch gta gtb\n");
176+unlink(qw(gta gtb));
177+
178+# Ensure both goal targets are built if they depend on a grouped prereq
179+touch(qw(gta));  # but not gtb
180+run_make_test(q!
181+x1 x2: ; touch $@
182+
183+x1: gta
184+x2: gtb
185+
186+gta gtb &: ; touch gta gtb
187+!,
188+              'x1 x2', "touch gta gtb\ntouch x1\ntouch x2\n");
189+
190+# Now everything should be up to date
191+run_make_test(undef, 'x1 x2',
192+              "#MAKE#: 'x1' is up to date.\n#MAKE#: 'x2' is up to date.");
193+
194+unlink(qw(x1 x2 gta gtb));
195+
196+# If an also-make file is older than a prerequisite build both
197+
198+utouch(-20, 'gtb');
199+utouch(-10, 'pre');
200+touch(qw(gta));
201+run_make_test(q!
202+gta gtb &: pre ; touch gta gtb
203+!,
204+              'gta', "touch gta gtb\n");
205+unlink(qw(pre gta gtb));
206+
207+# This tells the test driver that the perl test script executed properly.
208+1;
  1@@ -0,0 +1,483 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test implicit rule search.";
  5+
  6+$details = "";
  7+
  8+# sv 48643
  9+# Each test has a %.c rule ahead of %.f rule.
 10+# hello.f exists and hello.c is missing.
 11+
 12+unlink('hello.c', 'hello.tsk', 'hello.o', 'hello.x');
 13+
 14+# Run every test with and without a suffix.
 15+my @suffixes = ('', '.o');
 16+# Run every test with single and double colon rules.
 17+my @rules = ('', ':');
 18+
 19+for my $s (@suffixes) {
 20+for my $r (@rules) {
 21+touch('hello.f');
 22+
 23+# Test that make finds the intended implicit rule based on existence of a
 24+# prerequisite in the filesystem.
 25+#
 26+# '%.o: %.c' rule is skipped and '%.o: %.f' rule is chosen.
 27+run_make_test("
 28+all: hello$s
 29+%$s:$r %.c; \$(info hello.c)
 30+%$s:$r %.f; \$(info hello.f)
 31+", '-r', "hello.f\n#MAKE#: Nothing to be done for 'all'.");
 32+
 33+# Test that make finds the intended implicit rule based on the explicit
 34+# prerequisite of the top goal and despite the existence of a
 35+# prerequisite in the filesystem.
 36+#
 37+# hello.c is an explicit prerequisite of the top target (hello.o or hello).
 38+# hello.c ought to exist.
 39+# hello.c prerequisite causes '%.o: %.c' rule to be chosen.
 40+run_make_test("
 41+hello$s: hello.c
 42+%$s:$r %.c; \$(info hello.c)
 43+%$s:$r %.f; \$(info hello.f)
 44+", '-r',
 45+"#MAKE#: *** No rule to make target 'hello.c', needed by 'hello$s'.  Stop.\n",
 46+512);
 47+
 48+# Test that make finds the intended implicit rule when the implicit
 49+# prerequisite matches a target of an unrelated rule and despite the existence
 50+# of a prerequisite of the other rule candidate in the filesystem.
 51+#
 52+# hello.c matches 'hello.c:' rule. This makes hello.c a target and thus ought
 53+# to exist.
 54+# hello.c prerequisite causes '%.o: %.c' rule to be chosen.
 55+run_make_test("
 56+all: hello$s
 57+%$s:$r %.c; \$(info hello.c)
 58+%$s:$r %.f; \$(info hello.f)
 59+hello.c:; @#HELPER# fail 1
 60+", '-r', "fail 1\n#MAKE#: *** [#MAKEFILE#:5: hello.c] Error 1\n", 512);
 61+
 62+# Test that make finds the intended implicit rule based on existence of a
 63+# prerequisite in the filesystem, even when the prerequisite of another
 64+# candidate rule is mentioned explicitly on an unrelated rule.
 65+#
 66+# '%.o: %.c' rule is skipped and '%.o: %.f' rule is chosen, even though hello.c
 67+# is mentioned explicitly on 'unrelated: hello.c'.
 68+# ought-to-exist does not apply to hello.c.
 69+run_make_test("
 70+all: hello$s
 71+%$s:$r %.c; \$(info hello.c)
 72+%$s:$r %.f; \$(info hello.f)
 73+unrelated: hello.c
 74+", '-r', "hello.f\n#MAKE#: Nothing to be done for 'all'.");
 75+
 76+# Test that make finds the intended implicit rule based on existence of a
 77+# prerequisite in the filesystem.
 78+#
 79+# '%.o: %.c' rule is skipped and '%.o: %.f' rule is chosen.
 80+# Despite '%.o: %.c hello.c' rule having explicit prerequisite hello.c.
 81+# ought-to-exist does not apply to hello.c.
 82+run_make_test("
 83+all: hello$s
 84+%$s:$r %.c hello.c; \$(info hello.c)
 85+%$s:$r %.f; \$(info hello.f)
 86+", '-r', "hello.f\n#MAKE#: Nothing to be done for 'all'.");
 87+
 88+# '%.o: %.c' rule is skipped and '%.o: %.f' rule is chosen.
 89+# '%.o: %.f hello.f' rule has explicit prerequisite hello.f.
 90+# ought-to-exist does not apply to hello.c.
 91+run_make_test("
 92+all: hello$s
 93+%$s:$r %.c; \$(info hello.c)
 94+%$s:$r %.f hello.f; \$(info hello.f)
 95+", '-r', "hello.f\n#MAKE#: Nothing to be done for 'all'.");
 96+
 97+# Rule '%: %.f' is chosen, because '%: %.f' requires no intermediates.
 98+# '%: %.c', on the other hand, requires intemediate hello.c to be built by the
 99+# default rule.
100+run_make_test("
101+all: hello$s
102+%$s:$r %.c; \$(info \$<)
103+%$s:$r %.f; \$(info \$<)
104+.DEFAULT:; \$(info \$\@) true
105+unrelated: hello.c
106+", '-r', "hello.f\n#MAKE#: Nothing to be done for 'all'.");
107+
108+
109+# hello.f is missing.
110+# This time both hello.c and hello.f are missing and both '%: %.c' and '%: %.f'
111+# require an intermediate.
112+# The default rule builds intemerdiate hello.c.
113+# '%: %.c' rule is chosen to build hello.
114+unlink('hello.f');
115+run_make_test("
116+all: hello$s
117+%$s:$r %.c; \$(info \$<)
118+%$s:$r %.f; \$(info \$<)
119+.DEFAULT:; \@\$(info \$\@) #HELPER# fail 1
120+unrelated: hello.c
121+", '-r', "hello.c\nfail 1\n#MAKE#: *** [#MAKEFILE#:5: hello.c] Error 1\n", 512);
122+
123+# hello.f is missing.
124+# No rule is found, because hello.c is not mentioned explicitly.
125+run_make_test("
126+all: hello$s
127+%$s:$r %.c; \$(info \$<)
128+%$s:$r %.f; \$(info \$<)
129+.DEFAULT:; \@\$(info \$\@) #HELPER# fail 1
130+", '-r', "hello$s\nfail 1\n#MAKE#: *** [#MAKEFILE#:5: hello$s] Error 1\n", 512);
131+
132+}
133+}
134+
135+# Almost the same tests as above, but this time an intermediate is built.
136+
137+touch('hello.f');
138+for my $s (@suffixes) {
139+for my $r (@rules) {
140+
141+my $result = "#MAKE#: *** No rule to make target 'hello.tsk', needed by 'all'.  Stop.\n";
142+my $rcode = 512;
143+if ($s or $r) {
144+    $result = "hello.f\nhello.tsk\n#MAKE#: Nothing to be done for 'all'.";
145+    $rcode = 0;
146+}
147+
148+run_make_test("
149+all: hello.tsk
150+%.tsk: %$s; \$(info hello.tsk)
151+%$s:$r %.c; \$(info hello.c)
152+%$s:$r %.f; \$(info hello.f)
153+", '-r', "$result", $rcode);
154+
155+run_make_test("
156+all: hello.tsk
157+%.tsk: %$s hello$s; \$(info hello.tsk)
158+%$s:$r %.c; \$(info hello.c)
159+%$s:$r %.f; \$(info hello.f)
160+", '-r', $result, $rcode);
161+
162+run_make_test("
163+all: hello.tsk
164+%.tsk: %$s; \$(info hello.tsk)
165+%$s:$r %.c hello$s; \$(info hello.c)
166+%$s:$r %.f; \$(info hello.f)
167+", '-r', $result, $rcode);
168+
169+}
170+}
171+
172+for my $r (@rules) {
173+
174+# Circular dependency hello.o <- hello.tsk is dropped.
175+run_make_test("
176+all: hello.tsk
177+%.tsk: %.o; \$(info hello.tsk)
178+%.o:$r %.c; \$(info hello.c)
179+%.o:$r %.f %.tsk; \$(info hello.f)
180+", '-r',
181+"#MAKE#: circular hello.o <- hello.tsk dependency dropped\nhello.f\nhello.tsk\n#MAKE#: Nothing to be done for 'all'.");
182+
183+}
184+
185+
186+for my $s (@suffixes) {
187+for my $r (@rules) {
188+
189+run_make_test("
190+all: hello.tsk
191+hello$s: hello.c
192+%.tsk: %$s; \$(info hello.tsk)
193+%$s:$r %.c; \$(info hello.c)
194+%$s:$r %.f; \$(info hello.f)
195+", '-r',
196+"#MAKE#: *** No rule to make target 'hello.c', needed by 'hello$s'.  Stop.\n",
197+512);
198+}
199+}
200+
201+for my $s (@suffixes) {
202+for my $r (@rules) {
203+
204+my $result = "#MAKE#: *** No rule to make target 'hello.tsk', needed by 'all'.  Stop.\n";
205+if ($s or $r) {
206+    $result = "fail 1\n#MAKE#: *** [#MAKEFILE#:6: hello.c] Error 1\n";
207+}
208+
209+run_make_test("
210+all: hello.tsk
211+%.tsk: %$s; \$(info hello.tsk)
212+%$s:$r %.c; \$(info hello.c)
213+%$s:$r %.f; \$(info hello.f)
214+hello.c:; @#HELPER# fail 1
215+", '-r', $result, 512);
216+}
217+}
218+
219+
220+for my $s (@suffixes) {
221+for my $r (@rules) {
222+
223+run_make_test("
224+all: hello.tsk
225+%.tsk: %$s; \$(info hello.tsk)
226+%$s:$r %.c; \$(info hello.c)
227+%$s:$r %.f; \$(info hello.f)
228+unrelated: hello$s
229+", '-r', "hello.f\nhello.tsk\n#MAKE#: Nothing to be done for 'all'.");
230+}
231+}
232+
233+for my $s (@suffixes) {
234+for my $r (@rules) {
235+
236+my $result = "#MAKE#: *** No rule to make target 'hello.tsk', needed by 'all'.  Stop.\n";
237+my $rcode = 512;
238+if ($s or $r) {
239+    $result = "hello.f\nhello.tsk\n#MAKE#: Nothing to be done for 'all'.";
240+    $rcode = 0;
241+}
242+
243+run_make_test("
244+all: hello.tsk
245+%.tsk: %$s; \$(info hello.tsk)
246+%$s:$r %.c; \$(info hello.c)
247+%$s:$r %.f hello.f; \$(info hello.f)
248+", '-r', $result, $rcode);
249+}
250+}
251+
252+# One of the implicit rules has two prerequisites, hello.c and hello.x
253+# hello.c does not qualify as ought to exit.
254+# hello.x can be made from hello.z.
255+# This test exercises the break, which prevents making hello.x as an
256+# intermediate from hello.z during compatibility search.
257+unlink('hello.f');
258+touch('hello.z');
259+for my $s (@suffixes) {
260+for my $r (@rules) {
261+
262+run_make_test("
263+all: hello.tsk
264+%.tsk: %$s; \$(info hello.tsk)
265+%$s:$r %.c %.x; \$(info hello.c)
266+%$s:$r %.f; \$(info hello.f)
267+unrelated: hello$s
268+%.x:$r %.z; \$(info hello.z)
269+", '-r',
270+"#MAKE#: *** No rule to make target 'hello$s', needed by 'hello.tsk'.  Stop.\n",
271+512);
272+}
273+}
274+
275+# Test that prerequisite 'hello.x' mentioned explicitly on an unrelated rule is
276+# not considered intermediate.
277+touch('hello.tsk');
278+unlink('hello.x');
279+run_make_test("
280+all: hello.tsk
281+%.tsk: %.x; touch hello.tsk
282+%.x: ;
283+unrelated: hello.x
284+", '-r', "touch hello.tsk\n");
285+unlink('hello.tsk');
286+
287+touch ('hello.f');
288+# Test implicit search of builtin rules.
289+
290+# %: %.c (and other builtin rules) are skipped.
291+# %: %.f is chosen.
292+run_make_test(q!
293+all: hello
294+!, 'FC="@echo f77" OUTPUT_OPTION=', "f77 hello.f -o hello\n");
295+
296+# %.o: %.c (and other builtin rules) are skipped.
297+# %.o: %.f is chosen.
298+run_make_test(q!
299+all: hello.o
300+!, 'FC="@echo f77" OUTPUT_OPTION=', "f77 -c hello.f\n");
301+
302+
303+# %: %.c is chosen.
304+# hello.c is an explicit prerequisite of the top target hello.
305+# hello.c ought to exist.
306+# hello.c prerequisite causes '%: %.c' rule to be chosen.
307+run_make_test(q!
308+hello: hello.c
309+!, 'FC="@echo f77" OUTPUT_OPTION=',
310+"#MAKE#: *** No rule to make target 'hello.c', needed by 'hello'.  Stop.\n",
311+512);
312+
313+# %.o: %.c is chosen.
314+# hello.c is an explicit prerequisite of the top target hello.o.
315+# hello.c ought to exist.
316+# hello.c prerequisite causes '%.o: %.c' rule to be chosen.
317+run_make_test(q!
318+hello.o: hello.c
319+!, 'FC="@echo f77" OUTPUT_OPTION=',
320+"#MAKE#: *** No rule to make target 'hello.c', needed by 'hello.o'.  Stop.\n",
321+512);
322+
323+# %: %.c (and other builtin rules) are skipped.
324+# %: %.f is chosen.
325+# ought-to-exist does not apply to hello.c.
326+run_make_test(q!
327+all: hello
328+unrelated: hello.c
329+!, 'FC="@echo f77" OUTPUT_OPTION=', "f77 hello.f -o hello\n");
330+
331+# %.o: %.c (and other builtin rules) are skipped.
332+# %.o: %.f is chosen.
333+# ought-to-exist does not apply to hello.c.
334+run_make_test(q!
335+all: hello.o
336+unrelated: hello.c
337+!, 'FC="@echo f77" OUTPUT_OPTION=', "f77 -c hello.f\n");
338+
339+# builtin rule %.o: %.f is removed.
340+# %.o: %.c (and other builtin rules) are skipped, because hello.c is missing.
341+# ought-to-exist does not apply to hello.c.
342+# %.o: %.c is chosen as a compatibility rule, because of hello.c.
343+run_make_test(q!
344+all: hello.o
345+unrelated: hello.c
346+%.o: %.f
347+!, '',
348+"#MAKE#: *** No rule to make target 'hello.c', needed by 'hello.o'.  Stop.\n",
349+512);
350+
351+
352+# sv 17752.
353+# In this test the builtin match-anything rule '%: %.f' is used to build
354+# intermediate hello from hello.f, because hello is mentioned explicitly in
355+# the makefile.
356+run_make_test(q!
357+all: hello.tsk
358+%.tsk: %; $(info $@ from $<)
359+unrelated: hello
360+!, 'FC="@echo f77" OUTPUT_OPTION=',
361+"f77 hello.f -o hello\nhello.tsk from hello\n");
362+
363+# In this test the builtin match-anything rule %: %.f cannot be used to build
364+# intermediate hello from hello.f, because hello is not mentioned explicitly in
365+# the makefile.
366+run_make_test(q!
367+all: hello.tsk
368+%.tsk: %; $(info $@ from $<)
369+!, 'FC="@echo f77" OUTPUT_OPTION=',
370+"#MAKE#: *** No rule to make target 'hello.tsk', needed by 'all'.  Stop.\n",
371+512);
372+
373+# This is just like the one above, but compatibility rule '%.tsk: % %.x' has 2
374+# prerequisites, '%' and '%.x'.
375+# '%' expands to 'hello' and matches the explicit 'hello' on the unrelated rule.
376+# '%.x' is an intermediate built from 'hello.xx' by rule '%.x: %.xx' during the
377+# second pass (intermed_ok == 1) of compatibility search.
378+# This test validates that compatibility search performs both intermed_ok == 0
379+# and intermed_ok == 1 passes.
380+unlink('hello.x');
381+touch('hello.xx');
382+run_make_test(q!
383+all: hello.tsk
384+%.tsk: % %.x; $(info $@ from $^)
385+unrelated: hello
386+%.x: %.xx; $(info $@ from $<)
387+!, 'FC="@echo f77" OUTPUT_OPTION=',
388+"f77 hello.f -o hello\nhello.x from hello.xx\nhello.tsk from hello hello.x\n");
389+
390+unlink('bye.o', 'bye.tsk', 'bye.x');
391+# sv 21670.
392+# Default recipe is used to build bye.o.
393+run_make_test(q!
394+all: bye.tsk
395+%.tsk: %.o; $(info $@ from $<)
396+.DEFAULT:; $(info bye.o)
397+unrelated: bye.o
398+!, '-r', "bye.o\nbye.tsk from bye.o\n#MAKE#: Nothing to be done for 'all'.");
399+
400+touch('bye.xx');
401+# This is just like the one above, but compatibility rule '%.tsk: %.o %.x' has 2
402+# prerequisites, '%.o' and '%.x'.
403+# '%.o' expands to 'bye.o' and matches the explicit 'bye.o' on the unrelated rule.
404+# '%.x' is an intermediate built from 'bye.xx' by rule '%.x: %.xx' during the
405+# second pass (intermed_ok == 1) of compatibility search.
406+# This test validates that compatibility search performs both intermed_ok == 0
407+# and intermed_ok == 1 passes.
408+run_make_test(q!
409+all: bye.tsk
410+%.tsk: %.o %.x; $(info $@ from $^)
411+.DEFAULT:; $(info bye.o)
412+unrelated: bye.o
413+%.x: %.xx; $(info $@ from $<)
414+!, '-r',
415+"bye.o\nbye.x from bye.xx\nbye.tsk from bye.o bye.x\n#MAKE#: Nothing to be done for 'all'.");
416+
417+unlink('hello.f', 'hello.z', 'hello.xx', 'bye.xx');
418+
419+
420+# A target specific variable causes the file to be entered to the database as a
421+# prerequisite. Implicit search then treats this file as explicitly mentioned.
422+# Test that implicit search keeps target specific variables of this file intact.
423+# In this series of tests prerequisite 'hello.x' has a target specific variable
424+# and is built as an intermediate. Implicit search treats 'hello.x' as
425+# explicitly mentioned, but 'hello.x' does not qualify as ought-to-exist.
426+unlink('hello.x', 'hello.tsk');
427+
428+# 'hello.x' is mentioned explicitly on the same implicit rule.
429+run_make_test(q!
430+all: hello.tsk
431+%.tsk: hello.x; $(info $@)
432+%.x:; $(flags)
433+hello.x: flags:=true
434+!, '-r', "true\nhello.tsk\n");
435+
436+# Similar to the one above, but this time 'hello.x' is derived from the stem.
437+run_make_test(q!
438+all: hello.tsk
439+%.tsk: %.x; $(info $@)
440+%.x:; $(flags)
441+hello.x: flags:=true
442+!, '-r', "true\nhello.tsk\n");
443+
444+# Similar to the one above, this time 'hello.x' is also mentioned explicitly on
445+# an unrelated rule.
446+run_make_test(q!
447+all: hello.tsk
448+%.tsk: %.x; $(info $@)
449+%.x:; $(flags)
450+hello.x: flags:=true
451+unrelated: hello.x
452+!, '-r', "true\nhello.tsk\n");
453+
454+# 'hello.x' has a pattern specific variable.
455+run_make_test(q!
456+all: hello.tsk
457+%.tsk: %.x; $(info $@)
458+%.x:; $(flags)
459+%.x: flags:=true
460+!, '-r', "true\nhello.tsk\n");
461+
462+# 'hello.x' has a target specific variable and a pattern specific variable.
463+run_make_test(q!
464+all: hello.tsk
465+%.tsk: %.x; $(info $@)
466+%.x:; $(flags)
467+hello.x: flags+=good
468+%.x: flags:=true
469+!, '-r', "true good\nhello.tsk\n");
470+
471+# Intermediate prerequisite 'hello.x' has a target specific variable, a pattern
472+# specific variable, matches on both rules '%.tsk: %.x' and 'big_%.tsk: %.x'.
473+run_make_test(q!
474+all: hello.tsk big_hello.tsk
475+%.tsk: %.x; $(info $@)
476+big_%.tsk: %.x; $(info $@)
477+%.x:; $(flags)
478+hello.x: flags+=good
479+%.x: flags:=true
480+!, '-r', "true good\nhello.tsk\nbig_hello.tsk\n");
481+
482+
483+# This tells the test driver that the perl test script executed properly.
484+1;
+506, -0
  1@@ -0,0 +1,506 @@
  2+#                                                              -*-mode: perl-*-
  3+
  4+$description = "Test various forms of the GNU Make 'include' command.";
  5+
  6+$details = "\
  7+Test include, -include, sinclude and various regressions involving them.
  8+Test extra whitespace at the end of the include, multiple -includes and
  9+sincludes (should not give an error) and make sure that errors are reported
 10+for targets that were also -included.";
 11+
 12+create_file('incl.mk', "ANOTHER: ; \@echo This is another included makefile\n");
 13+
 14+run_make_test(qq!#Extra space at the end of the following file name
 15+include incl.mk    ! . q!
 16+all: ; @echo There should be no errors for this makefile.
 17+
 18+-include nonexistent.mk
 19+-include nonexistent.mk
 20+sinclude nonexistent.mk
 21+sinclude nonexistent-2.mk
 22+-include makeit.mk
 23+sinclude makeit.mk
 24+
 25+error: makeit.mk
 26+!,
 27+              "all", "There should be no errors for this makefile.\n");
 28+
 29+run_make_test(undef, "ANOTHER", "This is another included makefile\n");
 30+
 31+unlink('incl.mk');
 32+
 33+# Try to build the "error" target; this will fail since we don't know
 34+# how to create makeit.mk, but we should also get a message (even though
 35+# the -include suppressed it during the makefile read phase, we should
 36+# see one during the makefile run phase).
 37+
 38+run_make_test
 39+  ('
 40+-include foo.mk
 41+error: foo.mk ; @echo $@
 42+',
 43+   '',
 44+   "#MAKE#: *** No rule to make target 'foo.mk', needed by 'error'.  Stop.\n",
 45+   512
 46+  );
 47+
 48+# The same as above with an additional include directory.
 49+
 50+mkdir('hellod', 0777);
 51+
 52+run_make_test
 53+  ('
 54+-include foo.mk
 55+error: foo.mk ; @echo $@
 56+',
 57+   '-Ihellod',
 58+   "#MAKE#: *** No rule to make target 'foo.mk', needed by 'error'.  Stop.\n",
 59+   512
 60+  );
 61+
 62+rmdir('hellod');
 63+
 64+# Make sure that target-specific variables don't impact things.  This could
 65+# happen because a file record is created when a target-specific variable is
 66+# set.
 67+
 68+run_make_test
 69+  ('
 70+bar.mk: foo := baz
 71+-include bar.mk
 72+hello: ; @echo hello
 73+',
 74+   '',
 75+   "hello\n"
 76+  );
 77+
 78+
 79+# Test inheritance of dontcare flag when rebuilding makefiles.
 80+#
 81+run_make_test('
 82+.PHONY: all
 83+all: ; @:
 84+
 85+-include foo
 86+
 87+foo: bar; @:
 88+', '', '');
 89+
 90+
 91+# Make sure that we don't die when the command fails but we dontcare.
 92+# (Savannah bug #13216).
 93+#
 94+run_make_test('
 95+.PHONY: all
 96+all:; @:
 97+
 98+-include foo
 99+
100+foo: bar; @:
101+
102+bar:; @exit 1
103+', '', '');
104+
105+# Check include, sinclude, -include with no filenames.
106+# (Savannah bug #1761).
107+
108+run_make_test('
109+.PHONY: all
110+all:; @:
111+include
112+-include
113+sinclude', '', '');
114+
115+
116+# Test that the diagnostics is issued even if the target has been
117+# tried before with the dontcare flag (direct dependency case).
118+#
119+run_make_test('
120+-include foo
121+
122+all: bar
123+
124+foo: baz
125+bar: baz
126+',
127+'',
128+"#MAKE#: *** No rule to make target 'baz', needed by 'bar'.  Stop.\n",
129+512);
130+
131+# Test that the diagnostics is issued even if the target has been
132+# tried before with the dontcare flag (indirect dependency case).
133+#
134+run_make_test('
135+-include foo
136+
137+all: bar
138+
139+foo: baz
140+bar: baz
141+baz: end
142+',
143+'',
144+"#MAKE#: *** No rule to make target 'end', needed by 'baz'.  Stop.\n",
145+512);
146+
147+# Test include of make-able file doesn't show an error (Savannah #102)
148+run_make_test(q!
149+.PHONY: default
150+default:; @echo DONE
151+
152+inc1:; echo > $@
153+include inc1
154+include inc2
155+inc2:; echo > $@
156+!,
157+              '', "echo > inc1\necho > inc2\nDONE\n");
158+
159+rmfiles('inc1', 'inc2');
160+
161+# Test include of make-able file doesn't show an error.
162+# Specify an additional include directory.
163+
164+mkdir('hellod', 0777);
165+
166+run_make_test(q!
167+.PHONY: default
168+default:; @echo DONE
169+
170+inc1:; echo > $@
171+include inc1
172+include inc2
173+inc2:; echo > $@
174+!,
175+              '-Ihellod', "echo > inc1\necho > inc2\nDONE\n");
176+
177+rmfiles('inc1', 'inc2');
178+
179+# Test include of make-able file doesn't show an error.
180+# inc1 and inc2 are present in the specified include directory.
181+touch('hellod/inc1');
182+touch('hellod/inc2');
183+
184+run_make_test(q!
185+.PHONY: default
186+default:; @echo DONE
187+
188+inc1:; echo > $@
189+include inc1
190+include inc2
191+inc2:; echo > $@
192+!,
193+              '-Ihellod', "DONE\n");
194+
195+rmfiles('inc1', 'inc2', 'hellod/inc1', 'hellod/inc2');
196+
197+rmdir('hellod');
198+
199+# No target gets correct error
200+run_make_test("\n", '', '#MAKE#: *** No targets.  Stop.', 512);
201+
202+# No target in included file either, still gets correct error.
203+touch('inc1.mk');
204+run_make_test('include inc1.mk', '', '#MAKE#: *** No targets.  Stop.', 512);
205+rmfiles('inc1.mk');
206+
207+# Include same file multiple times
208+
209+run_make_test(q!
210+default:; @echo DEFAULT
211+include inc1
212+inc1:; echo > $@
213+include inc1
214+!,
215+              '', "echo > inc1\nDEFAULT\n");
216+
217+rmfiles('inc1');
218+
219+if (defined $ERR_no_such_file) {
220+
221+    # Test that the diagnostics is issued even if the target has been
222+    # tried before with the dontcare flag (include/-include case).
223+    #
224+    run_make_test('
225+include bar
226+-include foo
227+
228+all:
229+
230+foo: baz
231+bar: baz
232+baz: end
233+',
234+'',
235+                  "#MAKEFILE#:2: bar: $ERR_no_such_file\n#MAKE#: *** No rule to make target 'end', needed by 'baz'.  Stop.\n",
236+                  512);
237+
238+    # Test include of non-make-able file does show an error (Savannah #102)
239+    run_make_test(q!
240+.PHONY: default
241+default:; @echo DONE
242+
243+inc1:; echo > $@
244+include inc1
245+include inc2
246+!,
247+                  '', "echo > inc1\n#MAKEFILE#:7: inc2: $ERR_no_such_file\n#MAKE#: *** No rule to make target 'inc2'.  Stop.\n", 512);
248+
249+    rmfiles('inc1');
250+
251+    # Included file has a prerequisite that fails to build
252+
253+    run_make_test(q!
254+default:; @echo DEFAULT
255+include inc1
256+inc1: foo; echo > $@
257+foo:; exit 1
258+!,
259+                  '', "exit 1\n#MAKEFILE#:3: inc1: $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:5: foo] Error 1\n", 512);
260+
261+    rmfiles('inc1');
262+
263+    # Included file has a prerequisite we don't know how to build
264+
265+    run_make_test(q!
266+default:; @echo DEFAULT
267+include inc1
268+inc1: foo; echo > $@
269+!,
270+                  '', "#MAKEFILE#:3: inc1: $ERR_no_such_file\n#MAKE#: *** No rule to make target 'foo', needed by 'inc1'.  Stop.\n", 512);
271+
272+    rmfiles('inc1');
273+
274+    # Check that included double-colon targets with no prerequisites aren't
275+    # built.  This should fail as hello.mk doesn't exist
276+
277+    run_make_test(q!
278+.PHONY: default
279+default:;@echo 'FOO=$(FOO)'
280+include hello.mk
281+hello.mk:: ; echo 'FOO=bar' > $@
282+!,
283+                  '', "#MAKEFILE#:4: hello.mk: $ERR_no_such_file", 512);
284+
285+    # Check that included phony targets aren't built.
286+    # This should fail as hello.mk doesn't exist
287+
288+    run_make_test(q!
289+.PHONY: default
290+default:;@echo 'FOO=$(FOO)'
291+include hello.mk
292+hello.mk: ; echo 'FOO=bar' > $@
293+.PHONY: hello.mk
294+!,
295+                  '', "#MAKEFILE#:4: hello.mk: $ERR_no_such_file", 512);
296+}
297+
298+if (defined $ERR_unreadable_file) {
299+    # Including files that can't be read should show an error
300+    unlink('inc1');
301+    create_file('inc1', 'FOO := foo');
302+    chmod 0000, 'inc1';
303+
304+    run_make_test(q!
305+include inc1
306+all:;@echo $(FOO)
307+!,
308+                  '', "#MAKEFILE#:2: inc1: $ERR_unreadable_file\n#MAKE#: *** No rule to make target 'inc1'.  Stop.", 512);
309+
310+    # Including files that can't be read should show an error, even when there
311+    # is a readable file in a subsequent include directory.
312+    mkdir('hellod', 0777);
313+    touch("hellod/inc1");
314+
315+    run_make_test(q!
316+include inc1
317+all:;@echo $(FOO)
318+!,
319+                  '-Ihellod', "#MAKEFILE#:2: inc1: $ERR_unreadable_file\n#MAKE#: *** No rule to make target 'inc1'.  Stop.", 512);
320+
321+    # Unreadable files that we know how to successfully recreate should work
322+
323+    run_make_test(sprintf(q!
324+all:;@echo $(FOO)
325+include inc1
326+inc1:; @%s $@ && echo FOO := bar > $@
327+!, $CMD_rmfile),
328+                  '', "bar");
329+
330+    # Unreadable files that we know how to successfully recreate should work.
331+    # Even when there is a readable file in an additional include directory.
332+
333+    unlink('inc1');
334+    create_file('inc1', 'FOO := foo');
335+    chmod 0000, 'inc1';
336+
337+    run_make_test(sprintf(q!
338+all:;@echo $(FOO)
339+include inc1
340+inc1:; @%s $@ && echo FOO := bar > $@
341+!, $CMD_rmfile),
342+                  '-Ihellod', "bar");
343+
344+    rmfiles('inc1', 'hellod/inc1');
345+    rmdir('hellod');
346+}
347+
348+# Check that the order of remaking include files is correct: should remake
349+# them in the same order they were encountered in the makefile.  SV 58735
350+
351+run_make_test(q!
352+-include i1 i2
353+-include i3
354+-include i4
355+%:;@echo $@
356+all:;
357+!,
358+              '', "i1\ni2\ni3\ni4\n#MAKE#: 'all' is up to date.\n");
359+
360+# Check that included files work if created after the first include failed
361+# https://savannah.gnu.org/bugs/?57676
362+
363+run_make_test(q!
364+default:; @echo $(hello)
365+-include hello.mk
366+$(shell echo hello=world >hello.mk)
367+include hello.mk
368+!,
369+              '', "world\n");
370+
371+unlink('hello.mk');
372+
373+# Check that included double-colon targets with no prerequisites aren't built.
374+# This should succeed since hello.mk already exists
375+
376+touch('hello.mk');
377+
378+run_make_test(q!
379+.PHONY: default
380+default:;@echo 'FOO=$(FOO)'
381+include hello.mk
382+hello.mk:: ; echo 'FOO=bar' > $@
383+!,
384+              '', 'FOO=');
385+
386+unlink('hello.mk');
387+
388+# Check that included double-colon targets with no prerequisites aren't built.
389+# This should succeed due to -include
390+
391+run_make_test(q!
392+.PHONY: default
393+default:;@echo 'FOO=$(FOO)'
394+-include hello.mk
395+hello.mk:: ; echo 'FOO=bar' > $@
396+!,
397+              '', 'FOO=');
398+
399+# Check that phony targets aren't built.
400+# This should succeed since hello.mk already exists
401+
402+touch('hello.mk');
403+
404+run_make_test(q!
405+.PHONY: default
406+default:;@echo 'FOO=$(FOO)'
407+include hello.mk
408+hello.mk: ; echo 'FOO=bar' > $@
409+.PHONY: hello.mk
410+!,
411+              '', 'FOO=');
412+
413+unlink('hello.mk');
414+
415+# Check that included double-colon targets with no prerequisites aren't built.
416+# This should succeed due to -include
417+
418+run_make_test(q!
419+.PHONY: default
420+default:;@echo 'FOO=$(FOO)'
421+-include hello.mk
422+hello.mk: ; echo 'FOO=bar' > $@
423+.PHONY: hello.mk
424+!,
425+              '', 'FOO=');
426+
427+# SV 56301 Verify pattern rules creating optional includes.
428+# -k shouldn't matter when creating include files.
429+
430+run_make_test(q!
431+all:; @echo hello
432+-include inc_a.mk
433+include inc_b.mk
434+%_a.mk %_b.mk:; exit 1
435+!,
436+              '', "exit 1\n#MAKEFILE#:4: failed to remake makefile 'inc_b.mk'", 512);
437+
438+run_make_test(undef, '-k', "exit 1\n#MAKEFILE#:4: failed to remake makefile 'inc_b.mk'", 512);
439+
440+# It seems wrong to me that this gives a different error message, but at
441+# least it doesn't keep going.
442+run_make_test(q!
443+all:; @echo hello
444+include inc_a.mk
445+-include inc_b.mk
446+%_a.mk %_b.mk:; exit 1
447+!,
448+              '', "exit 1\n#MAKEFILE#:3: inc_a.mk: $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:5: inc_a.mk] Error 1\n", 512);
449+
450+run_make_test(undef, '-k', "exit 1\n#MAKEFILE#:3: inc_a.mk: $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:5: inc_a.mk] Error 1\n#MAKEFILE#:3: failed to remake makefile 'inc_a.mk'", 512);
451+
452+# Check the default makefiles... this requires us to invoke make with no
453+# arguments.  Also check MAKEFILES
454+
455+if ($port_type eq 'W32') {
456+    $defaults = "GNUmakefile\nmakefile\nMakefile\nmakefile.mak";
457+} else {
458+    $defaults = "GNUmakefile\nmakefile\nMakefile";
459+}
460+
461+$ENV{MAKEFILES} = 'foobar barfoo';
462+run_make_with_options(undef, ['-E', '%:;@echo $@', '-E', 'all:;', '-E', '-include bizbaz', '-E', '-include bazbiz'], get_logfile(0));
463+$answer = "bizbaz\nbazbiz\nfoobar\nbarfoo\n$defaults\n#MAKE#: 'all' is up to date.\n";
464+&compare_output(subst_make_string($answer), &get_logfile(1));
465+
466+# SV 63516
467+if (exists $FEATURES{'dospaths'}) {
468+    run_make_test(q!
469+include C:__foobar
470+%bar: ; @echo $@
471+all: ;
472+!,
473+                  '', "C:__foobar\n#MAKE#: 'all' is up to date.");
474+}
475+
476+# sv 63484.
477+# Test that included makefiles are not intermediate.
478+# Here 'test.foo' is mentioned explicitly and cannot be considered
479+# intermediate.
480+utouch(-10, 'test.foo');
481+utouch(-5, 'test.x');
482+touch('test');
483+run_make_test(q!
484+.PHONY: force
485+include test.foo
486+%.foo: force; @echo force $@
487+%.x: %.foo; touch $@
488+test: test.x; touch $@
489+!, '', "force test.foo\n#MAKE#: 'test' is up to date.\n");
490+
491+unlink('test.foo', 'test.x', 'test');
492+
493+# Verify that include prefixed by TAB gives a warning
494+
495+my @inctypes = ('include', '-include', 'sinclude');
496+
497+touch('inc.mk');
498+
499+for my $inc (@inctypes) {
500+    run_make_test(qq!
501+#TAB#$inc inc.mk
502+all:;\@echo hi
503+!,
504+                  '', "#MAKEFILE#:2: warning: $inc lines cannot start with TAB\nhi");
505+}
506+
507+1;
+225, -0
  1@@ -0,0 +1,225 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test jobserver.";
  5+
  6+$details = "These tests are ones that specifically are different when the
  7+jobserver feature is available.  Most -j tests are the same whether or not
  8+jobserver is available, and those appear in the 'parallelism' test suite.";
  9+
 10+exists $FEATURES{'jobserver'} or return -1;
 11+
 12+if (!$parallel_jobs) {
 13+  return -1;
 14+}
 15+
 16+# Shorthand
 17+my $np = '--no-print-directory';
 18+my $j1err = "warning: jobserver unavailable: using -j1 (add '+' to parent make rule)";
 19+
 20+# Simple test of MAKEFLAGS settings
 21+run_make_test(q!
 22+SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
 23+recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -f #MAKEFILE# all
 24+all:;@echo $@: "/$(SHOW)/"
 25+!,
 26+              "-j2 $np", "recurse: /-j2 --jobserver-auth=<auth> $np/\nall: /-j2 --jobserver-auth=<auth> $np/\n");
 27+
 28+# Setting parallelism with the environment
 29+# Command line should take precedence over the environment
 30+$ENV{MAKEFLAGS} = "-j2 $np";
 31+run_make_test(q!
 32+SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
 33+recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -f #MAKEFILE# all
 34+all:;@echo $@: "/$(SHOW)/"
 35+!,
 36+              '', "recurse: /-j2 --jobserver-auth=<auth> $np/\nall: /-j2 --jobserver-auth=<auth> $np/\n");
 37+
 38+# Test override of -jN
 39+$ENV{MAKEFLAGS} = "-j9 $np";
 40+run_make_test(q!
 41+SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
 42+recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -j3 -f #MAKEFILE# recurse2
 43+recurse2: ; @echo $@: "/$(SHOW)/"; $(MAKE) -f #MAKEFILE# all
 44+all:;@echo $@: "/$(SHOW)/"
 45+!,
 46+              "-j2 $np", "recurse: /-j2 --jobserver-auth=<auth> $np/\n#MAKE#[1]: warning: -j3 forced in submake: resetting jobserver mode\nrecurse2: /-j3 --jobserver-auth=<auth> $np/\nall: /-j3 --jobserver-auth=<auth> $np/\n");
 47+
 48+# Test override of -jN with -j
 49+run_make_test(q!
 50+SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
 51+recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -j -f #MAKEFILE# recurse2
 52+recurse2: ; @echo $@: "/$(SHOW)/"; $(MAKE) -f #MAKEFILE# all
 53+all:;@echo $@: "/$(SHOW)/"
 54+!,
 55+              "-j2 $np", "recurse: /-j2 --jobserver-auth=<auth> $np/\n#MAKE#[1]: warning: -j0 forced in submake: resetting jobserver mode\nrecurse2: /-j $np/\nall: /-j $np/\n");
 56+
 57+# Don't put --jobserver-auth into a re-exec'd MAKEFLAGS.
 58+# We can't test this directly because there's no way a makefile can
 59+# show the value of MAKEFLAGS we were re-exec'd with.  We can intuit it
 60+# by looking for "disabling jobserver mode" warnings; we should only
 61+# get one from the original invocation and none from the re-exec.
 62+# See Savannah bug #18124
 63+
 64+unlink('inc.mk');
 65+
 66+run_make_test(q!
 67+.RECIPEPREFIX = >
 68+-include inc.mk
 69+recur:
 70+#> @echo 'MAKEFLAGS = $(MAKEFLAGS)'
 71+> @rm -f inc.mk
 72+> @$(MAKE) -j2 -f #MAKEFILE# all
 73+all:
 74+#> @echo 'MAKEFLAGS = $(MAKEFLAGS)'
 75+> @echo $@
 76+inc.mk:
 77+#> @echo 'MAKEFLAGS = $(MAKEFLAGS)'
 78+> @echo 'FOO = bar' > $@
 79+!,
 80+              "$np -j2", "#MAKE#[1]: warning: -j2 forced in submake: resetting jobserver mode\nall\n");
 81+
 82+unlink('inc.mk');
 83+
 84+# Test recursion which is hidden from make.
 85+# See Savannah bug #39934
 86+# Or Red Hat bug https://bugzilla.redhat.com/show_bug.cgi?id=885474
 87+# Environments that don't use a pipe won't close access, so this won't happen.
 88+if ($port_type ne 'W32') {
 89+    create_file('Makefile2', "vpath %.c ../\n", "foo:\n");
 90+
 91+    run_make_test(q!
 92+default: ; @ #MAKEPATH# -f Makefile2
 93+!,
 94+              "--jobserver-style=pipe -j2 $np",
 95+"#MAKE#[1]: $j1err
 96+#MAKE#[1]: Nothing to be done for 'foo'.");
 97+
 98+    rmfiles('Makefile2');
 99+}
100+
101+# For Windows and named pipes, we don't need to worry about recursion
102+if ($port_type eq 'W32' || exists $FEATURES{'jobserver-fifo'}) {
103+  create_file('Makefile2', "vpath %.c ../\n", "foo:\n");
104+
105+  run_make_test(q!
106+default: ; @ #MAKEPATH# -f Makefile2
107+!,
108+              "-j2 $np",
109+"#MAKE#[1]: Nothing to be done for 'foo'.");
110+
111+  rmfiles('Makefile2');
112+}
113+
114+# SV 63981: Don't generat warnings if the user specifically disabled -j
115+
116+run_make_test(q!
117+all: ; @$(MAKE) -C . -f #MAKEFILE# recurse -j1
118+recurse: ; @echo hi
119+!,
120+              '-w -j2', "#MAKE#: Entering directory '#PWD#'
121+#MAKE#[1]: Entering directory '#PWD#'
122+hi
123+#MAKE#[1]: Leaving directory '#PWD#'
124+#MAKE#: Leaving directory '#PWD#'");
125+
126+# Ensure enter/leave directory messages appear before jobserver warnings
127+
128+run_make_test(q!
129+all: ; @$(MAKE) -C . -f #MAKEFILE# recurse -j10
130+recurse: ; @echo hi
131+!,
132+              '-w -j2', "#MAKE#: Entering directory '#PWD#'
133+#MAKE#[1]: Entering directory '#PWD#'
134+#MAKE#[1]: warning: -j10 forced in submake: resetting jobserver mode
135+hi
136+#MAKE#[1]: Leaving directory '#PWD#'
137+#MAKE#: Leaving directory '#PWD#'\n");
138+
139+# Check for invalid jobserver-style options
140+
141+run_make_test(q!
142+all: a
143+all a: ; @echo $@
144+!,
145+              '--jobserver-style=foo -j8',
146+              "#MAKE#: *** unknown jobserver auth style 'foo'.  Stop.", 512);
147+
148+# Ensure the jobserver is not disabled even if only later commands are recursive
149+
150+run_make_test(q!
151+.RECIPEPREFIX := >
152+all:
153+> @echo $@ 1
154+> @echo $@ 2
155+> @$(MAKE) -f #MAKEFILE# recurse
156+
157+recurse: ; @echo $@
158+!,
159+              "$np -j8", "all 1\nall 2\nrecurse");
160+
161+if ($port_type ne 'W32') {
162+    run_make_test(undef, "$np --jobserver-style=pipe -j8",
163+                  "all 1\nall 2\nrecurse");
164+}
165+
166+# And with + instead of $(MAKE)
167+
168+run_make_test(q!
169+.RECIPEPREFIX := >
170+all:
171+> @echo $@ 1
172+> @echo $@ 2
173+> @+#MAKEPATH# -f #MAKEFILE# recurse
174+
175+recurse: ; @echo $@
176+!,
177+              "$np -j8", "all 1\nall 2\nrecurse");
178+
179+if ($port_type ne 'W32') {
180+    run_make_test(undef, "$np --jobserver-style=pipe -j8",
181+                  "all 1\nall 2\nrecurse");
182+}
183+
184+# We can't reset TMPDIR to something invalid when using valgrind
185+if (exists $FEATURES{'jobserver-fifo'} && !$valgrind) {
186+  # sv 62908.
187+  # Test that when mkfifo fails, make switches to pipe and succeeds.
188+  # Force mkfifo to fail by attempting to create a fifo in a non existent
189+  # directory.
190+  # run_make_test does not allow matching a multiline pattern, therefore run
191+  # the test twice.
192+  # First time look for /$ERR_no_such_file/ to ensure mkfifo failed.
193+  # Second time look for /Nothing to be done/ to ensure make succeeded.
194+  $ENV{TMPDIR} = "nosuchdir";
195+  run_make_test("all:\n", '-j2', "/$ERR_no_such_file/");
196+
197+  $ENV{TMPDIR} = "nosuchdir";
198+  run_make_test(undef, '-j2', "/Nothing to be done/");
199+
200+  # Verify that MAKE_TMPDIR is preferred if provided
201+  $ENV{MAKE_TMPDIR} = '.';
202+  $ENV{TMPDIR} = 'nosuchdir';
203+
204+  run_make_test(q!
205+recurse: ; @$(MAKE) -f #MAKEFILE# all
206+all:;@echo "$$MAKEFLAGS"
207+!,
208+              "-j2 --no-print-directory", "/--jobserver-auth=fifo:\\./");
209+
210+  # Verify we fall back to -j1 but continue, of the auth is bad.
211+  $ENV{MAKEFLAGS} = '-j2 --jobserver-auth=fifo:nosuchfile';
212+  run_make_test(q!all:;@echo hi!, "", "#MAKE#: cannot open jobserver nosuchfile: $ERR_no_such_file\n#MAKE#: $j1err\nhi\n");
213+}
214+
215+if ($port_type eq 'UNIX') {
216+    # sv 66499. The specified number of jobs exceeds pipe capacity.
217+    run_make_test(q!
218+all:; $(info hello, world)
219+    !, '-j688777', '/requested job count \(688777\) is larger than system limit/', 512);
220+
221+    run_make_test(q!
222+all:; $(info hello, world)
223+    !, '-j688777 --jobserver-style=pipe', '/requested job count \(688777\) is larger than system limit/', 512);
224+}
225+
226+1;
+184, -0
  1@@ -0,0 +1,184 @@
  2+#                                                                    -*-perl-*-
  3+$description = "Test the load operator.";
  4+
  5+$details = "Test dynamic loading of modules.";
  6+
  7+# Don't do anything if this system doesn't support "load"
  8+exists $FEATURES{'load'} or return -1;
  9+
 10+my $cc = get_config('CC');
 11+if (! $cc) {
 12+    $verbose and print "Skipping load test: no CC defined\n";
 13+    return -1;
 14+}
 15+
 16+# First build a shared object
 17+# Provide both a default and non-default load symbol
 18+
 19+unlink(qw(testload.c testload.so));
 20+
 21+open(my $F, '> testload.c') or die "open: testload.c: $!\n";
 22+print $F <<'EOF' ;
 23+#include "gnumake.h"
 24+
 25+char* getenv (const char*);
 26+
 27+int plugin_is_GPL_compatible;
 28+
 29+int testload_gmk_setup (unsigned int, gmk_floc *);
 30+int explicit_setup (unsigned int, gmk_floc *);
 31+
 32+int
 33+testload_gmk_setup (unsigned int abi, gmk_floc *pos)
 34+{
 35+    (void)abi;
 36+    (void)pos;
 37+    gmk_eval ("TESTLOAD = implicit", 0);
 38+    if (getenv("TESTAPI_KEEP"))
 39+      return -1;
 40+    return 1;
 41+}
 42+
 43+int
 44+explicit_setup (unsigned int abi, gmk_floc *pos)
 45+{
 46+    (void)abi;
 47+    (void)pos;
 48+    gmk_eval ("TESTLOAD = explicit", 0);
 49+    if (getenv("TESTAPI_KEEP"))
 50+      return -1;
 51+    return 1;
 52+}
 53+EOF
 54+close($F) or die "close: testload.c: $!\n";
 55+
 56+# Make sure we can compile
 57+
 58+my $cppflags = get_config('CPPFLAGS') . ($srcdir ? " -I$srcdir/src" : '');
 59+my $cflags = get_config('CFLAGS') . ' -fPIC';
 60+my $ldflags = get_config('LDFLAGS') . ' -shared';
 61+my $sobuild = "\"$cc\" $cppflags $cflags $ldflags -o testload.so testload.c";
 62+
 63+my $clog = `$sobuild 2>&1`;
 64+if ($? != 0) {
 65+    $verbose and print "Failed to build testload.so:\n$sobuild\n$clog";
 66+    return -1;
 67+}
 68+
 69+# TEST 1
 70+run_make_test(q!
 71+PRE := $(.LOADED)
 72+load testload.so
 73+POST := $(.LOADED)
 74+all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
 75+!,
 76+              '--warn-undefined-variables', "pre= post=testload.so implicit\n");
 77+
 78+# TEST 2
 79+# Load using an explicit function
 80+run_make_test(q!
 81+PRE := $(.LOADED)
 82+load ./testload.so(explicit_setup)
 83+POST := $(.LOADED)
 84+all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
 85+!,
 86+              '', "pre= post=testload.so explicit\n");
 87+
 88+# TEST 3
 89+# Check multiple loads
 90+run_make_test(q!
 91+PRE := $(.LOADED)
 92+load ./testload.so
 93+load testload.so(explicit_setup)
 94+POST := $(.LOADED)
 95+all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
 96+!,
 97+              '', "pre= post=testload.so implicit\n");
 98+
 99+# TEST 4
100+# Check auto-rebuild of loaded file that's out of date
101+utouch(-10, 'testload.so');
102+touch('testload.c');
103+
104+run_make_test(q!
105+PRE := $(.LOADED)
106+load ./testload.so
107+POST := $(.LOADED)
108+all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
109+testload.so: testload.c ; @echo "rebuilding $@"; !.$sobuild,
110+              '', "rebuilding testload.so\npre= post=testload.so implicit\n");
111+
112+# TEST 5
113+# Check auto-rebuild of loaded file when it doesn't exist
114+unlink('testload.so');
115+
116+run_make_test(q!
117+PRE := $(.LOADED)
118+-load ./testload.so(explicit_setup)
119+POST := $(.LOADED)
120+all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
121+%.so: %.c ; @echo "rebuilding $@"; !.$sobuild,
122+              '', "rebuilding testload.so\npre= post=testload.so explicit\n");
123+
124+# sv 63044.
125+# Test that the loaded shared object is present in .LOADED when the setup
126+# routine returns -1.
127+$ENV{TESTAPI_KEEP} = 1;
128+run_make_test(q!
129+PRE := $(.LOADED)
130+load testload.so
131+POST := $(.LOADED)
132+all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
133+!,
134+              '--warn-undefined-variables', "pre= post=testload.so implicit\n");
135+
136+# Check that we don't auto-rebuild of loaded file that's out of date
137+# if we return -1 from the setup
138+utouch(-10, 'testload.so');
139+touch('testload.c');
140+
141+$ENV{TESTAPI_KEEP} = 1;
142+run_make_test(q!
143+PRE := $(.LOADED)
144+load ./testload.so
145+POST := $(.LOADED)
146+all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
147+testload.so: testload.c ; @echo "rebuilding $@"; !.$sobuild,
148+              '', "pre= post=testload.so implicit\n");
149+
150+# Check using load as a target or variable name
151+run_make_test(q!
152+load: ; @echo $@
153+-load&: ; @echo $@
154+!,
155+              "", "load\n");
156+
157+run_make_test(q!
158+load : ; @echo $@
159+-load &: ; echo $@
160+!,
161+              "", "load\n");
162+
163+run_make_test(q!
164+load = @echo $@
165+all: ; $(load)
166+load |: ; echo $@
167+!,
168+              "", "all\n");
169+
170+# Verify that load does not start with TAB
171+
172+run_make_test(q!
173+#TAB#load ./testload.so
174+all:;@echo hi
175+!,
176+              '', "#MAKEFILE#:2: warning: load lines cannot start with TAB\nhi\n");
177+
178+run_make_test(q!
179+#TAB#-load ./testload.so
180+all:;@echo hi
181+!,
182+              '', "#MAKEFILE#:2: warning: -load lines cannot start with TAB\nhi\n");
183+
184+# This tells the test driver that the perl test script executed properly.
185+1;
+321, -0
  1@@ -0,0 +1,321 @@
  2+#                                                                    -*-perl-*-
  3+$description = "Test the shared object load API.";
  4+
  5+$details = "Verify the different aspects of the shared object API.";
  6+
  7+# Don't do anything if this system doesn't support "load"
  8+exists $FEATURES{load} or return -1;
  9+
 10+my $cc = get_config('CC');
 11+if (! $cc) {
 12+    $verbose and print "Skipping load test: no CC defined\n";
 13+    return -1;
 14+}
 15+
 16+# First build a shared object
 17+# Provide both a default and non-default load symbol
 18+
 19+unlink(qw(testapi.c testapi.so));
 20+
 21+open(my $F, '> testapi.c') or die "open: testapi.c: $!\n";
 22+print $F <<'EOF' ;
 23+#include <string.h>
 24+#include <stdio.h>
 25+
 26+#include "gnumake.h"
 27+
 28+char *getenv (const char*);
 29+
 30+int plugin_is_GPL_compatible;
 31+
 32+int testapi_gmk_setup (unsigned int abi, const gmk_floc *floc);
 33+
 34+static char *
 35+test_eval (const char *buf)
 36+{
 37+    gmk_eval (buf, 0);
 38+    return NULL;
 39+}
 40+
 41+static char *
 42+test_expand (const char *val)
 43+{
 44+    return gmk_expand (val);
 45+}
 46+
 47+static char *
 48+test_noexpand (const char *val)
 49+{
 50+    char *str = gmk_alloc (strlen (val) + 1);
 51+    strcpy (str, val);
 52+    return str;
 53+}
 54+
 55+static char *
 56+func_test (const char *funcname, unsigned int argc, char **argv)
 57+{
 58+    char *mem;
 59+
 60+    (void)argc;
 61+
 62+    if (strcmp (funcname, "test-expand") == 0)
 63+        return test_expand (argv[0]);
 64+
 65+    if (strcmp (funcname, "test-eval") == 0)
 66+        return test_eval (argv[0]);
 67+
 68+    if (strcmp (funcname, "test-noexpand") == 0)
 69+        return test_noexpand (argv[0]);
 70+
 71+    mem = gmk_alloc (sizeof ("unknown"));
 72+    strcpy (mem, "unknown");
 73+    return mem;
 74+}
 75+
 76+int
 77+testapi_gmk_setup (unsigned int abi, const gmk_floc *floc)
 78+{
 79+    const char *verbose = getenv ("TESTAPI_VERBOSE");
 80+
 81+    (void)abi;
 82+
 83+    gmk_add_function ("test-expand", func_test, 1, 1, GMK_FUNC_DEFAULT);
 84+    gmk_add_function ("test-noexpand", func_test, 1, 1, GMK_FUNC_NOEXPAND);
 85+    gmk_add_function ("test-eval", func_test, 1, 1, GMK_FUNC_DEFAULT);
 86+    gmk_add_function ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.", func_test, 0, 0, 0);
 87+
 88+    if (verbose)
 89+      {
 90+        printf ("testapi_gmk_setup\n");
 91+
 92+        if (verbose[0] == '2')
 93+          printf ("%s:%lu\n", floc->filenm, floc->lineno);
 94+      }
 95+
 96+    if (getenv ("TESTAPI_KEEP"))
 97+      return -1;
 98+
 99+    return 1;
100+}
101+
102+int
103+alternative_setup ()
104+{
105+    gmk_add_function ("test-expand", func_test, 1, 1, GMK_FUNC_DEFAULT);
106+    gmk_add_function ("test-noexpand", func_test, 1, 1, GMK_FUNC_NOEXPAND);
107+    gmk_add_function ("test-eval", func_test, 1, 1, GMK_FUNC_DEFAULT);
108+    gmk_add_function ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.", func_test, 0, 0, 0);
109+
110+    if (getenv ("TESTAPI_VERBOSE"))
111+      printf ("alternative_setup\n");
112+
113+    if (getenv ("TESTAPI_KEEP"))
114+      return -1;
115+
116+    return 1;
117+}
118+
119+void
120+testapi_gmk_unload ()
121+{
122+    const char *s = getenv ("TESTAPI_VERBOSE");
123+    if (s && *s == '3')
124+      printf ("testapi_gmk_unload\n");
125+}
126+
127+EOF
128+close($F) or die "close: testapi.c: $!\n";
129+
130+# Make sure we can compile
131+
132+my $cflags = get_config('CFLAGS');
133+my $cppflags = get_config('CPPFLAGS');
134+my $ldflags = get_config('LDFLAGS');
135+my $sobuild = "\"$cc\" ".($srcdir? "-I$srcdir/src":'')." $cppflags $cflags -shared -fPIC $ldflags -o testapi.so testapi.c";
136+
137+my $clog = `$sobuild 2>&1`;
138+if ($? != 0) {
139+    $verbose and print "Failed to build testapi.so:\n$sobuild\n$_";
140+    return -1;
141+}
142+
143+# TEST 1
144+# Check the gmk_expand() function
145+run_make_test(q!
146+EXPAND = expansion
147+all: ; @echo $(test-expand $$(EXPAND))
148+load testapi.so
149+!,
150+              '', "expansion\n");
151+
152+# TEST 2
153+# Check the eval operation.  Prove that the argument is expanded only once
154+run_make_test(q!
155+load testapi.so
156+TEST = bye
157+ASSIGN = VAR = $(TEST) $(shell echo there)
158+$(test-eval $(value ASSIGN))
159+TEST = hi
160+all:;@echo '$(VAR)'
161+!,
162+              '', "hi there\n");
163+
164+# TEST 2
165+# Check the no-expand capability
166+run_make_test(q!
167+load testapi.so
168+TEST = hi
169+all:;@echo '$(test-noexpand $(TEST))'
170+!,
171+              '', "\$(TEST)\n");
172+
173+
174+# During all subsequent tests testapi.so exists.
175+#
176+my @loads = ('', q!
177+load testapi.so
178+load testapi.so
179+-load testapi.so
180+-load testapi.so
181+$(eval load testapi.so)
182+$(eval -load testapi.so)
183+!);
184+
185+for my $extra_loads (@loads) {
186+my $n = 5;
187+if ($extra_loads) {
188+  $n = 12;
189+}
190+# sv 63045.
191+# Test that having unloaded a shared object make loads it again, even if the
192+# shared object is not updated.
193+$ENV{TESTAPI_VERBOSE} = 1;
194+run_make_test("
195+load testapi.so
196+$extra_loads
197+all:; \$(info \$(test-expand hello))
198+testapi.so: force; \$(info \$@)
199+force:;
200+.PHONY: force
201+", '', "testapi_gmk_setup\ntestapi.so\ntestapi_gmk_setup\nhello\n#MAKE#: 'all' is up to date.\n");
202+
203+# sv 63045.
204+# Same as above, but testapi_gmk_setup returned -1.
205+$ENV{TESTAPI_KEEP} = 1;
206+$ENV{TESTAPI_VERBOSE} = 1;
207+run_make_test("
208+load testapi.so
209+$extra_loads
210+all:; \$(info \$(test-expand hello))
211+testapi.so: force; \$(info \$@)
212+force:;
213+.PHONY: force
214+", '', "testapi_gmk_setup\nhello\n#MAKE#: 'all' is up to date.\n");
215+
216+# sv 63045.
217+# Test that make exits, unless make can successfully update an unloaded shared
218+# object.
219+$ENV{TESTAPI_VERBOSE} = 1;
220+run_make_test("
221+load testapi.so
222+$extra_loads
223+all:; \$(info \$(test-expand hello))
224+testapi.so: force; @#HELPER# fail 1
225+force:;
226+.PHONY: force
227+", '', "testapi_gmk_setup\nfail 1\n#MAKE#: *** [#MAKEFILE#:$n: testapi.so] Error 1\n", 512);
228+
229+# sv 63045.
230+# Same as above, but testapi_gmk_setup returned -1.
231+$ENV{TESTAPI_KEEP} = 1;
232+$ENV{TESTAPI_VERBOSE} = 1;
233+run_make_test("
234+load testapi.so
235+$extra_loads
236+all:; \$(info \$(test-expand hello))
237+testapi.so: force; @#HELPER# fail 1
238+force:;
239+.PHONY: force
240+", '', "testapi_gmk_setup\nhello\n#MAKE#: 'all' is up to date.\n");
241+
242+# sv 63100.
243+# Test that make supplies the correct floc when the shared object is loaded
244+# again.
245+$ENV{TESTAPI_VERBOSE} = 2;
246+run_make_test("
247+load testapi.so
248+$extra_loads
249+all:; \$(info \$(test-expand hello))
250+testapi.so: force; \$(info \$@)
251+force:;
252+.PHONY: force
253+", '', "testapi_gmk_setup\n#MAKEFILE#:2\ntestapi.so\ntestapi_gmk_setup\n#MAKEFILE#:2\nhello\n#MAKE#: 'all' is up to date.\n");
254+}
255+
256+my @names  = ('testapi.so', './testapi.so', '#PWD#/testapi.so');
257+
258+for my $name (@names) {
259+
260+# Test the make correctly figures out the name of the close function and runs
261+# the close function.
262+$ENV{TESTAPI_VERBOSE} = 3;
263+run_make_test("
264+load $name
265+all:; \$(info \$(test-expand hello))
266+", '', "testapi_gmk_setup\nhello\n#MAKE#: 'all' is up to date.\ntestapi_gmk_unload\n");
267+}
268+
269+# Same as above, but the setup function is custom.
270+@names  = ('testapi.so(alternative_setup)', './testapi.so(alternative_setup)',
271+           '#PWD#/testapi.so(alternative_setup)');
272+for my $name (@names) {
273+
274+# Test the close function.
275+$ENV{TESTAPI_VERBOSE} = 3;
276+run_make_test("
277+load $name
278+all:; \$(info \$(test-expand hello))
279+", '', "alternative_setup\nhello\n#MAKE#: 'all' is up to date.\ntestapi_gmk_unload\n");
280+}
281+
282+# Test that makes runs the close function on failure.
283+$ENV{TESTAPI_VERBOSE} = 3;
284+run_make_test(q!
285+load testapi.so
286+all: bad_preqreq; :
287+!, '', "testapi_gmk_setup\n#MAKE#: *** No rule to make target 'bad_preqreq', needed by 'all'.  Stop.\ntestapi_gmk_unload\n", 512);
288+
289+# Test that make unloads a shared object, calls the close function, loads
290+# the plugin again, and then calls the close function again on exit.
291+&utouch(-10, 'testapi.so');
292+$ENV{TESTAPI_VERBOSE} = 3;
293+run_make_test("
294+load testapi.so
295+all:; \$(info \$(test-expand hello))
296+testapi.so: testapi.c; $sobuild
297+", '', "testapi_gmk_setup\ntestapi_gmk_unload\n$sobuild\ntestapi_gmk_setup\nhello\n#MAKE#: 'all' is up to date.\ntestapi_gmk_unload");
298+
299+# Test that make unloads a shared object, calls the close function, loads
300+# the plugin again, and then calls the close function again on exit.
301+$ENV{TESTAPI_VERBOSE} = 3;
302+run_make_test(q!
303+load testapi.so
304+all:; $(info $(test-expand hello))
305+testapi.so: force; $(info $@)
306+force:;
307+.PHONY: force
308+!, '', "testapi_gmk_setup\ntestapi_gmk_unload\ntestapi.so\ntestapi_gmk_setup\nhello\n#MAKE#: 'all' is up to date.\ntestapi_gmk_unload\n");
309+
310+unlink(qw(testapi.c testapi.so)) unless $keep;
311+
312+# Test that make does not run the close function, unless the shared object
313+# loaded successfully.
314+unlink('testapi.so');
315+$ENV{TESTAPI_VERBOSE} = 3;
316+run_make_test(q!
317+load testapi.so
318+all:; :
319+!, '', "#MAKEFILE#:2: testapi.so: cannot open shared object file: $ERR_no_such_file\n#MAKEFILE#:2: *** testapi.so: failed to load.  Stop.\n", 512);
320+
321+# This tells the test driver that the perl test script executed properly.
322+1;
+90, -0
 1@@ -0,0 +1,90 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "\
 5+The following test creates a makefile to test the presence
 6+of multiple rules for one target.  One file can be the
 7+target of several rules if at most one rule has commands;
 8+the other rules can only have dependencies.";
 9+
10+$details = "\
11+The makefile created in this test contains two hardcoded rules
12+for foo.o and bar.o.  It then gives another multiple target rule
13+with the same names as above but adding more dependencies.
14+Additionally, another variable extradeps is listed as a
15+dependency but is defined to be null.  It can however be defined
16+on the make command line as extradeps=extra.h which adds yet
17+another dependency to the targets.";
18+
19+open(MAKEFILE,"> $makefile");
20+
21+# The Contents of the MAKEFILE ...
22+
23+print MAKEFILE <<EOF;
24+objects = foo.o bar.o
25+foo.o : defs.h
26+bar.o : defs.h test.h
27+extradeps =
28+\$(objects) : config.h \$(extradeps)
29+\t\@echo EXTRA EXTRA
30+EOF
31+
32+# END of Contents of MAKEFILE
33+
34+close(MAKEFILE);
35+
36+&touch("defs.h","test.h","config.h");
37+
38+if ($vos)
39+{
40+   $error_code = 3307;
41+}
42+else
43+{
44+   $error_code = 512;
45+}
46+
47+&run_make_with_options($makefile,
48+                       "extradeps=extra.h",
49+                       &get_logfile,
50+                       $error_code);
51+
52+# Create the answer to what should be produced by this Makefile
53+$answer = "$make_name: *** No rule to make target 'extra.h', needed by 'foo.o'.  Stop.\n";
54+
55+&compare_output($answer,&get_logfile(1));
56+
57+
58+# TEST #2
59+# -------
60+
61+&touch("extra.h");
62+
63+&run_make_with_options($makefile,
64+                       "extradeps=extra.h",
65+                       &get_logfile,
66+                       0);
67+
68+# Create the answer to what should be produced by this Makefile
69+$answer = "EXTRA EXTRA\n";
70+
71+&compare_output($answer,&get_logfile(1));
72+
73+unlink("defs.h","test.h","config.h","extra.h");
74+
75+# sv 62650.
76+# Test the message that make prints when a file found by directory search
77+# is preferred over the local one.
78+run_make_test(q!
79+vpath hello.c src
80+all: hello.c; $(info $@ from $^)
81+hello.c: ; $(info 1 $@)
82+src/hello.c: ; $(info 2 $@)
83+!, '',
84+    "#MAKEFILE#:4: recipe was specified for file 'hello.c' at #MAKEFILE#:4,
85+#MAKEFILE#:4: but 'hello.c' is now considered the same file as 'src/hello.c'
86+#MAKEFILE#:4: recipe for 'hello.c' will be ignored in favor of the one for 'src/hello.c'
87+2 src/hello.c
88+all from src/hello.c
89+#MAKE#: 'all' is up to date.\n");
90+
91+1;
+46, -0
 1@@ -0,0 +1,46 @@
 2+$description = "The following test creates a makefile to test that a \n "
 3+              ."rule with multiple targets is equivalent to writing \n"
 4+              ."many rules, each with one target, and all identical aside\n"
 5+              ."from that.";
 6+
 7+$details = "A makefile is created with one rule and two targets.  Make \n"
 8+          ."is called twice, once for each target, and the output which \n"
 9+          ."contains the target name with \$@ is looked at for the changes.\n"
10+          ."This test also tests the substitute function by replacing \n"
11+          ."the word output with nothing in the target name giving either\n"
12+          ."an output of \"I am little\" or \"I am big\"";  
13+
14+open(MAKEFILE,"> $makefile");
15+
16+# The Contents of the MAKEFILE ...
17+
18+print MAKEFILE "bigoutput littleoutput: test.h\n";
19+print MAKEFILE "\t\@echo I am \$(subst output,,\$@)\n";  
20+
21+# END of Contents of MAKEFILE
22+
23+close(MAKEFILE);
24+
25+&touch("test.h");
26+
27+&run_make_with_options($makefile,"bigoutput",&get_logfile);
28+
29+
30+# Create the answer to what should be produced by this Makefile
31+$answer = "I am big\n";
32+
33+&compare_output($answer,&get_logfile(1));
34+
35+&run_make_with_options($makefile,"littleoutput",&get_logfile);
36+$answer = "I am little\n";
37+&compare_output($answer,&get_logfile(1));
38+
39+unlink "test.h";
40+
41+1;
42+
43+
44+
45+
46+
47+
+118, -0
  1@@ -0,0 +1,118 @@
  2+#                                                                    -*-perl-*-
  3+$description = "Test order-only prerequisites.";
  4+
  5+$details = "\
  6+Create makefiles with various combinations of normal and order-only
  7+prerequisites and ensure they behave properly.  Test the \$| variable.";
  8+
  9+# Basics
 10+
 11+run_make_test('
 12+%r: | baz ; @echo $< $^ $|
 13+bar: foo
 14+foo:;@:
 15+baz:;@:',
 16+              '', "foo foo baz\n");
 17+
 18+# First try: the order-only prereqs need to be built.
 19+
 20+run_make_test(q!
 21+foo: bar | baz
 22+#TAB#@echo '$$^ = $^'
 23+#TAB#@echo '$$| = $|'
 24+#TAB#touch $@
 25+
 26+.PHONY: baz
 27+
 28+bar baz:
 29+#TAB#touch $@!,
 30+              '', "touch bar\ntouch baz\n\$^ = bar\n\$| = baz\ntouch foo\n");
 31+
 32+
 33+# now we do it again: baz is PHONY but foo should _NOT_ be updated
 34+
 35+run_make_test(undef, '', "touch baz\n");
 36+
 37+unlink(qw(foo bar baz));
 38+
 39+# Make sure the order-only prereq was promoted to normal.
 40+
 41+run_make_test(q!
 42+foo: bar | baz
 43+#TAB#@echo '$$^ = $^'
 44+#TAB#@echo '$$| = $|'
 45+#TAB#touch $@
 46+
 47+foo: baz
 48+
 49+.PHONY: baz
 50+
 51+bar baz:
 52+#TAB#touch $@!,
 53+              '', "touch bar\ntouch baz\n\$^ = bar baz\n\$| = \ntouch foo\n");
 54+
 55+
 56+# now we do it again
 57+
 58+run_make_test(undef, '', "touch baz\n\$^ = bar baz\n\$| = \ntouch foo\n");
 59+
 60+unlink(qw(foo bar baz));
 61+
 62+# Test empty normal prereqs
 63+
 64+# make sure the parser was correct.
 65+
 66+run_make_test(q!
 67+foo:| baz
 68+#TAB#@echo '$$^ = $^'
 69+#TAB#@echo '$$| = $|'
 70+#TAB#touch $@
 71+
 72+.PHONY: baz
 73+
 74+baz:
 75+#TAB#touch $@!,
 76+              '', "touch baz\n\$^ = \n\$| = baz\ntouch foo\n");
 77+
 78+# now we do it again: this time foo won't be built
 79+
 80+run_make_test(undef, '', "touch baz\n");
 81+
 82+unlink(qw(foo baz));
 83+
 84+# Test order-only in pattern rules
 85+
 86+# make sure the parser was correct.
 87+
 88+run_make_test(q!
 89+%.w : %.x | baz
 90+#TAB#@echo '$$^ = $^'
 91+#TAB#@echo '$$| = $|'
 92+#TAB#touch $@
 93+
 94+all: foo.w
 95+
 96+.PHONY: baz
 97+foo.x baz:
 98+#TAB#touch $@!,
 99+              '',
100+              "touch foo.x\ntouch baz\n\$^ = foo.x\n\$| = baz\ntouch foo.w\n");
101+
102+# now we do it again: this time foo.w won't be built
103+
104+run_make_test(undef, '', "touch baz\n");
105+
106+unlink(qw(foo.w foo.x baz));
107+
108+# make sure that $< is set correctly in the face of order-only
109+# prerequisites in pattern rules.
110+
111+run_make_test('
112+%r: | baz ; @echo $< $^ $|
113+bar: foo
114+foo:;@:
115+baz:;@:',
116+              '', "foo foo baz\n");
117+
118+
119+1;
+403, -0
  1@@ -0,0 +1,403 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test --output-sync (-O) option.";
  5+
  6+$details = "Test the synchronization of output from parallel jobs.";
  7+
  8+# If we don't have output sync support, never mind.
  9+exists $FEATURES{'output-sync'} or return -1;
 10+
 11+# Output sync can't be tested without parallelization
 12+$parallel_jobs or return -1;
 13+
 14+
 15+# The following subdirectories with Makefiles are used in several
 16+# of the following tests.  The model is:
 17+#   foo/Makefile - has a "foo" target that waits for the bar target
 18+#   bar/Makefile - has a "bar" target that runs immediately
 19+#                - has a "baz" target that waits for the foo target
 20+#
 21+# So, you start the two sub-makes in parallel and first the "bar" target is
 22+# built, followed by "foo", followed by "baz".  The trick is that first each
 23+# target prints a "start" statement, then waits (if appropriate), then prints
 24+# an end statement.  Thus we can tell if the -O flag is working, since
 25+# otherwise these statements would be mixed together.
 26+
 27+@syncfiles = ();
 28+
 29+sub output_sync_clean {
 30+    rmfiles('foo/Makefile', 'bar/Makefile', @syncfiles);
 31+    rmdir('foo');
 32+    rmdir('bar');
 33+}
 34+
 35+# We synchronize the different jobs by having them wait for a sentinel file to
 36+# be created, instead of relying on a certain amount of time passing.
 37+# Unfortunately in this test we have to sleep after we see the sync file,
 38+# since we also want to make the obtaining of the write synchronization lock
 39+# reliable.  If things are too fast, then sometimes a different job will steal
 40+# the output sync lock and the output is mis-ordered from what we expect.
 41+sub output_sync_wait {
 42+    return subst_make_string("#HELPER# \$Q wait ../mksync.$_[0] sleep 1");
 43+}
 44+sub output_sync_set {
 45+    return subst_make_string("#HELPER# \$Q file ../mksync.$_[0]");
 46+}
 47+
 48+@syncfiles = qw(mksync.foo mksync.foo_start mksync.bar mksync.bar_start);
 49+
 50+$tmout = 30;
 51+
 52+output_sync_clean();
 53+mkdir('foo', 0777);
 54+mkdir('bar', 0777);
 55+
 56+$set_foo = output_sync_set('foo');
 57+$set_bar = output_sync_set('bar');
 58+$set_foo_start = output_sync_set('foo_start');
 59+$set_bar_start = output_sync_set('bar_start');
 60+
 61+$wait_foo = output_sync_wait('foo');
 62+$wait_bar = output_sync_wait('bar');
 63+$wait_foo_start = output_sync_set('foo_start');
 64+$wait_bar_start = output_sync_set('bar_start');
 65+
 66+open(MAKEFILE,"> foo/Makefile");
 67+print MAKEFILE <<EOF;
 68+all: foo
 69+
 70+foo: foo-base ; $set_foo
 71+
 72+foo-base:
 73+\t\@echo foo: start
 74+\t$wait_bar
 75+\t\@echo foo: end
 76+
 77+foo-job: foo-job-base ; $set_foo
 78+
 79+foo-job-base:
 80+\t$wait_bar_start
 81+\t\@echo foo: start
 82+\t$set_foo_start
 83+\t$wait_bar
 84+\t\@echo foo: end
 85+
 86+foo-fail:
 87+\t\@echo foo-fail: start
 88+\t$wait_bar
 89+\t\@echo foo-fail: end
 90+\texit 1
 91+
 92+V :=
 93+\$V.SILENT:
 94+Q :=
 95+\$VQ := -q
 96+EOF
 97+close(MAKEFILE);
 98+
 99+open(MAKEFILE,"> bar/Makefile");
100+print MAKEFILE <<EOF;
101+all: bar baz
102+
103+bar: bar-base ; $set_bar
104+bar-base:
105+\t\@echo bar: start
106+\t\@echo bar: end
107+
108+bar-job: bar-job-base ; $set_bar
109+
110+bar-job-base:
111+\t\@echo bar: start
112+\t$set_bar_start
113+\t$wait_foo_start
114+\t\@echo bar: end
115+
116+baz: baz-base
117+baz-base:
118+\t\@echo baz: start
119+\t$wait_foo
120+\t\@echo baz: end
121+
122+V :=
123+\$V.SILENT:
124+Q :=
125+\$VQ := -q
126+EOF
127+close(MAKEFILE);
128+
129+# Test per-make synchronization.
130+# Note we have to sleep again here after starting the foo makefile before
131+# starting the bar makefile, otherwise the "entering/leaving" messages for the
132+# submakes might be ordered differently than we expect.
133+
134+unlink(@syncfiles);
135+run_make_test(qq!
136+all: make-foo make-bar
137+
138+make-foo: ; \$(MAKE) -C foo
139+
140+make-bar: ; #HELPER# -q sleep 1 ; \$(MAKE) -C bar!,
141+              '-j -Orecurse',
142+"#MAKEPATH# -C foo
143+#MAKE#[1]: Entering directory '#PWD#/foo'
144+foo: start
145+foo: end
146+#MAKE#[1]: Leaving directory '#PWD#/foo'
147+#HELPER# -q sleep 1 ; #MAKEPATH# -C bar
148+#MAKE#[1]: Entering directory '#PWD#/bar'
149+bar: start
150+bar: end
151+baz: start
152+baz: end
153+#MAKE#[1]: Leaving directory '#PWD#/bar'\n", 0, $tmout);
154+
155+# Test per-target synchronization.
156+# Note we have to sleep again here after starting the foo makefile before
157+# starting the bar makefile, otherwise the "entering/leaving" messages for the
158+# submakes might be ordered differently than we expect.
159+
160+unlink(@syncfiles);
161+run_make_test(qq!
162+x=1
163+\$xMAKEFLAGS += --no-print-directory
164+
165+all: make-foo make-bar
166+
167+make-foo: ; \$(MAKE) -C foo
168+
169+make-bar: ; #HELPER# -q sleep 1 ; \$(MAKE) -C bar!,
170+              '-j --output-sync=target',
171+"#MAKEPATH# -C foo
172+#HELPER# -q sleep 1 ; #MAKEPATH# -C bar
173+#MAKE#[1]: Entering directory '#PWD#/bar'
174+bar: start
175+bar: end
176+#MAKE#[1]: Leaving directory '#PWD#/bar'
177+#MAKE#[1]: Entering directory '#PWD#/foo'
178+foo: start
179+foo: end
180+#MAKE#[1]: Leaving directory '#PWD#/foo'
181+#MAKE#[1]: Entering directory '#PWD#/bar'
182+baz: start
183+baz: end
184+#MAKE#[1]: Leaving directory '#PWD#/bar'\n", 0, $tmout);
185+
186+# Rerun but this time suppress the directory tracking
187+unlink(@syncfiles);
188+run_make_test(undef, '-j --output-sync=target x=',
189+              "#MAKEPATH# -C foo
190+#HELPER# -q sleep 1 ; #MAKEPATH# -C bar
191+bar: start
192+bar: end
193+foo: start
194+foo: end
195+baz: start
196+baz: end\n", 0, $tmout);
197+
198+# Test that messages from make itself are enclosed with
199+# "Entering/Leaving directory" messages.
200+unlink(@syncfiles);
201+run_make_test(qq!
202+all: make-foo-fail make-bar-bar
203+
204+make-foo-fail: ; \$(MAKE) -C foo foo-fail
205+
206+make-bar-bar: ; #HELPER# -q sleep 1 ; \$(MAKE) -C bar bar!,
207+              '-j -O',
208+"#MAKEPATH# -C foo foo-fail
209+#HELPER# -q sleep 1 ; #MAKEPATH# -C bar bar
210+#MAKE#[1]: Entering directory '#PWD#/bar'
211+bar: start
212+bar: end
213+#MAKE#[1]: Leaving directory '#PWD#/bar'
214+#MAKE#[1]: Entering directory '#PWD#/foo'
215+foo-fail: start
216+foo-fail: end
217+#MAKE#[1]: *** [Makefile:23: foo-fail] Error 1
218+#MAKE#[1]: Leaving directory '#PWD#/foo'
219+#MAKE#: *** [#MAKEFILE#:4: make-foo-fail] Error 2\n",
220+512);
221+
222+# Test the per-job synchronization.
223+# For this we'll have bar-job:
224+#   print start, invoke bar-start, wait for foo-start, print end, print-bar-end
225+# And foo-job:
226+#   wait for bar-start, print foo-start, wait for bar-end, print end
227+
228+unlink(@syncfiles);
229+run_make_test(qq!
230+all: make-foo make-bar
231+
232+make-foo: ; \$(MAKE) -C foo foo-job
233+
234+make-bar: ; #HELPER# -q sleep 1 ; \$(MAKE) -C bar bar-job!,
235+              '-j --output-sync=line',
236+"#MAKEPATH# -C foo foo-job
237+#HELPER# -q sleep 1 ; #MAKEPATH# -C bar bar-job
238+#MAKE#[1]: Entering directory '#PWD#/foo'
239+foo: start
240+#MAKE#[1]: Leaving directory '#PWD#/foo'
241+#MAKE#[1]: Entering directory '#PWD#/bar'
242+bar: start
243+#MAKE#[1]: Leaving directory '#PWD#/bar'
244+#MAKE#[1]: Entering directory '#PWD#/bar'
245+bar: end
246+#MAKE#[1]: Leaving directory '#PWD#/bar'
247+#MAKE#[1]: Entering directory '#PWD#/foo'
248+foo: end
249+#MAKE#[1]: Leaving directory '#PWD#/foo'\n", 0, $tmout);
250+
251+# Remove temporary directories and contents.
252+output_sync_clean();
253+
254+# Ensure recursion doesn't mis-order or double-print output
255+run_make_test(qq!
256+all:
257+\t\@echo foo
258+\t\@+echo bar
259+!,
260+              '-j -Oline', "foo\nbar\n");
261+
262+run_make_test(undef, '-j -Otarget', "foo\nbar\n");
263+
264+# Ensure when make writes out command it's not misordered
265+run_make_test(qq!
266+all:
267+\t\@echo foobar
268+\ttrue
269+!,
270+              '-j -Oline', "foobar\ntrue\n");
271+
272+run_make_test(undef, '-j -Otarget', "foobar\ntrue\n");
273+
274+# Ensure that shell functions inside recipes write stderr to the sync file
275+run_make_test(q!
276+all: ; @: $(shell echo foo 1>&2)
277+!,
278+              '-w -Oline', "#MAKE#: Entering directory '#PWD#'\nfoo\n#MAKE#: Leaving directory '#PWD#'\n");
279+
280+# Ensure that output generated while parsing makefiles is synced
281+# when appropriate.
282+run_make_test(q!
283+$(shell echo foo 1>&2)
284+all: ; echo bar
285+!,
286+              '-s -w -Otarget', "#MAKE#: Entering directory '#PWD#'\nfoo\n#MAKE#: Leaving directory '#PWD#'\n#MAKE#: Entering directory '#PWD#'\nbar\n#MAKE#: Leaving directory '#PWD#'\n");
287+
288+# Test recursion
289+$m1 = get_tmpfile();
290+$m2 = get_tmpfile();
291+
292+open(M1, "> $m1");
293+print M1 <<'EOF';
294+$(shell echo d1 stderr 1>&2)
295+$(info d1 stdout)
296+all:; @:
297+EOF
298+close(M1);
299+
300+open(M2, "> $m2");
301+print M2 <<'EOF';
302+$(shell echo d2 stderr 1>&2)
303+$(info d2 stdout)
304+all:; @:
305+# Force an ordering on the output
306+$(shell sleep 1)
307+EOF
308+close(M2);
309+
310+run_make_test(qq!
311+all: t1 t2
312+t1: ; \@\$(MAKE) -f $m1
313+t2: ; \@\$(MAKE) -f $m2
314+!,
315+              "-j -Oline", "#MAKE#[1]: Entering directory '#PWD#'\nd1 stderr\nd1 stdout\n#MAKE#[1]: Leaving directory '#PWD#'\n#MAKE#[1]: Entering directory '#PWD#'\nd2 stderr\nd2 stdout\n#MAKE#[1]: Leaving directory '#PWD#'\n");
316+
317+rmfiles($m1, $m2);
318+
319+# Ensure that output generated while parsing makefiles is synced
320+# when appropriate.
321+$m1 = get_tmpfile();
322+
323+open(M1, "> $m1");
324+print M1 <<'EOF';
325+$(shell echo d1 stderr 1>&2)
326+$(info d1 stdout)
327+$(error d1 failed)
328+all:; @:
329+EOF
330+close(M1);
331+
332+run_make_test(qq!
333+all: t1
334+t1: ; -\@\$(MAKE) -f $m1
335+!,
336+              "-j -Oline", "#MAKE#[1]: Entering directory '#PWD#'\nd1 stderr\nd1 stdout\n$m1:3: *** d1 failed.  Stop.\n#MAKE#[1]: Leaving directory '#PWD#'\n#MAKE#: [#MAKEFILE#:3: t1] Error 2 (ignored)\n");
337+
338+rmfiles($m1);
339+
340+# Test $(error ...) functions in recipes
341+
342+run_make_test(q!
343+foo: $(OBJS) ; echo $(or $(filter %.o,$^),$(error fail))
344+!,
345+              '-O', "#MAKEFILE#:2: *** fail.  Stop.\n", 512);
346+
347+# SV 47365: Make sure exec failure error messages are shown
348+# Needs to be ported to Windows
349+if ($port_type ne 'W32') {
350+    run_make_test(q!
351+all:: ; @./foo bar baz
352+!,
353+              '-O', "#MAKE#: ./foo: $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:2: all] Error 127\n", 512);
354+}
355+
356+if ($port_type eq 'UNIX') {
357+# POSIX doesn't require sh to set PPID so test this
358+my $cmd = create_command();
359+add_options($cmd, '-f', '/dev/null', '-E', q!all:;@echo $$PPID!);
360+my $fout = 'ppidtest.out';
361+run_command_with_output($fout, @$cmd);
362+$_ = read_file_into_string($fout);
363+s/\r?\n//g;
364+if (/^[0-9]+$/) {
365+use POSIX ();
366+# SV 63157.
367+# Test that make removes temporary files, even when a signal is received.  The
368+# general test_driver postprocessing will ensure the temporary file used to
369+# synchronize output and the jobserver fifo are both removed.  sleep is needed
370+# to let make write its "... Terminated" message to the log file.  Must use
371+# REGEX because some systems (MacOS) add extra text after Terminated.
372+run_make_test(q!
373+pid:=$(shell echo $$PPID)
374+all:; @#HELPER# -q term $(pid) sleep 10
375+!, '-O -j2', '/#MAKE#: \*\*\* \[#MAKEFILE#:3: all] Terminated/', POSIX::SIGTERM);
376+}
377+unlink($fout);
378+
379+# SV 63333. Test that make continues to run without output sync when we
380+# cannot create a temporary file.
381+# Create a non-writable temporary directory.
382+# Run the test twice, because run_make_test cannot match a regex against a
383+# multiline input.
384+
385+# If we do this Valgrind fails because it cannot write temp files... the docs
386+# don't describe any way to tell valgrind to use a directory other than TMPDIR.
387+
388+if (!$valgrind) {
389+    my $tdir = 'test_tmp_dir';
390+    mkdir($tdir, 0500);
391+    $ENV{'TMPDIR'} = $tdir;
392+
393+    run_make_test(q!
394+all:; $(info hello, world)
395+!, '-Orecurse', "/suppressing output-sync/");
396+
397+    run_make_test(undef, '-Orecurse', "/#MAKE#: 'all' is up to date./");
398+
399+    rmdir($tdir);
400+}
401+}
402+
403+# This tells the test driver that the perl test script executed properly.
404+1;
+64, -0
 1@@ -0,0 +1,64 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the override directive on variable assignments.";
 5+
 6+$details = "";
 7+
 8+# TEST 0: Basic override
 9+
10+run_make_test('
11+X = start
12+override recur = $(X)
13+override simple := $(X)
14+X = end
15+all: ; @echo "$(recur) $(simple)"
16+',
17+              'recur=I simple=J', "end start\n");
18+
19+# TEST 1: Override with append
20+
21+run_make_test('
22+X += X1
23+override X += X2
24+override Y += Y1
25+Y += Y2
26+all: ; @echo "$(X) $(Y)"
27+',
28+              '', "X1 X2 Y1\n");
29+
30+# TEST 2: Override with append to the command line
31+
32+run_make_test(undef, 'X=C Y=C', "C X2 C Y1\n");
33+
34+# Test override of define/endef
35+
36+run_make_test('
37+override define foo
38+@echo First comes the definition.
39+@echo Then comes the override.
40+endef
41+all: ; $(foo)
42+',
43+              'foo=Hello', "First comes the definition.\nThen comes the override.\n");
44+
45+# Directive lines cannot begin with TAB
46+
47+run_make_test(q!
48+#TAB#override FOO = bar
49+all:;@echo hi
50+!,
51+              '', "#MAKEFILE#:2: warning: directive lines cannot start with TAB\nhi");
52+
53+run_make_test(q!
54+#TAB#override#TAB#export FOO = bar
55+all:;@echo hi
56+!,
57+              '', "#MAKEFILE#:2: warning: directive lines cannot start with TAB\nhi");
58+
59+run_make_test(q!
60+    override#TAB#export FOO = bar
61+all:;@echo hi
62+!,
63+              '', "hi");
64+
65+1;
+248, -0
  1@@ -0,0 +1,248 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test parallelism (-j) option.";
  5+$details = "";
  6+
  7+if (!$parallel_jobs) {
  8+  return -1;
  9+}
 10+
 11+run_make_test(q!
 12+all : def_1 def_2 def_3
 13+def_1 : ; @#HELPER# file ONE wait THREE out TWO
 14+def_2 : ; @#HELPER# wait FOUR file THREE
 15+def_3 : ; @#HELPER# wait ONE file FOUR!,
 16+              '-j4', "file ONE\nwait ONE\nfile FOUR\nwait FOUR\nfile THREE\nwait THREE\nTWO");
 17+rmfiles(qw(ONE TWO THREE FOUR));
 18+
 19+# Verify -j added to MAKEFLAGS in the makefile
 20+run_make_test(q!
 21+MAKEFLAGS += -j4
 22+all : def_1 def_2 def_3
 23+def_1 : ; @#HELPER# file ONE wait THREE out TWO
 24+def_2 : ; @#HELPER# wait FOUR file THREE
 25+def_3 : ; @#HELPER# wait ONE file FOUR!,
 26+              '', "file ONE\nwait ONE\nfile FOUR\nwait FOUR\nfile THREE\nwait THREE\nTWO");
 27+rmfiles(qw(ONE TWO THREE FOUR));
 28+
 29+# Command line should take precedence
 30+run_make_test(q!
 31+MAKEFLAGS += -j2
 32+all : def_1 def_2 def_3
 33+def_1 : ; @#HELPER# file ONE wait THREE out TWO
 34+def_2 : ; @#HELPER# wait FOUR file THREE
 35+def_3 : ; @#HELPER# wait ONE file FOUR!,
 36+              '-j4', "file ONE\nwait ONE\nfile FOUR\nwait FOUR\nfile THREE\nwait THREE\nTWO");
 37+rmfiles(qw(ONE TWO THREE FOUR));
 38+
 39+# Test parallelism with included files.  Here we sleep/echo while
 40+# building the included files, to test that they are being built in
 41+# parallel.
 42+run_make_test(q!
 43+all: 1 2; @#HELPER# out success
 44+-include 1.inc 2.inc
 45+.RECIPEPREFIX := >
 46+1.inc:
 47+> @#HELPER# file ONE.inc wait THREE.inc file TWO.inc
 48+> @echo '1: ; @#HELPER# file ONE wait THREE file TWO' > $@
 49+2.inc:
 50+> @#HELPER# wait ONE.inc file THREE.inc
 51+> @echo '2: ; @#HELPER# wait ONE file THREE' > $@!,
 52+              "-j4",
 53+              "file ONE.inc\nwait ONE.inc\nfile THREE.inc\nwait THREE.inc\nfile TWO.inc\nfile ONE\nwait ONE\nfile THREE\nwait THREE\nfile TWO\nsuccess\n", 0, 7);
 54+rmfiles(qw(ONE.inc TWO.inc THREE.inc ONE TWO THREE 1.inc 2.inc));
 55+
 56+
 57+# Test parallelism with included files--this time recurse first and make
 58+# sure the jobserver works.
 59+run_make_test(q!
 60+recurse: ; @$(MAKE) --no-print-directory -f #MAKEFILE# INC=yes all
 61+all: 1 2; @#HELPER# out success
 62+
 63+INC = no
 64+ifeq ($(INC),yes)
 65+-include 1.inc 2.inc
 66+endif
 67+
 68+1.inc: ; @#HELPER# file ONE.inc wait THREE.inc file TWO.inc; echo '1: ; @#HELPER# file ONE wait THREE file TWO' > $@
 69+2.inc: ; @#HELPER# wait ONE.inc file THREE.inc; echo '2: ; @#HELPER# wait ONE file THREE' > $@!,
 70+              "-j4",
 71+              "file ONE.inc\nwait ONE.inc\nfile THREE.inc\nwait THREE.inc\nfile TWO.inc\nfile ONE\nwait ONE\nfile THREE\nwait THREE\nfile TWO\nsuccess\n", 0, 7);
 72+rmfiles(qw(ONE.inc TWO.inc THREE.inc ONE TWO THREE 1.inc 2.inc));
 73+
 74+# Grant Taylor reports a problem where tokens can be lost (not written back
 75+# to the pipe when they should be): this happened when there is a $(shell ...)
 76+# function in an exported recursive variable.  I added some code to check
 77+# for this situation and print a message if it occurred.  This test used
 78+# to trigger this code when I added it but no longer does after the fix.
 79+
 80+run_make_test(q!
 81+export HI = $(shell $($@.CMD))
 82+first.CMD = #HELPER# out hi
 83+second.CMD = #HELPER# sleep 4
 84+
 85+.PHONY: all first second
 86+all: first second
 87+
 88+first second: ; @#HELPER# out $@ sleep 1 out $@!,
 89+              '-j2', "first\nsleep 1\nfirst\nsecond\nsleep 1\nsecond", 0);
 90+
 91+# Michael Matz <matz@suse.de> reported a bug where if make is running in
 92+# parallel without -k and two jobs die in a row, but not too close to each
 93+# other, then make will quit without waiting for the rest of the jobs to die.
 94+
 95+run_make_test(q!
 96+.PHONY: all fail.1 fail.2 fail.3 ok
 97+all: fail.1 ok fail.2 fail.3
 98+
 99+fail.1: ; @#HELPER# -q sleep 1 out $@ file fail.1 fail 1
100+fail.2: ; @#HELPER# -q sleep 2 out $@ wait fail.1 file fail.2 fail 1
101+fail.3: ; @#HELPER# -q sleep 3 out $@ wait fail.2 file fail.3 fail 1
102+
103+ok: ; @#HELPER# -q sleep 4 wait fail.3 out OK!,
104+              '-rR -j5', "fail.1
105+#MAKE#: *** [#MAKEFILE#:5: fail.1] Error 1
106+#MAKE#: *** Waiting for unfinished jobs....
107+fail.2
108+#MAKE#: *** [#MAKEFILE#:6: fail.2] Error 1
109+fail.3
110+#MAKE#: *** [#MAKEFILE#:7: fail.3] Error 1
111+OK",
112+             512);
113+
114+rmfiles(qw(fail.1 fail.2 fail.3));
115+
116+# Test for Savannah bug #15641.
117+#
118+run_make_test('
119+.PHONY: all
120+all:; @:
121+
122+-include foo.d
123+
124+foo.d: comp ; @#HELPER# out $@
125+
126+comp: mod_a.o mod_b.o; @:
127+
128+mod_a.o mod_b.o: ; @#HELPER# fail 1
129+', '-j2', "fail 1\nfail 1\n");
130+
131+
132+# TEST #9 -- Savannah bugs 3330 and 15919
133+# In earlier versions of make this will either give the wrong answer, or hang.
134+
135+utouch(-10, 'target');
136+run_make_test('target: intermed ; #HELPER# file $@
137+
138+.INTERMEDIATE: intermed
139+intermed: | phony ; #HELPER# file $@
140+
141+.PHONY: phony
142+phony: ; : phony', '-rR -j', ': phony');
143+rmfiles('target');
144+
145+# TEST #11: Make sure -jN from MAKEFLAGS is processed even when we re-exec
146+# See Savannah bug #33873
147+
148+$ENV{MAKEFLAGS} = '-j4';
149+
150+run_make_test(q!
151+things = thing1 thing2
152+all: $(things)
153+thing1:; @#HELPER# wait thing2start file $@start wait thing2end out $@end
154+thing2:; @#HELPER# file $@start wait thing1start file $@end
155+-include inc.mk
156+inc.mk: ; @touch $@
157+!,
158+              '', "file thing2start\nwait thing2start\nfile thing1start\nwait thing1start\nfile thing2end\nwait thing2end\nthing1end\n");
159+
160+rmfiles(qw(inc.mk thing1start thing1end thing2start thing2end));
161+
162+# Ensure intermediate/secondary files are not pruned incorrectly.
163+# See Savannah bug #30653
164+
165+utouch(-15, 'file2');
166+utouch(-10, 'file4');
167+utouch(-5,  'file1');
168+
169+run_make_test(q!
170+.INTERMEDIATE: file3
171+file4: file3 ; @mv -f $< $@
172+file3: file2 ; touch $@
173+file2: file1 ; @touch $@
174+!,
175+              '--no-print-directory -j2', "touch file3");
176+
177+rmfiles('file1', 'file2', 'file3', 'file4');
178+
179+# Ensure that the jobserver is preserved across make re-exec.
180+
181+run_make_test(q!
182+all: one two
183+one: ;@ #HELPER# wait TWO file ONE
184+two: ;@ #HELPER# file TWO
185+include fff1.mk
186+fff1.mk: ; touch $@
187+!,
188+              '-j2', "touch fff1.mk\nfile TWO\nwait TWO\nfile ONE\n");
189+
190+rmfiles('fff1.mk', 'ONE', 'TWO');
191+
192+# Test if a sub-make needs to re-exec and the makefile is built via
193+# sub-make.  Reported by Masahiro Yamada <yamada.masahiro@socionext.com>
194+
195+run_make_test(q!
196+all: ; @$(MAKE) -f #MAKEFILE# recurse
197+
198+recurse: one two ; @#HELPER# out $@
199+one: ;@ #HELPER# wait TWO file ONE
200+two: ;@ #HELPER# file TWO
201+
202+mkinclude: ; touch fff1.mk
203+
204+ifeq ($(MAKECMDGOALS),recurse)
205+include fff1.mk
206+fff1.mk: ; @$(MAKE) -f #MAKEFILE# mkinclude
207+endif
208+!,
209+              '--no-print-directory -j2', "touch fff1.mk\nfile TWO\nwait TWO\nfile ONE\nrecurse\n");
210+
211+rmfiles('fff1.mk', 'ONE', 'TWO');
212+
213+
214+# Make sure that all jobserver FDs are closed if we need to re-exec the
215+# master copy.
216+#
217+# First, find the "default" file descriptors we normally use
218+# Then make sure they're still used.
219+#
220+# Right now we don't have a way to run a makefile and capture the output
221+# without checking it, so we can't really write this test.
222+
223+# run_make_test('
224+# submake: ; @$(MAKE) --no-print-directory -f #MAKEFILE# fdprint 5>output
225+
226+# dependfile: ; @echo FOO=bar > $@
227+
228+# INCL := true
229+
230+# FOO=foo
231+# ifeq ($(INCL),true)
232+# -include dependfile
233+# endif
234+
235+# fdprint: ; @echo $(filter --jobserver%,$(MAKEFLAGS))
236+
237+# recurse: ; @$(MAKE) --no-print-directory -f #MAKEFILE# submake INCL=true',
238+#               '-j2 INCL=false fdprint',
239+#               'bar');
240+
241+# rmfiles(qw(dependfile output));
242+
243+
244+# # Do it again, this time where the include is done by the non-master make.
245+# run_make_test(undef, '-j2 recurse INCL=false', 'bar');
246+
247+# rmfiles(qw(dependfile output));
248+
249+1;
+130, -0
  1@@ -0,0 +1,130 @@
  2+#                                                                    -*-perl-*-
  3+$description = "Test pattern-specific variable settings.";
  4+
  5+$details = "\
  6+Create a makefile containing various flavors of pattern-specific variable
  7+settings, override and non-override, and using various variable expansion
  8+rules, semicolon interference, etc.";
  9+
 10+# basics
 11+
 12+run_make_test(q!all: one.x two.x three.x
 13+FOO = foo
 14+BAR = bar
 15+BAZ = baz
 16+one.x: override FOO = one
 17+%.x: BAR = two
 18+t%.x: BAR = four
 19+thr% : override BAZ = three
 20+one.x two.x three.x: ; @echo $@: $(FOO) $(BAR) $(BAZ)
 21+four.x: baz ; @echo $@: $(FOO) $(BAR) $(BAZ)
 22+baz: ; @echo $@: $(FOO) $(BAR) $(BAZ)
 23+
 24+# test matching multiple patterns
 25+a%: AAA = aaa
 26+%b: BBB = ccc
 27+a%: BBB += ddd
 28+%b: AAA ?= xxx
 29+%b: AAA += bbb
 30+.PHONY: ab
 31+ab: ; @echo $(AAA); echo $(BBB)
 32+!,
 33+              "", "one.x: one two baz\ntwo.x: foo four baz\nthree.x: foo four three\n");
 34+
 35+# try the override feature
 36+
 37+run_make_test(undef, "BAZ=five",
 38+              "one.x: one two five\ntwo.x: foo four five\nthree.x: foo four three\n");
 39+
 40+# make sure patterns are inherited properly
 41+
 42+run_make_test(undef, "four.x",
 43+              "baz: foo two baz\nfour.x: foo two baz\n");
 44+
 45+# test multiple patterns matching the same target
 46+
 47+run_make_test(undef, "ab", "aaa bbb\nccc ddd\n");
 48+
 49+# test pattern-specific exported variables
 50+
 51+run_make_test('
 52+/%: export foo := foo
 53+
 54+/bar:
 55+#TAB#@echo $(foo) $$foo
 56+', '', 'foo foo');
 57+
 58+# test expansion of pattern-specific simple variables
 59+
 60+run_make_test('
 61+.PHONY: all
 62+
 63+all: inherit := good $$t
 64+all: bar baz
 65+
 66+b%: pattern := good $$t
 67+
 68+global := original $$t
 69+
 70+
 71+# normal target
 72+#
 73+ifdef rec
 74+bar: a = global: $(global) pattern: $(pattern) inherit: $(inherit)
 75+else
 76+bar: a := global: $(global) pattern: $(pattern) inherit: $(inherit)
 77+endif
 78+
 79+bar: ; @echo \'normal: $a;\'
 80+
 81+
 82+# pattern target
 83+#
 84+ifdef rec
 85+%z: a = global: $(global) pattern: $(pattern) inherit: $(inherit)
 86+else
 87+%z: a := global: $(global) pattern: $(pattern) inherit: $(inherit)
 88+endif
 89+
 90+%z: ; @echo \'pattern: $a;\'
 91+
 92+
 93+global := new $$t
 94+',
 95+'',
 96+'normal: global: original $t pattern:  inherit: ;
 97+pattern: global: original $t pattern:  inherit: ;');
 98+
 99+# test expansion of pattern-specific recursive variables
100+
101+run_make_test(undef, # reuse previous makefile
102+'rec=1',
103+'normal: global: new $t pattern: good $t inherit: good $t;
104+pattern: global: new $t pattern: good $t inherit: good $t;');
105+
106+# override in pattern-specific variables
107+
108+run_make_test('
109+a%: override FOO += f1
110+a%: FOO += f2
111+ab: ; @echo "$(FOO)"
112+',
113+              '', "f1\n");
114+
115+run_make_test(undef, 'FOO=C', "C f1\n");
116+
117+# Test shortest stem selection in pattern-specific variables.
118+
119+run_make_test('
120+%-mt.x: x := two
121+%.x: x := one
122+
123+all: foo.x foo-mt.x
124+
125+foo.x: ;@echo $x
126+foo-mt.x: ;@echo $x
127+',
128+'',
129+"one\ntwo");
130+
131+1;
+710, -0
  1@@ -0,0 +1,710 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test pattern rules.";
  5+
  6+$details = "";
  7+
  8+use Cwd;
  9+
 10+$dir = cwd;
 11+$dir =~ s,.*/([^/]+)$,../$1,;
 12+
 13+
 14+# TEST #0: Make sure that multiple patterns where the same target
 15+#          can be built are searched even if the first one fails
 16+#          to match properly.
 17+#
 18+
 19+run_make_test(q!
 20+.PHONY: all
 21+
 22+all: case.1 case.2 case.3 case.4
 23+
 24+# We can't have this, due to "Implicit Rule Search Algorithm" step 5c
 25+#xxx: void
 26+
 27+# 1 - existing file
 28+%.1: void ; @exit 1
 29+%.1: #MAKEFILE# ; @exit 0
 30+
 31+# 2 - phony
 32+%.2: void ; @exit 1
 33+%.2: 2.phony ; @exit 0
 34+.PHONY: 2.phony
 35+
 36+# 3 - implicit-phony
 37+%.3: void ; @exit 1
 38+%.3: 3.implicit-phony ; @exit 0
 39+
 40+3.implicit-phony:
 41+
 42+# 4 - explicitly mentioned file made by an implicit rule
 43+%.4: void ; @exit 1
 44+%.4: test.x ; @exit 0
 45+%.x: ;
 46+!,
 47+              '', '');
 48+
 49+# TEST #1: make sure files that are built via implicit rules are marked
 50+#          as targets (Savannah bug #12202).
 51+#
 52+run_make_test('
 53+TARGETS := foo foo.out
 54+
 55+.PHONY: all foo.in
 56+
 57+all: $(TARGETS)
 58+
 59+%: %.in ; @echo $@
 60+
 61+%.out: % ; @echo $@
 62+
 63+foo.in: ; @:
 64+
 65+',
 66+              '', "foo\nfoo.out");
 67+
 68+
 69+# TEST #2: make sure intermediate files that also happened to be
 70+#          prerequisites are not removed (Savannah bug #12267).
 71+#
 72+run_make_test('
 73+$(dir)/foo.o:
 74+
 75+$(dir)/foo.y: ; @echo $@
 76+
 77+%.c: %.y ; touch $@
 78+
 79+%.o: %.c ; @echo $@
 80+
 81+.PHONY: install
 82+install: $(dir)/foo.c
 83+
 84+',
 85+              "dir=$dir", "$dir/foo.y\ntouch $dir/foo.c\n$dir/foo.o");
 86+
 87+unlink("$dir/foo.c");
 88+
 89+
 90+# TEST #3: make sure precious flag is set properly for targets
 91+#          that are built via implicit rules (Savannah bug #13218).
 92+#
 93+run_make_test('
 94+.DELETE_ON_ERROR:
 95+
 96+.PRECIOUS: %.bar
 97+
 98+%.bar:; @touch $@ && exit 1
 99+
100+$(dir)/foo.bar:
101+
102+',
103+              "dir=$dir",
104+              "#MAKE#: *** [#MAKEFILE#:6: $dir/foo.bar] Error 1", 512);
105+
106+unlink("$dir/foo.bar");
107+
108+
109+# TEST #4: make sure targets of a matched implicit pattern rule are
110+#          never considered intermediate (Savannah bug #13022).
111+#
112+run_make_test('
113+.PHONY: all
114+all: foo.c foo.o
115+
116+%.h %.c: %.in ; touch $*.h ; touch $*.c
117+
118+%.o: %.c %.h ; echo $+ >$@
119+
120+%.o: %.c ; @echo wrong rule
121+
122+foo.in: ; touch $@
123+
124+',
125+              '', "touch foo.in\ntouch foo.h ; touch foo.c\necho foo.c foo.h >foo.o\nrm foo.h");
126+
127+unlink('foo.in', 'foo.h', 'foo.c', 'foo.o');
128+
129+# TEST #5: make sure both prefix and suffix patterns work with multiple
130+#          target patterns (Savannah bug #26593).
131+#
132+run_make_test('
133+all: foo.s1 foo.s2 p1.foo p2.foo
134+
135+p1.% p2.%: %.orig ; @echo $@
136+%.s1 %.s2: %.orig ; @echo $@
137+
138+.PHONY: foo.orig
139+',
140+              '', "foo.s1\np1.foo\n");
141+
142+# TEST 6: Make sure that non-target files are still eligible to be created
143+# as part of implicit rule chaining.  Savannah bug #17752.
144+
145+run_make_test(sprintf(q!
146+BIN = xyz
147+COPY = $(BIN).cp
148+SRC = $(BIN).c
149+allbroken: $(COPY) $(BIN) ; @echo ok
150+$(SRC): ; @echo 'main(){}' > $@
151+%%.cp: %% ; @cp $< $@
152+%% : %%.c ; @cp $< $@
153+clean: ; @%s $(SRC) $(COPY) $(BIN)
154+!, $CMD_rmfile),
155+              '', "ok\n");
156+
157+unlink(qw(xyz xyz.cp xyz.c));
158+
159+# TEST 7: Make sure that all prereqs of all "also_make" targets get created
160+# before any of the things that depend on any of them.  Savannah bug #19108.
161+
162+run_make_test(q!
163+final: x ; @echo $@
164+x: x.t1 x.t2 ; @echo $@
165+x.t2: dep
166+dep: ; @echo $@
167+%.t1 %.t2: ; @echo $*.t1 ; echo $*.t2
168+!,
169+              '', "dep\nx.t1\nx.t2\nx\nfinal\n");
170+
171+
172+# TEST 8: Verify we can remove pattern rules.  Savannah bug #18622.
173+
174+my @f = (qw(foo.w foo.ch));
175+touch(@f);
176+
177+run_make_test(q!
178+CWEAVE := :
179+
180+# Disable builtin rules
181+%.tex : %.w
182+%.tex : %.w %.ch
183+!,
184+              'foo.tex',
185+              "#MAKE#: *** No rule to make target 'foo.tex'.  Stop.", 512);
186+
187+unlink(@f);
188+
189+# TEST #9: Test shortest stem selection in pattern rules.
190+
191+run_make_test('
192+%.x: ;@echo one
193+%-mt.x: ;@echo two
194+
195+all: foo.x foo-mt.x
196+',
197+              '', "one\ntwo");
198+
199+# Test pattern rules building the same targets
200+# See SV 54233.
201+
202+touch('a.c');
203+
204+# a.lnk isn't listed as removed, because it's not actually created
205+run_make_test(q!
206+all: a.elf a.dbg
207+
208+%.elf %.lnk: %.c ; : $*.elf $*.lnk
209+
210+%.elf %.dbg: %.lnk ; : $*.elf $*.dbg
211+!,
212+    '-j2', ": a.elf a.lnk\n: a.elf a.dbg\n");
213+
214+# SV 60435 : a.lnk is removed, because it is intermediate.
215+run_make_test(q!
216+all: a.elf a.dbg
217+
218+%.elf %.lnk: %.c ; touch $*.elf $*.lnk
219+
220+%.elf %.dbg: %.lnk ; touch $*.elf $*.dbg
221+!,
222+              '-j2', "touch a.elf a.lnk\ntouch a.elf a.dbg\nrm a.lnk\n");
223+
224+unlink('a.elf', 'a.dbg');
225+
226+# SV 60435 : a.lnk is not intermediate, because it is explicitly mentioned.
227+run_make_test(q!
228+all: a.elf a.dbg
229+
230+%.elf %.lnk: %.c ; touch $*.elf $*.lnk
231+
232+%.elf %.dbg: %.lnk ; touch $*.elf $*.dbg
233+
234+install: a.lnk
235+.PHONY: install
236+!,
237+              '-j2', "touch a.elf a.lnk\ntouch a.elf a.dbg\n");
238+
239+unlink('a.c', 'a.elf', 'a.dbg', 'a.lnk');
240+
241+# SV 56655: Test patterns matching files containing whitespace
242+touch('some file.yy');
243+run_make_test(q!
244+%.xx : %.yy ; @echo matched
245+!,
246+              '"some file.xx"', "matched\n");
247+
248+unlink('some file.xx', 'some file.yy');
249+
250+
251+# sv 60188.
252+# Test that a file explicitly mentioned by the user and made by an implicit
253+# rule is not considered intermediate.
254+
255+touch('hello.z');
256+unlink('hello.x', 'test.x');
257+
258+# subtest 1
259+# hello.x is not explicitly mentioned and thus is an intermediate file.
260+run_make_test(q!
261+all: hello.z
262+%.z: %.x ; touch $@
263+%.x: ;
264+!,
265+              '', "#MAKE#: Nothing to be done for 'all'.\n");
266+
267+# subtest 2
268+# test.x is explicitly mentioned and thus is not an intermediate file.
269+run_make_test(q!
270+all: hello.z
271+%.z: %.x test.x ; touch $@
272+%.x: ;
273+!,
274+              '', "touch hello.z");
275+
276+# subtest 3
277+# hello.x is explicitly mentioned on an unrelated rule and thus is not an
278+# intermediate file.
279+touch('hello.z');
280+run_make_test(q!
281+all: hello.z
282+%.z: %.x; touch $@
283+%.x: ;
284+unrelated: hello.x
285+!,
286+              '', "touch hello.z");
287+
288+unlink('hello.z');
289+
290+# sv 60188.
291+# Test that a file explicitly mentioned by the user and made by an implicit
292+# rule is not considered intermediate, even when the builtin rules are used.
293+
294+touch('hello.x');
295+touch('test.x');
296+touch('hello.tsk');
297+
298+# subtest 1
299+# hello.o is not explicitly mentioned and thus is an intermediate file.
300+run_make_test(q!
301+all: hello.tsk
302+%.tsk: %.z ; @echo $@
303+%.z : %.x ; @echo $@
304+!,
305+              '', "#MAKE#: Nothing to be done for 'all'.\n");
306+
307+# subtest 2
308+# test.z is explicitly mentioned and thus is not an intermediate file.
309+# test.z is built first because until it's built we don't know if we
310+# need to rebuild the intermediate hello.z
311+run_make_test(q!
312+all: hello.tsk
313+%.tsk: %.z test.z ; @echo $@
314+%.z : %.x ; @echo $@
315+!,
316+              '', "test.z\nhello.z\nhello.tsk\n");
317+
318+# subtest 3
319+# hello.o is not explicitly mentioned and thus is an intermediate file.
320+run_make_test(q!
321+all: hello.tsk
322+dep:=%.o
323+%.tsk: $(dep) ; @echo $@
324+!,
325+              '', "#MAKE#: Nothing to be done for 'all'.\n");
326+
327+# subtest 4
328+# Even when test.z is constructed from 2 variables it is still explicitly
329+# mentioned and thus is not an intermediate file.
330+# test.z is built first because until it's built we don't know if we
331+# need to rebuild the intermediate hello.z
332+run_make_test(q!
333+all: hello.tsk
334+name:=test
335+suf:=.z
336+%.tsk: %.z $(name)$(suf) ; @echo $@
337+%.z: %.x ; @echo $@
338+!,
339+              '', "test.z\nhello.z\nhello.tsk\n");
340+
341+unlink('hello.x', 'test.x', 'hello.tsk');
342+
343+# Test that chained pattern rules with multiple targets remove all intermediate
344+# files.
345+# sv 60435.
346+
347+# subtest 1.
348+# a.1 and a.2 are intermediate and should be removed.
349+
350+run_make_test(q!
351+a.4:
352+%.4: %.1 %.15 ; cat $^ >$@
353+%.1 %.15: ; touch $*.1 $*.15
354+!,
355+              '', "touch a.1 a.15\ncat a.1 a.15 >a.4\nrm a.15 a.1");
356+
357+unlink('a.4');
358+
359+# subtest 2.
360+# a.1 and a.2 are intermediate and should be removed.
361+# a.3 is explicit and should not be removed.
362+run_make_test(q!
363+a.4:
364+%.4: %.1 %.15 a.3 ; cat $^ >$@
365+%.1 %.15: ; touch $*.1 $*.15
366+%.3: ; touch $@
367+!,
368+              '', "touch a.3\ntouch a.1 a.15\ncat a.1 a.15 a.3 >a.4\nrm a.15 a.1");
369+
370+unlink('a.3', 'a.4');
371+
372+# subtest 3.
373+# a.1 and a.2 are intermediate and should be removed.
374+# a.3 is explicit and should not be removed.
375+run_make_test(q!
376+a.4:
377+%.4: %.1 %.15 a.3 ; cat $^ >$@
378+%.1 %.15 %.3: ; touch $*.1 $*.15 $*.3
379+!,
380+              '', "touch a.1 a.15 a.3\ncat a.1 a.15 a.3 >a.4\nrm a.15 a.1");
381+
382+unlink('a.3', 'a.4');
383+
384+# subtest 4.
385+# a.1 and a.2 are intermediate and should be removed.
386+# a.3 is explicit and should not be removed.
387+run_make_test(q!
388+a.4:
389+%.4: %.1 %.15 a.3 ; cat $^ >$@
390+%.3 %.1 %.15: ; touch $*.1 $*.15 $*.3
391+!,
392+              '', "touch a.1 a.15 a.3\ncat a.1 a.15 a.3 >a.4\nrm a.15 a.1");
393+
394+unlink('a.3', 'a.4');
395+
396+# subtest 5.
397+# a.1 and a.2 are intermediate and should be removed.
398+# a.3 is explicit and should not be removed.
399+run_make_test(q!
400+a.4:
401+%.4: a.3 %.1 %.15 ; cat $^ >$@
402+%.1 %.15 %.3: ; touch $*.1 $*.15 $*.3
403+!,
404+              '', "touch a.1 a.15 a.3\ncat a.3 a.1 a.15 >a.4\nrm a.15 a.1");
405+
406+unlink('a.3', 'a.4');
407+
408+# subtest 6.
409+# a.2 is intermediate and should be removed.
410+# a.1 is mentioned explicitly on an unrelated rule and should not be removed.
411+run_make_test(q!
412+a.3:
413+%.3: %.1 %.2 ; cat $^ >$@
414+%.1 %.2: ; touch $*.1 $*.2
415+install: a.1
416+.PHONY: install
417+!,
418+              '', "touch a.1 a.2\ncat a.1 a.2 >a.3\nrm a.2");
419+
420+unlink('a.1', 'a.3');
421+
422+# Test removal of intermediate files.
423+
424+# subtest 1.
425+# hello.x is removed, because it is intermediate.
426+run_make_test(q!
427+hello.tsk:
428+%.tsk: %.x; touch $@
429+%.x: ; touch $@
430+!,
431+              '', "touch hello.x\ntouch hello.tsk\nrm hello.x");
432+
433+unlink('hello.tsk');
434+
435+# subtest 2.
436+# Even though hello.x is intermediate, it is not removed, because it is not
437+# created.
438+touch('hello.x');
439+
440+run_make_test(q!
441+hello.tsk:
442+%.tsk: %.x; touch $@
443+%.x: ; touch $@
444+!,
445+              '', "touch hello.tsk");
446+
447+unlink('hello.x', 'hello.tsk');
448+
449+# subtest 2.
450+# Even though hello.x is intermediate, it is not removed, because it is not
451+# created.
452+run_make_test(q!
453+hello.tsk:
454+%.tsk: %.x; touch $@
455+%.x: ; : $@
456+!,
457+              '', ": hello.x\ntouch hello.tsk");
458+
459+unlink('hello.tsk');
460+
461+# A target explicitly listed as a prerequisite of a pattern rule, is still
462+# considered mentioned and "ought to exist".
463+
464+run_make_test(q!
465+1.all: 1.q ; touch $@
466+%.q: 1.r ; touch $@
467+%.r: ; touch $@
468+!,
469+              '', "touch 1.r\ntouch 1.q\ntouch 1.all\n");
470+
471+unlink('1.all', '1.q', '1.r');
472+
473+# SV 63098: Verify that missing also_made in pattern rules gives a warning but
474+# doesn't fail.
475+
476+run_make_test(q!
477+%a %b : ; touch $*a
478+!,
479+              'gta', "touch gta\n#MAKEFILE#:2: warning: pattern recipe did not update peer target 'gtb'\n");
480+unlink(qw(gta));
481+
482+# We don't warn if we didn't update the file
483+utouch(-10, qw(gta));
484+run_make_test(q!
485+%a %b : xyzzy ; $(OP)
486+xyzzy: ;
487+ifdef RUN
488+OP = @echo no
489+endif
490+!,
491+              '-rR gta', "#MAKE#: 'gta' is up to date.\n");
492+
493+run_make_test(undef, '-rR gta RUN=1', "no\n");
494+unlink(qw(gta));
495+
496+run_make_test(q!
497+all:;
498+include gta
499+%a %b : ; touch $*a
500+!,
501+              '', "touch gta\n#MAKEFILE#:4: warning: pattern recipe did not update peer target 'gtb'\n#MAKE#: 'all' is up to date.");
502+unlink(qw(gta));
503+
504+run_make_test(q!
505+%.c %.h : %.y; touch $*.c
506+%.o: %.c; touch $@
507+foo.y: ; touch $@
508+!,
509+              'foo.o', "touch foo.y\ntouch foo.c\n#MAKEFILE#:2: warning: pattern recipe did not update peer target 'foo.h'\ntouch foo.o\nrm foo.c");
510+unlink(qw(foo.y foo.c foo.o));
511+
512+if (0) {
513+# SV 12078: Missing grouped pattern peer causes remake regardless of which
514+# target caused the rule to run.
515+touch(qw(gta));  # but not gtb
516+run_make_test(q!
517+%a %b : ; touch $*a $*b
518+!,
519+              'gta', "touch gta gtb\n");
520+unlink(qw(gta gtb));
521+
522+# Ensure both goal targets are built if they depend on a grouped pattern
523+touch(qw(gta));  # but not gtb
524+run_make_test(q!
525+x y: ; touch $@
526+
527+x: gta
528+y: gtb
529+
530+%a %b : ; touch $*a $*b
531+!,
532+              'x y', "touch gta gtb\ntouch x\ntouch y\n");
533+
534+# Now everything should be up to date
535+run_make_test(undef, 'x y',
536+              "#MAKE#: 'x' is up to date.\n#MAKE#: 'y' is up to date.");
537+
538+unlink(qw(x y gta gtb));
539+
540+# sv 12078 : make sure we notice when all targets need to be rebuilt
541+# a.1st exists but b.1st doesn't: make sure a.2nd is out of date as well
542+
543+utouch(-20, 'a.1st');
544+utouch(-10, 'a.2nd', 'b.2nd');
545+
546+run_make_test(q!
547+1st := a.1st b.1st
548+2nd := ${1st:.1st=.2nd}
549+.PHONY: all
550+all: ${2nd}
551+a.% b.% : ; touch a.$* b.$*
552+${2nd}: %.2nd: %.1st ; cp $< $@
553+!
554+              , '', "touch a.1st b.1st\ncp a.1st a.2nd\ncp b.1st b.2nd\n");
555+
556+unlink(qw(a.1st b.1st a.2nd b.2nd));
557+
558+# Variation: b.1st exists but is newer
559+
560+utouch(-20, 'a.1st');
561+utouch(-10, 'a.2nd', 'b.2nd');
562+touch(qw(b.1st));
563+
564+run_make_test(undef, '', "cp b.1st b.2nd\n");
565+
566+unlink(qw(a.1st b.1st a.2nd b.2nd));
567+}
568+
569+# sv 62206.
570+
571+# The following combinations are generated with and without second expansion.
572+# 1.
573+# all: bye.x
574+# %.x: ...
575+#
576+# 2.
577+# all: lib/bye.x
578+# %.x: ...
579+#
580+# 3.
581+# all: lib/bye.x
582+# lib/%.x: ...
583+#
584+# The following combination is not generated, because there is no rule to
585+# build bye.x, no stem substitution takes place, not of interest of this test.
586+# 4.
587+# all: bye.x
588+# lib/%.x: ...
589+
590+my @dir = ('', 'lib/'); # With and without last slash.
591+my @secondexpansion = ('', '.SECONDEXPANSION:');
592+
593+for my $se (@secondexpansion) {
594+for my $d (@dir) { # The directory of the prerequisite of 'all'.
595+for my $r (@dir) { # The directory of the target in the rule definition.
596+(!$d && $r) && next; # Combination 4.
597+my $dollar = $se ? '$' : '';
598+
599+# The prerequisite should only have directory if the prerequisite of 'all' has
600+# it and if the prerequisite pattern in the rule definition does not have it.
601+# That is combination 2.
602+my $pdir = $d && !$r ? $d : '';
603+
604+my $prereqs = "${pdir}bye.1";
605+
606+# One func, one %.
607+run_make_test("
608+$se
609+all: ${d}bye.x
610+$r%.x: $dollar\$(firstword %.1); \$(info \$@ from \$^)
611+.PHONY: $prereqs
612+", '', "${d}bye.x from $prereqs\n#MAKE#: Nothing to be done for 'all'.\n");
613+
614+$prereqs = "${pdir}bye.1 ${pdir}bye.2";
615+
616+# Multiple funcs, each has one %.
617+run_make_test("
618+$se
619+all: ${d}bye.x
620+$r%.x: $dollar\$(firstword %.1) $dollar\$(firstword %.2); \$(info \$@ from \$^)
621+.PHONY: $prereqs
622+", '', "${d}bye.x from $prereqs\n#MAKE#: Nothing to be done for 'all'.\n");
623+
624+$prereqs = "${pdir}bye.1 ${pdir}bye.2 ${pdir}bye.3 ${pdir}bye.4";
625+
626+# Multiple funcs, each has multiple %.
627+run_make_test("
628+$se
629+all: ${d}bye.x
630+$r%.x: $dollar\$(wordlist 1, 99, %.1 %.2) $dollar\$(wordlist 1, 99, %.3 %.4); \$(info \$@ from \$^)
631+.PHONY: $prereqs
632+", '', "${d}bye.x from $prereqs\n#MAKE#: Nothing to be done for 'all'.\n");
633+
634+$prereqs = "${pdir}bye.1 ${pdir}bye.2 ${pdir}bye.3 ${pdir}bye.4";
635+
636+# Nested functions.
637+run_make_test("
638+$se
639+all: ${d}bye.x
640+$r%.x: $dollar\$(wordlist 1, 99, $dollar\$(wordlist 1, 99, %.1 %.2)) $dollar\$(wordlist 1, 99, $dollar\$(wordlist 1,99, %.3 %.4)); \$(info \$@ from \$^)
641+.PHONY: $prereqs
642+", '', "${d}bye.x from $prereqs\n#MAKE#: Nothing to be done for 'all'.\n");
643+
644+$prereqs = "${pdir}bye1%2% ${pdir}bye ${pdir}3bye4%5 ${pdir}6bye ${pdir}bye7%8 ${pdir}bye9 ${pdir}bye10% ${pdir}11bye12 13";
645+
646+# Multiple funcs, each has multiple words, each word has multiple %, sole %,
647+# various corner cases.
648+# Make should substitute the first % and only the first % in each word with the
649+# stem.
650+run_make_test("
651+$se
652+all: ${d}bye.x
653+$r%.x: $dollar\$(wordlist 1, 99, %1%2% % 3%4%5 6%) %7%8 %9 $dollar\$(wordlist 1, 99, %10% 11%12) 13; \$(info \$@ from \$^)
654+.PHONY: $prereqs
655+", '', "${d}bye.x from $prereqs\n#MAKE#: Nothing to be done for 'all'.\n");
656+
657+if ($port_type eq 'UNIX') {
658+# Test that make does not use some hardcoded array of a finite size on stack.
659+# Long prerequisite name. This prerequisite name is over 66K long.
660+my $prefix = 'abcdefgh' x 128 x 33; # 33K long.
661+my $suffix = 'stuvwxyz' x 128 x 33; # 33K long.
662+$prereqs = "${pdir}${prefix}bye${suffix}.1 ${pdir}${prefix}bye${suffix}.2";
663+
664+run_make_test("
665+$se
666+all: ${d}bye.x
667+$r%.x: $dollar\$(wordlist 1, 99, ${prefix}%${suffix}.1 ${prefix}%${suffix}.2); \$(info \$@ from \$^)
668+.PHONY: $prereqs
669+", '', "${d}bye.x from $prereqs\n#MAKE#: Nothing to be done for 'all'.\n");
670+}
671+
672+}
673+}
674+}
675+
676+# SV 66268. An error message about a failure to remove an intermediate file.
677+if (defined $ERR_unreadable_file) {
678+  run_make_test(q!
679+  all: hello.x
680+  %.x: b/%.q; $(info $@ from $<)
681+  b/%.q:; @mkdir b; touch $@; chmod -w b
682+  !, '', "hello.x from b/hello.q\nrm b/hello.q\n#MAKE#: unlink: b/hello.q: $ERR_unreadable_file\n");
683+
684+  chmod(0754, 'b');
685+  unlink('b/hello.q');
686+  rmdir('b');
687+
688+  run_make_test(q!
689+  all: hello.x
690+  %.x: b/%.q; $(info $@ from $<)
691+  b/%.q:; @mkdir b; touch $@; chmod -w b
692+  !, '-s', "hello.x from b/hello.q\n#MAKE#: unlink: b/hello.q: $ERR_unreadable_file\n");
693+
694+  chmod(0754, 'b');
695+  unlink('b/hello.q');
696+  rmdir('b');
697+}
698+
699+# SV 66273. An explicitly mentioned prerequisite is not intermediate, even in
700+# the case of double colon.
701+unlink('hello.q', 'hello.x');
702+run_make_test(q!
703+all: hello.x
704+%.x: %.q; $(info $@ from $<)
705+hello.q::; touch $@
706+!,
707+              '', "touch hello.q\nhello.x from hello.q\n");
708+unlink('hello.q');
709+
710+# This tells the test driver that the perl test script executed properly.
711+1;
+31, -0
 1@@ -0,0 +1,31 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "The following test creates a makefile to test using \n" .
 5+               "quotes within makefiles.";
 6+
 7+open(MAKEFILE,"> $makefile");
 8+
 9+# The Contents of the MAKEFILE ...
10+
11+print MAKEFILE <<'EOM';
12+TEXFONTS = NICEFONT
13+DEFINES = -DDEFAULT_TFM_PATH=\".:$(TEXFONTS)\"
14+test: ; @"echo" 'DEFINES = $(DEFINES)'
15+EOM
16+
17+# END of Contents of MAKEFILE
18+
19+close(MAKEFILE);
20+
21+
22+&run_make_with_options($makefile,"",&get_logfile);
23+
24+
25+# Create the answer to what should be produced by this Makefile
26+$answer = 'DEFINES = -DDEFAULT_TFM_PATH=\".:NICEFONT\"' . "\n";
27+
28+# COMPARE RESULTS
29+
30+&compare_output($answer,&get_logfile(1));
31+
32+1;
+67, -0
 1@@ -0,0 +1,67 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Test recursion.";
 4+
 5+$details = "DETAILS";
 6+
 7+# Test some basic recursion.
 8+run_make_test('
 9+.RECIPEPREFIX := |
10+all:
11+|       $(MAKE) -f #MAKEFILE# foo
12+foo:
13+|       @echo $(MAKE)
14+|       @echo MAKELEVEL = $(MAKELEVEL)
15+|       $(MAKE) -f #MAKEFILE# last
16+last:
17+|       @echo $(MAKE)
18+|       @echo MAKELEVEL = $(MAKELEVEL)
19+|       @echo THE END
20+',
21+              ('CFLAGS=-O -w' . ($parallel_jobs ? ' -j 2' : '')),
22+              ($vos
23+               ? "#MAKE#: Entering directory '#PWD#'
24+make 'CFLAGS=-O' -f #MAKEFILE# foo
25+make CFLAGS=-O
26+MAKELEVEL = 0
27+make 'CFLAGS=-O' -f #MAKEFILE# last
28+make CFLAGS=-O
29+MAKELEVEL = 0
30+THE END
31+#MAKE#: Leaving directory '#PWD#'"
32+               : "#MAKE#: Entering directory '#PWD#'
33+#MAKEPATH# -f #MAKEFILE# foo
34+#MAKE#[1]: Entering directory '#PWD#'
35+#MAKEPATH#
36+MAKELEVEL = 1
37+#MAKEPATH# -f #MAKEFILE# last
38+#MAKE#[2]: Entering directory '#PWD#'
39+#MAKEPATH#
40+MAKELEVEL = 2
41+THE END
42+#MAKE#[2]: Leaving directory '#PWD#'
43+#MAKE#[1]: Leaving directory '#PWD#'
44+#MAKE#: Leaving directory '#PWD#'"));
45+
46+
47+# Test command line overrides.
48+run_make_test('
49+recur: all ; @$(MAKE) --no-print-directory -f #MAKEFILE# a=AA all
50+all: ; @echo "MAKEOVERRIDES = $(MAKEOVERRIDES)"
51+',
52+              'a=ZZ',
53+              'MAKEOVERRIDES = a=ZZ
54+MAKEOVERRIDES = a=AA
55+');
56+
57+# SV 46013: Ensure that MAKEOVERRIDES is passed even if set in the makefile
58+run_make_test(q!
59+ifeq ($(MAKELEVEL),0)
60+MAKEOVERRIDES += FOO+=bar
61+endif
62+.PHONY: M R
63+M: ; @$(MAKE) --no-print-directory -f #MAKEFILE# R
64+R: ; @echo '$(FOO)'
65+!,
66+              '', 'bar');
67+
68+1;
+182, -0
  1@@ -0,0 +1,182 @@
  2+#                                                              -*-mode: perl-*-
  3+
  4+$description = "Test GNU Make's auto-reinvocation feature.";
  5+
  6+$details = "\
  7+If the makefile or one it includes can be rebuilt then it is, and make
  8+is reinvoked.  We create a rule to rebuild the makefile from a temp
  9+file, then touch the temp file to make it newer than the makefile.";
 10+
 11+$omkfile = $makefile;
 12+
 13+&utouch(-600, 'incl.mk');
 14+# For some reason if we don't do this then the test fails for systems
 15+# with sub-second timestamps, maybe + NFS?  Not sure.
 16+&utouch(-1, 'incl-1.mk');
 17+
 18+run_make_test('
 19+all: ; @echo running rules.
 20+
 21+#MAKEFILE# incl.mk: incl-1.mk ; @echo rebuilding $@; echo >> $@
 22+
 23+include incl.mk',
 24+              '', "rebuilding incl.mk\nrunning rules.\n");
 25+
 26+# Make sure updating the makefile itself also works
 27+
 28+&utouch(-600, $omkfile);
 29+
 30+run_make_test(undef, '', "rebuilding #MAKEFILE#\nrunning rules.\n");
 31+
 32+&rmfiles('incl.mk', 'incl-1.mk');
 33+
 34+
 35+# In this test we create an included file that's out-of-date, but then
 36+# the rule doesn't update it.  Make shouldn't re-exec.
 37+
 38+&utouch(-600, 'b','a');
 39+#&utouch(-10, 'a');
 40+&touch('c');
 41+
 42+run_make_test('
 43+all: ; @echo hello
 44+
 45+a : b ; echo >> $@
 46+
 47+b : c ; test -f $@ || echo >> $@
 48+
 49+c: ; echo >> $@
 50+
 51+include $(F)',
 52+              'F=a', "test -f b || echo >> b\nhello\n");
 53+
 54+# Now try with the file we're not updating being the actual file we're
 55+# including: this and the previous one test different parts of the code.
 56+
 57+run_make_test(undef, 'F=b', "test -f b || echo >> b\nhello\n");
 58+
 59+&rmfiles('a','b','c');
 60+
 61+# Ensure command line variables are preserved properly across re-exec
 62+# Tests for Savannah bug #30723
 63+
 64+run_make_test('
 65+ifdef RECURSE
 66+-include foo30723
 67+endif
 68+recurse: ; @$(MAKE) -f $(MAKEFILE_LIST) RECURSE=1 test
 69+test: ; @echo F.O=$(F.O)
 70+foo30723: ; @touch $@
 71+',
 72+              '--no-print-directory F.O=bar', "F.O=bar\n");
 73+
 74+unlink('foo30723');
 75+
 76+# If ANY makefile is rebuilt then we should re-exec
 77+
 78+run_make_test('
 79+all: ; @echo RESTARTS=$(MAKE_RESTARTS)
 80+
 81+m1.d: ; @echo $@; touch $@
 82+
 83+m2.d: m1.d ; @test -f $< || { echo $@; touch $@; }
 84+
 85+include m1.d
 86+-include m2.d
 87+',
 88+              '', "m1.d\nRESTARTS=1\n");
 89+
 90+unlink('m1.d', 'm2.d');
 91+
 92+# Same as before but be sure we get error messages for un-created makefiles
 93+run_make_test('
 94+all: ; @echo RESTARTS=$(MAKE_RESTARTS)
 95+
 96+m1.d: ; @echo $@; touch $@
 97+
 98+m2.d: m1.d ; @test -f $< || { echo $@; touch $@; }
 99+
100+include m1.d m2.d
101+', '',
102+              # This runs afoul of https://savannah.gnu.org/bugs/?61226
103+              0 ? "m1.d\n#MAKEFILE#:8: m2.d: $ERR_no_such_file"
104+                  : "m1.d\nRESTARTS=1",
105+              0 ? 512 : 0);
106+
107+unlink('m1.d', 'm2.d');
108+
109+# sv 61226.
110+# This set of four cases tests two aspects of make.
111+#
112+# 1. If a rule has no prerequisites or recipe, and the target of the rule is a
113+# nonexistent file, then make imagines this target to have been updated
114+# whenever its rule is run.
115+#
116+# 2. Make does not re-execute itself in this case of imagined target.
117+#
118+# Test case 1.
119+# Make imagines hello.d was updated by a rule without recipe and without
120+# prereqs.
121+# This should succeed.
122+# Make should not re-execute itself.
123+run_make_test('
124+hello.o: hello.d; $(info RESTARTS=$(MAKE_RESTARTS))
125+hello.d:
126+include hello.d
127+', '', "RESTARTS=\n#MAKE#: 'hello.o' is up to date.");
128+
129+# Test case 2.
130+# Make imagines hello.d was updated by a rule with a recipe and without
131+# prereqs.
132+# This should succeed.
133+# Make should not re-execute itself.
134+run_make_test('
135+hello.o: hello.d; $(info RESTARTS=$(MAKE_RESTARTS))
136+hello.d:; $(info $@)
137+include hello.d
138+', '', "hello.d\nRESTARTS=\n#MAKE#: 'hello.o' is up to date.");
139+
140+&touch('hello.td');
141+# Test case 3.
142+# Make imagines hello.d was updated by a rule without a recipe and with
143+# prereqs.
144+# This should succeed.
145+# Make should not re-execute itself.
146+run_make_test('
147+hello.o: hello.d; $(info RESTARTS=$(MAKE_RESTARTS))
148+hello.d: hello.td
149+include hello.d
150+', '', "RESTARTS=\n#MAKE#: 'hello.o' is up to date.");
151+
152+# Test case 4.
153+# Same test as three tests above, but the rule has both recipe and prereqs.
154+# Make should report this error.
155+run_make_test('
156+hello.o: hello.d; $(info $@)
157+hello.d: hello.td; $(info $@)
158+include hello.d
159+', '',
160+              # This runs afoul of https://savannah.gnu.org/bugs/?61226
161+              0 ? "hello.d\n#MAKEFILE#:4: hello.d: $ERR_no_such_file"
162+                  : "hello.d\nhello.o\n#MAKE#: 'hello.o' is up to date.",
163+              0 ? 512 : 0);
164+
165+unlink('hello.td');
166+
167+# Test SV 62088 : make sure we don't re-invoke for stdin makefiles.
168+# The test framework doesn't seem to have a good way to do this.
169+
170+create_file('input.mk', "all:;\$(info all)\n");
171+
172+close(STDIN);
173+open(STDIN, "<", 'input.mk') || die "input.mk: $!\n";
174+
175+run_make_test('', '-sf -', "all\n");
176+
177+
178+# This close MUST come at the end of the test!!
179+close(STDIN);
180+unlink('input.mk');
181+
182+# This tells the test driver that the perl test script executed properly.
183+1;
+37, -0
 1@@ -0,0 +1,37 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test globbing in targets and prerequisites.";
 5+
 6+$details = "";
 7+
 8+touch(qw(a.one a.two a.three));
 9+
10+# Test wildcards in regular targets and prerequisites
11+run_make_test(q{
12+.PHONY: all a.one a.two a.three
13+all: a.one* a.t[a-z0-9]o a.th[!q]ee
14+a.o[Nn][Ee] a.t*: ; @echo $@
15+},
16+              '', "a.one\na.two\na.three");
17+
18+# Test wildcards in pattern targets and prerequisites
19+run_make_test(q{
20+.PHONY: all
21+all: a.four
22+%.four : %.t* ; @echo $@: $(sort $^)
23+},
24+              '', "a.four: a.three a.two");
25+
26+# Test wildcards in second expansion targets and prerequisites
27+run_make_test(q{
28+.PHONY: all
29+all: a.four
30+.SECONDEXPANSION:
31+%.four : $$(sort %.t*) ; @echo $@: $(sort $^)
32+},
33+              '', "a.four: a.three a.two");
34+
35+unlink(qw(a.one a.two a.three));
36+
37+# This tells the test driver that the perl test script executed properly.
38+1;
+504, -0
  1@@ -0,0 +1,504 @@
  2+#                                                                    -*-perl-*-
  3+$description = "Test second expansion in ordinary rules.";
  4+
  5+$details = "";
  6+
  7+# TEST #0: Test handing of '$' in prerequisites with and without second
  8+# expansion.
  9+
 10+# If we don't support archives then the prerequisite is different
 11+my $prereq = exists $FEATURES{'archives'} ? '$' : '$(PRE)';
 12+
 13+run_make_test(q!
 14+ifdef SE
 15+  .SECONDEXPANSION:
 16+endif
 17+foo$$bar: bar$$baz bar$$biz ; @echo '$@ : $^'
 18+PRE = one two
 19+bar$$baz: $$(PRE)
 20+baraz: $$(PRE)
 21+PRE = three four
 22+.DEFAULT: ; @echo '$@'
 23+!,
 24+              '',
 25+              "$prereq\nbar\$biz\nfoo\$bar : bar\$baz bar\$biz");
 26+
 27+run_make_test(undef, 'SE=1', "three\nfour\nbariz\nfoo\$bar : baraz bariz");
 28+
 29+# TEST #1: automatic variables.
 30+#
 31+run_make_test(q!
 32+.SECONDEXPANSION:
 33+.DEFAULT: ; @echo '$@'
 34+
 35+foo: bar baz
 36+
 37+foo: biz | buz
 38+
 39+foo: $$@.1 \
 40+     $$<.2 \
 41+     $$(addsuffix .3,$$^) \
 42+     $$(addsuffix .4,$$+) \
 43+     $$|.5 \
 44+     $$*.6
 45+
 46+!,
 47+'',
 48+'bar
 49+baz
 50+biz
 51+buz
 52+foo.1
 53+bar.2
 54+bar.3
 55+baz.3
 56+biz.3
 57+bar.4
 58+baz.4
 59+biz.4
 60+buz.5
 61+.6
 62+');
 63+
 64+
 65+# Test #2: target/pattern -specific variables.
 66+#
 67+run_make_test(q!
 68+.SECONDEXPANSION:
 69+.DEFAULT: ; @echo '$@'
 70+
 71+foo.x: $$a $$b
 72+
 73+foo.x: a := bar
 74+
 75+%.x: b := baz
 76+!,
 77+'',
 78+'bar
 79+baz
 80+');
 81+
 82+
 83+# Test #3: order of prerequisites.
 84+#
 85+run_make_test(q!
 86+.SECONDEXPANSION:
 87+.DEFAULT: ; @echo '$@'
 88+
 89+all: foo bar baz
 90+
 91+# Subtest #1
 92+foo: foo.1; @:
 93+foo: foo.2
 94+foo: foo.3
 95+
 96+# Subtest #2
 97+bar: bar.2
 98+bar: bar.1; @:
 99+bar: bar.3
100+
101+# Subtest #3
102+baz: baz.1
103+baz: baz.2
104+baz: ; @:
105+!,
106+'',
107+'foo.1
108+foo.2
109+foo.3
110+bar.1
111+bar.2
112+bar.3
113+baz.1
114+baz.2
115+');
116+
117+# TEST #4: eval in a context where there is no reading_file
118+run_make_test(q!
119+.SECONDEXPANSION:
120+all : $$(eval $$(info test))
121+!,
122+            '', "test\n#MAKE#: Nothing to be done for 'all'.\n");
123+
124+# TEST #5: (NEGATIVE) catch eval in a prereq list trying to create new
125+# target/prereq relationships.
126+
127+run_make_test(q!
128+.SECONDEXPANSION:
129+proj1.exe : proj1.o $$(eval $$(test))
130+define test
131+proj1.o : proj1.c
132+proj1.c: proj1.h
133+endef
134+!,
135+              '', "#MAKE#: *** prerequisites cannot be defined in recipes.  Stop.\n", 512);
136+
137+
138+# Automatic $$+ variable expansion issue.  Savannah bug #25780
139+run_make_test(q!
140+all : foo foo
141+.SECONDEXPANSION:
142+all : $$+ ; @echo '$+'
143+foo : ;
144+!,
145+                  '', "foo foo foo foo\n");
146+
147+
148+# Automatic $$+ variable expansion issue.  Savannah bug #25780
149+run_make_test(q!
150+all : bar bar
151+bar : ;
152+q%x : ;
153+.SECONDEXPANSION:
154+a%l: q1x $$+ q2x ; @echo '$+'
155+!,
156+                  '', "q1x bar bar q2x bar bar\n");
157+
158+
159+# Allow patsubst shorthand in second expansion context.
160+# Requires the colon to be quoted.  Savannah bug #16545
161+run_make_test(q!
162+.PHONY: foo.bar
163+.SECONDEXPANSION:
164+foo: $$(@\\:%=%.bar); @echo '$^'
165+!,
166+              '', "foo.bar\n");
167+
168+# SV 54549 : Ensure we don't free used variable_sets
169+run_make_test(q!
170+foo: -lcat
171+
172+# Removing second expansion prevents segfault
173+.SECONDEXPANSION:
174+foo: $$@.o ;
175+
176+# Having an empty command here prevents segfault unless,
177+# the environment is empty. `env -i make foo`
178+# MFLAGS=-w or MAKEFLAGS=-w `env MFLAGS=-w make foo`
179+# libcat.a target calls an extra command, `@true \n @touch $@`
180+# odd.
181+%.o: ; @true
182+
183+# Having an empty command prevents segfault.
184+-l%: lib%.a ; @true
185+
186+# Not creating libcat.a here prevents segfault,
187+libcat.a: ; @touch $@
188+!,
189+              '', q!#MAKEFILE#:16: recipe was specified for file '-lcat' at #MAKEFILE#:16,
190+#MAKEFILE#:16: but '-lcat' is now considered the same file as 'libcat.a'
191+#MAKEFILE#:16: recipe for '-lcat' will be ignored in favor of the one for 'libcat.a'!);
192+unlink('libcat.a');
193+
194+# SV 28456 : Don't reset $$< for default recipes
195+run_make_test(q!
196+.SECONDEXPANSION:
197+
198+.PHONY: biz baz
199+biz: baz ;
200+biz: $$(info $$<)
201+!,
202+              '', "baz\n#MAKE#: Nothing to be done for 'biz'.\n");
203+
204+
205+# sv 60659. Second expansion of automatic variables inside a function in the
206+# prerequisite list.
207+# $$@ expands to the target in the 1st and following rules.
208+# $$<,$$^,$$+,$$|,$$?,$$*,$$% expand to the empty string in the prerequisite
209+# list of the 1st rule.
210+# $$<,$$^,$$+,$$|,$$?,$$*,$$% in the prerequisite list of the 2nd (and
211+# following) rule expand to the values from the 1st rule.
212+
213+
214+# subtest 1. Explicit rules. 1st rule.
215+run_make_test(q!
216+.SECONDEXPANSION:
217+all: 2.x
218+2.x: 5.z 6.z 5.z $$(info @=$$@,<=$$<,^=$$^,+=$$+,|=$$|,?=$$?,*=$$*,%=$$%) ;
219+%.z: ;
220+!, '',
221+"@=2.x,<=,^=,+=,|=,?=,*=,%=
222+#MAKE#: Nothing to be done for 'all'.\n");
223+
224+
225+# subtest 2. Explicit rules. 2nd rule.
226+run_make_test(q!
227+.SECONDEXPANSION:
228+all: 15.x 1.x
229+15.x: 5.z 6.z 5.z | 7.z 7.z 8.z
230+1.x: 1.z 2.z 2.z | 3.z 4.z
231+15.x 1.x: 9.z $$(info @=$$@,<=$$<,^=$$^,+=$$+,|=$$|,?=$$?,*=$$*,%=$$%) ;
232+%.z: ;
233+!, '',
234+"@=15.x,<=5.z,^=5.z 6.z,+=5.z 6.z 5.z,|=7.z 8.z,?=,*=,%=
235+@=1.x,<=1.z,^=1.z 2.z,+=1.z 2.z 2.z,|=3.z 4.z,?=,*=,%=
236+#MAKE#: Nothing to be done for 'all'.\n");
237+
238+
239+# subtest 3. Grouped targets in explicit rules. 1st rule.
240+run_make_test(q!
241+.SECONDEXPANSION:
242+all: 15.x
243+15.x 1.x&: 5.z 6.z 5.z $$(info @=$$@,<=$$<,^=$$^,+=$$+,|=$$|,?=$$?,*=$$*,%=$$%) ;
244+%.z: ;
245+!, '',
246+"@=15.x,<=,^=,+=,|=,?=,*=,%=
247+@=1.x,<=,^=,+=,|=,?=,*=,%=
248+#MAKE#: Nothing to be done for 'all'.\n");
249+
250+
251+# subtest 4. Grouped targets in explicit rules. 2nd rule.
252+run_make_test(q!
253+.SECONDEXPANSION:
254+all: 15.x 1.x
255+15.x: 5.z 6.z 5.z | 7.z 7.z 8.z
256+1.x: 1.z 2.z 2.z | 3.z 4.z
257+15.x 1.x&: 9.z $$(info @=$$@,<=$$<,^=$$^,+=$$+,|=$$|,?=$$?,*=$$*,%=$$%) ;
258+%.z: ;
259+!, '',
260+"@=15.x,<=5.z,^=5.z 6.z,+=5.z 6.z 5.z,|=7.z 8.z,?=,*=,%=
261+@=1.x,<=1.z,^=1.z 2.z,+=1.z 2.z 2.z,|=3.z 4.z,?=,*=,%=
262+#MAKE#: Nothing to be done for 'all'.\n");
263+
264+
265+# Double colon rules.
266+# Because each double colon rule is independent of the other double colon rules
267+# for the same target, each automatic variable in the prerequisite list, other
268+# than $$@, second expands to the empty string in any rule, 1st, 2nd or later.
269+
270+# subtest 5. 1st double colon rule.
271+run_make_test(q!
272+.SECONDEXPANSION:
273+all: 2.x
274+2.x:: 5.z 6.z 5.z $$(info @=$$@,<=$$<,^=$$^,+=$$+,|=$$|,?=$$?,*=$$*,%=$$%) ;
275+%.z: ;
276+!, '',
277+"@=2.x,<=,^=,+=,|=,?=,*=,%=
278+#MAKE#: Nothing to be done for 'all'.\n");
279+
280+
281+# subtest 6. 2nd double colon rule.
282+run_make_test(q!
283+.SECONDEXPANSION:
284+all: 15.x 1.x
285+15.x:: 5.z 6.z 5.z | 7.z 7.z 8.z ;
286+1.x:: 1.z 2.z 2.z | 3.z 4.z ;
287+15.x 1.x:: 9.z $$(info @=$$@,<=$$<,^=$$^,+=$$+,|=$$|,?=$$?,*=$$*,%=$$%) ;
288+%.z: ;
289+!, '',
290+"@=15.x,<=,^=,+=,|=,?=,*=,%=
291+@=1.x,<=,^=,+=,|=,?=,*=,%=
292+#MAKE#: Nothing to be done for 'all'.\n");
293+
294+
295+# sv 62324.
296+# Integrity self check.
297+run_make_test(q!
298+.SECONDEXPANSION:
299+all: bye.x
300+bye.x: $$(firstword bye.1;
301+!, '', "#MAKEFILE#:4: *** unterminated call to function 'firstword': missing ')'.  Stop.", 512);
302+
303+unlink('hello.tsk', 'test.o', 'bye.tsk', 'hello.o', 'hello.h', 'hello.q', 'bye.c', 'bye.o');
304+
305+# sv 62706.
306+# Test that makes avoids second expanding prerequisites of the targets which
307+# are not built.
308+# Here, hello.tsk is built and its prerequisites are second expanded.
309+# bye.tsk is not built and its prerequisites are not second expanded.
310+run_make_test(q!
311+.SECONDEXPANSION:
312+hello.tsk: hello.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
313+bye.tsk: bye.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
314+hello.o: $$(info second expansion of $$@ prereqs); $(info $@)
315+bye.o: $$(info second expansion of $$@ prereqs); $(info $@)
316+!, 'hello.tsk',
317+"second expansion of hello.tsk prereqs
318+second expansion of hello.o prereqs
319+hello.o
320+hello.tsk from hello.o
321+#MAKE#: 'hello.tsk' is up to date.\n");
322+
323+# sv 62706.
324+# Multiple rules per target.
325+run_make_test(q!
326+.SECONDEXPANSION:
327+
328+all: hello.tsk
329+dep1:=hello.o
330+dep2:=hello.h
331+hello.tsk: $$(dep1)
332+hello.tsk: $$(dep2); $(info $@ from $^)
333+hello.o:; $(info $@)
334+hello.h:; $(info $@)
335+!, 'hello.tsk',
336+"hello.h
337+hello.o
338+hello.tsk from hello.h hello.o
339+#MAKE#: 'hello.tsk' is up to date.\n");
340+
341+# sv 62706.
342+# Multiple targets per rule.
343+run_make_test(q!
344+.SECONDEXPANSION:
345+hello.tsk bye.tsk: hello.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
346+bye.tsk: bye.o $$(info second expansion of $$@ prereqs)
347+hello.o: $$(info second expansion of $$@ prereqs); $(info $@)
348+bye.o: $$(info second expansion of $$@ prereqs); $(info $@)
349+!, 'hello.tsk',
350+"second expansion of hello.tsk prereqs
351+second expansion of hello.o prereqs
352+hello.o
353+hello.tsk from hello.o
354+#MAKE#: 'hello.tsk' is up to date.\n");
355+
356+# sv 62706.
357+# Grouped targets.
358+run_make_test(q!
359+.SECONDEXPANSION:
360+world.tsk: world.o $$(info 1 second expansion of $$@ prereqs)
361+hello.tsk world.tsk &: hello.o $$(info 2 second expansion of $$@ prereqs); $(info $@ from $<)
362+bye.tsk: bye.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
363+hello.o: $$(info second expansion of $$@ prereqs); $(info $@)
364+world.o: $$(info second expansion of $$@ prereqs); $(info $@)
365+bye.o: $$(info second expansion of $$@ prereqs); $(info $@)
366+!, 'hello.tsk',
367+"2 second expansion of hello.tsk prereqs
368+second expansion of hello.o prereqs
369+hello.o
370+2 second expansion of world.tsk prereqs
371+1 second expansion of world.tsk prereqs
372+second expansion of world.o prereqs
373+world.o
374+hello.tsk from hello.o
375+#MAKE#: 'hello.tsk' is up to date.\n");
376+
377+# sv 62706.
378+# Order only.
379+run_make_test(q!
380+.SECONDEXPANSION:
381+hello.tsk:| hello.o $$(info second expansion of $$@ prereqs); $(info $@ from $|)
382+bye.tsk:| bye.o $$(info second expansion of $$@ prereqs); $(info $@ from $|)
383+hello.o:| $$(info second expansion of $$@ prereqs); $(info $@)
384+bye.o:| $$(info second expansion of $$@ prereqs); $(info $@)
385+!, 'hello.tsk',
386+"second expansion of hello.tsk prereqs
387+second expansion of hello.o prereqs
388+hello.o
389+hello.tsk from hello.o
390+#MAKE#: 'hello.tsk' is up to date.\n");
391+
392+# sv 62706.
393+# Double colon. 1 rule per target.
394+run_make_test(q!
395+.SECONDEXPANSION:
396+hello.tsk:: hello.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
397+bye.tsk:: bye.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
398+hello.o:: $$(info second expansion of $$@ prereqs); $(info $@)
399+bye.o:: $$(info second expansion of $$@ prereqs); $(info $@)
400+!, 'hello.tsk',
401+"second expansion of hello.tsk prereqs
402+second expansion of hello.o prereqs
403+hello.o
404+hello.tsk from hello.o
405+#MAKE#: 'hello.tsk' is up to date.\n");
406+
407+# sv 62706.
408+# Double colon. 2 rules per targets.
409+run_make_test(q!
410+.SECONDEXPANSION:
411+hello.tsk:: hello.o $$(info 1 second expansion of $$@ prereqs); $(info 1 $@ from $<)
412+hello.tsk:: hello.o $$(info 2 second expansion of $$@ prereqs); $(info 2 $@ from $<)
413+bye.tsk:: bye.o $$(info 1 second expansion of $$@ prereqs); $(info 1 $@ from $<)
414+bye.tsk:: bye.o $$(info 2 second expansion of $$@ prereqs); $(info 2 $@ from $<)
415+hello.o:: $$(info 1 second expansion of $$@ prereqs); $(info 1 $@)
416+hello.o:: $$(info 2 second expansion of $$@ prereqs); $(info 2 $@)
417+bye.o:: $$(info 1 second expansion of $$@ prereqs); $(info 1 $@)
418+bye.o:: $$(info 2 second expansion of $$@ prereqs); $(info 2 $@)
419+!, 'hello.tsk',
420+"1 second expansion of hello.tsk prereqs
421+1 second expansion of hello.o prereqs
422+1 hello.o
423+2 second expansion of hello.o prereqs
424+2 hello.o
425+1 hello.tsk from hello.o
426+2 second expansion of hello.tsk prereqs
427+2 hello.tsk from hello.o
428+#MAKE#: 'hello.tsk' is up to date.\n");
429+
430+# sv 62706.
431+# Test that the prerequisites of 'hello.tsk' are second expanded once.
432+run_make_test(q!
433+.SECONDEXPANSION:
434+all: hello.tsk hello.q
435+hello.tsk: hello.o $$(info second expansion of $$@ prereqs); $(info $@ from $^)
436+hello.o: $$(info second expansion of $$@ prereqs); $(info $@)
437+hello.q: hello.tsk $$(info second expansion of $$@ prereqs); $(info $@ from $^)
438+!, '',
439+"second expansion of hello.tsk prereqs
440+second expansion of hello.o prereqs
441+hello.o
442+hello.tsk from hello.o
443+second expansion of hello.q prereqs
444+hello.q from hello.tsk
445+#MAKE#: Nothing to be done for 'all'.\n");
446+
447+# sv 62706.
448+# Merge vpath file and local file.
449+# Test that both sets of prerequisites from 'hello.c' rule and from
450+# 'src/hello.c' rule are second expanded.
451+run_make_test(q!
452+.SECONDEXPANSION:
453+vpath hello.c src
454+all: hello.c; $(info $@ from $^)
455+hello.c: $$(info second expansion of hello.c prereqs); $(info 1 $@)
456+src/hello.c: $$(info second expansion of src/hello.c prereqs); $(info 2 $@)
457+!, '',
458+"#MAKEFILE#:5: recipe was specified for file 'hello.c' at #MAKEFILE#:5,
459+#MAKEFILE#:5: but 'hello.c' is now considered the same file as 'src/hello.c'
460+#MAKEFILE#:5: recipe for 'hello.c' will be ignored in favor of the one for 'src/hello.c'
461+second expansion of src/hello.c prereqs
462+second expansion of hello.c prereqs
463+2 src/hello.c
464+all from src/hello.c
465+#MAKE#: 'all' is up to date.\n");
466+
467+# sv 62706.
468+# .DEFAULT.
469+run_make_test(q!
470+.SECONDEXPANSION:
471+bye:=bye.c
472+all: hello.o
473+.DEFAULT: $$(info second expansion of prereqs of default recipe @ = $$@) ; $(info default recipe $@)
474+!, '',
475+"default recipe hello.o
476+#MAKE#: Nothing to be done for 'all'.\n");
477+
478+unlink('hello.1');
479+
480+# sv 62706.
481+# No side effects from second expansion of unrelated rules.
482+run_make_test(q!
483+.SECONDEXPANSION:
484+hello.tsk:; exit 1
485+unrelated: $$(shell touch hello.1);
486+!, '',
487+"exit 1
488+#MAKE#: *** [#MAKEFILE#:3: hello.tsk] Error 1\n", 512);
489+
490+# sv 62706.
491+# Second expansion of intermediate prerequisites.
492+# The rule to build hello.x is explicit.
493+# .SECONDARY marks hello.x as intermediate.
494+# Test that $$(deps) is secondary expanded.
495+run_make_test(q!
496+deps:=hello.h
497+.SECONDEXPANSION:
498+.SECONDARY: hello.x
499+all: hello.x
500+hello.x: $$(deps); $(info $@)
501+hello.h:; $(info $@)
502+!, '', "hello.h\nhello.x\n#MAKE#: Nothing to be done for 'all'.\n");
503+
504+
505+1;
+506, -0
  1@@ -0,0 +1,506 @@
  2+#                                                                    -*-perl-*-
  3+$description = "Test second expansion in implicit rules.";
  4+
  5+$details = "";
  6+
  7+use Cwd;
  8+
  9+$dir = cwd;
 10+$dir =~ s,.*/([^/]+)$,../$1,;
 11+
 12+
 13+# Test #1: automatic variables.
 14+#
 15+run_make_test(q!
 16+.SECONDEXPANSION:
 17+.DEFAULT: ; @echo '$@'
 18+
 19+foo.a: bar baz
 20+
 21+foo.a: biz | buz
 22+
 23+foo.%: 1.$$@ \
 24+       2.$$< \
 25+       $$(addprefix 3.,$$^) \
 26+       $$(addprefix 4.,$$+) \
 27+       5.$$| \
 28+       6.$$* ; @:
 29+
 30+1.foo.a \
 31+2.bar \
 32+3.bar \
 33+3.baz \
 34+3.biz \
 35+4.bar \
 36+4.baz \
 37+4.biz \
 38+5.buz \
 39+6.a: ; @echo '$@'
 40+
 41+!,
 42+'',
 43+'1.foo.a
 44+2.bar
 45+3.bar
 46+3.baz
 47+3.biz
 48+4.bar
 49+4.baz
 50+4.biz
 51+5.buz
 52+6.a
 53+bar
 54+baz
 55+biz
 56+buz
 57+');
 58+
 59+
 60+# Test #2: target/pattern -specific variables.
 61+#
 62+run_make_test(q!
 63+.SECONDEXPANSION:
 64+foo.x:
 65+
 66+foo.%: $$(%_a) $$(%_b) bar ; @:
 67+
 68+foo.x: x_a := bar
 69+
 70+%.x: x_b := baz
 71+
 72+bar baz: ; @echo '$@'
 73+!,
 74+              '', "bar\nbaz\n");
 75+
 76+
 77+# Test #3: order of prerequisites.
 78+#
 79+run_make_test(q!
 80+.SECONDEXPANSION:
 81+.DEFAULT: ; @echo '$@'
 82+
 83+all: foo bar baz
 84+
 85+
 86+# Subtest #1
 87+#
 88+%oo: %oo.1; @:
 89+
 90+foo: foo.2
 91+
 92+foo: foo.3
 93+
 94+foo.1: ; @echo '$@'
 95+
 96+
 97+# Subtest #2
 98+#
 99+bar: bar.2
100+
101+%ar: %ar.1; @:
102+
103+bar: bar.3
104+
105+bar.1: ; @echo '$@'
106+
107+
108+# Subtest #3
109+#
110+baz: baz.1
111+
112+baz: baz.2
113+
114+%az: ; @:
115+!,
116+              '',
117+'foo.1
118+foo.2
119+foo.3
120+bar.1
121+bar.2
122+bar.3
123+baz.1
124+baz.2
125+');
126+
127+
128+# Test #4: stem splitting logic.
129+#
130+run_make_test(q!
131+.SECONDEXPANSION:
132+$(dir)/tmp/bar.o:
133+
134+$(dir)/tmp/foo/bar.c: ; @echo '$@'
135+$(dir)/tmp/bar/bar.c: ; @echo '$@'
136+foo.h: ; @echo '$@'
137+
138+%.o: $$(addsuffix /%.c,foo bar) foo.h ; @echo '$@: {$<} $^'
139+!,
140+              "dir=$dir", "$dir/tmp/foo/bar.c
141+$dir/tmp/bar/bar.c
142+foo.h
143+$dir/tmp/bar.o: {$dir/tmp/foo/bar.c} $dir/tmp/foo/bar.c $dir/tmp/bar/bar.c foo.h
144+");
145+
146+
147+# Test #5: stem splitting logic and order-only prerequisites.
148+#
149+run_make_test(q!
150+.SECONDEXPANSION:
151+$(dir)/tmp/foo.o: $(dir)/tmp/foo.c
152+$(dir)/tmp/foo.c: ; @echo '$@'
153+bar.h: ; @echo '$@'
154+
155+%.o: %.c|bar.h ; @echo '$@: {$<} {$|} $^'
156+
157+!,
158+              "dir=$dir", "$dir/tmp/foo.c
159+bar.h
160+$dir/tmp/foo.o: {$dir/tmp/foo.c} {bar.h} $dir/tmp/foo.c
161+");
162+
163+
164+# Test #6: lack of implicit prerequisites.
165+#
166+run_make_test(q!
167+.SECONDEXPANSION:
168+foo.o: foo.c
169+foo.c: ; @echo '$@'
170+
171+%.o: ; @echo '$@: {$<} $^'
172+!,
173+              '', "foo.c\nfoo.o: {foo.c} foo.c\n");
174+
175+
176+# Test #7: Test stem from the middle of the name.
177+#
178+run_make_test(q!
179+.SECONDEXPANSION:
180+foobarbaz:
181+
182+foo%baz: % $$*.1 ; @echo '$*'
183+
184+bar bar.1: ; @echo '$@'
185+!,
186+              '', "bar\nbar.1\nbar\n");
187+
188+
189+# Test #8: Make sure stem triple-expansion does not happen.
190+#
191+run_make_test(q!
192+.SECONDEXPANSION:
193+foo$$bar:
194+
195+f%r: % $$*.1 ; @echo '$*'
196+
197+oo$$ba oo$$ba.1: ; @echo '$@'
198+!,
199+              '', 'oo$ba
200+oo$ba.1
201+oo$ba
202+');
203+
204+# Test #9: Check the value of $^
205+run_make_test(q!
206+.SECONDEXPANSION:
207+
208+%.so: | $$(extra) ; @echo $^
209+
210+foo.so: extra := foo.o
211+foo.so:
212+foo.o:
213+!,
214+              '', "\n");
215+
216+# Test #10: Test second expansion with second expansion prerequisites
217+# Ensures pattern_search() recurses with SE prereqs.
218+touch('a');
219+run_make_test(q!
220+.SECONDEXPANSION:
221+sim_base_rgg := just_a_name
222+sim_base_src := a
223+sim_base_f := a a a
224+sim_%.f: $${sim_$$*_f} ; echo $@
225+sim_%.src: $${sim_$$*_src} ; echo $@
226+sim_%: \
227+        $$(if $$(sim_$$*_src),sim_%.src) \
228+        $$(if $$(sim_$$*_f),sim_%.f) \
229+        $$(if $$(sim_$$*_rgg),$$(sim_$$*_rgg).s) ; echo $@
230+!,
231+              '-s sim_base', "#MAKE#: *** No rule to make target 'sim_base'.  Stop.", 512);
232+
233+unlink('a');
234+
235+# Ensure that order-only tokens embedded in second expansions are parsed
236+run_make_test(q!
237+.SECONDEXPANSION:
238+PREREQS=p1|p2
239+P2=p2
240+all : foo bar
241+f%o: $$(PREREQS) ; @echo '$@' from '$^' and '$|'
242+b%r: p1|$$(P2)   ; @echo '$@' from '$^' and '$|'
243+p% : ; : $@
244+!,
245+              "", ": p1\n: p2\nfoo from p1 and p2\nbar from p1 and p2\n");
246+
247+# SV 28456 : Don't reset $$< for default recipes
248+run_make_test(q!
249+.SECONDEXPANSION:
250+
251+.PHONY: foo bar
252+foo: bar
253+foo: $$(info $$<)
254+%oo: ;
255+!,
256+              '', "bar\n#MAKE#: Nothing to be done for 'foo'.\n");
257+
258+# SV 54161: Expand $$* properly when it contains a path
259+
260+run_make_test(q!
261+.SECONDEXPANSION:
262+%x: $$(info $$*); @echo '$*'
263+!,
264+              'q/ux', "q/u\nq/u\n");
265+
266+
267+
268+# sv 60188.
269+# Test that a file explicitly mentioned by the user and made by an implicit
270+# rule is not considered intermediate.
271+
272+touch('hello.z');
273+
274+# subtest 1.
275+# hello.x is derived from the stem and thus is an intermediate file.
276+run_make_test(q!
277+.SECONDEXPANSION:
278+dep:=.x
279+all: hello.z
280+%.z: %$$(dep) ; @echo $@
281+%.x: ;
282+!, '', "#MAKE#: Nothing to be done for 'all'.\n");
283+
284+
285+# subtest 2.
286+# test.x is explicitly mentioned and thus is not an intermediate file.
287+run_make_test(q!
288+.SECONDEXPANSION:
289+dep:=test.x
290+all: hello.z
291+%.z: %.x $$(dep) ; @echo $@
292+%.x: ;
293+!, '', "hello.z\n");
294+
295+# subtest 3.
296+# make is building hello.z and does not second expand the prerequisites of rule
297+# 'unrelated: $$(dep)'. '$$(dep)' stays not expanded and 'hello.x' is never
298+# entered to the database. Make considers 'hello.x' intermediate while building
299+# 'hello.z'. Because 'hello.z' is present and 'hello.x' is missing and
300+# 'hello.x' is intermediate, there is no need to rebuild 'hello.z'.
301+run_make_test(q!
302+.SECONDEXPANSION:
303+dep:=hello.x
304+all: hello.z
305+%.z: %.x; @echo $@
306+%.x: ;
307+unrelated: $$(dep)
308+!, '', "#MAKE#: Nothing to be done for 'all'.\n");
309+
310+# subtest 4.
311+# Just like subtest 3. $$(dep) is not second expanded. 'hello.x' is
312+# intermediate.
313+run_make_test(q!
314+.SECONDEXPANSION:
315+dep:=hello.x
316+all: hello.z
317+%.z: %.x; @echo $@
318+%.x: ;
319+%.q: $$(dep)
320+!, '', "#MAKE#: Nothing to be done for 'all'.\n");
321+
322+unlink('hello.z');
323+
324+
325+# sv 60188.
326+# Test that a file explicitly mentioned by the user and made by an implicit
327+# rule is not considered intermediate, even when the builtin rules are used.
328+
329+touch('hello.x');
330+touch('hello.tsk');
331+
332+# subtest 1.
333+# hello.z is explicitly mentioned and thus is not an intermediate file.
334+run_make_test(q!
335+.SECONDEXPANSION:
336+dep:=hello.z
337+all: hello.tsk
338+%.tsk: $$(dep) ; @echo $@
339+%.z : %.x ; @echo $@
340+!, '', "hello.z\nhello.tsk");
341+
342+# subtest 2.
343+# hello.z is derived from the stem and thus is an intermediate file.
344+run_make_test(q!
345+.SECONDEXPANSION:
346+dep:=.z
347+all: hello.tsk
348+%.tsk: %$$(dep) ; @echo $@
349+%.z : %.x ; @echo $@
350+!, '', "#MAKE#: Nothing to be done for 'all'.\n");
351+
352+unlink('hello.x');
353+unlink('hello.tsk');
354+
355+
356+# sv 60659. Second expansion of automatic variables inside a function in the
357+# prerequisite list.
358+# $$@ expands to the target in the 1st and following rules.
359+# $$* expands to the stem in the 1st and following rules.
360+# $$<,$$^,$$+,$$|,$$?,$$% expand to the empty string in the prerequisite list
361+# of the 1st rule.
362+# $$<,$$^,$$+,$$|,$$?,$$% in the prerequisite list of the 2nd (and following)
363+# rule expand to the values from the 1st rule.
364+# $$% cannot be used in prerequisites, because in pattern rules % is
365+# substituted for stem.
366+
367+
368+# subtest 1. Pattern rules. 1st rule.
369+run_make_test(q!
370+.SECONDEXPANSION:
371+all: 2.x
372+%.x: 5.z 6.z 5.z $$(info @=$$@,<=$$<,^=$$^,+=$$+,|=$$|,?=$$?,*=$$*) ;
373+%.z: ;
374+!, '',
375+"@=2.x,<=,^=,+=,|=,?=,*=2
376+#MAKE#: Nothing to be done for 'all'.\n");
377+
378+
379+# subtest 2. Pattern rules. 2nd rule.
380+run_make_test(q!
381+.SECONDEXPANSION:
382+all: 2.x 1.x
383+2.x: 5.z 6.z 5.z | 7.z 7.z 8.z
384+1.x: 1.z 2.z 2.z | 3.z 4.z
385+%.x: 9.z $$(info @=$$@,<=$$<,^=$$^,+=$$+,|=$$|,?=$$?,*=$$*) ;
386+%.z: ;
387+!, '',
388+"@=2.x,<=5.z,^=5.z 6.z,+=5.z 6.z 5.z,|=7.z 8.z,?=,*=2
389+@=1.x,<=1.z,^=1.z 2.z,+=1.z 2.z 2.z,|=3.z 4.z,?=,*=1
390+#MAKE#: Nothing to be done for 'all'.\n");
391+
392+
393+# subtest 3. Static pattern rules. 1st rule.
394+run_make_test(q!
395+.SECONDEXPANSION:
396+all: 2.x
397+2.x: %.x: 5.z 6.z 5.z $$(info @=$$@,<=$$<,^=$$^,+=$$+,|=$$|,?=$$?,*=$$*) ;
398+%.z: ;
399+!, '',
400+"@=2.x,<=,^=,+=,|=,?=,*=2
401+#MAKE#: Nothing to be done for 'all'.\n");
402+
403+
404+# subtest 4. Static pattern rules. 2nd rule.
405+run_make_test(q!
406+.SECONDEXPANSION:
407+all: 15.x 1.x
408+15.x: 5.z 6.z 5.z | 7.z 7.z 8.z
409+1.x: 1.z 2.z 2.z | 3.z 4.z
410+15.x 1.x: %.x: 9.z $$(info @=$$@,<=$$<,^=$$^,+=$$+,|=$$|,?=$$?,*=$$*) ;
411+%.z: ;
412+!, '',
413+"@=15.x,<=5.z,^=5.z 6.z,+=5.z 6.z 5.z,|=7.z 8.z,?=,*=15
414+@=1.x,<=1.z,^=1.z 2.z,+=1.z 2.z 2.z,|=3.z 4.z,?=,*=1
415+#MAKE#: Nothing to be done for 'all'.\n");
416+
417+
418+# subtest 5. Grouped targets in implicit rules. 1st rule.
419+run_make_test(q!
420+.SECONDEXPANSION:
421+all: 2.x
422+%.x %.xx&: 5.z 6.z 5.z $$(info @=$$@,<=$$<,^=$$^,+=$$+,|=$$|,?=$$?,*=$$*) ;
423+%.z: ;
424+!, '',
425+"@=2.x,<=,^=,+=,|=,?=,*=2
426+#MAKE#: Nothing to be done for 'all'.\n");
427+
428+
429+# subtest 6. Grouped targets in implicit rules. 2nd rule.
430+run_make_test(q!
431+.SECONDEXPANSION:
432+all: 2.x 1.xx
433+2.x: 5.z 6.z 5.z | 7.z 7.z 8.z
434+1.xx: 1.z 2.z 2.z | 3.z 4.z
435+%.x %.xx&: 9.z $$(info @=$$@,<=$$<,^=$$^,+=$$+,|=$$|,?=$$?,*=$$*) ;
436+%.z: ;
437+!, '',
438+"@=2.x,<=5.z,^=5.z 6.z,+=5.z 6.z 5.z,|=7.z 8.z,?=,*=2
439+@=1.xx,<=1.z,^=1.z 2.z,+=1.z 2.z 2.z,|=3.z 4.z,?=,*=1
440+#MAKE#: Nothing to be done for 'all'.\n");
441+
442+
443+# subtest 7. Double colon rule.
444+run_make_test(q!
445+.SECONDEXPANSION:
446+all: 2.x
447+%.x:: 5.z 6.z 5.z $$(info @=$$@,<=$$<,^=$$^,+=$$+,|=$$|,?=$$?,*=$$*) ;
448+5.z 6.z: ;
449+!, '',
450+"@=2.x,<=,^=,+=,|=,?=,*=2
451+#MAKE#: Nothing to be done for 'all'.\n");
452+
453+# sv 62324.
454+# Integrity self check.
455+run_make_test(q!
456+.SECONDEXPANSION:
457+all: bye.x
458+%.x: $$(firstword %.1;
459+!, '', "#MAKE#: *** unterminated call to function 'firstword': missing ')'.  Stop.", 512);
460+
461+# sv 62706.
462+# Test that makes avoids second expanding prerequisites of the rules which are
463+# not tried during implicit search.
464+# Here, make tries rules '%.tsk: %.o' and '%.o' and their prerequisites are
465+# second expanded.
466+# Rules '%.bin: %.x' and '%.x:' are not used in implicit search for 'hello.tsk'
467+# and 'hello.o' and their prerequisites are not expanded.
468+run_make_test(q!
469+.SECONDEXPANSION:
470+%.bin: %.x $$(info second expansion of $$@ prereqs); $(info $@ from $<)
471+%.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
472+%.x: $$(info second expansion of $$@ prereqs); $(info $@)
473+%.o: $$(info second expansion of $$@ prereqs); $(info $@)
474+!, '-R hello.tsk',
475+"second expansion of hello.o prereqs
476+second expansion of hello.tsk prereqs
477+hello.o
478+hello.tsk from hello.o
479+#MAKE#: 'hello.tsk' is up to date.\n");
480+
481+# sv 62706.
482+# No side effects from second expansion of unrelated rules.
483+run_make_test(q!
484+.SECONDEXPANSION:
485+all: hello.tsk
486+%.tsk: %.o; exit 1
487+hello.o:;
488+%.q: $$(shell touch hello.1);
489+!, '',
490+"exit 1
491+#MAKE#: *** [#MAKEFILE#:4: hello.tsk] Error 1\n", 512);
492+
493+# sv 62706.
494+# Second expansion of intermediate prerequisites.
495+# The rule to build hello.x is implicit.
496+# Test that $$(deps) is secondary expanded.
497+run_make_test(q!
498+deps:=hello.h
499+.SECONDEXPANSION:
500+all: hello.tsk
501+%.tsk: %.x; $(info $@)
502+%.x: $$(deps); $(info $@)
503+hello.h:; $(info $@)
504+!, '', "hello.h\nhello.x\nhello.tsk\n#MAKE#: Nothing to be done for 'all'.\n");
505+
506+# This tells the test driver that the perl test script executed properly.
507+1;
+232, -0
  1@@ -0,0 +1,232 @@
  2+#                                                                    -*-perl-*-
  3+$description = "Test second expansion in static pattern rules.";
  4+
  5+$details = "";
  6+
  7+# Test #1: automatic variables.
  8+#
  9+run_make_test(q!
 10+.SECONDEXPANSION:
 11+.DEFAULT: ; @echo '$@'
 12+
 13+foo.a foo.b: foo.%: bar.% baz.%
 14+foo.a foo.b: foo.%: biz.% | buz.%
 15+
 16+foo.a foo.b: foo.%: $$@.1 \
 17+                    $$<.2 \
 18+                    $$(addsuffix .3,$$^) \
 19+                    $$(addsuffix .4,$$+) \
 20+                    $$|.5 \
 21+                    $$*.6
 22+!,
 23+              '', 'bar.a
 24+baz.a
 25+biz.a
 26+buz.a
 27+foo.a.1
 28+bar.a.2
 29+bar.a.3
 30+baz.a.3
 31+biz.a.3
 32+bar.a.4
 33+baz.a.4
 34+biz.a.4
 35+buz.a.5
 36+a.6
 37+');
 38+
 39+
 40+# Test #2: target/pattern -specific variables.
 41+#
 42+run_make_test(q!
 43+.SECONDEXPANSION:
 44+.DEFAULT: ; @echo '$@'
 45+
 46+foo.x foo.y: foo.%: $$(%_a) $$($$*_b)
 47+
 48+foo.x: x_a := bar
 49+
 50+%.x: x_b := baz
 51+!,
 52+              '', "bar\nbaz\n");
 53+
 54+
 55+# Test #3: order of prerequisites.
 56+#
 57+run_make_test(q!
 58+.SECONDEXPANSION:
 59+.DEFAULT: ; @echo '$@'
 60+
 61+all: foo.a bar.a baz.a
 62+
 63+# Subtest #1
 64+foo.a foo.b: foo.%: foo.%.1; @:
 65+foo.a foo.b: foo.%: foo.%.2
 66+foo.a foo.b: foo.%: foo.%.3
 67+
 68+
 69+# Subtest #2
 70+bar.a bar.b: bar.%: bar.%.2
 71+bar.a bar.b: bar.%: bar.%.1; @:
 72+bar.a bar.b: bar.%: bar.%.3
 73+
 74+
 75+# Subtest #3
 76+baz.a baz.b: baz.%: baz.%.1
 77+baz.a baz.b: baz.%: baz.%.2
 78+baz.a baz.b: ; @:
 79+!,
 80+             '', 'foo.a.1
 81+foo.a.2
 82+foo.a.3
 83+bar.a.1
 84+bar.a.2
 85+bar.a.3
 86+baz.a.1
 87+baz.a.2
 88+');
 89+
 90+
 91+# Test #4: Make sure stem triple-expansion does not happen.
 92+#
 93+run_make_test(q!
 94+.SECONDEXPANSION:
 95+foo$$bar: f%r: % $$*.1 ; @echo '$*'
 96+
 97+oo$$ba oo$$ba.1: ; @echo '$@'
 98+!,
 99+              '', 'oo$ba
100+oo$ba.1
101+oo$ba
102+');
103+
104+# sv 62324.
105+# Integrity self check.
106+run_make_test(q!
107+.SECONDEXPANSION:
108+all: bye.x
109+bye.x: %.x: $$(firstword %.1;
110+!, '', "#MAKEFILE#:4: *** unterminated call to function 'firstword': missing ')'.  Stop.", 512);
111+
112+#unlink('hello.tsk', 'bye.tsk', 'hello.o', 'hello.q', 'bye.o');
113+
114+# sv 62706.
115+# Test that makes avoids second expanding prerequisites of the targets which
116+# are not built.
117+# Here, hello.tsk is built and its prerequisites are second expanded.
118+# bye.tsk is not built and its prerequisites are not second expanded.
119+
120+# Static pattern rules.
121+run_make_test(q!
122+.SECONDEXPANSION:
123+hello.tsk: %.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
124+bye.tsk: %.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
125+hello.o: $$(info second expansion of $$@ prereqs); $(info $@)
126+bye.o: $$(info second expansion of $$@ prereqs); $(info $@)
127+!, 'hello.tsk',
128+"second expansion of hello.tsk prereqs
129+second expansion of hello.o prereqs
130+hello.o
131+hello.tsk from hello.o
132+#MAKE#: 'hello.tsk' is up to date.\n");
133+
134+# sv 62706.
135+# Order only prereqs.
136+run_make_test(q!
137+.SECONDEXPANSION:
138+hello.tsk: %.tsk:| %.o $$(info second expansion of $$@ prereqs); $(info $@ from $|)
139+bye.tsk: %.tsk:| %.o $$(info second expansion of $$@ prereqs); $(info $@ from $|)
140+hello.o:| $$(info second expansion of $$@ prereqs); $(info $@)
141+bye.o:| $$(info second expansion of $$@ prereqs); $(info $@)
142+!, 'hello.tsk',
143+"second expansion of hello.tsk prereqs
144+second expansion of hello.o prereqs
145+hello.o
146+hello.tsk from hello.o
147+#MAKE#: 'hello.tsk' is up to date.\n");
148+
149+# sv 62706.
150+# Double colon. 1 rule per target.
151+run_make_test(q!
152+.SECONDEXPANSION:
153+hello.tsk:: %.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
154+bye.tsk:: %.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
155+hello.o:: $$(info second expansion of $$@ prereqs); $(info $@)
156+bye.o:: $$(info second expansion of $$@ prereqs); $(info $@)
157+!, 'hello.tsk',
158+"second expansion of hello.tsk prereqs
159+second expansion of hello.o prereqs
160+hello.o
161+hello.tsk from hello.o
162+#MAKE#: 'hello.tsk' is up to date.\n");
163+
164+# sv 62706.
165+# Double colon. 2 rules per target.
166+run_make_test(q!
167+.SECONDEXPANSION:
168+hello.tsk:: %.tsk: %.o $$(info 1 second expansion of $$@ prereqs); $(info 1 $@ from $<)
169+hello.tsk:: %.tsk: %.o $$(info 2 second expansion of $$@ prereqs); $(info 2 $@ from $<)
170+bye.tsk:: %.tsk: %.o $$(info 1 second expansion of $$@ prereqs); $(info 1 $@ from $<)
171+bye.tsk:: %.tsk: %.o $$(info 2 second expansion of $$@ prereqs); $(info 2 $@ from $<)
172+hello.o:: $$(info 1 second expansion of $$@ prereqs); $(info 1 $@)
173+hello.o:: $$(info 2 second expansion of $$@ prereqs); $(info 2 $@)
174+bye.o:: $$(info 1 second expansion of $$@ prereqs); $(info 1 $@)
175+bye.o:: $$(info 2 second expansion of $$@ prereqs); $(info 2 $@)
176+!, 'hello.tsk',
177+"1 second expansion of hello.tsk prereqs
178+1 second expansion of hello.o prereqs
179+1 hello.o
180+2 second expansion of hello.o prereqs
181+2 hello.o
182+1 hello.tsk from hello.o
183+2 second expansion of hello.tsk prereqs
184+2 hello.tsk from hello.o
185+#MAKE#: 'hello.tsk' is up to date.\n");
186+
187+# sv 62706.
188+# Test that the prerequisites of 'hello.tsk' are second expanded once.
189+run_make_test(q!
190+.SECONDEXPANSION:
191+all: hello.tsk hello.q
192+hello.tsk: %.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $^)
193+hello.o: $$(info second expansion of $$@ prereqs); $(info $@)
194+hello.q: %.q: %.tsk $$(info second expansion of $$@ prereqs); $(info $@ from $^)
195+!, '',
196+"second expansion of hello.tsk prereqs
197+second expansion of hello.o prereqs
198+hello.o
199+hello.tsk from hello.o
200+second expansion of hello.q prereqs
201+hello.q from hello.tsk
202+#MAKE#: Nothing to be done for 'all'.\n");
203+
204+unlink('hello.1');
205+
206+# sv 62706.
207+# No side effects from second expansion of unrelated rules.
208+run_make_test(q!
209+.SECONDEXPANSION:
210+all: hello.tsk
211+hello.tsk: %.tsk: %.o; exit 1
212+hello.o:;
213+bye.tsk: %.tsk: $$(shell touch hello.1);
214+!, '',
215+"exit 1
216+#MAKE#: *** [#MAKEFILE#:4: hello.tsk] Error 1\n", 512);
217+
218+# sv 62706.
219+# Second expansion of intermediate prerequisites.
220+# The rule to build hello.x is static pattern.
221+# .SECONDARY marks hello.x as intermediate.
222+# Test that $$(deps) is secondary expanded.
223+run_make_test(q!
224+deps:=hello.h
225+.SECONDEXPANSION:
226+.SECONDARY: hello.x
227+all: hello.x
228+hello.x: %.x: $$(deps); $(info $@)
229+hello.h:; $(info $@)
230+!, '', "hello.h\nhello.x\n#MAKE#: Nothing to be done for 'all'.\n");
231+
232+# This tells the test driver that the perl test script executed properly.
233+1;
+69, -0
 1@@ -0,0 +1,69 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test BSD-style shell assignments (VAR != VAL) for variables.";
 5+
 6+$details = "";
 7+
 8+# TEST 0: Basic shell assignment (!=).
 9+
10+run_make_test('
11+.POSIX:
12+
13+demo1!=printf \'  1   2 3\n4\n\n5 \n \n 6\n\n\n\n\'
14+demo2 != printf \'7 8\n \'
15+demo3 != printf \'$$(demo2)\'
16+demo4 != printf \' 2 3 \n\'
17+demo5 != printf \' 2 3 \n\n\'
18+all: ; @echo "<$(demo1)> <$(demo2)> <$(demo3)> <$(demo4)> <${demo5}>"
19+',
20+              '', "<  1   2 3 4  5     6   > <7 8  > <7 8  > < 2 3 > < 2 3  >\n");
21+
22+# TEST 1: Handle '#' the same way as BSD make
23+$hashOctal = "\\043";
24+if ($osname eq 'os390') {
25+  $hashOctal = "\\173";
26+}
27+
28+run_make_test('
29+foo1!=echo bar#baz
30+hash != printf \'' . $hashOctal . '\'
31+foo2!= echo "bar$(hash)baz"
32+
33+all: ; @echo "<$(foo1)> <$(hash)> <$(foo2)>"
34+',
35+              '', "<bar> <#> <bar#baz>\n");
36+
37+# TEST 2: shell assignment variables (from !=) should be recursive.
38+# Note that variables are re-evaluated later, so the shell can output
39+# a value like $(XYZZY) as part of !=.  The $(XYZZY) will be EVALUATED
40+# when the value containing it is evaluated.  On the negative side, this
41+# means if you don't want this, you need to escape dollar signs as $$.
42+# On the positive side, it means that shell programs can output macros
43+# that are then evaluated as they are traditionally evaluated.. and that
44+# you can use traditional macro evaluation semantics to implement !=.
45+
46+run_make_test('
47+XYZZY = fiddle-dee-dee
48+dollar = $$
49+VAR3 != printf \'%s\' \'$(dollar)(XYZZY)\'
50+
51+all: ; @echo "<$(VAR3)>"
52+',
53+              '', "<fiddle-dee-dee>\n");
54+
55+
56+# TEST 3: Overrides invoke shell anyway; they just don't store the result
57+# in a way that is visible.
58+
59+run_make_test('
60+
61+override != echo abc > ,abc ; cat ,abc
62+
63+all: ; @echo "<$(override)>" ; cat ,abc
64+',
65+              'override=xyz', "<xyz>\nabc\n");
66+
67+unlink(',abc');
68+
69+
70+1;
+311, -0
  1@@ -0,0 +1,311 @@
  2+#                                                                    -*-perl-*-
  3+$description = "Test handling of static pattern rules.";
  4+
  5+$details = "\
  6+The makefile created in this test has three targets.  The
  7+filter command is used to get those target names ending in
  8+.o and statically creates a compile command with the target
  9+name and the target name with .c.  It also does the same thing
 10+for another target filtered with .elc and creates a command
 11+to emacs a .el file";
 12+
 13+&touch('bar.c', 'lose.c');
 14+
 15+#   TEST #0
 16+#   -------
 17+
 18+run_make_test('
 19+files = foo.elc bar.o lose.o
 20+
 21+$(filter %.o,$(files)): %.o: %.c ; @echo CC -c $(CFLAGS) $< -o $@
 22+
 23+$(filter %.elc,$(files)): %.elc: %.el ; @echo emacs $<
 24+',
 25+              '',
 26+              'CC -c bar.c -o bar.o');
 27+
 28+#  TEST #1
 29+#  -------
 30+
 31+run_make_test(undef, 'lose.o', 'CC -c lose.c -o lose.o');
 32+
 33+
 34+#   TEST #2
 35+#   -------
 36+&touch("foo.el");
 37+
 38+run_make_test(undef, 'foo.elc', 'emacs foo.el');
 39+
 40+# Clean up after the first tests.
 41+unlink('foo.el', 'bar.c', 'lose.c');
 42+
 43+
 44+# TEST #3 -- PR/1670: don't core dump on invalid static pattern rules
 45+# -------
 46+
 47+run_make_test('
 48+.DEFAULT: ; @echo $@
 49+foo: foo%: % %.x % % % y.% % ; @echo $@
 50+',
 51+              '', ".x\ny.\nfoo");
 52+
 53+
 54+# TEST #4 -- bug #12180: core dump on a stat pattern rule with an empty
 55+#                        prerequisite list.
 56+run_make_test('
 57+foo.x bar.x: %.x : ; @echo $@
 58+
 59+',
 60+              '', 'foo.x');
 61+
 62+
 63+# TEST #5 -- bug #13881: double colon static pattern rule does not
 64+#                        substitute %.
 65+run_make_test('
 66+foo.bar:: %.bar: %.baz
 67+foo.baz: ;@:
 68+',
 69+              '', '');
 70+
 71+
 72+# TEST #6: make sure the second stem does not overwrite the first
 73+#          perprerequisite's stem (Savannah bug #16053).
 74+#
 75+run_make_test('
 76+.RECIPEPREFIX := >
 77+
 78+all.foo.bar: %.foo.bar: %.one
 79+
 80+all.foo.bar: %.bar: %.two
 81+
 82+all.foo.bar:
 83+>#TAB#@echo $*
 84+>#TAB#@echo $^
 85+
 86+.DEFAULT:;@:
 87+',
 88+'',
 89+'all.foo
 90+all.one all.foo.two');
 91+
 92+
 93+# TEST #7: make sure the second stem does not overwrite the first
 94+#          perprerequisite's stem when second expansion is enabled
 95+#          (Savannah bug #16053).
 96+#
 97+run_make_test('
 98+.RECIPEPREFIX := >
 99+.SECONDEXPANSION:
100+
101+all.foo.bar: %.foo.bar: %.one $$*-one
102+
103+all.foo.bar: %.bar: %.two $$*-two
104+
105+all.foo.bar:
106+>#TAB#@echo $*
107+>#TAB#@echo $^
108+
109+.DEFAULT:;@:
110+',
111+'',
112+'all.foo
113+all.one all-one all.foo.two all.foo-two');
114+
115+# Test #8:
116+# sv 60188.
117+# Static pattern rules are considered explicit rules: no prerequisite of
118+# a static pattern rule can ever be considered intermediate.
119+
120+touch('hello.z');
121+
122+# subtest 1
123+run_make_test(q!
124+hello.z: %.z: %.x ; @echo $@
125+%.x: ;
126+!, '', "hello.z\n");
127+
128+# subtest 2
129+run_make_test(q!
130+hello.z: %.z: %.x test.x ; @echo $@
131+%.x: ;
132+!, '', "hello.z\n");
133+
134+# subtest 3
135+# 'hello.x' is mentioned explicitly on an unrelated rule.
136+run_make_test(q!
137+hello.z: %.z: %.x ; @echo $@
138+%.x: ;
139+unrelated: hello.x
140+!, '', "hello.z\n");
141+
142+unlink('hello.z');
143+
144+# sv 17374 Ensure double-colon static pattern rules work
145+
146+touch(qw(a.src b.src));
147+
148+run_make_test(q!
149+all: a.tgt b.tgt
150+a.tgt b.tgt:: %.tgt : %.src ; cp $< $@
151+!,
152+    '', "cp a.src a.tgt\ncp b.src b.tgt\n");
153+
154+unlink(qw(a.src b.src a.tgt b.tgt));
155+
156+my @dir = ('', 'lib/'); # With and without last slash.
157+my @secondexpansion = ('', '.SECONDEXPANSION:');
158+
159+# The following combinations are generated with and without second expansion.
160+# 1.
161+# all: bye.x
162+# bye.x: %.x: ...
163+#
164+# 2.
165+# all: lib/bye.x
166+# lib/bye.x: %.x: ...
167+#
168+# 3.
169+# all: lib/bye.x
170+# lib/bye.x: lib/%.x: ...
171+#
172+# The following combination is not generated, because there is no rule to
173+# build bye.x, no stem substitution takes place, not of interest of this test.
174+# 4.
175+# all: bye.x
176+# bye.x: lib/%.x: ...
177+#
178+
179+for my $se (@secondexpansion) {
180+for my $d (@dir) { # The directory of the prerequisite of 'all'.
181+for my $r (@dir) { # The directory of the prerequisite in the rule definition.
182+(!$d && $r) && next; # Combination 4.
183+my $dollar = $se ? '$' : '';
184+
185+# The prerequisite should only have directory if the prerequisite of 'all' has
186+# it and if the prerequisite pattern in the rule definition does not have it.
187+# That is combination 2.
188+my $pdir = $d && !$r ? $d : '';
189+
190+
191+# One func, one %.
192+my $prereqs = "${pdir}bye.1";
193+run_make_test("
194+$se
195+.PHONY: $prereqs
196+all: ${d}bye.x
197+${d}bye.x: $r%.x: $dollar\$(firstword %.1); \$(info \$@ from \$^)
198+", '', "${d}bye.x from $prereqs\n#MAKE#: Nothing to be done for 'all'.\n");
199+
200+
201+# Multiple funcs, each has one %.
202+$prereqs = "${pdir}bye.1 ${pdir}bye.2";
203+run_make_test("
204+$se
205+.PHONY: $prereqs
206+all: ${d}bye.x
207+${d}bye.x: $r%.x: $dollar\$(firstword %.1) $dollar\$(firstword %.2); \$(info \$@ from \$^)
208+", '', "${d}bye.x from $prereqs\n#MAKE#: Nothing to be done for 'all'.\n");
209+
210+
211+# Multiple funcs, each has multiple %.
212+$prereqs = "${pdir}bye.1 ${pdir}bye.2 ${pdir}bye.3 ${pdir}bye.4";
213+run_make_test("
214+$se
215+.PHONY: $prereqs
216+all: ${d}bye.x
217+${d}bye.x: $r%.x: $dollar\$(wordlist 1, 99, %.1 %.2) $dollar\$(wordlist 1, 99, %.3 %.4); \$(info \$@ from \$^)
218+", '', "${d}bye.x from $prereqs\n#MAKE#: Nothing to be done for 'all'.\n");
219+
220+
221+# Multiple funcs, each has multiple %, each prerequisite has multiple %.
222+$prereqs = "${pdir}bye_%_%.1 ${pdir}bye_%_%.2 ${pdir}bye_%_%.3 ${pdir}bye_%_%.4";
223+run_make_test("
224+$se
225+.PHONY: $prereqs
226+all: ${d}bye.x
227+${d}bye.x: $r%.x: $dollar\$(wordlist 1, 99, %_%_%.1 %_%_%.2) $dollar\$(wordlist 1, 99, %_%_%.3 %_%_%.4); \$(info \$@ from \$^)
228+", '', "${d}bye.x from $prereqs\n#MAKE#: Nothing to be done for 'all'.\n");
229+
230+
231+# Nested functions.
232+$prereqs = "${pdir}bye.1 ${pdir}bye.2 ${pdir}bye.3 ${pdir}bye.4";
233+run_make_test("
234+$se
235+.PHONY: $prereqs
236+all: ${d}bye.x
237+${d}bye.x: $r%.x: $dollar\$(wordlist 1, 99, $dollar\$(wordlist 1, 99, %.1 %.2)) $dollar\$(wordlist 1, 99, $dollar\$(wordlist 1,99, %.3 %.4)); \$(info \$@ from \$^)
238+", '', "${d}bye.x from $prereqs\n#MAKE#: Nothing to be done for 'all'.\n");
239+
240+
241+# Multiple funcs, each has multiple words, each word has multiple %, sole %,
242+# various corner cases.
243+# Make should substitute the first % and only the first % in each word with the
244+# stem.
245+$prereqs = "${pdir}bye1%2% ${pdir}bye 3${pdir}bye4%5 6${pdir}bye ${pdir}bye7%8 ${pdir}bye9 ${pdir}bye10% 11${pdir}bye12 13";
246+run_make_test("
247+$se
248+.PHONY: $prereqs
249+all: ${d}bye.x
250+${d}bye.x: $r%.x: $dollar\$(wordlist 1, 99, %1%2% % 3%4%5 6%) %7%8 %9 $dollar\$(wordlist 1, 99, %10% 11%12) 13; \$(info \$@ from \$^)
251+", '', "${d}bye.x from $prereqs\n#MAKE#: Nothing to be done for 'all'.\n");
252+
253+
254+if ($port_type eq 'UNIX') {
255+# Test that make does not use some hardcoded array of a finite size on stack.
256+# Long prerequisite name. This prerequisite name is over 66K long.
257+my $prefix = 'abcdefgh' x 128 x 33; # 33K long.
258+my $suffix = 'stuvwxyz' x 128 x 33; # 33K long.
259+$prereqs = "${prefix}${pdir}bye${suffix}.1 ${prefix}${pdir}bye${suffix}.2";
260+run_make_test("
261+$se
262+.PHONY: $prereqs
263+all: ${d}bye.x
264+${d}bye.x: $r%.x: $dollar\$(wordlist 1, 99, ${prefix}%${suffix}.1 ${prefix}%${suffix}.2); \$(info \$@ from \$^)
265+", '', "${d}bye.x from $prereqs\n#MAKE#: Nothing to be done for 'all'.\n");
266+}
267+
268+
269+# Empty stem.
270+$prereqs = "${pdir}.1";
271+run_make_test("
272+$se
273+.PHONY: $prereqs
274+all: ${d}bye.x
275+${d}bye.x: $r%bye.x: $dollar\$(firstword %.1); \$(info \$@ from \$^)
276+", '', "${d}bye.x from $prereqs\n#MAKE#: Nothing to be done for 'all'.\n");
277+
278+
279+# A word expands to an empty prerequisite.
280+run_make_test("
281+$se
282+all: ${d}bye.x
283+${d}bye.x: $r%.x: $dollar\$(%); \$(info \$@ from \$^)
284+", '', "${d}bye.x from \n#MAKE#: Nothing to be done for 'all'.\n");
285+
286+}
287+}
288+}
289+
290+# Escaped %.
291+# The following combinations are generated without second expansion.
292+# 1.
293+# all: the%weird\\_hello_pattern\\.x
294+# the\\%weird\\_hello_pattern\\.x: the\\%weird\\_%_pattern\\.x: ...
295+#
296+# 2.
297+# all: lib/the%weird\\_hello_pattern\\.x
298+# lib/the\\%weird\\_hello_pattern\\.x: lib/the\\%weird\\_%_pattern\\.x: ...
299+#
300+# Other combinations or second expansion are not tested, because escaped % is
301+# not implemented for those.
302+
303+for my $d (@dir) {
304+my $prereqs = "${d}the%weird\\\\_hello_pattern%\\\\.1 ${d}the%weird\\\\_hello_pattern%\\\\.2";
305+run_make_test("
306+.PHONY: $prereqs
307+all: ${d}the%weird\\\\_hello_pattern\\\\.x
308+${d}the\\%weird\\\\_hello_pattern\\\\.x: ${d}the\\%weird\\\\_%_pattern\\\\.x: \$(wordlist 1, 99, ${d}the\\%weird\\\\_%_pattern%\\\\.1 ${d}the\\%weird\\\\_%_pattern%\\\\.2); \$(info \$@ from \$^)
309+", '', "${d}the%weird\\\\_hello_pattern\\\\.x from $prereqs\n#MAKE#: Nothing to be done for 'all'.\n");
310+}
311+
312+1;
+189, -0
  1@@ -0,0 +1,189 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test suffix rules.";
  5+
  6+$details = "";
  7+
  8+# TEST #0: Clear all suffixes
  9+
 10+touch('foo.c');
 11+
 12+run_make_test(q!
 13+.SUFFIXES:
 14+all: foo.o ; @echo $@ $<
 15+!,
 16+              '', "#MAKE#: *** No rule to make target 'foo.o', needed by 'all'.  Stop.\n", 512);
 17+
 18+unlink('foo.c');
 19+
 20+# Test #1: Add a simple suffix rule
 21+
 22+touch('foo.baz');
 23+
 24+run_make_test(q!
 25+.SUFFIXES: .biz .baz
 26+
 27+.baz.biz: ; @echo make $@
 28+!,
 29+              'foo.biz', "make foo.biz\n");
 30+
 31+unlink('foo.baz');
 32+
 33+# Test #2: Make sure the defaults still work
 34+
 35+touch('foo.c');
 36+
 37+run_make_test(undef, 'foo.o COMPILE.c=@echo OUTPUT_OPTION=', "foo.c\n");
 38+
 39+unlink('foo.c');
 40+
 41+# Test #3: Replacing all suffixes
 42+
 43+touch('foo.baz');
 44+
 45+run_make_test(q!
 46+.SUFFIXES:
 47+.SUFFIXES: .biz .baz
 48+
 49+.baz.biz: ; @echo make $@
 50+!,
 51+              'foo.biz', "make foo.biz\n");
 52+
 53+unlink('foo.baz');
 54+
 55+# SV 40657: "Suffix rules" with deps are normal rules
 56+
 57+my $prewarn = 'warning: ignoring prerequisites on suffix rule definition';
 58+
 59+touch('foo.bar');
 60+
 61+# Verify warnings for single-suffix rules
 62+
 63+run_make_test(q!
 64+.SUFFIXES:
 65+.SUFFIXES: .baz
 66+
 67+.baz: foo.bar ; @echo make $@ from $<
 68+
 69+$X.POSIX:
 70+!,
 71+              'X=1 .baz', "#MAKEFILE#:5: $prewarn\nmake .baz from foo.bar\n");
 72+
 73+# In POSIX mode we don't get a warning
 74+
 75+run_make_test(undef, 'X= .baz', "make .baz from foo.bar\n");
 76+
 77+# Test double-suffix rules
 78+
 79+run_make_test(q!
 80+.SUFFIXES:
 81+.SUFFIXES: .biz .baz
 82+
 83+$X.POSIX:
 84+
 85+.baz.biz: foo.bar ; @echo make $@ from $<
 86+!,
 87+              'X=1 .baz.biz', "#MAKEFILE#:7: $prewarn\nmake .baz.biz from foo.bar\n");
 88+
 89+# SV 40657: In POSIX mode we don't get a warning
 90+
 91+run_make_test(undef, 'X= .baz.biz', "make .baz.biz from foo.bar\n");
 92+
 93+unlink('foo.bar');
 94+
 95+# SV 40657: In POSIX mode, no pattern rules should be created
 96+
 97+utouch(-20, 'foo.baz');
 98+
 99+run_make_test(undef,
100+              'X= foo.biz', "#MAKE#: *** No rule to make target 'foo.biz'.  Stop.\n", 512);
101+
102+# SV 40657: In Non-POSIX mode, a pattern rule is created
103+
104+run_make_test(undef,
105+              'X=1 foo.biz', "#MAKEFILE#:7: $prewarn\nmake foo.biz from foo.baz\n");
106+
107+# SV 40657: ... but any prerequisites are ignored
108+
109+utouch(-10, 'foo.biz');
110+touch('foo.bar');
111+
112+run_make_test(undef,
113+              'X=1 foo.biz', "#MAKEFILE#:7: $prewarn\n#MAKE#: 'foo.biz' is up to date.\n");
114+
115+unlink('foo.baz', 'foo.biz', 'foo.bar');
116+
117+
118+touch('hello.c');
119+unlink('hello.o');
120+
121+# sv 63821.
122+# Default suffix rule .c.o.
123+
124+run_make_test('all: hello.o', 'COMPILE.c=@echo OUTPUT_OPTION=', 'hello.c');
125+
126+# User defined rules beat built-in rules.
127+
128+run_make_test(q!
129+all: hello.o
130+.c.o:; $(info $@ user defined .c.o rule)
131+!, '', "hello.o user defined .c.o rule\n#MAKE#: Nothing to be done for 'all'.\n");
132+
133+# sv 63821.
134+# The same as above, but suffixes are cleared.
135+
136+run_make_test(q!
137+all: hello.o
138+.SUFFIXES:
139+.c.o:; $(info $@ user defined .c.o rule)
140+!, '', "#MAKE#: *** No rule to make target 'hello.o', needed by 'all'.  Stop.\n", 512);
141+
142+# sv 63821.
143+# Suffixes are cleared and defined in the makefile.
144+
145+run_make_test(q!
146+all: hello.o
147+.SUFFIXES:
148+.SUFFIXES: .c .o
149+.c.o:; $(info $@ user defined .c.o rule)
150+!, '', "hello.o user defined .c.o rule\n#MAKE#: Nothing to be done for 'all'.\n");
151+
152+# sv 63821.
153+# When built-in rules are disabled, but certain suffixes are added to
154+# .SUFFIXES, make should exit with the 'No rule...' error message.
155+
156+run_make_test(q!
157+.SUFFIXES: .c .o
158+all: hello.o
159+!, '-r', "#MAKE#: *** No rule to make target 'hello.o', needed by 'all'.  Stop.\n", 512);
160+
161+# sv 63821.
162+# Same as above, but this time built-in rules are disabled inside the makefile.
163+
164+run_make_test(q!
165+MAKEFLAGS += -r
166+.SUFFIXES: .c .o
167+all: hello.o
168+!, '', "#MAKE#: *** No rule to make target 'hello.o', needed by 'all'.  Stop.\n", 512);
169+
170+# sv 63821.
171+# Same as above, but this time there is a rule.
172+
173+run_make_test(q!
174+all: hello.o
175+MAKEFLAGS += -r
176+.SUFFIXES: .c .o
177+.c.o:; $(info $@ user defined .c.o rule)
178+!, '', "hello.o user defined .c.o rule\n#MAKE#: Nothing to be done for 'all'.\n");
179+
180+unlink('hello.c', 'hello.o');
181+
182+# sv 65324.
183+# Crash in disable_builtins.
184+run_make_test(q!
185+all:;
186+!, '-r MAKEFLAGS=', "#MAKE#: 'all' is up to date.\n");
187+
188+
189+# Complete
190+1;
+439, -0
  1@@ -0,0 +1,439 @@
  2+#                                                                    -*-perl-*-
  3+$description = "Test target-specific variable settings.";
  4+
  5+$details = "\
  6+Create a makefile containing various flavors of target-specific variable
  7+values, override and non-override, and using various variable expansion
  8+rules, semicolon interference, etc.";
  9+
 10+run_make_test('
 11+export FOO = foo
 12+export BAR = bar
 13+one: override FOO = one
 14+one two: ; @echo $(FOO) $(BAR)
 15+two: BAR = two
 16+.RECIPEPREFIX = >
 17+three: ; BAR=1000
 18+> @echo $(FOO) $(BAR)
 19+# Some things that shouldn not be target vars
 20+funk : override
 21+funk : override adelic
 22+adelic override : ; echo $@
 23+# Test per-target recursive variables
 24+four:FOO=x
 25+four:VAR$(FOO)=ok
 26+four: ; @echo "$(FOO) $(VAR$(FOO)) $(VAR) $(VARx)"
 27+five:FOO=x
 28+five six : VAR$(FOO)=good
 29+five six: ;@echo "$(FOO) $(VAR$(FOO)) $(VAR) $(VARx) $(VARfoo)"
 30+# Test per-target variable inheritance
 31+seven: eight
 32+seven eight: ; @echo $@: $(FOO) $(BAR)
 33+seven: BAR = seven
 34+seven: FOO = seven
 35+eight: BAR = eight
 36+# Test the export keyword with per-target variables
 37+nine: ; @echo $(FOO) $(BAR) $$FOO $$BAR
 38+nine: FOO = wallace
 39+nine-a: export BAZ = baz
 40+nine-a: ; @echo $$BAZ
 41+# Test = escaping
 42+EQ = =
 43+ten: one$(EQ)two
 44+ten: one $(EQ) two
 45+ten one$(EQ)two $(EQ):;@echo $@
 46+.PHONY: one two three four five six seven eight nine ten $(EQ) one$(EQ)two
 47+# Test target-specific vars with pattern/suffix rules
 48+QVAR = qvar
 49+RVAR = =
 50+%.q : ; @echo $(QVAR) $(RVAR)
 51+foo.q : RVAR += rvar
 52+# Target-specific vars with multiple LHS pattern rules
 53+%.r %.s %.t: ; @echo $(QVAR) $(RVAR) $(SVAR) $(TVAR)
 54+foo.r : RVAR += rvar
 55+foo.t : TVAR := $(QVAR)
 56+',
 57+                 "one two three", "one bar\nfoo two\nBAR=1000\nfoo bar\n");
 58+
 59+# TEST #2
 60+
 61+run_make_test(undef, "one two FOO=1 BAR=2", "one 2\n1 2\n");
 62+
 63+# TEST #3
 64+
 65+run_make_test(undef, "four", "x ok  ok\n");
 66+
 67+# TEST #4
 68+
 69+run_make_test(undef, "seven", "eight: seven eight\nseven: seven seven\n");
 70+
 71+# TEST #5
 72+
 73+run_make_test(undef, "nine", "wallace bar wallace bar\n");
 74+
 75+# TEST #5-a
 76+
 77+run_make_test(undef, "nine-a", "baz\n");
 78+
 79+# TEST #6
 80+
 81+run_make_test(undef, "ten", "one=two\none bar\n=\nfoo two\nten\n");
 82+
 83+# TEST #6
 84+
 85+run_make_test(undef, "foo.q bar.q", "qvar = rvar\nqvar =\n");
 86+
 87+# TEST #7
 88+
 89+run_make_test(undef, "foo.t bar.s", "qvar = qvar\nqvar =\n");
 90+
 91+# TEST #8
 92+# For PR/1378: Target-specific vars don't inherit correctly
 93+
 94+run_make_test('
 95+foo: FOO = foo
 96+bar: BAR = bar
 97+foo: bar
 98+bar: baz
 99+baz: ; @echo $(FOO) $(BAR)
100+', "", "foo bar\n");
101+
102+# TEST #9
103+# For PR/1380: Using += assignment in target-specific variables sometimes fails
104+# Also PR/1831
105+
106+run_make_test('
107+.PHONY: all one
108+all: FOO += baz
109+all: one; @echo $(FOO)
110+
111+FOO = bar
112+
113+one: FOO += biz
114+one: FOO += boz
115+one: ; @echo $(FOO)
116+',
117+              '', "bar baz biz boz\nbar baz\n");
118+
119+# Test #10
120+
121+run_make_test(undef, 'one', "bar biz boz\n");
122+
123+# Test #11
124+# PR/1709: Test semicolons in target-specific variable values
125+
126+run_make_test('
127+foo : FOO = ; ok
128+foo : ; @echo "$(FOO)"
129+',
130+              '', "; ok\n");
131+
132+# Test #12
133+# PR/2020: More hassles with += target-specific vars.  I _really_ think
134+# I nailed it this time :-/.
135+
136+run_make_test('
137+.PHONY: a
138+
139+BLAH := foo
140+COMMAND = echo $(BLAH)
141+
142+a: ; @$(COMMAND)
143+
144+a: BLAH := bar
145+a: COMMAND += snafu $(BLAH)
146+',
147+              '', "bar snafu bar\n");
148+
149+# Test #13
150+# Test double-colon rules with target-specific variable values
151+
152+run_make_test('
153+W = bad
154+X = bad
155+foo: W = ok
156+foo:: ; @echo $(W) $(X) $(Y) $(Z)
157+foo:: ; @echo $(W) $(X) $(Y) $(Z)
158+foo: X = ok
159+
160+Y = foo
161+bar: foo
162+bar: Y = bar
163+
164+Z = nopat
165+ifdef PATTERN
166+  fo% : Z = pat
167+endif
168+',
169+             'foo', "ok ok foo nopat\nok ok foo nopat\n");
170+
171+# Test #14
172+# Test double-colon rules with target-specific variable values and
173+# inheritance
174+
175+run_make_test(undef, 'bar', "ok ok bar nopat\nok ok bar nopat\n");
176+
177+# Test #15
178+# Test double-colon rules with pattern-specific variable values
179+
180+run_make_test(undef, 'foo PATTERN=yes', "ok ok foo pat\nok ok foo pat\n");
181+
182+# Test #16
183+# Test target-specific variables with very long command line
184+# (> make default buffer length)
185+
186+run_make_test('
187+base_metals_fmd_reports.sun5 base_metals_fmd_reports CreateRealPositions        CreateMarginFunds deals_changed_since : BUILD_OBJ=$(shell if test -f               "build_information.generate"   ; then echo "$(OBJ_DIR)/build_information.o"; else echo "no build information"; fi  )
188+
189+deals_changed_since: ; @echo $(BUILD_OBJ)
190+',
191+              '', "no build information\n");
192+
193+# TEST #17
194+
195+# Test a merge of set_lists for files, where one list is much longer
196+# than the other.  See Savannah bug #15757.
197+
198+mkdir('t1', 0777);
199+touch('t1/rules.mk');
200+
201+run_make_test('
202+VPATH = t1
203+include rules.mk
204+.PHONY: all
205+all: foo.x
206+foo.x : rules.mk ; @echo MYVAR=$(MYVAR) FOOVAR=$(FOOVAR) ALLVAR=$(ALLVAR)
207+all: ALLVAR = xxx
208+foo.x: FOOVAR = bar
209+rules.mk : MYVAR = foo
210+.INTERMEDIATE: foo.x rules.mk
211+',
212+              '-I t1', 'MYVAR= FOOVAR=bar ALLVAR=xxx');
213+
214+rmfiles('t1/rules.mk');
215+rmdir('t1');
216+
217+# TEST #18
218+
219+# Test appending to a simple variable containing a "$": avoid a
220+# double-expansion.  See Savannah bug #15913.
221+
222+run_make_test('
223+VAR := $$FOO
224+foo: VAR += BAR
225+foo: ; @echo '."'".'$(VAR)'."'".'
226+',
227+              '', '$FOO BAR');
228+
229+# TEST #19: Override with append variables
230+
231+run_make_test('
232+a: override FOO += f1
233+a: FOO += f2
234+a: ; @echo "$(FOO)"
235+',
236+              '', "f1\n");
237+
238+run_make_test(undef, 'FOO=C', "C f1\n");
239+
240+# TEST #19: Conditional variables with command-line settings
241+
242+run_make_test('
243+a: FOO ?= f1
244+a: ; @echo "$(FOO)"
245+',
246+              '', "f1\n");
247+
248+run_make_test(undef, 'FOO=C', "C\n");
249+
250+# TEST #20: Check for continuation after semicolons
251+
252+run_make_test(q!
253+a: A = 'hello;\
254+world'
255+a: ; @echo $(A)
256+!,
257+              '', "hello; world\n");
258+
259+# TEST #21: SV-56834 Ensure setting PATH in a target var works properly
260+my $sname = "foobar$scriptsuffix";
261+
262+mkdir('sd', 0775);
263+create_file("sd/$sname", "exit 0\n");
264+chmod 0755, "sd/$sname";
265+
266+run_make_test(qq!
267+all: PATH := sd
268+all: ; $sname >/dev/null
269+!,
270+              '', "$sname >/dev/null\n");
271+
272+# Don't use the general PATH if not found on the target path
273+
274+$ENV{PATH} = "$ENV{PATH}:sd";
275+
276+my ($ernum, $erstr);
277+if ($port_type eq 'W32') {
278+    $ernum = 1;
279+    $erstr = "'$sname' is not recognized as an internal or external command,\noperable program or batch file.";
280+} else {
281+    $ernum = 127;
282+    $erstr = "#MAKE#: $sname: $ERR_no_such_file";
283+}
284+
285+run_make_test(qq!
286+all: PATH := ..
287+all: ; $sname
288+!,
289+              '', "$sname\n$erstr\n#MAKE#: *** [#MAKEFILE#:3: all] Error $ernum", 512);
290+
291+unlink("sd/$sname");
292+rmdir ('sd');
293+
294+# SV 59230: Conditional (non-)assignment of target-specific variables should
295+# preserve export settings.
296+
297+$ENV{hello} = 'moon';
298+run_make_test(q!
299+all:; @echo hello=$$hello
300+dummy: hello?=world
301+!,
302+              '', 'hello=moon');
303+
304+# SV 59230: Assignment of a global variable should not affect export of a
305+# target specific variable.
306+
307+$ENV{hello} = "moon";
308+run_make_test(q!
309+all:; @echo hello=$$hello
310+hello=sun
311+dummy: hello?=world
312+!,
313+              '', 'hello=sun');
314+
315+# Support target-specific unexport
316+
317+$ENV{hello} = "moon";
318+run_make_test(q!
319+unexport hello=sun
320+all: base exp
321+base exp: ; @echo hello=$$hello
322+exp: export hello=world
323+!,
324+              '', "hello=\nhello=world\n");
325+
326+$ENV{hello} = "moon";
327+run_make_test(q!
328+hello=sun
329+all: base exp
330+base exp: ; @echo hello=$$hello
331+exp: unexport hello=world
332+!,
333+              '', "hello=sun\nhello=\n");
334+
335+run_make_test(q!
336+all:; @echo hello=$$hello
337+unexport hello=sun
338+dummy: hello?=world
339+!,
340+              '', 'hello=');
341+
342+$ENV{hello} = "moon";
343+run_make_test(q!
344+all:; @echo hello=$$hello
345+hello=sun
346+dummy: unexport hello=world
347+!,
348+              '', 'hello=sun');
349+
350+run_make_test(q!
351+all: mid
352+mid: base
353+
354+ifeq ($(midexport),export)
355+mid: export hello=mid
356+else ifeq ($(midexport),unexport)
357+mid: unexport hello=mid
358+else
359+mid: hello=mid
360+endif
361+
362+ifeq ($(baseexport),export)
363+base: export hello=base
364+else ifeq ($(baseexport),unexport)
365+base: unexport hello=base
366+else
367+base: hello=base
368+endif
369+
370+all mid base:; @echo $@ make=$(hello) shell=$$hello
371+!,
372+              '', "base make=base shell=\nmid make=mid shell=\nall make= shell=\n");
373+
374+# Test base settings with env var
375+$ENV{hello} = "environ";
376+run_make_test(undef,
377+              '', "base make=base shell=base\nmid make=mid shell=mid\nall make=environ shell=environ\n");
378+
379+$ENV{hello} = "environ";
380+run_make_test(undef,
381+              'baseexport=export', "base make=base shell=base\nmid make=mid shell=mid\nall make=environ shell=environ\n");
382+
383+$ENV{hello} = "environ";
384+run_make_test(undef,
385+              'baseexport=unexport', "base make=base shell=\nmid make=mid shell=mid\nall make=environ shell=environ\n");
386+
387+# Test mid settings with env var
388+$ENV{hello} = "environ";
389+run_make_test(undef,
390+              'midexport=export', "base make=base shell=base\nmid make=mid shell=mid\nall make=environ shell=environ\n");
391+
392+$ENV{hello} = "environ";
393+run_make_test(undef,
394+              'midexport=export baseexport=unexport', "base make=base shell=\nmid make=mid shell=mid\nall make=environ shell=environ\n");
395+
396+$ENV{hello} = "environ";
397+run_make_test(undef,
398+              'midexport=unexport', "base make=base shell=\nmid make=mid shell=\nall make=environ shell=environ\n");
399+
400+$ENV{hello} = "environ";
401+run_make_test(undef,
402+              'midexport=unexport baseexport=export', "base make=base shell=base\nmid make=mid shell=\nall make=environ shell=environ\n");
403+
404+# Test base settings without env var
405+run_make_test(undef,
406+              'baseexport=export', "base make=base shell=base\nmid make=mid shell=\nall make= shell=\n");
407+
408+run_make_test(undef,
409+              'baseexport=unexport', "base make=base shell=\nmid make=mid shell=\nall make= shell=\n");
410+
411+# Test mid settings with env var
412+run_make_test(undef,
413+              'midexport=export', "base make=base shell=base\nmid make=mid shell=mid\nall make= shell=\n");
414+
415+run_make_test(undef,
416+              'midexport=export baseexport=unexport', "base make=base shell=\nmid make=mid shell=mid\nall make= shell=\n");
417+
418+run_make_test(undef,
419+              'midexport=unexport', "base make=base shell=\nmid make=mid shell=\nall make= shell=\n");
420+
421+run_make_test(undef,
422+              'midexport=unexport baseexport=export', "base make=base shell=base\nmid make=mid shell=\nall make= shell=\n");
423+
424+
425+
426+# TEST #19: Test define/endef variables as target-specific vars
427+
428+# run_make_test('
429+# define b
430+# @echo global
431+# endef
432+# a: define b
433+# @echo local
434+# endef
435+
436+# a: ; $(b)
437+# ',
438+#               '', "local\n");
439+
440+1;
+140, -0
  1@@ -0,0 +1,140 @@
  2+#                                                              -*-mode: perl-*-
  3+
  4+$description = "Test handling of temporary file created from stdin.";
  5+
  6+# These tests rely on the test_driver checking for leftover temporary content
  7+
  8+create_file('input.mk', "world:=1\n");
  9+create_file('bye.mk', "moon:=2\n");
 10+
 11+# sv 62118,62145.
 12+# Test that makes leaves no temp file when make code is piped to stdin and -v,
 13+# -h or an invalid option is specified.
 14+my @opts = ('-v', '-h', '--nosuchopt');
 15+my @exit_codes = (0, 0, 512);
 16+for my $i (0 .. $#opts) {
 17+    close(STDIN);
 18+    open(STDIN, "<", 'input.mk') || die "$0: cannot open input.mk for reading: $!";
 19+    run_make_test(q!
 20+all:; $(info hello world)
 21+!,
 22+                  "$opts[$i] -f-", "/uilt for /", $exit_codes[$i]);
 23+}
 24+
 25+# sv 62118,62145.
 26+# Test that a stdin temp file is removed.
 27+close(STDIN);
 28+open(STDIN, "<", 'input.mk') || die "$0: cannot open input.mk for reading: $!";
 29+run_make_test(q!
 30+all:; $(info world=$(world))
 31+!,
 32+              '-f-', "world=1\n#MAKE#: 'all' is up to date.\n");
 33+
 34+# sv 62118,62145.
 35+# Test that a stdin temp file is removed, even when make re-execs.
 36+# Also test that make honors TMPDIR to create the temp file.
 37+# Ensure touching bye.mk causes re-exec.
 38+&utouch(-600, 'bye.mk');
 39+close(STDIN);
 40+open(STDIN, "<", 'input.mk') || die "$0: cannot open input.mk for reading: $!";
 41+run_make_test(q!
 42+include bye.mk
 43+all:; $(info hello)
 44+$(MAKE_RESTARTS)bye.mk: force; touch $@
 45+force:
 46+!,
 47+              '-R --debug=b -f-', "/Re-executing.+?--temp-stdin=\Q$temppath\E/");
 48+
 49+if ($port_type eq 'UNIX') {
 50+# POSIX doesn't require sh to set PPID so test this
 51+my $cmd = create_command();
 52+add_options($cmd, '-f', '/dev/null', '-E', q!all:;@echo $$PPID!);
 53+my $fout = 'ppidtest.out';
 54+run_command_with_output($fout, @$cmd);
 55+$_ = read_file_into_string($fout);
 56+s/\r?\n//g;
 57+if (/^[0-9]+$/) {
 58+use POSIX ();
 59+
 60+# sv 63157.
 61+# Test that make removes the temporary file which holds make code from stdin,
 62+# even when a signal is received.  include bye.mk and bye.mk: rule is needed
 63+# to cause make to keep the temporary file for re-exec. Without re-exec make
 64+# will remove the file before the signal arrives.  sleep is needed to let make
 65+# write its "... Terminated" message to the log file.  Must use REGEX because
 66+# some systems (MacOS) add extra text after Terminated.
 67+&utouch(-600, 'bye.mk');
 68+close(STDIN);
 69+open(STDIN, "<", 'input.mk') || die "$0: cannot open input.mk for reading: $!";
 70+
 71+run_make_test(q!
 72+include bye.mk
 73+pid := $(shell echo $$PPID)
 74+all:;
 75+bye.mk: force; @#HELPER# -q term $(pid) sleep 10
 76+force:
 77+!,
 78+              '-f-', '/#MAKE#: \*\*\* \[#MAKEFILE#:5: bye.mk] Terminated/', POSIX::SIGTERM);
 79+}
 80+unlink($fout);
 81+
 82+# sv 62118,62145.
 83+# Test that a stdin temp file is removed, when execvp fails to re-exec make.
 84+# In order to cause execvp to fail, copy the tested make binary to the temp
 85+# directory and take away the 'x' bit.
 86+use File::Spec;
 87+use File::Copy;
 88+
 89+my $tmakedir = File::Spec->catfile($cwdpath, 'tmakedir');
 90+mkdir($tmakedir, 0770);
 91+my $makecopy = File::Spec->catfile($tmakedir, 'make');
 92+copy("$mkpath", $makecopy);
 93+# Set file mode bits, because perl copy won't.
 94+chmod 0700, $makecopy;
 95+
 96+my @make_orig = @make_command;
 97+@make_command = ($makecopy);
 98+
 99+# Ensure touching bye.mk causes re-exec.
100+&utouch(-600, 'bye.mk');
101+close(STDIN);
102+open(STDIN, "<", 'input.mk') || die "$0: cannot open input.mk for reading: $!";
103+run_make_test("
104+include bye.mk
105+all:; \$(info hello)
106+\$(MAKE_RESTARTS)bye.mk: force; touch \$@ && chmod u-x $makecopy
107+force:
108+",
109+              "-f-", "touch bye.mk && chmod u-x $makecopy\nmake: $makecopy: $ERR_nonexe_file\n", 32512);
110+
111+@make_command = @make_orig;
112+unlink($makecopy);
113+rmdir($tmakedir);
114+
115+# SV 63333. Test that make exits with an error message if we cannot store a
116+# makefile from stdin to a temporary file.
117+# Create a non-writable temporary directory.
118+
119+# If we do this Valgrind fails because it cannot write temp files... the docs
120+# don't describe any way to tell valgrind to use a directory other than TMPDIR.
121+
122+if (!$valgrind) {
123+    my $tdir = 'test_tmp_dir';
124+    mkdir($tdir, 0500);
125+    $ENV{'TMPDIR'} = $tdir;
126+    close(STDIN);
127+    open(STDIN, "<", 'input.mk') || die "$0: cannot open input.mk for reading: $!";
128+
129+    run_make_test(q!
130+all:; $(info hello, world)
131+!, '-f-', '/cannot store makefile from stdin to a temporary file.  Stop./', 512);
132+    rmdir($tdir);
133+}
134+}
135+
136+# This close MUST come at the end of the test!!
137+close(STDIN);
138+unlink('input.mk', 'bye.mk');
139+
140+# This tells the test driver that the perl test script executed properly.
141+1;
+11, -0
 1@@ -0,0 +1,11 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test support for UTF-8.";
 5+
 6+$details = "";
 7+
 8+# Verify that the UTF-8 BOM is ignored.
 9+run_make_test("\xEF\xBB\xBFall: ; \@echo \$\@\n", '', "all");
10+
11+# This tells the test driver that the perl test script executed properly.
12+1;
+27, -0
 1@@ -0,0 +1,27 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Test recursive variables";
 4+
 5+$details = "";
 6+
 7+run_make_test('
 8+x = variable1
 9+variable2 := Hello
10+y = $(subst 1,2,$(x))
11+z = y
12+a := $($($(z)))
13+all: ; @echo $(a)
14+',
15+              '', "Hello\n");
16+
17+# This tests resetting the value of a variable while expanding it.
18+# You may only see problems with this if you're using valgrind or
19+# some other memory checker that poisons freed memory.
20+# See Savannah patch #7534
21+
22+run_make_test('
23+VARIABLE = $(eval VARIABLE := echo hi)$(VARIABLE)
24+wololo: ; @$(VARIABLE)
25+',
26+              '', "hi\n");
27+
28+1;
+124, -0
  1@@ -0,0 +1,124 @@
  2+#                                                                     -*-perl-*-
  3+
  4+$description = "Test vpath for particular classes of filenames.";
  5+
  6+$details = "";
  7+
  8+mkdir('work');
  9+
 10+@files_to_touch = ("work${pathsep}main.c","work${pathsep}defs.h",
 11+                   "work${pathsep}kbd.c","work${pathsep}command.h",
 12+                   "work${pathsep}commands.c","work${pathsep}display.c",
 13+                   "work${pathsep}buffer.h","work${pathsep}insert.c",
 14+                   "work${pathsep}command.c");
 15+
 16+&touch(@files_to_touch);
 17+
 18+run_make_test(q!
 19+vpath %.c foo
 20+vpath %.c work
 21+vpath %.h work
 22+objects = main.o kbd.o commands.o display.o insert.o
 23+edit: $(objects) ; @echo cc -o $@ $^
 24+main.o : main.c defs.h ; @echo cc -c $(firstword $^)
 25+kbd.o : kbd.c defs.h command.h ; @echo cc -c kbd.c
 26+commands.o : command.c defs.h command.h ; @echo cc -c commands.c
 27+display.o : display.c defs.h buffer.h ; @echo cc -c display.c
 28+insert.o : insert.c defs.h buffer.h ; @echo cc -c insert.c
 29+!,
 30+    '', "cc -c work${pathsep}main.c\ncc -c kbd.c\ncc -c commands.c\n"
 31+        ."cc -c display.c\ncc -c insert.c\n"
 32+        ."cc -o edit main.o kbd.o commands.o display.o insert.o\n");
 33+
 34+unlink(@files_to_touch);
 35+
 36+# TEST 2: after vpath lookup ensure we don't get incorrect circular dependency
 37+# warnings due to change of struct file ptr.  Savannah bug #13529.
 38+
 39+mkdir('vpath-d', 0777);
 40+
 41+run_make_test(q!
 42+vpath %.te vpath-d/
 43+.SECONDARY:
 44+default: vpath-d/a vpath-d/b
 45+vpath-d/a: fail.te
 46+vpath-d/b : fail.te
 47+vpath-d/fail.te:
 48+!,
 49+              '', "#MAKE#: Nothing to be done for 'default'.\n");
 50+
 51+rmdir('vpath-d');
 52+
 53+# Test VPATH vs vpath
 54+
 55+run_make_test(q!
 56+VPATH = work:#PWD#
 57+vpath %.c foo
 58+vpath %.c work
 59+vpath %.c #PWD#
 60+vpath %.h work
 61+vpath %.c
 62+vpath
 63+all: ; @echo ALL IS WELL
 64+!,
 65+              '', "ALL IS WELL\n");
 66+
 67+# Test interaction of -lfoo and vpath
 68+
 69+my @dirs_to_make = qw(a1 b1 a2 b2 b3);
 70+for my $d (@dirs_to_make) {
 71+    mkdir($d, 0777);
 72+}
 73+
 74+my @files_to_touch = ("a1${pathsep}lib1.a",
 75+                      "a1${pathsep}libc.a",
 76+                      "b1${pathsep}lib1.so",
 77+                      "a2${pathsep}lib2.a",
 78+                      "b2${pathsep}lib2.so",
 79+                      "lib3.a",
 80+                      "b3${pathsep}lib3.so");
 81+&touch(@files_to_touch);
 82+
 83+my $answer = "a1${pathsep}lib1.a a1${pathsep}libc.a " .
 84+             "a2${pathsep}lib2.a lib3.a\n";
 85+if ($port_type eq 'VMS-DCL') {
 86+    $answer =~ s/ /,/g;
 87+}
 88+
 89+run_make_test('
 90+vpath %.h b3
 91+vpath %.a a1
 92+vpath %.so b1
 93+vpath % a2 b2
 94+vpath % b3
 95+all: -l1 -lc -l2 -l3; @echo $^
 96+',
 97+              '', $answer);
 98+
 99+unlink(@files_to_touch);
100+for my $d (@dirs_to_make) {
101+    rmdir($d);
102+}
103+
104+# Check that if we find find files with VPATH, we don't do pattern search
105+
106+mkdir("vpa");
107+
108+run_make_test(q!
109+VPATH = vpa
110+%.x: ; @echo pattern $@
111+vpa/foo.x: ; @echo vpath $@
112+!,
113+              'foo.x', "vpath vpa/foo.x\n");
114+
115+rmdir("vpa");
116+
117+# Validate that vpath indented with TAB gives a warning
118+
119+run_make_test(q!
120+#TAB#vpath %.h b3
121+all:;@echo hi
122+!,
123+              '', "#MAKEFILE#:2: warning: vpath directive lines cannot start with TAB\nhi");
124+
125+1;
+68, -0
 1@@ -0,0 +1,68 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Tests VPATH+/GPATH functionality.";
 4+
 5+$details = "";
 6+
 7+mkdir('work');
 8+
 9+$VP = "work$pathsep";
10+
11+open(MAKEFILE,"> $makefile");
12+
13+# The Contents of the MAKEFILE ...
14+
15+print MAKEFILE "VPATH = $VP\n";
16+
17+print MAKEFILE <<'EOMAKE';
18+
19+GPATH = $(VPATH)
20+
21+.SUFFIXES: .a .b .c .d
22+.PHONY: general rename notarget intermediate
23+
24+%.a:
25+%.b:
26+%.c:
27+%.d:
28+
29+%.a : %.b ; cat $^ > $@
30+%.b : %.c ; cat $^ > $@
31+%.c :: %.d ; cat $^ > $@
32+
33+# General testing info:
34+
35+general: foo.b
36+foo.b: foo.c bar.c
37+
38+EOMAKE
39+
40+close(MAKEFILE);
41+
42+@touchedfiles = ();
43+
44+$off = -500;
45+
46+sub gtouchfiles {
47+  foreach (@_) {
48+    ($f = $_) =~ s,VP/,$VP,g;
49+    &utouch($off, $f);
50+    $off += 10;
51+    push(@touchedfiles, $f);
52+  }
53+}
54+
55+# Run the general-case test
56+
57+&gtouchfiles("VP/foo.d", "VP/bar.d", "VP/foo.c", "VP/bar.c", "foo.b", "bar.d");
58+
59+&run_make_with_options($makefile,"general",&get_logfile());
60+
61+push(@touchedfiles, "bar.c");
62+
63+$answer = "$make_name: Nothing to be done for 'general'.\n";
64+
65+&compare_output($answer,&get_logfile(1));
66+
67+unlink(@touchedfiles) unless $keep;
68+
69+1;
+90, -0
 1@@ -0,0 +1,90 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Tests the new VPATH+ functionality added in 3.76.";
 4+
 5+$details = "";
 6+
 7+mkdir('work');
 8+
 9+$VP = "work$pathsep";
10+
11+@touchedfiles = ();
12+
13+$off = -500;
14+
15+sub touchfiles {
16+  foreach (@_) {
17+    &utouch($off, $_);
18+    $off += 10;
19+    push(@touchedfiles, $_);
20+  }
21+}
22+
23+&touchfiles("$VP/foo.d", "$VP/bar.d", "$VP/foo.c", "$VP/bar.c", "foo.b", "bar.d");
24+
25+# Run the general-case test
26+
27+run_make_test(qq!VPATH = $VP! . q!
28+.SUFFIXES: .a .b .c .d
29+.PHONY: general rename notarget intermediate
30+
31+%.a:
32+%.b:
33+%.c:
34+%.d:
35+
36+%.a : %.b ; cat $^ > $@
37+%.b : %.c ; cat $^ > $@ 2>/dev/null || exit 1
38+%.c :: %.d ; cat $^ > $@
39+
40+# General testing info:
41+
42+general: foo.b
43+foo.b: foo.c bar.c
44+
45+# Rename testing info:
46+
47+rename: $(VPATH)/foo.c foo.d
48+
49+# Target not made testing info:
50+
51+notarget: notarget.b
52+notarget.c: notarget.d ; -@echo "not creating $@ from $^"
53+
54+# Intermediate files:
55+
56+intermediate: inter.a
57+!,
58+    'general', "cat bar.d > bar.c\ncat ${VP}foo.c bar.c > foo.b 2>/dev/null || exit 1\n");
59+
60+push(@touchedfiles, "bar.c");
61+
62+# Test rules that don't make the target correctly
63+
64+&touchfiles("$VP/notarget.c", "notarget.b", "notarget.d");
65+
66+run_make_test(undef, 'notarget', "not creating notarget.c from notarget.d\ncat notarget.c > notarget.b 2>/dev/null || exit 1\n#MAKE#: *** [#MAKEFILE#:11: notarget.b] Error 1\n", 512);
67+
68+# Test intermediate file handling (part 1)
69+
70+&touchfiles("$VP/inter.d");
71+
72+my $be = pack("L", 1) eq pack("N", 1);
73+my $intfiles = $be ? "inter.c inter.b" : "inter.b inter.c";
74+
75+run_make_test(undef, 'intermediate', "cat ${VP}inter.d > inter.c\ncat inter.c > inter.b 2>/dev/null || exit 1\ncat inter.b > inter.a\nrm $intfiles\n");
76+
77+push(@touchedfiles, "inter.a", "inter.b");
78+
79+# Test intermediate file handling (part 2)
80+
81+&utouch(-20, "inter.a");
82+&utouch(-10, "$VP/inter.b");
83+&touch("$VP/inter.d");
84+
85+run_make_test(undef, 'intermediate', "cat ${VP}inter.d > inter.c\ncat inter.c > inter.b 2>/dev/null || exit 1\ncat inter.b > inter.a\nrm inter.c\n");
86+
87+push(@touchedfiles, "$VP/inter.b", "$VP/inter.d");
88+
89+unlink @touchedfiles unless $keep;
90+
91+1;
+84, -0
 1@@ -0,0 +1,84 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Test the abspath functions.";
 4+
 5+$details = "";
 6+
 7+# Someone needs to rewrite this to be portable for Windows
 8+$port_type eq 'W32' and return -1;
 9+
10+run_make_test('
11+ifneq ($(realpath $(abspath .)),$(CURDIR))
12+  $(warning .: abs="$(abspath .)" real="$(realpath $(abspath .))" curdir="$(CURDIR)")
13+endif
14+
15+ifneq ($(realpath $(abspath ./)),$(CURDIR))
16+  $(warning ./: abs="$(abspath ./)" real="$(realpath $(abspath ./))" curdir="$(CURDIR)")
17+endif
18+
19+ifneq ($(realpath $(abspath .///)),$(CURDIR))
20+  $(warning .///: abs="$(abspath .///)" real="$(realpath $(abspath .///))" curdir="$(CURDIR)")
21+endif
22+
23+ifneq ($(abspath /),/)
24+  $(warning /: abspath="$(abspath /)")
25+endif
26+
27+ifneq ($(abspath ///),/)
28+  $(warning ///: abspath="$(abspath ///)")
29+endif
30+
31+ifneq ($(abspath /.),/)
32+  $(warning /.: abspath="$(abspath /.)")
33+endif
34+
35+ifneq ($(abspath ///.),/)
36+  $(warning ///.: abspath="$(abspath ///.)")
37+endif
38+
39+ifneq ($(abspath /./),/)
40+  $(warning /./: abspath="$(abspath /./)")
41+endif
42+
43+ifneq ($(abspath /.///),/)
44+  $(warning /.///: abspath="$(abspath /.///)")
45+endif
46+
47+ifneq ($(abspath /..),/)
48+  $(warning /..: abspath="$(abspath /..)")
49+endif
50+
51+ifneq ($(abspath ///..),/)
52+  $(warning ///..: abspath="$(abspath ///..)")
53+endif
54+
55+ifneq ($(abspath /../),/)
56+  $(warning /../: abspath="$(abspath /../)")
57+endif
58+
59+ifneq ($(abspath /..///),/)
60+  $(warning /..///: abspath="$(abspath /..///)")
61+endif
62+
63+
64+ifneq ($(abspath /foo/bar/..),/foo)
65+  $(warning /foo/bar/..: abspath="$(abspath /foo/bar/..)")
66+endif
67+
68+ifneq ($(abspath /foo/bar/../../../baz),/baz)
69+  $(warning /foo/bar/../../../baz: abspath="$(abspath /foo/bar/../../../baz)")
70+endif
71+
72+ifneq ($(abspath /foo/bar/../ /..),/foo /)
73+  $(warning /foo/bar/../ /..: abspath="$(abspath /foo/bar/../ /..)")
74+endif
75+
76+
77+.PHONY: all
78+all: ; @:
79+',
80+'',
81+'');
82+
83+
84+# This tells the test driver that the perl test script executed properly.
85+1;
+44, -0
 1@@ -0,0 +1,44 @@
 2+$description = "The following test creates a makefile to test the addprefix "
 3+              ."function.";
 4+
 5+$details = "";
 6+
 7+# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
 8+# THE NAME OF THE MAKEFILE.  THIS INSURES CONSISTENCY AND KEEPS TRACK OF
 9+# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
10+# EXAMPLE: $makefile2 = &get_tmpfile;
11+
12+
13+open(MAKEFILE,"> $makefile");
14+
15+# The Contents of the MAKEFILE ...
16+
17+print MAKEFILE "string := \$(addprefix src${pathsep},a.b.z.foo hacks) \n"
18+              ."all: \n"
19+              ."\t\@echo \$(string) \n";
20+
21+# END of Contents of MAKEFILE
22+
23+close(MAKEFILE);
24+
25+&run_make_with_options($makefile,"",&get_logfile,0);
26+
27+# Create the answer to what should be produced by this Makefile
28+$answer = "src${pathsep}a.b.z.foo src${pathsep}hacks\n";
29+
30+# COMPARE RESULTS
31+
32+# In this call to compare output, you should use the call &get_logfile(1)
33+# to send the name of the last logfile created.  You may also use
34+# the special call &get_logfile(1) which returns the same as &get_logfile(1).
35+
36+&compare_output($answer,&get_logfile(1));
37+
38+# This tells the test driver that the perl test script executed properly.
39+1;
40+
41+
42+
43+
44+
45+
+36, -0
 1@@ -0,0 +1,36 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Test the addsuffix function.";
 4+
 5+$details = "";
 6+
 7+
 8+open(MAKEFILE,"> $makefile");
 9+
10+# The Contents of the MAKEFILE ...
11+
12+print MAKEFILE <<EOMAKE;
13+string := \$(addsuffix .c,src${pathsep}a.b.z.foo hacks)
14+one: ; \@echo \$(string)
15+
16+two: ; \@echo \$(addsuffix foo,)
17+EOMAKE
18+
19+close(MAKEFILE);
20+
21+
22+# TEST 0
23+
24+&run_make_with_options($makefile, "", &get_logfile);
25+$answer = "src${pathsep}a.b.z.foo.c hacks.c\n";
26+&compare_output($answer,&get_logfile(1));
27+
28+
29+# TEST 1
30+
31+&run_make_with_options($makefile, "two", &get_logfile);
32+$answer = "\n";
33+&compare_output($answer,&get_logfile(1));
34+
35+
36+# This tells the test driver that the perl test script executed properly.
37+1;
+50, -0
 1@@ -0,0 +1,50 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Test the and & or functions.\n";
 4+
 5+$details = "Try various uses of and & or to ensure they all give the correct
 6+results.\n";
 7+
 8+# TEST #0
 9+# For $(and ...), it will either be empty or the last value
10+run_make_test('
11+NEQ = $(subst $1,,$2)
12+f =
13+t = true
14+
15+all:
16+#TAB#@echo 1 $(and    ,$t)
17+#TAB#@echo 2 $(and $t)
18+#TAB#@echo 3 $(and $t,)
19+#TAB#@echo 4 $(and z,true,$f,false)
20+#TAB#@echo 5 $(and $t,$f,$(info bad short-circuit))
21+#TAB#@echo 6 $(and $(call NEQ,a,b),true)
22+#TAB#@echo 7 $(and $(call NEQ,a,a),true)
23+#TAB#@echo 8 $(and z,true,fal,se) hi
24+#TAB#@echo 9 $(and ,true,fal,se)there
25+#TAB#@echo 10 $(and   $(e) ,$t)',
26+              '',
27+              "1\n2 true\n3\n4\n5\n6 true\n7\n8 se hi\n9 there\n10\n");
28+
29+# TEST #1
30+# For $(or ...), it will either be empty or the first true value
31+run_make_test('
32+NEQ = $(subst $1,,$2)
33+f =
34+t = true
35+
36+all:
37+#TAB#@echo 1 $(or    ,    )
38+#TAB#@echo 2 $(or $t)
39+#TAB#@echo 3 $(or ,$t)
40+#TAB#@echo 4 $(or z,true,$f,false)
41+#TAB#@echo 5 $(or $t,$(info bad short-circuit))
42+#TAB#@echo 6 $(or $(info short-circuit),$t)
43+#TAB#@echo 7 $(or $(call NEQ,a,b),true)
44+#TAB#@echo 8 $(or $(call NEQ,a,a),true)
45+#TAB#@echo 9 $(or z,true,fal,se) hi
46+#TAB#@echo 10 $(or ,true,fal,se)there
47+#TAB#@echo 11 $(or   $(e) ,$f)',
48+              '',
49+              "short-circuit\n1\n2 true\n3 true\n4 z\n5 true\n6 true\n7 b\n8 true\n9 z hi\n10 truethere\n11\n");
50+
51+1;
+44, -0
 1@@ -0,0 +1,44 @@
 2+$description = "The following test creates a makefile to test the suffix "
 3+              ."function.";
 4+
 5+$details = "";
 6+
 7+# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
 8+# THE NAME OF THE MAKEFILE.  THIS INSURES CONSISTENCY AND KEEPS TRACK OF
 9+# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
10+# EXAMPLE: $makefile2 = &get_tmpfile;
11+
12+
13+open(MAKEFILE,"> $makefile");
14+
15+# The Contents of the MAKEFILE ...
16+
17+print MAKEFILE "string := \$(basename src${pathsep}a.b.z.foo.c src${pathsep}hacks src.bar${pathsep}a.b.z.foo.c src.bar${pathsep}hacks hacks) \n"
18+              ."all: \n"
19+              ."\t\@echo \$(string) \n";
20+
21+# END of Contents of MAKEFILE
22+
23+close(MAKEFILE);
24+
25+&run_make_with_options($makefile,"",&get_logfile,0);
26+
27+# Create the answer to what should be produced by this Makefile
28+$answer = "src${pathsep}a.b.z.foo src${pathsep}hacks src.bar${pathsep}a.b.z.foo src.bar${pathsep}hacks hacks\n";
29+
30+# COMPARE RESULTS
31+
32+# In this call to compare output, you should use the call &get_logfile(1)
33+# to send the name of the last logfile created.  You may also use
34+# the special call &get_logfile(1) which returns the same as &get_logfile(1).
35+
36+&compare_output($answer,&get_logfile(1));
37+
38+# This tells the test driver that the perl test script executed properly.
39+1;
40+
41+
42+
43+
44+
45+
+88, -0
 1@@ -0,0 +1,88 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Test the call function.\n";
 4+
 5+$details = "Try various uses of call and ensure they all give the correct
 6+results.\n";
 7+
 8+run_make_test(q!
 9+# Simple, just reverse two things
10+#
11+reverse = $2 $1
12+
13+# A complex 'map' function, using recursive 'call'.
14+#
15+map = $(foreach a,$2,$(call $1,$a))
16+
17+# Test using a builtin; this is silly as it's simpler to do without call
18+#
19+my-notdir = $(call notdir,$(1))
20+
21+# Test using non-expanded builtins
22+#
23+my-foreach = $(foreach $(1),$(2),$(3))
24+my-if      = $(if $(1),$(2),$(3))
25+
26+# Test recursive invocations of call with different arguments
27+#
28+one = $(1) $(2) $(3)
29+two = $(call one,$(1),foo,$(2))
30+
31+# Test recursion on the user-defined function.  As a special case make
32+# won't error due to this.
33+# Implement transitive closure using $(call ...)
34+#
35+DEP_foo = bar baz quux
36+DEP_baz = quux blarp
37+rest = $(wordlist 2,$(words ${1}),${1})
38+tclose = $(if $1,$(firstword $1)\
39+#TAB##TAB#$(call tclose,$(sort ${DEP_$(firstword $1)} $(call rest,$1))))
40+
41+all: ; @echo '$(call reverse,bar,foo)'; \
42+        echo '$(call map,origin,MAKE reverse map)'; \
43+        echo '$(call my-notdir,a/b   c/d      e/f)'; \
44+        echo '$(call my-foreach)'; \
45+        echo '$(call my-foreach,a,,,)'; \
46+        echo '$(call my-if,a,b,c)'; \
47+        echo '$(call two,bar,baz)'; \
48+#TAB#echo '$(call tclose,foo)';
49+!,
50+              "", "foo bar\ndefault file file\nb d f\n\n\nb\nbar foo baz\nfoo bar baz blarp quux \n");
51+
52+# These won't work because call expands all its arguments first, before
53+# passing them on, then marks them as resolved/simple, so they're not
54+# expanded again by the function.
55+#
56+#        echo '$(call my-foreach,a,x y z,$$(a)$$(a))'; \
57+#        echo '$(call my-if,,$$(info don't print this),$$(info do print this))'
58+#
59+# $answer = "xx yy zz\ndo print this\n";
60+
61+# TEST eclipsing of arguments when invoking sub-calls
62+
63+run_make_test(q!
64+all = $1 $2 $3 $4 $5 $6 $7 $8 $9
65+
66+level1 = $(call all,$1,$2,$3,$4,$5)
67+level2 = $(call level1,$1,$2,$3)
68+level3 = $(call level2,$1,$2,$3,$4,$5)
69+
70+all:
71+#TAB#@echo $(call all,1,2,3,4,5,6,7,8,9,10,11)
72+#TAB#@echo $(call level1,1,2,3,4,5,6,7,8)
73+#TAB#@echo $(call level2,1,2,3,4,5,6,7,8)
74+#TAB#@echo $(call level3,1,2,3,4,5,6,7,8)
75+!,
76+              "", "1 2 3 4 5 6 7 8 9\n1 2 3 4 5\n1 2 3\n1 2 3\n");
77+
78+# Ensure that variables are defined in global scope even in a $(call ...)
79+
80+delete $ENV{X123};
81+
82+run_make_test(q!
83+tst = $(eval export X123)
84+$(call tst)
85+all: ; @echo "$${X123-not set}"
86+!,
87+              '', "\n");
88+
89+1;
+44, -0
 1@@ -0,0 +1,44 @@
 2+$description = "The following test creates a makefile to test the dir "
 3+              ."function.";
 4+
 5+$details = "";
 6+
 7+# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
 8+# THE NAME OF THE MAKEFILE.  THIS INSURES CONSISTENCY AND KEEPS TRACK OF
 9+# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
10+# EXAMPLE: $makefile2 = &get_tmpfile;
11+
12+
13+open(MAKEFILE,"> $makefile");
14+
15+# The Contents of the MAKEFILE ...
16+
17+print MAKEFILE "string := \$(dir src${pathsep}foo.c hacks) \n"
18+              ."all: \n"
19+              ."\t\@echo \$(string) \n";
20+
21+# END of Contents of MAKEFILE
22+
23+close(MAKEFILE);
24+
25+&run_make_with_options($makefile,"",&get_logfile,0);
26+
27+# Create the answer to what should be produced by this Makefile
28+$answer = "src${pathsep} .${pathsep}\n";
29+
30+# COMPARE RESULTS
31+
32+# In this call to compare output, you should use the call &get_logfile(1)
33+# to send the name of the last logfile created.  You may also use
34+# the special call &get_logfile(1) which returns the same as &get_logfile(1).
35+
36+&compare_output($answer,&get_logfile(1));
37+
38+# This tells the test driver that the perl test script executed properly.
39+1;
40+
41+
42+
43+
44+
45+
+55, -0
 1@@ -0,0 +1,55 @@
 2+#                                                                    -*-Perl-*-
 3+
 4+$description = "\
 5+The following test creates a makefile to test the error function.";
 6+
 7+$details = "";
 8+
 9+# Test #1
10+
11+run_make_test(q!err = $(error Error found)
12+
13+ifdef ERROR1
14+$(error error is $(ERROR1))
15+endif
16+
17+ifdef ERROR2
18+$(error error is $(ERROR2))
19+endif
20+
21+ifdef ERROR3
22+all: some; @echo $(error error is $(ERROR3))
23+endif
24+
25+ifdef ERROR4
26+all: some; @echo error is $(ERROR4)
27+#TAB#@echo $(error error is $(ERROR4))
28+endif
29+
30+some: ; @echo Some stuff
31+
32+testvar: ; @: $(err)
33+!,
34+              "ERROR1=yes", "#MAKEFILE#:4: *** error is yes.  Stop.\n", 512);
35+
36+# Test #2
37+
38+run_make_test(undef, "ERROR2=no", "#MAKEFILE#:8: *** error is no.  Stop.\n", 512);
39+
40+# Test #3
41+
42+run_make_test(undef, "ERROR3=maybe",
43+              "Some stuff\n#MAKEFILE#:12: *** error is maybe.  Stop.\n", 512);
44+
45+# Test #4
46+
47+run_make_test(undef, "ERROR4=definitely",
48+              "Some stuff\n#MAKEFILE#:17: *** error is definitely.  Stop.\n", 512);
49+
50+# Test #5
51+
52+run_make_test(undef, "testvar",
53+              "#MAKEFILE#:22: *** Error found.  Stop.\n", 512);
54+
55+# This tells the test driver that the perl test script executed properly.
56+1;
+169, -0
  1@@ -0,0 +1,169 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test the eval function.";
  5+
  6+$details = "This is a test of the eval function in GNU Make.
  7+This function will evaluate inline makefile syntax and incorporate the
  8+results into its internal database.\n";
  9+
 10+open(MAKEFILE,"> $makefile");
 11+
 12+print MAKEFILE <<'EOF';
 13+define Y
 14+  all:: ; @echo $AA
 15+  A = B
 16+endef
 17+
 18+X = $(eval $(value Y))
 19+
 20+$(eval $(shell echo A = A))
 21+$(eval $(Y))
 22+$(eval A = C)
 23+$(eval $(X))
 24+EOF
 25+
 26+close(MAKEFILE);
 27+
 28+&run_make_with_options($makefile, "", &get_logfile);
 29+
 30+# Create the answer to what should be produced by this Makefile
 31+$answer = "AA\nBA\n";
 32+
 33+&compare_output($answer,&get_logfile(1));
 34+
 35+# Test to make sure defining variables when we have extra scope pushed works
 36+# as expected.
 37+
 38+$makefile2 = &get_tmpfile;
 39+
 40+open(MAKEFILE,"> $makefile2");
 41+
 42+print MAKEFILE <<'EOF';
 43+VARS = A B
 44+
 45+VARSET = $(1) = $(2)
 46+
 47+$(foreach v,$(VARS),$(eval $(call VARSET,$v,$v)))
 48+
 49+all: ; @echo A = $(A) B = $(B)
 50+EOF
 51+
 52+close(MAKEFILE);
 53+
 54+&run_make_with_options($makefile2, "", &get_logfile);
 55+
 56+# Create the answer to what should be produced by this Makefile
 57+$answer = "A = A B = B\n";
 58+
 59+&compare_output($answer,&get_logfile(1));
 60+
 61+# Test to make sure eval'ing inside conditionals works properly
 62+
 63+$makefile3 = &get_tmpfile;
 64+
 65+open(MAKEFILE,"> $makefile3");
 66+
 67+print MAKEFILE <<'EOF';
 68+FOO = foo
 69+
 70+all:: ; @echo it
 71+
 72+define Y
 73+  all:: ; @echo worked
 74+endef
 75+
 76+ifdef BAR
 77+$(eval $(Y))
 78+endif
 79+
 80+EOF
 81+
 82+close(MAKEFILE);
 83+
 84+&run_make_with_options($makefile3, "", &get_logfile);
 85+$answer = "it\n";
 86+&compare_output($answer,&get_logfile(1));
 87+
 88+&run_make_with_options($makefile3, "BAR=1", &get_logfile);
 89+$answer = "it\nworked\n";
 90+&compare_output($answer,&get_logfile(1));
 91+
 92+
 93+# TEST very recursive invocation of eval
 94+
 95+$makefile3 = &get_tmpfile;
 96+
 97+open(MAKEFILE,"> $makefile3");
 98+
 99+print MAKEFILE <<'EOF';
100+..9 := 0 1 2 3 4 5 6 7 8 9
101+rev=$(eval res:=)$(foreach word,$1,$(eval res:=${word} ${res}))${res}
102+a:=$(call rev,${..9})
103+all: ; @echo '[$(a)]'
104+
105+EOF
106+
107+close(MAKEFILE);
108+
109+&run_make_with_options($makefile3, "", &get_logfile);
110+$answer = "[         9 8 7 6 5 4 3 2 1 0 ]\n";
111+&compare_output($answer,&get_logfile(1));
112+
113+
114+# TEST eval with no filename context.
115+# The trick here is that because EVAR is taken from the environment, it must
116+# be evaluated before every command is invoked.  Make sure that works, when
117+# we have no file context for reading_file (bug # 6195)
118+
119+$makefile4 = &get_tmpfile;
120+
121+open(MAKEFILE,"> $makefile4");
122+
123+print MAKEFILE <<'EOF';
124+EVAR = $(eval FOBAR = 1)
125+all: ; @echo "OK"
126+
127+EOF
128+
129+close(MAKEFILE);
130+
131+$ENV{EVAR} = '1';
132+&run_make_with_options($makefile4, "", &get_logfile);
133+$answer = "OK\n";
134+&compare_output($answer,&get_logfile(1));
135+
136+
137+# Clean out previous information to allow new run_make_test() interface.
138+# If we ever convert all the above to run_make_test() we can remove this line.
139+$makefile = undef;
140+
141+# Test handling of backslashes in strings to be evaled.
142+
143+run_make_test('
144+define FOO
145+all: ; @echo hello \
146+world
147+endef
148+$(eval $(FOO))
149+', '', 'hello world');
150+
151+run_make_test('
152+define FOO
153+all: ; @echo '."'".'he\llo'."'".'
154+#TAB#@echo world
155+endef
156+$(eval $(FOO))
157+', '', 'he\llo
158+world');
159+
160+
161+# We don't allow new target/prerequisite relationships to be defined within a
162+# command script, because these are evaluated after snap_deps() and that
163+# causes lots of problems (like core dumps!)
164+# See Savannah bug # 12124.
165+
166+run_make_test('deps: ; $(eval deps: foo)', '',
167+              '#MAKEFILE#:1: *** prerequisites cannot be defined in recipes.  Stop.',
168+              512);
169+
170+1;
+232, -0
  1@@ -0,0 +1,232 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = 'Test the $(file ...) function.';
  5+
  6+# Test > and >>
  7+run_make_test(q!
  8+define A
  9+a
 10+b
 11+endef
 12+B = c d
 13+$(file >file.out,$(A))
 14+$(foreach L,$(B),$(file >>     file.out,$L))
 15+x:;@echo hi; cat file.out
 16+!,
 17+              '', "hi\na\nb\nc\nd");
 18+
 19+unlink('file.out');
 20+
 21+# Test >> to a non-existent file
 22+run_make_test(q!
 23+define A
 24+a
 25+b
 26+endef
 27+$(file     >>     file.out    ,$(A))
 28+x:;@cat file.out
 29+!,
 30+              '', "a\nb");
 31+
 32+unlink('file.out');
 33+
 34+# Test > with no content
 35+run_make_test(q!
 36+$(file >4touch)
 37+.PHONY:x
 38+x:;@cat 4touch
 39+!,
 40+              '', '');
 41+
 42+# Test >> with no content
 43+run_make_test(q!
 44+$(file >>4touch)
 45+.PHONY:x
 46+x:;@cat 4touch
 47+!,
 48+              '', '');
 49+unlink('4touch');
 50+
 51+# Test > to a read-only file
 52+if (defined $ERR_read_only_file) {
 53+    touch('file.out');
 54+    chmod(0444, 'file.out');
 55+
 56+    run_make_test(q!
 57+define A
 58+a
 59+b
 60+endef
 61+$(file     >     file.out,$(A))
 62+x:;@cat file.out
 63+!,
 64+                  '', "#MAKEFILE#:6: *** open: file.out: $ERR_read_only_file.  Stop.",
 65+                  512);
 66+
 67+    unlink('file.out');
 68+}
 69+
 70+# Use variables for operator and filename
 71+run_make_test(q!
 72+define A
 73+a
 74+b
 75+endef
 76+OP = >
 77+FN = file.out
 78+$(file     $(OP)     $(FN),$(A))
 79+x:;@cat file.out
 80+!,
 81+              '', "a\nb");
 82+
 83+unlink('file.out');
 84+
 85+# Don't add newlines if one already exists
 86+run_make_test(q!
 87+define A
 88+a
 89+b
 90+
 91+endef
 92+$(file >file.out,$(A))
 93+x:;@cat file.out
 94+!,
 95+              '', "a\nb");
 96+
 97+unlink('file.out');
 98+
 99+# Empty text
100+run_make_test(q!
101+$(file >file.out,)
102+$(file >>file.out,)
103+x:;@cat file.out
104+!,
105+              '', "\n\n");
106+
107+unlink('file.out');
108+
109+# Reading files
110+run_make_test(q!
111+$(file >file.out,A = foo)
112+X1 := $(file <file.out)
113+$(file >>file.out,B = bar)
114+$(eval $(file <file.out))
115+
116+x:;@echo '$(X1)'; echo '$(A)'; echo '$(B)'
117+!,
118+              '', "A = foo\nfoo\nbar\n");
119+
120+unlink('file.out');
121+
122+# Read an empty file.
123+touch("file.out");
124+run_make_test(q!# empty file
125+X1 := x$(file <file.out)y
126+x:;@echo '$(X1)'
127+!,
128+              '', "xy\n");
129+
130+unlink('file.out');
131+
132+# Read a file whose full contents is a newline.
133+create_file('file.out', "\n");
134+run_make_test(q!# <nl>
135+X1 := x$(file <file.out)y
136+x:;@echo '$(X1)'
137+!,
138+              '', "xy\n");
139+
140+unlink('file.out');
141+
142+# Read a file which does not end with a newline.
143+create_file('file.out', "hello");
144+# echo prints a trailig newline, because run_make_test appends a newline.
145+run_make_test(q!# hello
146+X1 := x$(file <file.out)y
147+x:;@echo $(X1)
148+!,
149+              '', "xhelloy\n");
150+
151+unlink('file.out');
152+
153+# Read a file which ends with a newline.
154+create_file('file.out', "hello\n");
155+# echo prints a trailig newline, because run_make_test appends a newline.
156+run_make_test(q!# hello<nl>
157+X1 := x$(file <file.out)y
158+x:;@echo '$(X1)'
159+!,
160+              '', "xhelloy\n");
161+
162+
163+unlink('file.out');
164+
165+# Read a file which ends with multiple newlines.
166+create_file('file.out', "hello\n\n");
167+run_make_test(q!# hello<nl><nl>
168+X1 := x$(file <file.out)y
169+export X1
170+x:;@echo "$$X1"
171+!,
172+              '', "xhello\ny\n");
173+
174+unlink('file.out');
175+
176+# Read a file whose contents exceed 200 bytes.
177+# 200 is the initial size of variable_buffer.
178+# File bigger than 200 bytes causes a realloc.
179+# The size of the file in this test not only exceeds 200 bytes, it exceeds 65k.
180+# Use $(info ...) here to avoid command line limitations
181+
182+my $s = "hello world, hello world, hello world, hello world, hello world";
183+my $answer = $s x 2000;
184+create_file('file.out', $answer);
185+run_make_test(q!# <hugestring>
186+X1 := x$(file <file.out)y
187+x:;@$(info $(X1))
188+!,
189+              '', "x${answer}y\n#MAKE#: 'x' is up to date.\n");
190+
191+unlink('file.out');
192+
193+# Reading from non-existent file
194+run_make_test(q!
195+X1 := $(file <file.out)
196+x:;@echo '$(X1)';
197+!,
198+              '', "\n");
199+
200+# Extra arguments in read mode
201+run_make_test(q!
202+X1 := $(file <file.out,foo)
203+x:;@echo '$(X1)';
204+!,
205+              '', "#MAKEFILE#:2: *** file: too many arguments.  Stop.\n", 512);
206+
207+
208+# Missing filename
209+run_make_test('$(file >)', '',
210+              "#MAKEFILE#:1: *** file: missing filename.  Stop.\n", 512);
211+
212+run_make_test('$(file >>)', '',
213+              "#MAKEFILE#:1: *** file: missing filename.  Stop.\n", 512);
214+
215+run_make_test('$(file <)', '',
216+              "#MAKEFILE#:1: *** file: missing filename.  Stop.\n", 512);
217+
218+# Bad call
219+
220+run_make_test('$(file foo)', '',
221+              "#MAKEFILE#:1: *** file: invalid file operation: foo.  Stop.\n", 512);
222+
223+# SV 17448: check whitespace
224+create_file('out1', "1\n");
225+
226+run_make_test(q!
227+all:;$(info $(file <  out1  ))
228+!,
229+              '', "1\n#MAKE#: 'all' is up to date.");
230+
231+unlink('out1');
232+
233+1;
+58, -0
 1@@ -0,0 +1,58 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the filter and filter-out functions.";
 5+
 6+$details = "The makefile created in this test has two variables.  The
 7+filter-out function is first used to discard names ending in
 8+.o with a single simple pattern.  The second filter-out function
 9+augments the simple pattern with three literal names, which are
10+also added to the text argument.  This tests an internal hash table
11+which is only used if there are multiple literals present in both
12+the pattern and text arguments.  The result of both filter-out
13+functions is the same single .elc name.\n";
14+
15+# Basic test -- filter
16+run_make_test(q!
17+files1 := $(filter %.o, foo.elc bar.o lose.o)
18+files2 := $(filter %.o foo.i, foo.i bar.i lose.i foo.elc bar.o lose.o)
19+all: ; @echo '$(files1) $(files2)'
20+!,
21+              '', "bar.o lose.o foo.i bar.o lose.o\n");
22+
23+# Basic test -- filter-out
24+run_make_test(q!
25+files1 := $(filter-out %.o, foo.elc bar.o lose.o)
26+files2 := $(filter-out foo.i bar.i lose.i %.o, foo.i bar.i lose.i foo.elc bar.o lose.o)
27+all: ; @echo '$(files1) $(files2)'
28+!,
29+              '', "foo.elc foo.elc\n");
30+
31+# Force use of hash (see function.c:func_filter_filterout for params)
32+
33+my $base = 'foo.1 foo.2 foo.3 foo.4 foo.5 foo.6 foo.7 foo.8 foo.9 foo.10';
34+
35+my $base10 = join(' ', ($base) x 10);
36+my $out3 = join(' ', ('foo.3') x 10);
37+my $out456 = join(' ', ('foo.4 foo.5 foo.6') x 10);
38+
39+run_make_test("words := $base10" . q!
40+files1 := $(filter %.3, $(words))
41+files2 := $(filter %.4 foo.5 foo.6, $(words))
42+all: ; @echo '$(files1) $(files2)'
43+!,
44+              '', "$out3 $out456\n");
45+
46+
47+# Escaped patterns
48+run_make_test(q!all:;@echo '$(filter foo\%bar,foo%bar fooXbar)'!,
49+              '', "foo%bar\n");
50+
51+run_make_test(q!all:;@echo '$(filter foo\%\%\\\\\%\%bar,foo%%\\%%bar fooX\\Ybar)'!,
52+              '', "foo%%\\%%bar\n");
53+
54+run_make_test(q!
55+X = $(filter foo\\\\\%bar,foo\%bar foo\Xbar)
56+all:;@echo '$(X)'!,
57+              '', "foo\\%bar\n");
58+
59+1;
+47, -0
 1@@ -0,0 +1,47 @@
 2+$description = "The following test creates a makefile to test the findstring "
 3+              ."function.";
 4+
 5+$details = "";
 6+
 7+# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
 8+# THE NAME OF THE MAKEFILE.  THIS INSURES CONSISTENCY AND KEEPS TRACK OF
 9+# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
10+# EXAMPLE: $makefile2 = &get_tmpfile;
11+
12+
13+open(MAKEFILE,"> $makefile");
14+
15+# The Contents of the MAKEFILE ...
16+
17+print MAKEFILE "string := \$(findstring port, reporter)\n"
18+              ."all: \n"
19+              ."\t\@echo \$(string) \n";
20+
21+# END of Contents of MAKEFILE
22+
23+close(MAKEFILE);
24+
25+&run_make_with_options($makefile,
26+                       "",
27+                       &get_logfile,
28+                       0);
29+
30+# Create the answer to what should be produced by this Makefile
31+$answer = "port\n";
32+
33+# COMPARE RESULTS
34+
35+# In this call to compare output, you should use the call &get_logfile(1)
36+# to send the name of the last logfile created.  You may also use
37+# the special call &get_logfile(1) which returns the same as &get_logfile(1).
38+
39+&compare_output($answer,&get_logfile(1));
40+
41+# This tells the test driver that the perl test script executed properly.
42+1;
43+
44+
45+
46+
47+
48+
+44, -0
 1@@ -0,0 +1,44 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Test the flavor function.";
 4+
 5+$details = "";
 6+
 7+
 8+# Test #1: Test general logic.
 9+#
10+run_make_test('
11+s := s
12+r = r
13+
14+$(info u $(flavor u))
15+$(info s $(flavor s))
16+$(info r $(flavor r))
17+
18+ra += ra
19+rc ?= rc
20+
21+$(info ra $(flavor ra))
22+$(info rc $(flavor rc))
23+
24+s += s
25+r += r
26+
27+$(info s $(flavor s))
28+$(info r $(flavor r))
29+
30+
31+.PHONY: all
32+all:;@:
33+',
34+'',
35+'u undefined
36+s simple
37+r recursive
38+ra recursive
39+rc recursive
40+s simple
41+r recursive');
42+
43+
44+# This tells the test driver that the perl test script executed properly.
45+1;
+93, -0
 1@@ -0,0 +1,93 @@
 2+#                                                                    -*-perl-*-
 3+# $Id$
 4+
 5+$description = "Test the foreach function.";
 6+
 7+$details = "This is a test of the foreach function in gnu make.
 8+This function starts with a space separated list of
 9+names and a variable. Each name in the list is substituted
10+into the variable and the given text evaluated. The general
11+form of the command is $(foreach var,\$list,\$text). Several
12+types of foreach loops are tested\n";
13+
14+
15+# TEST 0
16+
17+# Set an environment variable that we can test in the makefile.
18+$ENV{FOOFOO} = 'foo foo';
19+
20+run_make_test("space = ' '".'
21+null :=
22+auto_var = udef space CC null FOOFOO MAKE foo CFLAGS WHITE @ <
23+foo = bletch null @ garf
24+av = $(foreach var, $(auto_var), $(origin $(var)) )
25+override WHITE := BLACK
26+for_var = $(addsuffix .c,foo $(null) $(foo) $(space) $(av) )
27+fe = $(foreach var2, $(for_var),$(subst .c,.o, $(var2) ) )
28+all: auto for2
29+auto : ; @echo $(av)
30+for2: ; @echo $(fe)',
31+              '-e WHITE=WHITE CFLAGS=',
32+              "undefined file default file environment override default file command line override automatic automatic
33+foo.o bletch.o null.o @.o garf.o .o    .o undefined.o file.o default.o file.o environment.o override.o default.o file.o command.o line.o override.o automatic.o automatic.o");
34+
35+# TEST 1: Test that foreach variables take precedence over global
36+# variables in a global scope (like inside an eval).  Tests bug #11913
37+
38+run_make_test('
39+.PHONY: all target
40+all: target
41+
42+x := BAD
43+
44+define mktarget
45+target: x := $(x)
46+target: ; @echo "$(x)"
47+endef
48+
49+x := GLOBAL
50+
51+$(foreach x,FOREACH,$(eval $(value mktarget)))',
52+              '',
53+              'FOREACH');
54+
55+# Allow variable names with trailing space
56+run_make_test(q!
57+$(foreach \
58+  a \
59+, b c d \
60+, $(info $a))
61+all:;@:
62+!,
63+              "", "b\nc\nd\n");
64+
65+# Allow empty variable names.  We still expand the body.
66+
67+run_make_test('
68+x = $(foreach ,1 2 3,a)
69+y := $x
70+
71+all: ; @echo $y',
72+              '', "a a a\n");
73+
74+# Check some error conditions.
75+
76+run_make_test('
77+x = $(foreach )
78+y = $x
79+
80+all: ; @echo $y',
81+              '',
82+              "#MAKEFILE#:2: *** insufficient number of arguments (1) to function 'foreach'.  Stop.",
83+              512);
84+
85+run_make_test('
86+x = $(foreach x,y)
87+y := $x
88+
89+all: ; @echo $y',
90+              '',
91+              "#MAKEFILE#:2: *** insufficient number of arguments (2) to function 'foreach'.  Stop.",
92+              512);
93+
94+1;
+117, -0
  1@@ -0,0 +1,117 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = 'Test the $(guile ...) function.';
  5+
  6+$details = 'This only works on systems that support it.';
  7+
  8+# If this instance of make doesn't support GNU Guile, skip it
  9+# This detects if guile is loaded using the "load" directive
 10+# $makefile = get_tmpfile();
 11+# open(MAKEFILE, "> $makefile") || die "Failed to open $makefile: $!\n";
 12+# print MAKEFILE q!
 13+# -load guile
 14+# all: ; @echo $(filter guile,$(.LOADED))
 15+# !;
 16+# close(MAKEFILE) || die "Failed to write $makefile: $!\n";
 17+# $cmd = subst_make_string("#MAKEPATH# -f $makefile");
 18+# $log = get_logfile(0);
 19+# $code = run_command_with_output($log, $cmd);
 20+# read_file_into_string ($log) eq "guile\n" and $FEATURES{guile} = 1;
 21+
 22+# If we don't have Guile support, never mind.
 23+exists $FEATURES{guile} or return -1;
 24+
 25+# Guile and Valgrind/ASAN don't play together at all.
 26+exists $FEATURES{sanitize} and return -1;
 27+$valgrind and return -1;
 28+
 29+# Verify simple data type conversions
 30+# Currently we don't support vectors:
 31+#    echo '$(guile (vector 1 2 3))'; \
 32+run_make_test(q!
 33+x:;@echo '$(guile #f)'; \
 34+    echo '$(guile #t)'; \
 35+    echo '$(guile #\c)'; \
 36+    echo '$(guile 1234)'; \
 37+    echo '$(guile 'foo)'; \
 38+    echo '$(guile "bar")'; \
 39+    echo '$(guile (cons 'a 'b))'; \
 40+    echo '$(guile '(a b (c . d) 1 (2) 3))'
 41+!,
 42+              '', "\n#t\nc\n1234\nfoo\nbar\na b\na b c d 1 2 3");
 43+
 44+# Verify guile functions in variables -- SV 43378
 45+run_make_test(q!
 46+res := $(guile #f) \
 47+       $(guile #t) \
 48+       $(guile #\c) \
 49+       $(guile 1234) \
 50+       $(guile 'foo) \
 51+       $(guile "bar") \
 52+       $(guile (cons 'a 'b)) \
 53+       $(guile '(a b (c . d) 1 (2) 3))
 54+x:;@echo '$(res)'
 55+!,
 56+              '', " #t c 1234 foo bar a b a b c d 1 2 3");
 57+
 58+# Verify the gmk-expand function
 59+run_make_test(q!
 60+VAR = $(guile (gmk-expand "$(shell echo hi)"))
 61+x:;@echo '$(VAR)'
 62+!,
 63+              '', "hi");
 64+
 65+# Verify the gmk-eval function
 66+# Prove that the string is expanded only once (by eval)
 67+run_make_test(q!
 68+TEST = bye
 69+EVAL = VAR = $(TEST) $(shell echo there)
 70+$(guile (gmk-eval "$(value EVAL)"))
 71+TEST = hi
 72+x:;@echo '$(VAR)'
 73+!,
 74+              '', "hi there");
 75+
 76+# Verify the gmk-eval function with a list
 77+run_make_test(q!
 78+$(guile (gmk-eval '(VAR = 1 (2) () 3)))
 79+x:;@echo '$(VAR)'
 80+!,
 81+              '', "1 2 3");
 82+
 83+# Verify the gmk-var function
 84+run_make_test(q!
 85+VALUE = hi $(shell echo there)
 86+VAR = $(guile (gmk-var "VALUE"))
 87+x:;@echo '$(VAR)'
 88+!,
 89+              '', "hi there");
 90+
 91+# Verify the gmk-var function with a symbol
 92+run_make_test(q!
 93+VALUE = hi $(shell echo there)
 94+VAR = $(guile (gmk-var 'VALUE))
 95+x:;@echo '$(VAR)'
 96+!,
 97+              '', "hi there");
 98+
 99+# Write a Guile program using define and run it
100+run_make_test(q!
101+# Define the "fib" function in Guile
102+define fib
103+;; A procedure for counting the n:th Fibonacci number
104+;; See SICP, p. 37
105+(define (fib n)
106+  (cond ((= n 0) 0)
107+        ((= n 1) 1)
108+        (else (+ (fib (- n 1))
109+                 (fib (- n 2))))))
110+endef
111+$(guile $(fib))
112+
113+# Now run it
114+x:;@echo $(guile (fib $(FIB)))
115+!,
116+              'FIB=10', "55");
117+
118+1;
+33, -0
 1@@ -0,0 +1,33 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Test the if function.\n";
 4+
 5+$details = "Try various uses of if and ensure they all give the correct
 6+results.\n";
 7+
 8+open(MAKEFILE, "> $makefile");
 9+
10+print MAKEFILE <<EOMAKE;
11+NEQ = \$(subst \$1,,\$2)
12+e =
13+
14+all:
15+\t\@echo 1 \$(if    ,true,false)
16+\t\@echo 2 \$(if ,true,)
17+\t\@echo 3 \$(if ,true)
18+\t\@echo 4 \$(if z,true,false)
19+\t\@echo 5 \$(if z,true,\$(shell echo hi))
20+\t\@echo 6 \$(if ,\$(shell echo hi),false)
21+\t\@echo 7 \$(if \$(call NEQ,a,b),true,false)
22+\t\@echo 8 \$(if \$(call NEQ,a,a),true,false)
23+\t\@echo 9 \$(if z,true,fal,se) hi
24+\t\@echo 10 \$(if ,true,fal,se)there
25+\t\@echo 11 \$(if \$(e) ,true,false)
26+EOMAKE
27+
28+close(MAKEFILE);
29+
30+&run_make_with_options($makefile, "", &get_logfile);
31+$answer = "1 false\n2\n3\n4 true\n5 true\n6 false\n7 true\n8 false\n9 true hi\n10 fal,sethere\n11 false\n";
32+&compare_output($answer, &get_logfile(1));
33+
34+1;
+95, -0
 1@@ -0,0 +1,95 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Test the intcmp function.\n";
 4+
 5+$details = "Try various uses of intcmp and ensure they all give the correct
 6+results.\n";
 7+
 8+run_make_test('# Negative
 9+n = -10
10+# Zero
11+z = 0
12+# Positive
13+p = 888
14+q = 889
15+huge = 8857889956778499040639527525992734031025567913257255490371761260681427
16+.RECIPEPREFIX = >
17+all:
18+> @echo 0_1 $(intcmp $n,$n)
19+> @echo 0_2 $(intcmp $z,$z)
20+> @echo 0_3 $(intcmp -$z,$z)
21+> @echo 0_4 $(intcmp $p,$p)
22+> @echo 0_5 $(intcmp $n,$z)
23+> @echo 0_6 $(intcmp $z,$n)
24+> @echo 1_1 $(intcmp $n,$n,$(shell echo lt))
25+> @echo 1_2 $(intcmp $n,$z,$(shell echo lt))
26+> @echo 1_3 $(intcmp $z,$n,$(shell echo lt))
27+> @echo 2_1 $(intcmp $n,$p,lt,ge)
28+> @echo 2_2 $(intcmp $z,$z,lt,ge)
29+> @echo 2_3 $(intcmp $p,$n,lt,ge)
30+> @echo 3_0 $(intcmp $p,$n,lt,eq,)
31+> @echo 3_1 $(intcmp $z,$p,lt,eq,gt)
32+> @echo 3_2 $(intcmp $p,$z,lt,eq,gt)
33+> @echo 3_3 $(intcmp $p,$p,lt,eq,gt)
34+> @echo 3_4 $(intcmp $p,$q,lt,eq,gt)
35+> @echo 3_5 $(intcmp $q,$p,lt,eq,gt)
36+> @echo 3_6 $(intcmp -$p,-$q,lt,eq,gt)
37+> @echo 3_7 $(intcmp -$q,-$p,lt,eq,gt)
38+> @echo 4_1 $(intcmp -$(huge),$(huge),lt,eq,gt)
39+> @echo 4_2 $(intcmp $(huge),-$(huge),lt,eq,gt)
40+> @echo 4_3 $(intcmp -$(huge),-$(huge),lt,eq,gt)
41+> @echo 4_4 $(intcmp +$(huge),$(huge),lt,eq,gt)
42+', '', '0_1 -10
43+0_2 0
44+0_3 0
45+0_4 888
46+0_5
47+0_6
48+1_1
49+1_2 lt
50+1_3
51+2_1 lt
52+2_2 ge
53+2_3 ge
54+3_0
55+3_1 lt
56+3_2 gt
57+3_3 eq
58+3_4 lt
59+3_5 gt
60+3_6 gt
61+3_7 lt
62+4_1 lt
63+4_2 gt
64+4_3 eq
65+4_4 eq
66+');
67+
68+# Test error conditions
69+
70+run_make_test('
71+intcmp-e1: ; @echo $(intcmp 12a,1,foo)
72+intcmp-e2: ; @echo $(intcmp 0,,foo)
73+intcmp-e3: ; @echo $(intcmp -1,)
74+intcmp-e4: ; @echo $(intcmp ,55)',
75+              'intcmp-e1',
76+              "#MAKEFILE#:2: *** non-numeric first argument to 'intcmp' function: '12a'.  Stop.",
77+              512);
78+
79+run_make_test(undef,
80+              'intcmp-e2',
81+              "#MAKEFILE#:3: *** non-numeric second argument to 'intcmp' function: empty value.  Stop.",
82+              512);
83+
84+run_make_test(undef,
85+              'intcmp-e3',
86+              "#MAKEFILE#:4: *** non-numeric second argument to 'intcmp' function: empty value.  Stop.",
87+              512);
88+
89+run_make_test(undef,
90+              'intcmp-e4',
91+              "#MAKEFILE#:5: *** non-numeric first argument to 'intcmp' function: empty value.  Stop.",
92+              512);
93+
94+
95+# This tells the test driver that the perl test script executed properly.
96+1;
+44, -0
 1@@ -0,0 +1,44 @@
 2+$description = "The following test creates a makefile to test the join "
 3+              ."function.";
 4+
 5+$details = "";
 6+
 7+# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
 8+# THE NAME OF THE MAKEFILE.  THIS INSURES CONSISTENCY AND KEEPS TRACK OF
 9+# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
10+# EXAMPLE: $makefile2 = &get_tmpfile;
11+
12+
13+open(MAKEFILE,"> $makefile");
14+
15+# The Contents of the MAKEFILE ...
16+
17+print MAKEFILE "string := \$(join a b c,foo      hacks .pl1) \n"
18+              ."all: \n"
19+              ."\t\@echo \$(string) \n";
20+
21+# END of Contents of MAKEFILE
22+
23+close(MAKEFILE);
24+
25+&run_make_with_options($makefile,"",&get_logfile,0);
26+
27+# Create the answer to what should be produced by this Makefile
28+$answer = "afoo bhacks c.pl1\n";
29+
30+# COMPARE RESULTS
31+
32+# In this call to compare output, you should use the call &get_logfile(1)
33+# to send the name of the last logfile created.  You may also use
34+# the special call &get_logfile(1) which returns the same as &get_logfile(1).
35+
36+&compare_output($answer,&get_logfile(1));
37+
38+# This tells the test driver that the perl test script executed properly.
39+1;
40+
41+
42+
43+
44+
45+
+112, -0
  1@@ -0,0 +1,112 @@
  2+#                                                                    -*-perl-*-
  3+# $Id$
  4+
  5+$description = "Test the let function.";
  6+
  7+$details = "This is a test of the let function in gnu make.
  8+This function destructures a list of values and binds each
  9+value to a variable name in a list of variable names.
 10+Superfluous variable names are assigned the empty string and
 11+the remaining values are assigned to the last variable name.
 12+The binding holds for the duration of the evaluation of the
 13+given text and no longer.  The general form of the command
 14+is $(let \$vars,\$list,\$text).  Several types of let
 15+assignments are tested\n";
 16+
 17+# check for mismatched var and list word counts
 18+run_make_test(q!
 19+a = bad
 20+b = news
 21+x = $(let a b,1 2,$a $b)
 22+y = $(let a,1 2,$a)
 23+z = $(let a b,1,$a $b)
 24+all:;@echo 'a=,$a,' 'b=,$b,' 'x=,$x,' 'y=,$y,' 'z=,$z,'
 25+!,
 26+    '', "a=,bad, b=,news, x=,1 2, y=,1 2, z=,1 ,\n");
 27+
 28+# check for whitespace
 29+run_make_test(q!
 30+a = bad
 31+b = news
 32+x = $(let a b,   1   2   ,+$a+$b+)
 33+y = $(let a,   1  2   ,+$a+)
 34+z = $(let a b,  1   ,+$a+$b+)
 35+all:;@echo 'a=,$a,' 'b=,$b,' 'x=,$x,' 'y=,$y,' 'z=,$z,'
 36+!,
 37+    '', "a=,bad, b=,news, x=,+1+2   +, y=,+1  2   +, z=,+1++,\n");
 38+
 39+# Allow empty variable names and empty value list.
 40+# We still expand the list and body.
 41+run_make_test('
 42+null =
 43+v = $(let    ,$(info blankvar),abc)
 44+x = $(let $(null),$(info side-effect),abc)
 45+y = $(let y,,$ydef)
 46+z = $(let a b, ,+$a+$b+)
 47+
 48+all: ; @echo $v/$x/$y/$z',
 49+              '', "blankvar\nside-effect\nabc/abc/def/+++\n");
 50+
 51+# The example macro from the manual.
 52+run_make_test('
 53+reverse = $(let first rest,$1,$(if $(rest),$(call reverse,$(rest)) )$(first))
 54+
 55+all: ; @echo $(call reverse, \
 56+                 moe   miny  meeny eeny \
 57+              )',
 58+              '', "eeny meeny miny moe\n");
 59+
 60+
 61+# Set an environment variable that we can test in the makefile.
 62+$ENV{FOOFOO} = 'foo foo';
 63+
 64+# Verify masking: expansion outside the scope of let is unaffected.
 65+run_make_test('
 66+auto_var = \
 67+  udef \
 68+  CC \
 69+  FOOFOO \
 70+  MAKE \
 71+  foo \
 72+  CFLAGS \
 73+  WHITE \
 74+  @ \
 75+  <
 76+av = $(foreach var, $(auto_var), $(origin $(var)) )
 77+foo = bletch null @ garf
 78+override WHITE := BLACK
 79+
 80+define mktarget
 81+target: foo := $(foo)
 82+target: ; @echo $(AR)_$(foo)_
 83+endef
 84+
 85+all: auto target
 86+auto: ; @echo $(let $(auto_var),,$(av)) $(av)
 87+$(let AR foo,bar foo ,$(eval $(value mktarget)))',
 88+              '-e WHITE=WHITE CFLAGS=',
 89+              "automatic automatic automatic automatic automatic automatic automatic automatic automatic undefined default environment override default file command line override automatic automatic
 90+ar_foo _
 91+");
 92+
 93+
 94+# Check some error conditions.
 95+run_make_test('
 96+x = $(let )
 97+y = $x
 98+
 99+all: ; @echo $y',
100+              '',
101+              "#MAKEFILE#:2: *** insufficient number of arguments (1) to function 'let'.  Stop.",
102+              512);
103+
104+run_make_test('
105+x = $(let x,y)
106+y := $x
107+
108+all: ; @echo $y',
109+              '',
110+              "#MAKEFILE#:2: *** insufficient number of arguments (2) to function 'let'.  Stop.",
111+              512);
112+
113+1;
+44, -0
 1@@ -0,0 +1,44 @@
 2+$description = "The following test creates a makefile to test the notdir "
 3+              ."function.";
 4+
 5+$details = "";
 6+
 7+# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
 8+# THE NAME OF THE MAKEFILE.  THIS INSURES CONSISTENCY AND KEEPS TRACK OF
 9+# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
10+# EXAMPLE: $makefile2 = &get_tmpfile;
11+
12+
13+open(MAKEFILE,"> $makefile");
14+
15+# The Contents of the MAKEFILE ...
16+
17+print MAKEFILE "string := \$(notdir ${pathsep}src${pathsep}foo.c hacks) \n"
18+              ."all: \n"
19+              ."\t\@echo \$(string) \n";
20+
21+# END of Contents of MAKEFILE
22+
23+close(MAKEFILE);
24+
25+&run_make_with_options($makefile,"",&get_logfile,0);
26+
27+# Create the answer to what should be produced by this Makefile
28+$answer = "foo.c hacks\n";
29+
30+# COMPARE RESULTS
31+
32+# In this call to compare output, you should use the call &get_logfile(1)
33+# to send the name of the last logfile created.  You may also use
34+# the special call &get_logfile(1) which returns the same as &get_logfile(1).
35+
36+&compare_output($answer,&get_logfile(1));
37+
38+# This tells the test driver that the perl test script executed properly.
39+1;
40+
41+
42+
43+
44+
45+
+49, -0
 1@@ -0,0 +1,49 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the origin function.";
 5+
 6+$details = "This is a test of the origin function in gnu make.
 7+This function will report on where a variable was
 8+defined per the following list:
 9+
10+'undefined'            never defined
11+'default'              default definition
12+'environment'          environment var without -e
13+'environment override' environment var with    -e
14+'file'                 defined in makefile
15+'command line'         defined on the command line
16+'override'             defined by override in makefile
17+'automatic'            Automatic variable\n";
18+
19+# Set an environment variable
20+$ENV{MAKETEST} = 1;
21+
22+run_make_test('
23+foo := bletch garf
24+auto_var = undefined CC MAKETEST MAKE foo CFLAGS WHITE @
25+av = $(foreach var, $(auto_var), $(origin $(var)) )
26+override WHITE := BLACK
27+.RECIPEPREFIX = >
28+all: auto
29+> @echo $(origin undefined)
30+> @echo $(origin CC)
31+> @echo $(origin MAKETEST)
32+> @echo $(origin MAKE)
33+> @echo $(origin foo)
34+> @echo $(origin CFLAGS)
35+> @echo $(origin WHITE)
36+> @echo $(origin @)
37+auto :
38+> @echo $(av)',
39+    '-e WHITE=WHITE CFLAGS=',
40+    'undefined default environment override default file command line override automatic
41+undefined
42+default
43+environment override
44+default
45+file
46+command line
47+override
48+automatic');
49+
50+1;
+92, -0
 1@@ -0,0 +1,92 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Test the realpath functions.";
 4+
 5+$details = "";
 6+
 7+# Check the local directory's realpath
 8+run_make_test('
 9+ifneq ($(realpath .),$(CURDIR))
10+  $(warning $(realpath .) != $(CURDIR))
11+endif
12+
13+ifneq ($(realpath ./),$(CURDIR))
14+  $(warning $(realpath ./) != $(CURDIR))
15+endif
16+
17+ifneq ($(realpath .///),$(CURDIR))
18+  $(warning $(realpath .///) != $(CURDIR))
19+endif
20+
21+.PHONY: all
22+all: ; @:
23+',
24+              '', '');
25+
26+# Find the realpath to the root of the partition
27+create_file('root.mk', 'all:;$(info $(realpath /))');
28+my $root = `"$make_path" -sf root.mk`;
29+unlink('root.mk');
30+$root =~ s/\r?\n//g;
31+
32+my $tst = '
33+ifneq ($(realpath /.),#ROOT#)
34+  $(warning $(realpath /.) != #ROOT#)
35+endif
36+
37+ifneq ($(realpath /./),#ROOT#)
38+  $(warning $(realpath /./) != #ROOT#)
39+endif
40+
41+ifneq ($(realpath /.///),#ROOT#)
42+  $(warning $(realpath /.///) != #ROOT#)
43+endif
44+
45+ifneq ($(realpath /..),#ROOT#)
46+  $(warning $(realpath /..) != #ROOT#)
47+endif
48+
49+ifneq ($(realpath /../),#ROOT#)
50+  $(warning $(realpath /../) != #ROOT#)
51+endif
52+
53+ifneq ($(realpath /..///),#ROOT#)
54+  $(warning $(realpath /..///) != #ROOT#)
55+endif
56+
57+ifneq ($(realpath . /..),$(CURDIR) #ROOT#)
58+  $(warning $(realpath . /..) != $(CURDIR) #ROOT#)
59+endif
60+
61+.PHONY: all
62+all: ; @:
63+';
64+$tst =~ s/#ROOT#/$root/g;
65+run_make_test($tst, '', '');
66+
67+# On Windows platforms "//" means something special.  So, don't do these tests
68+# there.
69+
70+if ($port_type ne 'W32') {
71+  $tst = '
72+ifneq ($(realpath ///),#ROOT#)
73+  $(warning $(realpath ///) != #ROOT#)
74+endif
75+
76+ifneq ($(realpath ///.),#ROOT#)
77+  $(warning $(realpath ///.) != #ROOT#)
78+endif
79+
80+ifneq ($(realpath ///..),#ROOT#)
81+  $(warning $(realpath ///..) != #ROOT#)
82+endif
83+
84+.PHONY: all
85+all: ; @:';
86+  $tst =~ s/#ROOT#/$root/g;
87+
88+  run_make_test($tst, '', '');
89+}
90+
91+
92+# This tells the test driver that the perl test script executed properly.
93+1;
+230, -0
  1@@ -0,0 +1,230 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = 'Test the $(shell ...) function.';
  5+
  6+$details = '';
  7+
  8+# Test standard shell
  9+run_make_test('.PHONY: all
 10+OUT := $(shell echo hi)
 11+all: ; @echo $(OUT)
 12+              ','','hi');
 13+
 14+# Test shells inside rules.
 15+run_make_test('.PHONY: all
 16+all: ; @echo $(shell echo hi)
 17+              ','','hi');
 18+
 19+# Verify .SHELLSTATUS
 20+run_make_test('.PHONY: all
 21+PRE := $(.SHELLSTATUS)
 22+$(shell exit 0)
 23+OK := $(.SHELLSTATUS)
 24+$(shell exit 1)
 25+BAD := $(.SHELLSTATUS)
 26+all: ; @echo PRE=$(PRE) OK=$(OK) BAD=$(BAD)
 27+              ','','PRE= OK=0 BAD=1');
 28+
 29+# Test unescaped comment characters in shells.  Savannah bug #20513
 30+run_make_test(q!
 31+FOO := $(shell echo '#')
 32+foo: ; echo '$(FOO)'
 33+!,
 34+              '', "echo '#'\n#\n");
 35+
 36+# Test that exported variables are passed to $(shell ...)
 37+$ENV{FOO} = 'baz';
 38+run_make_test(q!
 39+OUT = $(shell echo $$FOO)
 40+foo: ; @echo '$(OUT)'
 41+!,
 42+              '', 'baz');
 43+
 44+$ENV{FOO} = 'baz';
 45+run_make_test(q!
 46+FOO = bar
 47+OUT = $(shell echo $$FOO)
 48+foo: ; @echo '$(OUT)'
 49+!,
 50+              '', 'bar');
 51+
 52+run_make_test(q!
 53+export FOO = bar
 54+OUT = $(shell echo $$FOO)
 55+foo: ; @echo '$(OUT)'
 56+!,
 57+              '', 'bar');
 58+
 59+# Test shells inside exported environment variables, simply expanded.
 60+run_make_test('
 61+export HI := $(shell echo hi)
 62+.PHONY: all
 63+all: ; @echo $$HI
 64+',
 65+              '','hi');
 66+
 67+# Test shells inside exported environment variables.  See SV 10593
 68+run_make_test('
 69+export HI = $(shell echo hi)
 70+.PHONY: all
 71+all: ; @echo $$HI
 72+',
 73+              '',"hi");
 74+
 75+$ENV{HI} = 'foo';
 76+run_make_test('
 77+HI = $(shell echo hi)
 78+.PHONY: all
 79+all: ; @echo $$HI
 80+',
 81+              '',"hi");
 82+
 83+$ENV{HI} = 'foo';
 84+run_make_test('
 85+HI = $(shell echo hi)
 86+bad := $(HI)
 87+.PHONY: all
 88+all: ; @echo $$HI $(bad)
 89+',
 90+              '',"hi hi");
 91+
 92+# SV 63016: Exported variable that contains a variable containing $(shell...)
 93+
 94+run_make_test('
 95+HI = $(shell echo hi)
 96+export bad = $(HI)
 97+.PHONY: all
 98+all:; : $(HI)
 99+',
100+              '',": hi");
101+
102+$ENV{HI} = 'outer';
103+run_make_test('
104+export HI = $(shell echo $$HI)
105+.PHONY: all
106+all:; @echo $$HI
107+',
108+              '',"outer");
109+
110+$ENV{HI} = 'outer';
111+run_make_test('
112+export HI = $(shell echo $$HI)
113+.PHONY: all
114+all:; : $(HI)
115+',
116+              '',": outer");
117+
118+if ($port_type ne 'W32') {
119+    # Test shell errors in recipes including offset
120+    # This needs to be ported to Windows, or else Windows error messages
121+    # need to converted to look like more normal make errors.
122+    run_make_test('
123+.RECIPEPREFIX = >
124+all:
125+>@echo hi
126+>$(shell ./basdfdfsed there)
127+>@echo $(.SHELLSTATUS)
128+',
129+                  '', "#MAKE#: ./basdfdfsed: $ERR_no_such_file\nhi\n127\n");
130+
131+    run_make_test('
132+$(shell ./basdfdfsed where)
133+all: ; @echo $(.SHELLSTATUS)
134+',
135+                  '', "#MAKE#: ./basdfdfsed: $ERR_no_such_file\n127\n");
136+
137+    # Test SHELLSTATUS for kill.
138+    # This test could be ported to Windows, using taskkill ... ?
139+
140+    # Figure out the exit code for SIGINT
141+    my $pid = fork();
142+    if (! $pid) {
143+        exec('kill -2 $$') or die "exec: Cannot execute sleep\n";
144+    }
145+    waitpid($pid, 0);
146+    # .SHELLSTATUS for a signal gives 128 + the signal number
147+    my $ret = $?;
148+    if ($ret > 255) {
149+       # Solaris 10 perl 5.8.4 puts signal number + 128 into the high 8 bits.
150+       $ret >>= 8;
151+    }
152+    if ($osname ne 'os390') {
153+      $ret |= 128;
154+    }
155+
156+    run_make_test('.PHONY: all
157+$(shell kill -2 $$$$)
158+STAT := $(.SHELLSTATUS)
159+all: ; @echo STAT=$(STAT)
160+              ','',"STAT=$ret\n");
161+
162+    # Test that not-found errors can be redirected
163+    if ($ERR_command_not_found) {
164+        $_ = $ERR_command_not_found;
165+        s/#CMDNAME#/bad-command/g;
166+        run_make_test(q!
167+out := $(shell bad-command 2>&1)
168+all: ; @echo '$(.SHELLSTATUS): $(out)'
169+!,
170+                      '', "127: $_\n");
171+    }
172+
173+    # If we're using pipes for jobserver, then we will close them and not
174+    # allow them to be available to sub-makes invoked via $(shell ...)
175+    if (exists $FEATURES{'jobserver'}) {
176+        run_make_test(q!
177+ifeq ($(ELT),)
178+default:; @$(MAKE) -f #MAKEFILE# ELT=1
179+else ifeq ($(ELT),1)
180+OUTPUT := $(shell $(MAKE) -f #MAKEFILE# ELT=2)
181+$(info $(OUTPUT))
182+default:;: $(ELT)
183+else
184+default:;: $(ELT)
185+endif
186+!,
187+                      '--no-print-directory -j2 --jobserver-style=pipe', "#MAKE#[2]: warning: jobserver unavailable: using -j1 (add '+' to parent make rule)\n: 2\n: 1");
188+    }
189+
190+    # This crashes if we use vfork and don't reset environ properly
191+    run_make_test(q!
192+export PATH = $(shell echo "tests:$$PATH")
193+foo = $(shell echo yes)
194+
195+all:;echo $(foo)
196+!,
197+                  '', "echo yes\nyes\n");
198+}
199+
200+# If we're not using pipes for jobserver, then they are available in sub-makes
201+# invoked by $(shell ...)
202+if ($port_type eq 'W32' || exists $FEATURES{'jobserver-fifo'}) {
203+    run_make_test(q!
204+ifeq ($(ELT),)
205+default:; @$(MAKE) -f #MAKEFILE# ELT=1
206+else ifeq ($(ELT),1)
207+OUTPUT := $(shell $(MAKE) -f #MAKEFILE# ELT=2)
208+$(info $(OUTPUT))
209+default:;: $(ELT)
210+else
211+default:;: $(ELT)
212+endif
213+!,
214+                  '--no-print-directory -j2', ": 2\n: 1");
215+}
216+
217+# sv 65323. Check for bash, because such long variable name causes ksh to
218+# segfault.
219+if (-x '/bin/bash') {
220+    # sv 65172.
221+    # Buffer overrun in recursively_expand_for_file on a variable with a long
222+    # name.
223+    my $v = "a1234567890" x 4 x 1000;
224+    run_make_test("
225+SHELL:=/bin/bash
226+export $v=\$(shell echo hello)
227+all:; \@echo \$\$$v
228+", '', "hello\n");
229+}
230+
231+1;
+47, -0
 1@@ -0,0 +1,47 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "The following test creates a makefile to verify
 5+the ability of make to sort lists of object. Sort
 6+will also remove any duplicate entries. This will also
 7+be tested.";
 8+
 9+$details = "The make file is built with a list of object in a random order
10+and includes some duplicates. Make should sort all of the elements
11+remove all duplicates\n";
12+
13+run_make_test('
14+foo := moon_light days
15+foo1:= jazz
16+bar := captured#SPACE#
17+bar2 = boy end, has rise A midnight#SPACE#
18+bar3:= $(foo)
19+s1  := _by
20+s2  := _and_a
21+t1  := $(addsuffix $(s1), $(bar) )
22+t2  := $(addsuffix $(s2), $(foo1) )
23+t3  := $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2)#SPACE#
24+t4  := $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3)#SPACE#
25+t5  := $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4)#SPACE#
26+t6  := $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5)#SPACE#
27+t7  := $(t6) $(t6) $(t6)#SPACE#
28+p1  := $(addprefix $(foo1), $(s2) )
29+blank:=#SPACE#
30+all:
31+#TAB#@echo $(sort $(bar2) $(foo)  $(addsuffix $(s1), $(bar) ) $(t2) $(bar2) $(bar3))
32+#TAB#@echo $(sort $(blank) $(foo) $(bar2) $(t1) $(p1) )
33+#TAB#@echo $(sort $(foo) $(bar2) $(t1) $(t4) $(t5) $(t7) $(t6) )
34+',
35+              '', 'A boy captured_by days end, has jazz_and_a midnight moon_light rise
36+A boy captured_by days end, has jazz_and_a midnight moon_light rise
37+A boy captured_by days end, has jazz_and_a midnight moon_light rise
38+');
39+
40+
41+# Test with non-space/tab whitespace.  Note that you can't see the
42+# original bug except using valgrind.
43+
44+run_make_test("FOO = a b\tc\rd\fe \f \f \f \f \ff
45+all: ; \@echo \$(words \$(sort \$(FOO)))\n",
46+              '', "6\n");
47+
48+1;
+43, -0
 1@@ -0,0 +1,43 @@
 2+#                                                                    -*-perl-*-
 3+$description = "The following test creates a makefile to verify
 4+the ability of make to strip white space from lists of object.\n";
 5+
 6+
 7+$details = "The make file is built with a list of objects that contain white space
 8+These are then run through the strip command to remove it. This is then
 9+verified by echoing the result.\n";
10+
11+# Zippy the Pinhead quotes...
12+run_make_test(q!TEST1 := "Is this TERMINAL fun?                                                               What makes you believe is this terminal fun?                                                                                                                                               JAPAN is a WONDERFUL planet -- I wonder if we will ever reach                                         their level of COMPARATIVE SHOPPING..."
13+E :=
14+TEST2 := $E   try this     and#TAB##TAB#this     #TAB#$E
15+
16+define TEST3
17+
18+and these#TAB#        test out
19+
20+
21+some
22+blank lines
23+
24+
25+
26+endef
27+
28+.PHONY: all
29+all:
30+#TAB#@echo '$(strip  $(TEST1) )'
31+#TAB#@echo '$(strip  $(TEST2) )'
32+#TAB#@echo '$(strip  $(TEST3) )'
33+!,
34+              "", "\"Is this TERMINAL fun? What makes you believe is this terminal fun? JAPAN is a WONDERFUL planet -- I wonder if we will ever reach their level of COMPARATIVE SHOPPING...\"
35+try this and this
36+and these test out some blank lines
37+");
38+
39+run_make_test(q!
40+space: ; @echo '$(strip ) $(strip  #TAB#   )'
41+!,
42+              "", " \n");
43+
44+1;
+38, -0
 1@@ -0,0 +1,38 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the subst and patsubst functions";
 5+
 6+$details = "";
 7+
 8+# Generic patsubst test: test both the function and variable form.
 9+
10+run_make_test('
11+foo := a.o b.o c.o
12+bar := $(foo:.o=.c)
13+bar2:= $(foo:%.o=%.c)
14+bar3:= $(patsubst %.c,%.o,x.c.c bar.c)
15+all:;@echo $(bar); echo $(bar2); echo $(bar3)',
16+'',
17+'a.c b.c c.c
18+a.c b.c c.c
19+x.c.o bar.o');
20+
21+# Patsubst without '%'--shouldn't match because the whole word has to match
22+# in patsubst.  Based on a bug report by Markus Mauhart <qwe123@chello.at>
23+
24+run_make_test('all:;@echo $(patsubst Foo,Repl,FooFoo)', '', 'FooFoo');
25+
26+# Variable subst where a pattern matches multiple times in a single word.
27+# Based on a bug report by Markus Mauhart <qwe123@chello.at>
28+
29+run_make_test('
30+A := fooBARfooBARfoo
31+all:;@echo $(A:fooBARfoo=REPL)', '', 'fooBARREPL');
32+
33+1;
34+
35+
36+
37+
38+
39+
+57, -0
 1@@ -0,0 +1,57 @@
 2+$description = "The following test creates a makefile to test the suffix\n"
 3+              ."function. \n";
 4+
 5+$details = "The suffix function will return the string following the last _._\n"
 6+          ."the list provided. It will provide all of the unique suffixes found\n"
 7+          ."in the list. The long strings are sorted to remove duplicates.\n";
 8+
 9+# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
10+# THE NAME OF THE MAKEFILE.  THIS INSURES CONSISTENCY AND KEEPS TRACK OF
11+# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
12+# EXAMPLE: $makefile2 = &get_tmpfile;
13+
14+
15+open(MAKEFILE,"> $makefile");
16+
17+# The Contents of the MAKEFILE ...
18+
19+print 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"
20+              ."string2 := \$(string) \$(string) \$(string) \$(string) \$(string) \$(string) \$(string)\n"
21+              ."string3 := \$(string2) \$(string2) \$(string2) \$(string2) \$(string2) \$(string2) \$(string2)\n"
22+              ."string4 := \$(string3) \$(string3) \$(string3) \$(string3) \$(string3) \$(string3) \$(string3)\n"
23+              ."all: \n"
24+              ."\t\@echo \$(suffix \$(string)) \n"
25+              ."\t\@echo \$(sort \$(suffix \$(string4))) \n"
26+              ."\t\@echo \$(suffix \$(string) a.out) \n"
27+              ."\t\@echo \$(sort \$(suffix \$(string3))) \n";
28+
29+
30+
31+# END of Contents of MAKEFILE
32+
33+close(MAKEFILE);
34+
35+&run_make_with_options($makefile,"",&get_logfile,0);
36+
37+# Create the answer to what should be produced by this Makefile
38+
39+# COMPARE RESULTS
40+$answer = ".pl .pl1 .pl .pl3 .perl .c .c\n"
41+         .".c .perl .pl .pl1 .pl3\n"
42+         .".pl .pl1 .pl .pl3 .perl .c .c .out\n"
43+         .".c .perl .pl .pl1 .pl3\n";
44+
45+# In this call to compare output, you should use the call &get_logfile(1)
46+# to send the name of the last logfile created.  You may also use
47+# the special call &get_logfile(1) which returns the same as &get_logfile(1).
48+
49+&compare_output($answer,&get_logfile(1));
50+
51+# This tells the test driver that the perl test script executed properly.
52+1;
53+
54+
55+
56+
57+
58+
+30, -0
 1@@ -0,0 +1,30 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the value function.";
 5+
 6+$details = "This is a test of the value function in GNU Make.
 7+This function will evaluate to the value of the named variable with no
 8+further expansion performed on it.\n";
 9+
10+open(MAKEFILE,"> $makefile");
11+
12+print MAKEFILE <<'EOF';
13+export FOO = foo
14+
15+recurse = FOO = $FOO
16+static := FOO = $(value FOO)
17+
18+all: ; @echo $(recurse) $(value recurse) $(static) $(value static)
19+EOF
20+
21+close(MAKEFILE);
22+
23+&run_make_with_options($makefile, "", &get_logfile);
24+
25+# Create the answer to what should be produced by this Makefile
26+$answer = "FOO = OO FOO = foo FOO = foo FOO = foo\n";
27+
28+
29+&compare_output($answer,&get_logfile(1));
30+
31+1;
+59, -0
 1@@ -0,0 +1,59 @@
 2+#                                                                    -*-Perl-*-
 3+
 4+$description = "\
 5+The following test creates a makefile to test the warning function.";
 6+
 7+$details = "";
 8+
 9+run_make_test(q!ifdef WARNING1
10+$(warning warning is $(WARNING1))
11+endif
12+
13+ifdef WARNING2
14+$(warning warning is $(WARNING2))
15+endif
16+
17+ifdef WARNING3
18+all: some; @echo hi $(warning warning is $(WARNING3))
19+endif
20+
21+ifdef WARNING4
22+all: some; @echo hi
23+#TAB#@echo there $(warning warning is $(WARNING4))
24+endif
25+
26+some: ; @echo Some stuff
27+!,
28+              "WARNING1=yes", "#MAKEFILE#:2: warning is yes\nSome stuff\n");
29+
30+run_make_test(undef, "WARNING2=no",
31+              "#MAKEFILE#:6: warning is no\nSome stuff\n");
32+
33+run_make_test(undef, "WARNING3=maybe",
34+              "Some stuff\n#MAKEFILE#:10: warning is maybe\nhi\n");
35+
36+run_make_test(undef, "WARNING4=definitely",
37+              "Some stuff\n#MAKEFILE#:15: warning is definitely\nhi\nthere\n");
38+
39+# Test linenumber offset
40+
41+run_make_test(q!
42+all: one two
43+#TAB#$(warning in $@ line 3)
44+#TAB#@true
45+#TAB#$(warning in $@ line 5)
46+
47+one two:
48+#TAB#$(warning in $@ line 8)
49+#TAB#@true
50+#TAB#$(warning in $@ line 10)
51+!,
52+              '', "#MAKEFILE#:8: in one line 8
53+#MAKEFILE#:10: in one line 10
54+#MAKEFILE#:8: in two line 8
55+#MAKEFILE#:10: in two line 10
56+#MAKEFILE#:3: in all line 3
57+#MAKEFILE#:5: in all line 5\n");
58+
59+# This tells the test driver that the perl test script executed properly.
60+1;
+164, -0
  1@@ -0,0 +1,164 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "The following test creates a makefile to test wildcard
  5+expansions and the ability to put a command on the same
  6+line as the target name separated by a semi-colon.";
  7+
  8+$details = "\
  9+This test creates 4 files by the names of 1.example,
 10+two.example and 3.example.  We execute three tests.  The first
 11+executes the print1 target which tests the '*' wildcard by
 12+echoing all filenames by the name of '*.example'.  The second
 13+test echo's all files which match '?.example' and
 14+[a-z0-9].example.  Lastly we clean up all of the files using
 15+the '*' wildcard as in the first test";
 16+
 17+touch("example.1");
 18+touch("example.two");
 19+touch("example.3");
 20+touch("example.for");
 21+touch("example._");
 22+
 23+# TEST #1
 24+# -------
 25+
 26+run_make_test(qq/
 27+.PHONY: print1 print2 clean
 28+print1: ;\@echo \$(wildcard example.*)
 29+print2:
 30+\t\@echo \$(wildcard example.?)
 31+\t\@echo \$(wildcard example.[a-z0-9])
 32+\t\@echo \$(wildcard example.[!A-Za-z_\\!])
 33+clean:
 34+\t$CMD_rmfile \$(wildcard example.*)
 35+/,
 36+              'print1', "example.1 example.3 example._ example.for example.two\n");
 37+
 38+# TEST #2
 39+# -------
 40+
 41+run_make_test(undef, 'print2', "example.1 example.3 example._\n"
 42+                               ."example.1 example.3\n"
 43+                               ."example.1 example.3\n");
 44+
 45+# TEST #3
 46+# -------
 47+
 48+$answer = "$CMD_rmfile example.1 example.3 example._ example.for example.two";
 49+if ($vos)
 50+{
 51+   $answer .= " \n";
 52+}
 53+else
 54+{
 55+   $answer .= "\n";
 56+}
 57+
 58+run_make_test(undef, 'clean', $answer);
 59+
 60+# TEST #4: Verify that failed wildcards don't return the pattern
 61+
 62+run_make_test(q!
 63+all: ; @echo $(wildcard xz--y*.7)
 64+!,
 65+              '', "\n");
 66+
 67+# TEST #5: wildcard used to verify file existence
 68+
 69+touch('xxx.yyy');
 70+
 71+run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!, '', "file=xxx.yyy\n");
 72+
 73+unlink('xxx.yyy');
 74+
 75+run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!, '', "file=\n");
 76+
 77+# TEST #7: verify that when the input pattern has a trailing slash wildcard
 78+# returns only directories.
 79+#
 80+# Currently this doesn't work with our embedded GLOB so disable it.
 81+# -------
 82+
 83+if (get_config('USE_SYSTEM_GLOB') eq 'yes') {
 84+  touch("hellof");
 85+  mkdir("hellod", 0770);
 86+  mkdir("hellod/worldd", 0770);
 87+  touch("hellod/worldf");
 88+  mkdir("hellod/worldd/kend1", 0770);
 89+  mkdir("hellod/worldd/kend2", 0770);
 90+  touch("hellod/worldd/kenf1");
 91+  touch("hellod/worldd/kenf2");
 92+
 93+  run_make_test(qq!
 94+print3:
 95+\t\@echo \$(wildcard hello*)
 96+\t\@echo \$(wildcard hello*/)
 97+\t\@echo \$(wildcard hellod/world*)
 98+\t\@echo \$(wildcard hellod/world*/)
 99+\t\@echo \$(wildcard hello* hellod/world*)
100+\t\@echo \$(wildcard hello*/ hellod/world*/)
101+\t\@echo \$(wildcard hellod/*)
102+\t\@echo \$(wildcard hellod/*/)
103+\t\@echo \$(wildcard */world*)
104+\t\@echo \$(wildcard */worldd/)
105+\t\@echo \$(wildcard hellod/*/ken*/)
106+\t\@echo \$(wildcard hellod/*/ken?[12])
107+\t\@echo \$(wildcard hellod/*/ken?[12]/)
108+!, '',
109+                "hellod hellof\n"
110+                ."hellod/\n"
111+                ."hellod/worldd hellod/worldf\n"
112+                ."hellod/worldd/\n"
113+                ."hellod hellof hellod/worldd hellod/worldf\n"
114+                ."hellod/ hellod/worldd/\n"
115+                ."hellod/worldd hellod/worldf\n"
116+                ."hellod/worldd/\n"
117+                ."hellod/worldd hellod/worldf\n"
118+                ."hellod/worldd/\n"
119+                ."hellod/worldd/kend1/ hellod/worldd/kend2/\n"
120+                ."hellod/worldd/kend1 hellod/worldd/kend2 "
121+                ."hellod/worldd/kenf1 hellod/worldd/kenf2\n"
122+                ."hellod/worldd/kend1/ hellod/worldd/kend2/\n");
123+
124+  unlink('hellof', 'hellod/worldf', 'hellod/worldd/kenf1',
125+         'hellod/worldd/kenf2');
126+  foreach $d ('hellod/worldd/kend1', 'hellod/worldd/kend2', 'hellod/worldd',
127+              'hellod') {
128+    rmdir($d);
129+  }
130+}
131+
132+if ($port_type ne 'W32') {
133+  # Check wildcard on the root directory
134+  run_make_test('print4: ; @echo $(wildcard /)', '', "/\n");
135+}
136+
137+if ($port_type ne 'W32' && eval { symlink("",""); 1 }) {
138+
139+  # TEST #6: check for wildcards matching directories
140+  # See SV 53465
141+
142+  my $dir = '__rdir';
143+  my $lnk = '__ldir';
144+  mkdir($dir, 0777);
145+  symlink($dir, $lnk);
146+
147+  run_make_test(qq!all: ; \@echo \$(wildcard $lnk*/.)!, '', "$lnk/.");
148+
149+  unlink($lnk);
150+  rmdir($dir);
151+
152+  # Test for dangling symlinks
153+  # This doesn't work with the built-in glob... needs to be updated!
154+  # It also for some obscure reason, will break if we use ASAN!!
155+
156+  if (get_config('USE_SYSTEM_GLOB') eq 'yes' && !exists($FEATURES{sanitize})) {
157+    symlink($dir, $lnk);
158+
159+    run_make_test(qq!all: ; \@echo \$(wildcard $lnk)!, '', "$lnk");
160+
161+    unlink($lnk);
162+  }
163+}
164+
165+1;
+175, -0
  1@@ -0,0 +1,175 @@
  2+#                                                                    -*-perl-*-
  3+$description = "\
  4+Test the word, words, wordlist, firstword, and lastword functions.\n";
  5+
  6+$details = "\
  7+Produce a variable with a large number of words in it,
  8+determine the number of words, and then read each one back.\n";
  9+
 10+run_make_test('
 11+string  := word.pl general_test2.pl   FORCE.pl word.pl generic_test.perl MAKEFILES_variable.pl
 12+string2 := $(string) $(string) $(string) $(string) $(string) $(string) $(string)
 13+string3 := $(string2) $(string2) $(string2) $(string2) $(string2) $(string2) $(string2)
 14+string4 := $(string3) $(string3) $(string3) $(string3) $(string3) $(string3) $(string3)
 15+.RECIPEPREFIX = >
 16+all:
 17+> @echo $(words $(string))
 18+> @echo $(words $(string4))
 19+> @echo $(word 1, $(string))
 20+> @echo $(word 100, $(string))
 21+> @echo $(word 1  , $(string))
 22+> @echo $(word 1000, $(string3))
 23+> @echo $(word 9223372036854775807, $(string2))
 24+> @echo $(wordlist 3, 4, $(string))
 25+> @echo $(wordlist 4, 3, $(string))
 26+> @echo $(wordlist 1 , 6  , $(string))
 27+> @echo $(wordlist 5,7, $(string))
 28+> @echo $(wordlist 100, 110, $(string))
 29+> @echo $(wordlist 7, 10, $(string2))
 30+> @echo $(wordlist 9223372036854775807, 0, $(string2))
 31+', '', "6\n"
 32+      ."2058\n"
 33+      ."word.pl\n"
 34+      ."\n"
 35+      ."word.pl\n"
 36+      ."\n"
 37+      ."\n"
 38+      ."FORCE.pl word.pl\n"
 39+      ."\n"
 40+      ."word.pl general_test2.pl FORCE.pl word.pl generic_test.perl MAKEFILES_variable.pl\n"
 41+      ."generic_test.perl MAKEFILES_variable.pl\n"
 42+      ."\n"
 43+      ."word.pl general_test2.pl FORCE.pl word.pl\n"
 44+      ."\n"
 45+);
 46+
 47+# Test error conditions
 48+
 49+run_make_test('FOO = foo bar biz baz
 50+
 51+word-e1: ; @echo $(word ,$(FOO))
 52+word-e2: ; @echo $(word abc ,$(FOO))
 53+word-e3: ; @echo $(word 1a,$(FOO))
 54+word-e4: ; @echo $(word 9999999999999999999,$(FOO))
 55+
 56+wordlist-e1: ; @echo $(wordlist ,,$(FOO))
 57+wordlist-e2: ; @echo $(wordlist abc ,,$(FOO))
 58+wordlist-e3: ; @echo $(wordlist 1, 12a ,$(FOO))',
 59+              'word-e1',
 60+              "#MAKEFILE#:3: *** invalid first argument to 'word' function: empty value.  Stop.",
 61+              512);
 62+
 63+run_make_test(undef,
 64+              'word-e2',
 65+              "#MAKEFILE#:4: *** invalid first argument to 'word' function: 'abc '.  Stop.",
 66+              512);
 67+
 68+run_make_test(undef,
 69+              'word-e3',
 70+              "#MAKEFILE#:5: *** invalid first argument to 'word' function: '1a'.  Stop.",
 71+              512);
 72+
 73+run_make_test(undef,
 74+              'word-e4',
 75+              "#MAKEFILE#:6: *** invalid first argument to 'word' function: '9999999999999999999' out of range.  Stop.",
 76+              512);
 77+
 78+run_make_test(undef,
 79+              'wordlist-e1',
 80+              "#MAKEFILE#:8: *** invalid first argument to 'wordlist' function: empty value.  Stop.",
 81+              512);
 82+
 83+run_make_test(undef,
 84+              'wordlist-e2',
 85+              "#MAKEFILE#:9: *** invalid first argument to 'wordlist' function: 'abc '.  Stop.",
 86+              512);
 87+
 88+run_make_test(undef,
 89+              'wordlist-e3',
 90+              "#MAKEFILE#:10: *** invalid second argument to 'wordlist' function: ' 12a '.  Stop.",
 91+              512);
 92+
 93+# Test error conditions again, but this time in a variable reference
 94+
 95+run_make_test('FOO = foo bar biz baz
 96+
 97+W = $(word $x,$(FOO))
 98+WL = $(wordlist $s,$e,$(FOO))
 99+
100+word-e: ; @echo $(W)
101+wordlist-e: ; @echo $(WL)',
102+              'word-e x=',
103+              "#MAKEFILE#:3: *** invalid first argument to 'word' function: empty value.  Stop.",
104+              512);
105+
106+run_make_test(undef,
107+              'word-e x=abc',
108+              "#MAKEFILE#:3: *** invalid first argument to 'word' function: 'abc'.  Stop.",
109+              512);
110+
111+run_make_test(undef,
112+              'word-e x=0',
113+              "#MAKEFILE#:3: *** first argument to 'word' function must be greater than 0.  Stop.",
114+              512);
115+
116+run_make_test(undef,
117+              'wordlist-e s= e=',
118+              "#MAKEFILE#:4: *** invalid first argument to 'wordlist' function: empty value.  Stop.",
119+              512);
120+
121+run_make_test(undef,
122+              'wordlist-e s=abc e=',
123+              "#MAKEFILE#:4: *** invalid first argument to 'wordlist' function: 'abc'.  Stop.",
124+              512);
125+
126+run_make_test(undef,
127+              'wordlist-e s=4 e=12a',
128+              "#MAKEFILE#:4: *** invalid second argument to 'wordlist' function: '12a'.  Stop.",
129+              512);
130+
131+run_make_test(undef,
132+              'wordlist-e s=0 e=12',
133+              "#MAKEFILE#:4: *** invalid first argument to 'wordlist' function: '0'.  Stop.",
134+              512);
135+
136+run_make_test(undef,
137+              'wordlist-e s=1 e=-1',
138+              "#MAKEFILE#:4: *** invalid second argument to 'wordlist' function: '-1'.  Stop.",
139+              512);
140+
141+
142+# TEST #8 -- test $(firstword )
143+#
144+run_make_test('
145+void :=
146+list := $(void) foo bar baz #
147+
148+a := $(word 1,$(list))
149+b := $(firstword $(list))
150+
151+.PHONY: all
152+
153+all: ; @test "$a" = "$b" && echo $a
154+',
155+'',
156+'foo');
157+
158+
159+# TEST #9 -- test $(lastword )
160+#
161+run_make_test('
162+void :=
163+list := $(void) foo bar baz #
164+
165+a := $(word $(words $(list)),$(list))
166+b := $(lastword $(list))
167+
168+.PHONY: all
169+
170+all: ; @test "$a" = "$b" && echo $a
171+',
172+'',
173+'baz');
174+
175+# This tells the test driver that the perl test script executed properly.
176+1;
+230, -0
  1@@ -0,0 +1,230 @@
  2+#                                                                    -*-perl-*-
  3+$description = "Test backslash-newline handling.";
  4+
  5+$details = "";
  6+
  7+# TEST #1
  8+# -------
  9+
 10+# Backslash-newlines in recipes
 11+
 12+# These are basic backslash-newlines with no tricks
 13+run_make_test("fast:;\@echo fa\\\nst\n",
 14+              '', 'fast');
 15+
 16+run_make_test("slow:;\@: no-op; echo sl\\\now\n",
 17+              '', 'slow');
 18+
 19+run_make_test("dquote:;\@echo \"dqu\\\note\"\n",
 20+              '', 'dquote');
 21+
 22+# Single quotes don't behave the same in Windows
 23+if ($port_type ne 'W32') {
 24+    run_make_test("squote:;\@echo 'squ\\\note'\n",
 25+              '', "squ\\\note");
 26+}
 27+
 28+# Ensure that a leading prefix character is omitted
 29+run_make_test("fast:;\@echo fa\\\n\tst\n",
 30+              '', 'fast');
 31+
 32+run_make_test("slow:;\@: no-op; echo sl\\\n\tow\n",
 33+              '', 'slow');
 34+
 35+run_make_test("dquote:;\@echo \"dqu\\\n\tote\"\n",
 36+              '', 'dquote');
 37+
 38+# Single quotes don't behave the same in Windows
 39+if ($port_type ne 'W32') {
 40+    run_make_test("squote:;\@echo 'squ\\\n\tote'\n",
 41+              '', "squ\\\note");
 42+}
 43+
 44+# Ensure that ONLY the leading prefix character is omitted
 45+run_make_test("fast:;\@echo fa\\\n\t  st\n",
 46+              '', 'fa st');
 47+
 48+run_make_test("slow:;\@: no-op; echo sl\\\n\t\tow\n",
 49+              '', "sl ow");
 50+
 51+run_make_test("dquote:;\@echo \"dqu\\\n\t    ote\"\n",
 52+              '', 'dqu    ote');
 53+
 54+run_make_test("squote:;\@echo 'squ\\\n\t\t   ote'\n",
 55+              '', "squ\\\n\t   ote");
 56+
 57+# Backslash-newlines in variable values
 58+
 59+# Simple
 60+run_make_test(q!
 61+var = he\
 62+llo
 63+var:;@echo '|$(var)|'!,
 64+              '', "|he llo|");
 65+
 66+# Condense trailing space
 67+run_make_test(q!
 68+var = he  \
 69+llo
 70+var:;@echo '|$(var)|'!,
 71+              '', "|he llo|");
 72+
 73+# Remove leading space
 74+run_make_test(q!
 75+var = he\
 76+    llo
 77+var:;@echo '|$(var)|'!,
 78+              '', "|he llo|");
 79+
 80+# Multiple bs/nl condensed
 81+run_make_test(q!
 82+var = he\
 83+\
 84+\
 85+    llo
 86+var:;@echo '|$(var)|'!,
 87+              '', "|he llo|");
 88+
 89+# POSIX: Preserve trailing space
 90+run_make_test(q!
 91+.POSIX:
 92+var = he  \
 93+llo
 94+var:;@echo '|$(var)|'!,
 95+              '', "|he   llo|");
 96+
 97+# POSIX: One space per bs-nl
 98+run_make_test(q!
 99+.POSIX:
100+var = he\
101+\
102+\
103+    llo
104+var:;@echo '|$(var)|'!,
105+              '', "|he   llo|");
106+
107+# Savannah #39035: handle whitespace in call
108+run_make_test(q!
109+f = echo $(1)
110+t:; @$(call f,"a \
111+            b"); \
112+        $(call f,"a \
113+            b")
114+!,
115+              '', "a b\na b\n");
116+
117+# Savannah #38945: handle backslash CRLF
118+# We need our own makefile so we can set binmode
119+my $m1 = get_tmpfile();
120+open(MAKEFILE, "> $m1");
121+binmode(MAKEFILE);
122+print MAKEFILE "FOO = foo \\\r\n";
123+close(MAKEFILE);
124+
125+my $m2 = get_tmpfile();
126+open(MAKEFILE, "> $m2");
127+print MAKEFILE "include $m1\ndefine BAR\nall: ; \@echo \$(FOO) bar\nendef\n\$(eval \$(BAR))\n";
128+close(MAKEFILE);
129+
130+run_make_with_options($m2, '', get_logfile());
131+compare_output("foo bar\n", get_logfile(1));
132+
133+# Test different types of whitespace, and bsnl inside functions
134+
135+sub xlate
136+{
137+    $_ = $_[0];
138+    s/\\r/\r/g;
139+    s/\\t/\t/g;
140+    s/\\f/\f/g;
141+    s/\\n/\n/g;
142+    return $_;
143+}
144+
145+run_make_test(xlate(q!
146+$(foreach\r  a \t , b\t  c \r ,$(info    $a  \r  )      )
147+all:;@:
148+!),
149+              '', "b  \r  \nc  \r  \n");
150+
151+run_make_test(xlate(q!
152+all:;@:$(foreach\r  a \t , b\t  c \r ,$(info    $a  \r  )      )
153+!),
154+              '', "b  \r  \nc  \r  \n");
155+
156+run_make_test(xlate(q!
157+$(foreach \
158+\r  a \t\
159+ , b\t \
160+ c \r ,$(info  \
161+  $a  \r  )  \
162+    )
163+all:;@:
164+!),
165+              '', "b  \r  \nc  \r  \n");
166+
167+run_make_test(xlate(q!
168+all:;@:$(foreach \
169+\r  a \t\
170+ , b\t \
171+ c \r ,$(info  \
172+  $a  \r  )  \
173+    )
174+!),
175+              '', "b  \r  \nc  \r  \n");
176+
177+run_make_test(xlate(q!
178+define FOO
179+$(foreach
180+\r  a \t
181+ , b\t
182+ c \r ,$(info
183+  $a  \r  )
184+    )
185+endef
186+$(FOO)
187+all:;@:
188+!),
189+              '', "b  \r  \nc  \r  \n");
190+
191+run_make_test(xlate(q!
192+define FOO
193+$(foreach
194+\r  a \t
195+ , b\t
196+ c \r ,$(info
197+  $a  \r  )
198+    )
199+endef
200+all:;@:$(FOO)
201+!),
202+              '', "b  \r  \nc  \r  \n");
203+
204+# Test variables in recipes that expand to multiple lines
205+
206+run_make_test(q!
207+define var
208+
209+echo foo
210+
211+
212+echo bar
213+endef
214+all:;$(var)
215+!,
216+              '', "echo foo\nfoo\necho bar\nbar\n");
217+
218+run_make_test(q!
219+define var
220+
221+echo foo
222+
223+@
224+
225+echo bar
226+endef
227+all:;$(var)
228+!,
229+              '', "echo foo\nfoo\necho bar\nbar\n");
230+
231+1;
+12, -0
 1@@ -0,0 +1,12 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Make sure make exits with an error if stdout is full.";
 5+
 6+-e '/dev/full' or return -1;
 7+
 8+# In Strawberry Perl, /dev/full "exists" but does nothing :-/
 9+$port_type eq 'W32' and return -1;
10+
11+run_make_test("\n", '-v > /dev/full', '/^#MAKE#: write error/', 256);
12+
13+1;
+49, -0
 1@@ -0,0 +1,49 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test miscellaneous failures.";
 5+
 6+
 7+# Test that the "did you mean TAB" message is printed properly
 8+
 9+run_make_test(q!
10+$x.
11+!,
12+              '', '#MAKEFILE#:2: *** missing separator.  Stop.', 512);
13+
14+run_make_test(q!
15+foo:
16+        bar
17+!,
18+              '', '#MAKEFILE#:3: *** missing separator (did you mean TAB instead of 8 spaces?).  Stop.', 512);
19+
20+run_make_test(q!
21+.RECIPEPREFIX = :
22+foo:
23+        bar
24+!,
25+              '', '#MAKEFILE#:4: *** missing separator.  Stop.', 512);
26+
27+for my $kw ('eq', 'neq') {
28+run_make_test(qq!
29+if$kw(foo,bar)
30+\$(error ouch)
31+endif
32+!,
33+              '', '#MAKEFILE#:2: *** missing separator (ifeq/ifneq must be followed by whitespace).  Stop.', 512);
34+
35+run_make_test(qq!
36+if$kw
37+\$(error ouch)
38+endif
39+!,
40+              '', '#MAKEFILE#:2: *** invalid syntax in conditional.  Stop.', 512);
41+
42+run_make_test(qq!
43+if$kw blah
44+\$(error ouch)
45+endif
46+!,
47+              '', '#MAKEFILE#:2: *** invalid syntax in conditional.  Stop.', 512);
48+}
49+
50+1;
+22, -0
 1@@ -0,0 +1,22 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Make sure make exits with an error if fopen fails.";
 5+
 6+# For some reason on Cygwin, make exits with no error message after
 7+# it recurses for a while.
 8+$^O =~ /cygwin/ and return -1;
 9+
10+# Recurse infinitely until we run out of open files, and ensure we
11+# fail with a non-zero exit code.  Don't bother to test the output
12+# since it's hard to know what it will be, exactly.
13+# See Savannah bug #27374.
14+
15+# Use a longer-than-normal timeout: some systems have more FDs available?
16+# We also set ulimit -n 512 in check-regression in Makefile.am, which see.
17+# See Savannah bug #42390.
18+run_make_test(q!
19+include $(lastword $(MAKEFILE_LIST))
20+!,
21+              '', undef, 512, 300);
22+
23+1;
+52, -0
 1@@ -0,0 +1,52 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "The following test creates a makefile to test the
 5+simple functionality of make.  It mimics the
 6+rebuilding of a product with dependencies.
 7+It also tests the simple definition of VPATH.";
 8+
 9+open(MAKEFILE,"> $makefile");
10+
11+print MAKEFILE <<EOF;
12+VPATH = work
13+edit:  main.o kbd.o commands.o display.o \\
14+       insert.o
15+\t\@echo cc -o edit main.o kbd.o commands.o display.o \\
16+                  insert.o
17+main.o : main.c defs.h
18+\t\@echo cc -c main.c
19+kbd.o : kbd.c defs.h command.h
20+\t\@echo cc -c kbd.c
21+commands.o : command.c defs.h command.h
22+\t\@echo cc -c commands.c
23+display.o : display.c defs.h buffer.h
24+\t\@echo cc -c display.c
25+insert.o : insert.c defs.h buffer.h
26+\t\@echo cc -c insert.c
27+EOF
28+
29+close(MAKEFILE);
30+
31+
32+mkdir('work');
33+@files_to_touch = ("work${pathsep}main.c","work${pathsep}defs.h",
34+               "work${pathsep}kbd.c","work${pathsep}command.h",
35+               "work${pathsep}commands.c","work${pathsep}display.c",
36+               "work${pathsep}buffer.h","work${pathsep}insert.c",
37+               "work${pathsep}command.c");
38+
39+&touch(@files_to_touch);
40+
41+&run_make_with_options($makefile,"",&get_logfile);
42+
43+# Create the answer to what should be produced by this Makefile
44+$answer = "cc -c main.c\ncc -c kbd.c\ncc -c commands.c\ncc -c display.c
45+cc -c insert.c\ncc -o edit main.o kbd.o commands.o display.o insert.o\n";
46+
47+# COMPARE RESULTS
48+
49+if (&compare_output($answer,&get_logfile(1))) {
50+  unlink @files_to_touch;
51+}
52+
53+1;
+51, -0
 1@@ -0,0 +1,51 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "The following test creates a makefile to test the
 5+simple functionality of make.  It is the same as
 6+general_test1 except that this one tests the
 7+definition of a variable to hold the object filenames.";
 8+
 9+open(MAKEFILE,"> $makefile");
10+
11+# The contents of the Makefile ...
12+
13+print MAKEFILE <<EOF;
14+VPATH = work
15+objects = main.o kbd.o commands.o display.o insert.o
16+edit:  \$(objects)
17+\t\@echo cc -o edit \$(objects)
18+main.o : main.c defs.h
19+\t\@echo cc -c main.c
20+kbd.o : kbd.c defs.h command.h
21+\t\@echo cc -c kbd.c
22+commands.o : command.c defs.h command.h
23+\t\@echo cc -c commands.c
24+display.o : display.c defs.h buffer.h
25+\t\@echo cc -c display.c
26+insert.o : insert.c defs.h buffer.h
27+\t\@echo cc -c insert.c
28+EOF
29+
30+close(MAKEFILE);
31+
32+
33+mkdir('work');
34+@files_to_touch = ("work${pathsep}main.c","work${pathsep}defs.h",
35+               "work${pathsep}kbd.c","work${pathsep}command.h",
36+               "work${pathsep}commands.c","work${pathsep}display.c",
37+               "work${pathsep}buffer.h","work${pathsep}insert.c",
38+               "work${pathsep}command.c");
39+
40+&touch(@files_to_touch);
41+
42+&run_make_with_options($makefile,"",&get_logfile);
43+
44+# Create the answer to what should be produced by this Makefile
45+$answer = "cc -c main.c\ncc -c kbd.c\ncc -c commands.c\ncc -c display.c
46+cc -c insert.c\ncc -o edit main.o kbd.o commands.o display.o insert.o\n";
47+
48+if (&compare_output($answer,&get_logfile(1))) {
49+  unlink @files_to_touch;
50+}
51+
52+1;
+343, -0
  1@@ -0,0 +1,343 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "\
  5+This tests random features of the parser that need to be supported, and
  6+which have either broken at some point in the past or seem likely to
  7+break.";
  8+
  9+run_make_test(q!
 10+# We want to allow both empty commands _and_ commands that resolve to empty.
 11+EMPTY =
 12+
 13+.PHONY: all a1 a2 a3 a4
 14+all: a1 a2 a3 a4
 15+
 16+a1:;
 17+a2:
 18+#TAB#
 19+a3:;$(EMPTY)
 20+a4:
 21+#TAB#$(EMPTY)
 22+
 23+# Non-empty lines that expand to nothing should also be ignored.
 24+STR =     # Some spaces
 25+TAB =   #TAB#  # A TAB and some spaces
 26+
 27+$(STR)
 28+
 29+$(STR) $(TAB)!,
 30+              '', "#MAKE#: Nothing to be done for 'all'.");
 31+
 32+# TEST 2
 33+
 34+# Make sure files without trailing newlines are handled properly.
 35+# Have to use the old style invocation to test this.
 36+
 37+$makefile2 = &get_tmpfile;
 38+
 39+open(MAKEFILE, "> $makefile2");
 40+print MAKEFILE "all:;\@echo FOO = \$(FOO)\nFOO = foo";
 41+close(MAKEFILE);
 42+
 43+&run_make_with_options($makefile2,"",&get_logfile);
 44+$answer = "FOO = foo\n";
 45+&compare_output($answer,&get_logfile(1));
 46+
 47+# TEST 3
 48+
 49+# Check semicolons in variable references
 50+
 51+run_make_test(q!
 52+$(if true,$(info true; true))
 53+all: ; @:
 54+!,
 55+              '', 'true; true');
 56+
 57+# TEST 4
 58+
 59+# Check that backslashes in command scripts are handled according to POSIX.
 60+# Checks Savannah bug # 1332.
 61+
 62+# Test the fastpath / no quotes
 63+run_make_test(q!
 64+all:
 65+#TAB#@echo foo\
 66+bar
 67+#TAB#@echo foo\
 68+#TAB#bar
 69+#TAB#@echo foo\
 70+    bar
 71+#TAB#@echo foo\
 72+#TAB#    bar
 73+#TAB#@echo foo \
 74+bar
 75+#TAB#@echo foo \
 76+#TAB#bar
 77+#TAB#@echo foo \
 78+    bar
 79+#TAB#@echo foo \
 80+#TAB#    bar
 81+!,
 82+              '', 'foobar
 83+foobar
 84+foo bar
 85+foo bar
 86+foo bar
 87+foo bar
 88+foo bar
 89+foo bar');
 90+
 91+# Test the fastpath / single quotes
 92+# Single quotes don't behave the same in Windows
 93+if ($port_type ne 'W32') {
 94+    run_make_test(q!
 95+all:
 96+#TAB#@echo 'foo\
 97+bar'
 98+#TAB#@echo 'foo\
 99+#TAB#bar'
100+#TAB#@echo 'foo\
101+    bar'
102+#TAB#@echo 'foo\
103+#TAB#    bar'
104+#TAB#@echo 'foo \
105+bar'
106+#TAB#@echo 'foo \
107+#TAB#bar'
108+#TAB#@echo 'foo \
109+    bar'
110+#TAB#@echo 'foo \
111+#TAB#    bar'
112+!,
113+              '', 'foo\
114+bar
115+foo\
116+bar
117+foo\
118+    bar
119+foo\
120+    bar
121+foo \
122+bar
123+foo \
124+bar
125+foo \
126+    bar
127+foo \
128+    bar');
129+}
130+
131+# Test the fastpath / double quotes
132+run_make_test(q!
133+all:
134+#TAB#@echo "foo\
135+bar"
136+#TAB#@echo "foo\
137+#TAB#bar"
138+#TAB#@echo "foo\
139+    bar"
140+#TAB#@echo "foo\
141+#TAB#    bar"
142+#TAB#@echo "foo \
143+bar"
144+#TAB#@echo "foo \
145+#TAB#bar"
146+#TAB#@echo "foo \
147+    bar"
148+#TAB#@echo "foo \
149+#TAB#    bar"
150+!,
151+              '', 'foobar
152+foobar
153+foo    bar
154+foo    bar
155+foo bar
156+foo bar
157+foo     bar
158+foo     bar');
159+
160+# Test the slow path / no quotes
161+run_make_test(q!
162+all:
163+#TAB#@echo hi; echo foo\
164+bar
165+#TAB#@echo hi; echo foo\
166+#TAB#bar
167+#TAB#@echo hi; echo foo\
168+ bar
169+#TAB#@echo hi; echo foo\
170+#TAB# bar
171+#TAB#@echo hi; echo foo \
172+bar
173+#TAB#@echo hi; echo foo \
174+#TAB#bar
175+#TAB#@echo hi; echo foo \
176+ bar
177+#TAB#@echo hi; echo foo \
178+#TAB# bar
179+!,
180+              '', 'hi
181+foobar
182+hi
183+foobar
184+hi
185+foo bar
186+hi
187+foo bar
188+hi
189+foo bar
190+hi
191+foo bar
192+hi
193+foo bar
194+hi
195+foo bar');
196+
197+# Test the slow path / no quotes.  This time we put the slow path
198+# determination _after_ the backslash-newline handling.
199+run_make_test(q!
200+all:
201+#TAB#@echo foo\
202+bar; echo hi
203+#TAB#@echo foo\
204+#TAB#bar; echo hi
205+#TAB#@echo foo\
206+ bar; echo hi
207+#TAB#@echo foo\
208+#TAB# bar; echo hi
209+#TAB#@echo foo \
210+bar; echo hi
211+#TAB#@echo foo \
212+#TAB#bar; echo hi
213+#TAB#@echo foo \
214+ bar; echo hi
215+#TAB#@echo foo \
216+#TAB# bar; echo hi
217+!,
218+              '', 'foobar
219+hi
220+foobar
221+hi
222+foo bar
223+hi
224+foo bar
225+hi
226+foo bar
227+hi
228+foo bar
229+hi
230+foo bar
231+hi
232+foo bar
233+hi');
234+
235+# Test the slow path / single quotes
236+run_make_test(q!
237+all:
238+#TAB#@echo hi; echo 'foo\
239+bar'
240+#TAB#@echo hi; echo 'foo\
241+#TAB#bar'
242+#TAB#@echo hi; echo 'foo\
243+    bar'
244+#TAB#@echo hi; echo 'foo\
245+#TAB#    bar'
246+#TAB#@echo hi; echo 'foo \
247+bar'
248+#TAB#@echo hi; echo 'foo \
249+#TAB#bar'
250+#TAB#@echo hi; echo 'foo \
251+    bar'
252+#TAB#@echo hi; echo 'foo \
253+#TAB#    bar'
254+!,
255+              '', 'hi
256+foo\
257+bar
258+hi
259+foo\
260+bar
261+hi
262+foo\
263+    bar
264+hi
265+foo\
266+    bar
267+hi
268+foo \
269+bar
270+hi
271+foo \
272+bar
273+hi
274+foo \
275+    bar
276+hi
277+foo \
278+    bar');
279+
280+# Test the slow path / double quotes
281+run_make_test(q!
282+all:
283+#TAB#@echo hi; echo "foo\
284+bar"
285+#TAB#@echo hi; echo "foo\
286+#TAB#bar"
287+#TAB#@echo hi; echo "foo\
288+    bar"
289+#TAB#@echo hi; echo "foo\
290+#TAB#    bar"
291+#TAB#@echo hi; echo "foo \
292+bar"
293+#TAB#@echo hi; echo "foo \
294+#TAB#bar"
295+#TAB#@echo hi; echo "foo \
296+    bar"
297+#TAB#@echo hi; echo "foo \
298+#TAB#    bar"
299+!,
300+              '', 'hi
301+foobar
302+hi
303+foobar
304+hi
305+foo    bar
306+hi
307+foo    bar
308+hi
309+foo bar
310+hi
311+foo bar
312+hi
313+foo     bar
314+hi
315+foo     bar');
316+
317+run_make_test('x:;@-exit 1', '', "#MAKE#: [#MAKEFILE#:1: x] Error 1 (ignored)\n");
318+
319+# Slow path with odd setups
320+
321+if ($port_type ne 'W32') {
322+    run_make_test(q!
323+    slow: SHELL := echo
324+    slow: .SHELLFLAGS := hoho
325+    slow:; @foo bar
326+    !,
327+                  '', "hoho foo bar\n");
328+
329+    run_make_test(q!
330+    slow: SHELL := echo hi
331+    slow: .SHELLFLAGS := ho ho
332+    slow:; @foo bar
333+    !,
334+                  '', "hi ho ho foo bar\n");
335+
336+    run_make_test(q!
337+    slow: SHELL := echo hi
338+    slow: .SHELLFLAGS := 'ho;ho'
339+    slow:; @foo bar
340+    !,
341+                  '', "hi ho;ho foo bar\n");
342+}
343+
344+1;
+148, -0
  1@@ -0,0 +1,148 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "\
  5+This tests random features of make's algorithms, often somewhat obscure,
  6+which have either broken at some point in the past or seem likely to
  7+break.";
  8+
  9+run_make_test('
 10+# Make sure that subdirectories built as prerequisites are actually handled
 11+# properly.
 12+
 13+all: dir/subdir/file.a
 14+
 15+dir/subdir: ; @echo mkdir -p dir/subdir
 16+
 17+dir/subdir/file.b: dir/subdir ; @echo touch dir/subdir/file.b
 18+
 19+dir/subdir/%.a: dir/subdir/%.b ; @echo cp $< $@',
 20+              '', "mkdir -p dir/subdir\ntouch dir/subdir/file.b\ncp dir/subdir/file.b dir/subdir/file.a\n");
 21+
 22+# Test implicit rules
 23+
 24+&touch('foo.c');
 25+run_make_test('foo: foo.o',
 26+              'CC="@echo cc" OUTPUT_OPTION=',
 27+              'cc -c foo.c
 28+cc foo.o -o foo');
 29+unlink('foo.c');
 30+
 31+
 32+# Test implicit rules with '$' in the name (see se_implicit)
 33+
 34+run_make_test(q!
 35+%.foo : baz$$bar ; @echo 'done $<'
 36+%.foo : bar$$baz ; @echo 'done $<'
 37+test.foo:
 38+baz$$bar bar$$baz: ; @echo '$@'
 39+!,
 40+              '',
 41+              "baz\$bar\ndone baz\$bar");
 42+
 43+
 44+# Test implicit rules with '$' in the name (see se_implicit)
 45+# Use the '$' in the pattern.
 46+
 47+run_make_test(q!
 48+%.foo : %$$bar ; @echo 'done $<'
 49+test.foo:
 50+test$$bar: ; @echo '$@'
 51+!,
 52+              '',
 53+              "test\$bar\ndone test\$bar");
 54+
 55+# Make sure that subdirectories built as prerequisites are actually handled
 56+# properly... this time with '$'
 57+
 58+run_make_test(q!
 59+
 60+all: dir/subdir/file.$$a
 61+
 62+dir/subdir: ; @echo mkdir -p '$@'
 63+
 64+dir/subdir/file.$$b: dir/subdir ; @echo touch '$@'
 65+
 66+dir/subdir/%.$$a: dir/subdir/%.$$b ; @echo 'cp $< $@'
 67+!,
 68+              '', "mkdir -p dir/subdir\ntouch dir/subdir/file.\$b\ncp dir/subdir/file.\$b dir/subdir/file.\$a\n");
 69+
 70+# Test odd whitespace at the beginning of a line
 71+
 72+run_make_test("
 73+all:
 74+   \f
 75+
 76+    \\
 77+ \f  \\
 78+    \013 \\
 79+all: ; \@echo hi
 80+",
 81+              '', "hi\n");
 82+
 83+# SV-56834 Ensure setting PATH in the makefile works properly
 84+my $sname = "foobar$scriptsuffix";
 85+
 86+mkdir('sd', 0775);
 87+create_file("sd/$sname", "exit 0\n");
 88+chmod 0755, "sd/$sname";
 89+
 90+run_make_test(qq!
 91+PATH := sd
 92+all: ; $sname >/dev/null
 93+!,
 94+              '', "$sname >/dev/null\n");
 95+
 96+# Don't use the general PATH if not found on the target path
 97+
 98+$ENV{PATH} = "$ENV{PATH}:sd";
 99+
100+my ($ernum, $erstr);
101+
102+if ($port_type eq 'W32') {
103+    $ernum = 2;
104+    $erstr = "process_begin: CreateProcess(NULL, $sname, ...) failed.\nmake (e=2): The system cannot find the file specified.";
105+} else {
106+    $ernum = 127;
107+    $erstr = "#MAKE#: $sname: $ERR_no_such_file";
108+}
109+
110+run_make_test(qq!
111+PATH := ..
112+all: ; $sname
113+!,
114+              '', "$sname\n$erstr\n#MAKE#: *** [#MAKEFILE#:3: all] Error $ernum", 512);
115+
116+unlink("sd/$sname");
117+rmdir('sd');
118+
119+# Ensure that local programs are not found if "." is not on the PATH
120+
121+create_file($sname, '');
122+chmod 0755, $sname;
123+
124+if ($port_type eq 'W32') {
125+    $ernum = -1;
126+    $erstr = "";
127+} else {
128+    $ernum = 127;
129+    $erstr = "#MAKE#: $sname: $ERR_no_such_file\n";
130+}
131+
132+run_make_test(qq!
133+PATH := ..
134+all: ; $sname
135+!,
136+              '', "$sname\n$erstr#MAKE#: *** [#MAKEFILE#:3: all] Error $ernum", 512);
137+
138+unlink($sname);
139+
140+if ($port_type eq 'UNIX') {
141+    # SV 57674: ensure we use a system default PATH if one is not set
142+    delete $ENV{PATH};
143+    run_make_test(q!
144+a: ; @echo hi
145+!,
146+                  '', "hi\n");
147+}
148+
149+1;
+14, -0
 1@@ -0,0 +1,14 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Test utf8 handling.";
 4+
 5+$details = "";
 6+
 7+# Variable names containing UTF8 characters
 8+run_make_test("
 9+\xe2\x96\xaa := hello
10+\$(info \$(\xe2\x96\xaa))
11+all:
12+",
13+              '', "hello\n#MAKE#: Nothing to be done for 'all'.");
14+
15+1;
+84, -0
 1@@ -0,0 +1,84 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test make -B (always remake) option.\n";
 5+
 6+$details = "\
 7+Construct a simple makefile that builds a target.
 8+Invoke make once, so it builds everything.  Invoke it again and verify
 9+that nothing is built.  Then invoke it with -B and verify that everything
10+is built again.";
11+
12+&touch('bar.x');
13+
14+run_make_test(q!
15+.SUFFIXES:
16+
17+.PHONY: all
18+all: foo
19+
20+foo: bar.x
21+#TAB#@echo cp $< $@
22+#TAB#@echo "" > $@
23+!,
24+              '', 'cp bar.x foo');
25+
26+run_make_test(undef, '', "#MAKE#: Nothing to be done for 'all'.");
27+run_make_test(undef, '-B', 'cp bar.x foo');
28+
29+# Put the timestamp for foo into the future; it should still be remade.
30+# There are clock skew errors printed here but they will be cleared by
31+# the comparison code.
32+utouch(1000, 'foo');
33+run_make_test(undef, '', "#MAKE#: Nothing to be done for 'all'.");
34+run_make_test(undef, '-B', 'cp bar.x foo');
35+
36+# Clean up
37+
38+rmfiles('bar.x', 'foo');
39+
40+# Test -B with the re-exec feature: we don't want to re-exec forever
41+# Savannah bug # 7566
42+
43+run_make_test(q!
44+all: ; @:
45+$(info MAKE_RESTARTS=$(MAKE_RESTARTS))
46+include foo.x
47+foo.x: ; @touch $@
48+!,
49+              '-B', 'MAKE_RESTARTS=
50+MAKE_RESTARTS=1');
51+
52+rmfiles('foo.x');
53+
54+# Test -B with the re-exec feature: we DO want -B in the "normal" part of the
55+# makefile.
56+
57+&touch('blah.x');
58+
59+run_make_test(q!
60+all: blah.x ; @echo $@
61+$(info MAKE_RESTARTS=$(MAKE_RESTARTS))
62+include foo.x
63+foo.x: ; @touch $@
64+blah.x: ; @echo $@
65+!,
66+              '-B', 'MAKE_RESTARTS=
67+MAKE_RESTARTS=1
68+blah.x
69+all');
70+
71+rmfiles('foo.x', 'blah.x');
72+
73+# Test that $? is set properly with -B; all prerequisites will be newer!
74+
75+utouch(-10, 'x.b');
76+touch('x.a');
77+
78+run_make_test(q!
79+x.a: x.b ; @echo $?
80+!,
81+              '-B', "x.b\n");
82+
83+unlink(qw(x.a x.b));
84+
85+1;
+52, -0
 1@@ -0,0 +1,52 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the -C option to GNU Make.";
 5+
 6+use File::Spec;
 7+
 8+# Pre-set $makefile to be in a subdirectory
 9+$makefile = 'Makefile';
10+
11+my $_srcdir = 'src';
12+mkdir($_srcdir, 0775);
13+
14+my $_incdir = 'inc';
15+mkdir($_incdir, 0775);
16+
17+my $_mkpath = File::Spec->catfile($_srcdir, $makefile);
18+create_file($_mkpath, "include \$(file)\nall: ;\n");
19+
20+# TEST #1
21+# -------
22+run_make_test('', "-C $_srcdir --no-print-directory",
23+              "#MAKE#: 'all' is up to date.");
24+
25+# TEST #2
26+# -------
27+# Do it again with trailing "/"; this should work the same
28+
29+run_make_test(undef, "-C $_srcdir/ --no-print-directory",
30+              "#MAKE#: 'all' is up to date.");
31+
32+# Test stringing together multiple -C options
33+
34+run_make_test(undef, "-C $_incdir -C .. -C $_srcdir --no-print-directory",
35+              "#MAKE#: 'all' is up to date.");
36+
37+# SV 63552 - Ensure -I is considered after -C
38+
39+my $_incfile = 'test';
40+my $_incpath = File::Spec->catfile($_incdir, $_incfile);
41+create_file($_incpath, '$(info included)');
42+
43+my $_incopt = File::Spec->catfile('..', $_incdir);
44+
45+run_make_test(undef, "-C src -I $_incopt --no-print-directory file=$_incfile",
46+              "included\n#MAKE#: 'all' is up to date.");
47+
48+unlink($_incpath);
49+rmdir($_incdir);
50+
51+unlink($_mkpath);
52+rmdir($_srcdir);
53+1;
+116, -0
  1@@ -0,0 +1,116 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "The following test creates a makefile to test the -I option.";
  5+
  6+$details = "\
  7+This test tests the -I option by including a filename in
  8+another directory and giving make that directory name
  9+under -I in the command line.  Without this option, the make
 10+would fail to find the included file.  It also checks to make
 11+sure that the -I option gets passed to recursive makes.";
 12+
 13+use File::Spec;
 14+
 15+# Create a directory and put a makefile in it.
 16+# We can't put it in the current directory since that's automatically searched
 17+# anyway.
 18+my $subdir = 'idir';
 19+mkdir($subdir, 0777);
 20+
 21+my $included = 'ifile.mk';
 22+my $ipath = File::Spec->catfile($subdir, $included);
 23+create_file($ipath, "
 24+ANOTHER:
 25+\t\@echo This is another included makefile
 26+recurse:
 27+\t\@\$(MAKE) ANOTHER -f \$(main_makefile)\n");
 28+
 29+my $nosuch = "#MAKEFILE#:5: $included: $ERR_no_such_file
 30+#MAKE#: *** No rule to make target '$included'.  Stop.\n";
 31+
 32+
 33+# Verify that we get an error if we don't have -I
 34+run_make_test(qq!
 35+main_makefile := \$(firstword \$(MAKEFILE_LIST))
 36+all:
 37+\t\@echo There should be no errors for this makefile
 38+include $included
 39+!,
 40+              '', $nosuch, 512);
 41+
 42+# Check basic -I works
 43+run_make_test(undef, "-I $subdir all",
 44+              "There should be no errors for this makefile\n");
 45+
 46+# Check that the included target works
 47+run_make_test(undef, "-I $subdir ANOTHER",
 48+              "This is another included makefile\n");
 49+
 50+# Check that -I is passed down through MAKEFLAGS
 51+run_make_test(undef, "-I $subdir recurse",
 52+              "#MAKE#[1]: Entering directory '#PWD#'
 53+This is another included makefile
 54+#MAKE#[1]: Leaving directory '#PWD#'\n");
 55+
 56+# Verify that we get an error if we add -I- to delete previous includes
 57+run_make_test(undef, "-I $subdir -I- all", $nosuch, 512);
 58+
 59+# Make another directory with the same name and make sure the right one is
 60+# chosen if -I- stops the path.
 61+
 62+mkdir('idir2', 0777);
 63+my $ipath2 = File::Spec->catfile('idir2', $included);
 64+create_file($ipath2, "This is a bad makefile!!\n");
 65+
 66+run_make_test(undef, "-I idir2 -I $subdir ANOTHER",
 67+              "$included:1: *** missing separator.  Stop.\n", 512);
 68+
 69+run_make_test(undef, "-I idir2 -I - -I $subdir ANOTHER",
 70+              "This is another included makefile\n");
 71+
 72+# Check that -I- is passed down through MAKEFLAGS
 73+run_make_test(undef, "-I idir2 -I - -I $subdir recurse",
 74+              "#MAKE#[1]: Entering directory '#PWD#'
 75+This is another included makefile
 76+#MAKE#[1]: Leaving directory '#PWD#'\n");
 77+
 78+unlink($ipath2);
 79+rmdir('idir2');
 80+
 81+# The only way to check if -I- voids included directories is to see if a file
 82+# exists in one and try to include it.  We very likely can't add our own files
 83+# to the default directories since they're probably write-protected.  This
 84+# won't work if none of the default directories contain any files :-/
 85+
 86+create_file('defaultdirs.mk', "\$(info \$(.INCLUDE_DIRS))\nall:;\@:\n");
 87+my $cmd = subst_make_string('"#MAKEPATH#" -f defaultdirs.mk');
 88+my @dirs = `$cmd`;
 89+my $dirs = $dirs[0];
 90+$dirs =~ s/\r?\n//g;
 91+unlink('defaultdirs.mk');
 92+
 93+my $fn = undef;
 94+foreach my $dn (split ' ', $dirs) {
 95+    # On Windows the default is "." which is bogus!
 96+    if ($dn ne '.') {
 97+        my @files = glob(File::Spec->catfile($dn, "*"));
 98+        if (@files) {
 99+            (undef, undef, $fn) = File::Spec->splitpath($files[0]);
100+            last;
101+        }
102+    }
103+}
104+
105+if ($fn) {
106+    run_make_test("
107+all:;
108+include $fn
109+",
110+                  '-I-', "#MAKEFILE#:3: $fn: $ERR_no_such_file
111+#MAKE#: *** No rule to make target '$fn'.  Stop.\n", 512);
112+}
113+
114+unlink($ipath);
115+rmdir($subdir);
116+
117+1;
+90, -0
 1@@ -0,0 +1,90 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test make -W (what if) option.\n";
 5+
 6+# Basic build
 7+
 8+run_make_test(q!
 9+a.x: b.x
10+a.x b.x: ; echo >> $@
11+!,
12+              '', "echo >> b.x\necho >> a.x");
13+
14+# Run it again: nothing should happen
15+
16+run_make_test(undef, '', "#MAKE#: 'a.x' is up to date.");
17+
18+# Now run it with -W b.x: should rebuild a.x
19+
20+run_make_test(undef, '-W b.x', 'echo >> a.x');
21+
22+# Put the timestamp for a.x into the future; it should still be remade.
23+# There are clock skew errors printed here but they will be cleared by
24+# the comparison code.
25+utouch(1000, 'a.x');
26+run_make_test(undef, '', "#MAKE#: 'a.x' is up to date.");
27+run_make_test(undef, '-W b.x', 'echo >> a.x');
28+
29+# Clean up
30+
31+rmfiles('a.x', 'b.x');
32+
33+# Test -W with the re-exec feature: we don't want to re-exec forever
34+# Savannah bug # 7566
35+
36+# First set it up with a normal build
37+
38+run_make_test(q!
39+all: baz.x ; @:
40+include foo.x
41+foo.x: bar.x
42+#TAB#@echo "\$$(info restarts=\$$(MAKE_RESTARTS))" > $@
43+#TAB#@echo "touch $@"
44+bar.x: ; echo >> $@
45+baz.x: bar.x ; @echo "touch $@"
46+!,
47+              '', 'echo >> bar.x
48+touch foo.x
49+restarts=1
50+touch baz.x');
51+
52+# Now run with -W bar.x
53+
54+# Tweak foo.x's timestamp so the update will change it.
55+# There are clock skew errors printed here but they will be cleared by
56+# the comparison code.
57+&utouch(1000, 'foo.x');
58+
59+run_make_test(undef, '-W bar.x', "restarts=\ntouch foo.x\nrestarts=1\ntouch baz.x");
60+
61+rmfiles('foo.x', 'bar.x');
62+
63+# Test -W on vpath-found files: it should take effect.
64+# Savannah bug # 15341
65+
66+mkdir('x-dir', 0777);
67+utouch(-20, 'x-dir/x');
68+touch('y');
69+
70+run_make_test(q!
71+y: x ; @echo cp $< $@
72+!,
73+              '-W x-dir/x VPATH=x-dir',
74+              'cp x-dir/x y');
75+
76+# Make sure ./ stripping doesn't interfere with the match.
77+
78+run_make_test(q!
79+y: x ; @echo cp $< $@
80+!,
81+              '-W ./x-dir/x VPATH=x-dir',
82+              'cp x-dir/x y');
83+
84+run_make_test(undef,
85+              '-W x-dir/x VPATH=./x-dir',
86+              'cp ./x-dir/x y');
87+
88+unlink(qw(y x-dir/x));
89+rmdir('x-dir');
90+
91+1;
+9, -0
 1@@ -0,0 +1,9 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test make -d option.\n";
 5+
 6+# sv 60777.
 7+# Test that debug output is printed when both -d and --trace are specified.
 8+run_make_test('all: ; :', '-d --trace', "/GNU Make/");
 9+
10+1;
+145, -0
  1@@ -0,0 +1,145 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test the -e (environment overrides) option";
  5+
  6+$ENV{GOOGLE} = 'boggle';
  7+
  8+run_make_test(q!
  9+GOOGLE = bazzle
 10+all:; @echo "$(GOOGLE)"
 11+!,
 12+              '-e', "boggle\n");
 13+
 14+# Ensure variables set on the command line have the origin correct
 15+# See SV 61218
 16+
 17+run_make_test(q!
 18+$(info FOO [$(origin FOO)]: $(value FOO))
 19+all: ;
 20+recurse: ; @$(MAKE) -f #MAKEFILE#
 21+!,
 22+              '-e --no-print-directory FOO=1 recurse',
 23+              "FOO [command line]: 1\nFOO [command line]: 1\n#MAKE#[1]: 'all' is up to date.");
 24+
 25+# SV 64803.
 26+# Test that the origin of an env variable is 'enviroment override' when -e
 27+# is set and the makefile does not modify the variable.
 28+# First run the test without -e and then with -e.
 29+
 30+mkdir('lib', 0777);
 31+
 32+create_file('lib/makefile',
 33+'$(info in submake value=$(hello), origin=$(origin hello))
 34+all:; @echo "value=$(hello), origin=$(origin hello)"'."\n");
 35+
 36+# No -e.
 37+$ENV{hello} = 'world';
 38+run_make_test(q!
 39+.RECIPEPREFIX = >
 40+$(info value=$(hello), origin=$(origin hello))
 41+all:
 42+> @echo "value=$(hello), origin=$(origin hello)"
 43+> @$(MAKE) -C lib
 44+.PHONY: lib all
 45+!,
 46+              '-s',
 47+              "value=world, origin=environment\nvalue=world, origin=environment\n".
 48+              "in submake value=world, origin=environment\nvalue=world, origin=environment");
 49+
 50+# -e is specified on the command line.
 51+my @opts = ('-e', '--environment-overrides');
 52+for my $opt (@opts) {
 53+$ENV{hello} = 'world';
 54+run_make_test(q!
 55+.RECIPEPREFIX = >
 56+$(info value=$(hello), origin=$(origin hello))
 57+all:
 58+> @echo "value=$(hello), origin=$(origin hello)"
 59+> @$(MAKE) -C lib
 60+.PHONY: lib all
 61+!,
 62+              "-s $opt",
 63+              "value=world, origin=environment override\nvalue=world, origin=environment override\n".
 64+              "in submake value=world, origin=environment override\nvalue=world, origin=environment override");
 65+}
 66+
 67+# MAKEFLAGS from env affects top level make.
 68+$ENV{hello} = 'world';
 69+$ENV{MAKEFLAGS} = 'e';
 70+run_make_test(q!
 71+.RECIPEPREFIX = >
 72+$(info value=$(hello), origin=$(origin hello))
 73+all:
 74+> @echo "value=$(hello), origin=$(origin hello)"
 75+> @$(MAKE) -C lib
 76+.PHONY: lib all
 77+!,
 78+              "-s",
 79+              "value=world, origin=environment override\nvalue=world, origin=environment override\n".
 80+              "in submake value=world, origin=environment override\nvalue=world, origin=environment override");
 81+
 82+# -e is passed to submake on the command line.
 83+$ENV{hello} = 'world';
 84+run_make_test(q!
 85+.RECIPEPREFIX = >
 86+$(info value=$(hello), origin=$(origin hello))
 87+all:
 88+> @echo "value=$(hello), origin=$(origin hello)"
 89+> @$(MAKE) -e -C lib
 90+.PHONY: lib all
 91+!,
 92+              "-s",
 93+              "value=world, origin=environment\nvalue=world, origin=environment\n".
 94+              "in submake value=world, origin=environment override\nvalue=world, origin=environment override");
 95+
 96+# MAKEFLAGS is reset for submake.
 97+$ENV{hello} = 'world';
 98+run_make_test(q!
 99+.RECIPEPREFIX = >
100+$(info value=$(hello), origin=$(origin hello))
101+all:
102+> @echo "value=$(hello), origin=$(origin hello)"
103+> @$(MAKE) -C lib MAKEFLAGS=
104+.PHONY: lib all
105+!,
106+              "-se",
107+              "value=world, origin=environment override\nvalue=world, origin=environment override\n".
108+              "in submake value=world, origin=environment\nvalue=world, origin=environment");
109+
110+# Some MAKEFLAGS in top make env.
111+# This MAKEFLAGS does not conform to the format that make itself produces for
112+# submake. However, make still parses and honors this MAKEFLAGS.
113+# This test checks that make does not confuse 'e' in 'extramk' with '-e'.
114+$ENV{MAKEFLAGS} = 'r -Iextramk -k bye=moon';
115+$ENV{hello} = 'world';
116+run_make_test(q!
117+.RECIPEPREFIX = >
118+$(info value=$(hello), origin=$(origin hello))
119+all:
120+> @echo "value=$(hello), origin=$(origin hello)"
121+> @$(MAKE) -C lib
122+.PHONY: lib all
123+!,
124+              "-s",
125+              "value=world, origin=environment\nvalue=world, origin=environment\n".
126+              "in submake value=world, origin=environment\nvalue=world, origin=environment");
127+
128+# Some MAKEFLAGS in top make env.
129+# This MAKEFLAGS does not conform to the format that make itself produces for
130+# submake. However, make still parses and honors this MAKEFLAGS.
131+# This test checks that make detects '-e' in this MAKEFLAGS.
132+$ENV{MAKEFLAGS} = 'r -Iextramk -ke bye=moon';
133+$ENV{hello} = 'world';
134+run_make_test(q!
135+.RECIPEPREFIX = >
136+$(info value=$(hello), origin=$(origin hello))
137+all:
138+> @echo "value=$(hello), origin=$(origin hello)"
139+> @$(MAKE) -C lib
140+.PHONY: lib all
141+!,
142+              "-s",
143+              "value=world, origin=environment override\nvalue=world, origin=environment override\n".
144+              "in submake value=world, origin=environment override\nvalue=world, origin=environment override");
145+
146+1;
+164, -0
  1@@ -0,0 +1,164 @@
  2+#                                                                    -*-perl-*-
  3+$description = "The following test tests that if you specify greater \n"
  4+              ."than one '-f makefilename' on the command line, \n"
  5+              ."that make concatenates them.  This test creates three \n"
  6+              ."makefiles and specifies all of them with the -f option \n"
  7+              ."on the command line.  To make sure they were concatenated, \n"
  8+              ."we then call make with the rules from the concatenated \n"
  9+              ."makefiles one at a time.  Finally, it calls all three \n"
 10+              ."rules in one call to make and checks that the output\n"
 11+              ."is in the correct order.";
 12+
 13+$makefile2 = &get_tmpfile;
 14+$makefile3 = &get_tmpfile;
 15+
 16+open(MAKEFILE,"> $makefile");
 17+
 18+# The Contents of the MAKEFILE ...
 19+
 20+print MAKEFILE "all: \n";
 21+print MAKEFILE "\t\@echo This is the output from the original makefile\n";
 22+
 23+# END of Contents of MAKEFILE
 24+
 25+close(MAKEFILE);
 26+
 27+# Create a second makefile
 28+open(MAKEFILE,"> $makefile2");
 29+print MAKEFILE "TWO: \n";
 30+print MAKEFILE "\t\@echo This is the output from makefile 2\n";
 31+close(MAKEFILE);
 32+
 33+# Create a third makefile
 34+open(MAKEFILE,"> $makefile3");
 35+print MAKEFILE "THREE: \n";
 36+print MAKEFILE "\t\@echo This is the output from makefile 3\n";
 37+close(MAKEFILE);
 38+
 39+
 40+# Create the answer to what should be produced by this Makefile
 41+$answer = "This is the output from the original makefile\n";
 42+
 43+# Run make to catch the default rule
 44+&run_make_with_options($makefile,"-f $makefile2 -f $makefile3",&get_logfile,0);
 45+
 46+&compare_output($answer,&get_logfile(1));
 47+
 48+
 49+# Run Make again with the rule from the second makefile: TWO
 50+$answer = "This is the output from makefile 2\n";
 51+
 52+&run_make_with_options($makefile,"-f $makefile2 -f $makefile3 TWO",&get_logfile,0);
 53+
 54+&compare_output($answer,&get_logfile(1));
 55+
 56+
 57+# Run Make again with the rule from the third makefile: THREE
 58+
 59+$answer = "This is the output from makefile 3\n";
 60+&run_make_with_options($makefile,
 61+                       "-f $makefile2 -f $makefile3 THREE",
 62+                       &get_logfile,
 63+                       0);
 64+&compare_output($answer,&get_logfile(1));
 65+
 66+
 67+# Run Make again with ALL three rules in the order 2 1 3 to make sure
 68+# that all rules are executed in the proper order
 69+
 70+$answer = "This is the output from makefile 2\n";
 71+$answer .= "This is the output from the original makefile\n";
 72+$answer .= "This is the output from makefile 3\n";
 73+&run_make_with_options($makefile,
 74+                       "-f $makefile2 -f $makefile3 TWO all THREE",
 75+                       &get_logfile,
 76+                       0);
 77+&compare_output($answer,&get_logfile(1));
 78+
 79+
 80+# sv 62118.
 81+# Validate all sorts of -f etc. options
 82+
 83+my $hello = 'hello.mk';
 84+my $bye = 'bye.mk';
 85+my $byesrc = 'bye.mk.src';
 86+
 87+create_file($hello, 'all:; $(info hello, world)
 88+');
 89+
 90+create_file($bye, 'def:; $(info bye, world)
 91+bye.mk: bye.mk.src; touch $@
 92+bye.mk.src:; touch $@
 93+');
 94+
 95+# These invocations use the empty filename string so that the test framework
 96+# doesn't add any -f options on its own.
 97+
 98+# Incorrect order of options. -R follows -f.
 99+# Invocation of make is equivalent to
100+#   echo 'all:; $(info hello, world)' | make -f bye.mk -fR - all
101+# There is bye.mk, but there is no 'R'.
102+# make runs the recipes from bye.mk and prints the error about missing 'R'.
103+
104+# Ensure the newly created bye.src.mk is newer than bye.mk.
105+&utouch(-600, $bye);
106+run_make_test('', "-f$bye -fR - all", "#MAKE#: R: No such file or directory
107+touch bye.mk.src
108+touch bye.mk
109+#MAKE#: *** No rule to make target 'R'.  Stop.
110+", 512);
111+
112+my @opts;
113+my $answer;
114+
115+# Test double -f-.
116+@opts = ('-f- -f-', '-f - -f -', '-f- -f -', '-f - -f-',
117+         '-f- --file=-', '-f- --file -', '-f - --file=-', '-f - --file -',
118+         '-f- --makefile=-', '-f- --makefile -',
119+         '-f - --makefile=-', '-f - --makefile -',
120+         '--file=- --makefile=-', '--file=- --makefile -',
121+         '--file - --makefile=-', '--file - --makefile -');
122+
123+for my $opt (@opts) {
124+    # We shouldn't need this; if the options are wrong then make shouldn't try
125+    # to read from stdin.
126+    close(STDIN);
127+    open(STDIN, "<", $hello) || die "$0: cannot open $hello for reading: $!";
128+    run_make_test('', "-f$bye $opt", "#MAKE#: *** Makefile from standard input specified twice.  Stop.\n", 512);
129+}
130+
131+# -f is not followed by filename.
132+@opts = ('-f', '--file', '--makefile');
133+$answer = "/requires an argument/";
134+for my $opt (@opts) {
135+    run_make_test('', $opt, $answer, 512);
136+}
137+
138+# Test that make correctly parses all possible syntaxes to pipe make code to
139+# the standard input.
140+
141+$answer = "touch bye.mk.src
142+touch bye.mk
143+hello, world
144+#MAKE#: 'all' is up to date.\n";
145+
146+@opts = ('-f- all', '-f - all', '-Rf- all', '-Rf - all',
147+         '--file=- all', '--file - all',
148+         '--makefile=- all', '--makefile - all');
149+for my $opt (@opts) {
150+    unlink($byesrc);
151+    close(STDIN);
152+    open(STDIN, "<", $hello) || die "$0: cannot open $hello for reading: $!";
153+    # Ensure the newly created bye.src.mk is newer than bye.mk.
154+    &utouch(-600, $bye);
155+
156+    run_make_test('', "-f$bye $opt", $answer);
157+}
158+
159+
160+# This close MUST come at the end of the test!!
161+close(STDIN);
162+unlink($hello, $bye, $byesrc);
163+
164+# This tells the test driver that the perl test script executed properly.
165+1;
+116, -0
  1@@ -0,0 +1,116 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test the make -k (don't stop on error) option.\n";
  5+
  6+$details = "\
  7+The makefile created in this test is a simulation of building
  8+a small product.  However, the trick to this one is that one
  9+of the dependencies of the main target does not exist.
 10+Without the -k option, make would fail immediately and not
 11+build any part of the target.  What we are looking for here,
 12+is that make builds the rest of the dependencies even though
 13+it knows that at the end it will fail to rebuild the main target.";
 14+
 15+open(MAKEFILE,"> $makefile");
 16+
 17+# The Contents of the MAKEFILE ...
 18+
 19+print MAKEFILE <<EOF;
 20+VPATH = work
 21+edit:  main.o kbd.o commands.o display.o
 22+\t\@echo cc -o edit main.o kbd.o commands.o display.o
 23+
 24+main.o : main.c defs.h
 25+\t\@echo cc -c main.c
 26+
 27+kbd.o : kbd.c defs.h command.h
 28+\t\@echo cc -c kbd.c
 29+
 30+commands.o : command.c defs.h command.h
 31+\t\@echo cc -c commands.c
 32+
 33+display.o : display.c defs.h buffer.h
 34+\t\@echo cc -c display.c
 35+EOF
 36+
 37+# END of Contents of MAKEFILE
 38+
 39+close(MAKEFILE);
 40+
 41+
 42+mkdir('work');
 43+@files_to_touch = ("work${pathsep}main.c","work${pathsep}defs.h",
 44+               "work${pathsep}command.h",
 45+               "work${pathsep}commands.c","work${pathsep}display.c",
 46+               "work${pathsep}buffer.h",
 47+               "work${pathsep}command.c");
 48+
 49+&touch(@files_to_touch);
 50+
 51+if ($vos) {
 52+  $error_code = 3307;
 53+}
 54+else {
 55+  $error_code = 512;
 56+}
 57+
 58+&run_make_with_options($makefile, "-k", &get_logfile, $error_code);
 59+
 60+# Create the answer to what should be produced by this Makefile
 61+$answer = "cc -c main.c
 62+$make_name: *** No rule to make target 'kbd.c', needed by 'kbd.o'.
 63+cc -c commands.c
 64+cc -c display.c
 65+$make_name: Target 'edit' not remade because of errors.\n";
 66+
 67+# COMPARE RESULTS
 68+
 69+&compare_output($answer, &get_logfile(1));
 70+
 71+unlink(@files_to_touch) unless $keep;
 72+
 73+
 74+# TEST 1: Make sure that top-level targets that depend on targets that
 75+# previously failed to build, aren't attempted.  Regression for PR/1634.
 76+
 77+$makefile2 = &get_tmpfile;
 78+
 79+open(MAKEFILE, "> $makefile2");
 80+print MAKEFILE <<'EOF';
 81+.SUFFIXES:
 82+
 83+all: exe1 exe2; @echo making $@
 84+
 85+exe1 exe2: lib; @echo cp $^ $@
 86+
 87+lib: foo.o; @echo cp $^ $@
 88+
 89+foo.o: ; exit 1
 90+EOF
 91+
 92+close(MAKEFILE);
 93+
 94+&run_make_with_options($makefile2, "-k", &get_logfile, $error_code);
 95+
 96+$answer = "exit 1
 97+$make_name: *** [$makefile2:9: foo.o] Error 1
 98+$make_name: Target 'all' not remade because of errors.\n";
 99+
100+&compare_output($answer, &get_logfile(1));
101+
102+# TEST -- make sure we keep the error code if we can't create an included
103+# makefile.
104+
105+if (defined $ERR_no_such_file) {
106+    run_make_test('all: ; @echo hi
107+include ifile
108+ifile: no-such-file; exit 1
109+',
110+                  '-k',
111+                  "#MAKEFILE#:2: ifile: $ERR_no_such_file
112+#MAKE#: *** No rule to make target 'no-such-file', needed by 'ifile'.
113+#MAKEFILE#:2: failed to remake makefile 'ifile'",
114+                  512);
115+}
116+
117+1;
+46, -0
 1@@ -0,0 +1,46 @@
 2+#                                                                    -*-perl-*-
 3+# Date: Tue, 11 Aug 1992 09:34:26 -0400
 4+# From: pds@lemming.webo.dg.com (Paul D. Smith)
 5+
 6+$description = "Test load balancing (-l) option.";
 7+
 8+$details = "\
 9+This test creates a makefile where all depends on three rules
10+which contain the same body.  Each rule checks for the existence
11+of a temporary file; if it exists an error is generated.  If it
12+doesn't exist then it is created, the rule sleeps, then deletes
13+the temp file again.  Thus if any of the rules are run in
14+parallel the test will fail.  When make is called in this test,
15+it is given the -l option with a value of 0.0001.  This ensures
16+that the load will be above this number and make will therefore
17+decide that it cannot run more than one job even though -j 4 was
18+also specified on the command line.";
19+
20+# On Windows a very different algorithm is used.
21+$port_type eq 'W32' and return -1;
22+
23+open(MAKEFILE,"> $makefile");
24+printf MAKEFILE subst_make_string(q!
25+test = #HELPER# noexist test-file file test-file sleep 2 rm test-file
26+
27+all : ONE TWO THREE
28+ONE : ; @$(test)
29+TWO : ; @$(test)
30+THREE : ; @$(test)
31+!);
32+close(MAKEFILE);
33+my $ans = "noexist test-file\nfile test-file\nsleep 2\nrm test-file\n";
34+
35+$mkoptions = "-l 0.0001";
36+$mkoptions .= " -j 4" if ($parallel_jobs);
37+
38+# We have to wait longer than the default (5s).
39+&run_make_with_options($makefile, $mkoptions, &get_logfile, 0, 10);
40+
41+$slurp = &read_file_into_string(&get_logfile(1));
42+if ($slurp =~ /cannot enforce load limit/) {
43+  return -1;
44+}
45+&compare_output("$ans$ans$ans", &get_logfile(1));
46+
47+1;
+158, -0
  1@@ -0,0 +1,158 @@
  2+#                                                                    -*-perl-*-
  3+$description = "Test the -n option.\n";
  4+
  5+$details = "Try various uses of -n and ensure they all give the correct results.\n";
  6+
  7+touch('orig');
  8+
  9+run_make_test(q!
 10+final: intermediate ; echo >> $@
 11+intermediate: orig ; echo >> $@
 12+!,
 13+              '', "echo >> intermediate\necho >> final\n");
 14+
 15+# TEST 1
 16+
 17+run_make_test(undef, '-Worig -n', "echo >> intermediate\necho >> final\n");
 18+
 19+# We consider the actual updated timestamp of targets with all
 20+# recursive commands, even with -n.  Switching this to the new model
 21+# is non-trivial because we use a trick below to change the log content
 22+# before we compare it ...
 23+
 24+$makefile2 = &get_tmpfile;
 25+
 26+open(MAKEFILE, "> $makefile2");
 27+
 28+print MAKEFILE <<'EOF';
 29+.SUFFIXES:
 30+BAR =     # nothing
 31+FOO = +$(BAR)
 32+a: b; echo > $@
 33+b: c; $(FOO)
 34+EOF
 35+
 36+close(MAKEFILE);
 37+
 38+&utouch(-20, 'b');
 39+&utouch(-10, 'a');
 40+&touch('c');
 41+
 42+# TEST 2
 43+
 44+&run_make_with_options($makefile2, "", &get_logfile);
 45+$answer = "$make_name: 'a' is up to date.\n";
 46+&compare_output($answer, &get_logfile(1));
 47+
 48+# TEST 3
 49+
 50+&run_make_with_options($makefile2, "-n", &get_logfile);
 51+$answer = "$make_name: 'a' is up to date.\n";
 52+&compare_output($answer, &get_logfile(1));
 53+
 54+# TEST 4
 55+
 56+unlink(qw(a b));
 57+
 58+&run_make_with_options($makefile2, "-t -n", &get_logfile);
 59+
 60+open(DASH_N_LOG, ">>" . &get_logfile(1));
 61+print DASH_N_LOG "a exists but should not!\n" if -e 'a';
 62+print DASH_N_LOG "b exists but should not!\n" if -e 'b';
 63+close(DASH_N_LOG);
 64+
 65+&compare_output("touch b\ntouch a\n", &get_logfile(1));
 66+
 67+# Ensure -n continues to be included with recursive/re-execed make
 68+# See Savannah bug #38051
 69+
 70+$topmake = &get_tmpfile;
 71+$submake = &get_tmpfile;
 72+
 73+open(MAKEFILE, "> $topmake");
 74+print MAKEFILE <<"EOF";
 75+foo: ; \@\$(MAKE) -f "$submake" bar
 76+EOF
 77+close(MAKEFILE);
 78+
 79+# The bar target should print what would happen, but not actually run
 80+open(MAKEFILE, "> $submake");
 81+print MAKEFILE <<'EOF';
 82+inc: ; touch $@
 83+-include inc
 84+bar: ; @echo $(strip $(MAKEFLAGS))
 85+EOF
 86+close(MAKEFILE);
 87+
 88+&run_make_with_options($topmake, '-n --no-print-directory', &get_logfile);
 89+$answer = subst_make_string("#MAKEPATH# -f \"$submake\" bar\ntouch inc\necho n --no-print-directory\n");
 90+&compare_output($answer, &get_logfile(1));
 91+
 92+# SV 65917: Verify handling of -n with multi-target pattern rules
 93+
 94+# This is what the makefile below would run
 95+utouch(-12, qw(alpha.p));
 96+utouch(-10, qw(alpha.x alpha.y));
 97+utouch(-8, qw(beta.p));
 98+utouch(-6, qw(beta.x beta.y));
 99+utouch(-4, qw(alpha.q));
100+utouch(-2, qw(beta.q));
101+
102+# Now make some things out of date
103+touch(qw(alpha.p));
104+
105+run_make_test(q!
106+.SUFFIXES:
107+.RECIPEPREFIX := >
108+
109+all: alpha.q beta.q
110+
111+alpha.p beta.p:
112+> touch $@
113+
114+%.x %.y: %.p
115+> touch $*.x $*.y
116+
117+alpha.q: alpha.x alpha.y beta.y
118+> touch $@
119+
120+beta.q: beta.x beta.y alpha.y
121+> touch $@
122+!,
123+    '-n', "touch alpha.x alpha.y\ntouch alpha.q\ntouch beta.q\n");
124+
125+# This is what the makefile below would run
126+utouch(-12, qw(quark.p));
127+utouch(-10, qw(quark.x quark.y));
128+utouch(-8, qw(meson.p));
129+utouch(-6, qw(meson.x meson.y));
130+utouch(-4, qw(quark.q));
131+utouch(-2, qw(meson.q));
132+
133+# Now make some things out of date
134+touch(qw(quark.p));
135+
136+run_make_test(q!
137+.SUFFIXES:
138+.RECIPEPREFIX := >
139+
140+all: quark.q meson.q
141+
142+quark.p meson.p:
143+> touch $@
144+
145+quark.x quark.y &: quark.p
146+> touch quark.x quark.y
147+
148+meson.x meson.y &: meson.p
149+> touch meson.x meson.y
150+
151+quark.q: quark.x quark.y meson.y
152+> touch $@
153+
154+meson.q: meson.x meson.y quark.y
155+> touch $@
156+!,
157+    '-n', "touch quark.x quark.y\ntouch quark.q\ntouch meson.q\n");
158+
159+1;
+86, -0
 1@@ -0,0 +1,86 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Test the -q option.\n";
 4+
 5+$details = "Try various uses of -q and ensure they all give the correct results.\n";
 6+
 7+# TEST 0
 8+
 9+run_make_test(qq!
10+one:
11+two: ;
12+three: ; :
13+four: ; \$(.XY)
14+five: ; \\
15+ \$(.XY)
16+six: ; \\
17+ \$(.XY)
18+\t\$(.XY)
19+seven: ; \\
20+ \$(.XY)
21+\t: foo
22+\t\$(.XY)
23+!,
24+              '-q one', '');
25+
26+# TEST 1
27+
28+run_make_test(undef, '-q two', '');
29+
30+# TEST 2
31+
32+run_make_test(undef, '-q three', '', 256);
33+
34+# TEST 3
35+
36+run_make_test(undef, '-q four', '');
37+
38+# TEST 4
39+
40+run_make_test(undef, '-q five', '');
41+
42+# TEST 5
43+
44+run_make_test(undef, '-q six', '');
45+
46+# TEST 6
47+
48+run_make_test(undef, '-q seven', '', 256);
49+
50+# TEST 7 : Savannah bug # 7144
51+
52+run_make_test('
53+one:: ; @echo one
54+one:: ; @echo two
55+',
56+              '-q', '', 256);
57+
58+# TEST 7 : Savannah bug # 42249
59+# Make sure we exit with 1 even for prerequisite updates
60+run_make_test('
61+build-stamp: ; echo $@
62+build-arch: build-stamp
63+build-x: build-arch
64+build-y: build-x
65+',
66+              '-q build-y', '', 256);
67+
68+# TEST 8
69+# Make sure we exit with 2 on error even with -q
70+run_make_test('
71+build-stamp: ; echo $@
72+build-arch: build-stamp-2
73+build-x: build-arch
74+build-y: build-x
75+',
76+              '-q build-y', "#MAKE#: *** No rule to make target 'build-stamp-2', needed by 'build-arch'.  Stop.\n", 512);
77+
78+# TEST 9 : Savannah bug # 47151
79+# Make sure we exit with 1 when invoking a recursive make
80+run_make_test('
81+foo: bar ; echo foo
82+bar: ; @$(MAKE) -f #MAKEFILE# baz
83+baz: ; echo baz
84+',
85+              '-q foo', '', 256);
86+
87+1;
+103, -0
  1@@ -0,0 +1,103 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test removing default rules and variables";
  5+
  6+touch('xxx.c');
  7+
  8+# Simple check
  9+run_make_test("\n", '-r COMPILE.c=echo xxx.o',
 10+              "#MAKE#: *** No rule to make target 'xxx.o'.  Stop.", 512);
 11+
 12+# Make sure we can set it from within the makefile too
 13+run_make_test(q!
 14+COMPILE.c = echo
 15+MAKEFLAGS += -r
 16+!,
 17+              'xxx.o',
 18+              "#MAKE#: *** No rule to make target 'xxx.o'.  Stop.", 512);
 19+
 20+unlink('xxx.c');
 21+
 22+# Simple check for -R
 23+run_make_test(q!
 24+all:;$(info CC='$(CC)')
 25+!,
 26+              '-sR', "CC=''");
 27+
 28+# Make sure we can set -R from within the makefile too
 29+run_make_test(q!
 30+MAKEFLAGS += -R
 31+all:;$(info CC='$(CC)')
 32+!,
 33+              '-s', "CC=''");
 34+
 35+# sv 62356.
 36+# Setting -R in MAKEFLAGS sets -r.
 37+run_make_test(q!
 38+MAKEFLAGS := -R
 39+.PHONY: hello.c
 40+all: hello.o
 41+!, '', "#MAKE#: *** No rule to make target 'hello.o', needed by 'all'.  Stop.", 512);
 42+
 43+my @flavors = ('=', ':=', ':::=', '+=');
 44+
 45+# sv 64107.
 46+
 47+# Use $answer to test that -R in the makefile has the same effect as -R on the
 48+# command line.
 49+
 50+my $answer = "at parse time TEX=\nat build time TEX=\n#MAKE#: 'all' is up to date.\n";
 51+
 52+# Subtest 1.
 53+# First run with -R command line switch.
 54+
 55+for my $fl (@flavors) {
 56+run_make_test("
 57+\$(info at parse time TEX=\$(TEX))
 58+all:; \$(info at build time TEX=\$(TEX))
 59+", '-R', "$answer");
 60+}
 61+
 62+# Subtest 2.
 63+# Set -R in the makefile.
 64+# Also, test that setting -R in MAKEFLAGS takes effect immediately.
 65+
 66+for my $fl (@flavors) {
 67+run_make_test("
 68+\$(info at start time TEX=\$(TEX))
 69+MAKEFLAGS ${fl} -R
 70+\$(info at parse time TEX=\$(TEX))
 71+all:; \$(info at build time TEX=\$(TEX))
 72+", '', "at start time TEX=tex\n$answer");
 73+}
 74+
 75+# Same as above, but also set TEX conditionally.
 76+
 77+$answer = "at parse time TEX=hello\nat build time TEX=hello\n#MAKE#: 'all' is up to date.\n";
 78+
 79+# Subtest 3.
 80+# -R on the command line.
 81+
 82+for my $fl (@flavors) {
 83+run_make_test("
 84+TEX ?= hello
 85+\$(info at parse time TEX=\$(TEX))
 86+all:; \$(info at build time TEX=\$(TEX))
 87+", '-R', "$answer");
 88+}
 89+
 90+# Subtest 4.
 91+# -R in the makefile.
 92+
 93+for my $fl (@flavors) {
 94+run_make_test("
 95+\$(info at start time TEX=\$(TEX))
 96+MAKEFLAGS ${fl} -R
 97+TEX ?= hello
 98+\$(info at parse time TEX=\$(TEX))
 99+all:; \$(info at build time TEX=\$(TEX))
100+", '', "at start time TEX=tex\n$answer");
101+}
102+
103+
104+1;
+26, -0
 1@@ -0,0 +1,26 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the -s (silent) and --no-silent options.\n";
 5+
 6+run_make_test(q!
 7+all: one two
 8+one: ; @echo MAKEFLAGS=$$MAKEFLAGS
 9+two: ; echo two
10+!,
11+              '', "MAKEFLAGS=\necho two\ntwo");
12+
13+run_make_test(undef, '-s', "MAKEFLAGS=s\ntwo");
14+run_make_test(undef, '--silent', "MAKEFLAGS=s\ntwo");
15+run_make_test(undef, '--quiet', "MAKEFLAGS=s\ntwo");
16+
17+run_make_test(undef, '--no-silent', "MAKEFLAGS= --no-silent\necho two\ntwo");
18+
19+run_make_test(undef, '-s --no-silent', "MAKEFLAGS= --no-silent\necho two\ntwo");
20+run_make_test(undef, '--silent --no-silent', "MAKEFLAGS= --no-silent\necho two\ntwo");
21+run_make_test(undef, '--quiet --no-silent', "MAKEFLAGS= --no-silent\necho two\ntwo");
22+
23+run_make_test(undef, '--no-silent -s', "MAKEFLAGS=s\ntwo");
24+run_make_test(undef, '--no-silent --silent', "MAKEFLAGS=s\ntwo");
25+run_make_test(undef, '--no-silent --quiet', "MAKEFLAGS=s\ntwo");
26+
27+1;
+58, -0
 1@@ -0,0 +1,58 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the -t option.\n";
 5+
 6+$details = "Look out for regressions of prior bugs related to -t.\n";
 7+# That means, nobody has even tried to make the tests below comprehensive
 8+
 9+# TEST 0
10+# bug reported by Henning Makholm <henning@makholm.net> on 2001-11-03:
11+#   make 3.79.1 touches only interm-[ab] but reports final-[a] as
12+#   'up to date' without touching them.
13+# The 'obvious' fix didn't work for double-colon rules, so pay special
14+# attention to them.
15+
16+open(MAKEFILE, "> $makefile");
17+print MAKEFILE <<'EOMAKE';
18+final-a: interm-a ; echo >> $@
19+final-b: interm-b ; echo >> $@
20+interm-a:: orig1-a ; echo >> $@
21+interm-a:: orig2-a ; echo >> $@
22+interm-b:: orig1-b ; echo >> $@
23+interm-b:: orig2-b ; echo >> $@
24+EOMAKE
25+close(MAKEFILE);
26+
27+&utouch(-30, 'orig1-a','orig2-b');
28+&utouch(-20, 'interm-a','interm-b');
29+&utouch(-10, 'final-a','final-b');
30+&touch('orig2-a','orig1-b');
31+
32+&run_make_with_options($makefile, "-t final-a final-b", &get_logfile);
33+$answer = "touch interm-a\ntouch final-a\ntouch interm-b\ntouch final-b\n";
34+&compare_output($answer, &get_logfile(1));
35+
36+unlink('orig1-a', 'orig2-a', 'interm-a', 'final-a');
37+unlink('orig1-b', 'orig2-b', 'interm-b', 'final-b');
38+
39+# TEST 1
40+# -t should not touch files with no commands.
41+
42+$makefile2 = &get_tmpfile;
43+
44+open(MAKEFILE, "> $makefile2");
45+print MAKEFILE <<'EOMAKE';
46+
47+PHOOEY: xxx
48+xxx: ; @:
49+
50+EOMAKE
51+close(MAKEFILE);
52+
53+&run_make_with_options($makefile2, "-t", &get_logfile);
54+$answer = "touch xxx\n";
55+&compare_output($answer, &get_logfile(1));
56+
57+unlink('xxx');
58+
59+1;
+44, -0
 1@@ -0,0 +1,44 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the --eval option.";
 5+
 6+$details = "Verify that --eval options take effect,
 7+and are passed to sub-makes.";
 8+
 9+# Verify that --eval is evaluated first
10+run_make_test(q!
11+$(info infile)
12+BAR = bar
13+all: ; @echo all
14+recurse: ; @$(MAKE) -f #MAKEFILE# && echo recurse!,
15+              ['--eval=$(info eval)', 'FOO=$(BAR)'], "eval\ninfile\nall");
16+
17+# Make sure that --eval is handled correctly during recursion
18+run_make_test(undef, ['--no-print-directory', '--eval=$(info eval)', 'recurse'],
19+              "eval\ninfile\neval\ninfile\nall\nrecurse");
20+
21+# Make sure that --eval is not passed in MAKEFLAGS
22+run_make_test(q!
23+all: ; @echo "MAKEFLAGS=$$MAKEFLAGS"
24+!,
25+              ['--eval=$(info eval)'],
26+              "eval\n".'MAKEFLAGS= --eval=$$(info\ eval)');
27+
28+# Make sure that --eval is handled correctly during restarting
29+run_make_test(q!
30+all: ; @echo $@
31+-include gen.mk
32+gen.mk: ; @echo > $@
33+!,
34+              ['--eval=$(info eval)'], "eval\neval\nall");
35+
36+unlink('gen.mk');
37+
38+# Check -E
39+run_make_test(q!
40+BAR = bar
41+all: ; @echo all
42+recurse: ; @$(MAKE) -f #MAKEFILE# && echo recurse!,
43+              ['-E', '$(info eval)', 'FOO=$(BAR)'], "eval\nall");
44+
45+1;
+30, -0
 1@@ -0,0 +1,30 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Test generic option processing.\n";
 4+
 5+# TEST 0
 6+
 7+if (!$parallel_jobs) {
 8+  $answer = "#MAKE#: Parallel jobs (-j) are not supported on this platform.\n#MAKE#: Resetting to single job (-j1) mode.\n1foo\n";
 9+}
10+else {
11+  $answer = "1foo\n";
12+}
13+
14+run_make_test(q!
15+foo 1foo: ; @echo $@
16+!,
17+              "-j 1foo", $answer);
18+
19+# TEST 1
20+
21+# This test prints the usage string; I don't really know a good way to
22+# test it.  I guess I could invoke make with a known-bad option to see
23+# what the usage looks like, then compare it to what I get here... :(
24+
25+# On UNIX I can invoke it with 2>/dev/null, then just check the error code.
26+
27+if ($port_type ne 'W32') {
28+    run_make_test(undef, "-j1foo 2>/dev/null", '', 512);
29+}
30+
31+1;
+70, -0
 1@@ -0,0 +1,70 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the -w option to GNU Make.";
 5+
 6+my $enter = "#MAKE#: Entering directory '#PWD#'";
 7+my $leave = "#MAKE#: Leaving directory '#PWD#'";
 8+
 9+# Simple test without -w
10+run_make_test(q!
11+all: ; @echo hi
12+!,
13+        "", "hi\n");
14+
15+my $ans = "$enter\nhi\n$leave\n";
16+
17+# Simple test with -w
18+run_make_test(undef, "-w", $ans);
19+
20+# Simple test with overriding -w
21+run_make_test(undef, "-w --no-print-directory", "hi\n");
22+
23+# Simple test with overriding --no-print-directory
24+run_make_test(undef, "--no-print-directory --print-directory", $ans);
25+
26+# Test makefile rebuild to ensure no enter/leave
27+run_make_test(q!
28+include foo
29+all: ;@:
30+foo: ; touch foo
31+!,
32+        "", "touch foo\n");
33+unlink('foo');
34+
35+$ans = "$enter\ntouch foo\n$leave\n";
36+
37+# Test makefile rebuild with -w
38+run_make_test(undef, "-w", $ans);
39+unlink('foo');
40+
41+# Test makefile rebuild with -w overridden
42+run_make_test(undef, "-w --no-print-directory", "touch foo\n");
43+unlink('foo');
44+
45+# Test makefile rebuild with --no-print-directory overridden
46+run_make_test(undef, "--no-print-directory --print-directory", $ans);
47+unlink('foo');
48+
49+my $enter1 = "#MAKE#[1]: Entering directory '#PWD#'";
50+my $leave1 = "#MAKE#[1]: Leaving directory '#PWD#'";
51+
52+$ans = "$enter1\nhi\n$leave1\n";
53+
54+# Test makefile recursion with default enter/leave
55+run_make_test(q!
56+all: ;@$(MAKE) -f #MAKEFILE# recurse
57+recurse: ; @echo hi
58+!,
59+        "", $ans);
60+
61+# Disable enter/leave
62+run_make_test(undef, "--no-print-directory", "hi\n");
63+
64+# Re-enable enter/leave
65+$ans = "$enter\n$ans$leave\n";
66+run_make_test(undef, "--no-print-directory -w", $ans);
67+
68+# Override enter/leave
69+run_make_test(undef, "-w --no-print-directory", "hi\n");
70+
71+1;
+32, -0
 1@@ -0,0 +1,32 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the --print-targets option to GNU Make.";
 5+
 6+# Define various things and verify the output
 7+run_make_test(q!
 8+.PHONY: all
 9+all: ;@:
10+
11+# "special" target
12+.BOGUS: ;@:
13+
14+# Check various forms of suffix rule
15+.SUFFIXES: .q
16+.q: ;@:
17+.c.o: ;@:
18+
19+# Not a suffix rule
20+.x.z: ;@:
21+
22+# Verify included files aren't built / don't fail
23+
24+include badfile
25+include goodfile
26+
27+submake: ; $(MAKE) all
28+always: ; +echo always
29+goodfile: ; touch goodfile
30+!,
31+        "--print-targets", "submake\n.x.z\nalways\nall\ngoodfile\n");
32+
33+1;
+128, -0
  1@@ -0,0 +1,128 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test the --shuffle option.";
  5+
  6+$details = "Verify that --shuffle has expected effect on target order and argument order.";
  7+
  8+#
  9+# Test --shuffle=random
 10+#
 11+
 12+# TEST 1: Fixed seed should yield the same order from run to run.
 13+
 14+$makefile = &get_tmpfile;
 15+
 16+open(MAKEFILE, "> $makefile");
 17+print MAKEFILE <<'EOF';
 18+# More target prerequisites lower collision chance in TEST 2
 19+all: a_ b_ c_ d_ e_ f_ g_ i_ j_ k_ l_
 20+%: ; echo $@
 21+EOF
 22+close(MAKEFILE);
 23+
 24+$log1 = &get_logfile;
 25+$log2 = &get_logfile;
 26+&run_make_with_options($makefile, "--shuffle=12345", $log1);
 27+&run_make_with_options($makefile, "--shuffle=12345", $log2);
 28+
 29+&compare_output(&read_file_into_string($log1), $log2);
 30+
 31+# TEST 2: Sequential runs should produce different orders.
 32+
 33+$log3 = &get_logfile;
 34+$log4 = &get_logfile;
 35+&run_make_with_options($makefile, "--shuffle", $log3);
 36+&run_make_with_options($makefile, "--shuffle", $log4);
 37+
 38+++$tests_run;
 39+if (&read_file_into_string($log3) ne &read_file_into_string($log4)) {
 40+  print "ok\n" if $debug;
 41+  ++$tests_passed;
 42+}
 43+
 44+#
 45+# Test --shuffle=reverse
 46+#
 47+
 48+run_make_test('
 49+%: ; @echo $@
 50+all: a b c
 51+',
 52+              '--shuffle=reverse', "c\nb\na\nall");
 53+
 54+run_make_test('
 55+%: ; @echo $@
 56+all: a b c
 57+',
 58+              '--shuffle=none', "a\nb\nc\nall");
 59+
 60+run_make_test('
 61+%: ; @echo $@
 62+all: a b c
 63+',
 64+              '--shuffle=identity', "a\nb\nc\nall");
 65+
 66+# Make sure prerequisites get reverse order and commands don't get affected.
 67+run_make_test('
 68+all: foo.o ; @echo $@
 69+%.o : %.c ; @echo cc -c -o $@ $<
 70+foo.o : foo.c foo.h bar.h baz.h
 71+%.h: ; @echo $@
 72+%.c: ; @echo $@
 73+',
 74+              '--shuffle=reverse',
 75+              "baz.h\nbar.h\nfoo.h\nfoo.c\ncc -c -o foo.o foo.c\nall");
 76+
 77+# Make sure pattern prerequisites get reverse order and commands don't get
 78+# affected.
 79+run_make_test('
 80+all: foo_ ; @echo $@
 81+foo%: arg%1 arg%2 arg%3 arg%4 ; @echo bld $@ $< $(word 3,$^) $(word 2,$^) $(word 4,$^)
 82+
 83+arg%: ; @echo $@
 84+',
 85+              '--shuffle=reverse',
 86+              "arg_4\narg_3\narg_2\narg_1\nbld foo_ arg_1 arg_3 arg_2 arg_4\nall");
 87+
 88+# Check if make can survive circular dependency.
 89+run_make_test('
 90+all: a_ b_ ; @echo $@
 91+%_: ; @echo $@
 92+
 93+a_: b_
 94+b_: a_
 95+',
 96+              '--shuffle=reverse', "#MAKE#: circular a_ <- b_ dependency dropped\na_\nb_\nall");
 97+
 98+# Check if order-only dependencies get reordered.
 99+run_make_test('
100+all: a_ ; @echo $@
101+%_: ; @echo $@
102+a_: b_ c_ | d_ e_
103+',
104+              '--shuffle=reverse', "e_\nd_\nc_\nb_\na_\nall");
105+
106+# Check if goals are reordered.
107+run_make_test('
108+%_: ; @echo $@
109+',
110+              '--shuffle=reverse a_ b_ c_', "c_\nb_\na_");
111+
112+# .NOTPARALLEL should prevent reordering from happening.
113+run_make_test('
114+%_: ; @echo $@
115+# disable shuffling
116+.NOTPARALLEL:
117+',
118+              '--shuffle=reverse a_ b_ c_', "a_\nb_\nc_");
119+
120+# Check if SECONDEXPANSION targets also get reshuffled.
121+run_make_test('
122+.SECONDEXPANSION:
123+all: $$(var)
124+%_: ; @echo $@
125+var = a_ b_ c_
126+',
127+              '--shuffle=reverse', "c_\nb_\na_");
128+
129+1;
 1@@ -0,0 +1,63 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the -L option.";
 5+
 6+$details = "Verify that symlink handling with and without -L works properly.";
 7+
 8+# Only run these tests if the system sypports symlinks
 9+
10+exists $FEATURES{'check-symlink'} or return -1;
11+
12+use File::Spec;
13+
14+# Set up a symlink sym -> dep
15+# We'll make both dep and targ older than sym
16+&utouch(-10, 'dep');
17+&utouch(-5, 'targ');
18+
19+my $dirnm = (File::Spec->splitdir($testpath))[-1];
20+my $dep = File::Spec->catfile(File::Spec->updir(), $dirnm, 'dep');
21+symlink($dep, 'sym') or die "Cannot create symlink sym -> $dep\n";
22+
23+# Without -L, nothing should happen
24+# With -L, it should update targ
25+run_make_test('targ: sym ; @echo make $@ from $<', '',
26+              "#MAKE#: 'targ' is up to date.");
27+run_make_test(undef, '-L', "make targ from sym");
28+
29+# Now update dep; in all cases targ should be out of date.
30+&touch('dep');
31+run_make_test(undef, '', "make targ from sym");
32+run_make_test(undef, '-L', "make targ from sym");
33+
34+# Now update targ; in all cases targ should be up to date.
35+&touch('targ');
36+run_make_test(undef, '', "#MAKE#: 'targ' is up to date.");
37+run_make_test(undef, '-L', "#MAKE#: 'targ' is up to date.");
38+
39+# Add in a new link between sym and dep.  Be sure it's newer than targ.
40+sleep(1);
41+rename('dep', 'dep1');
42+symlink('dep1', 'dep');
43+
44+# Without -L, nothing should happen
45+# With -L, it should update targ
46+run_make_test(undef, '', "#MAKE#: 'targ' is up to date.");
47+run_make_test(undef, '-L', "make targ from sym");
48+
49+rmfiles('targ', 'dep', 'sym', 'dep1');
50+
51+# Check handling when symlinks point to non-existent files.  Without -L we
52+# should get an error: with -L we should use the timestamp of the symlink.
53+
54+symlink("../$dirnm/dep", 'sym');
55+run_make_test('targ: sym ; @echo make $@ from $<', '',
56+              "#MAKE#: *** No rule to make target 'sym', needed by 'targ'.  Stop.", 512);
57+
58+run_make_test('targ: sym ; @echo make $@ from $<', '-L',
59+              'make targ from sym');
60+
61+
62+rmfiles('targ', 'sym');
63+
64+1;
+182, -0
  1@@ -0,0 +1,182 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test the --warn option.";
  5+
  6+my %warn_test = (
  7+    '--warn' => '', '--warn=warn' => '', '--warn=error --warn=warn' => '',
  8+    '--warn --warn=error' => '=error',
  9+    '--warn=ignore --warn=error --warn=ignore --warn=invalid-ref,invalid-var,undefined-var' => '=ignore,invalid-ref,invalid-var,undefined-var',
 10+    '--warn=invalid-ref:ignore --warn=error --warn=invalid-var:warn,,,,,undefined-var:error,,,,,' => '=error,invalid-ref:ignore,invalid-var,undefined-var:error'
 11+);
 12+
 13+# Verify the deprecated --warn-undefined-variables option
 14+run_make_test(q!
 15+$(info MF=$(MAKEFLAGS))
 16+all:; @#HELPER# env MAKEFLAGS
 17+!,
 18+              '--warn-undefined-variables', "MF= --warn=undefined-var\nMAKEFLAGS= --warn=undefined-var");
 19+
 20+# sv 64115.
 21+# Verify that -R along with --warn-undefined-variables do not warn about
 22+# internal variables, such as GNUMAKEFLAGS.
 23+
 24+run_make_test(q!
 25+$(info MF=$(MAKEFLAGS))
 26+all:; @#HELPER# env MAKEFLAGS
 27+!,
 28+              '-R --warn-undefined-variables', "MF=rR --warn=undefined-var\nMAKEFLAGS=rR --warn=undefined-var");
 29+
 30+
 31+# Verify parsing of --warn in various forms.
 32+
 33+while (my ($f, $r) = each %warn_test) {
 34+    run_make_test(undef, $f, "MF= --warn$r\nMAKEFLAGS= --warn$r");
 35+}
 36+
 37+# Verify that values set in MAKEFLAGS take effect
 38+
 39+while (my ($f, $r) = each %warn_test) {
 40+    run_make_test(qq!
 41+MAKEFLAGS += $f
 42+\$(info MF=\$(MAKEFLAGS))
 43+all:; \@#HELPER# env MAKEFLAGS
 44+!,
 45+                  '', "MF= --warn$r\nMAKEFLAGS= --warn$r");
 46+}
 47+
 48+# Verify that make's special variables don't warn even if they're not set
 49+run_make_test(q!
 50+vars := $(.VARIABLES) $(MAKECMDGOALS) $(MAKE_RESTARTS) $(CURDIR)
 51+vars += $(GNUMAKEFLAGS) $(MAKEFLAGS) $(MFLAGS) $(MAKE_COMMAND) $(MAKE)
 52+vars += $(MAKEFILE_LIST) $(MAKEOVERRIDES) $(-*-command-variables-*-)
 53+vars += $(.RECIPEPREFIX) $(.LOADED) $(.FEATURES)
 54+vars += $(SHELL) $(.SHELLFLAGS) $(MAKE_TERMOUT) $(MAKE_TERMERR)
 55+vars += $(.DEFAULT) $(.DEFAULT_GOAL) $(-*-eval-flags-*-) $(SUFFIXES)
 56+vars += $(VPATH) $(GPATH)
 57+all:;
 58+!,
 59+              '--warn=undefined-var', "#MAKE#: 'all' is up to date.");
 60+
 61+# sv 63609.
 62+# Test for buffer overrun in warn_undefined.
 63+run_make_test(q!
 64+all:;
 65+X := $(averyveryveryloooooooooooooooooooooooooooongvariablename)
 66+!,
 67+              '--warn=undefined-var',
 68+              "#MAKEFILE#:3: warning: reference to undefined variable 'averyveryveryloooooooooooooooooooooooooooongvariablename'
 69+#MAKE#: 'all' is up to date.\n"
 70+);
 71+
 72+# Check undefined variable warnings
 73+
 74+# With no options or with ignore, nothing should happen
 75+run_make_test('
 76+EMPTY =
 77+EREF = $(EMPTY)
 78+UREF = $(UNDEFINED)
 79+
 80+SEREF := $(EREF)
 81+SUREF := $(UREF)
 82+
 83+all: ; @echo ref $(EREF) $(UREF)',
 84+              '', 'ref');
 85+
 86+run_make_test(undef, '--warn=undefined-var:ignore', 'ref');
 87+
 88+# Check warnings
 89+run_make_test(undef, '--warn=undefined-var',
 90+              "#MAKEFILE#:7: warning: reference to undefined variable 'UNDEFINED'
 91+#MAKEFILE#:9: warning: reference to undefined variable 'UNDEFINED'
 92+ref");
 93+
 94+# Check and errors
 95+run_make_test(undef, '--warn=undefined-var:error',
 96+              "#MAKEFILE#:7: *** reference to undefined variable 'UNDEFINED'.  Stop.", 512);
 97+
 98+# Check invalid variable reference warnings
 99+
100+# With no options we still check for invalid references
101+run_make_test('
102+IREF = $(bad variable)
103+SIREF := $(IREF)
104+
105+define nl
106+
107+
108+endef
109+
110+all: ; @echo ref $(also$(nl)bad) $(IREF) $(SIREF)',
111+              '', "#MAKEFILE#:2: warning: invalid variable reference 'bad variable'
112+#MAKEFILE#:10: warning: invalid variable reference 'also\nbad'
113+#MAKEFILE#:2: warning: invalid variable reference 'bad variable'
114+ref");
115+
116+run_make_test(undef, '--warn=ignore', 'ref');
117+
118+run_make_test(undef, '--warn=invalid-ref:ignore', 'ref');
119+
120+# Check and errors
121+run_make_test(undef, '--warn=invalid-ref:error',
122+              "#MAKEFILE#:2: *** invalid variable reference 'bad variable'.  Stop.", 512);
123+
124+# Check invalid variable name warnings
125+
126+# With no options we still check for invalid references
127+run_make_test('
128+EMPTY =
129+SPACE = $(EMPTY) $(EMPTY)
130+BAD$(SPACE)VAR = foo
131+
132+define nl
133+
134+
135+endef
136+
137+NL$(nl)VAR = bar
138+
139+define BAD$(SPACE)DEF :=
140+foo
141+endef
142+
143+define NL$(nl)DEF :=
144+foo
145+endef
146+
147+all: ; @echo ref',
148+              '', "#MAKEFILE#:4: warning: invalid variable name 'BAD VAR'
149+#MAKEFILE#:11: warning: invalid variable name 'NL\nVAR'
150+#MAKEFILE#:13: warning: invalid variable name 'BAD DEF'
151+#MAKEFILE#:17: warning: invalid variable name 'NL\nDEF'
152+ref");
153+
154+run_make_test(undef, '--warn=ignore', 'ref');
155+
156+run_make_test(undef, '--warn=invalid-var:ignore', 'ref');
157+
158+# Check errors
159+run_make_test(undef, '--warn=invalid-var:error',
160+              "#MAKEFILE#:4: *** invalid variable name 'BAD VAR'.  Stop.", 512);
161+
162+# Make sure unknown warnings and actions fail when given on the command line.
163+
164+run_make_test(undef, '--warn=no-such-warn',
165+    "#MAKE#: *** unknown warning 'no-such-warn'.  Stop.", 512);
166+
167+run_make_test(undef, '--warn=invalid-var:no-such-action',
168+    "#MAKE#: *** unknown warning action 'no-such-action'.  Stop.", 512);
169+
170+# sv 65739. Circular dependency.
171+run_make_test(q!
172+hello: hello; @:
173+!,
174+              '', "#MAKE#: circular hello <- hello dependency dropped\n");
175+
176+run_make_test(undef, '--warn=error', "#MAKE#: *** circular hello <- hello dependency detected.  Stop.\n", 512);
177+run_make_test(undef, '--warn=circular-dep:error', "#MAKE#: *** circular hello <- hello dependency detected.  Stop.\n", 512);
178+run_make_test(undef, '--warn=warn', "#MAKE#: circular hello <- hello dependency dropped\n");
179+run_make_test(undef, '--warn=circular-dep:warn', "#MAKE#: circular hello <- hello dependency dropped\n");
180+run_make_test(undef, '--warn=ignore', '');
181+run_make_test(undef, '--warn=circular-dep:ignore', '');
182+
183+1;
+35, -0
 1@@ -0,0 +1,35 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "The following test creates a makefile to override part\n"
 5+              ."of one Makefile with Another Makefile with the .DEFAULT\n"
 6+              ."rule.";
 7+
 8+$details = "This tests the use of the .DEFAULT special target to say that \n"
 9+          ."to remake any target that cannot be made fram the information\n"
10+          ."in the containing makefile, make should look in another makefile\n"
11+          ."This test gives this makefile the target bar which is not \n"
12+          ."defined here but passes the target bar on to another makefile\n"
13+          ."which does have the target bar defined.\n";
14+
15+create_file('defsub.mk', q!
16+bar: ; @echo Executing rule BAR
17+!);
18+
19+run_make_test(q!
20+foo:; @echo Executing rule FOO
21+
22+.DEFAULT: ; @$(MAKE) -f defsub.mk $@
23+!,
24+                       'bar',"#MAKE#[1]: Entering directory '#PWD#'\n"
25+                       . "Executing rule BAR\n"
26+                       . "#MAKE#[1]: Leaving directory '#PWD#'\n");
27+
28+unlink('defsub.mk');
29+
30+1;
31+
32+
33+
34+
35+
36+
+22, -0
 1@@ -0,0 +1,22 @@
 2+#! -*-perl-*-
 3+
 4+$description = "Test the behaviour of the .DELETE_ON_ERROR target.";
 5+
 6+$details = "";
 7+
 8+run_make_test('
 9+.DELETE_ON_ERROR:
10+all: ; exit 1 > $@
11+',
12+              '', "exit 1 > all\n#MAKE#: *** [#MAKEFILE#:3: all] Error 1\n#MAKE#: *** deleting file 'all'", 512);
13+
14+run_make_test('
15+.DELETE_ON_ERROR:
16+all: foo.x ;
17+%.x : %.q ; echo > $@
18+%.q : ; exit 1 > $@
19+',
20+              '', "exit 1 > foo.q\n#MAKE#: *** [#MAKEFILE#:5: foo.q] Error 1\n#MAKE#: *** deleting file 'foo.q'", 512);
21+
22+# This tells the test driver that the perl test script executed properly.
23+1;
+19, -0
 1@@ -0,0 +1,19 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "The following tests rules without Commands or Dependencies.";
 5+
 6+# Create a file named "clean".  This is the same name as the target clean
 7+# and tricks the target into thinking that it is up to date.  (Unless you
 8+# use the .PHONY target.
 9+touch('clean');
10+
11+run_make_test(qq!
12+.IGNORE :
13+clean: FORCE ; $CMD_rmfile clean
14+FORCE:
15+!,
16+              '', "$CMD_rmfile clean");
17+
18+rmfiles('clean');
19+
20+1;
+28, -0
 1@@ -0,0 +1,28 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the behaviour of the .IGNORE target.";
 5+
 6+$details = "";
 7+
 8+# Without any ignore
 9+run_make_test(q!
10+all: ; @#HELPER# -q fail 1
11+!,
12+              '', "#MAKE#: *** [#MAKEFILE#:2: all] Error 1", 512);
13+
14+# Global .IGNORE
15+run_make_test(q!
16+.IGNORE:
17+all: ; @#HELPER# -q fail 1
18+!,
19+              '', "#MAKE#: [#MAKEFILE#:3: all] Error 1 (ignored)");
20+
21+# Specific .IGNORE
22+
23+run_make_test(q!
24+.IGNORE: all
25+all: ; @#HELPER# -q fail 1
26+!,
27+              '', "#MAKE#: [#MAKEFILE#:3: all] Error 1 (ignored)");
28+
29+1;
+108, -0
  1@@ -0,0 +1,108 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test the behaviour of the .INTERMEDIATE target.";
  5+
  6+$details = "\
  7+Test the behavior of the .INTERMEDIATE special target.
  8+Create a makefile where a file would not normally be considered
  9+intermediate, then specify it as .INTERMEDIATE.  Build and ensure it's
 10+deleted properly.  Rebuild to ensure that it's not created if it doesn't
 11+exist but doesn't need to be built.  Change the original and ensure
 12+that the intermediate file and the ultimate target are both rebuilt, and
 13+that the intermediate file is again deleted.
 14+
 15+Try this with implicit rules and explicit rules: both should work.\n";
 16+
 17+# TEST #0
 18+
 19+&utouch(-20, 'foo.f', 'bar.f');
 20+
 21+run_make_test(q!
 22+.INTERMEDIATE: foo.e bar.e
 23+
 24+# Implicit rule test
 25+%.d : %.e ; cp $< $@
 26+%.e : %.f ; cp $< $@
 27+
 28+foo.d: foo.e
 29+
 30+# Explicit rule test
 31+foo.c: foo.e bar.e; cat $^ > $@
 32+!,
 33+    'foo.d', "cp foo.f foo.e\ncp foo.e foo.d\nrm foo.e\n");
 34+
 35+# TEST #1
 36+
 37+run_make_test(undef, 'foo.d', "#MAKE#: 'foo.d' is up to date.\n");
 38+
 39+# TEST #2
 40+
 41+&utouch(-10, 'foo.d');
 42+&touch('foo.f');
 43+
 44+run_make_test(undef, 'foo.d', "cp foo.f foo.e\ncp foo.e foo.d\nrm foo.e\n");
 45+
 46+# TEST #3
 47+
 48+run_make_test(undef, 'foo.c', "cp foo.f foo.e\ncp bar.f bar.e\ncat foo.e bar.e > foo.c\nrm foo.e bar.e\n");
 49+
 50+# TEST #4
 51+
 52+run_make_test(undef, 'foo.c', "#MAKE#: 'foo.c' is up to date.\n");
 53+
 54+# TEST #5
 55+
 56+&utouch(-10, 'foo.c');
 57+&touch('foo.f');
 58+
 59+run_make_test(undef, 'foo.c', "cp foo.f foo.e\ncp bar.f bar.e\ncat foo.e bar.e > foo.c\nrm foo.e bar.e\n");
 60+
 61+# TEST #6 -- added for PR/1669: don't remove files mentioned on the cmd line.
 62+
 63+run_make_test(undef, 'foo.e', "cp foo.f foo.e\n");
 64+
 65+unlink('foo.f', 'foo.e', 'foo.d', 'foo.c', 'bar.f', 'bar.e', 'bar.d', 'bar.c');
 66+
 67+# TEST #7 -- added for PR/1423
 68+
 69+run_make_test(q!
 70+all: foo
 71+foo.a: ; touch $@
 72+%: %.a ; touch $@
 73+.INTERMEDIATE: foo.a
 74+!,
 75+              '-R',  "touch foo.a\ntouch foo\nrm foo.a\n");
 76+
 77+unlink('foo');
 78+
 79+# sv 60188.
 80+# A file made by an implicit rule, but explicitly mentioned by the user, is
 81+# still considered intermediate if it's a prereq to .INTERMEDIATE.
 82+
 83+touch('hello.z');
 84+unlink('test.x');
 85+
 86+run_make_test(q!
 87+all: hello.z
 88+%.z: test.x; touch $@
 89+%.x: ;
 90+.INTERMEDIATE: test.x
 91+!, '', "#MAKE#: Nothing to be done for 'all'.\n");
 92+
 93+unlink('hello.z');
 94+
 95+# A target explicitly listed as a prerequisite of a pattern rule, is still
 96+# considered mentioned and "ought to exist".
 97+
 98+run_make_test(q!
 99+1.all: 1.q ; touch $@
100+%.q: 1.r ; touch $@
101+%.r: ; touch $@
102+.INTERMEDIATE: 1.r
103+!,
104+              '', "touch 1.r\ntouch 1.q\ntouch 1.all\nrm 1.r\n");
105+
106+unlink('1.all', '1.q', '1.r');
107+
108+# This tells the test driver that the perl test script executed properly.
109+1;
+116, -0
  1@@ -0,0 +1,116 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test the behaviour of the .NOTINTERMEDIATE target.";
  5+
  6+$details = "\
  7+Test the behavior of the .NOTINTERMEDIATE special target.\n";
  8+
  9+touch('hello.z');
 10+unlink('hello.x');
 11+
 12+
 13+# Test 1. A file which matches a .NOTINTERMEDIATE pattern is not intermediate.
 14+run_make_test(q!
 15+hello.z:
 16+%.z: %.x; touch $@
 17+%.x: ;
 18+.NOTINTERMEDIATE: %.q %.x
 19+!, '', "touch hello.z\n");
 20+
 21+# Test 2. .NOTINTERMEDIATE: %.q pattern has no effect on hello.x.
 22+touch('hello.z');
 23+run_make_test(q!
 24+hello.z:
 25+%.z: %.x; touch $@
 26+%.x: ;
 27+.NOTINTERMEDIATE: %.q
 28+!, '', "#MAKE#: 'hello.z' is up to date.\n");
 29+
 30+# Test 3. A file which is a prereq of .NOTINTERMEDIATE is not intermediate.
 31+run_make_test(q!
 32+hello.z:
 33+%.z: %.x; touch $@
 34+%.x: ;
 35+.NOTINTERMEDIATE: %.q hello.x
 36+!, '', "touch hello.z\n");
 37+
 38+# Test 4. .NOTINTERMEDIATE without prerequisites makes everything
 39+# notintermediate.
 40+run_make_test(q!
 41+hello.z:
 42+%.z: %.x; touch $@
 43+%.x: ;
 44+.NOTINTERMEDIATE:
 45+!, '', "touch hello.z\n");
 46+
 47+# Test 5. Same file cannot be intermediate and notintermediate.
 48+run_make_test(q!
 49+.INTERMEDIATE: hello.x
 50+.NOTINTERMEDIATE: hello.x
 51+!, '', "#MAKE#: *** hello.x cannot be both .NOTINTERMEDIATE and .INTERMEDIATE.  Stop.\n", 512);
 52+
 53+# Test 6. Same file cannot be secondary and notintermediate.
 54+run_make_test(q!
 55+.SECONDARY: hello.x
 56+.NOTINTERMEDIATE: hello.x
 57+!, '', "#MAKE#: *** hello.x cannot be both .NOTINTERMEDIATE and .SECONDARY.  Stop.\n", 512);
 58+
 59+# Test 7. All .SECONDARY and all .NOTINTERMEDIATE are mutually exclusive.
 60+run_make_test(q!
 61+.SECONDARY:
 62+.NOTINTERMEDIATE:
 63+!, '', "#MAKE#: *** .NOTINTERMEDIATE and .SECONDARY are mutually exclusive.  Stop.\n", 512);
 64+
 65+# Test 8. .INTERMEDIATE file takes priority over a .NOTINTERMEDIATE pattern.
 66+unlink('hello.x');
 67+run_make_test(q!
 68+hello.z:
 69+%.z: %.x; touch $@
 70+%.x: ;
 71+.INTERMEDIATE: hello.x
 72+.NOTINTERMEDIATE: %.q %.x
 73+!, '', "#MAKE#: 'hello.z' is up to date.\n");
 74+
 75+# Test 9. Everything is notintermediate, except hello.x.
 76+unlink('hello.x');
 77+run_make_test(q!
 78+hello.z:
 79+%.z: %.x; touch $@
 80+%.x: ;
 81+.INTERMEDIATE: hello.x
 82+.NOTINTERMEDIATE:
 83+!, '', "#MAKE#: 'hello.z' is up to date.\n");
 84+
 85+# Test 10. Everything is notintermediate, except hello.x.
 86+unlink('hello.x');
 87+run_make_test(q!
 88+hello.z:
 89+%.z: %.x; touch $@
 90+%.x: ;
 91+.SECONDARY: hello.x
 92+.NOTINTERMEDIATE:
 93+!, '', "#MAKE#: 'hello.z' is up to date.\n");
 94+
 95+# Test 11. Everything is secondary, except %.q, hello.x.
 96+unlink('hello.x');
 97+run_make_test(q!
 98+hello.z:
 99+%.z: %.x; touch $@
100+%.x: ;
101+.NOTINTERMEDIATE: %.q hello.x
102+.SECONDARY:
103+!, '', "touch hello.z\n");
104+
105+# Test 12. Everything is secondary, except %.q %.x.
106+unlink('hello.x');
107+run_make_test(q!
108+hello.z:
109+%.z: %.x; touch $@
110+%.x: ;
111+.NOTINTERMEDIATE: %.q %.x
112+.SECONDARY:
113+!, '', "touch hello.z\n");
114+
115+unlink('hello.z');
116+# This tells the test driver that the perl test script executed properly.
117+1;
+139, -0
  1@@ -0,0 +1,139 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test the behaviour of the .ONESHELL target.";
  5+
  6+$details = "";
  7+
  8+my $multi_ok = 0;
  9+
 10+if ($port_type ne 'W32') {
 11+    # Some shells (*shakes fist at Solaris*) cannot handle multiple flags in
 12+    # separate arguments.
 13+    my $t = `"$sh_name" -e -c true 2>/dev/null`;
 14+    $multi_ok = $? == 0;
 15+}
 16+
 17+# Simple
 18+
 19+run_make_test(q!
 20+.ONESHELL:
 21+all:
 22+#TAB#a=$$$$
 23+#TAB#[ 0"$$a" -eq "$$$$" ] || echo fail
 24+!,
 25+              '', 'a=$$
 26+[ 0"$a" -eq "$$" ] || echo fail
 27+');
 28+
 29+# Simple but use multi-word SHELLFLAGS
 30+
 31+if ($multi_ok) {
 32+    run_make_test(q!
 33+.ONESHELL:
 34+.SHELLFLAGS = -e -c
 35+all:
 36+#TAB#a=$$$$
 37+#TAB#[ 0"$$a" -eq "$$$$" ] || echo fail
 38+!,
 39+              '', 'a=$$
 40+[ 0"$a" -eq "$$" ] || echo fail
 41+');
 42+}
 43+
 44+# Again, but this time with inner prefix chars
 45+
 46+run_make_test(q!
 47+.ONESHELL:
 48+all:
 49+#TAB#a=$$$$
 50+#TAB#@-+    [ 0"$$a" -eq "$$$$" ] || echo fail
 51+!,
 52+              '', 'a=$$
 53+[ 0"$a" -eq "$$" ] || echo fail
 54+');
 55+
 56+# This time with outer prefix chars
 57+
 58+run_make_test(q!
 59+.ONESHELL:
 60+all:
 61+#TAB#   @a=$$$$
 62+#TAB#    [ 0"$$a" -eq "$$$$" ] || echo fail
 63+!,
 64+              '', '');
 65+
 66+
 67+# This time with outer and inner prefix chars
 68+
 69+run_make_test(q!
 70+.ONESHELL:
 71+all:
 72+#TAB#   @a=$$$$
 73+#TAB#    -@     +[ 0"$$a" -eq "$$$$" ] || echo fail
 74+!,
 75+              '', '');
 76+
 77+
 78+# Now try using a different interpreter
 79+# This doesn't work on Windows right now
 80+if ($port_type ne 'W32') {
 81+    run_make_test(q!
 82+.RECIPEPREFIX = >
 83+.ONESHELL:
 84+SHELL = #PERL#
 85+.SHELLFLAGS = -e
 86+all:
 87+>#TAB#   @$$a=5
 88+>#TAB#    +7;
 89+>#TAB#@y=qw(a b c);
 90+>print "a = $$a, y = (@y)\n";
 91+!,
 92+                  '', "a = 12, y = (a b c)\n");
 93+
 94+    # Simple .SHELLFLAGS, no quotes.
 95+    # sv 61805.
 96+    run_make_test(q!
 97+.ONESHELL:
 98+SHELL = #PERL#
 99+.SHELLFLAGS = -e
100+all:; @print "it works\n"
101+!, '', 'it works');
102+
103+    # Pass a quoted string with spaces to oneshell.
104+    # sv 61805.
105+    run_make_test(q!
106+.ONESHELL:
107+SHELL = #PERL#
108+.SHELLFLAGS = -w -E 'use warnings FATAL => "all";' -E
109+all:; @print "it works\n"
110+!, '', 'it works');
111+
112+    # Empty .SHELLFLAGS.
113+    # sv 61805.
114+    run_make_test(q!
115+.ONESHELL:
116+SHELL = #PERL#
117+.SHELLFLAGS =
118+all:; @print "it works"
119+!, '', "Can't open perl script \"print \"it works\"\": $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:5: all] Error $ERR_no_such_file_code", 512);
120+
121+    # No .SHELLFLAGS.
122+    # sv 61805.
123+    run_make_test(q!
124+.ONESHELL:
125+SHELL = #PERL#
126+all:; @print "it works"
127+!, '', "Can't open perl script \"print \"it works\"\": $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:4: all] Error $ERR_no_such_file_code", 512);
128+
129+    # Pass a quoted string with spaces to oneshell.
130+    # sv 61805.
131+    run_make_test(q!
132+.ONESHELL:
133+SHELL = #PERL#
134+.SHELLFLAGS = -w -E 'use warnings FATAL => "all";' -E 'my $$foo = "bar";' -E
135+all:; @print "it works: $$foo\n"
136+!, '', 'it works: bar');
137+}
138+
139+# This tells the test driver that the perl test script executed properly.
140+1;
+42, -0
 1@@ -0,0 +1,42 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "The following tests the use of a PHONY target.  It makes\n"
 5+              ."sure that the rules under a target get executed even if\n"
 6+              ."a filename of the same name of the target exists in the\n"
 7+              ."directory.\n";
 8+
 9+$details = "This makefile in this test declares the target clean to be a \n"
10+          ."PHONY target.  We then create a file named \"clean\" in the \n"
11+          ."directory.  Although this file exists, the rule under the target\n"
12+          ."clean should still execute because of it's phony status.";
13+
14+$example = "EXAMPLE_FILE";
15+
16+touch($example);
17+
18+# Create a file named "clean".  This is the same name as the target clean
19+# and tricks the target into thinking that it is up to date.  (Unless you
20+# use the .PHONY target.
21+touch('clean');
22+
23+open(MAKEFILE, "> $makefile");
24+print MAKEFILE qq!
25+.PHONY : clean
26+all: ; \@echo This makefile did not clean the dir ... good
27+clean: ; $CMD_rmfile $example clean
28+!;
29+close(MAKEFILE);
30+
31+$answer = "$CMD_rmfile $example clean\n";
32+&run_make_with_options($makefile,"clean",&get_logfile);
33+
34+if (-f $example) {
35+  $test_passed = 0;
36+}
37+
38+&compare_output($answer,&get_logfile(1));
39+
40+# Just in case
41+unlink($example, 'clean');
42+
43+1;
+117, -0
  1@@ -0,0 +1,117 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test the behaviour of the .POSIX target.";
  5+
  6+$details = "";
  7+
  8+
  9+# Ensure turning on .POSIX enables the -e flag for the shell
 10+
 11+run_make_test(q!
 12+.POSIX:
 13+all: ; @#HELPER# -q fail 1; #HELPER# out hello
 14+!,
 15+              '', "#MAKE#: *** [#MAKEFILE#:3: all] Error 1\n", 512);
 16+
 17+# But explicit settings must still take precedence
 18+
 19+run_make_test(q!
 20+.POSIX:
 21+all: ; @-#HELPER# -q fail 1; #HELPER# out hello
 22+.SHELLFLAGS = -c
 23+!,
 24+              '', "hello");
 25+
 26+run_make_test(q!
 27+.POSIX:
 28+all: ; @-#HELPER# -q fail 1; #HELPER# out hello
 29+all: .SHELLFLAGS = -c
 30+!,
 31+              '', "hello");
 32+
 33+# SV 63667: We shouldn't add -e to sh if errors are ignored
 34+
 35+run_make_test(q!
 36+.POSIX:
 37+all: ; @-#HELPER# -q fail 1; #HELPER# out hello
 38+!,
 39+              '', "hello\n");
 40+
 41+# SV 64085: Also don't add -e if -i or .IGNORE is used
 42+
 43+run_make_test(q!
 44+.POSIX:
 45+all: ; @#HELPER# -q fail 1; #HELPER# out hello
 46+!,
 47+              '-i', "hello\n");
 48+
 49+run_make_test(q!
 50+.POSIX:
 51+.IGNORE:
 52+all: ; @#HELPER# -q fail 1; #HELPER# out hello
 53+!,
 54+              '', "hello\n");
 55+
 56+run_make_test(q!
 57+.POSIX:
 58+.IGNORE: all
 59+all: ; @#HELPER# -q fail 1; #HELPER# out hello
 60+!,
 61+              '', "hello\n");
 62+
 63+# But explicit settings must still take precedence
 64+
 65+run_make_test(q!
 66+.POSIX:
 67+all: ; @-#HELPER# -q fail 1; #HELPER# out hello
 68+.SHELLFLAGS = -ec
 69+!,
 70+              '', "#MAKE#: [#MAKEFILE#:3: all] Error 1 (ignored)\n");
 71+
 72+run_make_test(q!
 73+.POSIX:
 74+all: ; @-#HELPER# -q fail 1; #HELPER# out hello
 75+all: .SHELLFLAGS = -ec
 76+!,
 77+              '', "#MAKE#: [#MAKEFILE#:3: all] Error 1 (ignored)\n");
 78+
 79+# User settings must override .POSIX
 80+# In the standard .POSIX must be the first thing in the makefile
 81+# but we relax that rule in GNU Make.
 82+
 83+# Different versions of sh generate different output for -x so check it
 84+my $script = subst_make_string('#HELPER# -q fail 1; true');
 85+my $flags = '-xc';
 86+my $out = `"$sh_name" $flags '$script' 2>&1`;
 87+
 88+run_make_test(qq!
 89+.SHELLFLAGS = $flags
 90+.POSIX:
 91+all: ; \@$script
 92+!,
 93+              '', $out);
 94+
 95+# Test the default value of various POSIX-specific variables
 96+my %POSIX = (AR => 'ar', ARFLAGS => '-rv',
 97+             YACC => 'yacc', YFLAGS => '',
 98+             LEX => 'lex', LFLAGS => '',
 99+             LDFLAGS => '',
100+             CC => 'c99', CFLAGS => '-O1',
101+             FC => 'fort77', FFLAGS => '-O1',
102+             SCCSFLAGS => '', SCCSGETFLAGS => '-s');
103+my $make = join('', map { "\t\@echo '$_=\$($_)'\n" } sort keys %POSIX);
104+my $r = join('', map { "$_=$POSIX{$_}\n"} sort keys %POSIX);
105+run_make_test(qq!
106+.POSIX:
107+all:
108+$make
109+!,
110+              '', $r);
111+
112+# Make sure that local settings take precedence
113+%ENV = (%ENV, map { $_ => "xx-$_" } keys %POSIX);
114+$r = join('', map { "$_=xx-$_\n"} sort keys %POSIX);
115+run_make_test(undef, '', $r);
116+
117+# This tells the test driver that the perl test script executed properly.
118+1;
+189, -0
  1@@ -0,0 +1,189 @@
  2+#! -*-perl-*-
  3+
  4+$description = "Test the behaviour of the .SECONDARY target.";
  5+
  6+$details = "\
  7+Test the behavior of the .SECONDARY special target.
  8+Create a makefile where a file would not normally be considered
  9+intermediate, then specify it as .SECONDARY.  Build and note that it's
 10+not automatically deleted.  Delete the file.  Rebuild to ensure that
 11+it's not created if it doesn't exist but doesn't need to be built.
 12+Change the original and ensure that the secondary file and the ultimate
 13+target are both rebuilt, and that the secondary file is not deleted.
 14+
 15+Try this with implicit rules and explicit rules: both should work.\n";
 16+
 17+open(MAKEFILE,"> $makefile");
 18+
 19+print MAKEFILE <<'EOF';
 20+
 21+.SECONDARY: foo.e
 22+
 23+# Implicit rule test
 24+%.d : %.e ; cp $< $@
 25+%.e : %.f ; cp $< $@
 26+
 27+foo.d: foo.e
 28+
 29+# Explicit rule test
 30+foo.c: foo.e ; cp $< $@
 31+EOF
 32+
 33+close(MAKEFILE);
 34+
 35+# TEST #1
 36+
 37+&utouch(-20, 'foo.f');
 38+
 39+&run_make_with_options($makefile,'foo.d',&get_logfile);
 40+$answer = "cp foo.f foo.e\ncp foo.e foo.d\n";
 41+&compare_output($answer, &get_logfile(1));
 42+
 43+# TEST #2
 44+
 45+unlink('foo.e');
 46+
 47+&run_make_with_options($makefile,'foo.d',&get_logfile);
 48+$answer = "$make_name: 'foo.d' is up to date.\n";
 49+&compare_output($answer, &get_logfile(1));
 50+
 51+# TEST #3
 52+
 53+&utouch(-10, 'foo.d');
 54+&touch('foo.f');
 55+
 56+&run_make_with_options($makefile,'foo.d',&get_logfile);
 57+$answer = "cp foo.f foo.e\ncp foo.e foo.d\n";
 58+&compare_output($answer, &get_logfile(1));
 59+
 60+# TEST #4
 61+
 62+&run_make_with_options($makefile,'foo.c',&get_logfile);
 63+$answer = "cp foo.e foo.c\n";
 64+&compare_output($answer, &get_logfile(1));
 65+
 66+# TEST #5
 67+
 68+unlink('foo.e');
 69+
 70+&run_make_with_options($makefile,'foo.c',&get_logfile);
 71+$answer = "$make_name: 'foo.c' is up to date.\n";
 72+&compare_output($answer, &get_logfile(1));
 73+
 74+# TEST #6
 75+
 76+&utouch(-10, 'foo.c');
 77+&touch('foo.f');
 78+
 79+&run_make_with_options($makefile,'foo.c',&get_logfile);
 80+$answer = "cp foo.f foo.e\ncp foo.e foo.c\n";
 81+&compare_output($answer, &get_logfile(1));
 82+
 83+unlink('foo.f', 'foo.e', 'foo.d', 'foo.c');
 84+
 85+# TEST #7 -- test the "global" .SECONDARY, with no targets.
 86+
 87+$makefile2 = &get_tmpfile;
 88+
 89+open(MAKEFILE, "> $makefile2");
 90+
 91+print MAKEFILE <<'EOF';
 92+.SECONDARY:
 93+
 94+final: intermediate
 95+intermediate: source
 96+
 97+final intermediate source: ; echo $< > $@
 98+EOF
 99+
100+close(MAKEFILE);
101+
102+&utouch(-10, 'source');
103+touch('final');
104+
105+&run_make_with_options($makefile2, '', &get_logfile);
106+$answer = "$make_name: 'final' is up to date.\n";
107+&compare_output($answer, &get_logfile(1));
108+
109+unlink('source', 'final', 'intermediate');
110+
111+
112+# TEST #8 -- test the "global" .SECONDARY, with .PHONY.
113+
114+touch('version2');
115+run_make_test('
116+.PHONY: version
117+.SECONDARY:
118+version2: version ; @echo GOOD
119+all: version2',
120+              'all', 'GOOD');
121+
122+unlink('version2');
123+
124+# TEST #9 -- Savannah bug #15919
125+# The original fix for this bug caused a new bug, shown here.
126+
127+touch(qw(1.a 2.a));
128+
129+run_make_test('
130+%.c : %.b ; cp $< $@
131+%.b : %.a ; cp $< $@
132+all : 1.c 2.c
133+2.a: 1.c', '-rR -j',
134+'cp 1.a 1.b
135+cp 1.b 1.c
136+cp 2.a 2.b
137+cp 2.b 2.c
138+rm 2.b 1.b');
139+
140+unlink(qw(1.a 2.a 1.c 2.c));
141+
142+# TEST #10 -- Savannah bug #15919
143+touch('test.0');
144+run_make_test('
145+.SECONDARY : test.1 test.2 test.3
146+
147+test : test.4
148+
149+%.4 : %.int %.3 ; touch $@
150+
151+%.int : %.3 %.2 ; touch $@
152+
153+%.3 : | %.2 ; touch $@
154+
155+%.2 : %.1 ; touch $@
156+
157+%.1 : %.0 ; touch $@', '-rR -j 2',
158+'touch test.1
159+touch test.2
160+touch test.3
161+touch test.int
162+touch test.4
163+rm test.int');
164+
165+# After a touch of test.0 it should give the same output, except we don't need
166+# to rebuild test.3 (order-only)
167+sleep(1);
168+touch('test.0');
169+run_make_test(undef, '-rR -j 2',
170+'touch test.1
171+touch test.2
172+touch test.int
173+touch test.4
174+rm test.int');
175+
176+# With both test.0 and test.3 updated it should still build everything except
177+# test.3
178+sleep(1);
179+touch('test.0', 'test.3');
180+run_make_test(undef, '-rR -j 2',
181+'touch test.1
182+touch test.2
183+touch test.int
184+touch test.4
185+rm test.int');
186+
187+unlink(qw(test.0 test.1 test.2 test.3 test.4));
188+
189+# This tells the test driver that the perl test script executed properly.
190+1;
+33, -0
 1@@ -0,0 +1,33 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the special target .SILENT.";
 5+
 6+run_make_test(q!
 7+.PHONY: M a b
 8+M: a b
 9+.SILENT : b
10+a b: ; echo $@
11+!,
12+              '', "echo a\na\nb");
13+
14+run_make_test(q!
15+.PHONY: M a b
16+M: a b
17+.SILENT:
18+a b: ; echo $@
19+!,
20+              '', "a\nb");
21+
22+# SV 54740 : don't inherit .SILENT settings in sub-makes
23+run_make_test(q!
24+.PHONY: M r a b
25+r: a b ; @$(MAKE) -f #MAKEFILE# M V=x
26+a b: ; echo $@
27+
28+V =
29+$V.SILENT:
30+M: a b
31+!,
32+              '--no-print-directory', "a\nb\necho a\na\necho b\nb");
33+
34+1;
+641, -0
  1@@ -0,0 +1,641 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test the behaviour of the .WAIT target.";
  5+
  6+$details = "";
  7+
  8+# Ensure .WAIT doesn't appear in any automatic variables
  9+
 10+run_make_test(q!
 11+all: .WAIT pre1 .WAIT pre2 | .WAIT pre3 ; @echo '<=$< ^=$^ ?=$? +=$+ |=$|'
 12+pre1 pre2 pre3:;
 13+
 14+# This is just here so we don't fail with older versions of make
 15+.WAIT:
 16+!,
 17+    '', '<=pre1 ^=pre1 pre2 ?=pre1 pre2 +=pre1 pre2 |=pre3');
 18+
 19+run_make_test(q!
 20+.SECONDEXPANSION:
 21+all: $$(pre) ; @echo '<=$< ^=$^ ?=$? +=$+ |=$|'
 22+pre1 pre2 pre3:;
 23+
 24+pre = .WAIT pre1 .WAIT pre2 | .WAIT pre3
 25+# This is just here so we don't fail with older versions of make
 26+.WAIT:
 27+!,
 28+    '', '<=pre1 ^=pre1 pre2 ?=pre1 pre2 +=pre1 pre2 |=pre3');
 29+
 30+run_make_test(q!
 31+all: pre
 32+p% : .WAIT p%1 .WAIT p%2 | .WAIT p%3; @echo '<=$< ^=$^ ?=$? +=$+ |=$|'
 33+pre1 pre2 pre3: ;
 34+
 35+# This is just here so we don't fail with older versions of make
 36+.WAIT:
 37+!,
 38+              '', "<=pre1 ^=pre1 pre2 ?=pre1 pre2 +=pre1 pre2 |=pre3\n");
 39+
 40+# Unfortunately I don't think we can get away from using sleep here; at least
 41+# I can't think of any way to make sure .WAIT works without it.  Even with it,
 42+# it's not reliable (in that even if .WAIT is not working we MIGHT succeed the
 43+# test--it shouldn't ever be the case that we fail the test unexpectedly).
 44+# That makes this test suite slow to run :-/.
 45+
 46+run_make_test(q!
 47+all : pre1 .WAIT pre2
 48+pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
 49+pre2: ; @#HELPER# -q out $@
 50+
 51+# This is just here so we don't fail with older versions of make
 52+.WAIT:
 53+!,
 54+              '-j10', "start-pre1\nend-pre1\npre2\n");
 55+
 56+# Ensure .WAIT doesn't add extra a dependency between its targets
 57+
 58+run_make_test(undef, '-j10 pre2', "pre2\n");
 59+
 60+# sv 63856.
 61+# .WAIT on the command line.
 62+
 63+run_make_test(q!
 64+pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
 65+pre2: ; @#HELPER# -q out $@
 66+
 67+# This is just here so we don't fail with older versions of make
 68+.WAIT:
 69+!,
 70+              '-j10 pre1 .WAIT pre2', "start-pre1\nend-pre1\npre2\n");
 71+
 72+# Multiple consecutive .WAITs.
 73+
 74+run_make_test(q!
 75+all : pre1 .WAIT .WAIT .WAIT pre2
 76+pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
 77+pre2: ; @#HELPER# -q out $@
 78+
 79+# This is just here so we don't fail with older versions of make
 80+.WAIT:
 81+!,
 82+              '-j10', "start-pre1\nend-pre1\npre2\n");
 83+
 84+# First and last prerequsites are .WAIT.
 85+
 86+run_make_test(q!
 87+all : .WAIT pre1 .WAIT pre2 .WAIT
 88+pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
 89+pre2: ; @#HELPER# -q out $@
 90+
 91+# This is just here so we don't fail with older versions of make
 92+.WAIT:
 93+!,
 94+              '-j10', "start-pre1\nend-pre1\npre2\n");
 95+
 96+# All prerequisites are .WAITs.
 97+
 98+run_make_test(q!
 99+all : .WAIT .WAIT .WAIT
100+
101+# This is just here so we don't fail with older versions of make
102+.WAIT:
103+!,
104+              '-j10', "#MAKE#: Nothing to be done for 'all'.\n");
105+
106+run_make_test(q!
107+all:
108+!,
109+              '-j10 .WAIT', "#MAKE#: Nothing to be done for 'all'.\n");
110+
111+# Wait between the duplicate goals.
112+
113+run_make_test(q!
114+all: hello.tsk .WAIT hello.tsk
115+hello.tsk:; $(info $@)
116+!,
117+              '-j10', "hello.tsk\n#MAKE#: Nothing to be done for 'all'.\n");
118+
119+# Wait between the duplicate command line goals.
120+
121+run_make_test(q!
122+hello.tsk:; $(info $@)
123+!,
124+              '-j10 hello.tsk .WAIT hello.tsk', "hello.tsk\n#MAKE#: 'hello.tsk' is up to date.\n#MAKE#: 'hello.tsk' is up to date.\n");
125+
126+
127+# Ensure .WAIT doesn't wait between all targets
128+
129+run_make_test(q!
130+all : pre1 .WAIT pre2 pre3
131+pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
132+pre2: ; @#HELPER# -q out start-$@ file TWO wait THREE out end-$@
133+pre3: ; @#HELPER# -q wait TWO out $@ file THREE
134+
135+# This is just here so we don't fail with older versions of make
136+.WAIT:
137+!,
138+              '-j10', "start-pre1\nend-pre1\nstart-pre2\npre3\nend-pre2\n");
139+
140+unlink(qw(TWO THREE));
141+
142+# Ensure .WAIT on the command line doesn't wait between all targets.
143+
144+run_make_test(q!
145+pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
146+pre2: ; @#HELPER# -q out start-$@ file TWO wait THREE out end-$@
147+pre3: ; @#HELPER# -q wait TWO out $@ file THREE
148+
149+# This is just here so we don't fail with older versions of make
150+.WAIT:
151+!,
152+              '-j10 pre1 .WAIT pre2 pre3', "start-pre1\nend-pre1\nstart-pre2\npre3\nend-pre2\n");
153+
154+unlink(qw(TWO THREE));
155+
156+# Ensure .WAIT waits for ALL targets on the left before ANY targets on the right
157+
158+run_make_test(q!
159+all : pre1 pre2 .WAIT post1 post2
160+pre1: ; @#HELPER# -q out start-$@ file PRE1 wait PRE2 sleep 1 out end-$@
161+pre2: ; @#HELPER# -q wait PRE1 out $@ file PRE2
162+
163+post1: ; @#HELPER# -q wait POST2 out $@ file POST1
164+post2: ; @#HELPER# -q file POST2 wait POST1 out $@
165+
166+# This is just here so we don't fail with older versions of make
167+.WAIT:
168+!,
169+              '-j10', "start-pre1\npre2\nend-pre1\npost1\npost2\n");
170+
171+unlink(qw(PRE1 PRE2 POST1 POST2));
172+
173+# Ensure .WAIT on the command line waits for ALL targets on the left before ANY
174+# targets on the right.
175+
176+run_make_test(q!
177+pre1: ; @#HELPER# -q out start-$@ file PRE1 wait PRE2 sleep 1 out end-$@
178+pre2: ; @#HELPER# -q wait PRE1 out $@ file PRE2
179+
180+post1: ; @#HELPER# -q wait POST2 out $@ file POST1
181+post2: ; @#HELPER# -q file POST2 wait POST1 out $@
182+
183+# This is just here so we don't fail with older versions of make
184+.WAIT:
185+!,
186+              '-j10 pre1 pre2 .WAIT post1 post2', "start-pre1\npre2\nend-pre1\npost1\npost2\n");
187+
188+unlink(qw(PRE1 PRE2 POST1 POST2));
189+
190+# See if .WAIT takes effect between different lists of prereqs
191+# In the current implementation, .WAIT waits only between two prerequisites
192+# in a given target.  These same two targets might be run in a different
193+# order if they appear as prerequisites of another target.  This is the way
194+# other implementations of .WAIT work.  I personally think it's gross and
195+# makes .WAIT just a toy when it comes to ordering, but it's much simpler
196+# to implement than creating an actual edge in the DAG to represent .WAIT
197+# and since that's what users expect, we'll do the same for now.
198+
199+run_make_test(q!
200+all : one two
201+one: pre1 .WAIT pre2
202+two: pre2 pre1
203+pre1: ; @#HELPER# -q out start-$@ file PRE1 wait PRE2 out end-$@
204+pre2: ; @#HELPER# -q wait PRE1 out $@ file PRE2
205+
206+
207+# This is just here so we don't fail with older versions of make
208+.WAIT:
209+!,
210+              '-j10', "start-pre1\npre2\nend-pre1\n");
211+unlink(qw(PRE1 PRE2));
212+
213+# Check that .WAIT works with pattern rules
214+
215+run_make_test(q!
216+all: pre
217+p% : p%1 .WAIT p%2;
218+pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
219+pre2: ; @#HELPER# -q out $@
220+
221+# This is just here so we don't fail with older versions of make
222+.WAIT:
223+!,
224+              '-j10', "start-pre1\nend-pre1\npre2\n");
225+
226+# Check that .WAIT works with secondarily expanded rules
227+
228+run_make_test(q!
229+.SECONDEXPANSION:
230+all: $$(pre)
231+pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
232+pre2: ; @#HELPER# -q out $@
233+pre3: ; @#HELPER# -q out $@
234+
235+pre = .WAIT pre1 .WAIT pre2 | .WAIT pre3
236+
237+# This is just here so we don't fail with older versions of make
238+.WAIT:
239+!,
240+              '-j10', "start-pre1\nend-pre1\npre2\npre3\n");
241+
242+# Verify NOTPARALLEL works
243+
244+run_make_test(q!
245+all : pre1 pre2
246+pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
247+pre2: ; @#HELPER# -q out $@
248+
249+.NOTPARALLEL:
250+!,
251+              '-j10', "start-pre1\nend-pre1\npre2\n");
252+
253+run_make_test(q!
254+all : p1 .WAIT np1
255+
256+p1: pre1 pre2
257+pre1: ; @#HELPER# -q out start-$@ file PRE1 wait PRE2 out end-$@
258+pre2: ; @#HELPER# -q wait PRE1 out $@ file PRE2
259+
260+
261+np1: npre1 npre2
262+npre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
263+npre2: ; @#HELPER# -q out $@
264+
265+.NOTPARALLEL: np1
266+!,
267+              '-j10', "start-pre1\npre2\nend-pre1\nstart-npre1\nend-npre1\nnpre2\n");
268+unlink(qw(PRE1 PRE2));
269+
270+# Ensure we don't shuffle if .WAIT is set
271+
272+run_make_test(q!
273+all : pre1 .WAIT pre2
274+pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
275+pre2: ; @#HELPER# -q out $@
276+
277+# This is just here so we don't fail with older versions of make
278+.WAIT:
279+!,
280+              '-j10 --shuffle=reverse', "start-pre1\nend-pre1\npre2\n");
281+
282+# Ensure we don't shuffle if .WAIT is set on the command line.
283+
284+run_make_test(q!
285+pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
286+pre2: ; @#HELPER# -q out $@
287+
288+# This is just here so we don't fail with older versions of make
289+.WAIT:
290+!,
291+              '-j10 --shuffle=reverse pre1 .WAIT pre2', "start-pre1\nend-pre1\npre2\n");
292+
293+# Warn about invalid .WAIT definitions
294+
295+run_make_test(q!
296+.WAIT: foo
297+.WAIT: ; echo oops
298+all:;@:
299+!,
300+              '', "#MAKEFILE#:2: .WAIT should not have prerequisites\n#MAKEFILE#:3: .WAIT should not have commands\n");
301+
302+# Wait for all double colon targets on the left, before building targets on the
303+# right.
304+# Subtest 1. First run this test without .WAIT and observe and A recipes
305+# interleave with B recipes.
306+# Then run the same test with .WAIT and observe that all A recipes get started
307+# sequentially before the 1st B recipe gets started and then all B recipes get
308+# started sequentially.
309+
310+unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');
311+
312+run_make_test(q!
313+all: A B
314+A ::; @#HELPER# -q out A-1 file A-1-done wait B-1-done out A-1-done
315+A ::; @#HELPER# -q out A-2 file A-2-done wait B-2-done out A-2-done
316+A ::; @#HELPER# -q out A-3 file A-3-done wait B-3-done out A-3-done
317+B ::; @#HELPER# -q wait A-1-done out B-1 out B-1-done file B-1-done
318+B ::; @#HELPER# -q wait A-2-done out B-2 out B-2-done file B-2-done
319+B ::; @#HELPER# -q wait A-3-done out B-3 out B-3-done file B-3-done
320+
321+# This is just here so we don't fail with older versions of make
322+.WAIT:
323+!,
324+              '-j10', "A-1\nB-1\nB-1-done\nA-1-done\nA-2\nB-2\nB-2-done\nA-2-done\nA-3\nB-3\nB-3-done\nA-3-done\n");
325+
326+unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');
327+
328+# Subtest 2.
329+# Wait for all double colon targets on the left, before building targets on the
330+# right.
331+
332+run_make_test(q!
333+all: A .WAIT B
334+A ::; @#HELPER# -q out $@-1 out $@-1-done
335+A ::; @#HELPER# -q out $@-2 out $@-2-done
336+A ::; @#HELPER# -q out $@-3 out $@-3-done
337+B ::; @#HELPER# -q out $@-1 out $@-1-done
338+B ::; @#HELPER# -q out $@-2 out $@-2-done
339+B ::; @#HELPER# -q out $@-3 out $@-3-done
340+
341+# This is just here so we don't fail with older versions of make
342+.WAIT:
343+!,
344+              '-j10', "A-1\nA-1-done\nA-2\nA-2-done\nA-3\nA-3-done\nB-1\nB-1-done\nB-2\nB-2-done\nB-3\nB-3-done\n");
345+
346+# sv 63856.
347+# Wait for all double colon targets on the left, before building targets on the
348+# right.
349+# Subtest 1. First run this test without .WAIT and observe and A recipes
350+# interleave with B recipes.
351+# Then run the same test with .WAIT and observe that all A recipes get started
352+# sequentially before the 1st B recipe gets started and then all B recipes get
353+# started sequentially.
354+# The targets are specified on the command line.
355+
356+unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');
357+
358+run_make_test(q!
359+A ::; @#HELPER# -q out A-1 file A-1-done wait B-1-done out A-1-done
360+A ::; @#HELPER# -q out A-2 file A-2-done wait B-2-done out A-2-done
361+A ::; @#HELPER# -q out A-3 file A-3-done wait B-3-done out A-3-done
362+B ::; @#HELPER# -q wait A-1-done out B-1 out B-1-done file B-1-done
363+B ::; @#HELPER# -q wait A-2-done out B-2 out B-2-done file B-2-done
364+B ::; @#HELPER# -q wait A-3-done out B-3 out B-3-done file B-3-done
365+
366+# This is just here so we don't fail with older versions of make
367+.WAIT:
368+!,
369+              '-j10 A B', "A-1\nB-1\nB-1-done\nA-1-done\nA-2\nB-2\nB-2-done\nA-2-done\nA-3\nB-3\nB-3-done\nA-3-done\n");
370+
371+unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');
372+
373+# Subtest 2.
374+# sv 63856.
375+# Wait for all double colon targets on the left, before building targets on the
376+# right. The targets are specified on the command line.
377+
378+run_make_test(q!
379+A ::; @#HELPER# -q out $@-1 out $@-1-done
380+A ::; @#HELPER# -q out $@-2 out $@-2-done
381+A ::; @#HELPER# -q out $@-3 out $@-3-done
382+B ::; @#HELPER# -q out $@-1 out $@-1-done
383+B ::; @#HELPER# -q out $@-2 out $@-2-done
384+B ::; @#HELPER# -q out $@-3 out $@-3-done
385+
386+# This is just here so we don't fail with older versions of make
387+.WAIT:
388+!,
389+              '-j10 A .WAIT B', "A-1\nA-1-done\nA-2\nA-2-done\nA-3\nA-3-done\nB-1\nB-1-done\nB-2\nB-2-done\nB-3\nB-3-done\n");
390+
391+
392+# Wait for all double colon targets on the left, before building targets on the
393+# right.
394+# Regular targets which have double colon targets as prerequisites.
395+# Subtest 1. First run this test without .WAIT and observe and A recipes
396+# interleave with B recipes.
397+# The targets are specified in the makefile.
398+
399+unlink('D', 'D-done', 'E', 'E-done');
400+unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');
401+
402+run_make_test(q!
403+all: C .WAIT A B
404+A ::; @#HELPER# -q out A-1 file A-1-done wait B-1-done out A-1-done
405+A ::; @#HELPER# -q out A-2 file A-2-done wait B-2-done out A-2-done
406+A ::; @#HELPER# -q out A-3 file A-3-done wait B-3-done out A-3-done
407+B ::; @#HELPER# -q wait A-1-done out B-1 out B-1-done file B-1-done
408+B ::; @#HELPER# -q wait A-2-done out B-2 out B-2-done file B-2-done
409+B ::; @#HELPER# -q wait A-3-done out B-3 out B-3-done file B-3-done
410+
411+C: D E
412+D:; @#HELPER# -q out D file D wait E-done out D-done
413+E:; @#HELPER# -q wait D out E out E-done file E-done
414+
415+.PHONY: C D E
416+
417+# This is just here so we don't fail with older versions of make
418+.WAIT:
419+!,
420+              '-j10', "D\nE\nE-done\nD-done\nA-1\nB-1\nB-1-done\nA-1-done\nA-2\nB-2\nB-2-done\nA-2-done\nA-3\nB-3\nB-3-done\nA-3-done\n");
421+
422+# Wait for all double colon targets on the left, before building targets on the
423+# right.
424+# Regular targets which have double colon targets as prerequisites.
425+# Subtest 2.
426+# Run the same test with .WAIT and observe that all A recipes get started
427+# sequentially before the 1st B recipe gets started and then all B recipes get
428+# started sequentially.
429+# The targets are specified in the makefile.
430+#
431+
432+unlink('D', 'D-done', 'E', 'E-done');
433+unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');
434+
435+run_make_test(q!
436+all: C .WAIT A .WAIT B
437+A ::; @#HELPER# -q out $@-1 out $@-1-done
438+A ::; @#HELPER# -q out $@-2 out $@-2-done
439+A ::; @#HELPER# -q out $@-3 out $@-3-done
440+B ::; @#HELPER# -q out $@-1 out $@-1-done
441+B ::; @#HELPER# -q out $@-2 out $@-2-done
442+B ::; @#HELPER# -q out $@-3 out $@-3-done
443+
444+C: D E
445+D:; @#HELPER# -q out D file D wait E-done out D-done
446+E:; @#HELPER# -q wait D out E out E-done file E-done
447+
448+.PHONY: C D E
449+
450+# This is just here so we don't fail with older versions of make
451+.WAIT:
452+!,
453+              '-j10', "D\nE\nE-done\nD-done\nA-1\nA-1-done\nA-2\nA-2-done\nA-3\nA-3-done\nB-1\nB-1-done\nB-2\nB-2-done\nB-3\nB-3-done\n");
454+
455+
456+# Wait for all double colon targets on the left, before building targets on the
457+# right.
458+# Regular targets which have double colon targets as prerequisites.
459+# Subtest 1. First run this test without .WAIT and observe and A recipes
460+# interleave with B recipes.
461+# The targets are specified on the command line.
462+
463+unlink('D', 'D-done', 'E', 'E-done');
464+unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');
465+
466+run_make_test(q!
467+A ::; @#HELPER# -q out A-1 file A-1-done wait B-1-done out A-1-done
468+A ::; @#HELPER# -q out A-2 file A-2-done wait B-2-done out A-2-done
469+A ::; @#HELPER# -q out A-3 file A-3-done wait B-3-done out A-3-done
470+B ::; @#HELPER# -q wait A-1-done out B-1 out B-1-done file B-1-done
471+B ::; @#HELPER# -q wait A-2-done out B-2 out B-2-done file B-2-done
472+B ::; @#HELPER# -q wait A-3-done out B-3 out B-3-done file B-3-done
473+
474+C: D E
475+D:; @#HELPER# -q out D file D wait E-done out D-done
476+E:; @#HELPER# -q wait D out E out E-done file E-done
477+
478+.PHONY: C D E
479+
480+# This is just here so we don't fail with older versions of make
481+.WAIT:
482+!,
483+              '-j10 C .WAIT A B', "D\nE\nE-done\nD-done\nA-1\nB-1\nB-1-done\nA-1-done\nA-2\nB-2\nB-2-done\nA-2-done\nA-3\nB-3\nB-3-done\nA-3-done\n");
484+
485+# Wait for all double colon targets on the left, before building targets on the
486+# right.
487+# Regular targets which have double colon targets as prerequisites.
488+# Subtest 2.
489+# Run the same test with .WAIT and observe that all A recipes get started
490+# sequentially before the 1st B recipe gets started and then all B recipes get
491+# started sequentially.
492+# The targets are specified on the command line.
493+
494+unlink('D', 'D-done', 'E', 'E-done');
495+unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');
496+
497+run_make_test(q!
498+A ::; @#HELPER# -q out $@-1 out $@-1-done
499+A ::; @#HELPER# -q out $@-2 out $@-2-done
500+A ::; @#HELPER# -q out $@-3 out $@-3-done
501+B ::; @#HELPER# -q out $@-1 out $@-1-done
502+B ::; @#HELPER# -q out $@-2 out $@-2-done
503+B ::; @#HELPER# -q out $@-3 out $@-3-done
504+
505+C: D E
506+D:; @#HELPER# -q out D file D wait E-done out D-done
507+E:; @#HELPER# -q wait D out E out E-done file E-done
508+
509+.PHONY: C D E
510+
511+# This is just here so we don't fail with older versions of make
512+.WAIT:
513+!,
514+              '-j10 C .WAIT A .WAIT B', "D\nE\nE-done\nD-done\nA-1\nA-1-done\nA-2\nA-2-done\nA-3\nA-3-done\nB-1\nB-1-done\nB-2\nB-2-done\nB-3\nB-3-done\n");
515+
516+unlink('D', 'D-done', 'E', 'E-done');
517+unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');
518+
519+# Wait for all double colon targets on the left, before building targets on the
520+# right.
521+# Double colon targets have reqular targets as prerequisites.
522+# Subtest 1. First run this test without .WAIT and observe and A recipes
523+# interleave with B recipes.
524+# The targets are specified in the makefile.
525+
526+unlink('D', 'D-done', 'E', 'E-done');
527+unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');
528+
529+run_make_test(q!
530+all: A B
531+A :: D; @#HELPER# -q out A-1 file A-1-done wait B-1-done out A-1-done
532+A ::; @#HELPER# -q out A-2 file A-2-done wait B-2-done out A-2-done
533+A ::; @#HELPER# -q out A-3 file A-3-done wait B-3-done out A-3-done
534+B :: E; @#HELPER# -q wait A-1-done out B-1 out B-1-done file B-1-done
535+B ::; @#HELPER# -q wait A-2-done out B-2 out B-2-done file B-2-done
536+B ::; @#HELPER# -q wait A-3-done out B-3 out B-3-done file B-3-done
537+
538+D:; @#HELPER# -q out D file D wait E-done out D-done
539+E:; @#HELPER# -q wait D out E out E-done file E-done
540+
541+.PHONY: D E
542+
543+# This is just here so we don't fail with older versions of make
544+.WAIT:
545+!,
546+              '-j10', "D\nE\nE-done\nD-done\nA-1\nB-1\nB-1-done\nA-1-done\nA-2\nB-2\nB-2-done\nA-2-done\nA-3\nB-3\nB-3-done\nA-3-done\n");
547+
548+# Wait for all double colon targets on the left, before building targets on the
549+# right.
550+# Double colon targets have reqular targets as prerequisites.
551+# Subtest 2.
552+# Run the same test with .WAIT and observe that all A recipes get started
553+# sequentially before the 1st B recipe gets started and then all B recipes get
554+# started sequentially.
555+# The targets are specified in the makefile.
556+
557+unlink('D', 'D-done', 'E', 'E-done');
558+unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');
559+
560+run_make_test(q!
561+all: A .WAIT B
562+A :: D; @#HELPER# -q out $@-1 out $@-1-done
563+A ::  ; @#HELPER# -q out $@-2 out $@-2-done
564+A ::  ; @#HELPER# -q out $@-3 out $@-3-done
565+B :: E; @#HELPER# -q out $@-1 out $@-1-done
566+B ::  ; @#HELPER# -q out $@-2 out $@-2-done
567+B ::  ; @#HELPER# -q out $@-3 out $@-3-done
568+
569+D:; @#HELPER# -q out D out D-done
570+E:; @#HELPER# -q out E out E-done
571+
572+.PHONY: D E
573+
574+# This is just here so we don't fail with older versions of make
575+.WAIT:
576+!,
577+              '-j10', "D\nD-done\nA-1\nA-1-done\nA-2\nA-2-done\nA-3\nA-3-done\nE\nE-done\nB-1\nB-1-done\nB-2\nB-2-done\nB-3\nB-3-done\n");
578+
579+
580+# Wait for all double colon targets on the left, before building targets on the
581+# right.
582+# Double colon targets have reqular targets as prerequisites.
583+# Subtest 1. First run this test without .WAIT and observe and A recipes
584+# interleave with B recipes.
585+# The targets are specified on the command line.
586+
587+unlink('D', 'D-done', 'E', 'E-done');
588+unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');
589+
590+run_make_test(q!
591+A :: D; @#HELPER# -q out A-1 file A-1-done wait B-1-done out A-1-done
592+A ::; @#HELPER# -q out A-2 file A-2-done wait B-2-done out A-2-done
593+A ::; @#HELPER# -q out A-3 file A-3-done wait B-3-done out A-3-done
594+B :: E; @#HELPER# -q wait A-1-done out B-1 out B-1-done file B-1-done
595+B ::; @#HELPER# -q wait A-2-done out B-2 out B-2-done file B-2-done
596+B ::; @#HELPER# -q wait A-3-done out B-3 out B-3-done file B-3-done
597+
598+D:; @#HELPER# -q out D file D wait E-done out D-done
599+E:; @#HELPER# -q wait D out E out E-done file E-done
600+
601+.PHONY: D E
602+
603+# This is just here so we don't fail with older versions of make
604+.WAIT:
605+!,
606+              '-j10 A B', "D\nE\nE-done\nD-done\nA-1\nB-1\nB-1-done\nA-1-done\nA-2\nB-2\nB-2-done\nA-2-done\nA-3\nB-3\nB-3-done\nA-3-done\n");
607+
608+# Wait for all double colon targets on the left, before building targets on the
609+# right.
610+# Double colon targets have reqular targets as prerequisites.
611+# Subtest 2.
612+# Run the same test with .WAIT and observe that all A recipes get started
613+# sequentially before the 1st B recipe gets started and then all B recipes get
614+# started sequentially.
615+# The targets are specified on the command line.
616+
617+unlink('D', 'D-done', 'E', 'E-done');
618+unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');
619+
620+run_make_test(q!
621+A :: D; @#HELPER# -q out $@-1 out $@-1-done
622+A ::  ; @#HELPER# -q out $@-2 out $@-2-done
623+A ::  ; @#HELPER# -q out $@-3 out $@-3-done
624+B :: E; @#HELPER# -q out $@-1 out $@-1-done
625+B ::  ; @#HELPER# -q out $@-2 out $@-2-done
626+B ::  ; @#HELPER# -q out $@-3 out $@-3-done
627+
628+D:; @#HELPER# -q out D out D-done
629+E:; @#HELPER# -q out E out E-done
630+
631+.PHONY: D E
632+
633+# This is just here so we don't fail with older versions of make
634+.WAIT:
635+!,
636+              '-j10 A .WAIT B', "D\nD-done\nA-1\nA-1-done\nA-2\nA-2-done\nA-3\nA-3-done\nE\nE-done\nB-1\nB-1-done\nB-2\nB-2-done\nB-3\nB-3-done\n");
637+
638+unlink('D', 'D-done', 'E', 'E-done');
639+unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');
640+
641+# This tells the test driver that the perl test script executed properly.
642+1;
+31, -0
 1@@ -0,0 +1,31 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "The following test creates a makefile to delete a \n"
 5+              ."file in the directory.  It tests to see if make will \n"
 6+              ."NOT execute the command unless the rule is given in \n"
 7+              ."the make command line.";
 8+
 9+$example = "EXAMPLE_FILE";
10+
11+open(MAKEFILE,"> $makefile");
12+print MAKEFILE qq!
13+all: ; \@echo This makefile did not clean the dir... good
14+clean: ; $CMD_rmfile $example
15+!;
16+close(MAKEFILE);
17+
18+touch($example);
19+run_make_with_options($makefile,"",&get_logfile,0);
20+
21+$answer = "This makefile did not clean the dir... good\n";
22+compare_output($answer,&get_logfile(1)) || error("abort");
23+
24+
25+$answer = "$CMD_rmfile $example\n";
26+run_make_with_options($makefile,"clean",&get_logfile,0);
27+if (-f $example) {
28+  $test_passed = 0;
29+}
30+compare_output($answer,&get_logfile(1)) || error("abort");
31+
32+1;
+29, -0
 1@@ -0,0 +1,29 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "<FILL IN SHORT DESCRIPTION HERE>";
 5+$details = "<FILL IN DETAILS OF HOW YOU TEST WHAT YOU SAY YOU ARE TESTING>";
 6+
 7+# Run a make test.  See the documentation of run_make_test() in
 8+# run_make_tests.pl, but briefly the first argument is a string with the
 9+# contents of a makefile to be tested, the second is a string containing the
10+# arguments to be passed to the make invocation, the third is a string
11+# containing the expected output.  The fourth is the expected exit code for
12+# make.  If not specified, it's assumed that the make program should succeed
13+# (exit with 0).
14+
15+run_make_test('Your test makefile goes here',
16+              'Arguments to pass to make go here',
17+              'Expected output from the invocation goes here');
18+
19+# There are various special tokens, options, etc.  See the full documentation
20+# in run_make_tests.pl.
21+
22+
23+# This tells the test driver that the perl test script executed properly.
24+1;
25+
26+
27+
28+
29+
30+
+16, -0
 1@@ -0,0 +1,16 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "This tests the CURDIR variable.";
 5+
 6+$details = "Echo CURDIR both with and without -C.  Also ensure overrides work.";
 7+
 8+
 9+# TEST #1
10+# -------
11+
12+run_make_test(q!
13+all: ; @echo $(CURDIR)
14+!,
15+              '', "#PWD#\n");
16+
17+1;
+87, -0
 1@@ -0,0 +1,87 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Test the .DEFAULT_GOAL special variable.";
 4+
 5+$details = "";
 6+
 7+
 8+# Test #1: basic logic.
 9+#
10+run_make_test('
11+# Basics.
12+#
13+foo: ; @:
14+
15+ifneq ($(.DEFAULT_GOAL),foo)
16+$(error )
17+endif
18+
19+# Reset to empty.
20+#
21+.DEFAULT_GOAL :=
22+
23+bar: ; @:
24+
25+ifneq ($(.DEFAULT_GOAL),bar)
26+$(error )
27+endif
28+
29+# Change to a different goal.
30+#
31+
32+.DEFAULT_GOAL := baz
33+
34+baz: ; @echo $@
35+',
36+'',
37+'baz');
38+
39+
40+# Test #2: unknown goal.
41+#
42+run_make_test('
43+.DEFAULT_GOAL = foo
44+',
45+'',
46+"#MAKE#: *** No rule to make target 'foo'.  Stop.",
47+512);
48+
49+
50+# Test #3: more than one goal.
51+#
52+run_make_test('
53+.DEFAULT_GOAL := foo bar
54+',
55+'',
56+'#MAKE#: *** .DEFAULT_GOAL contains more than one target.  Stop.',
57+512);
58+
59+
60+# Test #4: Savannah bug #12226.
61+#
62+run_make_test('
63+define rule
64+foo: ; @echo $$@
65+endef
66+
67+define make-rule
68+$(eval $(rule))
69+endef
70+
71+$(call make-rule)
72+
73+',
74+'',
75+'foo');
76+
77+# TEST #5: .DEFAULT_GOAL containing just whitespace (Savannah bug #25697)
78+
79+run_make_test('
80+N =
81+.DEFAULT_GOAL = $N  $N  # Just whitespace
82+
83+foo: ; @echo "boo"
84+',
85+              '', "#MAKE#: *** No targets.  Stop.\n", 512);
86+
87+# This tells the test driver that the perl test script executed properly.
88+1;
+193, -0
  1@@ -0,0 +1,193 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test the .EXTRA_PREREQS special variable.";
  5+$details = "";
  6+
  7+# Simple global .EXTRA_PREREQS and automatic variable settings
  8+run_make_test('
  9+.EXTRA_PREREQS = tick tack
 10+.PHONY: all
 11+all: ; @echo ${.EXTRA_PREREQS}/$@/$</$^/$?/$+/$|/$*/
 12+tick tack: ; @echo $@
 13+',
 14+              '', "tick\ntack\ntick tack/all///////\n");
 15+
 16+# Global .EXTRA_PREREQS and pattern rules
 17+run_make_test('
 18+.EXTRA_PREREQS = tick tack
 19+a%: ; @echo ${.EXTRA_PREREQS}/$@/$</$^/$?/$+/$|/$*/
 20+tick tack: ; @echo $@
 21+',
 22+              'all', "tick\ntack\ntick tack/all//////ll/\n");
 23+
 24+# Simple target-specific .EXTRA_PREREQS and automatic variable settings
 25+run_make_test('
 26+.PHONY: all
 27+all: ; @echo ${.EXTRA_PREREQS}/$@/$</$^/$?/$+/$|/$*/
 28+all: .EXTRA_PREREQS = tick tack
 29+tick tack: ; @echo $@
 30+',
 31+              '', "tick\ntack\ntick tack/all///////\n");
 32+
 33+# Simple pattern-specific .EXTRA_PREREQS and automatic variable settings
 34+# This is not currently supported :-/
 35+if (0) {
 36+    run_make_test('
 37+.PHONY: all
 38+all: ; @echo ${.EXTRA_PREREQS}/$@/$</$^/$?/$+/$|/$*/
 39+a%: .EXTRA_PREREQS = tick tack
 40+tick tack: ; @echo $@
 41+',
 42+                  '', "tick\ntack\ntick tack/all///////\n");
 43+}
 44+
 45+touch('hi');
 46+
 47+# Basic test target specific .EXTRA_PREREQS:
 48+run_make_test('
 49+DEPENDENCY_ONLY_PREREQUISITES = ho hey
 50+OTHER_PREREQUISITES := foo bar baz
 51+target: .EXTRA_PREREQS := hi ${DEPENDENCY_ONLY_PREREQUISITES}
 52+target: ${OTHER_PREREQUISITES} ; @echo ${.EXTRA_PREREQS} $^
 53+.PHONY: target ${DEPENDENCY_ONLY_PREREQUISITES} ${OTHER_PREREQUISITES}
 54+${DEPENDENCY_ONLY_PREREQUISITES} ${OTHER_PREREQUISITES}: ; @echo $@
 55+',
 56+              '', "foo\nbar\nbaz\nho\nhey\nhi ho hey foo bar baz\n");
 57+
 58+# Test target specific .EXTRA_PREREQS and pattern rules:
 59+run_make_test('
 60+all: target.dst
 61+DEPENDENCY_ONLY_PREREQUISITES = ho hey
 62+target.dst: .EXTRA_PREREQS := hi ${DEPENDENCY_ONLY_PREREQUISITES}
 63+%.dst: %.src ; @echo ${.EXTRA_PREREQS} $^
 64+.PHONY: ${DEPENDENCY_ONLY_PREREQUISITES} target.src
 65+${DEPENDENCY_ONLY_PREREQUISITES} target.src: ; @echo $@
 66+',
 67+              '', "target.src\nho\nhey\nhi ho hey target.src\n");
 68+
 69+# Test that global .EXTRA_PREREQS are built first:
 70+run_make_test('
 71+.EXTRA_PREREQS = hi ho hey
 72+OTHER_PREREQUISITES := foo bar baz
 73+target: ${OTHER_PREREQUISITES} ; @echo ${.EXTRA_PREREQS} $^
 74+.PHONY: target ${.EXTRA_PREREQS} ${OTHER_PREREQUISITES}
 75+${.EXTRA_PREREQS} ${OTHER_PREREQUISITES}: ; @echo $@
 76+',
 77+              '', "hi\nho\nhey\nfoo\nbar\nbaz\nhi ho hey foo bar baz\n");
 78+
 79+# Test that target specific .EXTRA_PREREQS override global .EXTRA_PREREQS:
 80+run_make_test('
 81+.EXTRA_PREREQS = tick tack
 82+DEPENDENCY_ONLY_PREREQUISITES = ho hey
 83+OTHER_PREREQUISITES := foo bar baz
 84+target: .EXTRA_PREREQS := hi ${DEPENDENCY_ONLY_PREREQUISITES}
 85+target: ${OTHER_PREREQUISITES} ; @echo ${.EXTRA_PREREQS} $^
 86+.PHONY: target ${DEPENDENCY_ONLY_PREREQUISITES} ${OTHER_PREREQUISITES} ${.EXTRA_PREREQS}
 87+${DEPENDENCY_ONLY_PREREQUISITES} ${OTHER_PREREQUISITES} ${.EXTRA_PREREQS}: ; @echo $@
 88+',
 89+              '', "tick\ntack\nfoo\nbar\nbaz\nho\nhey\nhi ho hey foo bar baz\n");
 90+
 91+# Cleanup:
 92+unlink('hi');
 93+
 94+# Test error reporting of global .EXTRA_PREREQS:
 95+run_make_test('
 96+.EXTRA_PREREQS = tick tack
 97+.PHONY: all
 98+all: ; @echo ${.EXTRA_PREREQS} $^
 99+',
100+              '', "#MAKE#: *** No rule to make target 'tick', needed by 'all'.  Stop.", 512);
101+
102+# Test error reporting of global .EXTRA_PREREQS and keep-going:
103+run_make_test('
104+.EXTRA_PREREQS = tick tack
105+.PHONY: all
106+all: ; @echo ${.EXTRA_PREREQS} $^
107+',
108+              '-k', "#MAKE#: *** No rule to make target 'tick', needed by 'all'.\n#MAKE#: *** No rule to make target 'tack', needed by 'all'.\n#MAKE#: Target 'all' not remade because of errors.", 512);
109+
110+# Test error reporting of target specific .EXTRA_PREREQS and keep-going:
111+run_make_test('
112+all: .EXTRA_PREREQS = tick tack
113+.PHONY: all
114+all: ; @echo ${.EXTRA_PREREQS} $^
115+',
116+              '-k',
117+              "#MAKE#: *** No rule to make target 'tick', needed by 'all'.
118+#MAKE#: *** No rule to make target 'tack', needed by 'all'.
119+#MAKE#: Target 'all' not remade because of errors.\n", 512);
120+
121+# Test wildcard
122+
123+touch('tick', 'tack');
124+
125+run_make_test('
126+.EXTRA_PREREQS = *ck
127+.PHONY: all tick tack
128+all: ; @echo ${.EXTRA_PREREQS} $^
129+tick tack: ; @echo $@
130+',
131+              '', "tack\ntick\ntack tick\n");
132+
133+run_make_test('
134+.PHONY: all tick tack
135+all: ; @echo ${.EXTRA_PREREQS} $^
136+all: .EXTRA_PREREQS = *ck
137+tick tack: ; @echo $@
138+',
139+              '', "tack\ntick\ntack tick\n");
140+
141+run_make_test('
142+.PHONY: tick tack
143+a%: ; @echo ${.EXTRA_PREREQS} $^
144+.EXTRA_PREREQS = *ck
145+tick tack: ; @echo $@
146+',
147+              'all', "tack\ntick\ntack tick\n");
148+
149+# SV 65006. Second expansion of global .EXTRA_PREQREQS.
150+run_make_test('
151+.SECONDEXPANSION:
152+extradep:=tick tack
153+.EXTRA_PREREQS=$$(extradep)
154+%.x:; @echo $@
155+',
156+              'hello.x', "hello.x\n");
157+
158+unlink('tick', 'tack');
159+
160+# SV 65006. Second expansion of a target-specific .EXTRA_PREQREQS.
161+run_make_test('
162+.SECONDEXPANSION:
163+all: hello.x;
164+extradep=tick tack
165+hello.x: .EXTRA_PREREQS=$$(extradep)
166+%.x:; @echo $@
167+tick tack:; @echo $@
168+',
169+              '', "tick\ntack\nhello.x\n");
170+
171+# SV 65006. Second expansion of a target-specific .EXTRA_PREQREQS.
172+# The value of .EXTRA_PREQREQS contains automatic variables.
173+run_make_test('
174+.SECONDEXPANSION:
175+all: hello.x world.x
176+hello.x world.x: .EXTRA_PREREQS=$$@.d
177+%.x:; @echo $@
178+%.d:; @echo $@
179+',
180+              '', "hello.x.d\nhello.x\nworld.x.d\nworld.x\n");
181+
182+# SV 67046. Rehashing of hash table files during iteration.
183+my $files = "";
184+for my $k (1 .. 1000) {
185+    $files = "$files file$k";
186+}
187+run_make_test(qq!
188+all: .EXTRA_PREREQS := $files
189+all:;
190+file%:;
191+!,
192+              '', "#MAKE#: 'all' is up to date.");
193+
194+1;
+54, -0
 1@@ -0,0 +1,54 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test proper behavior of GNUMAKEFLAGS";
 5+
 6+# Accept flags from GNUMAKEFLAGS as well as MAKEFLAGS
 7+# Results always go in MAKEFLAGS
 8+
 9+$ENV{'GNUMAKEFLAGS'} = '-e -r -R';
10+
11+run_make_test(q!
12+all: ; @echo $(MAKEFLAGS)
13+!,
14+              '', 'erR');
15+
16+# Long arguments mean everything is prefixed with "-"
17+
18+$ENV{'GNUMAKEFLAGS'} = '--no-print-directory -e -r -R --trace';
19+
20+run_make_test(q!
21+all: ; @echo $(MAKEFLAGS)
22+!,
23+              '', "#MAKEFILE#:2: update target 'all' due to: target does not exist
24+echo erR --trace --no-print-directory
25+erR --trace --no-print-directory");
26+
27+# Verify that re-exec / recursion doesn't duplicate flags from GNUMAKEFLAGS
28+
29+unlink('x.mk');
30+
31+$ENV{GNUMAKEFLAGS} = '-Itst/bad';
32+
33+run_make_test(q!
34+recurse: ; @echo $@; echo MAKEFLAGS = $$MAKEFLAGS; echo GNUMAKEFLAGS = $$GNUMAKEFLAGS; #MAKEPATH# -f #MAKEFILE# all
35+all: ; @echo $@; echo MAKEFLAGS = $$MAKEFLAGS; echo GNUMAKEFLAGS = $$GNUMAKEFLAGS
36+-include x.mk
37+x.mk: ; @echo $@; echo MAKEFLAGS = $$MAKEFLAGS; echo GNUMAKEFLAGS = $$GNUMAKEFLAGS; echo > $@
38+!,
39+              "", "x.mk\nMAKEFLAGS = -Itst/bad\nGNUMAKEFLAGS =\nrecurse\nMAKEFLAGS = -Itst/bad\nGNUMAKEFLAGS =\n#MAKE#[1]: Entering directory '#PWD#'\nall\nMAKEFLAGS = -Itst/bad\nGNUMAKEFLAGS =\n#MAKE#[1]: Leaving directory '#PWD#'\n");
40+
41+unlink('x.mk');
42+
43+# Ensure that we don't add GNUMAKEFLAGS to the environment if it's not there
44+run_make_test(q!
45+all: ; @#HELPER# env GNUMAKEFLAGS
46+!,
47+              '', 'GNUMAKEFLAGS=<unset>');
48+
49+$ENV{GNUMAKEFLAGS} = '-Itst/bad';
50+run_make_test(q!
51+all: ; @#HELPER# env GNUMAKEFLAGS
52+!,
53+              '', 'GNUMAKEFLAGS=');
54+
55+1;
+94, -0
 1@@ -0,0 +1,94 @@
 2+#                                                                    -*-perl-*-
 3+$description = "Test the .INCLUDE_DIRS special variable.";
 4+
 5+$details = "";
 6+
 7+use Cwd;
 8+
 9+$dir = cwd;
10+$dir =~ s,.*/([^/]+)$,../$1,;
11+
12+if (-d '/usr/include') {
13+  # Test #1: The content of .INCLUDE_DIRS depends on the platform for which
14+  #          make was built. What we know for sure is that it shouldn't be
15+  #          empty.
16+  #
17+  run_make_test('
18+ifeq ($(.INCLUDE_DIRS),)
19+$(warning .INCLUDE_DIRS is empty)
20+endif
21+
22+.PHONY: all
23+all:;@:
24+',
25+                '', '');
26+}
27+
28+# Test #2: Make sure -I paths end up in .INCLUDE_DIRS.
29+#
30+run_make_test('
31+ifeq ($(dir),)
32+$(warning dir is empty)
33+endif
34+
35+ifeq ($(filter $(dir),$(.INCLUDE_DIRS)),)
36+$(warning .INCLUDE_DIRS does not contain $(dir): $(.INCLUDE_DIRS))
37+endif
38+
39+.PHONY: all
40+all:;@:
41+',
42+              "-I$dir dir=$dir", '');
43+
44+# Find the default .INCLUDE_DIRS
45+create_file('defaultdirs.mk', "\$(info \$(.INCLUDE_DIRS))\nall:;\@:\n");
46+my $cmd = subst_make_string('"#MAKEPATH#" -f defaultdirs.mk');
47+my @dirs = `$cmd`;
48+my $dirs = $dirs[0];
49+$dirs =~ s/\r?\n//g;
50+unlink('defaultdirs.mk');
51+
52+run_make_test("
53+ifneq (\$(.INCLUDE_DIRS),$dirs)
54+\$(warning Mismatched \$(.INCLUDE_DIRS) != $dirs)
55+endif
56+all:;\@:
57+",
58+              '', '');
59+
60+# Verify that -I- disables content from .INCLUDE_DIRS
61+
62+run_make_test(q/
63+ifneq ($(.INCLUDE_DIRS),)
64+$(warning Mismatched $(.INCLUDE_DIRS) != )
65+endif
66+all:;@:
67+/,
68+              '-I-', '');
69+
70+# Prefix -I dirs to the front
71+mkdir('somedir', 0777);
72+
73+my $xdirs = $dirs ? " $dirs" : '';
74+run_make_test("
75+ifneq (\$(.INCLUDE_DIRS),somedir$xdirs)
76+\$(warning Mismatched '\$(.INCLUDE_DIRS)' != 'somedir$xdirs')
77+endif
78+all:;\@:
79+",
80+              '-I somedir', '');
81+
82+# Verify .INCLUDE_DIRS contains files after -I-
83+
84+run_make_test(q/
85+ifneq ($(.INCLUDE_DIRS),somedir)
86+$(warning Mismatched $(.INCLUDE_DIRS) != somedir)
87+endif
88+all:;@:
89+/,
90+              '-I - -I somedir', '');
91+
92+rmdir('somedir');
93+
94+# This tells the test driver that the perl test script executed properly.
95+1;
+38, -0
 1@@ -0,0 +1,38 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test .LIBPATTERNS special variable.";
 5+
 6+$details = "";
 7+
 8+# TEST 0: basics
 9+
10+touch('mtest_foo.a');
11+
12+run_make_test('
13+.LIBPATTERNS = mtest_%.a
14+all: -lfoo ; @echo "build $@ from $<"
15+',
16+              '', "build all from mtest_foo.a\n");
17+
18+# TEST 1: Handle elements that are not patterns.
19+
20+run_make_test('
21+.LIBPATTERNS = mtest_foo.a mtest_%.a
22+all: -lfoo ; @echo "build $@ from $<"
23+',
24+              '', "#MAKE#: .LIBPATTERNS element 'mtest_foo.a' is not a pattern
25+build all from mtest_foo.a\n");
26+
27+# TEST 2: target-specific override
28+
29+# Uncomment this when we add support, see Savannah bug #25703
30+# run_make_test('
31+# .LIBPATTERNS = mbad_%.a
32+# all: .LIBPATTERNS += mtest_%.a
33+# all: -lfoo ; @echo "build $@ from $<"
34+# ',
35+#               '', "build all from mtest_foo.a\n");
36+
37+unlink('mtest_foo.a');
38+
39+1;
+24, -0
 1@@ -0,0 +1,24 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test proper behavior of the MAKE variable";
 5+
 6+$details = "DETAILS";
 7+
 8+run_make_test(q!
 9+TMP  := $(MAKE)
10+MAKE := $(subst X=$(X),,$(MAKE))
11+all:
12+#TAB#@echo $(TMP)
13+#TAB#$(MAKE) -f #MAKEFILE# foo
14+
15+foo:
16+#TAB#@echo $(MAKE)
17+!,
18+              '',
19+              "#MAKEPATH#\n#MAKEPATH# -f #MAKEFILE# foo\n"
20+              . "#MAKE#[1]: Entering directory '#PWD#'\n"
21+              . "#MAKEPATH#\n#MAKE#[1]: Leaving directory '#PWD#'\n");
22+
23+rmfiles("foo");
24+
25+1;
+21, -0
 1@@ -0,0 +1,21 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the MAKECMDGOALS variable.";
 5+
 6+$details = "\
 7+We construct a makefile with various targets, all of which print out
 8+\$(MAKECMDGOALS), then call it different ways.";
 9+
10+run_make_test(q!
11+.DEFAULT all:
12+#TAB#@echo $(MAKECMDGOALS)
13+!,
14+                       '', "\n");
15+
16+run_make_test(undef, "all", "all\n");
17+
18+run_make_test(undef, "foo bar baz yaz",
19+              "foo bar baz yaz\nfoo bar baz yaz\nfoo bar baz yaz\nfoo bar baz yaz\n");
20+
21+# This tells the test driver that the perl test script executed properly.
22+1;
+47, -0
 1@@ -0,0 +1,47 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the MAKEFILES variable.";
 5+
 6+$makefile2 = &get_tmpfile;
 7+$makefile3 = &get_tmpfile;
 8+
 9+open(MAKEFILE,"> $makefile2");
10+print MAKEFILE <<EOF;
11+M2 = m2
12+NDEF: ; \@echo RULE FROM MAKEFILE 2
13+EOF
14+close(MAKEFILE);
15+
16+
17+open(MAKEFILE,"> $makefile3");
18+print MAKEFILE <<EOF;
19+M3 = m3
20+NDEF3: ; \@echo RULE FROM MAKEFILE 3
21+EOF
22+close(MAKEFILE);
23+
24+run_make_test(q!
25+all: ; @echo DEFAULT RULE: M2=$(M2) M3=$(M3)
26+!,
27+              ["MAKEFILES=$makefile2 $makefile3"], "DEFAULT RULE: M2=m2 M3=m3\n");
28+
29+# TEST 2: Verify that included makefiles don't set the default goal.
30+# See Savannah bug #13401.
31+
32+create_file('xx-inc.mk', '
33+include_goal: ; @echo $@
34+include xx-ind.mk
35+');
36+
37+create_file('xx-ind.mk', '
38+indirect_goal: ; @echo $@
39+');
40+
41+run_make_test(q!
42+top: ; @echo $@
43+!,
44+              'MAKEFILES=xx-inc.mk', "top\n");
45+
46+unlink(qw(xx-inc.mk xx-ind.mk));
47+
48+1;
+929, -0
  1@@ -0,0 +1,929 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test proper behavior of MAKEFLAGS";
  5+
  6+$details = "DETAILS";
  7+
  8+# Normal flags aren't prefixed with "-"
  9+run_make_test(q!
 10+all: ; @echo /$(MAKEFLAGS)/
 11+!,
 12+              '-e -r -R', '/erR/');
 13+
 14+# Long arguments mean everything is prefixed with "-"
 15+run_make_test(q!
 16+all: ; @echo /$(MAKEFLAGS)/
 17+!,
 18+              '--no-print-directory -e -r -R --trace', "#MAKEFILE#:2: update target 'all' due to: target does not exist
 19+echo /erR --trace --no-print-directory/
 20+/erR --trace --no-print-directory/");
 21+
 22+
 23+# Recursive invocations of make should accumulate MAKEFLAGS values.
 24+# Savannah bug #2216
 25+run_make_test(q!
 26+MSG = Fails
 27+.RECIPEPREFIX = >
 28+all:
 29+> @echo '$@: MAKEFLAGS=$(MAKEFLAGS)'
 30+> @MSG=Works $(MAKE) -e -f #MAKEFILE# jump
 31+jump:
 32+> @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
 33+> @$(MAKE) -f #MAKEFILE# print
 34+print:
 35+> @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
 36+.PHONY: all jump print
 37+!,
 38+                  '--no-print-directory',
 39+                  'all: MAKEFLAGS= --no-print-directory
 40+jump Works: MAKEFLAGS=e --no-print-directory
 41+print Works: MAKEFLAGS=e --no-print-directory');
 42+
 43+# Ensure MAKEFLAGS updates are handled immediately rather than later
 44+
 45+mkdir('foo', 0777);
 46+mkdir('bar', 0777);
 47+
 48+run_make_test(q!
 49+$(info MAKEFLAGS=$(MAKEFLAGS))
 50+$(info INCLUDE_DIRS=$(.INCLUDE_DIRS))
 51+MAKEFLAGS += -Ibar
 52+$(info MAKEFLAGS=$(MAKEFLAGS))
 53+$(info INCLUDE_DIRS=$(.INCLUDE_DIRS))
 54+.PHONY: all
 55+all: ; @echo 'MAKEFLAGS=$(MAKEFLAGS)' "\$$MAKEFLAGS=$$MAKEFLAGS"
 56+!,
 57+              '-I- -Ifoo', 'MAKEFLAGS= -I- -Ifoo
 58+INCLUDE_DIRS=foo
 59+MAKEFLAGS= -I- -Ifoo -Ibar
 60+INCLUDE_DIRS=foo bar
 61+MAKEFLAGS= -I- -Ifoo -Ibar $MAKEFLAGS= -I- -Ifoo -Ibar');
 62+
 63+rmdir('foo');
 64+rmdir('bar');
 65+
 66+# Test that command line switches are all present in MAKEFLAGS.
 67+# sv 62514.
 68+my @opts;
 69+my @flavors;
 70+
 71+# Simple flags.
 72+@opts = ('i', 'k', 'n', 'q', 'r', 's', 'w', 'd');
 73+exists $FEATURES{'check-symlink'} and push @opts, 'L';
 74+@flavors = ('=', ':=', ':::=', '+=-');
 75+
 76+for my $fl (@flavors) {
 77+for my $opt (@opts) {
 78+  run_make_test("
 79+MAKEFLAGS${fl}B
 80+all:; \$(info makeflags='\$(MAKEFLAGS)')
 81+", "-$opt", "/makeflags='B$opt'/");
 82+}
 83+}
 84+
 85+# Strawberry Perl's exec()--or something!--appears to replace all /tmp with the
 86+# user's %TEMP% value so we can't use that for -I testing.  Make a directory.
 87+
 88+mkdir('localtmp', 0777);
 89+
 90+# Switches which carry arguments.
 91+@opts = (' -Ilocaltmp', ' -Onone', ' --debug=b', ' -l2.5');
 92+for my $fl (@flavors) {
 93+for my $opt (@opts) {
 94+  run_make_test("
 95+MAKEFLAGS${fl}B
 96+all:; \$(info makeflags='\$(MAKEFLAGS)')
 97+", "$opt", "/makeflags='B$opt'/");
 98+}
 99+}
100+
101+# Long options which take no arguments.
102+# sv 62514.
103+@opts = (' --no-print-directory', ' --warn=undefined-var', ' --trace');
104+for my $fl (@flavors) {
105+for my $opt (@opts) {
106+run_make_test("
107+MAKEFLAGS${fl}B
108+all:; \$(info makeflags='\$(MAKEFLAGS)')
109+", "$opt", "/makeflags='B$opt'/");
110+}
111+}
112+
113+# Test that make filters out duplicates.
114+# Each option is specified in the makefile, env and on the command line.
115+@opts = (' -Ilocaltmp', ' -Onone', ' --debug=b', ' -l2.5');
116+for my $fl (@flavors) {
117+for my $opt (@opts) {
118+$ENV{'MAKEFLAGS'} = $opt;
119+  run_make_test("
120+MAKEFLAGS${fl}B $opt
121+all:; \$(info makeflags='\$(MAKEFLAGS)')
122+", "$opt", "/makeflags='B$opt'/");
123+}
124+}
125+
126+# Test that make filters out duplicates.
127+# Each option is specified in the makefile, env and on the command line.
128+# decode_switches reallocates when the number of parameters in sl->list exceeds 5.
129+# This test exercises the realloc branch.
130+for my $fl (@flavors) {
131+$ENV{'MAKEFLAGS'} = '-I1 -Onone --debug=b -l2.5 -I2 -I3 -I4 -I5 -I6 -I2 -I2';
132+run_make_test("
133+MAKEFLAGS${fl}B -I1 -Onone --debug=b -l2.5 -I2 -I3 -I4 -I5 -I6 -I2 -I2
134+all:; \$(info makeflags='\$(MAKEFLAGS)')
135+",
136+'-I1 -Onone --debug=b -l2.5 -I2 -I3 -I4 -I5 -I6',
137+"/makeflags='B -I1 -I2 -I3 -I4 -I5 -I6 -l2.5 -Onone --debug=b'/");
138+}
139+
140+# A mix of multiple flags from env, the makefile and command line.
141+# Skip -L since it's not available everywhere
142+for my $fl (@flavors) {
143+$ENV{'MAKEFLAGS'} = 'ikB --no-print-directory --warn=undefined-var --trace';
144+run_make_test("
145+MAKEFLAGS${fl}iknqrswd -Ilocaltmp -Ilocaltmp -Onone -Onone -l2.5 -l2.5
146+all:; \$(info makeflags='\$(MAKEFLAGS)')
147+",
148+'-Onone -l2.5 -l2.5 -Onone -Ilocaltmp -iknqrswd -i -n -s -k -Ilocaltmp',
149+"/makeflags='Bdiknqrsw -Ilocaltmp -l2.5 -Onone --trace --warn=undefined-var'/");
150+}
151+
152+# Verify MAKEFLAGS are all available to shell function at parse time.
153+for my $fl (@flavors) {
154+my $answer = 'Biknqrs -Ilocaltmp -l2.5 -Onone --no-print-directory --warn=undefined-var';
155+$ENV{'MAKEFLAGS'} = 'ikB --no-print-directory --warn=undefined-var';
156+run_make_test("
157+MAKEFLAGS${fl}iknqrsw -Ilocaltmp -Ilocaltmp -Onone -Onone -l2.5 -l2.5 --no-print-directory
158+\$(info at parse time '\$(MAKEFLAGS)')
159+XX := \$(shell echo \"\$\$MAKEFLAGS\")
160+all:; \$(info at build time makeflags='\$(XX)')
161+",
162+'-Onone -l2.5 -l2.5 -Onone -Ilocaltmp -iknqrs -i -n -s -k -Ilocaltmp',
163+"at parse time '$answer'
164+at build time makeflags='$answer'");
165+}
166+
167+# Verify MAKEFLAGS and command line definitions are all available to shell function at parse time.
168+for my $fl (@flavors) {
169+$ENV{'MAKEFLAGS'} = 'ikB --no-print-directory --warn=undefined-var';
170+my $answer = 'Biknqrs -Ilocaltmp -l2.5 -Onone --no-print-directory --warn=undefined-var -- hello=world';
171+run_make_test("
172+MAKEFLAGS${fl}iknqrsw -Ilocaltmp -Ilocaltmp -Onone -Onone -l2.5 -l2.5 --no-print-directory
173+\$(info at parse time '\$(MAKEFLAGS)')
174+XX := \$(shell echo \"\$\$MAKEFLAGS\")
175+all:; \$(info at build time makeflags='\$(XX)')
176+",
177+'-Onone -l2.5 -l2.5 -Onone -Ilocaltmp -iknqrs -i -n -s -k -Ilocaltmp hello=world',
178+"at parse time '$answer'
179+at build time makeflags='$answer'");
180+}
181+
182+# Verify that command line arguments are included in MAKEFLAGS
183+run_make_test(q!
184+all: ; @echo $(MAKEFLAGS)
185+!,
186+              '-e FOO=bar -r -R', 'erR -- FOO=bar');
187+
188+# Long arguments mean everything is prefixed with "-"
189+run_make_test(q!
190+all: ; @echo /$(MAKEFLAGS)/
191+!,
192+              '--no-print-directory -e -r -R --trace FOO=bar',
193+              "#MAKEFILE#:2: update target 'all' due to: target does not exist
194+echo /erR --trace --no-print-directory -- FOO=bar/
195+/erR --trace --no-print-directory -- FOO=bar/");
196+
197+
198+# sv 63347.
199+# Verify that command line arguments are included in MAKEFLAGS
200+# when makefiles are parsed.
201+my $answer = 'erR -- hello:=world FOO=bar';
202+run_make_test(q!
203+$(info $(MAKEFLAGS))
204+all:; $(info $(MAKEFLAGS))
205+!, '-e FOO=bar -r -R hello:=world',
206+"$answer
207+$answer
208+#MAKE#: 'all' is up to date.\n");
209+
210+# sv 63347.
211+# Same as above, with makefile setting the value of the same variables as
212+# defined on the cli.
213+$answer = 'erR -- hello:=world FOO=bar';
214+run_make_test(q!
215+$(info $(MAKEFLAGS))
216+FOO=moon
217+hello:=moon
218+$(info $(MAKEFLAGS))
219+all:; $(info $(MAKEFLAGS))
220+!, '-e FOO=bar -r -R hello:=world',
221+"$answer
222+$answer
223+$answer
224+#MAKE#: 'all' is up to date.\n");
225+
226+# sv 63347.
227+# Same as above, with makefile overriding the value of cli definition.
228+$answer = 'erR -- hello:=world FOO=bar';
229+run_make_test(q!
230+$(info $(MAKEFLAGS))
231+override FOO=moon
232+override hello:=moon
233+export hello
234+$(info $(MAKEFLAGS))
235+all:; $(info $(MAKEFLAGS))
236+!, '-e FOO=bar -r -R hello:=world',
237+"$answer
238+$answer
239+$answer
240+#MAKE#: 'all' is up to date.\n");
241+
242+# Same as above, and makefile overrides the value of cli definition.
243+# resets MAKEOVERRIDES.
244+$answer = 'rR -- hello:=world FOO=bar';
245+run_make_test(q!
246+$(info $(MAKEFLAGS))
247+override FOO=moon
248+override hello:=moon
249+export hello
250+$(info $(MAKEFLAGS))
251+MAKEOVERRIDES=
252+$(info $(MAKEFLAGS))
253+all:; $(info $(MAKEFLAGS))
254+!, 'FOO=bar -r -R hello:=world',
255+"$answer
256+$answer
257+rR -- \nrR
258+#MAKE#: 'all' is up to date.\n");
259+
260+# sv 63347.
261+# MAKEFLAGS set is env and makefile sets MAKEFLAGS and there is a command
262+# line definition.
263+$answer = ' -- bye=moon hello=world';
264+$ENV{'MAKEFLAGS'} = 'hello=world';
265+run_make_test(q!
266+$(info $(MAKEFLAGS))
267+all:; $(info $(MAKEFLAGS))
268+!, 'bye=moon',
269+" -- bye=moon hello=world
270+ -- bye=moon hello=world
271+#MAKE#: 'all' is up to date.\n");
272+
273+# sv 63347.
274+# Conditional assignment and MAKEFLAGS.
275+$answer = 'B -- bye=moon hello=world';
276+$ENV{'MAKEFLAGS'} = 'hello=world';
277+run_make_test(q!
278+$(info $(MAKEFLAGS))
279+MAKEFLAGS?=-k
280+$(info $(MAKEFLAGS))
281+all:; $(info $(MAKEFLAGS))
282+!, '-B bye=moon',
283+"$answer
284+$answer
285+$answer
286+#MAKE#: 'all' is up to date.\n");
287+
288+# sv 63347.
289+# MAKEFLAGS set is env and makefile sets MAKEFLAGS and there is a command
290+# line definition.
291+for my $fl (@flavors) {
292+my $answer = ' -- bye=moon hello=world';
293+$ENV{'MAKEFLAGS'} = 'hello=world';
294+run_make_test("
295+\$(info \$(MAKEFLAGS))
296+MAKEFLAGS${fl}R
297+\$(info \$(MAKEFLAGS))
298+all:; \$(info \$(MAKEFLAGS))
299+", 'bye=moon',
300+"$answer
301+rR$answer
302+rR$answer
303+#MAKE#: 'all' is up to date.\n");
304+}
305+
306+# sv 63347.
307+# Test changes introduced by makefiles to MAKEFLAGS.
308+for my $fl (@flavors) {
309+my $answer = 'rR --no-print-directory -- hello:=world FOO=bar';
310+run_make_test(q!
311+MAKEFLAGS+=--no-print-directory
312+$(info $(MAKEFLAGS))
313+MAKEFLAGS+=-k
314+$(info $(MAKEFLAGS))
315+all:; $(info $(MAKEFLAGS))
316+!, 'FOO=bar -r -R hello:=world',
317+"$answer
318+k$answer
319+k$answer
320+#MAKE#: 'all' is up to date.\n");
321+}
322+
323+# sv 63347.
324+# Test changes introduced by makefiles to MAKEFLAGS.
325+# Same as above, but with -e.
326+for my $fl (@flavors) {
327+my $answer = 'erR -- hello:=world FOO=bar';
328+run_make_test(q!
329+MAKEFLAGS+=--no-print-directory
330+$(info $(MAKEFLAGS))
331+MAKEFLAGS+=-k
332+$(info $(MAKEFLAGS))
333+all:; $(info $(MAKEFLAGS))
334+!, '-e FOO=bar -r -R hello:=world',
335+"$answer
336+$answer
337+$answer
338+#MAKE#: 'all' is up to date.\n");
339+}
340+
341+mkdir('bye', 0777);
342+
343+create_file('bye/makefile',
344+'hello=moon
345+all:; $(info $(hello))');
346+
347+# sv 63347.
348+# Test that a cli definition takes precedence over a definition set in
349+# submake.
350+run_make_test(q!
351+v:=$(shell $(MAKE) -C bye --no-print-directory)
352+all: ; $(info $(v))
353+!, 'hello=world', "world #MAKE#[1]: 'all' is up to date.\n#MAKE#: 'all' is up to date.");
354+
355+# Same as above with the shell assignment operator.
356+run_make_test(q!
357+v \!= $(MAKE) -C bye --no-print-directory
358+all: ; $(info $(v))
359+!, 'hello=world', "world #MAKE#[1]: 'all' is up to date.\n#MAKE#: 'all' is up to date.");
360+
361+unlink('bye/makefile');
362+rmdir('bye');
363+
364+# sv 63347
365+# Invalid command line variable definition.
366+run_make_test(q!
367+all:; $(info $(hello))
368+!, 'hello=\'$(world\'', "#MAKEFILE#:2: *** unterminated variable reference.  Stop.\n", 512);
369+
370+# sv 63347
371+# An unused invalid command line variable definition is ignored.
372+run_make_test(q!
373+all:; $(info good)
374+!, 'hello=\'$(world\'', "good\n#MAKE#: 'all' is up to date.\n");
375+
376+
377+
378+# sv 63537
379+# Certain switches can be flipped on and off.
380+# -k/-S, -w/--no-print-directory and -s/--no-silent.
381+# Test the following aspects of behavior of these switches
382+# 1. A switch can be enabled or disabled in makefile.
383+# 2. A switch can be enabled or disabled in env.
384+# 3. A switch can be enabled or disabled on the command line.
385+# 4. Command line beats makefile.
386+# 5. Env beats makefile.
387+# 6. Command line beats env.
388+# 7. MAKEFLAGS contains each specified switch at parse and build time.
389+# 8. If contradicting switches are specified in multiple origins, MAKEFLAGS
390+#    contains the winning switch at parse and build time.
391+# 9. MAKEFLAGS does not contain the beaten switch.
392+
393+@flavors = ('=', ':=', ':::=', '+=');
394+
395+# sv 63537
396+# -w vs --no-print-directory
397+
398+# -w on the command line.
399+run_make_test(q!
400+$(info $(MAKEFLAGS))
401+all:; $(info $(MAKEFLAGS))
402+!, '-w',
403+"#MAKE#: Entering directory '#PWD#'
404+w
405+w
406+#MAKE#: 'all' is up to date.
407+#MAKE#: Leaving directory '#PWD#'\n");
408+
409+# -w in the env.
410+$ENV{'MAKEFLAGS'} = '-w';
411+run_make_test(q!
412+$(info $(MAKEFLAGS))
413+all:; $(info $(MAKEFLAGS))
414+!, '',
415+"#MAKE#: Entering directory '#PWD#'
416+w
417+w
418+#MAKE#: 'all' is up to date.
419+#MAKE#: Leaving directory '#PWD#'\n");
420+
421+# -w in env, --no-print-directory on the command line.
422+$ENV{'MAKEFLAGS'} = '-w';
423+run_make_test(q!
424+$(info $(MAKEFLAGS))
425+all:; $(info $(MAKEFLAGS))
426+!, '--no-print-directory',
427+" --no-print-directory
428+ --no-print-directory
429+#MAKE#: 'all' is up to date.\n");
430+
431+# --no-print-directory in env, -w on the command line.
432+$ENV{'MAKEFLAGS'} = '--no-print-directory';
433+run_make_test(q!
434+$(info $(MAKEFLAGS))
435+all:; $(info $(MAKEFLAGS))
436+!, '-w',
437+"#MAKE#: Entering directory '#PWD#'
438+w
439+w
440+#MAKE#: 'all' is up to date.
441+#MAKE#: Leaving directory '#PWD#'\n");
442+
443+delete $ENV{'MAKEFLAGS'};
444+
445+# -w in makefile.
446+for my $fl (@flavors) {
447+run_make_test("
448+MAKEFLAGS${fl}-w
449+\$(info \$(MAKEFLAGS))
450+all:; \$(info \$(MAKEFLAGS))
451+", '',
452+"#MAKE#: Entering directory '#PWD#'
453+w
454+w
455+#MAKE#: 'all' is up to date.
456+#MAKE#: Leaving directory '#PWD#'\n");
457+}
458+
459+# sv 63537
460+# -w in makefile, --no-print-directory on the command line.
461+for my $fl (@flavors) {
462+run_make_test("
463+MAKEFLAGS${fl}-w
464+\$(info \$(MAKEFLAGS))
465+all:; \$(info \$(MAKEFLAGS))
466+", '--no-print-directory',
467+" --no-print-directory
468+ --no-print-directory
469+#MAKE#: 'all' is up to date.\n");
470+}
471+
472+mkdir('lib2', 0777);
473+create_file('lib2/makefile', 'all:; $(info $(MAKEFLAGS))');
474+
475+# sv 63537
476+# Default, no -w or --no-print-directory is specified.
477+run_make_test(q!
478+all:; $(MAKE) -C lib2
479+!, '',
480+"#MAKEPATH# -C lib2
481+#MAKE#[1]: Entering directory '#PWD#/lib2'
482+
483+#MAKE#[1]: 'all' is up to date.
484+#MAKE#[1]: Leaving directory '#PWD#/lib2'\n");
485+
486+# sv 63537
487+# --no-print-directory in makefile, -w on the command line.
488+for my $fl (@flavors) {
489+run_make_test("
490+MAKEFLAGS${fl}--no-print-directory
491+\$(info \$(MAKEFLAGS))
492+all:
493+\t \$(info \$(MAKEFLAGS))
494+\t \$(MAKE) -C lib2
495+", '-w',
496+"#MAKE#: Entering directory '#PWD#'
497+w
498+w
499+#MAKEPATH# -C lib2
500+#MAKE#[1]: Entering directory '#PWD#/lib2'
501+w
502+#MAKE#[1]: 'all' is up to date.
503+#MAKE#[1]: Leaving directory '#PWD#/lib2'
504+#MAKE#: Leaving directory '#PWD#'\n");
505+}
506+
507+# sv 63537
508+# --no-print-directory in makefile, -w in the env.
509+for my $fl (@flavors) {
510+$ENV{'MAKEFLAGS'} = '-w';
511+run_make_test("
512+MAKEFLAGS${fl}--no-print-directory
513+\$(info \$(MAKEFLAGS))
514+all:
515+\t \$(info \$(MAKEFLAGS))
516+\t \$(MAKE) -C lib2
517+", '',
518+"#MAKE#: Entering directory '#PWD#'
519+w
520+w
521+#MAKEPATH# -C lib2
522+#MAKE#[1]: Entering directory '#PWD#/lib2'
523+w
524+#MAKE#[1]: 'all' is up to date.
525+#MAKE#[1]: Leaving directory '#PWD#/lib2'
526+#MAKE#: Leaving directory '#PWD#'\n");
527+}
528+
529+unlink('lib2/makefile');
530+rmdir('lib2');
531+
532+# sv 63537
533+# -k vs -S.
534+
535+
536+# -S in env.
537+$ENV{'MAKEFLAGS'} = '-S';
538+run_make_test(q!
539+.RECIPEPREFIX := >
540+$(info $(MAKEFLAGS))
541+all: one two
542+one:
543+> $(info $(MAKEFLAGS))
544+> #HELPER# -q fail 1
545+two:; $(info $@)
546+!, '',
547+"S
548+S
549+#HELPER# -q fail 1
550+#MAKE#: *** [#MAKEFILE#:7: one] Error 1", 512);
551+
552+# -S in env, -k on the command line.
553+$ENV{'MAKEFLAGS'} = '-S';
554+run_make_test(q!
555+.RECIPEPREFIX := >
556+$(info $(MAKEFLAGS))
557+all: one two
558+one:
559+> $(info $(MAKEFLAGS))
560+> #HELPER# -q fail 1
561+two:; $(info $@)
562+!, '-k',
563+"k
564+k
565+#HELPER# -q fail 1
566+#MAKE#: *** [#MAKEFILE#:7: one] Error 1
567+two
568+#MAKE#: Target 'all' not remade because of errors.", 512);
569+
570+# -k in env.
571+$ENV{'MAKEFLAGS'} = '-k';
572+run_make_test(q!
573+.RECIPEPREFIX := >
574+$(info $(MAKEFLAGS))
575+all: one two
576+one:
577+> $(info $(MAKEFLAGS))
578+> #HELPER# -q fail 1
579+two:; $(info $@)
580+!, '',
581+"k
582+k
583+#HELPER# -q fail 1
584+#MAKE#: *** [#MAKEFILE#:7: one] Error 1
585+two
586+#MAKE#: Target 'all' not remade because of errors.", 512);
587+
588+# -k in env, -S on the command line.
589+$ENV{'MAKEFLAGS'} = '-k';
590+run_make_test(q!
591+.RECIPEPREFIX := >
592+$(info $(MAKEFLAGS))
593+all: one two
594+one:
595+> $(info $(MAKEFLAGS))
596+> #HELPER# -q fail 1
597+two:; $(info $@)
598+!, '-S',
599+"S
600+S
601+#HELPER# -q fail 1
602+#MAKE#: *** [#MAKEFILE#:7: one] Error 1", 512);
603+
604+delete $ENV{'MAKEFLAGS'};
605+
606+# -k in makefile.
607+for my $fl (@flavors) {
608+run_make_test("
609+MAKEFLAGS${fl}-k
610+\$(info \$(MAKEFLAGS))
611+all: one two
612+one:
613+\t \$(info \$(MAKEFLAGS))
614+\t #HELPER# -q fail 1
615+two:; \$(info \$@)
616+", '',
617+"k
618+k
619+#HELPER# -q fail 1
620+#MAKE#: *** [#MAKEFILE#:7: one] Error 1
621+two
622+#MAKE#: Target 'all' not remade because of errors.", 512);
623+}
624+
625+# sv 63537
626+# -k in makefile and -S on the command line.
627+for my $fl (@flavors) {
628+run_make_test("
629+MAKEFLAGS${fl}-k
630+\$(info \$(MAKEFLAGS))
631+all: one two
632+one:
633+\t \$(info \$(MAKEFLAGS))
634+\t #HELPER# -q fail 1
635+two:; \$(info \$@)
636+", '-S',
637+"S
638+S
639+#HELPER# -q fail 1
640+#MAKE#: *** [#MAKEFILE#:7: one] Error 1", 512);
641+}
642+
643+# sv 63537
644+# -k in makefile and -S in the env.
645+for my $fl (@flavors) {
646+$ENV{'MAKEFLAGS'} = '-S';
647+run_make_test("
648+MAKEFLAGS${fl}-k
649+\$(info \$(MAKEFLAGS))
650+all: one two
651+one:
652+\t \$(info \$(MAKEFLAGS))
653+\t #HELPER# -q fail 1
654+two:; \$(info \$@)
655+", '',
656+"S
657+S
658+#HELPER# -q fail 1
659+#MAKE#: *** [#MAKEFILE#:7: one] Error 1", 512);
660+}
661+
662+delete $ENV{'MAKEFLAGS'};
663+
664+# sv 63537
665+# -S in makefile.
666+for my $fl (@flavors) {
667+run_make_test("
668+MAKEFLAGS${fl}-S
669+\$(info \$(MAKEFLAGS))
670+all: one two
671+one:
672+\t \$(info \$(MAKEFLAGS))
673+\t #HELPER# -q fail 1
674+two:; \$(info \$@)
675+", '',
676+"S
677+S
678+#HELPER# -q fail 1
679+#MAKE#: *** [#MAKEFILE#:7: one] Error 1", 512);
680+}
681+
682+# -S in makefile and -k on the command line.
683+for my $fl (@flavors) {
684+run_make_test("
685+MAKEFLAGS${fl}-S
686+\$(info \$(MAKEFLAGS))
687+all: one two
688+one:
689+\t \$(info \$(MAKEFLAGS))
690+\t #HELPER# -q fail 1
691+two:; \$(info \$@)
692+", '-k',
693+"k
694+k
695+#HELPER# -q fail 1
696+#MAKE#: *** [#MAKEFILE#:7: one] Error 1
697+two
698+#MAKE#: Target 'all' not remade because of errors.", 512);
699+}
700+
701+# sv 63537
702+# -S in makefile and -k in the env.
703+for my $fl (@flavors) {
704+$ENV{'MAKEFLAGS'} = '-k';
705+run_make_test("
706+MAKEFLAGS${fl}-S
707+\$(info \$(MAKEFLAGS))
708+all: one two
709+one:
710+\t \$(info \$(MAKEFLAGS))
711+\t #HELPER# -q fail 1
712+two:; \$(info \$@)
713+", '',
714+"k
715+k
716+#HELPER# -q fail 1
717+#MAKE#: *** [#MAKEFILE#:7: one] Error 1
718+two
719+#MAKE#: Target 'all' not remade because of errors.", 512);
720+}
721+
722+
723+# sv 63537
724+# -s vs --no-silent.
725+
726+# -s in env.
727+$ENV{'MAKEFLAGS'} = '-s';
728+run_make_test(q!
729+$(info $(MAKEFLAGS))
730+all:; $(info $(MAKEFLAGS))
731+!, '', "s\ns");
732+
733+# -s in env, --no-silent on the command line.
734+$ENV{'MAKEFLAGS'} = '-s';
735+run_make_test(q!
736+$(info $(MAKEFLAGS))
737+all:; $(info $(MAKEFLAGS))
738+!, '--no-silent',
739+" --no-silent
740+ --no-silent
741+#MAKE#: 'all' is up to date.\n");
742+
743+# --no-silent in env.
744+$ENV{'MAKEFLAGS'} = '--no-silent';
745+run_make_test(q!
746+$(info $(MAKEFLAGS))
747+all:; $(info $(MAKEFLAGS))
748+!, '',
749+" --no-silent
750+ --no-silent
751+#MAKE#: 'all' is up to date.\n");
752+
753+# --no-silent in env, -s on the command line.
754+$ENV{'MAKEFLAGS'} = '--no-silent';
755+run_make_test(q!
756+$(info $(MAKEFLAGS))
757+all:; $(info $(MAKEFLAGS))
758+!, '-s', "s\ns");
759+
760+delete $ENV{'MAKEFLAGS'};
761+
762+# -s in the makefile.
763+for my $fl (@flavors) {
764+run_make_test("
765+MAKEFLAGS${fl}-s
766+\$(info \$(MAKEFLAGS))
767+all:; \$(info \$(MAKEFLAGS))
768+", '', "s\ns");
769+}
770+
771+# sv 63537
772+# -s in makefile and --no-silent on the command line.
773+for my $fl (@flavors) {
774+run_make_test("
775+MAKEFLAGS${fl}-s
776+\$(info \$(MAKEFLAGS))
777+all:; \$(info \$(MAKEFLAGS))
778+", '--no-silent',
779+" --no-silent
780+ --no-silent
781+#MAKE#: 'all' is up to date.\n");
782+}
783+
784+# sv 63537
785+# -s in makefile and --no-silent in the env.
786+for my $fl (@flavors) {
787+$ENV{'MAKEFLAGS'} = '--no-silent';
788+run_make_test("
789+MAKEFLAGS${fl}-s
790+\$(info \$(MAKEFLAGS))
791+all:; \$(info \$(MAKEFLAGS))
792+", '',
793+" --no-silent
794+ --no-silent
795+#MAKE#: 'all' is up to date.\n");
796+}
797+
798+delete $ENV{'MAKEFLAGS'};
799+
800+# sv 63537
801+# --no-silent in makefile.
802+for my $fl (@flavors) {
803+run_make_test("
804+MAKEFLAGS${fl}--no-silent
805+\$(info \$(MAKEFLAGS))
806+all:; \$(info \$(MAKEFLAGS))
807+", '',
808+" --no-silent
809+ --no-silent
810+#MAKE#: 'all' is up to date.\n");
811+}
812+
813+# sv 63537
814+# --no-silent in makefile and -s on the command line.
815+for my $fl (@flavors) {
816+run_make_test("
817+MAKEFLAGS${fl}--no-silent
818+\$(info \$(MAKEFLAGS))
819+all:; \$(info \$(MAKEFLAGS))
820+", '-s', "s\ns");
821+}
822+
823+# sv 63537
824+# --no-silent in makefile and -s in the env.
825+for my $fl (@flavors) {
826+$ENV{'MAKEFLAGS'} = '-s';
827+run_make_test("
828+MAKEFLAGS${fl}--no-silent
829+\$(info \$(MAKEFLAGS))
830+all:; \$(info \$(MAKEFLAGS))
831+", '', "s\ns");
832+}
833+
834+delete $ENV{'MAKEFLAGS'};
835+
836+# sv 63537
837+# Multiple --debug switches from various origins are all combined.
838+# Because run_make_test regex matching facility does not allow to match against
839+# multiple lines, run the test twice. During the first run match the output of
840+# --debug=b, during the second run match the output of --debug=-j.
841+#
842+# --debug=b in makefile.
843+for my $fl (@flavors) {
844+run_make_test("
845+MAKEFLAGS${fl}--debug=b
846+hello:; touch \$@
847+.PHONY: hello
848+", '', "/Updating makefiles/");
849+}
850+
851+# --debug=b in makefile, --debug=j on the command line.
852+# Test for --debug=j output.
853+for my $fl (@flavors) {
854+run_make_test("
855+MAKEFLAGS${fl}--debug=b
856+hello:; touch \$@
857+.PHONY: hello
858+", '--debug=j', "/Putting child/");
859+}
860+
861+# --debug=b in makefile, --debug=j on the command line.
862+# Test for --debug=b output.
863+for my $fl (@flavors) {
864+run_make_test("
865+MAKEFLAGS${fl}--debug=b
866+hello:; touch \$@
867+.PHONY: hello
868+", '--debug=j', "/Updating makefiles/");
869+}
870+
871+# --debug=j in makefile, --debug=b on the command line.
872+# Test that MAKEFLAGS contains --debug=b.
873+run_make_test(q!
874+MAKEFLAGS=--debug=j
875+$(info makeflags=$(MAKEFLAGS))
876+hello:; touch $@
877+.PHONY: hello
878+!, '--debug=b', "/makeflags= --debug=b/");
879+
880+# --debug=b in makefile, --debug=j in the env.
881+# Test for --debug=j output.
882+for my $fl (@flavors) {
883+$ENV{'MAKEFLAGS'} = '--debug=j';
884+run_make_test("
885+MAKEFLAGS${fl}--debug=b
886+hello:; touch \$@
887+.PHONY: hello
888+", '', "/Putting child/");
889+}
890+
891+# --debug=b in makefile, --debug=j in the env.
892+# Test for --debug=b output.
893+for my $fl (@flavors) {
894+$ENV{'MAKEFLAGS'} = '--debug=j';
895+run_make_test("
896+MAKEFLAGS${fl}--debug=b
897+hello:; touch \$@
898+.PHONY: hello
899+", '', "/Updating makefiles/");
900+}
901+
902+unlink('hello');
903+
904+rmdir('localtmp');
905+
906+# sv 66037. An infinite loop when MAKEFLAGS is specified on the command line.
907+my @cli= ('-r MAKEFLAGS=-k hello=world',
908+'-r MAKEFLAGS=-k hello=world MAKEFLAGS=-R',
909+'-r MAKEFLAGS="-R -- hello=world MAKEFLAGS=-k"');
910+for my $c (@cli) {
911+run_make_test(q!
912+$(info hello=$(hello))
913+all:;
914+!, $c, "hello=world\n#MAKE#: 'all' is up to date.\n");
915+}
916+
917+run_make_test(q!
918+$(info hello=$(hello))
919+all:;
920+!, '-r MAKEFLAGS="-R -- hello=world MAKEFLAGS=hello=bye"',
921+"hello=bye\n#MAKE#: 'all' is up to date.\n");
922+
923+run_make_test(q!
924+$(info hello=$(hello))
925+all:;
926+!, '-r MAKEFLAGS="-R -- hello=world MAKEFLAGS=-s"',
927+"hello=world\n");
928+
929+# This tells the test driver that the perl test script executed properly.
930+1;
+33, -0
 1@@ -0,0 +1,33 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "The following test creates a makefile to test
 5+makelevels in Make. It prints \$(MAKELEVEL) and then
 6+prints the environment variable MAKELEVEL";
 7+
 8+open(MAKEFILE,"> $makefile");
 9+
10+# The Contents of the MAKEFILE ...
11+
12+print MAKEFILE <<EOF;
13+all:
14+\t\@echo MAKELEVEL is \$(MAKELEVEL)
15+\techo \$\$MAKELEVEL
16+EOF
17+
18+# END of Contents of MAKEFILE
19+
20+close(MAKEFILE);
21+
22+# RUN MAKE
23+
24+&run_make_with_options($makefile,"",&get_logfile);
25+
26+# SET ANSWER
27+
28+$answer = "MAKELEVEL is 0\necho \$MAKELEVEL\n1\n";
29+
30+# COMPARE RESULTS
31+
32+&compare_output($answer,&get_logfile(1));
33+
34+1;
+57, -0
 1@@ -0,0 +1,57 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the MAKE_RESTARTS variable.";
 5+
 6+# Test basic capability
 7+
 8+run_make_test('
 9+all: ; @:
10+$(info MAKE_RESTARTS=$(MAKE_RESTARTS))
11+include foo.x
12+foo.x: ; @touch $@
13+',
14+              '', 'MAKE_RESTARTS=
15+MAKE_RESTARTS=1');
16+
17+rmfiles('foo.x');
18+
19+# Test multiple restarts
20+
21+run_make_test('
22+all: ; @:
23+$(info MAKE_RESTARTS=$(MAKE_RESTARTS))
24+include foo.x
25+foo.x: ; @echo "include bar.x" > $@
26+bar.x: ; @touch $@
27+',
28+              '', 'MAKE_RESTARTS=
29+MAKE_RESTARTS=1
30+MAKE_RESTARTS=2');
31+
32+rmfiles('foo.x', 'bar.x');
33+
34+# Test multiple restarts and make sure the variable is cleaned up
35+
36+run_make_test('
37+.RECIPEPREFIX = >
38+recurse:
39+> @echo recurse MAKE_RESTARTS=$$MAKE_RESTARTS
40+> @$(MAKE) -f #MAKEFILE# all
41+all: ; @echo all MAKE_RESTARTS=$$MAKE_RESTARTS
42+$(info MAKE_RESTARTS=$(MAKE_RESTARTS))
43+include foo.x
44+foo.x: ; @echo "include bar.x" > $@
45+bar.x: ; @touch $@
46+',
47+              '', "MAKE_RESTARTS=
48+MAKE_RESTARTS=1
49+MAKE_RESTARTS=2
50+recurse MAKE_RESTARTS=
51+#MAKE#[1]: Entering directory '#PWD#'
52+MAKE_RESTARTS=
53+all MAKE_RESTARTS=
54+#MAKE#[1]: Leaving directory '#PWD#'");
55+
56+rmfiles('foo.x', 'bar.x');
57+
58+1;
+40, -0
 1@@ -0,0 +1,40 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Test the MAKEFILE_LIST variable.";
 5+
 6+create_file('incl2', "m2 := \$(MAKEFILE_LIST)\n");
 7+
 8+run_make_test(qq!
 9+m1 := \$(MAKEFILE_LIST)
10+include incl2
11+m3 := \$(MAKEFILE_LIST)
12+
13+all:
14+\t\@echo \$(m1)
15+\t\@echo \$(m2)
16+\t\@echo \$(m3)
17+!,
18+              '', "#MAKEFILE#\n#MAKEFILE# incl2\n#MAKEFILE# incl2\n");
19+
20+unlink('incl2');
21+
22+# SV 50823 -- makefiles containing '$' chars
23+
24+create_file('foo$bar', "m2 := \$(MAKEFILE_LIST)\n");
25+
26+run_make_test(qq!
27+m1 := \$(MAKEFILE_LIST)
28+include foo\$\$bar
29+m3 := \$(MAKEFILE_LIST)
30+
31+all:
32+\t\@echo '\$(m1)'
33+\t\@echo '\$(m2)'
34+\t\@echo '\$(m3)'
35+\t\@echo '\$(value MAKEFILE_LIST)'
36+!,
37+              '', "#MAKEFILE#\n#MAKEFILE# foo\$bar\n#MAKEFILE# foo\$bar\n#MAKEFILE# foo\$bar\n");
38+
39+unlink('foo$bar');
40+
41+1;
+107, -0
  1@@ -0,0 +1,107 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test proper handling of SHELL.";
  5+
  6+# If we don't have a POSIX shell available, never mind
  7+$is_posix_sh or return -1;
  8+
  9+# On Windows, shell names might not match
 10+if ($port_type eq 'W32') {
 11+    return -1;
 12+}
 13+
 14+$mshell = $sh_name;
 15+
 16+# According to POSIX, the value of SHELL in the environment has no impact on
 17+# the value in the makefile.
 18+
 19+$ENV{SHELL} = '/dev/null';
 20+run_make_test('all:;@echo "$(SHELL)"', '', $mshell);
 21+
 22+# According to POSIX, any value of SHELL set in the makefile should not be
 23+# exported to the subshell.  A more portable option might be to set SHELL to
 24+# be $^X (perl) in the makefile, and set .SHELLFLAGS to -e.
 25+
 26+$ENV{SHELL} = $mshell;
 27+
 28+my $altshell = "/./$mshell";
 29+my $altshell2 = "/././$mshell";
 30+
 31+if ($mshell =~ m,^([a-zA-Z]:)([\\/])(.*),) {
 32+    $altshell = "$1$2.$2$3";
 33+    $altshell2 = "$1$2.$2.$2$3";
 34+}
 35+
 36+run_make_test("SHELL := $altshell\n".'
 37+all:;@echo "$(SHELL) $$SHELL"
 38+', '', "$altshell $mshell");
 39+
 40+# As a GNU Make extension, if make's SHELL variable is explicitly exported,
 41+# then we really _DO_ export it.
 42+
 43+$ENV{SHELL} = $mshell;
 44+
 45+run_make_test("export SHELL := $altshell\n".'
 46+all:;@echo "$(SHELL) $$SHELL"
 47+', '', "$altshell $altshell");
 48+
 49+
 50+# Test out setting of SHELL, both exported and not, as a target-specific
 51+# variable.
 52+
 53+$ENV{SHELL} = $mshell;
 54+
 55+run_make_test("all: SHELL := $altshell\n".'
 56+all:;@echo "$(SHELL) $$SHELL"
 57+', '', "$altshell $mshell");
 58+
 59+$ENV{SHELL} = $mshell;
 60+
 61+run_make_test("
 62+SHELL := $altshell2
 63+one: two
 64+two: export SHELL := $altshell\n".'
 65+one two:;@echo "$@: $(SHELL) $$SHELL"
 66+', '', "two: $altshell $altshell\none: $altshell2 $mshell\n");
 67+
 68+# Test .SHELLFLAGS
 69+
 70+# We don't know the output here: on some systems, for example, every line
 71+# printed by the shell in -x mode has a trailing space!
 72+my $script = 'true; true';
 73+my $flags = '-xc';
 74+my $out = `"$sh_name" $flags '$script' 2>&1`;
 75+
 76+run_make_test(qq!
 77+.SHELLFLAGS = $flags
 78+all: ; \@$script
 79+!,
 80+              '', $out);
 81+
 82+# Do it again but add spaces to SHELLFLAGS
 83+
 84+# Some shells (*shakes fist at Solaris*) cannot handle multiple flags in
 85+# separate arguments.
 86+my $t = `"$sh_name" -e -c true 2>/dev/null`;
 87+my $multi_ok = $? == 0;
 88+
 89+if ($multi_ok) {
 90+    $flags = '-x -c';
 91+    run_make_test(qq!
 92+.SHELLFLAGS = $flags
 93+all: ; \@$script
 94+!,
 95+              '', $out);
 96+}
 97+
 98+$script = subst_make_string('true; #HELPER# -q fail 1; true');
 99+$flags = '-xec';
100+$out = `"$sh_name" $flags '$script' 2>&1`;
101+
102+run_make_test(qq!
103+.SHELLFLAGS = $flags
104+all: ; \@$script
105+!,
106+              '', "${out}#MAKE#: *** [#MAKEFILE#:3: all] Error 1", 512);
107+
108+1;
+201, -0
  1@@ -0,0 +1,201 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test the .WARNINGS variable.";
  5+
  6+my %warn_test = (
  7+    'warn' => 'warn', 'error warn' => 'warn',
  8+    'error' => 'error',
  9+    'ignore error ignore invalid-var,invalid-ref,undefined-var' => 'ignore,invalid-var,invalid-ref,undefined-var',
 10+    'invalid-ref:ignore error invalid-var:warn,,,,,undefined-var:error,,,,,' => '=error,invalid-var,invalid-ref:ignore,undefined-var:error'
 11+);
 12+
 13+# Verify that values set in .WARNINGS don't get passed to sub-makes
 14+
 15+while (my ($f, $r) = each %warn_test) {
 16+    run_make_test(qq!
 17+.WARNINGS = error
 18+\$(info MF=\$(MAKEFLAGS))
 19+all:; \@#HELPER# env MAKEFLAGS
 20+!,
 21+                  '', "MF=\nMAKEFLAGS=");
 22+}
 23+
 24+# Verify that make's special variables don't warn even if they're not set
 25+run_make_test(q!
 26+.WARNINGS = undefined-var
 27+vars := $(.VARIABLES) $(MAKECMDGOALS) $(MAKE_RESTARTS) $(CURDIR)
 28+vars += $(GNUMAKEFLAGS) $(MAKEFLAGS) $(MFLAGS) $(MAKE_COMMAND) $(MAKE)
 29+vars += $(MAKEFILE_LIST) $(MAKEOVERRIDES) $(-*-command-variables-*-)
 30+vars += $(.RECIPEPREFIX) $(.LOADED) $(.FEATURES)
 31+vars += $(SHELL) $(.SHELLFLAGS) $(MAKE_TERMOUT) $(MAKE_TERMERR)
 32+vars += $(.DEFAULT) $(.DEFAULT_GOAL) $(-*-eval-flags-*-) $(SUFFIXES)
 33+vars += $(VPATH) $(GPATH)
 34+all:;
 35+!,
 36+              '', "#MAKE#: 'all' is up to date.");
 37+
 38+# sv 63609.
 39+# Test for buffer overrun in warn_undefined.
 40+run_make_test(q!
 41+.WARNINGS = undefined-var
 42+all:;
 43+X := $(averyveryveryloooooooooooooooooooooooooooongvariablename)
 44+!,
 45+              '', "#MAKEFILE#:4: warning: reference to undefined variable 'averyveryveryloooooooooooooooooooooooooooongvariablename'
 46+#MAKE#: 'all' is up to date.\n"
 47+);
 48+
 49+# Check undefined variable warnings
 50+
 51+# With no options or with ignore, nothing should happen
 52+run_make_test('
 53+.WARNINGS := $(warnval)
 54+EMPTY =
 55+EREF = $(EMPTY)
 56+UREF = $(UNDEFINED)
 57+
 58+SEREF := $(EREF)
 59+SUREF := $(UREF)
 60+
 61+all: ; @echo ref $(EREF) $(UREF)',
 62+              '', 'ref');
 63+
 64+run_make_test(undef, 'warnval=undefined-var:ignore', 'ref');
 65+
 66+# Check warnings
 67+run_make_test(undef, 'warnval=undefined-var',
 68+              "#MAKEFILE#:8: warning: reference to undefined variable 'UNDEFINED'
 69+#MAKEFILE#:10: warning: reference to undefined variable 'UNDEFINED'
 70+ref");
 71+
 72+# Check and errors
 73+run_make_test(undef, 'warnval=undefined-var:error',
 74+              "#MAKEFILE#:8: *** reference to undefined variable 'UNDEFINED'.  Stop.", 512);
 75+
 76+# Check invalid variable reference warnings
 77+
 78+# With no options we still check for invalid references
 79+run_make_test('
 80+.WARNINGS = $(warnval)
 81+IREF = $(bad variable)
 82+SIREF := $(IREF)
 83+
 84+define nl
 85+
 86+
 87+endef
 88+
 89+all: ; @echo ref $(also$(nl)bad) $(IREF) $(SIREF)',
 90+              '', "#MAKEFILE#:3: warning: invalid variable reference 'bad variable'
 91+#MAKEFILE#:11: warning: invalid variable reference 'also\nbad'
 92+#MAKEFILE#:3: warning: invalid variable reference 'bad variable'
 93+ref");
 94+
 95+run_make_test(undef, 'warnval=ignore', 'ref');
 96+
 97+run_make_test(undef, 'warnval=invalid-ref:ignore', 'ref');
 98+
 99+# Check and errors
100+run_make_test(undef, 'warnval=invalid-ref:error',
101+              "#MAKEFILE#:3: *** invalid variable reference 'bad variable'.  Stop.", 512);
102+
103+# Check invalid variable name warnings
104+
105+# With no options we still check for invalid references
106+run_make_test('
107+.WARNINGS = $(warnval)
108+EMPTY =
109+SPACE = $(EMPTY) $(EMPTY)
110+BAD$(SPACE)VAR = foo
111+
112+define nl
113+
114+
115+endef
116+
117+NL$(nl)VAR = bar
118+
119+define BAD$(SPACE)DEF :=
120+foo
121+endef
122+
123+define NL$(nl)DEF :=
124+foo
125+endef
126+
127+all: ; @echo ref',
128+              '', "#MAKEFILE#:5: warning: invalid variable name 'BAD VAR'
129+#MAKEFILE#:12: warning: invalid variable name 'NL\nVAR'
130+#MAKEFILE#:14: warning: invalid variable name 'BAD DEF'
131+#MAKEFILE#:18: warning: invalid variable name 'NL\nDEF'
132+ref");
133+
134+run_make_test(undef, 'warnval=ignore', 'ref');
135+
136+run_make_test(undef, 'warnval=invalid-var:ignore', 'ref');
137+
138+# Check errors
139+run_make_test(undef, 'warnval=invalid-var:error',
140+              "#MAKEFILE#:5: *** invalid variable name 'BAD VAR'.  Stop.", 512);
141+
142+# Make sure unknown warnings and actions are only noted but not failed on:
143+# this allows makefiles to be portable to older versions where those warnings
144+# didn't exist
145+
146+run_make_test(q!
147+.WARNINGS = no-such-warn
148+all:;
149+!,
150+    '',"#MAKEFILE#:2: unknown warning 'no-such-warn': ignored\n#MAKE#: 'all' is up to date.");
151+
152+run_make_test(q!
153+.WARNINGS = invalid-var:no-such-action
154+all:;
155+!,
156+    '',"#MAKEFILE#:2: unknown warning action 'no-such-action': ignored\n#MAKE#: 'all' is up to date.");
157+
158+# sv 65739. Circular dependency.
159+run_make_test(q!
160+hello: hello; @:
161+!,
162+              '', "#MAKE#: circular hello <- hello dependency dropped\n");
163+run_make_test(q!
164+.WARNINGS = circular-dep:error
165+hello: hello; @:
166+!,
167+              '', "#MAKE#: *** circular hello <- hello dependency detected.  Stop.\n", 512);
168+run_make_test(q!
169+.WARNINGS = circular-dep:warn
170+hello: hello; @:
171+!,
172+              '', "#MAKE#: circular hello <- hello dependency dropped\n");
173+run_make_test(q!
174+.WARNINGS = circular-dep:ignore
175+hello: hello; @:
176+!,
177+              '', '');
178+
179+
180+# Validate .WARNINGS set as target-specific variables
181+# This is not supported (yet...?)
182+
183+# run_make_test(q!
184+# ok := $(undef)
185+# ref = $(undef)
186+
187+# all: enabled disabled enabled2 ;
188+
189+# .WARNINGS = undefined-var
190+
191+# enabled enabled2 disabled ref: ; $(info $@:$(ref))
192+
193+# disabled: .WARNINGS =
194+# disabled: ref
195+# !,
196+#     '', "#MAKEFILE#:9: reference to undefined variable 'undef'\nenabled:
197+# ref:
198+# disabled:
199+# #MAKEFILE#:9: reference to undefined variable 'undef'\nenabled2:
200+# #MAKE#: 'all' is up to date.");
201+
202+1;
+280, -0
  1@@ -0,0 +1,280 @@
  2+#                                                                    -*-perl-*-
  3+
  4+use warnings;
  5+
  6+my $description = "Test appending to variables of various origins.";
  7+
  8+# sv 64822, sv 36486.
  9+# Test various combinations of appends in the presence and absence of command
 10+# line definitions, env overrides and makefile overrides.
 11+# Test the following statements.
 12+# A target or pattern specific definition or append is available at build time
 13+# only.
 14+# A definition with a makefile override can only be appended to with another
 15+# override.
 16+# A definition with a makefile override can only be redefined with another
 17+# override.
 18+# A target or pattern specific definition takes precedence over a global
 19+# definition for that target.
 20+# A global variable is immune to a target or pattern specific definition or
 21+# append.
 22+# A target or pattern specific definition is immune to another target or pattern
 23+# specific definition or append.
 24+# A prerequisite inherits a target or pattern specific value from its target.
 25+# "phobos" inherits the value of "hello" from "mars".
 26+
 27+my @goals = ('phobos', 'mars');
 28+my @specificities = ('', 's: ', '%: ');
 29+my @inits = ('', 'hello=file', 'hello:=file', 'override hello=file');
 30+my @global_append = ('', 'hello+=red');
 31+my @blue_override = ('', 'override ');
 32+my @yellow_override = ('', 'override ');
 33+my @cmdline = ('', 'hello=cmd', 'hello:=cmd hello+=cmd2');
 34+my @env_ovr = ('', '-e');
 35+my @envs = ('', 'env');
 36+
 37+for my $goal (@goals) {
 38+ for my $spec (@specificities) {
 39+  for my $init (@inits) {
 40+   for my $ga (@global_append) {
 41+    for my $bovr (@blue_override) {
 42+     for my $yovr (@yellow_override) {
 43+      for my $dashe (@env_ovr) {
 44+       for my $env (@envs) {
 45+        for my $cmd (@cmdline) {
 46+
 47+        if ($env) {
 48+            $ENV{'hello'} = 'env';
 49+        } else {
 50+            delete $ENV{'hello'};
 51+        }
 52+
 53+        my $parse_time_answer = '';
 54+        my $build_time_answer = '';
 55+
 56+        # For goal "phobos" target is "", "phobos: " and "phobo%: ".
 57+        # For goal "mars" target is "", "mars: " and "mar%: ".
 58+        my $target = '';
 59+        if ($spec) {
 60+            $target = $goal;
 61+            chop($target);
 62+            $target .= $spec;
 63+        }
 64+
 65+        if ($init =~ 'override') {
 66+            $build_time_answer = 'file';
 67+        } elsif ($cmd) {
 68+            $build_time_answer = $cmd =~ 'cmd2' ? 'cmd cmd2' : 'cmd';
 69+        } elsif ($dashe and $env) {
 70+            $build_time_answer = 'env';
 71+        } elsif ($init and !$target and $ga) {
 72+            $build_time_answer = 'file red';
 73+        } elsif ($init) {
 74+            $build_time_answer = 'file';
 75+        } elsif ($env and $ga) {
 76+            $build_time_answer = 'env red';
 77+        } elsif ($env) {
 78+            $build_time_answer = 'env';
 79+        } elsif ($ga) {
 80+            $build_time_answer = 'red';
 81+        }
 82+
 83+        if ($bovr and $yovr) {
 84+            $build_time_answer .= ' ' if ($build_time_answer);
 85+            $build_time_answer .= 'blue yellow';
 86+        } elsif ($bovr) {
 87+            $build_time_answer .= ' ' if ($build_time_answer);
 88+            $build_time_answer .= 'blue';
 89+        } elsif ($yovr and !($init =~ 'override') and !$cmd and !($dashe and $env)) {
 90+            $build_time_answer .= ' ' if ($build_time_answer);
 91+            $build_time_answer .= 'blue yellow';
 92+        } elsif ($yovr) {
 93+            $build_time_answer .= ' ' if ($build_time_answer);
 94+            $build_time_answer .= 'yellow';
 95+        } elsif ($init =~ 'override') {
 96+        } elsif ($cmd) {
 97+        } elsif ($dashe and $env) {
 98+        } else {
 99+            $build_time_answer .= ' ' if ($build_time_answer);
100+            $build_time_answer .= 'blue yellow';
101+        }
102+
103+
104+        if ($cmd and $target) {
105+            $parse_time_answer = $cmd =~ 'cmd2' ? 'cmd cmd2' : 'cmd';
106+        } elsif ($env and !$dashe and $target and $ga) {
107+            $parse_time_answer = 'env red';
108+        } elsif ($env and $target) {
109+            $parse_time_answer = 'env';
110+        } elsif ($target and $ga) {
111+            $parse_time_answer = 'red';
112+        } elsif ($target) {
113+            $parse_time_answer = '';
114+        } else {
115+            $parse_time_answer = $build_time_answer;
116+        }
117+
118+        my $i = $init ? "$target$init" : '';
119+
120+        # moon and satur% specific settings test that target and pattern
121+        # settings specific to one target do not affect another target.
122+
123+        my $answer = $goal eq "mars" ?
124+            "$parse_time_answer\n$build_time_answer\n" # From parse time and from "phobos" recipe.
125+          . "$build_time_answer\n#MAKE#: 'mars' is up to date.\n" :  # From "mars" recipe.
126+            "$parse_time_answer\n$build_time_answer\n#MAKE#: 'phobos' is up to date.\n";
127+
128+
129+        run_make_test("
130+# goal = $goal
131+# init = $init
132+# target = $target
133+# ga = $ga
134+# bovr = $bovr
135+# yovr = $yovr
136+# cmd = $cmd
137+# env = $env
138+# dashe = $dashe
139+
140+moon: hello=1
141+moon: override hello+=2
142+
143+$i
144+$ga
145+$target${bovr}hello+=blue
146+$target${yovr}hello+=yellow
147+
148+satur%: override hello:=3
149+satur%: hello+=4
150+
151+\$(info \$(hello))
152+phobos:; \$(info \$(hello))
153+mars: phobos; \$(info \$(hello))
154+saturn:; \$(info \$(hello))
155+", "$dashe $cmd $goal", "$answer");
156+        }
157+       }
158+      }
159+     }
160+    }
161+   }
162+  }
163+ }
164+}
165+
166+# Preferably, we would want to run the tests below for all the combinations,
167+# generated by the loop above. However, that causes the test to take a lot of
168+# time.
169+
170+# The fix for sv 64822 went to recursively_expand_for_file.
171+# There are three code paths that lead to recursively_expand_for_file.
172+#  - export of a variable to target environment.
173+#  - expansion of a substitution reference.
174+#  - other expansions of a variable that was appended to.
175+# Test target env, substitution reference in parse and build modes.;
176+# Also test a mix of pattern and target specific definitions and appends.
177+
178+run_make_test(q!
179+al%: hello=file
180+al%: hello+=one
181+all: hello+=two
182+$(info $(hello))
183+all:; $(info $(hello))
184+!, "", "\nfile one two\n#MAKE#: 'all' is up to date.\n");
185+
186+run_make_test(q!
187+hello=file
188+al%: hello+=one
189+all: hello+=two
190+$(info $(hello:X=Y))
191+all:; $(info $(hello:X=Y))
192+!, "", "file\nfile one two\n#MAKE#: 'all' is up to date.\n");
193+
194+run_make_test(q!
195+hello=file
196+al%: hello+=one
197+all: hello+=two
198+export hello
199+$(info $(shell echo $$hello))
200+all:; $(info $(shell echo $$hello))
201+!, "", "file\nfile one two\n#MAKE#: 'all' is up to date.\n");
202+
203+# "phobos" inherits the value of "hello" from "mars". On top of that there are
204+# also "phobos" specific appends.
205+for my $goal (@goals) {
206+my $answer = $goal eq "mars" ?
207+    "\nminit mone mtwo pone ptwo\n" # From parse time and from "phobos" recipe.
208+  . "minit mone mtwo\n#MAKE#: 'mars' is up to date.\n" :  # From "mars" recipe.
209+    "\npone ptwo\n#MAKE#: 'phobos' is up to date.\n"; # From parse time and from "phobos" recipe.
210+
211+run_make_test("
212+mar%: hello=minit
213+mar%: hello+=mone
214+mars: hello+=mtwo
215+phobo%: hello+=pone
216+phobos: hello+=ptwo
217+\$(info \$(hello))
218+phobos:; \$(info \$(hello))
219+mars: phobos; \$(info \$(hello))
220+", "$goal", "$answer");
221+}
222+
223+# This test is similar to the one above. The difference is that here there is a
224+# pattern-specific definition of "hello" that matches "phobos".
225+run_make_test(q!
226+mar%: hello:=minit
227+mar%: hello+=mone
228+mars: hello+=mtwo
229+phobo%: hello:=pinit
230+phobo%: hello+=pone
231+phobos: hello+=ptwo
232+$(info $(hello))
233+phobos:; $(info $(hello))
234+mars: phobos; $(info $(hello))
235+!, 'phobos', "\npinit pone ptwo\n#MAKE#: 'phobos' is up to date.\n");
236+
237+# Test pattern and target specific appends to a global variable that has origin override.
238+# sv 36486.
239+my @ops = ('=', '+=', ':=');
240+@inits = ('', 'override ', 'al%: override ');
241+@specificities = ('', 'all: ', 'al%: ');
242+for my $init (@inits) {
243+ for my $spec (@specificities) {
244+  for my $op (@ops) {
245+
246+  my $build_time_answer = '';
247+  if ($init =~ ':' and $op eq '+=' and !$spec) {
248+      # This is the case where global variable obtains value 'one two three' at
249+      # parse time and later at build time a pattern or target specific
250+      # 'hello+=file' appends 'file'.
251+      # e.g.
252+      # al%: override hello+=file
253+      # hello+=one
254+      # hello+=two
255+      # hello+=three
256+      $build_time_answer = 'one two three file';
257+  } elsif ($init =~ 'override') {
258+      $build_time_answer = 'file';
259+  } else {
260+      $build_time_answer = 'file one two three';
261+  }
262+
263+  my $parse_time_answer = $init =~ ':' ? '' : 'file';
264+  if (!$spec and ($init ne 'override ')) {
265+      $parse_time_answer .= ' ' if $parse_time_answer;
266+      $parse_time_answer .= 'one two three';
267+  }
268+
269+  run_make_test("
270+${init}hello${op}file
271+${spec}hello+=one
272+${spec}hello+=two
273+${spec}hello+=three
274+\$(info \$(hello))
275+all:; \$(info \$(hello))
276+", "", "$parse_time_answer\n$build_time_answer\n#MAKE#: 'all' is up to date.\n");
277+  }
278+ }
279+}
280+
281+1;
+126, -0
  1@@ -0,0 +1,126 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test automatic variable setting.";
  5+
  6+$details = "";
  7+
  8+use Cwd;
  9+
 10+$dir = cwd;
 11+$dir =~ s,.*/([^/]+)$,../$1,;
 12+
 13+# simple test
 14+# Touch these into the past
 15+&utouch(-10, qw(foo.x baz.z));
 16+
 17+run_make_test(q!
 18+.SUFFIXES:
 19+.SUFFIXES: .x .y .z
 20+$(dir)/foo.x : baz.z $(dir)/bar.y baz.z
 21+#TAB#@echo '$$@ = $@, $$(@D) = $(@D), $$(@F) = $(@F)'
 22+#TAB#@echo '$$* = $*, $$(*D) = $(*D), $$(*F) = $(*F)'
 23+#TAB#@echo '$$< = $<, $$(<D) = $(<D), $$(<F) = $(<F)'
 24+#TAB#@echo '$$^ = $^, $$(^D) = $(^D), $$(^F) = $(^F)'
 25+#TAB#@echo '$$+ = $+, $$(+D) = $(+D), $$(+F) = $(+F)'
 26+#TAB#@echo '$$? = $?, $$(?D) = $(?D), $$(?F) = $(?F)'
 27+#TAB#touch $@
 28+
 29+$(dir)/bar.y baz.z : ; touch $@
 30+!,
 31+              "dir=$dir", "touch $dir/bar.y
 32+\$\@ = $dir/foo.x, \$(\@D) = $dir, \$(\@F) = foo.x
 33+\$* = $dir/foo, \$(*D) = $dir, \$(*F) = foo
 34+\$< = baz.z, \$(<D) = ., \$(<F) = baz.z
 35+\$^ = baz.z $dir/bar.y, \$(^D) = . $dir, \$(^F) = baz.z bar.y
 36+\$+ = baz.z $dir/bar.y baz.z, \$(+D) = . $dir ., \$(+F) = baz.z bar.y baz.z
 37+\$? = $dir/bar.y, \$(?D) = $dir, \$(?F) = bar.y
 38+touch $dir/foo.x\n");
 39+
 40+unlink(qw(foo.x bar.y baz.z));
 41+
 42+# test the SysV emulation of $$@ etc.
 43+
 44+run_make_test(q!
 45+.SECONDEXPANSION:
 46+.SUFFIXES:
 47+.DEFAULT: ; @echo '$@'
 48+
 49+$(dir)/foo $(dir)/bar: $@.x $$@.x $$$@.x $$$$@.x $$(@D).x $$(@F).x
 50+
 51+$(dir)/x.z $(dir)/y.z: $(dir)/%.z : $@.% $$@.% $$$@.% $$$$@.% $$(@D).% $$(@F).%
 52+
 53+$(dir)/biz: $$(@).x $${@}.x $${@D}.x $${@F}.x
 54+!,
 55+              "dir=$dir $dir/foo $dir/bar",
 56+              ".x\n$dir/foo.x\nx\n\$@.x\n$dir.x\nfoo.x\n$dir/bar.x\nbar.x\n");
 57+
 58+run_make_test(undef, "dir=$dir $dir/x.z $dir/y.z",
 59+              ".x\n$dir/x.z.x\nx\n\$@.x\n$dir.x\nx.z.x\n.y\n$dir/y.z.y\ny\n\$@.y\n$dir.y\ny.z.y\n");
 60+
 61+run_make_test(undef, "dir=$dir $dir/biz", "$dir/biz.x\n$dir.x\nbiz.x\n");
 62+
 63+# TEST #2 -- test for Savannah bug #12320.
 64+#
 65+run_make_test('
 66+.SUFFIXES: .b .src
 67+
 68+mbr.b: mbr.src
 69+#TAB#@echo $*
 70+
 71+mbr.src: ; @:',
 72+              '',
 73+              'mbr');
 74+
 75+# Same as above with second expansion.
 76+#
 77+run_make_test('
 78+.SECONDEXPANSION:
 79+.SUFFIXES: .b .src
 80+
 81+p:=mbr.src
 82+mbr.b: $$p
 83+#TAB#@echo $*
 84+
 85+mbr.src: ; @:',
 86+              '',
 87+              'mbr');
 88+
 89+# Test that $* is set to empty string for unknown suffixes.
 90+
 91+run_make_test('
 92+mbr.b: mbr.src
 93+#TAB#@echo star=$*
 94+
 95+mbr.src: ; @:',
 96+              '',
 97+              "star=\n");
 98+
 99+# TEST #3 -- test for Savannah bug #8154
100+# Make sure that nonexistent prerequisites are listed in $?, since they are
101+# considered reasons for the target to be rebuilt.
102+#
103+# See also Savannah bugs #16002 and #16051.
104+
105+touch('foo');
106+
107+run_make_test('
108+foo: bar ; @echo "\$$? = $?"
109+bar: ;',
110+              '',
111+              '$? = bar');
112+
113+unlink('foo');
114+
115+# TEST #4: ensure prereq ordering is correct when the command target has none
116+# See Savannah bug #21198
117+
118+run_make_test('
119+all : A B
120+all : ; @echo $@ -- $^ -- $<
121+all : C D
122+all : E F
123+A B C D E F G H : ; @:
124+',
125+              '', "all -- A B C D E F -- A\n");
126+
127+1;
+137, -0
  1@@ -0,0 +1,137 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test various flavors of conditional variable setting.";
  5+
  6+$details = "";
  7+
  8+# Test ?=
  9+
 10+run_make_test(q!
 11+x = bar
 12+y = baz
 13+foo ?= $(x)
 14+biz?=$(y)
 15+x = 10
 16+y = 20
 17+all:;@: $(info foo=$(foo) biz=$(biz))
 18+!,
 19+              '', "foo=10 biz=20");
 20+
 21+run_make_test(q!
 22+foo=1
 23+biz=2
 24+x = bar
 25+y = baz
 26+foo ?= $(x)
 27+biz?=$(y)
 28+x = 10
 29+y = 20
 30+all:;@: $(info foo=$(foo) biz=$(biz))
 31+!,
 32+              '', "foo=1 biz=2");
 33+
 34+# Test ?:=
 35+
 36+run_make_test(q!
 37+x = bar
 38+y = baz
 39+foo ?:= $(x)
 40+biz?:=$(y)
 41+x = 10
 42+y = 20
 43+all:;@: $(info foo=$(foo) biz=$(biz))
 44+!,
 45+              '', "foo=bar biz=baz");
 46+
 47+run_make_test(q!
 48+foo=1
 49+biz=2
 50+x = bar
 51+y = baz
 52+foo ?:= $(x)$(info expanded)
 53+biz?:=$(y)$(info expanded)
 54+x = 10
 55+y = 20
 56+all:;@: $(info foo=$(foo) biz=$(biz))
 57+!,
 58+              '', "foo=1 biz=2");
 59+
 60+# Test ?::=
 61+
 62+run_make_test(q!
 63+x = bar
 64+y = baz
 65+foo ?::= $(x)
 66+biz?::=$(y)
 67+x = 10
 68+y = 20
 69+all:;@: $(info foo=$(foo) biz=$(biz))
 70+!,
 71+              '', "foo=bar biz=baz");
 72+
 73+run_make_test(q!
 74+foo=1
 75+biz=2
 76+x = bar
 77+y = baz
 78+foo ?::= $(x)$(info expanded)
 79+biz?::=$(y)$(info expanded)
 80+x = 10
 81+y = 20
 82+all:;@: $(info foo=$(foo) biz=$(biz))
 83+!,
 84+              '', "foo=1 biz=2");
 85+
 86+# Test ?:::=
 87+
 88+run_make_test(q!
 89+x = bar
 90+y = baz
 91+foo ?:::= $(x)
 92+biz?:::=$(y)
 93+x = 10
 94+y = 20
 95+all:;@: $(info foo=$(foo) biz=$(biz))
 96+!,
 97+              '', "foo=bar biz=baz");
 98+
 99+run_make_test(q!
100+foo=1
101+biz=2
102+x = bar
103+y = baz
104+foo ?:::= $(x)$(info expanded)
105+biz?:::=$(y)$(info expanded)
106+x = 10
107+y = 20
108+all:;@: $(info foo=$(foo) biz=$(biz))
109+!,
110+              '', "foo=1 biz=2");
111+
112+# Test ?!=
113+
114+run_make_test(q/
115+x = bar
116+y = baz
117+foo ?!= echo $(x)
118+biz?!=echo $(y)
119+x = 10
120+y = 20
121+all:;@: $(info foo=$(foo) biz=$(biz))
122+/,
123+              '', "foo=bar biz=baz");
124+
125+run_make_test(q/
126+foo=1
127+biz=2
128+x = bar
129+y = baz
130+foo ?!= echo $(x)$(info expanded)
131+biz?!=echo $(y)$(info expanded)
132+x = 10
133+y = 20
134+all:;@: $(info foo=$(foo) biz=$(biz))
135+/,
136+              '', "foo=1 biz=2");
137+
138+1;
+343, -0
  1@@ -0,0 +1,343 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test define/endef variable assignments.";
  5+
  6+$details = "";
  7+
  8+# old-style basic define/endef
  9+
 10+run_make_test('
 11+define multi
 12+@echo hi
 13+echo there
 14+endef
 15+
 16+all: ; $(multi)
 17+',
 18+              '', "hi\necho there\nthere\n");
 19+
 20+# Various new-style define/endef
 21+
 22+run_make_test('
 23+FOO = foo
 24+
 25+define multi =
 26+echo hi
 27+@echo $(FOO)
 28+endef # this is the end
 29+
 30+define simple :=
 31+@echo $(FOO)
 32+endef
 33+
 34+define posix ::=
 35+@echo $(FOO)
 36+endef
 37+
 38+append = @echo a
 39+
 40+define append +=
 41+
 42+@echo b
 43+endef
 44+
 45+define cond ?= # this is a conditional
 46+@echo first
 47+endef
 48+
 49+define cond ?=
 50+@echo second
 51+endef
 52+
 53+FOO = there
 54+
 55+all: ; $(multi)
 56+#TAB#$(simple)
 57+#TAB#$(posix)
 58+#TAB#$(append)
 59+#TAB#$(cond)
 60+',
 61+              '', "echo hi\nhi\nthere\nfoo\nfoo\na\nb\nfirst\n");
 62+
 63+# Various new-style define/endef, with no spaces
 64+
 65+run_make_test(q!
 66+FOO = foo
 67+
 68+define multi=
 69+echo hi
 70+@echo $(FOO)
 71+endef # this is the end
 72+
 73+define simple:=
 74+@echo $(FOO)
 75+endef
 76+
 77+define posix::=
 78+@echo $(FOO)
 79+endef
 80+
 81+define posixbsd:::=
 82+@echo '$(FOO)$$bar'
 83+endef
 84+
 85+append = @echo a
 86+
 87+define append+=
 88+
 89+@echo b
 90+endef
 91+
 92+define cond?= # this is a conditional
 93+@echo first
 94+endef
 95+
 96+define cond?=
 97+@echo second
 98+endef
 99+
100+FOO = there
101+
102+all: ; $(multi)
103+#TAB#$(simple)
104+#TAB#$(posix)
105+#TAB#$(posixbsd)
106+#TAB#$(append)
107+#TAB#$(cond)
108+!,
109+              '', "echo hi\nhi\nthere\nfoo\nfoo\nfoo\$bar\na\nb\nfirst\n");
110+
111+# define in true section of conditional (containing conditional)
112+
113+run_make_test('
114+FOO = foo
115+NAME = def
116+def =
117+ifdef BOGUS
118+ define  $(subst e,e,$(NAME))     =
119+  ifeq (1,1)
120+   FOO = bar
121+  endif
122+ endef
123+endif
124+
125+$(eval $(def))
126+all: ; @echo $(FOO)
127+',
128+              'BOGUS=1', "bar\n");
129+
130+# define in false section of conditional (containing conditional)
131+
132+run_make_test(undef, '', "foo\n");
133+
134+# nested define (supported?)
135+
136+run_make_test('
137+define outer
138+ define inner
139+  A = B
140+ endef
141+endef
142+
143+$(eval $(outer))
144+
145+outer: ; @echo $(inner)
146+',
147+              '', "A = B\n");
148+
149+# NEGATIVE: Missing variable name
150+
151+run_make_test('
152+NAME =
153+define $(NAME)  =
154+ouch
155+endef
156+all: ; @echo ouch
157+',
158+              '', "#MAKEFILE#:3: *** empty variable name.  Stop.\n", 512);
159+
160+# NEGATIVE: extra text after define
161+
162+run_make_test('
163+NAME =
164+define NAME = $(NAME)
165+ouch
166+endef
167+all: ; @echo ok
168+',
169+              '', "#MAKEFILE#:3: extraneous text after 'define' directive\nok\n");
170+
171+# NEGATIVE: extra text after endef
172+
173+run_make_test('
174+NAME =
175+define NAME =
176+ouch
177+endef $(NAME)
178+all: ; @echo ok
179+',
180+              '', "#MAKEFILE#:5: extraneous text after 'endef' directive\nok\n");
181+
182+# NEGATIVE: missing endef
183+
184+run_make_test('
185+NAME =
186+all: ; @echo ok
187+define NAME =
188+ouch
189+endef$(NAME)
190+',
191+              '', "#MAKEFILE#:4: *** missing 'endef', unterminated 'define'.  Stop.\n", 512);
192+
193+# -------------------------
194+# Make sure that prefix characters apply properly to define/endef values.
195+#
196+# There's a bit of oddness here if you try to use a variable to hold the
197+# prefix character for a define.  Even though something like this:
198+#
199+#       define foo
200+#       echo bar
201+#       endef
202+#
203+#       all: ; $(V)$(foo)
204+#
205+# (where V=@) can be seen by the user to be obviously different than this:
206+#
207+#       define foo
208+#       $(V)echo bar
209+#       endef
210+#
211+#       all: ; $(foo)
212+#
213+# and the user thinks it should behave the same as when the "@" is literal
214+# instead of in a variable, that can't happen because by the time make
215+# expands the variables for the command line and sees it begins with a "@" it
216+# can't know anymore whether the prefix character came before the variable
217+# reference or was included in the first line of the variable reference.
218+
219+run_make_test('
220+define FOO
221+$(V1)echo hello
222+$(V2)echo world
223+endef
224+all: ; @$(FOO)
225+', '', 'hello
226+world');
227+
228+run_make_test(undef, 'V1=@ V2=@', 'hello
229+world');
230+
231+run_make_test('
232+define FOO
233+$(V1)echo hello
234+$(V2)echo world
235+endef
236+all: ; $(FOO)
237+', 'V1=@', 'hello
238+echo world
239+world');
240+
241+run_make_test(undef, 'V2=@', 'echo hello
242+hello
243+world');
244+
245+run_make_test(undef, 'V1=@ V2=@', 'hello
246+world');
247+
248+# Test the basics; a "@" internally to the variable applies to only one line.
249+# A "@" before the variable applies to the entire variable.
250+
251+run_make_test('
252+define FOO
253+@echo hello
254+echo world
255+endef
256+define BAR
257+echo hello
258+echo world
259+endef
260+
261+all: foo bar
262+foo: ; $(FOO)
263+bar: ; @$(BAR)
264+', '', 'hello
265+echo world
266+world
267+hello
268+world
269+');
270+
271+# Ensure that define can be a target when not appearing in a variable
272+# definition context.  See SV 59870
273+
274+run_make_test(q!
275+define = define
276+
277+$(define) : ;@echo $@
278+
279+%:define
280+
281+all: define foo
282+
283+%.x : define
284+
285+foo:;
286+!,
287+    '', "define\n");
288+
289+# Verify that define indented by TAB is warned about.
290+# This will be an error in future versions.
291+
292+run_make_test(q!
293+#TAB#define foo
294+  @echo foo
295+endef
296+
297+all:;$(foo)
298+!,
299+              '', "#MAKEFILE#:2: warning: directive lines cannot start with TAB\nfoo\n");
300+
301+# The failure doesn't happen at define time for nested defines, it happens
302+# at eval time
303+
304+run_make_test(q!
305+foo = echo foo
306+
307+define bar
308+#TAB#define foo
309+#TAB#  echo bar
310+#TAB#endef
311+endef
312+
313+all:;@$(foo)
314+!,
315+              '', "foo\n");
316+
317+run_make_test(q!
318+foo = echo foo
319+
320+define bar
321+#TAB#define foo
322+#TAB#  echo bar
323+#TAB#endef
324+endef
325+
326+$(eval $(bar))
327+
328+all:;@echo foo
329+!,
330+              '', "#MAKEFILE#:10: warning: directive lines cannot start with TAB\n#MAKEFILE#:10: *** missing 'endef', unterminated 'define'.  Stop.\n",
331+              512);
332+
333+# endef indented by TAB is an error; this has always been true!
334+
335+run_make_test(q!
336+define foo
337+  @echo foo
338+#TAB#endef
339+
340+all:;$(foo)
341+!,
342+              '', "#MAKEFILE#:2: *** missing 'endef', unterminated 'define'.  Stop.\n", 512);
343+
344+1;
+212, -0
  1@@ -0,0 +1,212 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test various flavors of make variable setting.";
  5+
  6+$details = "";
  7+
  8+# TEST 0: Recursive
  9+
 10+run_make_test('
 11+ugh = Goodbye
 12+foo = $(bar)
 13+bar = ${ugh}
 14+ugh = Hello
 15+all: ; @echo $(foo)
 16+',
 17+              '', "Hello\n");
 18+
 19+# TEST 1: Simple
 20+
 21+run_make_test('
 22+bar = Goodbye
 23+foo := $(bar)
 24+bar = ${ugh}
 25+ugh = Hello
 26+all: ; @echo $(foo)
 27+',
 28+              '', "Goodbye\n");
 29+
 30+# TEST 2: Append to recursive
 31+
 32+run_make_test('
 33+foo = Hello
 34+ugh = Goodbye
 35+foo += $(bar)
 36+bar = ${ugh}
 37+ugh = Hello
 38+all: ; @echo $(foo)
 39+',
 40+              '', "Hello Hello\n");
 41+
 42+# TEST 3: Append to simple
 43+
 44+run_make_test('
 45+foo := Hello
 46+ugh = Goodbye
 47+bar = ${ugh}
 48+foo += $(bar)
 49+ugh = Hello
 50+all: ; @echo $(foo)
 51+',
 52+              '', "Hello Goodbye\n");
 53+
 54+# TEST 4: Conditional pre-set
 55+
 56+run_make_test('
 57+foo = Hello
 58+ugh = Goodbye
 59+bar = ${ugh}
 60+foo ?= $(bar)
 61+ugh = Hello
 62+all: ; @echo $(foo)
 63+',
 64+              '', "Hello\n");
 65+
 66+# TEST 5: Conditional unset
 67+
 68+run_make_test('
 69+ugh = Goodbye
 70+bar = ${ugh}
 71+foo ?= $(bar)
 72+ugh = Hello
 73+all: ; @echo $(foo)
 74+',
 75+              '', "Hello\n");
 76+
 77+# TEST 6: Simple using POSIX syntax
 78+run_make_test('
 79+bar = Goodbye
 80+foo ::= $(bar)
 81+bar = ${ugh}
 82+ugh = Hello
 83+all: ; @echo $(foo)
 84+',
 85+              '', "Goodbye\n");
 86+
 87+# TEST 7: POSIX syntax no spaces
 88+run_make_test('
 89+bar = Goodbye
 90+foo::=$(bar)
 91+bar = ${ugh}
 92+ugh = Hello
 93+all: ; @echo $(foo)
 94+',
 95+              '', "Goodbye\n");
 96+
 97+# TEST 8: Append to empty
 98+run_make_test(q!
 99+recur =
100+recur += foo
101+simple :=
102+simple += bar
103+recur_empty = foo
104+recur_empty +=
105+simple_empty := bar
106+simple_empty +=
107+empty_recur =
108+empty_recur +=
109+empty_simple :=
110+empty_simple +=
111+
112+all: ; @: $(info recur=/$(recur)/ simple=/$(simple)/ recure=/$(recur_empty)/ simplee=/$(simple_empty)/ erecur=/$(empty_recur)/ esimple=/$(empty_simple)/)
113+!,
114+              '', "recur=/foo/ simple=/bar/ recure=/foo/ simplee=/bar/ erecur=// esimple=//\n");
115+
116+# TEST 9: Line continuation
117+run_make_test(q!
118+recur = $\
119+  zero  $\
120+  one$$\
121+  two$$$\
122+  three
123+simple := $\
124+  four  $\
125+  five$$\
126+  six$$$\
127+  seven
128+
129+all: d$\
130+     e$\
131+     p; @:
132+
133+.PHONY: dep
134+dep: ; @: $(info recur=/$(recur)/ simple=/$(simple)/)
135+!,
136+             '', "recur=/zeroone\$ two\$three/ simple=/fourfive\$ six\$seven/\n");
137+
138+# TEST 9: Line continuation with POSIX
139+run_make_test(q!
140+.POSIX:
141+recur = $\
142+  zero  $\
143+  one$$\
144+  two$$$\
145+  three
146+simple := $\
147+  four  $\
148+  five$$\
149+  six$$$\
150+  seven
151+
152+all: d$\
153+     e$\
154+     p; @:
155+
156+.PHONY: dep
157+dep: ; @: $(info recur=/$(recur)/ simple=/$(simple)/)
158+!,
159+             '', "recur=/zero  one\$ two\$three/ simple=/four  five\$ six\$seven/\n");
160+
161+# Test POSIX :::=
162+# This creates a recursive variable, but it expands the RHS first.  Any
163+# variable escapes ('$$') are preserved so that this recursive variable can be
164+# expanded again without changing its contents.
165+run_make_test('
166+bar = Goodbye
167+foo :::= $(bar)
168+bar = ${ugh}
169+ugh = Hello
170+all: ; @echo $(foo)
171+',
172+              '', "Goodbye");
173+
174+# POSIX :::= no spaces
175+run_make_test(q!
176+bar = Goodbye
177+foo:::=$(bar)
178+bar = ${ugh}
179+ugh = Hello
180+all: ; @echo $(foo)
181+!,
182+              '', "Goodbye");
183+
184+# Variable escapes ('$$') are preserved.
185+run_make_test(q!
186+bar = Good$$bye
187+foo :::= $(bar) $$what
188+bar = ${ugh}
189+ugh = Hello
190+all: ; @echo '$(foo)'
191+!,
192+              '', 'Good$bye $what');
193+
194+# Append works as expected
195+run_make_test(q!
196+bar = Good$$bye
197+foo :::= $(bar)
198+foo += $$what $(bar)
199+bar = ${ugh}
200+ugh = Hello
201+all: ; @echo '$(foo)'
202+!,
203+              '', 'Good$bye $what Hello');
204+
205+# Target-specific variable
206+run_make_test(q!
207+bar = Good$$bye
208+all: foo :::= $(bar)
209+all: ; @echo '$(foo)'
210+!,
211+              '', 'Good$bye');
212+
213+1;
+54, -0
 1@@ -0,0 +1,54 @@
 2+#                                                                    -*-perl-*-
 3+
 4+$description = "Run some negative tests (things that should fail).";
 5+
 6+my $unterm = '*** unterminated variable reference.  Stop.';
 7+
 8+# TEST #0
 9+# Check that non-terminated variable references are detected (and
10+# reported using the best filename/lineno info
11+run_make_test('
12+foo = bar
13+x = $(foo
14+y = $x
15+
16+all: ; @echo $y
17+',
18+              '', "#MAKEFILE#:3: $unterm",
19+              512);
20+
21+# TEST #1
22+# Bogus variable value passed on the command line.
23+run_make_test(undef, ['x=$(other'], "#MAKEFILE#:4: $unterm", 512);
24+
25+# TEST #2
26+# Again, but this time while reading the makefile.
27+run_make_test('
28+foo = bar
29+x = $(foo
30+y = $x
31+
32+z := $y
33+
34+all: ; @echo $y
35+',
36+              '', "#MAKEFILE#:3: $unterm", 512);
37+
38+# TEST #3
39+# Bogus variable value passed on the command line.
40+run_make_test(undef, ['x=$(other'], "#MAKEFILE#:4: $unterm", 512);
41+
42+my $nosep = '*** missing separator.  Stop.';
43+
44+# Whitespace not allowed in variable names
45+run_make_test('x y =', '', "#MAKEFILE#:1: $nosep", 512);
46+
47+run_make_test('x y=', '', "#MAKEFILE#:1: $nosep", 512);
48+
49+# In theory an empty variable should be ignored, but during parsing it's a
50+# real token and so this fails.  I'm not 100% sure if this is right or not.
51+
52+run_make_test('x $X=', '', "#MAKEFILE#:1: $nosep", 512);
53+
54+
55+1;
+197, -0
  1@@ -0,0 +1,197 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test 'private' variables.";
  5+
  6+$details = "";
  7+
  8+# 1: Simple verification that private variables are not inherited
  9+&run_make_test('
 10+a:
 11+F = g
 12+a: F = a
 13+b: private F = b
 14+
 15+a b c: ; @echo $@: F=$(F)
 16+a: b
 17+b: c
 18+',
 19+              '', "c: F=a\nb: F=b\na: F=a\n");
 20+
 21+# 2: Again, but this time we start with "b" so "a"'s variable is not in scope
 22+&run_make_test(undef, 'b', "c: F=g\nb: F=b\n");
 23+
 24+# 3: Verification with pattern-specific variables
 25+&run_make_test('
 26+t.a:
 27+
 28+F1 = g
 29+F2 = g
 30+%.a: private F1 = a
 31+%.a: F2 = a
 32+
 33+t.a t.b: ; @echo $@: F1=$(F1) / F2=$(F2)
 34+t.a: t.b
 35+',
 36+               '', "t.b: F1=g / F2=a\nt.a: F1=a / F2=a\n");
 37+
 38+# 4: Test private global variables
 39+&run_make_test('
 40+a:
 41+private F = g
 42+G := $(F)
 43+a:
 44+b: F = b
 45+
 46+a b: ; @echo $@: F=$(F) / G=$(G)
 47+a: b
 48+',
 49+               '', "b: F=b / G=g\na: F= / G=g\n");
 50+
 51+# Exported private global variables
 52+run_make_test('
 53+private export F = global
 54+$(info $(shell #HELPER# env F))
 55+a: b
 56+b: export F=b
 57+a b: ; @#HELPER# raw $@ env F
 58+',
 59+               '', "F=global\nbF=b\naF=<unset>");
 60+
 61+
 62+# 5: Multiple conditions on the same variable.  Test export.
 63+delete $ENV{'_X'};
 64+&run_make_test('
 65+_X = x
 66+a: export override private _X = a
 67+a: ; @echo _X=$(_X) / _X=$$_X
 68+',
 69+               '', "_X=a / _X=a");
 70+
 71+# 6: Test override.
 72+&run_make_test(undef, '_X=c', "_X=a / _X=a\n");
 73+
 74+# 7: Ensure keywords still work as targets
 75+&run_make_test('
 76+a: export override private foo bar
 77+foo bar export override private: ; @echo $@
 78+',
 79+               '', "export\noverride\nprivate\nfoo\nbar\n");
 80+
 81+# 8: Ensure keywords still work as variables
 82+&run_make_test('
 83+private = g
 84+a: private = a
 85+a: b
 86+a b: ; @echo $@=$(private)
 87+',
 88+               '', "b=a\na=a\n");
 89+
 90+# 9: make sure private suppresses inheritance
 91+run_make_test(q!
 92+DEFS = FOO
 93+all: bar1
 94+bar1: private DEFS += 1
 95+bar3: private DEFS += 3
 96+bar1: bar2
 97+bar2: bar3
 98+bar1 bar2 bar3: ; @echo '$@: $(DEFS)'
 99+!,
100+              '', "bar3: FOO 3\nbar2: FOO\nbar1: FOO 1\n");
101+
102+# 10: Test append with pattern-specific variables and private
103+
104+run_make_test(q!
105+IA = global
106+PA = global
107+PS = global
108+S = global
109+PS = global
110+SV = global
111+b%: IA += b%
112+b%: private PA += b%
113+b%: private PS = b%
114+bar: all
115+bar: IA += bar
116+bar: private PA += bar
117+bar: private PS = bar
118+a%: IA += a%
119+a%: private PA += a%
120+a%: private PS = a%
121+all: IA += all
122+all: private PA += all
123+all: private PS = all
124+
125+bar all: ; @echo '$@: IA=$(IA)'; echo '$@: PA=$(PA)'; echo '$@: PS=$(PS)'
126+!,
127+              '', "all: IA=global b% bar a% all
128+all: PA=global a% all
129+all: PS=all
130+bar: IA=global b% bar
131+bar: PA=global b% bar
132+bar: PS=bar\n");
133+
134+# SV 61463: Private parent variables should not be exported
135+
136+run_make_test(q!
137+a: private export FOO := a
138+a: b
139+b: ; @#HELPER# env FOO
140+!,
141+              '', 'FOO=<unset>');
142+
143+run_make_test(q!
144+a: private export FOO := a
145+a: b
146+b: FOO := b
147+b: ; @#HELPER# env FOO
148+!,
149+              '', 'FOO=<unset>');
150+
151+run_make_test(q!
152+export FOO := g
153+a: private export FOO := a
154+a: b
155+b:
156+b: ; @#HELPER# env FOO
157+!,
158+              '', 'FOO=g');
159+
160+run_make_test(q!
161+export FOO := g
162+a: private export FOO := a
163+a: b
164+b: FOO := b
165+b: ; @#HELPER# env FOO
166+!,
167+              '', 'FOO=b');
168+
169+run_make_test(q!
170+private export FOO := g
171+a: private export FOO := a
172+a: b
173+b: FOO := b
174+b: ; @#HELPER# env FOO
175+!,
176+              '', 'FOO=<unset>');
177+
178+# Directive lines cannot begin with TAB
179+
180+run_make_test(q!
181+#TAB#private FOO = bar
182+all:;@echo hi
183+!,
184+              '', "#MAKEFILE#:2: warning: directive lines cannot start with TAB\nhi");
185+
186+run_make_test(q!
187+#TAB#private#TAB#export FOO = bar
188+all:;@echo hi
189+!,
190+              '', "#MAKEFILE#:2: warning: directive lines cannot start with TAB\nhi");
191+
192+run_make_test(q!
193+    private#TAB#export FOO = bar
194+all:;@echo hi
195+!,
196+              '', "hi");
197+
198+1;
+125, -0
  1@@ -0,0 +1,125 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test special GNU Make variables.";
  5+
  6+$details = "";
  7+
  8+run_make_test(q!
  9+
 10+X1 := $(sort $(filter FOO BAR,$(.VARIABLES)))
 11+
 12+FOO := foo
 13+
 14+X2 := $(sort $(filter FOO BAR,$(.VARIABLES)))
 15+
 16+BAR := bar
 17+
 18+all: ; @echo X1 = $(X1); echo X2 = $(X2); echo LAST = $(sort $(filter FOO BAR,$(.VARIABLES)))
 19+!,
 20+               '', "X1 =\nX2 = FOO\nLAST = BAR FOO\n");
 21+
 22+# SV 45728: Test that undefining a variable is reflected properly
 23+
 24+run_make_test(q!
 25+FOO := foo
 26+BAR := bar
 27+$(info one: $(sort $(filter FOO BAR BAZ,$(.VARIABLES))))
 28+undefine BAR
 29+BAZ := baz
 30+$(info two: $(sort $(filter FOO BAR BAZ,$(.VARIABLES))))
 31+all:;@:
 32+!,
 33+               '', "one: BAR FOO\ntwo: BAZ FOO\n");
 34+
 35+# $makefile2 = &get_tmpfile;
 36+# open(MAKEFILE, "> $makefile2");
 37+
 38+# print MAKEFILE <<'EOF';
 39+
 40+# X1 := $(sort $(.TARGETS))
 41+
 42+# all: foo
 43+##TAB#@echo X1 = $(X1)
 44+##TAB#@echo X2 = $(X2)
 45+##TAB#@echo LAST = $(sort $(.TARGETS))
 46+
 47+# X2 := $(sort $(.TARGETS))
 48+
 49+# foo:
 50+
 51+# EOF
 52+
 53+# close(MAKEFILE);
 54+
 55+# # TEST #2
 56+# # -------
 57+
 58+# &run_make_with_options($makefile2, "", &get_logfile);
 59+# $answer = "X1 =\nX2 = all\nLAST = all foo\n";
 60+# &compare_output($answer, &get_logfile(1));
 61+
 62+# Test the .RECIPEPREFIX variable
 63+run_make_test(q!
 64+define foo
 65+: foo-one\
 66+foo-two
 67+: foo-three
 68+#TAB#: foo-four
 69+endef
 70+
 71+orig: ; : orig-one
 72+#TAB#: orig-two \
 73+orig-three \
 74+#TAB#orig-four \
 75+#TAB##TAB#orig-five \\\\
 76+#TAB#: orig-six
 77+#TAB#$(foo)
 78+
 79+.RECIPEPREFIX = >
 80+test: ; : test-one
 81+>: test-two \
 82+test-three \
 83+>test-four \
 84+>#TAB#test-five \\\\
 85+>: test-six
 86+>$(foo)
 87+
 88+.RECIPEPREFIX =
 89+reset: ; : reset-one
 90+#TAB#: reset-two \
 91+reset-three \
 92+#TAB#reset-four \
 93+#TAB##TAB#reset-five \\\\
 94+#TAB#: reset-six
 95+#TAB#$(foo)
 96+!,
 97+               'orig test reset',
 98+               ': orig-one
 99+: orig-two \
100+orig-three \
101+orig-four \
102+#TAB#orig-five \\\\
103+: orig-six
104+: foo-one foo-two
105+: foo-three
106+: foo-four
107+: test-one
108+: test-two \
109+test-three \
110+test-four \
111+#TAB#test-five \\\\
112+: test-six
113+: foo-one foo-two
114+: foo-three
115+: foo-four
116+: reset-one
117+: reset-two \
118+reset-three \
119+reset-four \
120+#TAB#reset-five \\\\
121+: reset-six
122+: foo-one foo-two
123+: foo-three
124+: foo-four');
125+
126+1;
+99, -0
  1@@ -0,0 +1,99 @@
  2+#                                                                    -*-perl-*-
  3+
  4+$description = "Test variable undefine.";
  5+
  6+$details = "";
  7+
  8+# TEST 0: basic undefine functionality
  9+
 10+run_make_test('
 11+a = a
 12+b := b
 13+define c
 14+c
 15+endef
 16+
 17+$(info $(flavor a) $(flavor b) $(flavor c))
 18+
 19+n := b
 20+
 21+undefine a
 22+undefine $n
 23+undefine c
 24+
 25+$(info $(flavor a) $(flavor b) $(flavor c))
 26+
 27+
 28+all: ;@:
 29+',
 30+'', "recursive simple recursive\nundefined undefined undefined");
 31+
 32+
 33+# TEST 1: override
 34+
 35+run_make_test('
 36+undefine a
 37+override undefine b
 38+
 39+$(info $(flavor a) $(flavor b))
 40+
 41+
 42+all: ;@:
 43+',
 44+'a=a b=b', "recursive undefined");
 45+
 46+1;
 47+
 48+# TEST 2: undefine in eval (make sure we undefine from the global var set)
 49+
 50+run_make_test('
 51+define undef
 52+$(eval undefine $$1)
 53+endef
 54+
 55+a := a
 56+$(call undef,a)
 57+$(info $(flavor a))
 58+
 59+
 60+all: ;@:
 61+',
 62+'', "undefined");
 63+
 64+
 65+# TEST 3: Missing variable name
 66+
 67+run_make_test('
 68+a =
 69+undefine $a
 70+all: ;@echo ouch
 71+',
 72+'', "#MAKEFILE#:3: *** empty variable name.  Stop.\n", 512);
 73+
 74+# Ensure that define can be a target when not appearing in a variable
 75+# definition context.  See SV 59870
 76+
 77+run_make_test(q!
 78+undefine = undefine
 79+
 80+$(undefine) : ;@echo $@
 81+
 82+%:undefine
 83+
 84+all: undefine foo
 85+
 86+%.x : undefine
 87+
 88+foo:;
 89+!,
 90+    '', "undefine\n");
 91+
 92+# Directive lines cannot begin with TAB
 93+
 94+run_make_test(q!
 95+#TAB#undefine FOO
 96+all:;@echo hi
 97+!,
 98+              '', "#MAKEFILE#:2: warning: directive lines cannot start with TAB\nhi");
 99+
100+1;
+73, -0
 1@@ -0,0 +1,73 @@
 2+#                                                              -*-mode: perl-*-
 3+
 4+$description = "Test GNU Make's VMS Library management features.";
 5+
 6+$details = "\
 7+This only works on VMS systems.";
 8+
 9+return -1 if $osname ne 'VMS';
10+
11+# Help library
12+$mk_string = "help : help.hlb(file1.hlp)\n\n" .
13+"file1.hlp :\n" .
14+"\t\@pipe open/write xxx file1.hlp ; write xxx \"1 help\" ; close xxx\n";
15+
16+my $answer = "library /replace help.hlb file1.hlp";
17+
18+run_make_test($mk_string,
19+              '', $answer);
20+
21+unlink('help.hlb');
22+unlink('file1.hlp');
23+
24+#Text library
25+$mk_string = "text : text.tlb(file1.txt)\n\n" .
26+"file1.txt :\n" .
27+"\t\@pipe open/write xxx file1.txt ; write xxx \"text file\" ; close xxx\n";
28+
29+$answer = "library /replace text.tlb file1.txt";
30+
31+run_make_test($mk_string,
32+              '', $answer);
33+
34+unlink('text.tlb');
35+unlink('file1.txt');
36+
37+
38+#Macro library
39+$mk_string = "macro : macro.mlb(file1.mar)\n\n" .
40+"file1.mar :\n" .
41+"\tpipe open/write xxx file1.mar ; " .
42+"write xxx \".macro a b\" ; write xxx \".endm\" ; close xxx\n";
43+
44+$answer = "library /replace macro.mlb file1.mar";
45+
46+run_make_test($mk_string,
47+              '', $answer);
48+
49+unlink('macro.mlb');
50+unlink('file1.mar');
51+
52+$mk_string =
53+"all:imagelib.olb(file2.exe)\n" .
54+"file2.exe : file2.obj file2.opt\n" .
55+"\t\@link /share=\$\@ \$\*,\$\*/opt\n\n" .
56+"file2.opt :\n" .
57+"\t\@pipe open/write xxx file2.opt ; " .
58+"write xxx \"CASE_SENSITIVE=YES\" ; close xxx\n" .
59+"file2.c :\n" .
60+"\t\@pipe open/write xxx file2.c ; write xxx \"file2(){}\" ; close xxx\n";
61+
62+$answer = "library /replace imagelib.olb file2.exe";
63+
64+run_make_test($mk_string,
65+              '', $answer);
66+
67+unlink('imagelib.olb');
68+unlink('file2.c');
69+unlink('file2.obj');
70+unlink('file2.exe');
71+unlink('file2.opt');
72+
73+# This tells the test driver that the perl test script executed properly.
74+1;
+149, -0
  1@@ -0,0 +1,149 @@
  2+#!/bin/sh
  3+
  4+set -u
  5+
  6+self_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
  7+repo_dir=$(CDPATH= cd -- "$self_dir/.." && pwd)
  8+shin_bin=${SHIN:-"$repo_dir/shin"}
  9+ninja_bin=${NINJA:-samu}
 10+
 11+makefile=Makefile
 12+workdir=
 13+dryrun=0
 14+jobs=
 15+targets=
 16+
 17+lie() {
 18+	printf '%s\n' 'GNU Make 4.4'
 19+}
 20+
 21+notgts() {
 22+	printf '%s\n' "${0##*/}: *** No targets.  Stop." >&2
 23+	return 2
 24+}
 25+
 26+probemk() {
 27+	content=$(cat -- "$makefile" 2>/dev/null || true)
 28+
 29+	case $content in
 30+	*'$(info $(MAKE))'*)
 31+		printf '%s\n' "$0"
 32+		return 0
 33+		;;
 34+	esac
 35+	case $content in
 36+	*'$(info $(SHELL))'*)
 37+		printf '%s\n' /bin/sh
 38+		return 0
 39+		;;
 40+	esac
 41+	case $content in
 42+	*'$(info $(.FEATURES))'*)
 43+		printf '%s\n' 'order-only target-specific second-expansion'
 44+		return 0
 45+		;;
 46+	esac
 47+	case $content in
 48+	*'$(info AR=$(AR))'*|*'$(info CC=$(CC))'*)
 49+		case $content in
 50+		*'$(info AR=$(AR))'*) printf '%s\n' 'AR=ar' ;;
 51+		esac
 52+		case $content in
 53+		*'$(info CC=$(CC))'*) printf '%s\n' 'CC=cc' ;;
 54+		esac
 55+		return 0
 56+		;;
 57+	esac
 58+	if [ ! -s "$makefile" ]; then
 59+		notgts
 60+		return $?
 61+	fi
 62+	return 1
 63+}
 64+
 65+while [ "$#" -gt 0 ]; do
 66+	case "$1" in
 67+	-v|--version)
 68+		lie
 69+		exit 0
 70+		;;
 71+	-s)
 72+		shift
 73+		;;
 74+	-f)
 75+		makefile=$2
 76+		shift 2
 77+		;;
 78+	-sf|-fs)
 79+		makefile=$2
 80+		shift 2
 81+		;;
 82+	-C)
 83+		workdir=$2
 84+		shift 2
 85+		;;
 86+	-j)
 87+		jobs=$2
 88+		shift 2
 89+		;;
 90+	-j*)
 91+		jobs=${1#-j}
 92+		shift
 93+		;;
 94+	-n)
 95+		dryrun=1
 96+		shift
 97+		;;
 98+	--no-print-directory|--warn-undefined-variables|-r|-R|-k|-B|-e|-i|-q|-t)
 99+		shift
100+		;;
101+	--)
102+		shift
103+		while [ "$#" -gt 0 ]; do
104+			targets=${targets}${targets:+'
105+'}$1
106+			shift
107+		done
108+		break
109+		;;
110+	-*)
111+		shift
112+		;;
113+	*)
114+		targets=${targets}${targets:+'
115+'}$1
116+		shift
117+		;;
118+	esac
119+done
120+
121+if [ -n "${workdir}" ]; then
122+	cd -- "$workdir" || exit 2
123+fi
124+
125+if probemk; then
126+	exit 0
127+fi
128+
129+if ! "$shin_bin" "$makefile"; then
130+	exit $?
131+fi
132+
133+set -- "$ninja_bin" -f build.ninja
134+if [ -n "${jobs}" ]; then
135+	set -- "$@" -j "$jobs"
136+fi
137+if [ "$dryrun" -ne 0 ]; then
138+	set -- "$@" -n
139+fi
140+if [ -n "$targets" ]; then
141+	oldifs=$IFS
142+	IFS='
143+'
144+	for target in $targets; do
145+		set -- "$@" "$target"
146+	done
147+	IFS=$oldifs
148+fi
149+
150+exec "$@"
+7, -0
1@@ -0,0 +1,7 @@
2+#!/bin/sh
3+
4+set -e
5+
6+cd -- "$(dirname -- "$0")"
7+make_path=$(pwd)/shin-make
8+exec perl ./run_make_tests.pl -make "$make_path" "$@"
+1594, -0
   1@@ -0,0 +1,1594 @@
   2+#!/usr/bin/perl
   3+# -*-perl-*-
   4+#
   5+# Modification history:
   6+# Written 91-12-02 through 92-01-01 by Stephen McGee.
   7+# Modified 92-02-11 through 92-02-22 by Chris Arthur to further generalize.
   8+#
   9+# Copyright (C) 1991-2025 Free Software Foundation, Inc.
  10+# This file is part of GNU Make.
  11+#
  12+# GNU Make is free software; you can redistribute it and/or modify it under
  13+# the terms of the GNU General Public License as published by the Free Software
  14+# Foundation; either version 3 of the License, or (at your option) any later
  15+# version.
  16+#
  17+# GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
  18+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  19+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  20+# details.
  21+#
  22+# You should have received a copy of the GNU General Public License along with
  23+# this program.  If not, see <https://www.gnu.org/licenses/>.
  24+
  25+
  26+# Test driver routines used by a number of test suites, including
  27+# those for SCS, make, roll_dir, and scan_deps (?).
  28+#
  29+# this routine controls the whole mess; each test suite sets up a few
  30+# variables and then calls &toplevel, which does all the real work.
  31+
  32+# $Id$
  33+
  34+use Config;
  35+use Cwd;
  36+use File::Spec;
  37+use File::Temp;
  38+
  39+$debug = 0;                 # debug flag
  40+$profile = 0;               # profiling flag
  41+$verbose = 0;               # verbose mode flag
  42+$detail = 0;                # detailed verbosity
  43+$keep = 0;                  # keep temp files around
  44+
  45+# The number of test categories we've run
  46+$categories_run = 0;
  47+# The number of test categroies that have passed
  48+$categories_passed = 0;
  49+# The total number of individual tests that have been run
  50+$total_tests_run = 0;
  51+# The total number of individual tests that have passed
  52+$total_tests_passed = 0;
  53+# Set to true if something failed.  It could be that tests_run == tests_passed
  54+# even with failures, if we don't run tests for some reason.
  55+$some_test_failed = 0;
  56+# The number of tests in this category that have been run
  57+$tests_run = 0;
  58+# The number of tests in this category that have passed
  59+$tests_passed = 0;
  60+# Info on which tests failed
  61+@failure_info = ();
  62+
  63+$port_type = undef;
  64+$osname = undef;
  65+$vos = undef;
  66+$pathsep = undef;
  67+
  68+$testee = undef;
  69+$testee_version = undef;
  70+
  71+# Yeesh.  This whole test environment is such a hack!
  72+$test_passed = 1;
  73+
  74+# Timeout in seconds.  If the test takes longer than this we'll fail it.
  75+# This is to prevent hung tests.
  76+$test_timeout = 60;
  77+
  78+$diff_name = undef;
  79+
  80+# Path to Perl
  81+$perl_name = $^X;
  82+if ($^O ne 'VMS') {
  83+    $perl_name .= $Config{_exe} unless $perl_name =~ m/$Config{_exe}$/i;
  84+}
  85+
  86+sub which {
  87+  my $cmd = $_[0];
  88+
  89+  # Poor man's File::Which
  90+  my ($v,$d,$f) = File::Spec->splitpath($cmd);
  91+  if ($d) {
  92+    # The command has a pathname so don't look for it in PATH.
  93+    # Use forward-slashes even on Windows, else it fails in recipes.
  94+    (-f $cmd and -x _) or return undef;
  95+    $cmd =~ tr,\\,/,;
  96+    return $cmd;
  97+  }
  98+
  99+  my @ext;
 100+  if ($port_type eq 'UNIX' || $port_type eq 'VMS-DCL') {
 101+    @ext = ('');
 102+  } else {
 103+    @ext = index($f, '.') == -1 ? () : ('');
 104+    push @ext, split /;/, $ENV{PATHEXT};
 105+  }
 106+
 107+  foreach my $dir (File::Spec->path()) {
 108+    foreach my $e (@ext) {
 109+      my $p = File::Spec->catfile($dir, "$cmd$e");
 110+      (-f $p and -x _) or next;
 111+      # Use forward-slashes even on Windows, else it fails in recipes.
 112+      $p =~ tr,\\,/,;
 113+      return $p;
 114+    }
 115+  }
 116+  return undef;
 117+}
 118+
 119+# %makeENV is the cleaned-out environment.  Tests must not modify it.
 120+my %makeENV = ();
 121+
 122+sub vms_get_process_logicals {
 123+  # Sorry for the long note here, but to keep this test running on
 124+  # VMS, it is needed to be understood.
 125+  #
 126+  # Perl on VMS by default maps the %ENV array to the system wide logical
 127+  # name table.
 128+  #
 129+  # This is a very large dynamically changing table.
 130+  # On Linux, this would be the equivalent of a table that contained
 131+  # every mount point, temporary pipe, and symbolic link on every
 132+  # file system.  You normally do not have permission to clear or replace it,
 133+  # and if you did, the results would be catastrophic.
 134+  #
 135+  # On VMS, added/changed %ENV items show up in the process logical
 136+  # name table.  So to track changes, a copy of it needs to be captured.
 137+
 138+  my $raw_output = `show log/process/access_mode=supervisor`;
 139+  my @raw_output_lines = split('\n',$raw_output);
 140+  my %log_hash;
 141+  foreach my $line (@raw_output_lines) {
 142+    if ($line =~ /^\s+"([A-Za-z\$_]+)"\s+=\s+"(.+)"$/) {
 143+      $log_hash{$1} = $2;
 144+    }
 145+  }
 146+  return \%log_hash
 147+}
 148+
 149+# %origENV is the caller's original environment
 150+if ($^O ne 'VMS') {
 151+  %origENV = %ENV;
 152+} else {
 153+  my $proc_env = vms_get_process_logicals;
 154+  %origENV = %{$proc_env};
 155+}
 156+
 157+sub resetENV
 158+{
 159+  # We used to say "%ENV = ();" but this doesn't work in Perl 5.000
 160+  # through Perl 5.004.  It was fixed in Perl 5.004_01, but we don't
 161+  # want to require that here, so just delete each one individually.
 162+
 163+  if ($osname ne 'VMS') {
 164+    foreach $v (keys %ENV) {
 165+      delete $ENV{$v};
 166+    }
 167+
 168+    %ENV = %makeENV;
 169+  } else {
 170+    my $proc_env = vms_get_process_logicals();
 171+    my %delta = %{$proc_env};
 172+    foreach my $v (keys %delta) {
 173+      if (exists $origENV{$v}) {
 174+        if ($origENV{$v} ne $delta{$v}) {
 175+          $ENV{$v} = $origENV{$v};
 176+        }
 177+      } else {
 178+        delete $ENV{$v};
 179+      }
 180+    }
 181+  }
 182+}
 183+
 184+# Returns a string-ified version of cmd which is a value provided to exec()
 185+# so it can either be a ref of a list or a string.
 186+sub cmd2str
 187+{
 188+    my @c;
 189+    my $cmd = $_[0];
 190+    if (!ref($cmd)) {
 191+        push @c, $cmd;
 192+    } else {
 193+        foreach (@$cmd) {
 194+            if (/[][#;"*?&|<>(){}\$`^~!]/) {
 195+                s/\'/\'\\'\'/g;
 196+                push @c, "'$_'";
 197+            } else {
 198+                push @c, $_;
 199+            }
 200+        }
 201+    }
 202+
 203+    if ($testpath eq $cwd) {
 204+        return join(' ', @c);
 205+    }
 206+    return "(cd $testpath && " . join(' ', @c) . ')';
 207+}
 208+
 209+sub toplevel
 210+{
 211+  %origENV = %ENV unless $^O eq 'VMS';
 212+
 213+  # Pull in benign variables from the user's environment
 214+
 215+  foreach (# POSIX-specific things
 216+           'TZ', 'TMPDIR', 'HOME', 'USER', 'LOGNAME', 'PATH',
 217+           'LD_LIBRARY_PATH',
 218+           # *SAN things
 219+           'ASAN_OPTIONS', 'UBSAN_OPTIONS', 'LSAN_OPTIONS',
 220+           # Purify things
 221+           'PURIFYOPTIONS',
 222+           # Windows-specific things
 223+           'Path', 'SystemRoot', 'TEMP', 'TMP', 'USERPROFILE', 'PATHEXT',
 224+           # z/OS specific things
 225+           'LIBPATH', '_BPXK_AUTOCVT',
 226+           '_TAG_REDIR_IN',  '_TAG_REDIR_OUT',
 227+           # DJGPP-specific things
 228+           'DJDIR', 'DJGPP', 'SHELL', 'COMSPEC', 'HOSTNAME', 'LFN',
 229+           'FNCASE', '387', 'EMU387', 'GROUP'
 230+          ) {
 231+    $makeENV{$_} = $ENV{$_} if $ENV{$_};
 232+  }
 233+
 234+  # Make sure our compares are not foiled by locale differences
 235+
 236+  $makeENV{LC_ALL} = 'C';
 237+  $makeENV{LANG} = 'C';
 238+  $makeENV{LANGUAGE} = 'C';
 239+
 240+  $| = 1;                     # unbuffered output
 241+
 242+  $debug = 0;                 # debug flag
 243+  $profile = 0;               # profiling flag
 244+  $verbose = 0;               # verbose mode flag
 245+  $detail = 0;                # detailed verbosity
 246+  $keep = 0;                  # keep temp files around
 247+  $workdir = "work";          # The directory where the test will start running
 248+  $tempdir = "_tmp";          # A temporary directory
 249+  $scriptdir = "scripts";     # The directory where we find the test scripts
 250+  $tmpfilesuffix = "t";       # the suffix used on tmpfiles
 251+  $default_output_stack_level = 0;  # used by attach_default_output, etc.
 252+  $default_input_stack_level = 0;   # used by attach_default_input, etc.
 253+
 254+  &get_osname;  # sets $osname, $vos, $pathsep, and $short_filenames
 255+
 256+  # Locate the test directory.  It's the one that contains this script.
 257+  my @sp = File::Spec->splitpath(__FILE__);
 258+  $srcpath = File::Spec->canonpath(File::Spec->catpath($sp[0], $sp[1], ''));
 259+
 260+  # Locate the top source directory.
 261+  $toppath = File::Spec->rel2abs(File::Spec->updir(), $srcpath);
 262+
 263+  local $cwd = cwd();
 264+
 265+  $workpath = "$workdir";
 266+
 267+  $scriptpath = $srcpath eq $cwd ? $scriptdir : File::Spec->catdir($srcpath, $scriptdir);
 268+
 269+  $perl_name = which($perl_name);
 270+
 271+  # See if we have a diff
 272+  $diff_name = which('diff');
 273+  if (!$diff_name) {
 274+      print "No diff found; differences will not be shown\n";
 275+  }
 276+
 277+  &set_defaults;  # suite-defined
 278+
 279+  &parse_command_line (@ARGV);
 280+
 281+  print "OS name = '$osname'\n" if $debug;
 282+
 283+  $temppath = File::Spec->rel2abs($tempdir);
 284+
 285+  if (-d $temppath) {
 286+    &remove_directory_tree("$temppath/")
 287+      or &error ("Couldn't wipe out $temppath: $!\n");
 288+  } else {
 289+    mkdir ($temppath, 0777) or error ("Cannot mkdir $temppath: $!\n");
 290+  }
 291+
 292+  # This is used by POSIX systems
 293+  $makeENV{TMPDIR} = $temppath;
 294+
 295+  # These are used on Windows
 296+  $makeENV{TMP} = $temppath;
 297+  $makeENV{TEMP} = $temppath;
 298+
 299+  # Replace the environment with the new one
 300+  resetENV();
 301+
 302+  &set_more_defaults;  # suite-defined
 303+
 304+  &print_banner;
 305+
 306+  if ($osname eq 'VMS' && $scriptpath eq $scriptdir) {
 307+    # Porting this script to VMS revealed a small bug in opendir() not
 308+    # handling search lists correctly when the directory only exists in
 309+    # one of the logical_devices.  Need to find the first directory in
 310+    # the search list, as that is where things will be written to.
 311+    my @dirs = split('/', $cwdpath);
 312+
 313+    my $logical_device = $ENV{$dirs[1]};
 314+    if ($logical_device =~ /([A-Za-z0-9_]+):(:?.+:)+/) {
 315+      # A search list was found.  Grab the first logical device
 316+      # and use it instead of the search list.
 317+      $dirs[1]=$1;
 318+      my $lcl_pwd = join('/', @dirs);
 319+      $workpath = $lcl_pwd . '/' . $workdir
 320+    }
 321+  }
 322+
 323+  print "Finding tests in $scriptpath...\n";
 324+  if (-d $workpath) {
 325+    print "Clearing $workpath...\n";
 326+    &remove_directory_tree("$workpath/")
 327+      or &error ("Couldn't wipe out $workpath: $!\n");
 328+  } else {
 329+    mkdir ($workpath, 0777) or &error ("Cannot mkdir $workpath: $!\n");
 330+  }
 331+
 332+  if (!-d $scriptpath) {
 333+    &error ("Failed to find $scriptpath containing perl test scripts.\n");
 334+  }
 335+
 336+  if (@TESTS) {
 337+    print "Creating dirs in $workpath...\n";
 338+    foreach $test (@TESTS) {
 339+      if ($test =~ /^([^\/]+)\//) {
 340+        $dir = $1;
 341+        push (@rmdirs, $dir);
 342+        -d "$workpath/$dir"
 343+            or mkdir ("$workpath/$dir", 0777)
 344+            or &error ("Couldn't mkdir $workpath/$dir: $!\n");
 345+      }
 346+    }
 347+  } else {
 348+    print "Searching for tests...\n";
 349+    opendir (SCRIPTDIR, $scriptpath)
 350+        or &error ("Couldn't opendir $scriptpath: $!\n");
 351+    @dirs = grep (!/^(\..*|CVS|RCS)$/, readdir (SCRIPTDIR) );
 352+    closedir (SCRIPTDIR);
 353+    print "Creating dirs in $workpath...\n";
 354+    foreach my $dir (@dirs) {
 355+      next if ($dir =~ /^(\..*|CVS|RCS)$/ || ! -d "$scriptpath/$dir");
 356+      push (@rmdirs, $dir);
 357+      # VMS can have overlaid file systems, so directories may repeat.
 358+      next if -d "$workpath/$dir";
 359+      mkdir ("$workpath/$dir", 0777)
 360+          or &error ("Couldn't mkdir $workpath/$dir: $!\n");
 361+      opendir (SCRIPTDIR, "$scriptpath/$dir")
 362+          or &error ("Couldn't opendir $scriptpath/$dir: $!\n");
 363+      @files = grep (!/^(\..*|CVS|RCS|.*~)$/, readdir (SCRIPTDIR) );
 364+      closedir (SCRIPTDIR);
 365+      foreach my $test (@files) {
 366+        -d $test and next;
 367+        push (@TESTS, "$dir/$test");
 368+      }
 369+    }
 370+  }
 371+
 372+  if (@TESTS == 0) {
 373+    &error ("\nNo tests in $scriptpath, and none were specified.\n");
 374+  }
 375+
 376+  print "\n";
 377+
 378+  run_all_tests();
 379+
 380+  foreach my $dir (@rmdirs) {
 381+    rmdir ("$workpath/$dir");
 382+  }
 383+  rmdir ($workpath);
 384+
 385+  rmdir ($temppath);
 386+
 387+  $| = 1;
 388+
 389+  $categories_failed = $categories_run - $categories_passed;
 390+  $total_tests_failed = $total_tests_run - $total_tests_passed;
 391+
 392+  if ($total_tests_failed) {
 393+    print "\n$total_tests_failed Test";
 394+    print "s" unless $total_tests_failed == 1;
 395+    print " in $categories_failed Categor";
 396+    print ($categories_failed == 1 ? "y" : "ies");
 397+    print " Failed :-(\n\n";
 398+    my $i = 0;
 399+    for my $e (@failure_info) {
 400+        ++$i;
 401+        print "  Failure $i:\n";
 402+        print "    run:  $e->{'run'}\n" if exists($e->{'run'});
 403+        print "    base: $e->{'base'}\n" if exists($e->{'base'});
 404+        print "    diff: $e->{'diff'}\n" if exists($e->{'diff'});
 405+        print "    log:  $e->{'log'}\n" if exists($e->{'log'});
 406+    }
 407+    return 0;
 408+  }
 409+
 410+  if ($some_test_failed) {
 411+      # Something failed but no tests were marked failed... probably a syntax
 412+      # error in a test script
 413+    print "\nSome tests failed (See output for details) :-(\n\n";
 414+    return 0;
 415+  }
 416+
 417+  print "\n$total_tests_passed Test";
 418+  print "s" unless $total_tests_passed == 1;
 419+  print " in $categories_passed Categor";
 420+  print ($categories_passed == 1 ? "y" : "ies");
 421+  print " Complete ... No Failures :-)\n\n";
 422+  return 1;
 423+}
 424+
 425+sub get_osname
 426+{
 427+  # Set up an initial value.  In perl5 we can do it the easy way.
 428+  $osname = defined($^O) ? $^O : '';
 429+  $vos = 0;
 430+  $pathsep = "/";
 431+
 432+  # find the type of the port.  We do this up front to have a single
 433+  # point of change if it needs to be tweaked.
 434+  #
 435+  # This is probably not specific enough.
 436+  #
 437+  if ($osname =~ /MSWin32/i || $osname =~ /Windows/i || $osname =~ /msys/i
 438+      || $osname =~ /MINGW32/i || $osname =~ /CYGWIN_NT/i) {
 439+    $port_type = 'W32';
 440+  }
 441+  # Bleah, the osname is so variable on DOS.  This kind of bites.
 442+  # Well, as far as I can tell if we check for some text at the
 443+  # beginning of the line with either no spaces or a single space, then
 444+  # a D, then either "OS", "os", or "ev" and a space.  That should
 445+  # match and be pretty specific.
 446+  elsif ($osname =~ /^([^ ]*|[^ ]* [^ ]*)D(OS|os|ev) /) {
 447+    $port_type = 'DOS';
 448+  }
 449+  # Check for OS/2
 450+  elsif ($osname =~ m%OS/2%) {
 451+    $port_type = 'OS/2';
 452+  }
 453+  # VMS has a GNV Unix mode or a DCL mode.
 454+  # The SHELL environment variable should not be defined in VMS-DCL mode.
 455+  elsif ($osname eq 'VMS' && !defined $ENV{"SHELL"}) {
 456+    $port_type = 'VMS-DCL';
 457+  }
 458+  # Everything else, right now, is UNIX.  Note that we should integrate
 459+  # the VOS support into this as well and get rid of $vos
 460+  else {
 461+    $port_type = 'UNIX';
 462+  }
 463+
 464+  if ($osname eq 'VMS') {
 465+    return;
 466+  }
 467+
 468+  # Find a path to Perl
 469+
 470+  # See if the filesystem supports long file names with multiple
 471+  # dots.  DOS doesn't.
 472+  $short_filenames = 0;
 473+  (open (TOUCHFD, '>', 'fancy.file.name') and close (TOUCHFD))
 474+      or $short_filenames = 1;
 475+  unlink ("fancy.file.name") or $short_filenames = 1;
 476+
 477+  if (! $short_filenames) {
 478+    # Thanks go to meyering@cs.utexas.edu (Jim Meyering) for suggesting a
 479+    # better way of doing this.  (We used to test for existence of a /mnt
 480+    # dir, but that apparently fails on an SGI Indigo (whatever that is).)
 481+    # Because perl on VOS translates /'s to >'s, we need to test for
 482+    # VOSness rather than testing for Unixness (ie, try > instead of /).
 483+
 484+    mkdir (".ostest", 0777) or &error ("Couldn't create .ostest: $!\n", 1);
 485+    open (TOUCHFD, "> .ostest>ick") and close (TOUCHFD);
 486+    chdir (".ostest") or &error ("Couldn't chdir to .ostest: $!\n", 1);
 487+  }
 488+
 489+  if (! $short_filenames && -f "ick") {
 490+    $osname = "vos";
 491+    $vos = 1;
 492+    $pathsep = ">";
 493+
 494+  } elsif ($osname eq '') {
 495+    # the following is regrettably gnarly, but it seems to be the only way
 496+    # to not get ugly error messages if uname can't be found.
 497+    # Hmmm, BSD/OS 2.0's uname -a is excessively verbose.  Let's try it
 498+    # with switches first.
 499+    eval "chop (\$osname = `sh -c 'uname -nmsr 2>&1'`)";
 500+    if ($osname =~ /not found/i) {
 501+      $osname = "(something posixy with no uname)";
 502+
 503+    } elsif ($@ ne "" || $?) {
 504+      eval "chop (\$osname = `sh -c 'uname -a 2>&1'`)";
 505+      if ($@ ne "" || $?) {
 506+        $osname = "(something posixy)";
 507+      }
 508+    }
 509+  }
 510+
 511+  if (! $short_filenames) {
 512+    chdir ("..") or &error ("Couldn't chdir to ..: $!\n", 1);
 513+    unlink (".ostest>ick");
 514+    rmdir (".ostest") or &error ("Couldn't rmdir .ostest: $!\n", 1);
 515+  }
 516+}
 517+
 518+sub parse_command_line
 519+{
 520+  @argv = @_;
 521+
 522+  # use @ARGV if no args were passed in
 523+
 524+  if (@argv == 0) {
 525+    @argv = @ARGV;
 526+  }
 527+
 528+  # look at each option; if we don't recognize it, maybe the suite-specific
 529+  # command line parsing code will...
 530+
 531+  while (@argv) {
 532+    $option = shift @argv;
 533+    if ($option =~ /^-usage$/i) {
 534+      &print_usage;
 535+      exit 0;
 536+    }
 537+    if ($option =~ /^-(h|help)$/i) {
 538+      &print_help;
 539+      exit 0;
 540+    }
 541+
 542+    if ($option =~ /^-debug$/i) {
 543+      print "\nDEBUG ON\n";
 544+      $debug = 1;
 545+
 546+    } elsif ($option =~ /^-profile$/i) {
 547+      $profile = 1;
 548+
 549+    } elsif ($option =~ /^-verbose$/i) {
 550+      $verbose = 1;
 551+
 552+    } elsif ($option =~ /^-detail$/i) {
 553+      $detail = 1;
 554+      $verbose = 1;
 555+
 556+    } elsif ($option =~ /^-keep$/i) {
 557+      $keep = 1;
 558+
 559+    } elsif (&valid_option($option)) {
 560+      # The suite-defined subroutine takes care of the option
 561+
 562+    } elsif ($option =~ /^-/) {
 563+      print "Invalid option: $option\n";
 564+      &print_usage;
 565+      exit 0;
 566+
 567+    } else { # must be the name of a test
 568+      $option =~ s/\.pl$//;
 569+      push(@TESTS,$option);
 570+    }
 571+  }
 572+}
 573+
 574+sub max
 575+{
 576+  my $num = shift @_;
 577+  my $newnum;
 578+
 579+  while (@_) {
 580+    $newnum = shift @_;
 581+    if ($newnum > $num) {
 582+      $num = $newnum;
 583+    }
 584+  }
 585+
 586+  return $num;
 587+}
 588+
 589+sub print_centered
 590+{
 591+  my ($width, $string) = @_;
 592+
 593+  if (length ($string)) {
 594+    my $pad = " " x ( ($width - length ($string) + 1) / 2);
 595+    print "$pad$string";
 596+  }
 597+}
 598+
 599+sub print_banner
 600+{
 601+  # $testee is suite-defined
 602+  my $info = "Running tests for $testee on $osname";
 603+  my $len = &max (length($info), length($testee_version), 77) + 2;
 604+  my $line = ("-" x $len) . "\n";
 605+
 606+  &print_centered ($len, $line);
 607+  &print_centered ($len, $info."\n");
 608+  &print_centered ($len, $testee_version);
 609+  &print_centered ($len, $line);
 610+  print "\n";
 611+}
 612+
 613+sub run_all_tests
 614+{
 615+  # Make sure we always run the tests from the current directory
 616+  unshift(@INC, cwd());
 617+
 618+  $categories_run = 0;
 619+
 620+  # Make a copy of STDIN so we can reset it
 621+  open(INCOPY, "<&STDIN");
 622+
 623+  # Leave enough space in the extensions to append a number, even
 624+  # though it needs to fit into 8+3 limits.
 625+  if ($short_filenames) {
 626+    $logext = 'l';
 627+    $diffext = 'd';
 628+    $baseext = 'b';
 629+    $runext = 'r';
 630+    $extext = '';
 631+  } else {
 632+    $logext = 'log';
 633+    $diffext = 'diff';
 634+    $baseext = 'base';
 635+    $runext = 'run';
 636+    $extext = $osname eq 'VMS' ? '_' : '.';
 637+  }
 638+
 639+  $lasttest = '';
 640+  # $testname is published
 641+  foreach $testname (sort @TESTS) {
 642+    # Skip duplicates on VMS caused by logical name search lists.
 643+    next if $testname eq $lasttest;
 644+
 645+    $lasttest = $testname;
 646+    $suite_passed = 1;       # reset by test on failure
 647+    $num_of_logfiles = 0;
 648+    $num_of_tmpfiles = 0;
 649+    $description = "";
 650+    $details = "";
 651+    $old_makefile = undef;
 652+    $testname =~ s/^$scriptpath$pathsep//;
 653+    $testname =~ s/(\.pl|\.perl)$//;
 654+
 655+    $perl_testname = File::Spec->catfile($scriptpath, $testname);
 656+    -f $perl_testname or die "Invalid test: $testname\n\n";
 657+
 658+    local $testpath = File::Spec->catdir($workpath, $testname);
 659+
 660+    remove_directory_tree($testpath);
 661+    mkdir($testpath, 0777) or &error("Couldn't mkdir $testpath: $!\n", 1);
 662+
 663+    setup_for_test();
 664+
 665+    $output = "........................................................ ";
 666+
 667+    substr($output, 0, length($testname)) = "$testname ";
 668+
 669+    print $output;
 670+
 671+    $tests_run = 0;
 672+    $tests_passed = 0;
 673+
 674+    # Run the test!
 675+    chdir($testpath) or error("Can't change to $testpath: $!\n", 1);
 676+    $code = do $perl_testname;
 677+    chdir($cwd) or error("Can't change back to $cwd: $!\n", 1);
 678+
 679+    # Reset STDIN from the copy in case it was changed
 680+    open(STDIN, "<&INCOPY");
 681+
 682+    ++$categories_run;
 683+    $total_tests_run += $tests_run;
 684+    $total_tests_passed += $tests_passed;
 685+
 686+    # How did it go?
 687+    if (!defined($code)) {
 688+      # Failed to parse or called die
 689+      if (length ($@)) {
 690+        warn "\n*** Test died ($testname): $@\n";
 691+      } else {
 692+        warn "\n*** Couldn't parse $perl_testname\n";
 693+      }
 694+      $status = "FAILED ($tests_passed/$tests_run passed)";
 695+      $some_test_failed = 1;
 696+
 697+    } elsif ($code == -1) {
 698+      # Skipped... not supported
 699+      $status = "N/A";
 700+      --$categories_run;
 701+      remove_directory_tree($testpath);
 702+
 703+    } elsif ($code != 1) {
 704+      # Bad result... this shouldn't really happen.  Usually means that
 705+      # the suite forgot to end with "1;".
 706+      warn "\n*** Test returned $code\n";
 707+      $status = "FAILED ($tests_passed/$tests_run passed)";
 708+      $some_test_failed = 1;
 709+
 710+    } elsif ($tests_run == 0) {
 711+      # Nothing was done!!
 712+      $status = "FAILED (no tests found!)";
 713+      $some_test_failed = 1;
 714+
 715+    } elsif ($tests_run > $tests_passed) {
 716+      # Lose!
 717+      $status = "FAILED ($tests_passed/$tests_run passed)";
 718+      $some_test_failed = 1;
 719+
 720+    } else {
 721+      # Win!
 722+      ++$categories_passed;
 723+      $status = "ok     ($tests_passed passed)";
 724+
 725+      # Clean up
 726+      if (!$keep) {
 727+        remove_directory_tree($testpath);
 728+      }
 729+    }
 730+
 731+    # If the verbose option has been specified, then a short description
 732+    # of each test is printed before displaying the results of each test
 733+    # describing WHAT is being tested.
 734+
 735+    if ($verbose) {
 736+      if ($detail) {
 737+        print "\nWHAT IS BEING TESTED\n";
 738+        print "--------------------";
 739+      }
 740+      print "\n\n$description\n\n";
 741+    }
 742+
 743+    # If the detail option has been specified, then the details of HOW
 744+    # the test is testing what it says it is testing in the verbose output
 745+    # will be displayed here before the results of the test are displayed.
 746+
 747+    if ($detail) {
 748+      print "\nHOW IT IS TESTED\n";
 749+      print "----------------";
 750+      print "\n\n$details\n\n";
 751+    }
 752+
 753+    print "$status\n";
 754+  }
 755+
 756+  close(INCOPY);
 757+}
 758+
 759+# Deletes all filenames that are sent to it.
 760+
 761+sub rmfiles
 762+{
 763+  return (unlink @_);
 764+}
 765+
 766+sub print_standard_usage
 767+{
 768+  my ($plname, @moreusage) = @_;
 769+
 770+  print "usage:\t$plname [testname] [-verbose] [-detail] [-keep]\n";
 771+  print "\t\t\t[-profile] [-usage] [-help] [-debug]\n";
 772+  foreach (@moreusage) {
 773+    print "\t\t\t$_\n";
 774+  }
 775+}
 776+
 777+sub print_standard_help
 778+{
 779+  my (@morehelp) = @_;
 780+  my $t = "      ";
 781+
 782+  my $line = "Test Driver For $testee";
 783+  print "$line\n";
 784+  $line = "=" x length ($line);
 785+  print "$line\n";
 786+
 787+  print_usage();
 788+
 789+  print "\ntestname\n"
 790+      . "${t}You may, if you wish, run only ONE test if you know the name\n"
 791+      . "${t}of that test and specify this name anywhere on the command\n"
 792+      . "${t}line.  Otherwise ALL existing tests in the scripts directory\n"
 793+      . "${t}will be run.\n"
 794+      . "-verbose\n"
 795+      . "${t}If this option is given, a description of every test is\n"
 796+      . "${t}displayed before the test is run. (Not all tests may have\n"
 797+      . "${t}descriptions at this time)\n"
 798+      . "-detail\n"
 799+      . "${t}If this option is given, a detailed description of every\n"
 800+      . "${t}test is displayed before the test is run. (Not all tests\n"
 801+      . "${t}have descriptions at this time)\n"
 802+      . "-profile\n"
 803+      . "${t}If this option is given, then the profile file\n"
 804+      . "${t}is added to other profiles every time $testee is run.\n"
 805+      . "${t}This option only works on VOS at this time.\n"
 806+      . "-keep\n"
 807+      . "${t}You may give this option if you DO NOT want ANY\n"
 808+      . "${t}of the files generated by the tests to be deleted. \n"
 809+      . "${t}Without this option, all files generated by the test will\n"
 810+      . "${t}be deleted IF THE TEST PASSES.\n"
 811+      . "-debug\n"
 812+      . "${t}Use this option if you would like to see all of the system\n"
 813+      . "${t}calls issued and their return status while running the tests\n"
 814+      . "${t}This can be helpful if you're having a problem adding a test\n"
 815+      . "${t}to the suite, or if the test fails!\n";
 816+
 817+  foreach $line (@morehelp) {
 818+    my $tline = $line;
 819+    if (substr ($tline, 0, 1) eq "\t") {
 820+      substr ($tline, 0, 1) = $t;
 821+    }
 822+    print "$tline\n";
 823+  }
 824+}
 825+
 826+#######################################################################
 827+###########         Generic Test Driver Subroutines         ###########
 828+#######################################################################
 829+
 830+sub get_caller
 831+{
 832+  my $depth = defined ($_[0]) ? $_[0] : 1;
 833+  my ($pkg, $filename, $linenum) = caller ($depth + 1);
 834+  return "$filename: $linenum";
 835+}
 836+
 837+sub error
 838+{
 839+  my $message = $_[0];
 840+  my $caller = &get_caller (1);
 841+
 842+  if (defined ($_[1])) {
 843+    $caller = &get_caller ($_[1] + 1) . " -> $caller";
 844+  }
 845+
 846+  die "$caller: $message";
 847+}
 848+
 849+sub compare_answer_vms
 850+{
 851+  my ($kgo, $log) = @_;
 852+
 853+  # VMS has extra blank lines in output sometimes.
 854+  # Ticket #41760
 855+  $log =~ s/\n\n+/\n/gm;
 856+  $log =~ s/\A\n+//g;
 857+  return 1 if ($kgo eq $log);
 858+
 859+  # VMS adding a "Waiting for unfinished jobs..."
 860+  # Remove it for now to see what else is going on.
 861+  $log =~ s/^.+\*\*\* Waiting for unfinished jobs.+$//m;
 862+  $log =~ s/\n\n/\n/gm;
 863+  $log =~ s/^\n+//gm;
 864+  return 1 if ($log eq $kgo);
 865+
 866+  # VMS wants target device to exist or generates an error,
 867+  # Some test targets look like VMS devices and trip this.
 868+  $log =~ s/^.+\: no such device or address.*$//gim;
 869+  $log =~ s/\n\n/\n/gm;
 870+  $log =~ s/^\n+//gm;
 871+  return 1 if ($log eq $kgo);
 872+
 873+  # VMS error message has a different case
 874+  $log =~ s/no such file /No such file /gm;
 875+  return 1 if ($log eq $kgo);
 876+
 877+  # VMS is putting comas instead of spaces in output
 878+  $log =~ s/,/ /gm;
 879+  return 1 if ($log eq $kgo);
 880+
 881+  # VMS Is sometimes adding extra leading spaces to output?
 882+  {
 883+     (my $mlog = $log) =~ s/^ +//gm;
 884+     return 1 if ($mlog eq $kgo);
 885+  }
 886+
 887+  # VMS port not handling POSIX encoded child status
 888+  # Translate error case it for now.
 889+  $log =~ s/0x1035a00a/1/gim;
 890+  return 1 if ($log =~ /\Q$kgo\E/i);
 891+
 892+  $log =~ s/0x1035a012/2/gim;
 893+  return 1 if ($log eq $kgo);
 894+
 895+  # Tests are using a UNIX null command, temp hack
 896+  # until this can be handled by the VMS port.
 897+  # ticket # 41761
 898+  $log =~ s/^.+DCL-W-NOCOMD.*$//gim;
 899+  $log =~ s/\n\n+/\n/gm;
 900+  $log =~ s/^\n+//gm;
 901+  return 1 if ($log eq $kgo);
 902+
 903+  # Tests are using exit 0;
 904+  # this generates a warning that should stop the make, but does not
 905+  $log =~ s/^.+NONAME-W-NOMSG.*$//gim;
 906+  $log =~ s/\n\n+/\n/gm;
 907+  $log =~ s/^\n+//gm;
 908+  return 1 if ($log eq $kgo);
 909+
 910+  # VMS is sometimes adding single quotes to output?
 911+  $log =~ s/\'//gm;
 912+  return 1 if ($log eq $kgo);
 913+
 914+  # And missing an extra space in output
 915+  $kgo =~ s/\h\h+/ /gm;
 916+  return 1 if ($log eq $kgo);
 917+
 918+  # VMS adding ; to end of some lines.
 919+  $log =~ s/;\n/\n/gm;
 920+  return 1 if ($log eq $kgo);
 921+
 922+  # VMS adding trailing space to end of some quoted lines.
 923+  $log =~ s/\h+\n/\n/gm;
 924+  return 1 if ($log eq $kgo);
 925+
 926+  # And VMS missing leading blank line
 927+  $kgo =~ s/\A\n//g;
 928+  return 1 if ($log eq $kgo);
 929+
 930+  # Unix double quotes showing up as single quotes on VMS.
 931+  $kgo =~ s/\"//g;
 932+  return 1 if ($log eq $kgo);
 933+
 934+  return 0;
 935+}
 936+
 937+sub convert_answer_zos
 938+{
 939+  my ($log) = @_;
 940+
 941+  # z/OS emits "Error 143" or "SIGTERM" instead of terminated
 942+  $log =~ s/Error 143/Terminated/igm;
 943+  $log =~ s/SIGTERM/Terminated/igm;
 944+
 945+  # z/OS error messages have a prefix
 946+  $log =~ s/EDC5129I No such file or directory\./No such file or directory/igm;
 947+  $log =~ s/FSUM7351 not found/not found/igm;
 948+
 949+  return $log;
 950+}
 951+
 952+sub compare_answer
 953+{
 954+  my ($kgo, $log) = @_;
 955+  my ($mkgo, $mlog);
 956+
 957+  # For make, get rid of any time skew error before comparing--too bad this
 958+  # has to go into the "generic" driver code :-/
 959+  $log =~ s/^.*modification time .*in the future.*\n//igm;
 960+  $log =~ s/^.*clock skew detected.*\n//igm;
 961+  return 1 if ($log eq $kgo);
 962+
 963+  # Get rid of newline differences, forever
 964+  $kgo =~ s,\r\n,\n,gs;
 965+  $log =~ s,\r\n,\n,gs;
 966+  return 1 if ($log eq $kgo);
 967+
 968+  # Keep the originals in case it's a regex
 969+  $mkgo = $kgo;
 970+  $mlog = $log;
 971+
 972+  # z/OS has quirky outputs
 973+  if ($osname eq 'os390') {
 974+    $mlog = convert_answer_zos($mlog);
 975+    return 1 if ($mlog eq $kgo);
 976+  }
 977+
 978+  # Some versions of Perl on Windows use /c instead of C:
 979+  $mkgo =~ s,\b([A-Z]):,/\L$1,g;
 980+  $mlog =~ s,\b([A-Z]):,/\L$1,g;
 981+  return 1 if ($mlog eq $mkgo);
 982+
 983+  # See if it is a backslash problem (only on W32?)
 984+  $mkgo =~ tr,\\,/,;
 985+  $mlog =~ tr,\\,/,;
 986+  return 1 if ($mlog eq $mkgo);
 987+
 988+  # VMS is a whole thing...
 989+  return 1 if ($osname eq 'VMS' && compare_answer_vms($kgo, $log));
 990+
 991+  # See if the answer might be a regex.
 992+  if ($kgo =~ m,^/(.+)/$,) {
 993+    # Check the regex against both the original and modified strings
 994+    return 1 if ($log =~ /$1/);
 995+    return 1 if ($mlog =~ /$1/);
 996+  }
 997+
 998+  return 0;
 999+}
1000+
1001+my %old_tempfiles = ();
1002+
1003+sub compare_output
1004+{
1005+  my ($answer, $logfile) = @_;
1006+  my ($slurp, $matched, $extra) = ('', 0, 0);
1007+
1008+  ++$tests_run;
1009+
1010+  # Check to see if any temporary files were leftover after the run completes
1011+  my @tf = ();
1012+  foreach my $file (glob(File::Spec->catfile($temppath, "*"))) {
1013+    if (!exists $old_tempfiles{$file}) {
1014+      push @tf, $file;
1015+      $old_tempfiles{$file} = 1;
1016+    }
1017+  }
1018+  if (@tf) {
1019+    open (LOGFILE, '>>', $logfile) or die "Cannot open log file $logfile: $!\n";
1020+    print LOGFILE "Leftover temporary files: @tf\n";
1021+    close (LOGFILE);
1022+    $extra = 1;
1023+  }
1024+
1025+  if (! defined $answer) {
1026+    print "Ignoring output ........ " if $debug;
1027+    $matched = 1;
1028+  } else {
1029+    print "Comparing output ........ " if $debug;
1030+    $matched = compare_answer($answer, &read_file_into_string ($logfile));
1031+  }
1032+
1033+  my $base = get_basefile();
1034+  my $run = get_runfile();
1035+  my $diff = get_difffile();
1036+
1037+  my %e = ('log' => File::Spec->catdir($testpath, $logfile));
1038+
1039+  if (! $matched) {
1040+    &create_file($base, $answer);
1041+    &create_file($run, $command_string);
1042+    $e{'base'} = File::Spec->catdir($testpath, $base);
1043+    $e{'run'} = File::Spec->catdir($testpath, $run);
1044+  }
1045+
1046+  if ($matched && $test_passed && !$extra) {
1047+    print "ok\n" if $debug;
1048+    ++$tests_passed;
1049+    return 1;
1050+  }
1051+
1052+  if (! $matched) {
1053+    # Create the difference file
1054+    if ($diff_name) {
1055+        run_command_with_output($diff, "\"$diff_name\" -c $base $logfile");
1056+    } else {
1057+        create_file($diff, "Log file $logfile differs from base file $base\n");
1058+    }
1059+
1060+    $e{'diff'} = File::Spec->catdir($testpath, $diff);
1061+  }
1062+
1063+  push @failure_info, \%e;
1064+
1065+  return 0;
1066+}
1067+
1068+sub read_file_into_string
1069+{
1070+  my ($filename) = @_;
1071+  my $oldslash = $/;
1072+  undef $/;
1073+
1074+  open (RFISFILE, '<', $filename) or return "";
1075+  my $slurp = <RFISFILE>;
1076+  close (RFISFILE);
1077+
1078+  $/ = $oldslash;
1079+
1080+  return $slurp;
1081+}
1082+
1083+my @OUTSTACK = ();
1084+my @ERRSTACK = ();
1085+
1086+sub attach_default_output
1087+{
1088+  my ($filename) = @_;
1089+
1090+  if ($vos)
1091+  {
1092+    my $code = system "++attach_default_output_hack $filename";
1093+    $code == -2 or &error ("ado death\n", 1);
1094+    return 1;
1095+  }
1096+
1097+  my $dup = undef;
1098+  open($dup, '>&', STDOUT) or error("ado: $! duping STDOUT\n", 1);
1099+  push @OUTSTACK, $dup;
1100+
1101+  $dup = undef;
1102+  open($dup, '>&', STDERR) or error("ado: $! duping STDERR\n", 1);
1103+  push @ERRSTACK, $dup;
1104+
1105+  open(STDOUT, '>', $filename) or error("ado: $filename: $!\n", 1);
1106+  open(STDERR, ">&STDOUT") or error("ado: $filename: $!\n", 1);
1107+}
1108+
1109+# close the current stdout/stderr, and restore the previous ones from
1110+# the "stack."
1111+
1112+sub detach_default_output
1113+{
1114+  if ($vos)
1115+  {
1116+    my $code = system "++detach_default_output_hack";
1117+    $code == -2 or &error ("ddoh death\n", 1);
1118+    return 1;
1119+  }
1120+
1121+  @OUTSTACK or error("default output stack has flown under!\n", 1);
1122+
1123+  close(STDOUT);
1124+  close(STDERR) unless $osname eq 'VMS';
1125+
1126+
1127+  open (STDOUT, '>&', pop @OUTSTACK) or error("ddo: $! duping STDOUT\n", 1);
1128+  open (STDERR, '>&', pop @ERRSTACK) or error("ddo: $! duping STDERR\n", 1);
1129+}
1130+
1131+sub _run_with_timeout
1132+{
1133+  my $code;
1134+  if ($osname eq 'VMS') {
1135+    #local $SIG{ALRM} = sub {
1136+    #    my $e = $ERRSTACK[0];
1137+    #    print $e "\nTest timed out after $test_timeout seconds\n";
1138+    #    die "timeout\n";
1139+    #};
1140+    #alarm $test_timeout;
1141+    system(@_);
1142+    #alarm 0;
1143+    my $severity = ${^CHILD_ERROR_NATIVE} & 7;
1144+    $code = 0;
1145+    if (($severity & 1) == 0) {
1146+      $code = 512;
1147+    }
1148+
1149+    # Get the vms status.
1150+    my $vms_code = ${^CHILD_ERROR_NATIVE};
1151+
1152+    # Remove the print status bit
1153+    $vms_code &= ~0x10000000;
1154+
1155+    # Posix code translation.
1156+    if (($vms_code & 0xFFFFF000) == 0x35a000) {
1157+      $code = (($vms_code & 0xFFF) >> 3) * 256;
1158+    }
1159+
1160+  } elsif ($port_type eq 'W32' && $^O ne 'msys') {
1161+    # Using ActiveState Perl (?)
1162+    my $pid = system(1, @_);
1163+    $pid > 0 or die "Cannot execute $_[0]: $!\n";
1164+    local $SIG{ALRM} = sub {
1165+      my $e = $ERRSTACK[0];
1166+      print $e "\nTest timed out after $test_timeout seconds\n";
1167+      kill -9, $pid;
1168+      die "timeout\n";
1169+    };
1170+    alarm $test_timeout;
1171+    my $r = waitpid($pid, 0);
1172+    alarm 0;
1173+    $r == -1 and die "No such pid: $pid\n";
1174+    # This shouldn't happen since we wait forever or timeout via SIGALRM
1175+    $r == 0 and die "No process exited.\n";
1176+    $code = $?;
1177+
1178+  } else {
1179+    my $pid = fork();
1180+    if (! $pid) {
1181+      exec(@_) or die "exec: Cannot execute $_[0]: $!\n";
1182+    }
1183+    local $SIG{ALRM} = sub {
1184+      my $e = $ERRSTACK[0];
1185+      print $e "\nTest timed out after $test_timeout seconds\n";
1186+      # Resend the alarm to our process group to kill the children.
1187+      $SIG{ALRM} = 'IGNORE';
1188+      kill -14, $$;
1189+      die "timeout\n";
1190+    };
1191+    alarm $test_timeout;
1192+    my $r = waitpid($pid, 0);
1193+    alarm 0;
1194+    $r == -1 and die "No such pid: $pid\n";
1195+    # This shouldn't happen since we wait forever or timeout via SIGALRM
1196+    $r == 0 and die "No process exited.\n";
1197+    $code = $?;
1198+  }
1199+
1200+  return $code;
1201+}
1202+
1203+# This runs a command without any debugging info.
1204+sub _run_command
1205+{
1206+  my $orig = $SIG{ALRM};
1207+  my $code = eval { _run_with_timeout(@_); };
1208+  $SIG{ALRM} = $orig;
1209+
1210+  # Reset then environment so that it's clean for the next test.
1211+  resetENV();
1212+
1213+  if ($@) {
1214+    # The eval failed.  If it wasn't SIGALRM then die.
1215+    $@ eq "timeout\n" or die "Command failed: $@";
1216+    $code = 14;
1217+  }
1218+
1219+  return $code;
1220+}
1221+
1222+# run one command (passed as a list of arg 0 - n), returning 0 on success
1223+# and nonzero on failure.
1224+
1225+sub run_command
1226+{
1227+  print "\nrun_command: @_\n" if $debug;
1228+  my $code = _run_command(@_);
1229+  print "run_command returned $code.\n" if $debug;
1230+  print "vms status = ${^CHILD_ERROR_NATIVE}\n" if $debug and $osname eq 'VMS';
1231+  return $code;
1232+}
1233+
1234+# run one command (passed as a list of arg 0 - n, with arg 0 being the
1235+# second arg to this routine), returning 0 on success and non-zero on failure.
1236+# The first arg to this routine is a filename to connect to the stdout
1237+# & stderr of the child process.
1238+
1239+sub run_command_with_output
1240+{
1241+  my $filename = shift;
1242+
1243+  print "\nrun_command_with_output($filename,$runname): @_\n" if $debug;
1244+  &attach_default_output ($filename);
1245+  my $code = eval { _run_command(@_) };
1246+  my $err = $@;
1247+  &detach_default_output;
1248+
1249+  $err and die $err;
1250+
1251+  print "run_command_with_output returned $code.\n" if $debug;
1252+  print "vms status = ${^CHILD_ERROR_NATIVE}\n" if $debug and $osname eq 'VMS';
1253+  return $code;
1254+}
1255+
1256+# performs the equivalent of an "rm -rf" on the first argument.  Like
1257+# rm, if the path ends in /, leaves the (now empty) directory; otherwise
1258+# deletes it, too.
1259+
1260+sub remove_directory_tree
1261+{
1262+  my ($targetdir) = @_;
1263+  my ($nuketop) = 1;
1264+
1265+  my $ch = substr ($targetdir, length ($targetdir) - 1);
1266+  if ($ch eq "/" || $ch eq $pathsep) {
1267+    $targetdir = substr ($targetdir, 0, length ($targetdir) - 1);
1268+    $nuketop = 0;
1269+  }
1270+
1271+  -e $targetdir or return 1;
1272+
1273+  &remove_directory_tree_inner ("RDT00", $targetdir) or return 0;
1274+  if ($nuketop && !rmdir ($targetdir)) {
1275+    print "Cannot remove $targetdir: $!\n";
1276+    return 0;
1277+  }
1278+
1279+  return 1;
1280+}
1281+
1282+sub remove_directory_tree_inner
1283+{
1284+  my ($dirhandle, $targetdir) = @_;
1285+
1286+  opendir ($dirhandle, $targetdir) or return 0;
1287+  my $subdirhandle = $dirhandle;
1288+  $subdirhandle++;
1289+  while (my $object = readdir ($dirhandle)) {
1290+    $object =~ /^(\.\.?|CVS|RCS)$/ and next;
1291+    $object = "$targetdir$pathsep$object";
1292+
1293+    lstat ($object);
1294+    if (-d _ && &remove_directory_tree_inner ($subdirhandle, $object)) {
1295+      if (!rmdir($object)) {
1296+        print "Cannot remove $object: $!\n";
1297+        return 0;
1298+      }
1299+    } else {
1300+      if ($osname ne 'VMS') {
1301+        if (!unlink $object) {
1302+          print "Cannot unlink $object: $!\n";
1303+          return 0;
1304+        }
1305+      } else {
1306+        # VMS can have multiple versions of a file.
1307+        1 while unlink $object;
1308+      }
1309+    }
1310+  }
1311+  closedir ($dirhandle);
1312+  return 1;
1313+}
1314+
1315+# We used to use this behavior for this function:
1316+#
1317+#sub touch
1318+#{
1319+#  my (@filenames) = @_;
1320+#  my $now = time;
1321+#
1322+#  foreach my $file (@filenames) {
1323+#    utime ($now, $now, $file)
1324+#          or (open (TOUCHFD, '>>', $file) and close (TOUCHFD))
1325+#               or &error ("Couldn't touch $file: $!\n", 1);
1326+#  }
1327+#  return 1;
1328+#}
1329+#
1330+# But this behaves badly on networked filesystems where the time is
1331+# skewed, because it sets the time of the file based on the _local_
1332+# host.  Normally when you modify a file, it's the _remote_ host that
1333+# determines the modtime, based on _its_ clock.  So, instead, now we open
1334+# the file and write something into it to force the remote host to set
1335+# the modtime correctly according to its clock.
1336+#
1337+
1338+sub touch
1339+{
1340+  foreach my $file (@_) {
1341+    (open(T, '>>', $file) and print(T "\n") and close(T))
1342+        or &error("Couldn't touch $file: $!\n", 1);
1343+  }
1344+
1345+  return @_;
1346+}
1347+
1348+# Touch with a time offset.  To DTRT, call touch() then use stat() to get the
1349+# access/mod time for each file and apply the offset.
1350+
1351+sub utouch
1352+{
1353+  my $off = shift;
1354+
1355+  &touch(@_);
1356+
1357+  foreach my $f (@_) {
1358+      my @s = stat($f);
1359+      utime($s[8]+$off, $s[9]+$off, $f);
1360+  }
1361+
1362+  return @_;
1363+}
1364+
1365+# open a file, write some stuff to it, and close it.
1366+
1367+sub create_file
1368+{
1369+  my ($filename, @lines) = @_;
1370+
1371+  open (CF, '>', $filename) or &error ("Couldn't open '$filename': $!\n", 1);
1372+  foreach $line (@lines) {
1373+    print CF $line;
1374+  }
1375+  close (CF);
1376+}
1377+
1378+# create a directory tree described by an associative array, wherein each
1379+# key is a relative pathname (using slashes) and its associated value is
1380+# one of:
1381+#    DIR            indicates a directory
1382+#    FILE:contents  indicates a file, which should contain contents +\n
1383+#    LINK:target    indicates a symlink, pointing to $basedir/target
1384+# The first argument is the dir under which the structure will be created
1385+# (the dir will be made and/or cleaned if necessary); the second argument
1386+# is the associative array.
1387+
1388+sub create_dir_tree
1389+{
1390+  my ($basedir, %dirtree) = @_;
1391+
1392+  &remove_directory_tree ("$basedir");
1393+  mkdir ($basedir, 0777) or &error ("Couldn't mkdir $basedir: $!\n", 1);
1394+
1395+  foreach my $path (sort keys (%dirtree)) {
1396+    if ($dirtree {$path} =~ /^DIR$/) {
1397+      mkdir ("$basedir/$path", 0777)
1398+          or &error ("Couldn't mkdir $basedir/$path: $!\n", 1);
1399+
1400+    } elsif ($dirtree {$path} =~ /^FILE:(.*)$/) {
1401+      &create_file ("$basedir/$path", $1 . "\n");
1402+
1403+    } elsif ($dirtree {$path} =~ /^LINK:(.*)$/) {
1404+      symlink ("$basedir/$1", "$basedir/$path")
1405+          or &error ("Couldn't symlink $basedir/$path -> $basedir/$1: $!\n", 1);
1406+
1407+    } else {
1408+      &error ("Bogus dirtree type: \"$dirtree{$path}\"\n", 1);
1409+    }
1410+  }
1411+  if ($just_setup_tree) {
1412+    die "Tree is setup...\n";
1413+  }
1414+}
1415+
1416+# compare a directory tree with an associative array in the format used
1417+# by create_dir_tree, above.
1418+# The first argument is the dir under which the structure should be found;
1419+# the second argument is the associative array.
1420+
1421+sub compare_dir_tree
1422+{
1423+  my ($basedir, %dirtree) = @_;
1424+  my $bogus = 0;
1425+
1426+  opendir (DIR, $basedir) or &error ("Couldn't open $basedir: $!\n", 1);
1427+  my @allfiles = grep (!/^(\.\.?|CVS|RCS)$/, readdir (DIR) );
1428+  closedir (DIR);
1429+  if ($debug) {
1430+    print "dirtree: (%dirtree)\n$basedir: (@allfiles)\n";
1431+  }
1432+
1433+  foreach my $path (sort keys (%dirtree))
1434+  {
1435+    if ($debug) {
1436+      print "Checking $path ($dirtree{$path}).\n";
1437+    }
1438+
1439+    my $found = 0;
1440+    foreach my $i (0 .. $#allfiles) {
1441+      if ($allfiles[$i] eq $path) {
1442+        splice (@allfiles, $i, 1);  # delete it
1443+        if ($debug) {
1444+          print "     Zapped $path; files now (@allfiles).\n";
1445+        }
1446+        lstat ("$basedir/$path");
1447+        $found = 1;
1448+        last;
1449+      }
1450+    }
1451+
1452+    if (!$found) {
1453+      print "compare_dir_tree: $path does not exist.\n";
1454+      $bogus = 1;
1455+      next;
1456+    }
1457+
1458+    if ($dirtree {$path} =~ /^DIR$/) {
1459+      if (-d _ && opendir (DIR, "$basedir/$path") ) {
1460+        my @files = readdir (DIR);
1461+        closedir (DIR);
1462+        @files = grep (!/^(\.\.?|CVS|RCS)$/ && ($_ = "$path/$_"), @files);
1463+        push (@allfiles, @files);
1464+        if ($debug)
1465+        {
1466+          print "     Read in $path; new files (@files).\n";
1467+        }
1468+
1469+      } else {
1470+        print "compare_dir_tree: $path is not a dir.\n";
1471+        $bogus = 1;
1472+      }
1473+
1474+    } elsif ($dirtree {$path} =~ /^FILE:(.*)$/) {
1475+      if (-l _ || !-f _) {
1476+        print "compare_dir_tree: $path is not a file.\n";
1477+        $bogus = 1;
1478+        next;
1479+      }
1480+
1481+      if ($1 ne "*") {
1482+        my $contents = &read_file_into_string ("$basedir/$path");
1483+        if ($contents ne "$1\n") {
1484+          print "compare_dir_tree: $path contains wrong stuff."
1485+              . "  Is:\n$contentsShould be:\n$1\n";
1486+          $bogus = 1;
1487+        }
1488+      }
1489+
1490+    } elsif ($dirtree {$path} =~ /^LINK:(.*)$/) {
1491+      my $target = $1;
1492+      if (!-l _) {
1493+        print "compare_dir_tree: $path is not a link.\n";
1494+        $bogus = 1;
1495+        next;
1496+      }
1497+
1498+      my $contents = readlink ("$basedir/$path");
1499+      $contents =~ tr/>/\//;
1500+      my $fulltarget = "$basedir/$target";
1501+      $fulltarget =~ tr/>/\//;
1502+      if (!($contents =~ /$fulltarget$/)) {
1503+        if ($debug) {
1504+          $target = $fulltarget;
1505+        }
1506+        print "compare_dir_tree: $path should be link to $target, "
1507+            . "not $contents.\n";
1508+        $bogus = 1;
1509+      }
1510+
1511+    } else {
1512+      &error ("Bogus dirtree type: \"$dirtree{$path}\"\n", 1);
1513+    }
1514+  }
1515+
1516+  if ($debug) {
1517+    print "leftovers: (@allfiles).\n";
1518+  }
1519+
1520+  foreach my $file (@allfiles) {
1521+    print "compare_dir_tree: $file should not exist.\n";
1522+    $bogus = 1;
1523+  }
1524+
1525+  return !$bogus;
1526+}
1527+
1528+# this subroutine generates the prefix name used to keep tmp filenames,
1529+# log filenames, etc., unique.
1530+
1531+sub get_prefix
1532+{
1533+  my ($num) = @_;
1534+  return sprintf("t%03d.", $num);
1535+}
1536+
1537+# just like logfile, only a generic tmp filename for use by the test.
1538+# they are automatically cleaned up unless -keep was used, or the test fails.
1539+# Pass an argument of 1 to return the same filename as the previous call.
1540+
1541+sub get_tmpfile
1542+{
1543+  my ($no_increment) = @_;
1544+
1545+  $num_of_tmpfiles += !$no_increment;
1546+
1547+  return (&get_prefix ($num_of_tmpfiles) . $tmpfilesuffix);
1548+}
1549+
1550+# This subroutine returns a log filename with a number appended to
1551+# the end corresponding to how many logfiles have been created in the
1552+# current running test.  An optional parameter may be passed (0 or 1).
1553+# If a 1 is passed, then it does NOT increment the logfile counter
1554+# and returns the name of the latest logfile.  If either no parameter
1555+# is passed at all or a 0 is passed, then the logfile counter is
1556+# incremented and the new name is returned.
1557+
1558+sub get_logfile
1559+{
1560+  my ($no_increment) = @_;
1561+
1562+  $num_of_logfiles += !$no_increment;
1563+
1564+  return (&get_prefix ($num_of_logfiles) . $logext);
1565+}
1566+
1567+# This subroutine returns a base (answer) filename with a number
1568+# appended to the end corresponding to how many logfiles (and thus
1569+# base files) have been created in the current running test.
1570+# NO PARAMETERS ARE PASSED TO THIS SUBROUTINE.
1571+
1572+sub get_basefile
1573+{
1574+  return (&get_prefix ($num_of_logfiles) . $baseext);
1575+}
1576+
1577+# This subroutine returns a difference filename with a number appended
1578+# to the end corresponding to how many logfiles (and thus diff files)
1579+# have been created in the current running test.
1580+
1581+sub get_difffile
1582+{
1583+  return (&get_prefix ($num_of_logfiles) . $diffext);
1584+}
1585+
1586+# This subroutine returns a command filename with a number appended
1587+# to the end corresponding to how many logfiles (and thus command files)
1588+# have been created in the current running test.
1589+
1590+sub get_runfile
1591+{
1592+  return (&get_prefix ($num_of_logfiles) . $runext);
1593+}
1594+
1595+1;
+150, -0
  1@@ -0,0 +1,150 @@
  2+#!/usr/bin/env perl
  3+# -*-perl-*-
  4+#
  5+# This script helps us write tests in a portable way, without relying on a lot
  6+# of shell features.  Since we already have Perl to run the tests, use that.
  7+#
  8+# The arguments represent a set of steps that will be run one at a time.
  9+# Each step consists of an operator and argument.
 10+#
 11+# It supports the following operators:
 12+#  out <word>     : echo <word> to stdout with a newline
 13+#  raw <word>     : echo <word> to stdout without adding anything
 14+#  env <word>     : echo the value of the env.var. <word>, or "<unset>"
 15+#  file <word>    : echo <word> to stdout AND create the file <word>
 16+#  dir <word>     : echo <word> to stdout AND create the directory <word>
 17+#  rm <word>      : echo <word> to stdout AND delete the file/directory <word>
 18+#  wait <word>    : wait for a file named <word> to exist
 19+#  exist <word>   : echo <word> AND fail if a file named <word> doesn't exist
 20+#  noexist <word> : echo <word> AND fail if a file named <word> exists
 21+#  tmout <secs>   : Change the timeout for waiting.  Default is 4 seconds.
 22+#  sleep <secs>   : Sleep for <secs> seconds then echo <secs>
 23+#  term <pid>     : send SIGTERM to PID <pid>
 24+#  fail <err>     : echo <err> to stdout then exit with error code err
 25+#
 26+# If given -q only the "out", "raw", and "env" commands generate output.
 27+
 28+# Force flush
 29+$| = 1;
 30+
 31+my $quiet = 0;
 32+my $timeout = 10;
 33+
 34+sub op {
 35+    my ($op, $nm) = @_;
 36+
 37+    defined $nm or die "Missing value for $op\n";
 38+
 39+    if ($op eq 'out') {
 40+        print "$nm\n";
 41+        return 1;
 42+    }
 43+    if ($op eq 'raw') {
 44+        print "$nm";
 45+        return 1;
 46+    }
 47+
 48+    if ($op eq 'env') {
 49+        print "$nm=" unless $quiet;
 50+        if (exists $ENV{$nm}) {
 51+            print "$ENV{$nm}\n";
 52+        } else {
 53+            print "<unset>\n";
 54+        }
 55+        return 1;
 56+    }
 57+
 58+    # Show the output before creating the file
 59+    if ($op eq 'file') {
 60+        print "file $nm\n" unless $quiet;
 61+        open(my $fh, '>', $nm) or die "$nm: open: $!\n";
 62+        close(my $fh);
 63+        return 1;
 64+    }
 65+
 66+    if ($op eq 'exist') {
 67+        -f "$nm" || die "$nm: file should exist: $!\n";
 68+        print "exist $nm\n" unless $quiet;
 69+        return 1
 70+    }
 71+
 72+    if ($op eq 'noexist') {
 73+        -f "$nm" && die "$nm: file exists\n";
 74+        print "noexist $nm\n" unless $quiet;
 75+        return 1
 76+    }
 77+
 78+    # Show the output before creating the directory
 79+    if ($op eq 'dir') {
 80+        print "dir $nm\n" unless $quiet;
 81+        mkdir($nm) or die "$nm: mkdir: $!\n";
 82+        return 1;
 83+    }
 84+
 85+    # Show the output after removing the file
 86+    if ($op eq 'rm') {
 87+        if (-f $nm) {
 88+            unlink($nm) or die "$nm: unlink: $!\n";
 89+        } elsif (-d $nm) {
 90+            rmdir($nm) or die "$nm: rmdir: $!\n";
 91+        } else {
 92+            die "$nm: not file or directory: $!\n";
 93+        }
 94+        print "rm $nm\n" unless $quiet;
 95+        return 1;
 96+    }
 97+
 98+    if ($op eq 'tmout') {
 99+        $timeout = $nm;
100+        print "tmout $nm\n" unless $quiet;
101+        return 1;
102+    }
103+
104+    # Show the output after the file exists
105+    if ($op eq 'wait') {
106+        my $start = time();
107+        my $end = $start + $timeout;
108+        while (time() <= $end) {
109+            if (-f $nm) {
110+                print "wait $nm\n" unless $quiet;
111+                return 1;
112+            }
113+            select(undef, undef, undef, 0.1);
114+        }
115+        die "wait $nm: timeout after ".(time()-$start-1)." seconds\n";
116+    }
117+
118+    # Show the output after sleeping
119+    if ($op eq 'sleep') {
120+        sleep($nm);
121+        print "sleep $nm\n" unless $quiet;
122+        return 1;
123+    }
124+
125+    if ($op eq 'term') {
126+        print "term $nm\n" unless $quiet;
127+        kill('TERM', $nm);
128+        return 1;
129+    }
130+
131+    if ($op eq 'fail') {
132+        print "fail $nm\n" unless $quiet;
133+        exit($nm);
134+    }
135+
136+    die("Invalid command: $op $nm\n");
137+}
138+
139+if (@ARGV && $ARGV[0] eq '-q') {
140+    $quiet = 1;
141+    shift;
142+}
143+
144+while (@ARGV) {
145+    if (op($ARGV[0], $ARGV[1])) {
146+        shift;
147+        shift;
148+    }
149+}
150+
151+exit(0);