home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / MISC / GNU / MAK358AS.ZIP / DEFAULT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-22  |  11.5 KB  |  451 lines

  1. /* Data base of default implicit rules for GNU Make.
  2. Copyright (C) 1988, 1989 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 1, 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. /*
  20.  * MS-DOS port (c) 1990 by Thorsten Ohl <ohl@gnu.ai.mit.edu>
  21.  *
  22.  * To this port, the same copying conditions apply as to the
  23.  * original release.
  24.  *
  25.  * IMPORTANT:
  26.  * This file is not identical to the original GNU release!
  27.  * You should have received this code as patch to the official
  28.  * GNU release.
  29.  *
  30.  * MORE IMPORTANT:
  31.  * This port comes with ABSOLUTELY NO WARRANTY.
  32.  *
  33.  * $Header: e:/gnu/make/RCS/default.c'v 3.58.0.3 90/07/18 10:42:57 tho Exp $
  34.  */
  35.  
  36. #include "make.h"
  37. #include "rule.h"
  38. #include "dep.h"
  39. #include "file.h"
  40. #include "commands.h"
  41. #include "variable.h"
  42.  
  43.  
  44. #if defined(MSDOS) && !defined(STRICT)
  45.  
  46. static char default_suffixes[] = \
  47.   ".com .exe .obj .c .pas .for .r .y .l .asm .h .dvi .tex .web";
  48.  
  49. static struct pspec default_pattern_rules[] =
  50. {
  51.   "(%)", "%",
  52.   "$(ZIP) $(ZFLAGS) $@ $<",
  53.  
  54.   0, 0, 0
  55. };
  56.  
  57. static struct pspec default_terminal_rules[] =
  58. {
  59.   /* RCS  */
  60.   "%", "%'v",
  61.   "$(CO) $(COFLAGS) $@",
  62.   "%", "RCS/%'v",
  63.   "$(CO) $(COFLAGS) $@",
  64.  
  65.   "%.asm", "%.a'v",        /* kludges until we convert */
  66.   "$(CO) $(COFLAGS) $@",        /* RCS to prefixes ... */
  67.   "%.asm", "RCS/%.a'v",
  68.   "$(CO) $(COFLAGS) $@",
  69.   "%.for", "%.f'v",
  70.   "$(CO) $(COFLAGS) $@",
  71.   "%.for", "RCS/%.f'v",
  72.   "$(CO) $(COFLAGS) $@",
  73.   "%.tex", "%.t'v",
  74.   "$(CO) $(COFLAGS) $@",
  75.   "%.tex", "RCS/%.t'v",
  76.   "$(CO) $(COFLAGS) $@",
  77.   "%.web", "%.w'v",
  78.   "$(CO) $(COFLAGS) $@",
  79.   "%.web", "RCS/%.w'v",
  80.   "$(CO) $(COFLAGS) $@",
  81.  
  82.   /* Backup */
  83.   /* we should add some rules for copying .zip archives to
  84.      disk, but: how to handle the ':' of the drive ? */
  85.  
  86.       0, 0, 0
  87. };
  88.  
  89. static char *default_suffix_rules[] =
  90. {
  91.   ".exe.com",
  92.   "$(EXE2BIN) $< $@",
  93.   ".obj.exe",
  94.   "$(LINK.s) $<;",
  95.  
  96.   ".asm.obj",
  97.   "$(COMPILE.s) $<;",
  98.   ".c.obj",
  99.   "$(COMPILE.c) $<",
  100.   ".for.obj",
  101.   "$(COMPILE.f) $<",
  102.   ".pas.exe",
  103.   "$(COMPILE.p) $<",
  104.  
  105.   ".y.c",
  106.   "$(YACC.y) $< \n mv -f y_tab.c $@",
  107.   ".l.c",
  108.   "$(LEX.l) $< \n mv -f lexyy.c $@",
  109.  
  110.   ".r.for",
  111.   "$(PREPROCESS.r) < $< > $@",
  112.  
  113.   ".tex.dvi",
  114.   "-$(TEX) $<",
  115.  
  116.   ".web.for",            /* make it smarter about changefiles! */
  117.   "$(FTANGLE) $<",
  118.   ".web.pas",
  119.   "$(TANGLE) $<",
  120.   ".web.c",
  121.   "$(CTANGLE) $<",
  122.   ".web.tex",
  123.   "$(WEAVE) $<",
  124.  
  125.   0
  126.  
  127. };
  128.  
  129.  
  130. static char *default_variables[] =
  131. {
  132.   "AR", "lib",
  133.   "ARFLAGS", "-+",
  134.   "AS", "masm",            /* might want tasm here */
  135.   "CC", "cl",            /* might want tcc here  */
  136.   "CO", "co",
  137.   "CPP", "$(CC) -E",
  138.   "FC", "fl",
  139.   "F77", "$(FC)",
  140.   "F77FLAGS", "$(FFLAGS)",
  141.   "LEX", "flex",
  142.   "LINT", "$(CC) -Zs -W4",
  143.   "LINTFLAGS", "$(CFLAGS)",
  144.   "PC", "tpc",
  145.   "YACC", "bison -y",
  146.   "TEX", "latex",
  147.   "WEAVE", "weave",
  148.   "CWEAVE", "cweave",
  149.   "FWEAVE", "fweave",
  150.   "TANGLE", "tangle",
  151.   "CTANGLE", "ctangle",
  152.   "FTANGLE", "ftangle",
  153.   "RAT4", "ratfor",
  154.   "LINK", "link",            /* might want tlink here */
  155.   "EXE2BIN", "exe2bin",
  156.   "ZIP", "pkzip",
  157.  
  158.   "RM", "rm -f",
  159.  
  160.   "COMPILE.c", "$(CC) $(CFLAGS) $(CPPFLAGS) -c",
  161.   "LINK.s", "$(LINK) $(LDFLAGS)",
  162.   "YACC.y", "$(YACC) $(YFLAGS)",
  163.   "LEX.l", "$(LEX) $(LFLAGS) -t",
  164.   "COMPILE.f", "$(FC) $(FFLAGS) -c",
  165.   "LINK.f", "$(LINK) $(LDFLAGS)",
  166.   "COMPILE.p", "$(PC) $(PFLAGS)",
  167.   "COMPILE.s", "$(AS) $(ASFLAGS)",
  168.   "LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS)",
  169.   "PREPROCESS.r", "$(RAT4) $(RFLAGS)",
  170.  
  171.   0, 0
  172. };
  173.  
  174. #else
  175.  
  176. /* This is the default list of suffixes for suffix rules.
  177.    `.s' must come last, so that a `.o' file will be made from
  178.    a `.c' or `.p' or ... file rather than from a .s file.  */
  179.  
  180. static char default_suffixes[]
  181.   = ".out .a .ln .o .c .cc .p .f .F .r .y .l .s .S \
  182. .mod .sym .def .h .info .dvi .tex .texinfo .cweb .web .sh .elc .el";
  183.  
  184. static struct pspec default_pattern_rules[] =
  185.   {
  186.     "(%)", "%",
  187.     "$(AR) $(ARFLAGS) $@ $<",
  188.  
  189.     /* The X.out rules are only in BSD's default set because
  190.        BSD Make has no null-suffix rules, so `foo.out' and
  191.        `foo' are the same thing.  */
  192.     "%.out", "%",
  193.     "@rm -f $@ \n cp $< $@",
  194.  
  195.     0, 0, 0
  196.   };
  197.  
  198. static struct pspec default_terminal_rules[] =
  199.   {
  200.     /* RCS.  */
  201.     "%", "%,v",
  202.     "test -f $@ || $(CO) $(COFLAGS) $< $@",
  203.     "%", "RCS/%,v",
  204.     "test -f $@ || $(CO) $(COFLAGS) $< $@",
  205.  
  206.     /* SCCS.  */
  207.     "%", "s.%",
  208.     "$(GET) $(GFLAGS) $<",
  209.     "%", "SCCS/s.%",
  210.     "$(GET) $(GFLAGS) $<",
  211.  
  212.     0, 0, 0
  213.   };
  214.  
  215. static char *default_suffix_rules[] =
  216.   {
  217.     ".o",
  218.     "$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  219.     ".s",
  220.     "$(LINK.s) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  221.     ".S",
  222.     "$(LINK.S) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  223.     ".c",
  224.     "$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  225.     ".cc",
  226.     "$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  227.     ".f",
  228.     "$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  229.     ".p",
  230.     "$(LINK.p) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  231.     ".F",
  232.     "$(LINK.F) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  233.     ".r",
  234.     "$(LINK.r) $^ $(LOADLIBES) $(LDLIBS) -o $@",
  235.     ".mod",
  236.     "$(COMPILE.mod) -o $@ -e $@ $^",
  237.  
  238.     ".def.sym", 
  239.     "$(COMPILE.def) -o $@ $<",
  240.  
  241.     ".sh",
  242.     "cat $< >$@ \n chmod a+x $@",
  243.  
  244.     ".s.o",
  245. #ifndef    M_XENIX
  246.     "$(COMPILE.s) -o $@ $<",
  247. #else    /* Xenix.  */
  248.     "$(COMPILE.s) -o$@ $<",
  249. #endif    /* Not Xenix.  */
  250.     ".c.o",
  251.     "$(COMPILE.c) $< $(OUTPUT_OPTION)",
  252.     ".cc.o",
  253.     "$(COMPILE.cc) $< $(OUTPUT_OPTION)",
  254.     ".f.o",
  255.     "$(COMPILE.f) $< $(OUTPUT_OPTION)",
  256.     ".p.o",
  257.     "$(COMPILE.p) $< $(OUTPUT_OPTION)",
  258.     ".F.o",
  259.     "$(COMPILE.F) $< $(OUTPUT_OPTION)",
  260.     ".r.o",
  261.     "$(COMPILE.r) $< $(OUTPUT_OPTION)",
  262.     ".mod.o",
  263.     "$(COMPILE.mod) -o $@ $<",
  264.  
  265.     ".c.ln",
  266.     "$(LINT.c) -C$* $<",
  267.     ".y.ln",
  268.     "$(YACC.y) $< \n $(LINT.c) -C$* y.tab.c \n $(RM) y.tab.c",
  269.     ".l.ln",
  270.     "@$(RM) $*.c \n $(LEX.l) $< > $*.c \n\
  271. $(LINT.c) -i $*.c -o $@ \n $(RM) $*.c",
  272.  
  273.     ".y.c",
  274.     "$(YACC.y) $< \n mv -f y.tab.c $@",
  275.     ".l.c",
  276.     "@$(RM) $@ \n $(LEX.l) $< > $@",
  277.  
  278.     ".F.f",
  279.     "$(PREPROCESS.F) $< $(OUTPUT_OPTION)",
  280.     ".r.f",
  281.     "$(PREPROCESS.r) $< $(OUTPUT_OPTION)",
  282.  
  283.     /* This might actually make lex.yy.c if there's no %R%
  284.        directive in $*.l, but in that case why were you
  285.        trying to make $*.r anyway?  */
  286.     ".l.r",
  287.     "$(LEX.l) $< > $@ \n mv -f lex.yy.r $@",
  288.  
  289.     ".S.s",
  290.     "$(PREPROCESS.S) $< > $@",
  291.  
  292.     ".texinfo.info",
  293.     "$(MAKEINFO) $<",
  294.  
  295.     ".tex.dvi",
  296.     "$(TEX) $<",
  297.  
  298.     ".texinfo.dvi",
  299.     "$(TEXINDEX) $(wildcard $(foreach _s_,cp fn ky pg tp vr,$*.$(_s_)))\n\
  300.      -$(foreach _f_,$(wildcard $(foreach _s_,aux cp fn ky pg tp vr,$*.$(_s_)))\
  301. ,cp $(_f_) $(_f_)O;)\n\
  302.      -$(TEX) $< \n\
  303.      $(foreach _f_,$(wildcard $(foreach _s_,aux cp fn ky pg tp vr,\
  304. $*.$(_s_))),cmp -s $(_f_)O $(_f_) ||) \\\n\
  305. ($(TEXINDEX) $(wildcard $(foreach _s_,cp fn ky pg tp vr,$*.$(_s_))); \\\n\
  306. $(TEX) $<) \n\
  307.      -rm -f $(addsuffix O,$(wildcard $(foreach _s_,\
  308. aux cp fn ky pg tp vr,$*.$(_s_))))",
  309.  
  310.     ".cweb.c",
  311.     "$(CTANGLE) $<",
  312.  
  313.     ".web.p",
  314.     "$(TANGLE) $<",
  315.  
  316.     ".cweb.tex",
  317.     "$(CWEAVE) $<",
  318.  
  319.     ".web.tex",
  320.     "$(WEAVE) $<",
  321.  
  322.     0
  323.   };
  324.  
  325. static char *default_variables[] =
  326.   {
  327.     "AR", "ar",
  328.     "ARFLAGS", "rv",
  329.     "AS", "as",
  330.     "CC", "cc",
  331.     "C++", "g++",
  332.     "CO", "co",
  333.     "CPP", "$(CC) -E",
  334.     "FC", "f77",
  335.     /* System V uses these, so explicit rules using them should work.
  336.        However, there is no way to make implicit rules use them and FC.  */
  337.     "F77", "$(FC)",
  338.     "F77FLAGS", "$(FFLAGS)",
  339. #ifdef    USG
  340.     "GET", "get",
  341. #else
  342.     "GET", "/usr/sccs/get",
  343. #endif
  344.     "LD", "ld",
  345.     "LEX", "lex",
  346.     "LINT", "lint",
  347.     "M2C", "m2c",
  348.     "PC", "pc",
  349.     "YACC", "yacc",    /* Or "bison -y"  */
  350.     "MAKEINFO", "makeinfo",
  351.     "TEX", "tex",
  352.     "TEXINDEX", "texindex",
  353.     "WEAVE", "weave",
  354.     "CWEAVE", "cweave",
  355.     "TANGLE", "tangle",
  356.     "CTANGLE", "ctangle",
  357.  
  358.     "RM", "rm -f",
  359.  
  360.     "LINK.o", "$(CC) $(LDFLAGS) $(TARGET_ARCH)",
  361.     "COMPILE.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
  362.     "LINK.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
  363.     "COMPILE.cc", "$(C++) $(C++FLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
  364.     "LINK.cc", "$(C++) $(C++FLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
  365.     "YACC.y", "$(YACC) $(YFLAGS)",
  366.     "LEX.l", "$(LEX) $(LFLAGS) -t",
  367.     "COMPILE.f", "$(FC) $(FFLAGS) $(TARGET_ARCH) -c",
  368.     "LINK.f", "$(FC) $(FFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
  369.     "COMPILE.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
  370.     "LINK.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
  371.     "COMPILE.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -c",
  372.     "LINK.r", "$(FC) $(FFLAGS) $(RFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
  373.     "COMPILE.def", "$(M2C) $(M2FLAGS) $(DEFFLAGS) $(TARGET_ARCH)",
  374.     "COMPILE.mod", "$(M2C) $(M2FLAGS) $(MODFLAGS) $(TARGET_ARCH)",
  375.     "COMPILE.p", "$(PC) $(PFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
  376.     "LINK.p", "$(PC) $(PFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
  377.     "COMPILE.s", "$(AS) $(ASFLAGS) $(TARGET_MACH)",
  378.     "COMPILE.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c",
  379.     "LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
  380. #ifndef    M_XENIX
  381.     "PREPROCESS.S", "$(CC) -E $<",
  382. #else    /* Xenix.  */
  383.     "PREPROCESS.S", "$(CC) -EP $<",
  384. #endif    /* Not Xenix.  */
  385.     "PREPROCESS.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -F",
  386.     "PREPROCESS.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -F",
  387.  
  388. #ifndef    NO_MINUS_C_MINUS_O
  389. #ifndef    M_XENIX
  390.     "OUTPUT_OPTION", "-o $@",
  391. #else    /* Xenix.  */
  392.     "OUTPUT_OPTION", "-Fo$@",
  393. #endif    /* Not Xenix.  */
  394. #endif
  395.  
  396.     0, 0
  397.   };
  398.  
  399. #endif /* MSDOS && !STRICT */
  400.  
  401.  
  402. /* Set up the default .SUFFIXES list.  */
  403.  
  404. void
  405. set_default_suffixes ()
  406. {
  407.   suffix_file = enter_file (".SUFFIXES");
  408.  
  409.   if (no_builtin_rules_flag)
  410.     (void) define_variable ("SUFFIXES", 8, "", o_default, 0);
  411.   else
  412.     {
  413.       char *p = default_suffixes;
  414.       suffix_file->deps = (struct dep *)
  415.     multi_glob (parse_file_seq (&p, '\0', sizeof (struct dep)),
  416.             sizeof (struct dep));
  417.       (void) define_variable ("SUFFIXES", 8, default_suffixes, o_default, 0);
  418.     }
  419. }
  420.  
  421. /* Install the default pattern rules and enter
  422.    the default suffix rules as file rules.  */
  423.  
  424. void
  425. install_default_implicit_rules ()
  426. {
  427.   register struct pspec *p;
  428.   register char **s;
  429.   
  430.   if (no_builtin_rules_flag)
  431.     return;
  432.  
  433.   for (p = default_pattern_rules; p->target != 0; ++p)
  434.     install_pattern_rule (p, 0);
  435.  
  436.   for (p = default_terminal_rules; p->target != 0; ++p)
  437.     install_pattern_rule (p, 1);
  438.  
  439.   for (s = default_suffix_rules; *s != 0; s += 2)
  440.     {
  441.       register struct file *f = enter_file (s[0]);
  442.       f->cmds = (struct commands *) xmalloc (sizeof (struct commands));
  443.       f->cmds->filename = 0;
  444.       f->cmds->commands = s[1];
  445.       f->cmds->command_lines = 0;
  446.     }
  447.  
  448.   for (s = default_variables; *s != 0; s += 2)
  449.     (void) define_variable (s[0], strlen (s[0]), s[1], o_default, 1);
  450. }
  451.