summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:20 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:20 +0000
commita15b8ac6912cef59d7e1ba7a80e58466e2c9fcba (patch)
tree26b5e2d5670359b095209d199c53d8a099d11e31
parentac5d447a2f18bdd07d5f97bb27cd9d065e30f683 (diff)
downloadxorg-util-makedepend-a15b8ac6912cef59d7e1ba7a80e58466e2c9fcba.tar.gz
-rw-r--r--cppsetup.c49
-rw-r--r--def.h81
-rw-r--r--ifparser.c197
-rw-r--r--ifparser.h21
-rw-r--r--imakemdep.h769
-rw-r--r--include.c157
-rw-r--r--main.c398
-rw-r--r--makedepend.man20
-rw-r--r--parse.c183
-rw-r--r--pr.c25
10 files changed, 1354 insertions, 546 deletions
diff --git a/cppsetup.c b/cppsetup.c
index b25d2ce..49a746a 100644
--- a/cppsetup.c
+++ b/cppsetup.c
@@ -24,6 +24,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
+/* $XFree86: xc/config/makedepend/cppsetup.c,v 3.11 2001/12/17 20:52:22 dawes Exp $ */
#include "def.h"
@@ -39,7 +40,7 @@ in this Software without prior written authorization from The Open Group.
#define QB 16
#define WB 32
#define SALT '#'
-#if pdp11 | vax | ns16000 | mc68000 | ibm032
+#if defined(pdp11) || defined(vax) || defined(ns16000) || defined(mc68000) || defined(ibm032)
#define COFF 128
#else
#define COFF 0
@@ -58,12 +59,10 @@ extern char slotab[];
struct filepointer *currentfile;
struct inclist *currentinc;
-cppsetup(line, filep, inc)
- register char *line;
- register struct filepointer *filep;
- register struct inclist *inc;
+int
+cppsetup(char *line, struct filepointer *filep, struct inclist *inc)
{
- register char *p, savec;
+ char *p, savec;
static boolean setupdone = FALSE;
boolean value;
@@ -132,10 +131,7 @@ struct _parse_data {
};
static const char *
-my_if_errors (ip, cp, expecting)
- IfParser *ip;
- const char *cp;
- const char *expecting;
+my_if_errors (IfParser *ip, const char *cp, const char *expecting)
{
struct _parse_data *pd = (struct _parse_data *) ip->data;
int lineno = pd->filep->f_line;
@@ -162,10 +158,7 @@ my_if_errors (ip, cp, expecting)
#define MAXNAMELEN 256
static struct symtab **
-lookup_variable (ip, var, len)
- IfParser *ip;
- const char *var;
- int len;
+lookup_variable (IfParser *ip, const char *var, int len)
{
char tmpbuf[MAXNAMELEN + 1];
struct _parse_data *pd = (struct _parse_data *) ip->data;
@@ -180,10 +173,7 @@ lookup_variable (ip, var, len)
static int
-my_eval_defined (ip, var, len)
- IfParser *ip;
- const char *var;
- int len;
+my_eval_defined (IfParser *ip, const char *var, int len)
{
if (lookup_variable (ip, var, len))
return 1;
@@ -194,11 +184,9 @@ my_eval_defined (ip, var, len)
#define isvarfirstletter(ccc) (isalpha(ccc) || (ccc) == '_')
static long
-my_eval_variable (ip, var, len)
- IfParser *ip;
- const char *var;
- int len;
+my_eval_variable (IfParser *ip, const char *var, int len)
{
+ long val;
struct symtab **s;
s = lookup_variable (ip, var, len);
@@ -206,20 +194,21 @@ my_eval_variable (ip, var, len)
return 0;
do {
var = (*s)->s_value;
- if (!isvarfirstletter(*var))
+ if (!isvarfirstletter(*var) || !strcmp((*s)->s_name, var))
break;
s = lookup_variable (ip, var, strlen(var));
} while (s);
- return strtol(var, NULL, 0);
+ var = ParseIfExpression(ip, var, &val);
+ if (var && *var) debug(4, ("extraneous: '%s'\n", var));
+ return val;
}
-
-cppsetup(filename, line, filep, inc)
- register char *filename;
- register char *line;
- register struct filepointer *filep;
- register struct inclist *inc;
+int
+cppsetup(char *filename,
+ char *line,
+ struct filepointer *filep,
+ struct inclist *inc)
{
IfParser ip;
struct _parse_data pd;
diff --git a/def.h b/def.h
index 63f6bd0..f80c9d2 100644
--- a/def.h
+++ b/def.h
@@ -24,22 +24,28 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
+/* $XFree86: xc/config/makedepend/def.h,v 3.14 2003/01/17 17:09:49 tsi Exp $ */
#include "Xos.h"
#include "Xfuncproto.h"
+#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <ctype.h>
+#if 0
#ifndef X_NOT_POSIX
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE
#endif
#endif
+#endif
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#define MAXDEFINES 512
#define MAXFILES 1024
+#define MAXINCFILES 128 /* "-include" files */
#define MAXDIRS 64
#define SYMTABINC 10 /* must be > 1 for define() to work right */
#define TRUE 1
@@ -61,12 +67,14 @@ in this Software without prior written authorization from The Open Group.
#define SCCS 12
#define ELIF 13
#define EJECT 14
-#define WARNING 15
-#define IFFALSE 16 /* pseudo value --- never matched */
-#define ELIFFALSE 17 /* pseudo value --- never matched */
-#define INCLUDEDOT 18 /* pseudo value --- never matched */
-#define IFGUESSFALSE 19 /* pseudo value --- never matched */
-#define ELIFGUESSFALSE 20 /* pseudo value --- never matched */
+#define WARNING 15
+#define INCLUDENEXT 16
+#define IFFALSE 17 /* pseudo value --- never matched */
+#define ELIFFALSE 18 /* pseudo value --- never matched */
+#define INCLUDEDOT 19 /* pseudo value --- never matched */
+#define IFGUESSFALSE 20 /* pseudo value --- never matched */
+#define ELIFGUESSFALSE 21 /* pseudo value --- never matched */
+#define INCLUDENEXTDOT 22 /* pseudo value --- never matched */
#ifdef DEBUG
extern int _debugmask;
@@ -113,35 +121,62 @@ struct inclist {
};
struct filepointer {
+ char *f_name;
char *f_p;
char *f_base;
char *f_end;
long f_len;
long f_line;
+ long cmdinc_count;
+ char **cmdinc_list;
+ long cmdinc_line;
};
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
#if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */
char *malloc(), *realloc();
#endif /* macII */
-#else
-char *malloc();
-char *realloc();
-#endif
-char *copy();
-char *base_name();
-char *getline();
-struct symtab **slookup();
-struct symtab **isdefined();
-struct symtab **fdefined();
-struct filepointer *getfile();
-struct inclist *newinclude();
-struct inclist *inc_path();
-
-#if NeedVarargsPrototypes
+char *copy(char *str);
+int match(char *str, char **list);
+char *base_name(char *file);
+char *getnextline(struct filepointer *fp);
+struct symtab **slookup(char *symbol, struct inclist *file);
+struct symtab **isdefined(char *symbol, struct inclist *file,
+ struct inclist **srcfile);
+struct symtab **fdefined(char *symbol, struct inclist *file,
+ struct inclist **srcfile);
+struct filepointer *getfile(char *file);
+void included_by(struct inclist *ip,
+ struct inclist *newfile);
+struct inclist *newinclude(char *newfile, char *incstring);
+void inc_clean (void);
+struct inclist *inc_path(char *file, char *include, int type);
+
+void freefile(struct filepointer *fp);
+
+void define2(char *name, char *val, struct inclist *file);
+void define(char *def, struct inclist *file);
+void undefine(char *symbol, struct inclist *file);
+int find_includes(struct filepointer *filep,
+ struct inclist *file,
+ struct inclist *file_red,
+ int recursion, boolean failOK);
+
+void recursive_pr_include(struct inclist *head,
+ char *file, char *base);
+void add_include(struct filepointer *filep,
+ struct inclist *file,
+ struct inclist *file_red,
+ char *include, int type,
+ boolean failOK);
+
+int cppsetup(char *filename,
+ char *line,
+ struct filepointer *filep,
+ struct inclist *inc);
+
+
extern void fatalerr(char *, ...);
extern void warning(char *, ...);
extern void warning1(char *, ...);
-#endif
diff --git a/ifparser.c b/ifparser.c
index c91c236..d8d9e76 100644
--- a/ifparser.c
+++ b/ifparser.c
@@ -31,10 +31,13 @@
*
* EXPRESSION := VALUE
* | VALUE BINOP EXPRESSION
+ * | VALUE '?' EXPRESSION ':' EXPRESSION
*
* VALUE := '(' EXPRESSION ')'
* | '!' VALUE
* | '-' VALUE
+ * | '+' VALUE
+ * | '~' VALUE
* | 'defined' '(' variable ')'
* | 'defined' variable
* | # variable '(' variable-list ')'
@@ -46,19 +49,22 @@
* | '<<' | '>>'
* | '<' | '>' | '<=' | '>='
* | '==' | '!='
- * | '&' | '|'
+ * | '&' | '^' | '|'
* | '&&' | '||'
*
- * The normal C order of precidence is supported.
+ * The normal C order of precedence is supported.
*
*
* External Entry Points:
*
* ParseIfExpression parse a string for #if
*/
+/* $XFree86: xc/config/makedepend/ifparser.c,v 3.11 2002/09/23 01:48:08 tsi Exp $ */
#include "ifparser.h"
#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
/****************************************************************************
Internal Macros and Utilities for Parser
@@ -71,10 +77,7 @@
static const char *
-parse_variable (g, cp, varp)
- IfParser *g;
- const char *cp;
- const char **varp;
+parse_variable (IfParser *g, const char *cp, const char **varp)
{
SKIPSPACE (cp);
@@ -89,32 +92,55 @@ parse_variable (g, cp, varp)
static const char *
-parse_number (g, cp, valp)
- IfParser *g;
- const char *cp;
- long *valp;
+parse_number (IfParser *g, const char *cp, long *valp)
{
+ long base = 10;
SKIPSPACE (cp);
if (!isdigit(*cp))
return CALLFUNC(g, handle_error) (g, cp, "number");
- *valp = strtol(cp, &cp, 0);
- /* skip trailing qualifiers */
+ *valp = 0;
+
+ if (*cp == '0') {
+ cp++;
+ if ((*cp == 'x') || (*cp == 'X')) {
+ base = 16;
+ cp++;
+ } else {
+ base = 8;
+ }
+ }
+
+ /* Ignore overflows and assume ASCII, what source is usually written in */
+ while (1) {
+ int increment = -1;
+ if (base == 8) {
+ if ((*cp >= '0') && (*cp <= '7'))
+ increment = *cp++ - '0';
+ } else if (base == 16) {
+ if ((*cp >= '0') && (*cp <= '9'))
+ increment = *cp++ - '0';
+ else if ((*cp >= 'A') && (*cp <= 'F'))
+ increment = *cp++ - ('A' - 10);
+ else if ((*cp >= 'a') && (*cp <= 'f'))
+ increment = *cp++ - ('a' - 10);
+ } else { /* Decimal */
+ if ((*cp >= '0') && (*cp <= '9'))
+ increment = *cp++ - '0';
+ }
+ if (increment < 0)
+ break;
+ *valp = (*valp * base) + increment;
+ }
+
+ /* Skip trailing qualifiers */
while (*cp == 'U' || *cp == 'u' || *cp == 'L' || *cp == 'l') cp++;
-#if 0
- *valp = atoi (cp);
- /* EMPTY */
- for (cp++; isdigit(*cp); cp++) ;
-#endif
return cp;
}
static const char *
-parse_character (g, cp, valp)
- IfParser *g;
- const char *cp;
- long *valp;
+parse_character (IfParser *g, const char *cp, long *valp)
{
char val;
@@ -143,12 +169,9 @@ parse_character (g, cp, valp)
}
static const char *
-parse_value (g, cp, valp)
- IfParser *g;
- const char *cp;
- long *valp;
+parse_value (IfParser *g, const char *cp, long *valp)
{
- const char *var;
+ const char *var, *varend;
*valp = 0;
@@ -175,6 +198,15 @@ parse_value (g, cp, valp)
*valp = -(*valp);
return cp;
+ case '+':
+ DO (cp = parse_value (g, cp + 1, valp));
+ return cp;
+
+ case '~':
+ DO (cp = parse_value (g, cp + 1, valp));
+ *valp = ~(*valp);
+ return cp;
+
case '#':
DO (cp = parse_variable (g, cp + 1, &var));
SKIPSPACE (cp);
@@ -223,7 +255,24 @@ parse_value (g, cp, valp)
return CALLFUNC(g, handle_error) (g, cp, "variable or number");
else {
DO (cp = parse_variable (g, cp, &var));
- *valp = (*(g->funcs.eval_variable)) (g, var, cp - var);
+ varend = cp;
+ SKIPSPACE(cp);
+ if (*cp != '(') {
+ *valp = (*(g->funcs.eval_variable)) (g, var, varend - var);
+ } else {
+ do {
+ long dummy;
+ DO (cp = ParseIfExpression (g, cp + 1, &dummy));
+ SKIPSPACE(cp);
+ if (*cp == ')')
+ break;
+ if (*cp != ',')
+ return CALLFUNC(g, handle_error) (g, cp, ",");
+ } while (1);
+
+ *valp = 1; /* XXX */
+ cp++;
+ }
}
return cp;
@@ -232,10 +281,7 @@ parse_value (g, cp, valp)
static const char *
-parse_product (g, cp, valp)
- IfParser *g;
- const char *cp;
- long *valp;
+parse_product (IfParser *g, const char *cp, long *valp)
{
long rightval;
@@ -263,10 +309,7 @@ parse_product (g, cp, valp)
static const char *
-parse_sum (g, cp, valp)
- IfParser *g;
- const char *cp;
- long *valp;
+parse_sum (IfParser *g, const char *cp, long *valp)
{
long rightval;
@@ -289,10 +332,7 @@ parse_sum (g, cp, valp)
static const char *
-parse_shift (g, cp, valp)
- IfParser *g;
- const char *cp;
- long *valp;
+parse_shift (IfParser *g, const char *cp, long *valp)
{
long rightval;
@@ -319,10 +359,7 @@ parse_shift (g, cp, valp)
static const char *
-parse_inequality (g, cp, valp)
- IfParser *g;
- const char *cp;
- long *valp;
+parse_inequality (IfParser *g, const char *cp, long *valp)
{
long rightval;
@@ -355,10 +392,7 @@ parse_inequality (g, cp, valp)
static const char *
-parse_equality (g, cp, valp)
- IfParser *g;
- const char *cp;
- long *valp;
+parse_equality (IfParser *g, const char *cp, long *valp)
{
long rightval;
@@ -385,10 +419,7 @@ parse_equality (g, cp, valp)
static const char *
-parse_band (g, cp, valp)
- IfParser *g;
- const char *cp;
- long *valp;
+parse_band (IfParser *g, const char *cp, long *valp)
{
long rightval;
@@ -408,10 +439,7 @@ parse_band (g, cp, valp)
static const char *
-parse_bor (g, cp, valp)
- IfParser *g;
- const char *cp;
- long *valp;
+parse_bxor (IfParser *g, const char *cp, long *valp)
{
long rightval;
@@ -419,6 +447,24 @@ parse_bor (g, cp, valp)
SKIPSPACE (cp);
switch (*cp) {
+ case '^':
+ DO (cp = parse_bxor (g, cp + 1, &rightval));
+ *valp = (*valp ^ rightval);
+ break;
+ }
+ return cp;
+}
+
+
+static const char *
+parse_bor (IfParser *g, const char *cp, long *valp)
+{
+ long rightval;
+
+ DO (cp = parse_bxor (g, cp, valp));
+ SKIPSPACE (cp);
+
+ switch (*cp) {
case '|':
if (cp[1] != '|') {
DO (cp = parse_bor (g, cp + 1, &rightval));
@@ -431,10 +477,7 @@ parse_bor (g, cp, valp)
static const char *
-parse_land (g, cp, valp)
- IfParser *g;
- const char *cp;
- long *valp;
+parse_land (IfParser *g, const char *cp, long *valp)
{
long rightval;
@@ -454,10 +497,7 @@ parse_land (g, cp, valp)
static const char *
-parse_lor (g, cp, valp)
- IfParser *g;
- const char *cp;
- long *valp;
+parse_lor (IfParser *g, const char *cp, long *valp)
{
long rightval;
@@ -476,17 +516,34 @@ parse_lor (g, cp, valp)
}
+static const char *
+parse_cond(IfParser *g, const char *cp, long *valp)
+{
+ long trueval, falseval;
+
+ DO (cp = parse_lor (g, cp, valp));
+ SKIPSPACE (cp);
+
+ switch (*cp) {
+ case '?':
+ DO (cp = parse_cond (g, cp + 1, &trueval));
+ SKIPSPACE (cp);
+ if (*cp != ':')
+ return CALLFUNC(g, handle_error) (g, cp, ":");
+ DO (cp = parse_cond (g, cp + 1, &falseval));
+ *valp = (*valp ? trueval : falseval);
+ break;
+ }
+ return cp;
+}
+
+
/****************************************************************************
External Entry Points
****************************************************************************/
const char *
-ParseIfExpression (g, cp, valp)
- IfParser *g;
- const char *cp;
- long *valp;
+ParseIfExpression (IfParser *g, const char *cp, long *valp)
{
- return parse_lor (g, cp, valp);
+ return parse_cond (g, cp, valp);
}
-
-
diff --git a/ifparser.h b/ifparser.h
index 2b10266..89d2a2f 100644
--- a/ifparser.h
+++ b/ifparser.h
@@ -31,10 +31,12 @@
*
* EXPRESSION := VALUE
* | VALUE BINOP EXPRESSION
+ * | VALUE '?' EXPRESSION ':' EXPRESSION
*
* VALUE := '(' EXPRESSION ')'
* | '!' VALUE
* | '-' VALUE
+ * | '~' VALUE
* | 'defined' '(' variable ')'
* | variable
* | number
@@ -44,10 +46,10 @@
* | '<<' | '>>'
* | '<' | '>' | '<=' | '>='
* | '==' | '!='
- * | '&' | '|'
+ * | '&' | '^' | '|'
* | '&&' | '||'
*
- * The normal C order of precidence is supported.
+ * The normal C order of precedence is supported.
*
*
* External Entry Points:
@@ -55,28 +57,27 @@
* ParseIfExpression parse a string for #if
*/
+/* $XFree86: xc/config/makedepend/ifparser.h,v 3.5 2001/07/25 15:04:40 dawes Exp $ */
+
#include <stdio.h>
-#define const /**/
typedef int Bool;
#define False 0
#define True 1
typedef struct _if_parser {
struct { /* functions */
- char *(*handle_error) (/* struct _if_parser *, const char *,
- const char * */);
- long (*eval_variable) (/* struct _if_parser *, const char *, int */);
- int (*eval_defined) (/* struct _if_parser *, const char *, int */);
+ const char *(*handle_error) (struct _if_parser *, const char *,
+ const char *);
+ long (*eval_variable) (struct _if_parser *, const char *, int);
+ int (*eval_defined) (struct _if_parser *, const char *, int);
} funcs;
char *data;
} IfParser;
-char *ParseIfExpression (
-#ifdef __STDC__
+const char *ParseIfExpression (
IfParser *,
const char *,
long *
-#endif
);
diff --git a/imakemdep.h b/imakemdep.h
index b6ebd42..c31a000 100644
--- a/imakemdep.h
+++ b/imakemdep.h
@@ -24,6 +24,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
+/* $XFree86: xc/config/imake/imakemdep.h,v 3.68 2002/12/24 17:42:58 tsi Exp $ */
/*
@@ -39,6 +40,10 @@ in this Software without prior written authorization from The Open Group.
* These will be passed to the compile along with the contents of the
* make variable BOOTSTRAPCFLAGS.
*/
+#if defined(clipper) || defined(__clipper__)
+#define imake_ccflags "-O -DSYSV -DBOOTSTRAPCFLAGS=-DSYSV"
+#endif
+
#ifdef hpux
#ifdef hp9000s800
#define imake_ccflags "-DSYSV"
@@ -64,7 +69,7 @@ in this Software without prior written authorization from The Open Group.
#ifdef imake_ccflags
#undef imake_ccflags
#endif
-#define imake_ccflags "-Dsco"
+#define imake_ccflags "-Dsco -DSYSV -DSCO -DSCO325"
#endif
#ifdef sony
@@ -81,7 +86,6 @@ in this Software without prior written authorization from The Open Group.
#endif
#endif
#endif
-
#ifdef _CRAY
#define imake_ccflags "-DSYSV -DUSG"
#endif
@@ -122,6 +126,10 @@ in this Software without prior written authorization from The Open Group.
# endif
#endif
+#if defined(Lynx) || defined(__Lynx__)
+#define imake_ccflags "-DLynx"
+#endif /* Lynx */
+
#ifdef __convex__
#define imake_ccflags "-fn -tm c1"
#endif
@@ -162,15 +170,23 @@ in this Software without prior written authorization from The Open Group.
#define imake_ccflags "-DSVR4"
#endif
-#ifdef MACH
+#if defined(MACH) && !defined(__GNU__)
#define imake_ccflags "-DNOSTDHDRS"
#endif
-/* this is for OS/2 under EMX. This won't work with DOS */
-#if defined(__EMX__)
+/* this is for OS/2 under UNIXOS2. This won't work with DOS */
+#if defined(__UNIXOS2__)
#define imake_ccflags "-DBSD43"
#endif
+#if defined(__QNX__) && !defined(__QNXNTO__)
+#define imake_ccflags "-D__QNX__ -D_i386"
+#endif
+
+#if defined(__QNXNTO__)
+#define imake_ccflags "-D__QNXNTO__"
+#endif
+
#else /* not CCIMAKE */
#ifndef MAKEDEPEND
/*
@@ -187,14 +203,14 @@ in this Software without prior written authorization from The Open Group.
/*
* Step 3: FIXUP_CPP_WHITESPACE
- * If your cpp collapses tabs macro expansions into a single space and
+ * If your cpp collapses tabs in macro expansions into a single space and
* replaces escaped newlines with a space, define this symbol. This will
* cause imake to attempt to patch up the generated Makefile by looking
* for lines that have colons in them (this is why the rules file escapes
* all colons). One way to tell if you need this is to see whether or not
* your Makefiles have no tabs in them and lots of @@ strings.
*/
-#if defined(sun) || defined(SYSV) || defined(SVR4) || defined(hcx) || defined(WIN32) || defined(sco) || (defined(AMOEBA) && defined(CROSS_COMPILE))
+#if defined(sun) || defined(SYSV) || defined(SVR4) || defined(hcx) || defined(WIN32) || defined(sco) || (defined(AMOEBA) && defined(CROSS_COMPILE)) || defined(__QNX__) || defined(__sgi) || defined(__UNIXOS2__)
#define FIXUP_CPP_WHITESPACE
#endif
#ifdef WIN32
@@ -202,6 +218,18 @@ in this Software without prior written authorization from The Open Group.
#define INLINE_SYNTAX
#define MAGIC_MAKE_VARS
#endif
+#ifdef __minix_vmd
+#define FIXUP_CPP_WHITESPACE
+#endif
+
+#if defined(Lynx)
+/* On LynxOS 2.4.0 imake gets built with the old "legacy"
+ * /bin/cc which has a rather pedantic builtin preprocessor.
+ * Using a macro which is not #defined (as in Step 5
+ * below) flags an *error*
+ */
+#define __NetBSD_Version__ 0
+#endif
/*
* Step 4: USE_CC_E, DEFAULT_CC, DEFAULT_CPP
@@ -209,6 +237,16 @@ in this Software without prior written authorization from The Open Group.
* If use cc -E but want a different compiler, define DEFAULT_CC.
* If the cpp you need is not in /lib/cpp, define DEFAULT_CPP.
*/
+#if !defined (CROSSCOMPILE) || defined (CROSSCOMPILE_CPP)
+
+#if defined(__APPLE__)
+#define DEFAULT_CPP "/usr/bin/cpp"
+#define DEFAULT_CC "cc"
+#endif
+#if defined(Lynx) || defined(__Lynx__)
+#define DEFAULT_CC "gcc"
+#define USE_CC_E
+#endif
#ifdef hpux
#define USE_CC_E
#endif
@@ -219,6 +257,9 @@ in this Software without prior written authorization from The Open Group.
#ifdef apollo
#define DEFAULT_CPP "/usr/lib/cpp"
#endif
+#if defined(clipper) || defined(__clipper__)
+#define DEFAULT_CPP "/usr/lib/cpp"
+#endif
#if defined(_IBMR2) && !defined(DEFAULT_CPP)
#define DEFAULT_CPP "/usr/ccs/lib/cpp"
#endif
@@ -237,23 +278,44 @@ in this Software without prior written authorization from The Open Group.
#ifdef _CRAY
#define DEFAULT_CPP "/lib/pcpp"
#endif
-#if defined(__386BSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
+#if defined(__386BSD__)
#define DEFAULT_CPP "/usr/libexec/cpp"
#endif
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#define USE_CC_E
+#endif
#if defined(__sgi) && defined(__ANSI_CPP__)
#define USE_CC_E
#endif
-#ifdef MACH
+#if defined(MACH) && !defined(__GNU__)
#define USE_CC_E
#endif
#ifdef __minix_vmd
#define DEFAULT_CPP "/usr/lib/cpp"
#endif
-#if defined(__EMX__)
+#if defined(__UNIXOS2__)
/* expects cpp in PATH */
#define DEFAULT_CPP "cpp"
#endif
+#ifdef __CYGWIN__
+#define DEFAULT_CC "gcc"
+#define DEFAULT_CPP "/usr/bin/cpp"
+#endif
+#if defined (__QNX__)
+#ifdef __QNXNTO__
+#define DEFAULT_CPP "/usr/bin/cpp"
+#else
+#define DEFAULT_CPP "/usr/X11R6/bin/cpp"
+#endif
+#endif
+#if defined(__GNUC__) && !defined(USE_CC_E)
+#define USE_CC_E
+#ifndef DEFAULT_CC
+#define DEFAULT_CC "gcc"
+#endif
+#endif
+#endif /* !defined (CROSSCOMPILE) || defined (CROSSCOMPILE_CPP) */
/*
* Step 5: cpp_argv
* The following table contains the flags that should be passed
@@ -261,7 +323,7 @@ in this Software without prior written authorization from The Open Group.
* doesn't predefine any unique symbols, choose one and add it to the
* end of this table. Then, do the following:
*
- * a. Use this symbol in Imake.tmpl when setting MacroFile.
+ * a. Use this symbol in Imake.cf when setting MacroFile.
* b. Put this symbol in the definition of BootstrapCFlags in your
* <platform>.cf file.
* c. When doing a make World, always add "BOOTSTRAPCFLAGS=-Dsymbol"
@@ -272,15 +334,74 @@ in this Software without prior written authorization from The Open Group.
*/
#define ARGUMENTS 50 /* number of arguments in various arrays */
+#if !defined (CROSSCOMPILE) || defined (CROSSCOMPILE_CPP)
char *cpp_argv[ARGUMENTS] = {
"cc", /* replaced by the actual program to exec */
"-I.", /* add current directory to include path */
+#if !defined(__NetBSD_Version__) || __NetBSD_Version__ < 103080000
#ifdef unix
"-Uunix", /* remove unix symbol so that filename unix.c okay */
#endif
-#if defined(__386BSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(MACH)
+#endif
+#if defined(__386BSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
+ defined(__FreeBSD__) || defined(MACH) || defined(linux) || \
+ defined(__GNU__) || defined(__bsdi__) || defined(__GNUC__)
# ifdef __i386__
"-D__i386__",
+# if defined(__GNUC__) && (__GNUC__ >= 3)
+ "-m32",
+# endif
+# endif
+# ifdef __i486__
+ "-D__i486__",
+# endif
+# ifdef __i586__
+ "-D__i586__",
+# endif
+# ifdef __i686__
+ "-D__i686__",
+# endif
+# ifdef __k6__
+ "-D__k6__",
+# endif
+# ifdef __ia64__
+ "-D__ia64__",
+# endif
+# ifdef __x86_64__
+ "-D__x86_64__",
+# endif
+# ifdef __s390__
+ "-D__s390__",
+# endif
+# ifdef __alpha__
+ "-D__alpha__",
+# endif
+# ifdef __arm__
+ "-D__arm__",
+# endif
+# ifdef __s390x__
+ "-D__s390x__",
+# endif
+# ifdef __sparc__
+ "-D__sparc__",
+# endif
+# ifdef __m68k__
+ "-D__m68k__",
+# endif
+# ifdef __sh__
+ "-D__sh__",
+# endif
+# ifdef __sh3__
+ "-D__sh3__",
+# endif
+# ifdef __SH3__
+ "-D__SH3__",
+# endif
+# ifdef __SH4__
+ "-D__SH4__",
+# endif
+# ifdef __SH4NOFPU__
+ "-D__SH4_NOFPU__",
# endif
# ifdef __GNUC__
"-traditional",
@@ -356,9 +477,7 @@ char *cpp_argv[ARGUMENTS] = {
#endif /* MOTOROLA */
#if defined(M_UNIX) || defined(sco)
"-Dsco",
-# if defined(sco324)
- "-Dsco324",
-# endif
+ "-DSYSV",
#endif
#ifdef i386
"-Di386",
@@ -385,59 +504,56 @@ char *cpp_argv[ARGUMENTS] = {
# endif
# ifdef SCO
"-DSCO",
-# ifdef SCO324
- "-DSCO324",
+# ifdef _SCO_DS
+ "-DSCO325",
# endif
# endif
-# ifdef ESIX
+# endif
+# ifdef ESIX
"-DESIX",
-# endif
-# ifdef ATT
+# endif
+# ifdef ATT
"-DATT",
-# endif
-# ifdef DELL
+# endif
+# ifdef DELL
"-DDELL",
-# endif
# endif
#endif
-#ifdef SYSV386 /* System V/386 folks, obsolete */
+#ifdef SYSV386 /* System V/386 folks, obsolete */
"-Di386",
# ifdef SVR4
"-DSVR4",
# endif
-# ifdef SYSV
- "-DSYSV",
-# ifdef ISC
+# ifdef ISC
"-DISC",
-# ifdef ISC40
+# ifdef ISC40
"-DISC40", /* ISC 4.0 */
-# else
-# ifdef ISC202
+# else
+# ifdef ISC202
"-DISC202", /* ISC 2.0.2 */
-# else
-# ifdef ISC30
+# else
+# ifdef ISC30
"-DISC30", /* ISC 3.0 */
-# else
+# else
"-DISC22", /* ISC 2.2.1 */
-# endif
# endif
# endif
# endif
-# ifdef SCO
+# endif
+# ifdef SCO
"-DSCO",
-# ifdef SCO324
- "-DSCO324",
-# endif
+# ifdef _SCO_DS
+ "-DSCO325",
# endif
-# ifdef ESIX
+# endif
+# ifdef ESIX
"-DESIX",
-# endif
-# ifdef ATT
+# endif
+# ifdef ATT
"-DATT",
-# endif
-# ifdef DELL
+# endif
+# ifdef DELL
"-DDELL",
-# endif
# endif
#endif
#ifdef __osf__
@@ -448,6 +564,12 @@ char *cpp_argv[ARGUMENTS] = {
# ifdef __alpha
"-D__alpha",
# endif
+# ifdef __amiga__
+ "-D__amiga__",
+# endif
+# ifdef __alpha__
+ "-D__alpha__",
+# endif
# ifdef __i386__
"-D__i386__",
# endif
@@ -475,9 +597,28 @@ char *cpp_argv[ARGUMENTS] = {
"-DNCR", /* NCR */
#endif
#ifdef linux
- "-traditional",
"-Dlinux",
#endif
+#if defined(__CYGWIN__)
+ "-traditional",
+#endif
+#if defined(Lynx) || defined(__Lynx__)
+ "-traditional",
+#if 0
+ "-DLYNX", /* do we really need this?? */
+#endif
+ "-DLynx",
+# ifdef ppc
+ "-Dppc",
+# endif
+# if defined(m68k) || defined(M68k) || defined(m68040)
+ "-Dm68k",
+ "-DM68k",
+# endif
+# ifdef uSPARC1
+ "-Dsparc",
+# endif
+#endif
#ifdef __uxp__
"-D__uxp__",
#endif
@@ -492,13 +633,13 @@ char *cpp_argv[ARGUMENTS] = {
# ifdef CROSS_COMPILE
"-DCROSS_COMPILE",
# ifdef CROSS_i80386
- "-DCROSS_i80386",
+ "-Di80386",
# endif
# ifdef CROSS_sparc
- "-DCROSS_sparc",
+ "-Dsparc",
# endif
# ifdef CROSS_mc68000
- "-DCROSS_mc68000",
+ "-Dmc68000",
# endif
# else
# ifdef i80386
@@ -519,76 +660,309 @@ char *cpp_argv[ARGUMENTS] = {
"-Dminix",
#endif
-#if defined(__EMX__)
+#if defined(__UNIXOS2__)
"-traditional",
"-Demxos2",
#endif
+#ifdef MetroLink
+ "-DMetroLink",
+# ifdef SVR4
+ "-DSVR4",
+# endif
+# ifdef __powerpc__
+ "-D__powerpc__",
+# endif
+# ifdef PowerMAX_OS
+ "-DPowerMAX_OS",
+# endif
+#endif
+#if defined (__QNX__) && !defined(__QNXNTO__)
+ "-traditional",
+ "-D__QNX__",
+#endif
+#if defined(__QNXNTO__)
+ "-traditional",
+ "-D__QNXNTO__",
+#if defined(i386)
+ "-Di386",
+#endif
+#if defined(__i386__)
+ "-D__i386__",
+#endif
+#if defined(PPC)
+ "-DPPC",
+#endif
+#if defined(MIPS)
+ "-DMIPS",
+#endif
+#endif
+
+#if defined(__APPLE__)
+ "-D__APPLE__",
+ "-D__DARWIN__",
+# ifdef __ppc__
+ "-D__ppc__",
+# endif
+# ifdef __i386__
+ "-D__i386__",
+# endif
+#endif
};
+#endif /* CROSSCOMPILE */
/*
* Step 6: DEFAULT_OS_MAJOR_REV, DEFAULT_OS_MINOR_REV, DEFAULT_OS_TEENY_REV,
* and DEFAULT_OS_NAME.
- * If your systems provides a way to generate the default major,
+ * If your system provides a way to generate the default major,
* minor, teeny, or system names at runtime add commands below.
* The syntax of the _REV strings is 'f fmt' where 'f' is an argument
* you would give to uname, and "fmt" is a scanf() format string.
* Supported uname arguments are "snrvm", and if you specify multiple
* arguments they will be separated by spaces. No more than 5 arguments
* may be given. Unlike uname() order of arguments matters.
+ *
+ * DEFAULT_OS_MAJOR_REV_FROB, DEFAULT_OS_MINOR_REV_FROB,
+ * DEFAULT_OS_TEENY_REV_FROB, and DEFAULT_OS_NAME_FROB can be used to
+ * modify the results of the use of the various strings.
*/
-#if defined(aix)
+#if !defined CROSSCOMPILE || defined CROSSCOMPILE_CPP
+# if defined(aix)
/* uname -v returns "x" (e.g. "4"), and uname -r returns "y" (e.g. "1") */
-# define DEFAULT_OS_MAJOR_REV "v %[0-9]"
-# define DEFAULT_OS_MINOR_REV "r %[0-9]"
+# define DEFAULT_OS_MAJOR_REV "v %[0-9]"
+# define DEFAULT_OS_MINOR_REV "r %[0-9]"
/* No information available to generate default OSTeenyVersion value. */
-# define DEFAULT_OS_NAME "srvm %[^\n]"
-#elif defined(sun) || defined(sgi) || defined(ultrix) || defined(__uxp__) || defined(linux) || defined(sony)
+# define DEFAULT_OS_NAME "srvm %[^\n]"
+# elif defined(sun) || defined(sgi) || defined(ultrix) || defined(__uxp__) || defined(sony)
/* uname -r returns "x.y[.z]", e.g. "5.4" or "4.1.3" */
-# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
-# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
-# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"
-# define DEFAULT_OS_NAME "srvm %[^\n]"
-#elif defined(hpux)
+# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
+# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
+# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"
+# define DEFAULT_OS_NAME "srvm %[^\n]"
+# elif defined(hpux)
/* uname -r returns "W.x.yz", e.g. "B.10.01" */
-# define DEFAULT_OS_MAJOR_REV "r %*[^.].%[0-9]"
-# define DEFAULT_OS_MINOR_REV "r %*[^.].%*d.%1s"
-# define DEFAULT_OS_TEENY_REV "r %*[^.].%*d.%*c%[0-9]"
-# define DEFAULT_OS_NAME "srvm %[^\n]"
-#elif defined(USL) || defined(__USLC__)
+# define DEFAULT_OS_MAJOR_REV "r %*[^.].%[0-9]"
+# define DEFAULT_OS_MINOR_REV "r %*[^.].%*d.%1s"
+# define DEFAULT_OS_TEENY_REV "r %*[^.].%*d.%*c%[0-9]"
+# define DEFAULT_OS_NAME "srvm %[^\n]"
+# elif defined(USL) || defined(__USLC__)
+/* uname -v returns "x.yz" or "x.y.z", e.g. "2.02" or "2.1.2". */
+# define DEFAULT_OS_MAJOR_REV "v %[0-9]"
+# define DEFAULT_OS_MINOR_REV "v %*d.%1s"
+# define DEFAULT_OS_TEENY_REV "v %*d.%*c%[.0-9]"
+# define DEFAULT_OS_NAME "srvm %[^\n]"
+# elif defined(__APPLE__)
/* uname -v returns "x.yz" or "x.y.z", e.g. "2.02" or "2.1.2". */
-# define DEFAULT_OS_MAJOR_REV "v %[0-9]"
-# define DEFAULT_OS_MINOR_REV "v %*d.%1s"
-# define DEFAULT_OS_TEENY_REV "v %*d.%*c%[.0-9]"
-# define DEFAULT_OS_NAME "srvm %[^\n]"
-#elif defined(__osf__)
+# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
+# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
+# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]" /* this will just get 0 */
+# define DEFAULT_OS_NAME "s %[^\n]"
+# elif defined(__osf__)
/* uname -r returns "Wx.y", e.g. "V3.2" or "T4.0" */
-# define DEFAULT_OS_MAJOR_REV "r %*[^0-9]%[0-9]"
-# define DEFAULT_OS_MINOR_REV "r %*[^.].%[0-9]"
-# define DEFAULT_OS_NAME "srvm %[^\n]"
-#elif defined(__uxp__)
+# define DEFAULT_OS_MAJOR_REV "r %*[^0-9]%[0-9]"
+# define DEFAULT_OS_MINOR_REV "r %*[^.].%[0-9]"
+# define DEFAULT_OS_NAME "srvm %[^\n]"
+# elif defined(__uxp__)
/* NOTE: "x.y[.z]" above handles UXP/DF. This is a sample alternative. */
/* uname -v returns "VxLy Yzzzzz ....", e.g. "V20L10 Y95021 Increment 5 ..." */
-# define DEFAULT_OS_MAJOR_REV "v V%[0-9]"
-# define DEFAULT_OS_MINOR_REV "v V%*dL%[0-9]"
-# define DEFAULT_OS_NAME "srvm %[^\n]"
-#elif defined(__FreeBSD__)
-/* NetBSD, OpenBSD, 386BSD, and BSD/OS too? */
+# define DEFAULT_OS_MAJOR_REV "v V%[0-9]"
+# define DEFAULT_OS_MINOR_REV "v V%*dL%[0-9]"
+# define DEFAULT_OS_NAME "srvm %[^\n]"
+# elif defined(linux) || defined(__bsdi__)
+# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
+# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
+# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"
+# define DEFAULT_OS_NAME "srm %[^\n]"
+# if defined(linux) && defined (CROSSCOMPILE_CPP)
+# define CROSS_UTS_SYSNAME "Linux"
+# include <linux/version.h>
+# define CROSS_UTS_RELEASE UTS_RELEASE
+# endif
+# elif defined(__CYGWIN__)
+# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
+# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
+# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"
+# define DEFAULT_OS_NAME "srm %[^\n]"
+# if defined(__CYGWIN__) && defined (CROSSCOMPILE_CPP)
+# define CROSS_UTS_SYSNAME "Cygwin"
+# include <cygwin/version.h>
+# define CROSS_UTS_RELEASE "1.3.12"
+# endif
+# elif defined(__GNU__)
+# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
+# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
+# define DEFAULT_OS_NAME "srm %[^\n]"
+# elif defined(ISC)
+/* ISC all Versions ? */
+/* uname -r returns "x.y", e.g. "3.2" ,uname -v returns "x" e.g. "2" */
+# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
+# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
+# define DEFAULT_OS_TEENY_REV "v %[0-9]"
+/* # define DEFAULT_OS_NAME "srm %[^\n]" */ /* Not useful on ISC */
+# elif defined(__FreeBSD__) || defined(__OpenBSD__)
+/* BSD/OS too? */
/* uname -r returns "x.y[.z]-mumble", e.g. "2.1.5-RELEASE" or "2.2-0801SNAP" */
-# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
-# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
-# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"
-# define DEFAULT_OS_NAME "srm %[^\n]"
-#elif defined(_SEQUENT_)
+# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
+# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
+# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"
+# define DEFAULT_OS_NAME "srm %[^\n]"
+# if defined(__FreeBSD__)
+/* Use an alternate way to find the teeny version for -STABLE, -SNAP versions */
+# ifndef CROSSCOMPILE_CPP
+# define DEFAULT_OS_TEENY_REV_FROB(buf, size) \
+ do { \
+ if (*buf == 0) { \
+ int __mib[2]; \
+ size_t __len; \
+ int __osrel; \
+ \
+ __mib[0] = CTL_KERN; \
+ __mib[1] = KERN_OSRELDATE; \
+ __len = sizeof(__osrel); \
+ sysctl(__mib, 2, &__osrel, &__len, NULL, 0); \
+ if (__osrel < 210000) { \
+ if (__osrel < 199607) \
+ buf[0] = '0'; \
+ else if (__osrel < 199612) \
+ buf[0] = '5'; \
+ else if (__osrel == 199612) \
+ buf[0] = '6'; \
+ else \
+ buf[0] = '8'; /* guess */ \
+ } else { \
+ buf[0] = ((__osrel / 1000) % 10) + '0'; \
+ } \
+ buf[1] = 0; \
+ } \
+ } while (0)
+# endif
+# else
+ /* OpenBSD - Add DEFAULT_MACHINE_ARCHITECTURE */
+# define DEFAULT_MACHINE_ARCHITECTURE "m %[^\n]"
+# endif
+# elif defined(__NetBSD__)
+/*
+ * uname -r returns "x.y([ABCD...]|_mumble)", e.g.:
+ * 1.2 1.2_BETA 1.2A 1.2B
+ *
+ * That means that we have to do something special to turn the
+ * TEENY revision into a form that we can use (i.e., a string of
+ * decimal digits).
+ *
+ * We also frob the name DEFAULT_OS_NAME so that it looks like the
+ * 'standard' NetBSD name for the version, e.g. "NetBSD/i386 1.2B" for
+ * NetBSD 1.2B on an i386.
+ */
+# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
+# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
+# define DEFAULT_OS_TEENY_REV "r %*d.%*d%[A-Z]"
+# define DEFAULT_OS_TEENY_REV_FROB(buf, size) \
+ do { \
+ int teeny = 0; \
+ char *ptr = (buf); \
+ \
+ while (*ptr >= 'A' && *ptr <= 'Z') /* sanity check */ \
+ teeny = teeny * 26 + (int)(*ptr++ - 'A'); \
+ \
+ snprintf((buf), (size), "%d", teeny + 1); \
+ } while (0)
+# define DEFAULT_OS_NAME "smr %[^\n]"
+# define DEFAULT_OS_NAME_FROB(buf, size) \
+ do { \
+ char *__sp; \
+ if ((__sp = strchr((buf), ' ')) != NULL) \
+ *__sp = '/'; \
+ } while (0)
+# elif defined(__Lynx__) || defined(Lynx)
+/* Lynx 2.4.0 /bin/cc doesn't like #elif */
+# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
+# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
+# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"
+# define DEFAULT_OS_NAME "srm %[^\n]"
+# elif defined(_SEQUENT_)
/* uname -v returns 'Vx.y.z', e.g. 'V4.4.2' */
-# define DEFAULT_OS_MAJOR_REV "v V%[0-9]"
-# define DEFAULT_OS_MINOR_REV "v V%*d.%[0-9]"
-# define DEFAULT_OS_TEENY_REV "v V%*d.%*d.%[0-9]"
-# define DEFAULT_OS_NAME "s %[^\n]"
-#endif
+# define DEFAULT_OS_MAJOR_REV "v V%[0-9]"
+# define DEFAULT_OS_MINOR_REV "v V%*d.%[0-9]"
+# define DEFAULT_OS_TEENY_REV "v V%*d.%*d.%[0-9]"
+# define DEFAULT_OS_NAME "s %[^\n]"
+# endif
+#endif /* !defined CROSSCOMPILE || defined CROSSCOMPILE_CPP */
+
+# if defined (CROSSCOMPILE_CPP)
+# ifndef CROSS_UTS_SYSNAME
+char *cross_uts_sysname = "";
+# else
+char *cross_uts_sysname = CROSS_UTS_SYSNAME;
+# endif
+# ifndef CROSS_UTS_RELEASE
+char* cross_uts_release = "";
+# else
+char* cross_uts_release = CROSS_UTS_RELEASE;
+# endif
+# ifndef CROSS_UTS_MACHINE
+char *cross_uts_machine = "";
+# else
+char *cross_uts_machine = CROSS_UTS_MACHINE;
+# endif
+# ifndef CROSS_UTS_VERSION
+char * cross_uts_version = "";
+# else
+char * cross_uts_version = CROSS_UTS_VERSION;
+# endif
+# ifdef DEFAULT_OS_NAME
+char *defaultOsName = DEFAULT_OS_NAME;
+# else
+char *defaultOsName = NULL;
+# endif
+# ifdef DEFAULT_OS_MAJOR_REV
+char *defaultOsMajorRev = DEFAULT_OS_MAJOR_REV;
+# else
+char *defaultOsMajorRev = NULL;
+# endif
+# ifdef DEFAULT_OS_MINOR_REV
+char *defaultOsMinorRev = DEFAULT_OS_MINOR_REV;
+# else
+char *defaultOsMinorRev = NULL;
+# endif
+# ifdef DEFAULT_OS_TEENY_REV
+char *defaultOsTeenyRev = DEFAULT_OS_TEENY_REV;
+# else
+char *defaultOsTeenyRev = NULL;
+# endif
+# ifdef DEFAULT_MACHINE_ARCHITECTURE
+char *defaultMachineArchitecture = DEFAULT_MACHINE_ARCHITECTURE;
+# else
+char *defaultMachineArchitecture = NULL;
+# endif
+# ifdef DEFAULT_OS_NAME_FROB
+void defaultOsNameFrob(char *buf, int size)
+{DEFAULT_OS_NAME_FROB(buf,size)}
+# else
+void (*defaultOsNameFrob)(char *buf, int size) = NULL;
+# endif
+# ifdef DEFAULT_OS_MAJOR_REV_FROB
+void defaultOsMajorRevFrob(char *buf, int size)
+{DEFAULT_OS_MAJOR_REV_FROB(buf,size)}
+# else
+void (*defaultOsMajorRevFrob)(char *buf, int size) = NULL;
+# endif
+# ifdef DEFAULT_OS_MINOR_REV_FROB
+void defaultOsMinorRevFrob(char *buf, int size)
+{DEFAULT_OS_MINOR_REV_FROB(buf,size)}
+# else
+void (*defaultOsMinorRevFrob)(char *buf, int size) = NULL;
+# endif
+# ifdef DEFAULT_OS_TEENY_REV_FROB
+void defaultOsTeenyRevFrob(char *buf, int size)
+{DEFAULT_OS_TEENY_REV_FROB(buf,size)}
+# else
+void (*defaultOsTeenyRevFrob)(char *buf, int size) = NULL;
+# endif
+# endif /* CROSSCOMPILE_CPP */
#else /* else MAKEDEPEND */
+#if !defined (CROSSCOMPILE) || defined (CROSSCOMPILE_CPP)
/*
* Step 7: predefs
* If your compiler and/or preprocessor define any specific symbols, add
@@ -599,6 +973,12 @@ struct symtab predefs[] = {
#ifdef apollo
{"apollo", "1"},
#endif
+#if defined(clipper) || defined(__clipper__)
+ {"clipper", "1"},
+ {"__clipper__", "1"},
+ {"clix", "1"},
+ {"__clix__", "1"},
+#endif
#ifdef ibm032
{"ibm032", "1"},
#endif
@@ -675,10 +1055,25 @@ struct symtab predefs[] = {
{"mc68020", "1"},
#endif
#ifdef __GNUC__
+# if __GNUC__ == 1
{"__GNUC__", "1"},
+# elif __GNUC__ == 2
+ {"__GNUC__", "2"},
+# elif __GNUC__ == 3
+ {"__GNUC__", "3"},
+# endif
+#endif
+#ifdef __STRICT_ANSI__
+ {"__STRICT_ANSI__", "1"},
#endif
-#if __STDC__
+#ifdef __STDC__
+# if __STDC__ == 0
+ {"__STDC__", "0"},
+# elif __STDC__ == 1
{"__STDC__", "1"},
+# elif __STDC__ == 2
+ {"__STDC__", "2"},
+# endif
#endif
#ifdef __HIGHC__
{"__HIGHC__", "1"},
@@ -713,6 +1108,12 @@ struct symtab predefs[] = {
#ifdef m68k
{"m68k", "1"},
#endif
+#ifdef M68k
+ {"M68k", "1"},
+#endif
+#ifdef __m68k__
+ {"__m68k__", "1"},
+#endif
#ifdef m88k
{"m88k", "1"},
#endif
@@ -740,9 +1141,15 @@ struct symtab predefs[] = {
#ifdef __osf__
{"__osf__", "1"},
#endif
+#ifdef __amiga__
+ {"__amiga__", "1"},
+#endif
#ifdef __alpha
{"__alpha", "1"},
#endif
+#ifdef __alpha__
+ {"__alpha__", "1"},
+#endif
#ifdef __DECC
{"__DECC", "1"},
#endif
@@ -804,12 +1211,188 @@ struct symtab predefs[] = {
#ifdef __NetBSD__
{"__NetBSD__", "1"},
#endif
-#ifdef __EMX__
- {"__EMX__", "1"},
+#ifdef __GNU__
+ {"__GNU__", "1"},
+#endif
+#ifdef __ELF__
+ {"__ELF__", "1"},
+#endif
+#ifdef __UNIXOS2__
+ {"__UNIXOS2__", "1"},
+#endif
+#if defined(__QNX__)
+ {"__QNX__", "1"},
+#endif
+#ifdef __QNXNTO__
+ {"__QNXNTO__", "1"},
+#endif
+# ifdef __powerpc__
+ {"__powerpc__", "1"},
+# endif
+# ifdef PowerMAX_OS
+ {"PowerMAX_OS", "1"},
+# endif
+# ifdef ia64
+ {"ia64", "1"},
+# endif
+# ifdef __ia64__
+ {"__ia64__", "1"},
+# endif
+# ifdef x86_64
+ {"x86_64", "1"},
+# endif
+# ifdef __x86_64__
+ {"__x86_64__", "1"},
+# endif
+# ifdef __i386__
+ {"__i386__", "1"},
+# endif
+# ifdef __i486__
+ {"__i486__", "1"},
+# endif
+# ifdef __i586__
+ {"__i586__", "1"},
+# endif
+# ifdef __i686__
+ {"__i686__", "1"},
+# endif
+# ifdef __k6__
+ {"__k6__", "1"},
+# endif
+# ifdef i386
+ {"i386", "1"},
+# endif
+# ifdef i486
+ {"i486", "1"},
+# endif
+# ifdef i586
+ {"i586", "1"},
+# endif
+# ifdef i686
+ { "i686", "1"},
+# endif
+# ifdef k6
+ {"k6", "1"},
+# endif
+# ifdef sparc
+ {"sparc", "1"},
+# endif
+# ifdef __sparc__
+ {"__sparc__", "1"},
+# endif
+# ifdef __s390__
+ {"__s390__", "1"},
+# endif
+# ifdef __sh__
+ {"__sh__", "1"},
+# endif
+# ifdef __sh3_
+ {"__sh3__", "1"},
+# endif
+# ifdef __SH3__
+ {"__SH3__", "1"},
+# endif
+# ifdef __SH4__
+ {"__SH4__", "1"},
+# endif
+# ifdef __SH4NOFPU__
+ {"__SH4NOFPU__", "1"},
+# endif
+#if defined(__ppc__)
+ {"__ppc__", "1"},
+#endif
+#if defined(__BIG_ENDIAN__)
+ {"__BIG_ENDIAN__", "1"},
+#endif
+#if defined(__LITTLE_ENDIAN__)
+ {"__LITTLE_ENDIAN__", "1"},
#endif
+
+
/* add any additional symbols before this line */
{NULL, NULL}
};
-
+#endif /* CROSSCOMPILE */
#endif /* MAKEDEPEND */
+
+# ifndef MAKEDEPEND
+# if defined (CROSSCOMPILE_CPP)
+# ifdef USE_CC_E
+boolean crosscompile_use_cc_e = TRUE;
+# ifdef DEFAULT_CC
+char* crosscompile_cpp = DEFAULT_CC;
+# else
+char* crosscompile_cpp = "cc";
+# endif
+# else
+boolean crosscompile_use_cc_e = FALSE;
+# ifdef DEFAULT_CPP
+char* crosscompile_cpp = DEFAULT_CPP;
+# else
+char* crosscompile_cpp = "cpp";
+# endif
+# endif
+# ifdef FIXUP_CPP_WHITESPACE
+boolean fixup_whitespace = TRUE;
+# else
+boolean fixup_whitespace = FALSE;
+# endif
+# ifdef REMOVE_CPP_LEADSPACE
+boolean remove_cpp_leadspace = TRUE;
+# else
+boolean remove_cpp_leadspace = FALSE;
+# endif
+# ifdef INLINE_SYNTAX
+boolean inline_syntax = TRUE;
+# else
+boolean inline_syntax = FALSE;
+# endif
+# ifdef MAGIC_MAKE_VARS
+boolean magic_make_vars = TRUE;
+# else
+boolean magic_make_vars = FALSE;
+# endif
+
+typedef enum {
+ unknown,
+ freeBSD,
+ netBSD,
+ LinuX,
+ emx,
+ win32
+} System;
+
+# ifdef linux
+System sys = LinuX;
+# elif defined __FreeBSD__
+System sys = freebsd;
+# elif defined __NetBSD__
+System sys = netBSD;
+# elif defined __EMX__
+System sys = emx;
+# elif defined WIN32
+System sys = win32;
+# else
+System sys = unknown;
+# endif
+
+# if defined __GNUC__
+int gnu_c = __GNUC__;
+int gnu_c_minor = __GNUC_MINOR__;
+# else
+int gnu_c = 0;
+int gnu_c_minor = -1;
+# endif
+# if defined linux
+# include <features.h>
+int glibc_major = __GLIBC__ + 4;
+int glibc_minor = __GLIBC_MINOR__;
+# else
+int glibc_major = 0;
+int glibc_minor = -1;
+# endif
+# endif /* !CROSSCOMPILE || CROSSCOMPILE_CPP */
+
+# endif /* MAKEDEPEND */
+
#endif /* CCIMAKE */
diff --git a/include.c b/include.c
index 4b74341..4e32800 100644
--- a/include.c
+++ b/include.c
@@ -24,38 +24,37 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
+/* $XFree86: xc/config/makedepend/include.c,v 3.7 2001/12/14 19:53:20 dawes Exp $ */
#include "def.h"
extern struct inclist inclist[ MAXFILES ],
- *inclistp;
-extern char *includedirs[ ];
+ *inclistp, *inclistnext;
+extern char *includedirs[ ],
+ **includedirsnext;
extern char *notdotdot[ ];
extern boolean show_where_not;
extern boolean warn_multiple;
-boolean
-isdot(p)
- register char *p;
+static boolean
+isdot(char *p)
{
if(p && *p++ == '.' && *p++ == '\0')
return(TRUE);
return(FALSE);
}
-boolean
-isdotdot(p)
- register char *p;
+static boolean
+isdotdot(char *p)
{
if(p && *p++ == '.' && *p++ == '.' && *p++ == '\0')
return(TRUE);
return(FALSE);
}
-boolean
-issymbolic(dir, component)
- register char *dir, *component;
+static boolean
+issymbolic(char *dir, char *component)
{
#ifdef S_IFLNK
struct stat st;
@@ -81,9 +80,8 @@ issymbolic(dir, component)
* Any of the 'x/..' sequences within the name can be eliminated.
* (but only if 'x' is not a symbolic link!!)
*/
-void
-remove_dotdot(path)
- char *path;
+static void
+remove_dotdot(char *path)
{
register char *end, *from, *to, **cp;
char *components[ MAXFILES ],
@@ -154,8 +152,8 @@ remove_dotdot(path)
/*
* Add an include file to the list of those included by 'file'.
*/
-struct inclist *newinclude(newfile, incstring)
- register char *newfile, *incstring;
+struct inclist *
+newinclude(char *newfile, char *incstring)
{
register struct inclist *ip;
@@ -172,12 +170,12 @@ struct inclist *newinclude(newfile, incstring)
else
ip->i_incstring = copy(incstring);
+ inclistnext = inclistp;
return(ip);
}
void
-included_by(ip, newfile)
- register struct inclist *ip, *newfile;
+included_by(struct inclist *ip, struct inclist *newfile)
{
register int i;
@@ -227,7 +225,7 @@ included_by(ip, newfile)
}
void
-inc_clean ()
+inc_clean (void)
{
register struct inclist *ip;
@@ -236,84 +234,85 @@ inc_clean ()
}
}
-struct inclist *inc_path(file, include, dot)
- register char *file,
- *include;
- boolean dot;
+struct inclist *
+inc_path(char *file, char *include, int type)
{
- static char path[ BUFSIZ ];
+ static char path[ BUFSIZ ];
register char **pp, *p;
register struct inclist *ip;
- struct stat st;
- boolean found = FALSE;
+ struct stat st;
/*
* Check all previously found include files for a path that
* has already been expanded.
*/
- for (ip = inclist; ip->i_file; ip++)
- if ((strcmp(ip->i_incstring, include) == 0) &&
- !(ip->i_flags & INCLUDED_SYM))
- {
- found = TRUE;
- break;
- }
+ if ((type == INCLUDE) || (type == INCLUDEDOT))
+ inclistnext = inclist;
+ ip = inclistnext;
+
+ for (; ip->i_file; ip++) {
+ if ((strcmp(ip->i_incstring, include) == 0) &&
+ !(ip->i_flags & INCLUDED_SYM)) {
+ inclistnext = ip + 1;
+ return ip;
+ }
+ }
- /*
- * If the path was surrounded by "" or is an absolute path,
- * then check the exact path provided.
- */
- if (!found && (dot || *include == '/')) {
- if (stat(include, &st) == 0) {
- ip = newinclude(include, include);
- found = TRUE;
+ if (inclistnext == inclist) {
+ /*
+ * If the path was surrounded by "" or is an absolute path,
+ * then check the exact path provided.
+ */
+ if ((type == INCLUDEDOT) ||
+ (type == INCLUDENEXTDOT) ||
+ (*include == '/')) {
+ if (stat(include, &st) == 0)
+ return newinclude(include, include);
+ if (show_where_not)
+ warning1("\tnot in %s\n", include);
+ }
+
+ /*
+ * If the path was surrounded by "" see if this include file is
+ * in the directory of the file being parsed.
+ */
+ if ((type == INCLUDEDOT) || (type == INCLUDENEXTDOT)) {
+ for (p=file+strlen(file); p>file; p--)
+ if (*p == '/')
+ break;
+ if (p == file) {
+ strcpy(path, include);
+ } else {
+ strncpy(path, file, (p-file) + 1);
+ path[ (p-file) + 1 ] = '\0';
+ strcpy(path + (p-file) + 1, include);
+ }
+ remove_dotdot(path);
+ if (stat(path, &st) == 0)
+ return newinclude(path, include);
+ if (show_where_not)
+ warning1("\tnot in %s\n", path);
}
- else if (show_where_not)
- warning1("\tnot in %s\n", include);
}
/*
- * If the path was surrounded by "" see if this include file is in the
- * directory of the file being parsed.
+ * Check the include directories specified. Standard include dirs
+ * should be at the end.
*/
- if (!found && dot) {
- for (p=file+strlen(file); p>file; p--)
- if (*p == '/')
- break;
- if (p == file)
- strcpy(path, include);
- else {
- strncpy(path, file, (p-file) + 1);
- path[ (p-file) + 1 ] = '\0';
- strcpy(path + (p-file) + 1, include);
- }
+ if ((type == INCLUDE) || (type == INCLUDEDOT))
+ includedirsnext = includedirs;
+ pp = includedirsnext;
+
+ for (; *pp; pp++) {
+ sprintf(path, "%s/%s", *pp, include);
remove_dotdot(path);
if (stat(path, &st) == 0) {
- ip = newinclude(path, include);
- found = TRUE;
+ includedirsnext = pp + 1;
+ return newinclude(path, include);
}
- else if (show_where_not)
+ if (show_where_not)
warning1("\tnot in %s\n", path);
}
- /*
- * Check the include directories specified. (standard include dir
- * should be at the end.)
- */
- if (!found)
- for (pp = includedirs; *pp; pp++) {
- sprintf(path, "%s/%s", *pp, include);
- remove_dotdot(path);
- if (stat(path, &st) == 0) {
- ip = newinclude(path, include);
- found = TRUE;
- break;
- }
- else if (show_where_not)
- warning1("\tnot in %s\n", path);
- }
-
- if (!found)
- ip = NULL;
- return(ip);
+ return NULL;
}
diff --git a/main.c b/main.c
index bfb6d26..73b30b0 100644
--- a/main.c
+++ b/main.c
@@ -24,6 +24,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
+/* $XFree86: xc/config/makedepend/main.c,v 3.31 2003/01/17 17:09:49 tsi Exp $ */
#include "def.h"
#ifdef hpux
@@ -44,14 +45,26 @@ in this Software without prior written authorization from The Open Group.
#endif
#endif
-#if NeedVarargsPrototypes
#include <stdarg.h>
+
+#ifdef MINIX
+#define USE_CHMOD 1
#endif
#ifdef DEBUG
int _debugmask;
#endif
+/* #define DEBUG_DUMP */
+#ifdef DEBUG_DUMP
+#define DBG_PRINT(args...) fprintf(args)
+#else
+#define DBG_PRINT(args...) /* empty */
+#endif
+
+#define DASH_INC_PRE "#include \""
+#define DASH_INC_POST "\""
+
char *ProgramName;
char *directives[] = {
@@ -71,6 +84,7 @@ char *directives[] = {
"elif",
"eject",
"warning",
+ "include_next",
NULL
};
@@ -80,28 +94,28 @@ char *directives[] = {
struct inclist inclist[ MAXFILES ],
*inclistp = inclist,
+ *inclistnext = inclist,
maininclist;
-char *filelist[ MAXFILES ];
-char *includedirs[ MAXDIRS + 1 ];
-char *notdotdot[ MAXDIRS ];
-char *objprefix = "";
-char *objsuffix = OBJSUFFIX;
-char *startat = "# DO NOT DELETE";
-int width = 78;
-boolean append = FALSE;
-boolean printed = FALSE;
-boolean verbose = FALSE;
-boolean show_where_not = FALSE;
-boolean warn_multiple = FALSE; /* Warn on multiple includes of same file */
-
-void freefile();
-void redirect();
-#if !NeedVarargsPrototypes
-void fatalerr();
-void warning();
-void warning1();
-#endif
+static char *filelist[ MAXFILES ];
+char *includedirs[ MAXDIRS + 1 ],
+ **includedirsnext = includedirs;
+char *notdotdot[ MAXDIRS ];
+static int cmdinc_count = 0;
+static char *cmdinc_list[ 2 * MAXINCFILES ];
+char *objprefix = "";
+char *objsuffix = OBJSUFFIX;
+static char *startat = "# DO NOT DELETE";
+int width = 78;
+static boolean append = FALSE;
+boolean printed = FALSE;
+boolean verbose = FALSE;
+boolean show_where_not = FALSE;
+/* Warn on multiple includes of same file */
+boolean warn_multiple = FALSE;
+
+static void setfile_cmdinc(struct filepointer *filep, long count, char **list);
+static void redirect(char *line, char *makefile);
static
#ifdef SIGNALRETURNSINT
@@ -109,19 +123,18 @@ int
#else
void
#endif
-catch (sig)
- int sig;
+catch (int sig)
{
fflush (stdout);
fatalerr ("got signal %d\n", sig);
}
-#if defined(USG) || (defined(i386) && defined(SYSV)) || defined(WIN32)
+#if defined(USG) || (defined(i386) && defined(SYSV)) || defined(WIN32) || defined(__UNIXOS2__) || defined(Lynx_22) || defined(__CYGWIN__)
#define USGISH
#endif
#ifndef USGISH
-#ifndef _POSIX_SOURCE
+#ifdef X_NOT_POSIX
#define sigaction sigvec
#define sa_handler sv_handler
#define sa_mask sv_mask
@@ -130,19 +143,20 @@ catch (sig)
struct sigaction sig_act;
#endif /* USGISH */
-main(argc, argv)
- int argc;
- char **argv;
+int
+main(int argc, char *argv[])
{
- register char **fp = filelist;
- register char **incp = includedirs;
- register char *p;
- register struct inclist *ip;
+ char **fp = filelist;
+ char **incp = includedirs;
+ char *p;
+ struct inclist *ip;
char *makefile = NULL;
struct filepointer *filecontent;
struct symtab *psymp = predefs;
char *endmarker = NULL;
char *defincdir = NULL;
+ char **undeflist = NULL;
+ int numundefs = 0, i;
ProgramName = argv[0];
@@ -237,6 +251,20 @@ main(argc, argv)
argc--;
}
break;
+ case 'U':
+ /* Undef's override all -D's so save them up */
+ numundefs++;
+ if (numundefs == 1)
+ undeflist = malloc(sizeof(char *));
+ else
+ undeflist = realloc(undeflist,
+ numundefs * sizeof(char *));
+ if (argv[0][2] == '\0') {
+ argv++;
+ argc--;
+ }
+ undeflist[numundefs - 1] = argv[0] + 2;
+ break;
case 'Y':
defincdir = argv[0]+2;
break;
@@ -310,21 +338,76 @@ main(argc, argv)
case 'O':
case 'g':
break;
+ case 'i':
+ if (strcmp(&argv[0][1],"include") == 0) {
+ char *buf;
+ if (argc<2)
+ fatalerr("option -include is a "
+ "missing its parameter\n");
+ if (cmdinc_count >= MAXINCFILES)
+ fatalerr("Too many -include flags.\n");
+ argc--;
+ argv++;
+ buf = malloc(strlen(DASH_INC_PRE) +
+ strlen(argv[0]) +
+ strlen(DASH_INC_POST) + 1);
+ if(!buf)
+ fatalerr("out of memory at "
+ "-include string\n");
+ cmdinc_list[2 * cmdinc_count + 0] = argv[0];
+ cmdinc_list[2 * cmdinc_count + 1] = buf;
+ cmdinc_count++;
+ break;
+ }
+ /* intentional fall through */
default:
if (endmarker) break;
/* fatalerr("unknown opt = %s\n", argv[0]); */
warning("ignoring option %s\n", argv[0]);
}
}
+ /* Now do the undefs from the command line */
+ for (i = 0; i < numundefs; i++)
+ undefine(undeflist[i], &maininclist);
+ if (numundefs > 0)
+ free(undeflist);
+
if (!defincdir) {
#ifdef PREINCDIR
if (incp >= includedirs + MAXDIRS)
fatalerr("Too many -I flags.\n");
*incp++ = PREINCDIR;
#endif
+#ifdef __UNIXOS2__
+ {
+ char *emxinc = getenv("C_INCLUDE_PATH");
+ /* can have more than one component */
+ if (emxinc) {
+ char *beg, *end;
+ beg= (char*)strdup(emxinc);
+ for (;;) {
+ end = (char*)strchr(beg,';');
+ if (end) *end = 0;
+ if (incp >= includedirs + MAXDIRS)
+ fatalerr("Too many include dirs\n");
+ *incp++ = beg;
+ if (!end) break;
+ beg = end+1;
+ }
+ }
+ }
+#else /* !__UNIXOS2__, does not use INCLUDEDIR at all */
if (incp >= includedirs + MAXDIRS)
fatalerr("Too many -I flags.\n");
*incp++ = INCLUDEDIR;
+#endif
+
+#ifdef EXTRAINCDIR
+ if (incp >= includedirs + MAXDIRS)
+ fatalerr("Too many -I flags.\n");
+ *incp++ = EXTRAINCDIR;
+#endif
+
#ifdef POSTINCDIR
if (incp >= includedirs + MAXDIRS)
fatalerr("Too many -I flags.\n");
@@ -360,7 +443,7 @@ main(argc, argv)
#endif
#else
sig_act.sa_handler = catch;
-#ifdef _POSIX_SOURCE
+#if defined(_POSIX_SOURCE) || !defined(X_NOT_POSIX)
sigemptyset(&sig_act.sa_mask);
sigaddset(&sig_act.sa_mask, SIGINT);
sigaddset(&sig_act.sa_mask, SIGQUIT);
@@ -407,7 +490,9 @@ main(argc, argv)
* now peruse through the list of files.
*/
for(fp=filelist; *fp; fp++) {
+ DBG_PRINT(stderr,"file: %s\n",*fp);
filecontent = getfile(*fp);
+ setfile_cmdinc(filecontent, cmdinc_count, cmdinc_list);
ip = newinclude(*fp, (char *)NULL);
find_includes(filecontent, ip, ip, 0, FALSE);
@@ -417,17 +502,34 @@ main(argc, argv)
}
if (printed)
printf("\n");
- exit(0);
+ return 0;
}
-struct filepointer *getfile(file)
- char *file;
+#ifdef __UNIXOS2__
+/*
+ * eliminate \r chars from file
+ */
+static int
+elim_cr(char *buf, int sz)
+{
+ int i,wp;
+ for (i= wp = 0; i<sz; i++) {
+ if (buf[i] != '\r')
+ buf[wp++] = buf[i];
+ }
+ return wp;
+}
+#endif
+
+struct filepointer *
+getfile(char *file)
{
- register int fd;
+ int fd;
struct filepointer *content;
struct stat st;
content = (struct filepointer *)malloc(sizeof(struct filepointer));
+ content->f_name = file;
if ((fd = open(file, O_RDONLY)) < 0) {
warning("cannot open \"%s\"\n", file);
content->f_p = content->f_base = content->f_end = (char *)malloc(1);
@@ -440,36 +542,48 @@ struct filepointer *getfile(file)
fatalerr("cannot allocate mem\n");
if ((st.st_size = read(fd, content->f_base, st.st_size)) < 0)
fatalerr("failed to read %s\n", file);
+#ifdef __UNIXOS2__
+ st.st_size = elim_cr(content->f_base,st.st_size);
+#endif
close(fd);
content->f_len = st.st_size+1;
content->f_p = content->f_base;
content->f_end = content->f_base + st.st_size;
*content->f_end = '\0';
content->f_line = 0;
+ content->cmdinc_count = 0;
+ content->cmdinc_list = NULL;
+ content->cmdinc_line = 0;
return(content);
}
void
-freefile(fp)
- struct filepointer *fp;
+setfile_cmdinc(struct filepointer* filep, long count, char** list)
+{
+ filep->cmdinc_count = count;
+ filep->cmdinc_list = list;
+ filep->cmdinc_line = 0;
+}
+
+void
+freefile(struct filepointer *fp)
{
free(fp->f_base);
free(fp);
}
-char *copy(str)
- register char *str;
+char *copy(char *str)
{
- register char *p = (char *)malloc(strlen(str) + 1);
+ char *p = (char *)malloc(strlen(str) + 1);
strcpy(p, str);
return(p);
}
-match(str, list)
- register char *str, **list;
+int
+match(char *str, char **list)
{
- register int i;
+ int i;
for (i=0; *list; i++, list++)
if (strcmp(str, *list) == 0)
@@ -481,13 +595,26 @@ match(str, list)
* Get the next line. We only return lines beginning with '#' since that
* is all this program is ever interested in.
*/
-char *getline(filep)
- register struct filepointer *filep;
+char *getnextline(struct filepointer *filep)
{
- register char *p, /* walking pointer */
- *eof, /* end of file pointer */
- *bol; /* beginning of line pointer */
- register int lineno; /* line number */
+ char *p, /* walking pointer */
+ *eof, /* end of file pointer */
+ *bol; /* beginning of line pointer */
+ int lineno; /* line number */
+ boolean whitespace = FALSE;
+
+ /*
+ * Fake the "-include" line files in form of #include to the
+ * start of each file.
+ */
+ if (filep->cmdinc_line < filep->cmdinc_count) {
+ char *inc = filep->cmdinc_list[2 * filep->cmdinc_line + 0];
+ char *buf = filep->cmdinc_list[2 * filep->cmdinc_line + 1];
+ filep->cmdinc_line++;
+ sprintf(buf,"%s%s%s",DASH_INC_PRE,inc,DASH_INC_POST);
+ DBG_PRINT(stderr,"%s\n",buf);
+ return(buf);
+ }
p = filep->f_p;
eof = filep->f_end;
@@ -495,86 +622,103 @@ char *getline(filep)
return((char *)NULL);
lineno = filep->f_line;
- for(bol = p--; ++p < eof; ) {
- if (*p == '/' && *(p+1) == '*') { /* consume comments */
- *p++ = ' ', *p++ = ' ';
- while (*p) {
- if (*p == '*' && *(p+1) == '/') {
- *p++ = ' ', *p = ' ';
+ for (bol = p--; ++p < eof; ) {
+ if ((bol == p) && ((*p == ' ') || (*p == '\t')))
+ {
+ /* Consume leading white-spaces for this line */
+ while (((p+1) < eof) && ((*p == ' ') || (*p == '\t')))
+ {
+ p++;
+ bol++;
+ }
+ whitespace = TRUE;
+ }
+
+ if (*p == '/' && (p+1) < eof && *(p+1) == '*') {
+ /* Consume C comments */
+ *(p++) = ' ';
+ *(p++) = ' ';
+ while (p < eof && *p) {
+ if (*p == '*' && (p+1) < eof && *(p+1) == '/') {
+ *(p++) = ' ';
+ *(p++) = ' ';
break;
}
- else if (*p == '\n')
+ if (*p == '\n')
lineno++;
- *p++ = ' ';
+ *(p++) = ' ';
}
- continue;
+ --p;
}
- else if (*p == '/' && *(p+1) == '/') { /* consume comments */
- *p++ = ' ', *p++ = ' ';
-
- while (*p)
- {
- /* Comment continues on next line. */
- if (*p == '\\' && *(p+1) == '\n')
- {
- *(p++) = ' ';
+ else if (*p == '/' && (p+1) < eof && *(p+1) == '/') {
+ /* Consume C++ comments */
+ *(p++) = ' ';
+ *(p++) = ' ';
+ while (p < eof && *p) {
+ if (*p == '\\' && (p+1) < eof &&
+ *(p+1) == '\n') {
*(p++) = ' ';
lineno++;
}
- else
- if (*p == '\n')
- {
- /*
- * Decrement so that the next iteration
- * of the outter "for loop" will handle
- * the case of "*p == '\n'".
- */
- --p;
- break;
- }
- else
- {
- *p++ = ' ';
+ else if (*p == '?' && (p+3) < eof &&
+ *(p+1) == '?' &&
+ *(p+2) == '/' &&
+ *(p+3) == '\n') {
+ *(p++) = ' ';
+ *(p++) = ' ';
+ *(p++) = ' ';
+ lineno++;
}
+ else if (*p == '\n')
+ break; /* to process end of line */
+ *(p++) = ' ';
}
-
- continue;
+ --p;
}
-#ifdef WIN32
- else if (*p == '/' && *(p+1) == '/') { /* consume comments */
- *p++ = ' ', *p++ = ' ';
- while (*p && *p != '\n')
- *p++ = ' ';
+ else if (*p == '\\' && (p+1) < eof && *(p+1) == '\n') {
+ /* Consume backslash line terminations */
+ *(p++) = ' ';
+ *p = ' ';
lineno++;
- continue;
}
-#endif
- else if (*p == '\\') {
- if (*(p+1) == '\n') {
- *p = ' ';
- *(p+1) = ' ';
- lineno++;
- }
+ else if (*p == '?' && (p+3) < eof &&
+ *(p+1) == '?' && *(p+2) == '/' && *(p+3) == '\n') {
+ /* Consume trigraph'ed backslash line terminations */
+ *(p++) = ' ';
+ *(p++) = ' ';
+ *(p++) = ' ';
+ *p = ' ';
+ lineno++;
}
else if (*p == '\n') {
lineno++;
if (*bol == '#') {
- register char *cp;
+ char *cp;
- *p++ = '\0';
+ *(p++) = '\0';
/* punt lines with just # (yacc generated) */
for (cp = bol+1;
*cp && (*cp == ' ' || *cp == '\t'); cp++);
if (*cp) goto done;
+ --p;
}
bol = p+1;
+ whitespace = FALSE;
}
}
if (*bol != '#')
bol = NULL;
done:
+ if (bol && whitespace) {
+ warning("%s: non-portable whitespace encountered at line %d\n",
+ filep->f_name, lineno);
+ }
filep->f_p = p;
filep->f_line = lineno;
+#ifdef DEBUG_DUMP
+ if (bol)
+ DBG_PRINT(stderr,"%s\n",bol);
+#endif
return(bol);
}
@@ -582,10 +726,9 @@ done:
* Strip the file name down to what we want to see in the Makefile.
* It will have objprefix and objsuffix around it.
*/
-char *base_name(file)
- register char *file;
+char *base_name(char *file)
{
- register char *p;
+ char *p;
file = copy(file);
for(p=file+strlen(file); p>file && *p != '.'; p--) ;
@@ -595,9 +738,8 @@ char *base_name(file)
return(file);
}
-#if defined(USG) && !defined(CRAY) && !defined(SVR4)
-int rename (from, to)
- char *from, *to;
+#if defined(USG) && !defined(CRAY) && !defined(SVR4) && !defined(__UNIXOS2__) && !defined(clipper) && !defined(__clipper__)
+int rename (char *from, char *to)
{
(void) unlink (to);
if (link (from, to) == 0) {
@@ -610,9 +752,7 @@ int rename (from, to)
#endif /* USGISH */
void
-redirect(line, makefile)
- char *line,
- *makefile;
+redirect(char *line, char *makefile)
{
struct stat st;
FILE *fdin, *fdout;
@@ -646,12 +786,12 @@ redirect(line, makefile)
fatalerr("cannot open \"%s\"\n", makefile);
sprintf(backup, "%s.bak", makefile);
unlink(backup);
-#ifdef WIN32
+#if defined(WIN32) || defined(__UNIXOS2__) || defined(__CYGWIN__)
fclose(fdin);
#endif
if (rename(makefile, backup) < 0)
fatalerr("cannot rename %s to %s\n", makefile, backup);
-#ifdef WIN32
+#if defined(WIN32) || defined(__UNIXOS2__) || defined(__CYGWIN__)
if ((fdin = fopen(backup, "r")) == NULL)
fatalerr("cannot open \"%s\"\n", backup);
#endif
@@ -674,7 +814,7 @@ redirect(line, makefile)
}
}
fflush(fdout);
-#if defined(USGISH) || defined(_SEQUENT_)
+#if defined(USGISH) || defined(_SEQUENT_) || defined(USE_CHMOD)
chmod(makefile, st.st_mode);
#else
fchmod(fileno(fdout), st.st_mode);
@@ -682,65 +822,31 @@ redirect(line, makefile)
}
void
-#if NeedVarargsPrototypes
fatalerr(char *msg, ...)
-#else
-/*VARARGS*/
-fatalerr(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
- char *msg;
-#endif
{
-#if NeedVarargsPrototypes
va_list args;
-#endif
fprintf(stderr, "%s: error: ", ProgramName);
-#if NeedVarargsPrototypes
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
-#else
- fprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);
-#endif
exit (1);
}
void
-#if NeedVarargsPrototypes
warning(char *msg, ...)
-#else
-/*VARARGS0*/
-warning(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
- char *msg;
-#endif
{
-#if NeedVarargsPrototypes
va_list args;
-#endif
fprintf(stderr, "%s: warning: ", ProgramName);
-#if NeedVarargsPrototypes
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
-#else
- fprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);
-#endif
}
void
-#if NeedVarargsPrototypes
warning1(char *msg, ...)
-#else
-/*VARARGS0*/
-warning1(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
- char *msg;
-#endif
{
-#if NeedVarargsPrototypes
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
-#else
- fprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);
-#endif
}
diff --git a/makedepend.man b/makedepend.man
index 21a3faa..595c87e 100644
--- a/makedepend.man
+++ b/makedepend.man
@@ -22,7 +22,10 @@
.\" be used in advertising or otherwise to promote the sale, use or other
.\" dealing in this Software without prior written authorization from The
.\" Open Group.
-.TH MAKEDEPEND 1 "Release 6.4" "X Version 11"
+.\"
+.\" $XFree86: xc/config/makedepend/mkdepend.man,v 1.7 2002/12/14 02:39:45 dawes Exp $
+.\"
+.TH MAKEDEPEND 1 __xorgversion__
.UC 4
.SH NAME
makedepend \- create dependencies in makefiles
@@ -41,6 +44,8 @@ makedepend \- create dependencies in makefiles
] [
.BI \-f makefile
] [
+.BI \-include \ file
+] [
.BI \-o objsuffix
] [
.BI \-p objprefix
@@ -111,7 +116,7 @@ option.
It first searches the makefile for
the line
.sp
- # DO NOT DELETE THIS LINE \-\^\- make depend depends on it.
+\& # DO NOT DELETE THIS LINE \-\^\- make depend depends on it.
.sp
or one provided with the
.B \-s
@@ -199,6 +204,12 @@ can place its output.
Specifying ``\-'' as the file name (i.e., \fB\-f\-\fP) sends the
output to standard output instead of modifying an existing file.
.TP 5
+.B \-include \fIfile\fP
+Process file as input, and include all the resulting output
+before processing the regular input file. This has the same
+affect as if the specified file is an include statement that
+appears before the very first line of the regular input file.
+.TP 5
.B \-o\fIobjsuffix\fP
Object file suffix.
Some systems may have object files whose suffix is something other
@@ -342,9 +353,8 @@ to the list of dependencies for
cc(1), make(1)
.SH BUGS
.B makedepend
-parses, but does not currently evaluate, the SVR4
-#predicate(token-list) preprocessor expression;
-such expressions are simply assumed to be true.
+parses, but does not currently evaluate, the SVR4 #predicate(token-list)
+preprocessor expression; such expressions are simply assumed to be true.
This may cause the wrong
.I #include
directives to be evaluated.
diff --git a/parse.c b/parse.c
index 68fde6c..968d2c4 100644
--- a/parse.c
+++ b/parse.c
@@ -24,21 +24,32 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
+/* $XFree86: xc/config/makedepend/parse.c,v 1.12 2002/02/26 05:09:10 tsi Exp $ */
#include "def.h"
extern char *directives[];
-extern struct inclist maininclist;
-
-int
-gobble(filep, file, file_red)
- register struct filepointer *filep;
- struct inclist *file, *file_red;
+extern struct inclist inclist[ MAXFILES ],
+ *inclistnext,
+ maininclist;
+extern char *includedirs[ ],
+ **includedirsnext;
+
+static int deftype (char *line, struct filepointer *filep,
+ struct inclist *file_red, struct inclist *file,
+ int parse_it);
+static int zero_value(char *filename, char *exp, struct filepointer *filep,
+ struct inclist *file_red);
+static int merge2defines(struct inclist *file1, struct inclist *file2);
+
+static int
+gobble(struct filepointer *filep, struct inclist *file,
+ struct inclist *file_red)
{
- register char *line;
- register int type;
+ char *line;
+ int type;
- while ((line = getline(filep))) {
+ while ((line = getnextline(filep))) {
switch(type = deftype(line, filep, file_red, file, FALSE)) {
case IF:
case IFFALSE:
@@ -68,6 +79,8 @@ gobble(filep, file, file_red)
case SCCS:
case EJECT:
case WARNING:
+ case INCLUDENEXT:
+ case INCLUDENEXTDOT:
break;
case ELIF:
case ELIFFALSE:
@@ -88,14 +101,12 @@ gobble(filep, file, file_red)
/*
* Decide what type of # directive this line is.
*/
-int deftype (line, filep, file_red, file, parse_it)
- register char *line;
- register struct filepointer *filep;
- register struct inclist *file_red, *file;
- int parse_it;
+static int
+deftype (char *line, struct filepointer *filep,
+ struct inclist *file_red, struct inclist *file, int parse_it)
{
register char *p;
- char *directive, savechar;
+ char *directive, savechar, *q;
register int ret;
/*
@@ -106,7 +117,7 @@ int deftype (line, filep, file_red, file, parse_it)
directive++;
p = directive;
- while (*p >= 'a' && *p <= 'z')
+ while ((*p == '_') || (*p >= 'a' && *p <= 'z'))
p++;
savechar = *p;
*p = '\0';
@@ -152,6 +163,11 @@ int deftype (line, filep, file_red, file, parse_it)
*/
while (*p == ' ' || *p == '\t')
p++;
+ q = p + strlen(p);
+ do {
+ q--;
+ } while (*q == ' ' || *q == '\t');
+ q[1] = '\0';
switch (ret) {
case IF:
/*
@@ -174,13 +190,22 @@ int deftype (line, filep, file_red, file, parse_it)
*line = '\0';
break;
case INCLUDE:
- debug(2,("%s, line %d: #include %s\n",
- file->i_file, filep->f_line, p));
+ case INCLUDENEXT:
+ debug(2,("%s, line %d: #include%s %s\n",
+ file->i_file, filep->f_line,
+ (ret == INCLUDE) ? "" : "_next", p));
/* Support ANSI macro substitution */
- {
- struct symtab **sym = isdefined(p, file_red, NULL);
- while (sym) {
+ while (1) {
+ struct symtab **sym;
+
+ if (!*p || *p == '"' || *p == '<')
+ break;
+
+ sym = isdefined(p, file_red, NULL);
+ if (!sym)
+ break;
+
p = (*sym)->s_value;
debug(3,("%s : #includes SYMBOL %s = %s\n",
file->i_incstring,
@@ -188,8 +213,6 @@ int deftype (line, filep, file_red, file, parse_it)
(*sym) -> s_value));
/* mark file as having included a 'soft include' */
file->i_flags |= INCLUDED_SYM;
- sym = isdefined(p, file_red, NULL);
- }
}
/*
@@ -200,7 +223,10 @@ int deftype (line, filep, file_red, file, parse_it)
if (! *p)
return(-2);
if (*p++ == '"') {
- ret = INCLUDEDOT;
+ if (ret == INCLUDE)
+ ret = INCLUDEDOT;
+ else
+ ret = INCLUDENEXTDOT;
while (*p && *p != '"')
*line++ = *p++;
} else
@@ -222,6 +248,7 @@ int deftype (line, filep, file_red, file, parse_it)
case IDENT:
case SCCS:
case EJECT:
+ case WARNING:
debug(0,("%s, line %d: #%s\n",
file->i_file, filep->f_line, directives[ret]));
/*
@@ -232,34 +259,30 @@ int deftype (line, filep, file_red, file, parse_it)
return(ret);
}
-struct symtab **fdefined(symbol, file, srcfile)
- register char *symbol;
- struct inclist *file;
- struct inclist **srcfile;
+struct symtab **
+fdefined(char *symbol, struct inclist *file, struct inclist **srcfile)
{
- register struct inclist **ip;
- register struct symtab **val;
- register int i;
+ struct inclist **ip;
+ struct symtab **val;
+ int i;
static int recurse_lvl = 0;
if (file->i_flags & DEFCHECKED)
return(NULL);
+ debug(2,("Looking for %s in %s\n", symbol, file->i_file));
file->i_flags |= DEFCHECKED;
if ((val = slookup(symbol, file)))
debug(1,("%s defined in %s as %s\n",
symbol, file->i_file, (*val)->s_value));
if (val == NULL && file->i_list)
- {
+ {
for (ip = file->i_list, i=0; i < file->i_listlen; i++, ip++)
if (file->i_merged[i]==FALSE) {
val = fdefined(symbol, *ip, srcfile);
- if ((*ip)->i_flags & FINISHED) {
- merge2defines(file,*ip);
- file->i_merged[i]=TRUE;
- }
+ file->i_merged[i]=merge2defines(file,*ip);
if (val!=NULL) break;
}
- }
+ }
else if (val != NULL && srcfile != NULL) *srcfile = file;
recurse_lvl--;
file->i_flags &= ~DEFCHECKED;
@@ -267,12 +290,10 @@ struct symtab **fdefined(symbol, file, srcfile)
return(val);
}
-struct symtab **isdefined(symbol, file, srcfile)
- register char *symbol;
- struct inclist *file;
- struct inclist **srcfile;
+struct symtab **
+isdefined(char *symbol, struct inclist *file, struct inclist **srcfile)
{
- register struct symtab **val;
+ struct symtab **val;
if ((val = slookup(symbol, &maininclist))) {
debug(1,("%s defined on command line\n", symbol));
@@ -288,12 +309,11 @@ struct symtab **isdefined(symbol, file, srcfile)
/*
* Return type based on if the #if expression evaluates to 0
*/
-int
-zero_value(filename, exp, filep, file_red)
- register char *filename;
- register char *exp;
- register struct filepointer *filep;
- register struct inclist *file_red;
+static int
+zero_value(char *filename,
+ char *exp,
+ struct filepointer *filep,
+ struct inclist *file_red)
{
if (cppsetup(filename, exp, filep, file_red))
return(IFFALSE);
@@ -302,9 +322,7 @@ zero_value(filename, exp, filep, file_red)
}
void
-define2(name, val, file)
- char *name, *val;
- struct inclist *file;
+define2(char *name, char *val, struct inclist *file)
{
int first, last, below;
register struct symtab **sp = NULL, **dest;
@@ -364,6 +382,8 @@ define2(name, val, file)
just replace its s_value */
if (sp != NULL)
{
+ debug(1,("redefining %s from %s to %s in file %s\n",
+ name, (*sp)->s_value, val, file->i_file));
free((*sp)->s_value);
(*sp)->s_value = copy(val);
return;
@@ -380,15 +400,14 @@ define2(name, val, file)
if (stab == NULL)
fatalerr("malloc()/realloc() failure in insert_defn()\n");
+ debug(1,("defining %s to %s in file %s\n", name, val, file->i_file));
stab->s_name = copy(name);
stab->s_value = copy(val);
*sp = stab;
}
void
-define(def, file)
- char *def;
- struct inclist *file;
+define(char *def, struct inclist *file)
{
char *val;
@@ -406,9 +425,8 @@ define(def, file)
define2(def, val, file);
}
-struct symtab **slookup(symbol, file)
- register char *symbol;
- register struct inclist *file;
+struct symtab **
+slookup(char *symbol, struct inclist *file)
{
register int first = 0;
register int last = file->i_ndefs - 1;
@@ -446,12 +464,20 @@ struct symtab **slookup(symbol, file)
return(NULL);
}
-int merge2defines(file1, file2)
- struct inclist *file1;
- struct inclist *file2;
+static int
+merge2defines(struct inclist *file1, struct inclist *file2)
{
- if ((file1!=NULL) && (file2!=NULL))
- {
+ int i;
+
+ if ((file1==NULL) || (file2==NULL) ||
+ !(file2->i_flags & FINISHED))
+ return 0;
+
+ for (i=0; i < file2->i_listlen; i++)
+ if (file2->i_merged[i]==FALSE)
+ return 0;
+
+ {
int first1 = 0;
int last1 = file1->i_ndefs - 1;
@@ -462,6 +488,9 @@ int merge2defines(file1, file2)
struct symtab** i_defs = NULL;
int deflen=file1->i_ndefs+file2->i_ndefs;
+ debug(2,("merging %s into %s\n",
+ file2->i_file, file1->i_file));
+
if (deflen>0)
{
/* make sure deflen % SYMTABINC == 0 is still true */
@@ -501,13 +530,10 @@ int merge2defines(file1, file2)
return 1;
}
- return 0;
}
void
-undefine(symbol, file)
- char *symbol;
- register struct inclist *file;
+undefine(char *symbol, struct inclist *file)
{
register struct symtab **ptr;
struct inclist *srcfile;
@@ -520,17 +546,16 @@ undefine(symbol, file)
}
int
-find_includes(filep, file, file_red, recursion, failOK)
- struct filepointer *filep;
- struct inclist *file, *file_red;
- int recursion;
- boolean failOK;
+find_includes(struct filepointer *filep, struct inclist *file,
+ struct inclist *file_red, int recursion, boolean failOK)
{
+ struct inclist *inclistp;
+ char **includedirsp;
register char *line;
register int type;
boolean recfailOK;
- while ((line = getline(filep))) {
+ while ((line = getnextline(filep))) {
switch(type = deftype(line, filep, file_red, file, TRUE)) {
case IF:
doif:
@@ -614,12 +639,19 @@ find_includes(filep, file, file_red, recursion, failOK)
undefine(line, file_red);
break;
case INCLUDE:
- add_include(filep, file, file_red, line, FALSE, failOK);
- break;
case INCLUDEDOT:
- add_include(filep, file, file_red, line, TRUE, failOK);
+ case INCLUDENEXT:
+ case INCLUDENEXTDOT:
+ inclistp = inclistnext;
+ includedirsp = includedirsnext;
+ debug(2,("%s, reading %s, includes %s\n",
+ file_red->i_file, file->i_file, line));
+ add_include(filep, file, file_red, line, type, failOK);
+ inclistnext = inclistp;
+ includedirsnext = includedirsp;
break;
case ERROR:
+ case WARNING:
warning("%s", file_red->i_file);
if (file_red != file)
warning1(" (reading %s)", file->i_file);
@@ -649,5 +681,6 @@ find_includes(filep, file, file_red, recursion, failOK)
}
}
file->i_flags |= FINISHED;
+ debug(2,("finished with %s\n", file->i_file));
return(-1);
}
diff --git a/pr.c b/pr.c
index 8e6a32c..e864793 100644
--- a/pr.c
+++ b/pr.c
@@ -24,6 +24,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
+/* $XFree86: xc/config/makedepend/pr.c,v 1.5 2001/12/14 19:53:21 dawes Exp $ */
#include "def.h"
@@ -37,11 +38,9 @@ extern boolean verbose;
extern boolean show_where_not;
void
-add_include(filep, file, file_red, include, dot, failOK)
- struct filepointer *filep;
- struct inclist *file, *file_red;
- char *include;
- boolean dot;
+add_include(struct filepointer *filep, struct inclist *file,
+ struct inclist *file_red, char *include, int type,
+ boolean failOK)
{
register struct inclist *newfile;
register struct filepointer *content;
@@ -49,7 +48,7 @@ add_include(filep, file, file_red, include, dot, failOK)
/*
* First decide what the pathname of this include file really is.
*/
- newfile = inc_path(file->i_file, include, dot);
+ newfile = inc_path(file->i_file, include, type);
if (newfile == NULL) {
if (failOK)
return;
@@ -60,7 +59,7 @@ add_include(filep, file, file_red, include, dot, failOK)
warning("%s, line %d: ", file->i_file, filep->f_line);
warning1("cannot find include file \"%s\"\n", include);
show_where_not = TRUE;
- newfile = inc_path(file->i_file, include, dot);
+ newfile = inc_path(file->i_file, include, type);
show_where_not = FALSE;
}
@@ -75,10 +74,8 @@ add_include(filep, file, file_red, include, dot, failOK)
}
}
-void
-pr(ip, file, base)
- register struct inclist *ip;
- char *file, *base;
+static void
+pr(struct inclist *ip, char *file, char *base)
{
static char *lastfile;
static int current_len;
@@ -113,11 +110,9 @@ pr(ip, file, base)
}
void
-recursive_pr_include(head, file, base)
- register struct inclist *head;
- register char *file, *base;
+recursive_pr_include(struct inclist *head, char *file, char *base)
{
- register int i;
+ int i;
if (head->i_flags & MARKED)
return;