1 /* MetaMake - A Make extension
2 Copyright © 1995-2011, 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)
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. */
30 #endif /* PROTOTYPES */
32 #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__
34 # define VA_START(args, lastarg) va_start(args, lastarg)
37 # define VA_START(args, lastarg) va_start(args)
41 # define __DATE__ "No __DATE__"
55 #ifdef HAVE_SYS_STAT_H
56 # include <sys/stat.h>
58 #ifdef HAVE_SYS_TYPES_H
59 # include <sys/types.h>
68 #if defined(DEBUG_MMAKE)
81 char *mm_srcdir
; /* Location to scan for cfg files */
82 char *mm_builddir
; /* Location to generate files/build in */
86 error (char * fmt
, ...)
90 fprintf (stderr
, "[MMAKE] Error: ");
91 vfprintf (stderr
, fmt
, args
);
93 fprintf (stderr
, ": %s", strerror (errno
));
94 fprintf (stderr
, "\n");
100 main (int argc
, char ** argv
)
107 currdir
= getcwd (NULL
, 1024);
110 mm_builddir
= currdir
;
112 mflagc
= targetc
= 0;
114 for (t
=1; t
<argc
; t
++)
116 if (argv
[t
][0] == '-')
118 if (!strcmp (argv
[t
], "--version"))
120 printf ("MetaMake %s (%s)\n", PACKAGE_VERSION
, __DATE__
);
124 else if (!strncmp (argv
[t
], "--srcdir", 8) || !strcmp (argv
[t
], "-s"))
126 mm_srcdir
= (char *)&argv
[t
][9];
128 else if (!strncmp (argv
[t
], "--builddir", 10) || !strcmp (argv
[t
], "-b"))
130 mm_builddir
= (char *)&argv
[t
][11];
132 else if (!strcmp (argv
[t
], "--verbose") || !strcmp (argv
[t
], "-v"))
136 else if (!strcmp (argv
[t
], "--quiet") || !strcmp (argv
[t
], "-q"))
140 else if (!strcmp (argv
[t
], "--debug"))
144 else if (!strcmp (argv
[t
], "--help"))
146 printf ("%s [--srcdir=<directory>] [--builddir=<directory>] [--version] [-v,--verbose] [-q,--quiet] [--debug] [--help]\n", argv
[0]);
151 mflags
[mflagc
++] = argv
[t
];
156 targets
[targetc
++] = argv
[t
];
163 printf ("SRCDIR '%s'\n", mm_srcdir
);
164 printf ("BUILDDIR '%s'\n", mm_builddir
);
172 debug(printf("MMAKE:mmake.c->main: parsed command line options\n"));
176 debug(printf("MMAKE:mmake.c->main: projects initialised\n"));
180 struct Project
* firstprj
= getfirstproject ();
184 targets
[targetc
++] = firstprj
->node
.name
;
185 debug(printf("MMAKE:mmake.c->main: targetc not set, using default'%s'\n", firstprj
->node
.name
));
188 for (t
=0; t
<targetc
; t
++)
190 char * pname
, * tname
, * ptr
;
191 struct Project
* prj
;
193 pname
= ptr
= targets
[t
];
194 while (*ptr
&& *ptr
!= '.')
200 prj
= findproject (pname
);
204 printf ("[MMAKE] Nothing known about project %s\n", pname
);
208 debug(printf("MMAKE:mmake.c->main: calling maketarget '%s'\n", tname
));
209 maketarget (prj
, tname
);
214 ASSERT(chdir (currdir
) == 0);