* texinfo.tex (\acronym): New Texinfo command.
[make.git] / default.c
blob5f5d2b51c573e3941d472399fbc7c7cc6941226d
1 /* Data base of default implicit rules for GNU Make.
2 Copyright (C) 1988,89,90,91,92,93,94,95,96 Free Software Foundation, Inc.
3 This file is part of GNU Make.
5 GNU Make is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
10 GNU Make is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNU Make; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19 #include "make.h"
20 #include "rule.h"
21 #include "dep.h"
22 #include "filedef.h"
23 #include "job.h"
24 #include "commands.h"
25 #include "variable.h"
27 /* Define GCC_IS_NATIVE if gcc is the native development environment on
28 your system (gcc/bison/flex vs cc/yacc/lex). */
29 #ifdef __MSDOS__
30 #define GCC_IS_NATIVE
31 #endif
34 /* This is the default list of suffixes for suffix rules.
35 `.s' must come last, so that a `.o' file will be made from
36 a `.c' or `.p' or ... file rather than from a .s file. */
38 static char default_suffixes[]
39 #ifdef VMS
40 = ".exe .olb .ln .obj .c .cc .pas .p .for .f .r .y .l .mar \
41 .mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \
42 .w .ch .cweb .web .com .sh .elc .el";
43 #else
44 = ".out .a .ln .o .c .cc .C .p .f .F .r .y .l .s .S \
45 .mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \
46 .w .ch .web .sh .elc .el";
47 #endif
49 static struct pspec default_pattern_rules[] =
51 { "(%)", "%",
52 "$(AR) $(ARFLAGS) $@ $<" },
54 /* The X.out rules are only in BSD's default set because
55 BSD Make has no null-suffix rules, so `foo.out' and
56 `foo' are the same thing. */
57 #ifdef VMS
58 { "%.exe", "%",
59 "copy $< $@" },
60 #else
61 { "%.out", "%",
62 "@rm -f $@ \n cp $< $@" },
63 #endif
64 /* Syntax is "ctangle foo.w foo.ch foo.c". */
65 { "%.c", "%.w %.ch",
66 "$(CTANGLE) $^ $@" },
67 { "%.tex", "%.w %.ch",
68 "$(CWEAVE) $^ $@" },
70 { 0, 0, 0 }
73 static struct pspec default_terminal_rules[] =
75 #ifdef VMS
76 /* RCS. */
77 { "%", "%$$5lv", /* Multinet style */
78 "if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
79 { "%", "[.$$rcs]%$$5lv", /* Multinet style */
80 "if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
81 { "%", "%_v", /* Normal style */
82 "if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
83 { "%", "[.rcs]%_v", /* Normal style */
84 "if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
86 /* SCCS. */
87 /* ain't no SCCS on vms */
88 #else
89 /* RCS. */
90 { "%", "%,v",
91 "$(CHECKOUT,v)" },
92 { "%", "RCS/%,v",
93 "$(CHECKOUT,v)" },
95 /* SCCS. */
96 { "%", "s.%",
97 "$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" },
98 { "%", "SCCS/s.%",
99 "$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" },
100 #endif /* !VMS */
101 { 0, 0, 0 }
104 static char *default_suffix_rules[] =
106 #ifdef VMS
107 ".obj.exe",
108 "$(LINK.obj) $^ $(LOADLIBES) $(LDLIBS) /exe=$@",
109 ".mar.exe",
110 "$(LINK.mar) $^ $(LOADLIBES) $(LDLIBS) /exe=$@",
111 ".c.exe",
112 "$(COMPILE.c) $^ \n $(LINK.obj) $(subst .c,.obj,$^) $(LOADLIBES) $(LDLIBS) /exe=$@",
113 ".cc.exe",
114 "$(COMPILE.cc) $^ \n $(LINK.obj) $(subst .cc,.obj,$^) $(LOADLIBES) $(LDLIBS) /exe=$@",
115 ".for.exe",
116 "$(COMPILE.for) $^ \n $(LINK.obj) $(subst .for,.obj,$^) $(LOADLIBES) $(LDLIBS) /exe=$@",
117 ".pas.exe",
118 "$(COMPILE.pas) $^ \n $(LINK.obj) $(subst .pas,.obj,$^) $(LOADLIBES) $(LDLIBS) /exe=$@",
120 ".com",
121 "copy $< >$@",
123 ".mar.obj",
124 "$(COMPILE.mar) /obj=$@ $<",
125 ".c.obj",
126 "$(COMPILE.c) /obj=$@ $<",
127 ".cc.obj",
128 "$(COMPILE.cc) /obj=$@ $<",
129 ".for.obj",
130 "$(COMPILE.for) /obj=$@ $<",
131 ".pas.obj",
132 "$(COMPILE.pas) /obj=$@ $<",
134 ".y.c",
135 "$(YACC.y) $< \n rename y_tab.c $@",
136 ".l.c",
137 "$(LEX.l) $< \n rename lexyy.c $@",
139 ".texinfo.info",
140 "$(MAKEINFO) $<",
142 ".tex.dvi",
143 "$(TEX) $<",
145 #else /* ! VMS */
147 ".o",
148 "$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@",
149 ".s",
150 "$(LINK.s) $^ $(LOADLIBES) $(LDLIBS) -o $@",
151 ".S",
152 "$(LINK.S) $^ $(LOADLIBES) $(LDLIBS) -o $@",
153 ".c",
154 "$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@",
155 ".cc",
156 "$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@",
157 ".C",
158 "$(LINK.C) $^ $(LOADLIBES) $(LDLIBS) -o $@",
159 ".f",
160 "$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@",
161 ".p",
162 "$(LINK.p) $^ $(LOADLIBES) $(LDLIBS) -o $@",
163 ".F",
164 "$(LINK.F) $^ $(LOADLIBES) $(LDLIBS) -o $@",
165 ".r",
166 "$(LINK.r) $^ $(LOADLIBES) $(LDLIBS) -o $@",
167 ".mod",
168 "$(COMPILE.mod) -o $@ -e $@ $^",
170 ".def.sym",
171 "$(COMPILE.def) -o $@ $<",
173 ".sh",
174 "cat $< >$@ \n chmod a+x $@",
176 ".s.o",
177 "$(COMPILE.s) -o $@ $<",
178 ".S.o",
179 "$(COMPILE.S) -o $@ $<",
180 ".c.o",
181 "$(COMPILE.c) $< $(OUTPUT_OPTION)",
182 ".cc.o",
183 "$(COMPILE.cc) $< $(OUTPUT_OPTION)",
184 ".C.o",
185 "$(COMPILE.C) $< $(OUTPUT_OPTION)",
186 ".f.o",
187 "$(COMPILE.f) $< $(OUTPUT_OPTION)",
188 ".p.o",
189 "$(COMPILE.p) $< $(OUTPUT_OPTION)",
190 ".F.o",
191 "$(COMPILE.F) $< $(OUTPUT_OPTION)",
192 ".r.o",
193 "$(COMPILE.r) $< $(OUTPUT_OPTION)",
194 ".mod.o",
195 "$(COMPILE.mod) -o $@ $<",
197 ".c.ln",
198 "$(LINT.c) -C$* $<",
199 ".y.ln",
200 #ifndef __MSDOS__
201 "$(YACC.y) $< \n $(LINT.c) -C$* y.tab.c \n $(RM) y.tab.c",
202 #else
203 "$(YACC.y) $< \n $(LINT.c) -C$* y_tab.c \n $(RM) y_tab.c",
204 #endif
205 ".l.ln",
206 "@$(RM) $*.c\n $(LEX.l) $< > $*.c\n$(LINT.c) -i $*.c -o $@\n $(RM) $*.c",
208 ".y.c",
209 #ifndef __MSDOS__
210 "$(YACC.y) $< \n mv -f y.tab.c $@",
211 #else
212 "$(YACC.y) $< \n mv -f y_tab.c $@",
213 #endif
214 ".l.c",
215 "@$(RM) $@ \n $(LEX.l) $< > $@",
217 ".F.f",
218 "$(PREPROCESS.F) $< $(OUTPUT_OPTION)",
219 ".r.f",
220 "$(PREPROCESS.r) $< $(OUTPUT_OPTION)",
222 /* This might actually make lex.yy.c if there's no %R%
223 directive in $*.l, but in that case why were you
224 trying to make $*.r anyway? */
225 ".l.r",
226 "$(LEX.l) $< > $@ \n mv -f lex.yy.r $@",
228 ".S.s",
229 "$(PREPROCESS.S) $< > $@",
231 ".texinfo.info",
232 "$(MAKEINFO) $(MAKEINFO_FLAGS) $< -o $@",
234 ".texi.info",
235 "$(MAKEINFO) $(MAKEINFO_FLAGS) $< -o $@",
237 ".txinfo.info",
238 "$(MAKEINFO) $(MAKEINFO_FLAGS) $< -o $@",
240 ".tex.dvi",
241 "$(TEX) $<",
243 ".texinfo.dvi",
244 "$(TEXI2DVI) $(TEXI2DVI_FLAGS) $<",
246 ".texi.dvi",
247 "$(TEXI2DVI) $(TEXI2DVI_FLAGS) $<",
249 ".txinfo.dvi",
250 "$(TEXI2DVI) $(TEXI2DVI_FLAGS) $<",
252 ".w.c",
253 "$(CTANGLE) $< - $@", /* The `-' says there is no `.ch' file. */
255 ".web.p",
256 "$(TANGLE) $<",
258 ".w.tex",
259 "$(CWEAVE) $< - $@", /* The `-' says there is no `.ch' file. */
261 ".web.tex",
262 "$(WEAVE) $<",
264 #endif /* !VMS */
266 0, 0,
269 static char *default_variables[] =
271 #ifdef VMS
272 "AR", "library/obj",
273 "ARFLAGS", "/replace",
274 "AS", "macro",
275 "CC", "cc",
276 "C++", "gcc/plus",
277 "CXX", "gcc/plus",
278 "CO", "co",
279 "CPP", "$(CC) /preprocess_only",
280 "FC", "fortran",
281 /* System V uses these, so explicit rules using them should work.
282 However, there is no way to make implicit rules use them and FC. */
283 "F77", "$(FC)",
284 "F77FLAGS", "$(FFLAGS)",
285 "LD", "link",
286 "LEX", "lex",
287 "PC", "pascal",
288 "YACC", "yacc", /* Or "bison -y" */
289 "MAKEINFO", "makeinfo",
290 "TEX", "tex",
291 "TEXINDEX", "texindex",
293 "RM", "delete/nolog",
295 "LINK.obj", "$(LD) $(LDFLAGS)",
296 "COMPILE.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
297 "COMPILE.cc", "$(C++) $(C++FLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
298 "YACC.y", "$(YACC) $(YFLAGS)",
299 "LEX.l", "$(LEX) $(LFLAGS)",
300 "COMPILE.for", "$(FC) $(FFLAGS) $(TARGET_ARCH)",
301 "COMPILE.pas", "$(PC) $(PFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
302 "COMPILE.mar", "$(AS) $(ASFLAGS) $(TARGET_MACH)",
303 "LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
305 "MV", "rename/new_version",
306 "CP", "copy",
308 #else /* !VMS */
310 "AR", "ar",
311 "ARFLAGS", "rv",
312 "AS", "as",
313 #ifdef GCC_IS_NATIVE
314 "CC", "gcc",
315 "CXX", "gcc",
316 #else
317 "CC", "cc",
318 "CXX", "g++",
319 #endif
321 /* This expands to $(CO) $(COFLAGS) $< $@ if $@ does not exist,
322 and to the empty string if $@ does exist. */
323 "CHECKOUT,v",
324 "+$(patsubst $@-noexist,$(CO) $(COFLAGS) $< $@,\
325 $(filter-out $@,$(firstword $(wildcard $@) $@-noexist)))",
327 "CO", "co",
328 "CPP", "$(CC) -E",
329 #ifdef CRAY
330 "CF77PPFLAGS", "-P",
331 "CF77PP", "/lib/cpp",
332 "CFT", "cft77",
333 "CF", "cf77",
334 "FC", "$(CF)",
335 #else /* Not CRAY. */
336 #ifdef _IBMR2
337 "FC", "xlf",
338 #else
339 #ifdef __convex__
340 "FC", "fc",
341 #else
342 "FC", "f77",
343 #endif /* __convex__ */
344 #endif /* _IBMR2 */
345 /* System V uses these, so explicit rules using them should work.
346 However, there is no way to make implicit rules use them and FC. */
347 "F77", "$(FC)",
348 "F77FLAGS", "$(FFLAGS)",
349 #endif /* Cray. */
350 "GET", SCCS_GET,
351 "LD", "ld",
352 #ifdef GCC_IS_NATIVE
353 "LEX", "flex",
354 #else
355 "LEX", "lex",
356 #endif
357 "LINT", "lint",
358 "M2C", "m2c",
359 #ifdef pyr
360 "PC", "pascal",
361 #else
362 #ifdef CRAY
363 "PC", "PASCAL",
364 "SEGLDR", "segldr",
365 #else
366 "PC", "pc",
367 #endif /* CRAY. */
368 #endif /* pyr. */
369 #ifdef GCC_IS_NATIVE
370 "YACC", "bison -y",
371 #else
372 "YACC", "yacc", /* Or "bison -y" */
373 #endif
374 "MAKEINFO", "makeinfo",
375 "TEX", "tex",
376 "TEXI2DVI", "texi2dvi",
377 "WEAVE", "weave",
378 "CWEAVE", "cweave",
379 "TANGLE", "tangle",
380 "CTANGLE", "ctangle",
382 "RM", "rm -f",
384 "LINK.o", "$(CC) $(LDFLAGS) $(TARGET_ARCH)",
385 "COMPILE.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
386 "LINK.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
387 "COMPILE.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
388 "COMPILE.C", "$(COMPILE.cc)",
389 "LINK.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
390 "LINK.C", "$(LINK.cc)",
391 "YACC.y", "$(YACC) $(YFLAGS)",
392 "LEX.l", "$(LEX) $(LFLAGS) -t",
393 "COMPILE.f", "$(FC) $(FFLAGS) $(TARGET_ARCH) -c",
394 "LINK.f", "$(FC) $(FFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
395 "COMPILE.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
396 "LINK.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
397 "COMPILE.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -c",
398 "LINK.r", "$(FC) $(FFLAGS) $(RFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
399 "COMPILE.def", "$(M2C) $(M2FLAGS) $(DEFFLAGS) $(TARGET_ARCH)",
400 "COMPILE.mod", "$(M2C) $(M2FLAGS) $(MODFLAGS) $(TARGET_ARCH)",
401 "COMPILE.p", "$(PC) $(PFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
402 "LINK.p", "$(PC) $(PFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
403 "LINK.s", "$(CC) $(ASFLAGS) $(LDFLAGS) $(TARGET_MACH)",
404 "COMPILE.s", "$(AS) $(ASFLAGS) $(TARGET_MACH)",
405 "LINK.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_MACH)",
406 "COMPILE.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c",
407 "PREPROCESS.S", "$(CC) -E $(CPPFLAGS)",
408 "PREPROCESS.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -F",
409 "PREPROCESS.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -F",
410 "LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
412 #ifndef NO_MINUS_C_MINUS_O
413 "OUTPUT_OPTION", "-o $@",
414 #endif
416 #ifdef SCCS_GET_MINUS_G
417 "SCCS_OUTPUT_OPTION", "-G$@",
418 #endif
420 #endif /* !VMS */
421 0, 0
424 /* Set up the default .SUFFIXES list. */
426 void
427 set_default_suffixes ()
429 suffix_file = enter_file (".SUFFIXES");
431 if (no_builtin_rules_flag)
432 (void) define_variable ("SUFFIXES", 8, "", o_default, 0);
433 else
435 char *p = default_suffixes;
436 suffix_file->deps = (struct dep *)
437 multi_glob (parse_file_seq (&p, '\0', sizeof (struct dep), 1),
438 sizeof (struct dep));
439 (void) define_variable ("SUFFIXES", 8, default_suffixes, o_default, 0);
443 /* Enter the default suffix rules as file rules. This used to be done in
444 install_default_implicit_rules, but that loses because we want the
445 suffix rules installed before reading makefiles, and thee pattern rules
446 installed after. */
448 void
449 install_default_suffix_rules ()
451 register char **s;
453 if (no_builtin_rules_flag)
454 return;
456 for (s = default_suffix_rules; *s != 0; s += 2)
458 register struct file *f = enter_file (s[0]);
459 /* Don't clobber cmds given in a makefile if there were any. */
460 if (f->cmds == 0)
462 f->cmds = (struct commands *) xmalloc (sizeof (struct commands));
463 f->cmds->filename = 0;
464 f->cmds->commands = s[1];
465 f->cmds->command_lines = 0;
471 /* Install the default pattern rules. */
473 void
474 install_default_implicit_rules ()
476 register struct pspec *p;
478 if (no_builtin_rules_flag)
479 return;
481 for (p = default_pattern_rules; p->target != 0; ++p)
482 install_pattern_rule (p, 0);
484 for (p = default_terminal_rules; p->target != 0; ++p)
485 install_pattern_rule (p, 1);
488 void
489 define_default_variables ()
491 register char **s;
493 for (s = default_variables; *s != 0; s += 2)
494 (void) define_variable (s[0], strlen (s[0]), s[1], o_default, 1);