Don't initialise library bases used by linklibs here. Will probably be done
[tangerine.git] / tools / MetaMake / mmake.c
blobf1acbad9eb690a7e217fa8ef69bba17f4ca811fa
1 /* MetaMake - A Make extension
2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
4 This file is part of MetaMake.
6 MetaMake is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 MetaMake is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20 /* Includes */
21 #include "config.h"
23 #ifdef PROTOTYPES
24 # define PARAMS(x) x
25 #else
26 # define PARAMS(x) ()
27 #endif /* PROTOTYPES */
29 #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__
30 # include <stdarg.h>
31 # define VA_START(args, lastarg) va_start(args, lastarg)
32 #else
33 # include <varargs.h>
34 # define VA_START(args, lastarg) va_start(args)
35 #endif
37 #ifndef __DATE__
38 # define __DATE__ "No __DATE__"
39 #endif
41 #include <stdio.h>
42 #include <assert.h>
43 #include <errno.h>
44 #include <ctype.h>
45 #include <stdlib.h>
46 #include <time.h>
47 #ifdef HAVE_STRING_H
48 # include <string.h>
49 #else
50 # include <strings.h>
51 #endif
52 #ifdef HAVE_SYS_STAT_H
53 # include <sys/stat.h>
54 #endif
55 #ifdef HAVE_SYS_TYPES_H
56 # include <sys/types.h>
57 #endif
59 #include "list.h"
60 #include "mem.h"
61 #include "var.h"
62 #include "dep.h"
63 #include "project.h"
65 /* globals */
66 char * mflags[64];
67 int mflagc;
68 int verbose = 0;
69 int debug = 0;
71 /* Functions */
72 void
73 error (char * fmt, ...)
75 va_list args;
76 VA_START (args, fmt);
77 fprintf (stderr, "Error: ");
78 vfprintf (stderr, fmt, args);
79 if (errno != 0)
80 fprintf (stderr, ": %s", strerror (errno));
81 fprintf (stderr, "\n");
82 va_end (args);
86 int
87 main (int argc, char ** argv)
89 char * currdir;
90 int t;
91 char * targets[64];
92 int targetc;
94 currdir = getcwd (NULL, 1024);
96 mflagc = targetc = 0;
98 for (t=1; t<argc; t++)
100 if (argv[t][0] == '-')
102 if (!strcmp (argv[t], "--version"))
104 printf ("MetaMake %s (%s)\n", PACKAGE_VERSION, __DATE__);
105 if (argc == 2)
106 exit (0);
108 else if (!strcmp (argv[t], "--verbose") || !strcmp (argv[t], "-v"))
110 verbose = 1;
112 else if (!strcmp (argv[t], "--debug"))
114 debug = 1;
116 else if (!strcmp (argv[t], "--help"))
118 printf ("%s [--version] [-v,--verbose] [--debug] [--help]\n", argv[0]);
119 return 0;
121 else
123 mflags[mflagc++] = argv[t];
126 else
128 targets[targetc++] = argv[t];
132 initprojects ();
134 if (!targetc)
136 Project * firstprj = getfirstproject ();
138 assert (firstprj);
140 targets[targetc++] = firstprj->node.name;
143 for (t=0; t<targetc; t++)
145 char * pname, * tname, * ptr;
146 Project * prj;
148 pname = ptr = targets[t];
149 while (*ptr && *ptr != '.')
150 ptr ++;
151 if (*ptr)
152 *ptr ++ = 0;
153 tname = ptr;
155 prj = findproject (pname);
157 if (!prj)
159 printf ("Nothing known about project %s\n", pname);
160 return 20;
163 maketarget (prj, tname);
166 expungeprojects ();
168 chdir (currdir);
170 free (currdir);
172 return 0;