1 /* MetaMake - A Make extension
2 Copyright © 1995-2008, 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)
80 char *mm_srcdir
; /* Location to scan for cfg files */
81 char *mm_builddir
; /* Location to generate files/build in */
85 error (char * fmt
, ...)
89 fprintf (stderr
, "Error: ");
90 vfprintf (stderr
, fmt
, args
);
92 fprintf (stderr
, ": %s", strerror (errno
));
93 fprintf (stderr
, "\n");
99 main (int argc
, char ** argv
)
106 currdir
= getcwd (NULL
, 1024);
109 mm_builddir
= currdir
;
111 mflagc
= targetc
= 0;
113 for (t
=1; t
<argc
; t
++)
115 if (argv
[t
][0] == '-')
117 if (!strcmp (argv
[t
], "--version"))
119 printf ("MetaMake %s (%s)\n", PACKAGE_VERSION
, __DATE__
);
123 else if (!strncmp (argv
[t
], "--srcdir", 8) || !strcmp (argv
[t
], "-s"))
125 mm_srcdir
= (char *)&argv
[t
][9];
127 else if (!strncmp (argv
[t
], "--builddir", 10) || !strcmp (argv
[t
], "-b"))
129 mm_builddir
= (char *)&argv
[t
][11];
131 else if (!strcmp (argv
[t
], "--verbose") || !strcmp (argv
[t
], "-v"))
135 else if (!strcmp (argv
[t
], "--debug"))
139 else if (!strcmp (argv
[t
], "--help"))
141 printf ("%s [--srcdir=<directory>] [--builddir=<directory>] [--version] [-v,--verbose] [--debug] [--help]\n", argv
[0]);
146 mflags
[mflagc
++] = argv
[t
];
151 targets
[targetc
++] = argv
[t
];
157 printf ("SRCDIR '%s'\n", mm_srcdir
);
158 printf ("BUILDDIR '%s'\n", mm_builddir
);
161 debug(printf("MMAKE:mmake.c->main: parsed command line options\n"));
165 debug(printf("MMAKE:mmake.c->main: projects initialised\n"));
169 struct Project
* firstprj
= getfirstproject ();
173 targets
[targetc
++] = firstprj
->node
.name
;
174 debug(printf("MMAKE:mmake.c->main: targetc not set, using default'%s'\n", firstprj
->node
.name
));
177 for (t
=0; t
<targetc
; t
++)
179 char * pname
, * tname
, * ptr
;
180 struct Project
* prj
;
182 pname
= ptr
= targets
[t
];
183 while (*ptr
&& *ptr
!= '.')
189 prj
= findproject (pname
);
193 printf ("Nothing known about project %s\n", pname
);
197 debug(printf("MMAKE:mmake.c->main: calling maketarget '%s'\n", tname
));
198 maketarget (prj
, tname
);