home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / bbs / gnu / make-3.70-src.lha / src / amiga / make-3.70 / default.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-15  |  9.7 KB  |  377 lines

  1. /* Data base of default implicit rules for GNU Make.
  2. Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  3. This file is part of GNU Make.
  4.  
  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.
  9.  
  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.
  14.  
  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.  */
  18.  
  19. #include "make.h"
  20. #include "rule.h"
  21. #include "dep.h"
  22. #include "file.h"
  23. #include "commands.h"
  24. #include "variable.h"
  25.  
  26.  
  27. /* This is the default list of suffixes for suffix rules.
  28.    `.s' must come last, so that a `.o' file will be made from
  29.    a `.c' or `.p' or ... file rather than from a .s file.  */
  30.  
  31. static char default_suffixes[]
  32.   = ".out .a .ln .o .c .cc .C .p .f .F .r .y .l .s .S \
  33. .mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \
  34. .w .ch .web .sh .elc .el";
  35.  
  36. static struct pspec default_pattern_rules[] =
  37.   {
  38.     { "(%)", "%",
  39.     "$(AR) $(ARFLAGS) $@ $<" },
  40.  
  41.     /* The X.out rules are only in BSD's default set because
  42.        BSD Make has no null-suffix rules, so `foo.out' and
  43.        `foo' are the same thing.  */
  44.     { "%.out", "%",
  45.     "@rm -f $@ \n cp $< $@" },
  46.  
  47.     /* Syntax is "ctangle foo.w foo.ch foo.c".  */
  48.     { "%.c", "%.w %.ch",
  49.     "$(CTANGLE) $^ $@" },
  50.     { "%.tex", "%.w %.ch",
  51.     "$(CWEAVE) $^ $@" },
  52.  
  53.     { 0, 0, 0 }
  54.   };
  55.  
  56. static struct pspec default_terminal_rules[] =
  57.   {
  58.     /* RCS.  */
  59.     { "%", "%,v",
  60.     "+$(CHECKOUT,v)" },
  61.     { "%", "RCS/%,v",
  62.     "+$(CHECKOUT,v)" },
  63.  
  64.     /* SCCS.  */
  65.     { "%", "s.%",
  66.     "$(GET) $(GFLAGS) $< $(SCCS_OUTPUT_OPTION)" },
  67.     { "%", "SCCS/s.%",
  68.     "$(GET) $(GFLAGS) $< $(SCCS_OUTPUT_OPTION)" },
  69.  
  70.     { 0, 0, 0 }
  71.   };
  72.  
  73. static char *default_suffix_rules[] =
  74.   {
  75.     ".o",
  76.     "$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  77.     ".s",
  78.     "$(LINK.s) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  79.     ".S",
  80.     "$(LINK.S) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  81.     ".c",
  82.     "$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  83.     ".cc",
  84.     "$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  85.     ".C",
  86.     "$(LINK.C) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  87.     ".f",
  88.     "$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  89.     ".p",
  90.     "$(LINK.p) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  91.     ".F",
  92.     "$(LINK.F) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  93.     ".r",
  94.     "$(LINK.r) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  95.     ".mod",
  96.     "$(COMPILE.mod) -o $@ -e $@ $^",
  97.  
  98.     ".def.sym", 
  99.     "$(COMPILE.def) -o $@ $<",
  100.  
  101.     ".sh",
  102.     "cat $< >$@ \n chmod a+x $@",
  103.  
  104.     ".s.o",
  105. #if !defined(M_XENIX) || defined(__GNUC__)
  106.     "$(COMPILE.s) -o $@ $<",
  107. #else    /* Xenix.  */
  108.     "$(COMPILE.s) -o$@ $<",
  109. #endif    /* Not Xenix.  */
  110.     ".S.o",
  111. #if !defined(M_XENIX) || defined(__GNUC__)
  112.     "$(COMPILE.S) -o $@ $<",
  113. #else    /* Xenix.  */
  114.     "$(COMPILE.S) -o$@ $<",
  115. #endif    /* Not Xenix.  */
  116.     ".c.o",
  117.     "$(COMPILE.c) $< $(OUTPUT_OPTION)",
  118.     ".cc.o",
  119.     "$(COMPILE.cc) $< $(OUTPUT_OPTION)",
  120.     ".C.o",
  121.     "$(COMPILE.C) $< $(OUTPUT_OPTION)",
  122.     ".f.o",
  123.     "$(COMPILE.f) $< $(OUTPUT_OPTION)",
  124.     ".p.o",
  125.     "$(COMPILE.p) $< $(OUTPUT_OPTION)",
  126.     ".F.o",
  127.     "$(COMPILE.F) $< $(OUTPUT_OPTION)",
  128.     ".r.o",
  129.     "$(COMPILE.r) $< $(OUTPUT_OPTION)",
  130.     ".mod.o",
  131.     "$(COMPILE.mod) -o $@ $<",
  132.  
  133.     ".c.ln",
  134.     "$(LINT.c) -C$* $<",
  135.     ".y.ln",
  136.     "$(YACC.y) $< \n $(LINT.c) -C$* y.tab.c \n $(RM) y.tab.c",
  137.     ".l.ln",
  138.     "@$(RM) $*.c\n $(LEX.l) $< > $*.c\n$(LINT.c) -i $*.c -o $@\n $(RM) $*.c",
  139.  
  140.     ".y.c",
  141.     "$(YACC.y) $< \n mv -f y.tab.c $@",
  142.     ".l.c",
  143.     "@$(RM) $@ \n $(LEX.l) $< > $@",
  144.  
  145.     ".F.f",
  146.     "$(PREPROCESS.F) $< $(OUTPUT_OPTION)",
  147.     ".r.f",
  148.     "$(PREPROCESS.r) $< $(OUTPUT_OPTION)",
  149.  
  150.     /* This might actually make lex.yy.c if there's no %R%
  151.        directive in $*.l, but in that case why were you
  152.        trying to make $*.r anyway?  */
  153.     ".l.r",
  154.     "$(LEX.l) $< > $@ \n mv -f lex.yy.r $@",
  155.  
  156.     ".S.s",
  157.     "$(PREPROCESS.S) $< > $@",
  158.  
  159.     ".texinfo.info",
  160.     "$(MAKEINFO) $< -o $@",
  161.  
  162.     ".texi.info",
  163.     "$(MAKEINFO) $< -o $@",
  164.  
  165.     ".txinfo.info",
  166.     "$(MAKEINFO) $< -o $@",
  167.  
  168.     ".tex.dvi",
  169.     "$(TEX) $<",
  170.  
  171.     ".texinfo.dvi",
  172.     "$(TEXI2DVI) $<",
  173.  
  174.     ".texi.dvi",
  175.     "$(TEXI2DVI) $<",
  176.  
  177.     ".txinfo.dvi",
  178.     "$(TEXI2DVI) $<",
  179.  
  180.     ".w.c",
  181.     "$(CTANGLE) $< - $@",    /* The `-' says there is no `.ch' file.  */
  182.  
  183.     ".web.p",
  184.     "$(TANGLE) $<",
  185.  
  186.     ".w.tex",
  187.     "$(CWEAVE) $< - $@",    /* The `-' says there is no `.ch' file.  */
  188.  
  189.     ".web.tex",
  190.     "$(WEAVE) $<",
  191.  
  192.     0, 0,
  193.   };
  194.  
  195. static char *default_variables[] =
  196.   {
  197.     "AR", "ar",
  198.     "ARFLAGS", "rv",
  199.     "AS", "as",
  200.     "CC", "cc",
  201.     "CXX", "g++",
  202.  
  203.     /* This expands to $(CO) $(COFLAGS) $< $@ if $@ does not exist,
  204.        and to the empty string if $@ does exist.  */
  205.     "CHECKOUT,v",
  206.     "$(patsubst $@-noexist,$(CO) $(COFLAGS) $< $@,\
  207.         $(filter-out $@,$(firstword $(wildcard $@) $@-noexist)))",
  208.  
  209.     "CO", "co",
  210.     "CPP", "$(CC) -E",
  211. #ifdef    CRAY
  212.     "CF77PPFLAGS", "-P",
  213.     "CF77PP", "/lib/cpp",
  214.     "CFT", "cft77",
  215.     "CF", "cf77",
  216.     "FC", "$(CF)",
  217. #else    /* Not CRAY.  */
  218. #ifdef    _IBMR2
  219.     "FC", "xlf",
  220. #else
  221. #ifdef    __convex__
  222.     "FC", "fc",
  223. #else
  224.     "FC", "f77",
  225. #endif /* __convex__ */
  226. #endif /* _IBMR2 */
  227.     /* System V uses these, so explicit rules using them should work.
  228.        However, there is no way to make implicit rules use them and FC.  */
  229.     "F77", "$(FC)",
  230.     "F77FLAGS", "$(FFLAGS)",
  231. #endif    /* Cray.  */
  232.     "GET", SCCS_GET,
  233.     "LD", "ld",
  234.     "LEX", "lex",
  235.     "LINT", "lint",
  236.     "M2C", "m2c",
  237. #ifdef    pyr
  238.     "PC", "pascal",
  239. #else
  240. #ifdef    CRAY
  241.     "PC", "PASCAL",
  242.     "SEGLDR", "segldr",
  243. #else
  244.     "PC", "pc",
  245. #endif    /* CRAY.  */
  246. #endif    /* pyr.  */
  247.     "YACC", "yacc",    /* Or "bison -y"  */
  248.     "MAKEINFO", "makeinfo",
  249.     "TEX", "tex",
  250.     "TEXI2DVI", "texi2dvi",
  251.     "WEAVE", "weave",
  252.     "CWEAVE", "cweave",
  253.     "TANGLE", "tangle",
  254.     "CTANGLE", "ctangle",
  255.  
  256.     "RM", "rm -f",
  257.  
  258.     "LINK.o", "$(CC) $(LDFLAGS) $(TARGET_ARCH)",
  259.     "COMPILE.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
  260.     "LINK.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
  261.     "COMPILE.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
  262.     "COMPILE.C", "$(COMPILE.cc)",
  263.     "LINK.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
  264.     "LINK.C", "$(LINK.cc)",
  265.     "YACC.y", "$(YACC) $(YFLAGS)",
  266.     "LEX.l", "$(LEX) $(LFLAGS) -t",
  267.     "COMPILE.f", "$(FC) $(FFLAGS) $(TARGET_ARCH) -c",
  268.     "LINK.f", "$(FC) $(FFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
  269.     "COMPILE.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
  270.     "LINK.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
  271.     "COMPILE.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -c",
  272.     "LINK.r", "$(FC) $(FFLAGS) $(RFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
  273.     "COMPILE.def", "$(M2C) $(M2FLAGS) $(DEFFLAGS) $(TARGET_ARCH)",
  274.     "COMPILE.mod", "$(M2C) $(M2FLAGS) $(MODFLAGS) $(TARGET_ARCH)",
  275.     "COMPILE.p", "$(PC) $(PFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
  276.     "LINK.p", "$(PC) $(PFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
  277.     "LINK.s", "$(CC) $(ASFLAGS) $(LDFLAGS) $(TARGET_MACH)",
  278.     "COMPILE.s", "$(AS) $(ASFLAGS) $(TARGET_MACH)",
  279.     "LINK.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_MACH)",
  280.     "COMPILE.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c",
  281. #if !defined(M_XENIX) || defined(__GNUC__)
  282.     "PREPROCESS.S", "$(CC) -E $(CPPFLAGS)",
  283. #else    /* Xenix.  */
  284.     "PREPROCESS.S", "$(CC) -EP $(CPPFLAGS)",
  285. #endif    /* Not Xenix.  */
  286.     "PREPROCESS.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -F",
  287.     "PREPROCESS.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -F",
  288.     "LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
  289.  
  290. #ifndef    NO_MINUS_C_MINUS_O
  291. #if !defined(M_XENIX) || defined(__GNUC__)
  292.     "OUTPUT_OPTION", "-o $@",
  293. #else    /* Xenix.  */
  294.     "OUTPUT_OPTION", "-Fo$@",
  295. #endif    /* Not Xenix.  */
  296. #endif
  297.  
  298. #ifdef    SCCS_GET_MINUS_G
  299.     "SCCS_OUTPUT_OPTION", "-G$@",
  300. #endif
  301.  
  302.     0, 0
  303.   };
  304.  
  305. /* Set up the default .SUFFIXES list.  */
  306.  
  307. void
  308. set_default_suffixes ()
  309. {
  310.   suffix_file = enter_file (".SUFFIXES");
  311.  
  312.   if (no_builtin_rules_flag)
  313.     (void) define_variable ("SUFFIXES", 8, "", o_default, 0);
  314.   else
  315.     {
  316.       char *p = default_suffixes;
  317.       suffix_file->deps = (struct dep *)
  318.     multi_glob (parse_file_seq (&p, '\0', sizeof (struct dep), 1),
  319.             sizeof (struct dep));
  320.       (void) define_variable ("SUFFIXES", 8, default_suffixes, o_default, 0);
  321.     }
  322. }
  323.  
  324. /* Enter the default suffix rules as file rules.  This used to be done in
  325.    install_default_implicit_rules, but that loses because we want the
  326.    suffix rules installed before reading makefiles, and thee pattern rules
  327.    installed after.  */
  328.  
  329. void
  330. install_default_suffix_rules ()
  331. {
  332.   register char **s;
  333.   
  334.   if (no_builtin_rules_flag)
  335.     return;
  336.  
  337.  for (s = default_suffix_rules; *s != 0; s += 2)
  338.     {
  339.       register struct file *f = enter_file (s[0]);
  340.       /* Don't clobber cmds given in a makefile if there were any.  */
  341.       if (f->cmds == 0)
  342.     {
  343.       f->cmds = (struct commands *) xmalloc (sizeof (struct commands));
  344.       f->cmds->filename = 0;
  345.       f->cmds->commands = s[1];
  346.       f->cmds->command_lines = 0;
  347.     }
  348.     }
  349. }
  350.  
  351.  
  352. /* Install the default pattern rules.  */
  353.  
  354. void
  355. install_default_implicit_rules ()
  356. {
  357.   register struct pspec *p;
  358.   
  359.   if (no_builtin_rules_flag)
  360.     return;
  361.  
  362.   for (p = default_pattern_rules; p->target != 0; ++p)
  363.     install_pattern_rule (p, 0);
  364.  
  365.   for (p = default_terminal_rules; p->target != 0; ++p)
  366.     install_pattern_rule (p, 1);
  367. }
  368.  
  369. void
  370. define_default_variables ()
  371. {
  372.   register char **s;
  373.  
  374.   for (s = default_variables; *s != 0; s += 2)
  375.     (void) define_variable (s[0], strlen (s[0]), s[1], o_default, 1);
  376. }
  377.