make-dfsg/default.c

404 lines
10 KiB
C
Raw Normal View History

1992-01-11 11:37:36 +00:00
/* Data base of default implicit rules for GNU Make.
Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
1992-01-11 11:37:36 +00:00
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Make is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Make; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "make.h"
#include "rule.h"
#include "dep.h"
#include "file.h"
#include "commands.h"
#include "variable.h"
/* Define GCC_IS_NATIVE if gcc is the native development environment on
your system (gcc/bison/flex vs cc/yacc/lex). */
#ifdef __MSDOS__
#define GCC_IS_NATIVE
#endif
1992-01-11 11:37:36 +00:00
/* This is the default list of suffixes for suffix rules.
`.s' must come last, so that a `.o' file will be made from
a `.c' or `.p' or ... file rather than from a .s file. */
static char default_suffixes[]
= ".out .a .ln .o .c .cc .C .p .f .F .r .y .l .s .S \
1993-04-12 19:58:26 +00:00
.mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \
1993-06-25 18:59:05 +00:00
.w .ch .web .sh .elc .el";
1992-01-11 11:37:36 +00:00
static struct pspec default_pattern_rules[] =
{
1992-11-23 20:48:49 +00:00
{ "(%)", "%",
"$(AR) $(ARFLAGS) $@ $<" },
1992-01-11 11:37:36 +00:00
/* The X.out rules are only in BSD's default set because
BSD Make has no null-suffix rules, so `foo.out' and
`foo' are the same thing. */
1992-11-23 20:48:49 +00:00
{ "%.out", "%",
"@rm -f $@ \n cp $< $@" },
1992-01-11 11:37:36 +00:00
1993-06-25 18:59:05 +00:00
/* Syntax is "ctangle foo.w foo.ch foo.c". */
{ "%.c", "%.w %.ch",
"$(CTANGLE) $^ $@" },
{ "%.tex", "%.w %.ch",
"$(CWEAVE) $^ $@" },
1992-11-23 20:48:49 +00:00
{ 0, 0, 0 }
1992-01-11 11:37:36 +00:00
};
static struct pspec default_terminal_rules[] =
{
1992-07-30 19:53:39 +00:00
/* RCS. */
1992-11-23 20:48:49 +00:00
{ "%", "%,v",
"+$(CHECKOUT,v)" },
{ "%", "RCS/%,v",
"+$(CHECKOUT,v)" },
1992-01-11 11:37:36 +00:00
/* SCCS. */
1992-11-23 20:48:49 +00:00
{ "%", "s.%",
"$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" },
1992-11-23 20:48:49 +00:00
{ "%", "SCCS/s.%",
"$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" },
1992-01-11 11:37:36 +00:00
1992-11-23 20:48:49 +00:00
{ 0, 0, 0 }
1992-01-11 11:37:36 +00:00
};
static char *default_suffix_rules[] =
{
".o",
"$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@",
".s",
"$(LINK.s) $^ $(LOADLIBES) $(LDLIBS) -o $@",
".S",
"$(LINK.S) $^ $(LOADLIBES) $(LDLIBS) -o $@",
".c",
"$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@",
".cc",
"$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@",
".C",
"$(LINK.C) $^ $(LOADLIBES) $(LDLIBS) -o $@",
".f",
"$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@",
".p",
"$(LINK.p) $^ $(LOADLIBES) $(LDLIBS) -o $@",
".F",
"$(LINK.F) $^ $(LOADLIBES) $(LDLIBS) -o $@",
".r",
"$(LINK.r) $^ $(LOADLIBES) $(LDLIBS) -o $@",
".mod",
"$(COMPILE.mod) -o $@ -e $@ $^",
".def.sym",
"$(COMPILE.def) -o $@ $<",
".sh",
"cat $< >$@ \n chmod a+x $@",
".s.o",
#if !defined(M_XENIX) || defined(__GNUC__)
"$(COMPILE.s) -o $@ $<",
#else /* Xenix. */
"$(COMPILE.s) -o$@ $<",
#endif /* Not Xenix. */
".S.o",
#if !defined(M_XENIX) || defined(__GNUC__)
"$(COMPILE.S) -o $@ $<",
#else /* Xenix. */
"$(COMPILE.S) -o$@ $<",
#endif /* Not Xenix. */
".c.o",
"$(COMPILE.c) $< $(OUTPUT_OPTION)",
".cc.o",
"$(COMPILE.cc) $< $(OUTPUT_OPTION)",
".C.o",
"$(COMPILE.C) $< $(OUTPUT_OPTION)",
".f.o",
"$(COMPILE.f) $< $(OUTPUT_OPTION)",
".p.o",
"$(COMPILE.p) $< $(OUTPUT_OPTION)",
".F.o",
"$(COMPILE.F) $< $(OUTPUT_OPTION)",
".r.o",
"$(COMPILE.r) $< $(OUTPUT_OPTION)",
".mod.o",
"$(COMPILE.mod) -o $@ $<",
".c.ln",
"$(LINT.c) -C$* $<",
".y.ln",
#ifndef __MSDOS__
1992-01-11 11:37:36 +00:00
"$(YACC.y) $< \n $(LINT.c) -C$* y.tab.c \n $(RM) y.tab.c",
#else
"$(YACC.y) $< \n $(LINT.c) -C$* y_tab.c \n $(RM) y_tab.c",
#endif
1992-01-11 11:37:36 +00:00
".l.ln",
1992-07-30 19:53:39 +00:00
"@$(RM) $*.c\n $(LEX.l) $< > $*.c\n$(LINT.c) -i $*.c -o $@\n $(RM) $*.c",
1992-01-11 11:37:36 +00:00
".y.c",
#ifndef __MSDOS__
1992-01-11 11:37:36 +00:00
"$(YACC.y) $< \n mv -f y.tab.c $@",
#else
"$(YACC.y) $< \n mv -f y_tab.c $@",
#endif
1992-01-11 11:37:36 +00:00
".l.c",
"@$(RM) $@ \n $(LEX.l) $< > $@",
".F.f",
"$(PREPROCESS.F) $< $(OUTPUT_OPTION)",
".r.f",
"$(PREPROCESS.r) $< $(OUTPUT_OPTION)",
/* This might actually make lex.yy.c if there's no %R%
directive in $*.l, but in that case why were you
trying to make $*.r anyway? */
".l.r",
"$(LEX.l) $< > $@ \n mv -f lex.yy.r $@",
".S.s",
"$(PREPROCESS.S) $< > $@",
".texinfo.info",
1994-01-17 22:05:22 +00:00
"$(MAKEINFO) $(MAKEINFO_FLAGS) $< -o $@",
1992-01-11 11:37:36 +00:00
".texi.info",
1994-01-17 22:05:22 +00:00
"$(MAKEINFO) $(MAKEINFO_FLAGS) $< -o $@",
1992-01-11 11:37:36 +00:00
1993-04-12 19:58:26 +00:00
".txinfo.info",
1994-01-17 22:05:22 +00:00
"$(MAKEINFO) $(MAKEINFO_FLAGS) $< -o $@",
1993-04-12 19:58:26 +00:00
1992-01-11 11:37:36 +00:00
".tex.dvi",
"$(TEX) $<",
".texinfo.dvi",
1994-01-17 22:05:22 +00:00
"$(TEXI2DVI) $(TEXI2DVI_FLAGS) $<",
1992-01-11 11:37:36 +00:00
".texi.dvi",
1994-01-17 22:05:22 +00:00
"$(TEXI2DVI) $(TEXI2DVI_FLAGS) $<",
1992-01-11 11:37:36 +00:00
1993-04-12 19:58:26 +00:00
".txinfo.dvi",
1994-01-17 22:05:22 +00:00
"$(TEXI2DVI) $(TEXI2DVI_FLAGS) $<",
1993-04-12 19:58:26 +00:00
1993-06-21 21:56:36 +00:00
".w.c",
1993-06-25 18:59:05 +00:00
"$(CTANGLE) $< - $@", /* The `-' says there is no `.ch' file. */
1992-01-11 11:37:36 +00:00
".web.p",
"$(TANGLE) $<",
1993-06-21 21:56:36 +00:00
".w.tex",
1993-06-25 18:59:05 +00:00
"$(CWEAVE) $< - $@", /* The `-' says there is no `.ch' file. */
1992-01-11 11:37:36 +00:00
".web.tex",
"$(WEAVE) $<",
1992-07-30 19:53:39 +00:00
0, 0,
};
1992-01-11 11:37:36 +00:00
static char *default_variables[] =
{
"AR", "ar",
"ARFLAGS", "rv",
"AS", "as",
#ifdef GCC_IS_NATIVE
"CC", "gcc",
1994-09-07 00:15:23 +00:00
"CXX", "gcc",
#else
1992-01-11 11:37:36 +00:00
"CC", "cc",
1992-12-09 22:09:42 +00:00
"CXX", "g++",
#endif
1992-07-30 19:53:39 +00:00
/* This expands to $(CO) $(COFLAGS) $< $@ if $@ does not exist,
and to the empty string if $@ does exist. */
"CHECKOUT,v",
"$(patsubst $@-noexist,$(CO) $(COFLAGS) $< $@,\
$(filter-out $@,$(firstword $(wildcard $@) $@-noexist)))",
1992-01-11 11:37:36 +00:00
"CO", "co",
"CPP", "$(CC) -E",
1992-06-03 01:13:51 +00:00
#ifdef CRAY
"CF77PPFLAGS", "-P",
"CF77PP", "/lib/cpp",
"CFT", "cft77",
"CF", "cf77",
"FC", "$(CF)",
#else /* Not CRAY. */
1992-01-11 11:37:36 +00:00
#ifdef _IBMR2
"FC", "xlf",
1992-12-22 22:31:16 +00:00
#else
#ifdef __convex__
"FC", "fc",
1992-01-11 11:37:36 +00:00
#else
"FC", "f77",
1992-12-22 22:31:16 +00:00
#endif /* __convex__ */
#endif /* _IBMR2 */
1992-01-11 11:37:36 +00:00
/* System V uses these, so explicit rules using them should work.
However, there is no way to make implicit rules use them and FC. */
"F77", "$(FC)",
"F77FLAGS", "$(FFLAGS)",
1992-06-03 01:13:51 +00:00
#endif /* Cray. */
1993-04-16 00:54:40 +00:00
"GET", SCCS_GET,
1992-01-11 11:37:36 +00:00
"LD", "ld",
#ifdef GCC_IS_NATIVE
"LEX", "flex",
#else
1992-01-11 11:37:36 +00:00
"LEX", "lex",
#endif
1992-01-11 11:37:36 +00:00
"LINT", "lint",
"M2C", "m2c",
#ifdef pyr
"PC", "pascal",
1992-06-03 01:13:51 +00:00
#else
#ifdef CRAY
"PC", "PASCAL",
"SEGLDR", "segldr",
1992-01-11 11:37:36 +00:00
#else
"PC", "pc",
1992-06-03 01:13:51 +00:00
#endif /* CRAY. */
#endif /* pyr. */
#ifdef GCC_IS_NATIVE
"YACC", "bison -y",
#else
1992-01-11 11:37:36 +00:00
"YACC", "yacc", /* Or "bison -y" */
#endif
1992-01-11 11:37:36 +00:00
"MAKEINFO", "makeinfo",
"TEX", "tex",
"TEXI2DVI", "texi2dvi",
"WEAVE", "weave",
"CWEAVE", "cweave",
"TANGLE", "tangle",
"CTANGLE", "ctangle",
"RM", "rm -f",
"LINK.o", "$(CC) $(LDFLAGS) $(TARGET_ARCH)",
"COMPILE.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
"LINK.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
1992-12-09 22:09:42 +00:00
"COMPILE.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
1992-01-11 11:37:36 +00:00
"COMPILE.C", "$(COMPILE.cc)",
1992-12-09 22:09:42 +00:00
"LINK.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
1992-01-11 11:37:36 +00:00
"LINK.C", "$(LINK.cc)",
"YACC.y", "$(YACC) $(YFLAGS)",
"LEX.l", "$(LEX) $(LFLAGS) -t",
"COMPILE.f", "$(FC) $(FFLAGS) $(TARGET_ARCH) -c",
"LINK.f", "$(FC) $(FFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
"COMPILE.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
"LINK.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
"COMPILE.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -c",
"LINK.r", "$(FC) $(FFLAGS) $(RFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
"COMPILE.def", "$(M2C) $(M2FLAGS) $(DEFFLAGS) $(TARGET_ARCH)",
"COMPILE.mod", "$(M2C) $(M2FLAGS) $(MODFLAGS) $(TARGET_ARCH)",
"COMPILE.p", "$(PC) $(PFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
"LINK.p", "$(PC) $(PFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
"LINK.s", "$(CC) $(ASFLAGS) $(LDFLAGS) $(TARGET_MACH)",
"COMPILE.s", "$(AS) $(ASFLAGS) $(TARGET_MACH)",
"LINK.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_MACH)",
"COMPILE.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c",
#if !defined(M_XENIX) || defined(__GNUC__)
"PREPROCESS.S", "$(CC) -E $(CPPFLAGS)",
#else /* Xenix. */
"PREPROCESS.S", "$(CC) -EP $(CPPFLAGS)",
#endif /* Not Xenix. */
"PREPROCESS.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -F",
"PREPROCESS.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -F",
"LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
#ifndef NO_MINUS_C_MINUS_O
#if !defined(M_XENIX) || defined(__GNUC__)
"OUTPUT_OPTION", "-o $@",
#else /* Xenix. */
"OUTPUT_OPTION", "-Fo$@",
#endif /* Not Xenix. */
#endif
1993-12-14 21:59:57 +00:00
#ifdef SCCS_GET_MINUS_G
"SCCS_OUTPUT_OPTION", "-G$@",
#endif
1992-01-11 11:37:36 +00:00
0, 0
};
/* Set up the default .SUFFIXES list. */
void
set_default_suffixes ()
{
suffix_file = enter_file (".SUFFIXES");
if (no_builtin_rules_flag)
(void) define_variable ("SUFFIXES", 8, "", o_default, 0);
else
{
char *p = default_suffixes;
suffix_file->deps = (struct dep *)
1993-06-09 23:16:28 +00:00
multi_glob (parse_file_seq (&p, '\0', sizeof (struct dep), 1),
sizeof (struct dep));
1992-01-11 11:37:36 +00:00
(void) define_variable ("SUFFIXES", 8, default_suffixes, o_default, 0);
}
}
1993-10-14 22:25:17 +00:00
/* Enter the default suffix rules as file rules. This used to be done in
install_default_implicit_rules, but that loses because we want the
suffix rules installed before reading makefiles, and thee pattern rules
installed after. */
1992-01-11 11:37:36 +00:00
void
1993-10-14 22:25:17 +00:00
install_default_suffix_rules ()
1992-01-11 11:37:36 +00:00
{
register char **s;
if (no_builtin_rules_flag)
return;
1993-10-14 22:25:17 +00:00
for (s = default_suffix_rules; *s != 0; s += 2)
1992-01-11 11:37:36 +00:00
{
register struct file *f = enter_file (s[0]);
/* Don't clobber cmds given in a makefile if there were any. */
if (f->cmds == 0)
{
f->cmds = (struct commands *) xmalloc (sizeof (struct commands));
f->cmds->filename = 0;
f->cmds->commands = s[1];
f->cmds->command_lines = 0;
}
}
}
1993-10-14 22:25:17 +00:00
/* Install the default pattern rules. */
void
install_default_implicit_rules ()
{
register struct pspec *p;
if (no_builtin_rules_flag)
return;
for (p = default_pattern_rules; p->target != 0; ++p)
install_pattern_rule (p, 0);
for (p = default_terminal_rules; p->target != 0; ++p)
install_pattern_rule (p, 1);
}
1992-01-11 11:37:36 +00:00
void
define_default_variables ()
{
register char **s;
for (s = default_variables; *s != 0; s += 2)
(void) define_variable (s[0], strlen (s[0]), s[1], o_default, 1);
}