1 /* Data base of default implicit rules for GNU Make.
2 Copyright (C) 1988-2013 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 it under the
6 terms of the GNU General Public License as published by the Free Software
7 Foundation; either version 3 of the License, or (at your option) any later
10 GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License along with
15 this program. If not, see <http://www.gnu.org/licenses/>. */
28 /* Define GCC_IS_NATIVE if gcc is the native development environment on
29 your system (gcc/bison/flex vs cc/yacc/lex). */
30 #if defined(__MSDOS__) || defined(__EMX__)
31 # define GCC_IS_NATIVE
35 /* This is the default list of suffixes for suffix rules.
36 '.s' must come last, so that a '.o' file will be made from
37 a '.c' or '.p' or ... file rather than from a .s file. */
39 static char default_suffixes[]
41 = ".exe .olb .ln .obj .c .cxx .cc .pas .p .for .f .r .y .l .mar \
42 .s .ss .i .ii .mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \
43 .w .ch .cweb .web .com .sh .elc .el";
44 #elif defined(__EMX__)
45 = ".out .a .ln .o .c .cc .C .cpp .p .f .F .m .r .y .l .ym .yl .s .S \
46 .mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \
47 .w .ch .web .sh .elc .el .obj .exe .dll .lib";
49 = ".out .a .ln .o .c .cc .C .cpp .p .f .F .m .r .y .l .ym .yl .s .S \
50 .mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \
51 .w .ch .web .sh .elc .el";
54 static struct pspec default_pattern_rules[] =
57 "$(AR) $(ARFLAGS) $@ $<" },
59 /* The X.out rules are only in BSD's default set because
60 BSD Make has no null-suffix rules, so 'foo.out' and
61 'foo' are the same thing. */
67 "@rm -f $@ \n cp $< $@" },
69 /* Syntax is "ctangle foo.w foo.ch foo.c". */
72 { "%.tex", "%.w %.ch",
78 static struct pspec default_terminal_rules[] =
82 { "%", "%$$5lv", /* Multinet style */
83 "if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
84 { "%", "[.$$rcs]%$$5lv", /* Multinet style */
85 "if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
86 { "%", "%_v", /* Normal style */
87 "if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
88 { "%", "[.rcs]%_v", /* Normal style */
89 "if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
92 /* ain't no SCCS on vms */
104 "$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" },
106 "$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" },
111 static char *default_suffix_rules[] =
115 "$(LINK.obj) $^ $(LOADLIBES) $(LDLIBS) $(CRT0) /exe=$@",
117 "$(COMPILE.mar) $^ \n $(LINK.obj) $(subst .mar,.obj,$^) $(LOADLIBES) $(LDLIBS) $(CRT0) /exe=$@",
119 "$(COMPILE.s) $^ \n $(LINK.obj) $(subst .s,.obj,$^) $(LOADLIBES) $(LDLIBS) $(CRT0) /exe=$@",
121 "$(COMPILE.c) $^ \n $(LINK.obj) $(subst .c,.obj,$^) $(LOADLIBES) $(LDLIBS) $(CRT0) /exe=$@",
124 "$(COMPILE.cc) $^ \n $(LINK.obj) $(CXXSTARTUP),sys$$disk:[]$(subst .cc,.obj,$^) $(LOADLIBES) $(LXLIBS) $(LDLIBS) $(CXXRT0) /exe=$@",
126 "$(COMPILE.cc) $^ \n $(CXXLINK.obj) $(subst .cc,.obj,$^) $(LOADLIBES) $(LXLIBS) $(LDLIBS) $(CXXRT0) /exe=$@",
128 "$(COMPILE.cxx) $^ \n $(CXXLINK.obj) $(subst .cxx,.obj,$^) $(LOADLIBES) $(LXLIBS) $(LDLIBS) $(CXXRT0) /exe=$@",
131 "$(COMPILE.for) $^ \n $(LINK.obj) $(subst .for,.obj,$^) $(LOADLIBES) $(LDLIBS) /exe=$@",
133 "$(COMPILE.pas) $^ \n $(LINK.obj) $(subst .pas,.obj,$^) $(LOADLIBES) $(LDLIBS) /exe=$@",
139 "$(COMPILE.mar) /obj=$@ $<",
141 "$(COMPILE.s) /obj=$@ $<",
143 "$(COMPILE.s) /obj=$@ $<",
145 "$(COMPILE.c)/prep /list=$@ $<",
147 "$(COMPILE.c)/noobj/machine /list=$@ $<",
149 "$(COMPILE.c)/noprep/noobj/machine /list=$@ $<",
151 "$(COMPILE.c) /obj=$@ $<",
153 "$(COMPILE.cc)/prep /list=$@ $<",
155 "$(COMPILE.cc)/noobj/machine /list=$@ $<",
157 "$(COMPILE.cc)/noprep/noobj/machine /list=$@ $<",
159 "$(COMPILE.cc) /obj=$@ $<",
161 "$(COMPILE.cxx) /obj=$@ $<",
163 "$(COMPILE.for) /obj=$@ $<",
165 "$(COMPILE.pas) /obj=$@ $<",
168 "$(YACC.y) $< \n rename y_tab.c $@",
170 "$(LEX.l) $< \n rename lexyy.c $@",
181 "$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@",
183 "$(LINK.s) $^ $(LOADLIBES) $(LDLIBS) -o $@",
185 "$(LINK.S) $^ $(LOADLIBES) $(LDLIBS) -o $@",
187 "$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@",
189 "$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@",
191 "$(LINK.C) $^ $(LOADLIBES) $(LDLIBS) -o $@",
193 "$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@",
195 "$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@",
197 "$(LINK.m) $^ $(LOADLIBES) $(LDLIBS) -o $@",
199 "$(LINK.p) $^ $(LOADLIBES) $(LDLIBS) -o $@",
201 "$(LINK.F) $^ $(LOADLIBES) $(LDLIBS) -o $@",
203 "$(LINK.r) $^ $(LOADLIBES) $(LDLIBS) -o $@",
205 "$(COMPILE.mod) -o $@ -e $@ $^",
208 "$(COMPILE.def) -o $@ $<",
211 "cat $< >$@ \n chmod a+x $@",
214 "$(COMPILE.s) -o $@ $<",
216 "$(COMPILE.S) -o $@ $<",
218 "$(COMPILE.c) $(OUTPUT_OPTION) $<",
220 "$(COMPILE.cc) $(OUTPUT_OPTION) $<",
222 "$(COMPILE.C) $(OUTPUT_OPTION) $<",
224 "$(COMPILE.cpp) $(OUTPUT_OPTION) $<",
226 "$(COMPILE.f) $(OUTPUT_OPTION) $<",
228 "$(COMPILE.m) $(OUTPUT_OPTION) $<",
230 "$(COMPILE.p) $(OUTPUT_OPTION) $<",
232 "$(COMPILE.F) $(OUTPUT_OPTION) $<",
234 "$(COMPILE.r) $(OUTPUT_OPTION) $<",
236 "$(COMPILE.mod) -o $@ $<",
242 "$(YACC.y) $< \n $(LINT.c) -C$* y.tab.c \n $(RM) y.tab.c",
244 "$(YACC.y) $< \n $(LINT.c) -C$* y_tab.c \n $(RM) y_tab.c",
247 "@$(RM) $*.c\n $(LEX.l) $< > $*.c\n$(LINT.c) -i $*.c -o $@\n $(RM) $*.c",
251 "$(YACC.y) $< \n mv -f y.tab.c $@",
253 "$(YACC.y) $< \n mv -f y_tab.c $@",
256 "@$(RM) $@ \n $(LEX.l) $< > $@",
258 "$(YACC.m) $< \n mv -f y.tab.c $@",
260 "@$(RM) $@ \n $(LEX.m) $< > $@",
263 "$(PREPROCESS.F) $(OUTPUT_OPTION) $<",
265 "$(PREPROCESS.r) $(OUTPUT_OPTION) $<",
267 /* This might actually make lex.yy.c if there's no %R% directive in $*.l,
268 but in that case why were you trying to make $*.r anyway? */
270 "$(LEX.l) $< > $@ \n mv -f lex.yy.r $@",
273 "$(PREPROCESS.S) $< > $@",
276 "$(MAKEINFO) $(MAKEINFO_FLAGS) $< -o $@",
279 "$(MAKEINFO) $(MAKEINFO_FLAGS) $< -o $@",
282 "$(MAKEINFO) $(MAKEINFO_FLAGS) $< -o $@",
288 "$(TEXI2DVI) $(TEXI2DVI_FLAGS) $<",
291 "$(TEXI2DVI) $(TEXI2DVI_FLAGS) $<",
294 "$(TEXI2DVI) $(TEXI2DVI_FLAGS) $<",
297 "$(CTANGLE) $< - $@", /* The '-' says there is no '.ch' file. */
303 "$(CWEAVE) $< - $@", /* The '-' says there is no '.ch' file. */
313 static const char *default_variables[] =
326 "ARFLAGS", "/replace",
336 "ECHO", "write sys$$output \"",
346 "CPP", "$(CC) /preprocess_only",
348 /* System V uses these, so explicit rules using them should work.
349 However, there is no way to make implicit rules use them and FC. */
351 "F77FLAGS", "$(FFLAGS)",
355 "YACC", "bison/yacc",
356 "YFLAGS", "/Define/Verbose",
358 "MAKEINFO", "makeinfo",
360 "TEXINDEX", "texindex",
362 "RM", "delete/nolog",
366 "CRT0", ",sys$$library:vaxcrtl.olb/lib,gnu_cc_library:crt0.obj",
367 "CXXSTARTUP", "gnu_cc_library:crtbegin.obj",
368 "CXXRT0", ",sys$$library:vaxcrtl.olb/lib,gnu_cc_library:crtend.obj,gnu_cc_library:gxx_main.obj",
369 "LXLIBS", ",gnu_cc_library:libstdcxx.olb/lib,gnu_cc_library:libgccplus.olb/lib",
370 "LDLIBS", ",gnu_cc_library:libgcc.olb/lib",
379 "LINK.obj", "$(LD) $(LDFLAGS)",
380 #ifndef GCC_IS_NATIVE
381 "CXXLINK.obj", "$(CXXLD) $(LDFLAGS)",
382 "COMPILE.cxx", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
384 "COMPILE.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
385 "COMPILE.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
386 "YACC.y", "$(YACC) $(YFLAGS)",
387 "LEX.l", "$(LEX) $(LFLAGS)",
388 "COMPILE.for", "$(FC) $(FFLAGS) $(TARGET_ARCH)",
389 "COMPILE.pas", "$(PC) $(PFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
390 "COMPILE.mar", "$(MACRO) $(MACROFLAGS)",
391 "COMPILE.s", "$(AS) $(ASFLAGS) $(TARGET_MACH)",
392 "LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
394 "MV", "rename/new_version",
405 "CXX", "gpp", /* g++ is an invalid name on MSDOS */
408 # endif /* __MSDOS__ */
416 /* This expands to $(CO) $(COFLAGS) $< $@ if $@ does not exist,
417 and to the empty string if $@ does exist. */
418 "CHECKOUT,v", "+$(if $(wildcard $@),,$(CO) $(COFLAGS) $< $@)",
425 "CF77PP", "/lib/cpp",
429 #else /* Not CRAY. */
437 #endif /* __convex__ */
439 /* System V uses these, so explicit rules using them should work.
440 However, there is no way to make implicit rules use them and FC. */
442 "F77FLAGS", "$(FFLAGS)",
466 "YACC", "yacc", /* Or "bison -y" */
468 "MAKEINFO", "makeinfo",
470 "TEXI2DVI", "texi2dvi",
474 "CTANGLE", "ctangle",
478 "LINK.o", "$(CC) $(LDFLAGS) $(TARGET_ARCH)",
479 "COMPILE.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
480 "LINK.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
481 "COMPILE.m", "$(OBJC) $(OBJCFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
482 "LINK.m", "$(OBJC) $(OBJCFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
483 "COMPILE.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
484 "COMPILE.C", "$(COMPILE.cc)",
485 "COMPILE.cpp", "$(COMPILE.cc)",
486 "LINK.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
487 "LINK.C", "$(LINK.cc)",
488 "LINK.cpp", "$(LINK.cc)",
489 "YACC.y", "$(YACC) $(YFLAGS)",
490 "LEX.l", "$(LEX) $(LFLAGS) -t",
491 "YACC.m", "$(YACC) $(YFLAGS)",
492 "LEX.m", "$(LEX) $(LFLAGS) -t",
493 "COMPILE.f", "$(FC) $(FFLAGS) $(TARGET_ARCH) -c",
494 "LINK.f", "$(FC) $(FFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
495 "COMPILE.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
496 "LINK.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
497 "COMPILE.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -c",
498 "LINK.r", "$(FC) $(FFLAGS) $(RFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
499 "COMPILE.def", "$(M2C) $(M2FLAGS) $(DEFFLAGS) $(TARGET_ARCH)",
500 "COMPILE.mod", "$(M2C) $(M2FLAGS) $(MODFLAGS) $(TARGET_ARCH)",
501 "COMPILE.p", "$(PC) $(PFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
502 "LINK.p", "$(PC) $(PFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
503 "LINK.s", "$(CC) $(ASFLAGS) $(LDFLAGS) $(TARGET_MACH)",
504 "COMPILE.s", "$(AS) $(ASFLAGS) $(TARGET_MACH)",
505 "LINK.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_MACH)",
506 "COMPILE.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c",
507 "PREPROCESS.S", "$(CC) -E $(CPPFLAGS)",
508 "PREPROCESS.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -F",
509 "PREPROCESS.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -F",
510 "LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
512 #ifndef NO_MINUS_C_MINUS_O
513 "OUTPUT_OPTION", "-o $@",
516 #ifdef SCCS_GET_MINUS_G
517 "SCCS_OUTPUT_OPTION", "-G$@",
521 ".LIBPATTERNS", "%.lib",
522 #elif defined(__MSDOS__)
523 ".LIBPATTERNS", "lib%.a $(DJDIR)/lib/lib%.a",
524 #elif defined(__APPLE__)
525 ".LIBPATTERNS", "lib%.dylib lib%.a",
527 ".LIBPATTERNS", "lib%.so lib%.a",
531 /* Make this assignment to avoid undefined variable warnings. */
536 /* Set up the default .SUFFIXES list. */
539 set_default_suffixes (void)
541 suffix_file = enter_file (strcache_add (".SUFFIXES"));
542 suffix_file->builtin = 1;
544 if (no_builtin_rules_flag)
545 define_variable_cname ("SUFFIXES", "", o_default, 0);
549 char *p = default_suffixes;
550 suffix_file->deps = enter_prereqs (PARSE_SIMPLE_SEQ (&p, struct dep),
552 for (d = suffix_file->deps; d; d = d->next)
553 d->file->builtin = 1;
555 define_variable_cname ("SUFFIXES", default_suffixes, o_default, 0);
559 /* Enter the default suffix rules as file rules. This used to be done in
560 install_default_implicit_rules, but that loses because we want the
561 suffix rules installed before reading makefiles, and the pattern rules
565 install_default_suffix_rules (void)
569 if (no_builtin_rules_flag)
572 for (s = default_suffix_rules; *s != 0; s += 2)
574 struct file *f = enter_file (strcache_add (s[0]));
575 /* This function should run before any makefile is parsed. */
576 assert (f->cmds == 0);
577 f->cmds = xmalloc (sizeof (struct commands));
578 f->cmds->fileinfo.filenm = 0;
579 f->cmds->commands = s[1];
580 f->cmds->command_lines = 0;
581 f->cmds->recipe_prefix = RECIPEPREFIX_DEFAULT;
587 /* Install the default pattern rules. */
590 install_default_implicit_rules (void)
594 if (no_builtin_rules_flag)
597 for (p = default_pattern_rules; p->target != 0; ++p)
598 install_pattern_rule (p, 0);
600 for (p = default_terminal_rules; p->target != 0; ++p)
601 install_pattern_rule (p, 1);
605 define_default_variables (void)
609 if (no_builtin_variables_flag)
612 for (s = default_variables; *s != 0; s += 2)
613 define_variable (s[0], strlen (s[0]), s[1], o_default, 1);
617 undefine_default_variables (void)
621 for (s = default_variables; *s != 0; s += 2)
622 undefine_variable_global (s[0], strlen (s[0]), o_default);