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
commite5ab5c93d3178aa82b66e2c086b54e042930725e (patch)
tree42efcbac8c0286d28b60d6b05688bf825527450a
parent1bc16368b0ff5701fa740aba943ac47a4f99b258 (diff)
-rw-r--r--imake.c1428
-rw-r--r--imake.man26
-rw-r--r--imakemdep.h769
-rw-r--r--makeg.man5
-rw-r--r--mdepend.cpp24
-rw-r--r--mergelib.cpp11
-rw-r--r--mkdirhier2
-rw-r--r--mkdirhier.man5
-rw-r--r--xmkmf.cpp30
-rw-r--r--xmkmf.man5
10 files changed, 1728 insertions, 577 deletions
diff --git a/imake.c b/imake.c
index 3f13fc6..a85a166 100644
--- a/imake.c
+++ b/imake.c
@@ -1,4 +1,3 @@
-/* $Id */
/***************************************************************************
* *
@@ -8,10 +7,11 @@
* be passed to the template file. *
* *
***************************************************************************/
+/* $XFree86: xc/config/imake/imake.c,v 3.63 2002/12/16 22:48:27 herrb Exp $ */
/*
- *
-Copyright (c) 1985, 1986, 1987, 1998 The Open Group
+ *
+Copyright (c) 1985, 1986, 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
@@ -32,7 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
- *
+ *
* Original Author:
* Todd Brunhoff
* Tektronix, inc.
@@ -47,6 +47,8 @@ in this Software without prior written authorization from The Open Group.
* on the Makefile.
* Options:
* -D define. Same as cpp -D argument.
+ * -U undefine. Same as cpp -U argument.
+ * -W warning. Same as cpp -W argument.
* -I Include directory. Same as cpp -I argument.
* -T template. Designate a template other
* than Imake.tmpl
@@ -55,11 +57,11 @@ in this Software without prior written authorization from The Open Group.
* -s[F] show. Show the produced makefile on the standard
* output. Make is not run is this case. If a file
* argument is provided, the output is placed there.
- * -e[F] execute instead of show; optionally name Makefile F
+ * -e[F] execute instead of show; optionally name Makefile F
* -v verbose. Show the make command line executed.
*
* Environment variables:
- *
+ *
* IMAKEINCLUDE Include directory to use in addition to "."
* IMAKECPP Cpp to use instead of /lib/cpp
* IMAKEMAKE make program to use other than what is
@@ -102,12 +104,15 @@ in this Software without prior written authorization from The Open Group.
* - If DEFAULT_OS_TEENY_REV is defined, format the utsname struct
* and call the result <defaultOsTeenyVersion>. Add:
* #define DefaultOSTeenyVersion <defaultOsTeenyVersion>
+ * - If DEFAULT_MACHINE_ARCITECTURE is defined, format the utsname struct
+ * and define the corresponding macro. (For example on the amiga,
+ * this will define amiga in addition to m68k).
* - If the file "localdefines" is readable in the current
- * directory, print a warning message to stderr and add:
+ * directory, print a warning message to stderr and add:
* #define IMAKE_LOCAL_DEFINES "localdefines"
* #include IMAKE_LOCAL_DEFINES
* - If the file "admindefines" is readable in the current
- * directory, print a warning message to stderr and add:
+ * directory, print a warning message to stderr and add:
* #define IMAKE_ADMIN_DEFINES "admindefines"
* #include IMAKE_ADMIN_DEFINES
* - The following lines:
@@ -115,11 +120,11 @@ in this Software without prior written authorization from The Open Group.
* #define IMAKE_TEMPLATE " <template> "
* #include IMAKE_TEMPLATE
* - If the file "adminmacros" is readable in the current
- * directory, print a warning message to stderr and add:
+ * directory, print a warning message to stderr and add:
* #define IMAKE_ADMIN_MACROS "adminmacros"
* #include IMAKE_ADMIN_MACROS
* - If the file "localmacros" is readable in the current
- * directory, print a warning message to stderr and add:
+ * directory, print a warning message to stderr and add:
* #define IMAKE_LOCAL_MACROS "localmacros"
* #include IMAKE_LOCAL_MACROS
* 5. Start up cpp and provide it with this file.
@@ -140,17 +145,27 @@ in this Software without prior written authorization from The Open Group.
* #include INCLUDE_IMAKEFILE
* <add any global targets like 'clean' and long dependencies>
*/
+#if defined(__FreeBSD__) || defined(__NetBSD__)
+/* This needs to be before _POSIX_SOURCE gets defined */
+# include <sys/param.h>
+# include <sys/types.h>
+# include <sys/sysctl.h>
+#endif
+#include <stdlib.h>
#include <stdio.h>
-#include <ctype.h>
#include "Xosdefs.h"
+#include <string.h>
+#include <ctype.h>
#ifdef WIN32
# include "Xw32defs.h"
#endif
+#if 0
#ifndef X_NOT_POSIX
# ifndef _POSIX_SOURCE
# define _POSIX_SOURCE
# endif
#endif
+#endif
#include <sys/types.h>
#include <fcntl.h>
#ifdef X_NOT_POSIX
@@ -160,6 +175,9 @@ in this Software without prior written authorization from The Open Group.
#else
# include <unistd.h>
#endif
+#ifdef ISC
+# include <unistd.h>
+#endif
#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE)
# include <signal.h>
#else
@@ -167,9 +185,16 @@ in this Software without prior written authorization from The Open Group.
# include <signal.h>
# undef _POSIX_SOURCE
#endif
+#if !defined(SIGCHLD) && defined(SIGCLD)
+# define SIGCHLD SIGCLD
+#endif
#include <sys/stat.h>
#ifndef X_NOT_POSIX
# ifdef _POSIX_SOURCE
+# ifdef SCO325
+# include <sys/procset.h>
+# include <sys/siginfo.h>
+# endif
# include <sys/wait.h>
# else
# define _POSIX_SOURCE
@@ -202,21 +227,17 @@ typedef union wait waitType;
# define WIFEXITED(w) waitCode(w)
# endif
#endif /* X_NOT_POSIX */
-#ifndef X_NOT_STDC_ENV
# include <stdlib.h>
-#else
-char *malloc(), *realloc();
-void exit();
-#endif
#if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */
char *malloc(), *realloc();
#endif /* macII */
-#ifdef X_NOT_STDC_ENV
-extern char *getenv();
-#endif
#include <errno.h>
-#ifdef X_NOT_STDC_ENV
-extern int errno;
+#ifdef __minix_vmd
+#define USE_FREOPEN 1
+#endif
+
+#if !((defined(sun) && !defined(SVR4)) || defined(macII))
+#define USE_STRERROR 1
#endif
#ifndef WIN32
#include <sys/utsname.h>
@@ -230,21 +251,19 @@ extern int errno;
# define SYS_NMLN 257
# endif
#endif
-#ifdef linux
+#if defined(linux) || defined(__GNU__)
#include <limits.h>
+#include <stdio.h>
+#endif
+#ifdef __QNX__
+#include <unix.h>
#endif
-/*
- * is strstr() in <strings.h> on X_NOT_STDC_ENV?
- * are there any X_NOT_STDC_ENV machines left in the world?
- */
-#include <string.h>
-#include "imakemdep.h"
/*
* This define of strerror is copied from (and should be identical to)
* Xos.h, which we don't want to include here for bootstrapping reasons.
*/
-#if defined(X_NOT_STDC_ENV) || (defined(sun) && !defined(SVR4)) || defined(macII)
+#ifndef USE_STRERROR
# ifndef strerror
extern char *sys_errlist[];
extern int sys_nerr;
@@ -253,52 +272,65 @@ extern int sys_nerr;
# endif
#endif
-#define TRUE 1
-#define FALSE 0
+#if defined(__NetBSD__) /* see code clock in init() below */
+#include <sys/utsname.h>
+#endif
-#ifdef FIXUP_CPP_WHITESPACE
-int InRule = FALSE;
-# ifdef INLINE_SYNTAX
-int InInline = 0;
-# endif
+#if !(defined(Lynx) || defined(__Lynx__) || (defined(SVR4) && !defined(sun))) && !defined (__CYGWIN__)
+#define HAS_MKSTEMP
+#endif
+
+typedef unsigned char boolean;
+#define TRUE 1
+#define FALSE 0
+
+# include "imakemdep.h"
+#ifdef CROSSCOMPILE
+# include "imakemdep_cpp.h"
#endif
-#ifdef MAGIC_MAKE_VARS
+
+#if defined CROSSCOMPILE || defined FIXUP_CPP_WHITESPACE
+int InRule = FALSE;
+#endif
+#if defined CROSSCOMPILE || defined INLINE_SYNTAX
+int InInline = 0;
+#endif
+#if defined CROSSCOMPILE || defined MAGIC_MAKE_VARS
int xvariable = 0;
int xvariables[10];
#endif
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
/*
* Some versions of cpp reduce all tabs in macro expansion to a single
* space. In addition, the escaped newline may be replaced with a
* space instead of being deleted. Blech.
*/
-#ifdef FIXUP_CPP_WHITESPACE
-void KludgeOutputLine(), KludgeResetRule();
-#else
-# define KludgeOutputLine(arg)
-# define KludgeResetRule()
-#endif
-
-typedef unsigned char boolean;
+void KludgeOutputLine(char **), KludgeResetRule(void);
-#ifdef USE_CC_E
-# ifndef DEFAULT_CC
-# define DEFAULT_CC "cc"
-# endif
-#else
-# ifndef DEFAULT_CPP
-# ifdef CPP_PROGRAM
-# define DEFAULT_CPP CPP_PROGRAM
-# else
-# define DEFAULT_CPP "/lib/cpp"
+#ifndef CROSSCOMPILE
+# ifdef USE_CC_E
+# ifndef DEFAULT_CC
+# define DEFAULT_CC "cc"
+# endif
+# else
+# ifndef DEFAULT_CPP
+# ifdef CPP_PROGRAM
+# define DEFAULT_CPP CPP_PROGRAM
+# else
+# define DEFAULT_CPP "/lib/cpp"
+# endif
# endif
# endif
#endif
char *cpp = NULL;
-char *tmpMakefile = "/tmp/Imf.XXXXXX";
-char *tmpImakefile = "/tmp/IIf.XXXXXX";
+char *tmpMakefile = "/tmp/Imf.XXXXXX";
+char *tmpImakefile = "/tmp/IIf.XXXXXX";
char *make_argv[ ARGUMENTS ] = {
#ifdef WIN32
"nmake"
@@ -316,49 +348,100 @@ char *ImakefileC = "Imakefile.c";
boolean haveImakefileC = FALSE;
char *cleanedImakefile = NULL;
char *program;
-char *FindImakefile();
-char *ReadLine();
-char *CleanCppInput();
-char *Strdup();
-char *Emalloc();
-void LogFatalI(), LogFatal(), LogMsg();
-
-void showit();
-void wrapup();
-void init();
-void AddMakeArg();
-void AddCppArg();
-void SetOpts();
-void CheckImakefileC();
-void cppit();
-void makeit();
-void CleanCppOutput();
-boolean isempty();
-void writetmpfile();
-
-boolean verbose = FALSE;
-boolean show = TRUE;
+char *FindImakefile(char *Imakefile);
+char *ReadLine(FILE *tmpfd, char *tmpfname);
+char *CleanCppInput(char *imakefile);
+char *Strdup(char *cp);
+char *Emalloc(int size);
+void LogFatalI(char *s, int i), LogFatal(char *x0, char *x1),
+ LogMsg(char *x0, char *x1);
+
+void showit(FILE *fd);
+void wrapup(void);
+void init(void);
+void AddMakeArg(char *arg);
+void AddCppArg(char *arg);
+#ifdef CROSSCOMPILE
+char *CrossCompileCPP(void);
+#endif
+void SetOpts(int argc, char **argv);
+void CheckImakefileC(char *masterc);
+void cppit(char *imakefile, char *template, char *masterc,
+ FILE *outfd, char *outfname);
+void makeit(void);
+void CleanCppOutput(FILE *tmpfd, char *tmpfname);
+boolean isempty(char *line);
+void writetmpfile(FILE *fd, char *buf, int cnt, char *fname);
+#ifdef SIGNALRETURNSINT
+int catch(int sig);
+#else
+void catch(int sig);
+#endif
+void showargs(char **argv);
+boolean optional_include(FILE *inFile, char *defsym, char *fname);
+void doit(FILE *outfd, char *cmd, char **argv);
+boolean define_os_defaults(FILE *inFile);
+#ifdef CROSSCOMPILE
+static void get_cross_compile_dir(FILE *inFile);
+#endif
+#ifdef CROSSCOMPILEDIR
+char *CrossCompileDir = CROSSCOMPILEDIR;
+#else
+char *CrossCompileDir = "";
+#endif
+boolean CrossCompiling = FALSE;
+
+
+
+boolean verbose = FALSE;
+boolean show = TRUE;
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char *argv[])
{
- FILE *tmpfd;
+ FILE *tmpfd = NULL;
char makeMacro[ BUFSIZ ];
char makefileMacro[ BUFSIZ ];
+ int lenCrossCompileDir = 0;
program = argv[0];
init();
- SetOpts(argc, argv);
+ lenCrossCompileDir = strlen(CrossCompileDir);
+ if (lenCrossCompileDir) {
+ if (lenCrossCompileDir > (PATH_MAX - 20))
+ LogFatal("Cross compile directory path too long %s\n",
+ CrossCompileDir);
+ else
+ CrossCompiling = TRUE;
+ }
+
+ SetOpts(argc, argv);
Imakefile = FindImakefile(Imakefile);
CheckImakefileC(ImakefileC);
- if (Makefile)
+ if (Makefile) {
tmpMakefile = Makefile;
- else {
+ if ((tmpfd = fopen(tmpMakefile, "w+")) == NULL)
+ LogFatal("Cannot create temporary file %s.", tmpMakefile);
+ } else {
+#ifdef HAS_MKSTEMP
+ int fd;
+#endif
tmpMakefile = Strdup(tmpMakefile);
- (void) mktemp(tmpMakefile);
+#ifndef HAS_MKSTEMP
+ if (mktemp(tmpMakefile) == NULL ||
+ (tmpfd = fopen(tmpMakefile, "w+")) == NULL) {
+ LogFatal("Cannot create temporary file %s.", tmpMakefile);
+ }
+#else
+ fd = mkstemp(tmpMakefile);
+ if (fd == -1 || (tmpfd = fdopen(fd, "w+")) == NULL) {
+ if (fd != -1) {
+ unlink(tmpMakefile); close(fd);
+ }
+ LogFatal("Cannot create temporary file %s.", tmpMakefile);
+ }
+#endif
}
AddMakeArg("-f");
AddMakeArg( tmpMakefile );
@@ -367,9 +450,6 @@ main(argc, argv)
sprintf(makefileMacro, "MAKEFILE=%s", Imakefile);
AddMakeArg( makefileMacro );
- if ((tmpfd = fopen(tmpMakefile, "w+")) == NULL)
- LogFatal("Cannot create temporary file %s.", tmpMakefile);
-
cleanedImakefile = CleanCppInput(Imakefile);
cppit(cleanedImakefile, Template, ImakefileC, tmpfd, tmpMakefile);
@@ -383,8 +463,7 @@ main(argc, argv)
}
void
-showit(fd)
- FILE *fd;
+showit(FILE *fd)
{
char buf[ BUFSIZ ];
int red;
@@ -397,7 +476,7 @@ showit(fd)
}
void
-wrapup()
+wrapup(void)
{
if (tmpMakefile != Makefile)
unlink(tmpMakefile);
@@ -412,8 +491,7 @@ int
#else
void
#endif
-catch(sig)
- int sig;
+catch(int sig)
{
errno = 0;
LogFatalI("Signal %d.", sig);
@@ -423,7 +501,7 @@ catch(sig)
* Initialize some variables.
*/
void
-init()
+init(void)
{
register char *p;
@@ -434,6 +512,33 @@ init()
while (cpp_argv[ cpp_argindex ] != NULL)
cpp_argindex++;
+#if defined CROSSCOMPILE
+ if (sys == netBSD)
+ if (CrossCompiling) {
+ LogFatal("fix imake to do crosscompiling for NetBSD\n","");
+ } else
+#endif
+#if defined(__NetBSD__) || defined CROSSCOMPILE
+ {
+ struct utsname uts;
+ static char argument[512];
+
+ /*
+ * Sharable imake configurations require a
+ * machine identifier.
+ */
+ if (uname(&uts) != 0)
+ LogFatal("uname(3) failed; can't tell what %s",
+ "kind of machine you have.");
+
+ memset(argument, 0, sizeof(argument));
+ (void)snprintf(argument, sizeof(argument) - 1,
+ "-D__%s__", uts.machine);
+
+ AddCppArg(argument);
+ }
+#endif /* __NetBSD__ */
+
/*
* See if the standard include directory is different than
* the default. Or if cpp is not the default. Or if the make
@@ -457,11 +562,13 @@ init()
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
signal(SIGINT, catch);
+#ifdef SIGCHLD
+ signal(SIGCHLD, SIG_DFL);
+#endif
}
void
-AddMakeArg(arg)
- char *arg;
+AddMakeArg(char *arg)
{
errno = 0;
if (make_argindex >= ARGUMENTS-1)
@@ -471,8 +578,7 @@ AddMakeArg(arg)
}
void
-AddCppArg(arg)
- char *arg;
+AddCppArg(char *arg)
{
errno = 0;
if (cpp_argindex >= ARGUMENTS-1)
@@ -482,10 +588,9 @@ AddCppArg(arg)
}
void
-SetOpts(argc, argv)
- int argc;
- char **argv;
+SetOpts(int argc, char **argv)
{
+
errno = 0;
/*
* Now gather the arguments for make
@@ -499,6 +604,10 @@ SetOpts(argc, argv)
AddCppArg(argv[0]);
} else if (argv[0][1] == 'I') {
AddCppArg(argv[0]);
+ } else if (argv[0][1] == 'U') {
+ AddCppArg(argv[0]);
+ } else if (argv[0][1] == 'W') {
+ AddCppArg(argv[0]);
} else if (argv[0][1] == 'f') {
if (argv[0][2])
Imakefile = argv[0]+2;
@@ -548,53 +657,60 @@ SetOpts(argc, argv)
} else
AddMakeArg(argv[0]);
}
-#ifdef USE_CC_E
- if (!cpp)
- {
+
+#ifndef CROSSCOMPILE
+# ifdef USE_CC_E
+ if (!cpp)
+ {
AddCppArg("-E");
+#ifdef __GNUC__
+ if (verbose)
+ AddCppArg("-v");
+#endif
cpp = DEFAULT_CC;
- }
-#else
- if (!cpp)
+ }
+# else
+ if (!cpp)
cpp = DEFAULT_CPP;
+# endif
+#else
+ if (!cpp)
+ cpp = CrossCompileCPP();
#endif
+
cpp_argv[0] = cpp;
AddCppArg(ImakefileC);
}
char *
-FindImakefile(Imakefile)
- char *Imakefile;
+FindImakefile(char *Imakefile)
{
if (Imakefile) {
if (access(Imakefile, R_OK) < 0)
LogFatal("Cannot find %s.", Imakefile);
} else {
- if (access("Imakefile", R_OK) < 0)
+ if (access("Imakefile", R_OK) < 0) {
if (access("imakefile", R_OK) < 0)
LogFatal("No description file.", "");
else
Imakefile = "imakefile";
- else
+ } else
Imakefile = "Imakefile";
}
return(Imakefile);
}
void
-LogFatalI(s, i)
- char *s;
- int i;
+LogFatalI(char *s, int i)
{
/*NOSTRICT*/
- LogFatal(s, (char *)i);
+ LogFatal(s, (char *)(long)i);
}
void
-LogFatal(x0,x1)
- char *x0, *x1;
+LogFatal(char *x0, char *x1)
{
- static boolean entered = FALSE;
+ static boolean entered = FALSE;
if (entered)
return;
@@ -607,8 +723,7 @@ LogFatal(x0,x1)
}
void
-LogMsg(x0,x1)
- char *x0, *x1;
+LogMsg(char *x0, char *x1)
{
int error_number = errno;
@@ -622,8 +737,7 @@ LogMsg(x0,x1)
}
void
-showargs(argv)
- char **argv;
+showargs(char **argv)
{
for (; *argv; argv++)
fprintf(stderr, "%s ", *argv);
@@ -633,8 +747,7 @@ showargs(argv)
#define ImakefileCHeader "/* imake - temporary file */"
void
-CheckImakefileC(masterc)
- char *masterc;
+CheckImakefileC(char *masterc)
{
char mkcbuf[1024];
FILE *inFile;
@@ -644,7 +757,7 @@ CheckImakefileC(masterc)
if (inFile == NULL)
LogFatal("Refuse to overwrite: %s", masterc);
if ((fgets(mkcbuf, sizeof(mkcbuf), inFile) &&
- strncmp(mkcbuf, ImakefileCHeader,
+ strncmp(mkcbuf, ImakefileCHeader,
sizeof(ImakefileCHeader)-1)))
{
fclose(inFile);
@@ -658,13 +771,10 @@ CheckImakefileC(masterc)
#define IncludeFmt "#include %s\n"
#define ImakeDefSym "INCLUDE_IMAKEFILE"
#define ImakeTmplSym "IMAKE_TEMPLATE"
-#define OverrideWarning "Warning: local file \"%s\" overrides global macros."
+#define OverrideWarning "Warning: local file \"%s\" overrides global macros."
boolean
-optional_include(inFile, defsym, fname)
- FILE *inFile;
- char *defsym;
- char *fname;
+optional_include(FILE *inFile, char *defsym, char *fname)
{
errno = 0;
if (access(fname, R_OK) == 0) {
@@ -676,12 +786,9 @@ optional_include(inFile, defsym, fname)
}
void
-doit(outfd, cmd, argv)
- FILE *outfd;
- char *cmd;
- char **argv;
+doit(FILE *outfd, char *cmd, char **argv)
{
- int pid;
+ int pid;
waitType status;
/*
@@ -719,18 +826,17 @@ doit(outfd, cmd, argv)
#endif
}
-#ifndef WIN32
+#if !defined WIN32
static void
-parse_utsname(name, fmt, result, msg)
- struct utsname *name;
- char *fmt;
- char *result;
- char *msg;
+parse_utsname(struct utsname *name, char *fmt, char *result, char *msg)
{
char buf[SYS_NMLN * 5 + 1];
char *ptr = buf;
int arg;
+ if (!name)
+ LogFatal(msg,fmt);
+
/* Assemble all the pieces into a buffer. */
for (arg = 0; fmt[arg] != ' '; arg++)
{
@@ -793,10 +899,9 @@ parse_utsname(name, fmt, result, msg)
the number to be interpreted as octal numbers. Some version strings
have the potential for different numbers of .'s in them.
*/
-
+
static char *
-trim_version(p)
- char *p;
+trim_version(char *p)
{
if (p != 0 && *p != '\0')
@@ -808,55 +913,15 @@ trim_version(p)
}
#endif
-#ifdef linux
-static void get_distrib(inFile)
- FILE* inFile;
-{
- struct stat sb;
-
- static char* yast = "/sbin/YaST";
- static char* redhat = "/etc/redhat-release";
-
- fprintf (inFile, "%s\n", "#define LinuxUnknown 0");
- fprintf (inFile, "%s\n", "#define LinuxSuSE 1");
- fprintf (inFile, "%s\n", "#define LinuxCaldera 2");
- fprintf (inFile, "%s\n", "#define LinuxCraftworks 3");
- fprintf (inFile, "%s\n", "#define LinuxDebian 4");
- fprintf (inFile, "%s\n", "#define LinuxInfoMagic 5");
- fprintf (inFile, "%s\n", "#define LinuxKheops 6");
- fprintf (inFile, "%s\n", "#define LinuxPro 7");
- fprintf (inFile, "%s\n", "#define LinuxRedHat 8");
- fprintf (inFile, "%s\n", "#define LinuxSlackware 9");
- fprintf (inFile, "%s\n", "#define LinuxTurbo 10");
- fprintf (inFile, "%s\n", "#define LinuxWare 11");
- fprintf (inFile, "%s\n", "#define LinuxYggdrasil 12");
-
- if (lstat (yast, &sb) == 0) {
- fprintf (inFile, "%s\n", "#define DefaultLinuxDistribution LinuxSuSE");
- return;
- }
- if (lstat (redhat, &sb) == 0) {
- fprintf (inFile, "%s\n", "#define DefaultLinuxDistribution LinuxRedHat");
- return;
- }
- /* what's the definitive way to tell what any particular distribution is? */
-
- fprintf (inFile, "%s\n", "#define DefaultLinuxDistribution LinuxUnknown");
- /* would like to know what version of the distribution it is */
-}
-
-static const char *libc_c=
+#if defined linux
+const char *libc_c=
"#include <stdio.h>\n"
"#include <ctype.h>\n"
"\n"
-"#if 0\n"
+"#if 1\n"
"#pragma weak gnu_get_libc_version\n"
"#pragma weak __libc_version\n"
"#pragma weak __linux_C_lib_version\n"
-"#else\n"
-"asm (\".weak gnu_get_libc_version\");\n"
-"asm (\".weak __libc_version\");\n"
-"asm (\".weak __linux_C_lib_version\");\n"
"#endif\n"
"\n"
"extern const char * gnu_get_libc_version (void);\n"
@@ -867,34 +932,30 @@ static const char *libc_c=
"main ()\n"
"{\n"
" int libcmajor = 0, libcminor = 0, libcteeny = 0;\n"
+" const char * ptr = NULL;\n"
+" int glibcmajor = 0;\n"
"\n"
-" if (((&__linux_C_lib_version != 0)\n"
-" && ((&__libc_version != 0) || (gnu_get_libc_version != 0)))\n"
-" || (!(&__linux_C_lib_version != 0) && !(&__libc_version != 0)\n"
-" && !(gnu_get_libc_version != 0)))\n"
+" if (gnu_get_libc_version != 0)\n"
" {\n"
-" libcmajor = 0;\n"
-" libcminor = 0;\n"
-" libcteeny = 0;\n"
+" ptr = gnu_get_libc_version ();\n"
+" glibcmajor = 4;\n"
+" }\n"
+" else if (&__libc_version != 0)\n"
+" {\n"
+" ptr = __libc_version;\n"
+" glibcmajor = 4;\n"
+" }\n"
+" else if (&__linux_C_lib_version != 0)\n"
+" {\n"
+" ptr = __linux_C_lib_version;\n"
" }\n"
" else\n"
" {\n"
-" const char * ptr;\n"
-" int glibcmajor = 0;\n"
-"\n"
-" if (gnu_get_libc_version != 0)\n"
-" {\n"
-" ptr = gnu_get_libc_version ();\n"
-" glibcmajor = 4;\n"
-" }\n"
-" else if (&__libc_version != 0)\n"
-" {\n"
-" ptr = __libc_version;\n"
-" glibcmajor = 4;\n"
-" }\n"
-" else\n"
-" ptr = __linux_C_lib_version;\n"
+" libcmajor = 0; libcminor = 0; libcteeny = 0;\n"
+" }\n"
"\n"
+" if (ptr)\n"
+" {\n"
" while (!isdigit (*ptr))\n"
" ptr++;\n"
"\n"
@@ -910,75 +971,157 @@ static const char *libc_c=
"}\n"
;
-static void get_libc_version(inFile)
- FILE* inFile;
+static void
+get_libc_version(FILE *inFile)
{
- static char* libcso = "/usr/lib/libc.so";
- struct stat sb;
- char buf[PATH_MAX];
- char* ptr;
- int libcmajor, libcminor, libcteeny;
-
- if (lstat (libcso, &sb) == 0) {
- if (S_ISLNK (sb.st_mode)) {
- /*
- * /usr/lib/libc.so is a symlink -- this is libc 5.x
- * we can do this the quick way
- */
- if (readlink (libcso, buf, PATH_MAX) >= 0) {
- for (ptr = buf; *ptr && !isdigit (*ptr); ptr++);
- (void) sscanf (ptr, "%d.%d.%d", &libcmajor, &libcminor, &libcteeny);
- fprintf(inFile, "#define DefaultLinuxCLibMajorVersion %d\n", libcmajor);
- fprintf(inFile, "#define DefaultLinuxCLibMinorVersion %d\n", libcminor);
- fprintf(inFile, "#define DefaultLinuxCLibTeenyVersion %d\n", libcteeny);
- }
- } else {
- /*
- * /usr/lib/libc.so is NOT a symlink -- this is libc 6.x / glibc 2.x
- * now we have to figure this out the hard way.
- */
- char *aout = tmpnam (NULL);
- FILE *fp;
- const char *format = "%s -o %s -x c -";
- char *cc;
- int len;
- char *command;
-
- cc = getenv ("CC");
- if (cc == NULL)
- cc = "gcc";
- len = strlen (aout) + strlen (format) + strlen (cc);
- if (len < 128) len = 128;
- command = alloca (len);
-
- if (snprintf (command , len, format, cc, aout) == len)
- abort ();
-
- fp = popen (command, "w");
- if (fp == NULL || fprintf (fp, "%s\n", libc_c) < 0 || pclose (fp) != 0)
- abort ();
-
- fp = popen (aout, "r");
- if (fp == NULL)
- abort ();
-
- while (fgets (command, len, fp))
- fprintf (inFile, command);
+ char aout[] = "/tmp/imakeXXXXXX";
+ FILE *fp;
+ const char *format = "%s -o %s -x c -";
+ char *cc;
+ int len;
+ char *command;
+
+ /* Pre-create temp file safely */
+ {
+ /* Linux + ELF has mkstemp() */
+ int tmpfd;
+ if ((tmpfd = mkstemp(aout)) == -1) {
+ perror("mkstemp");
+ abort();
+ }
+ close(tmpfd);
+ }
+ cc = getenv ("CC");
+ if (cc == NULL)
+ cc = "gcc";
+ len = strlen (aout) + strlen (format) + strlen (cc);
+ if (len < 128) len = 128;
+ command = alloca (len);
+
+ if (snprintf (command , len, format, cc, aout) == len)
+ abort ();
+
+ fp = popen (command, "w");
+ if (fp == NULL || fprintf (fp, "%s\n", libc_c) < 0
+ || pclose (fp) != 0)
+ abort ();
+
+ fp = popen (aout, "r");
+ if (fp == NULL)
+ abort ();
+
+ while (fgets (command, len, fp))
+ fprintf (inFile, command);
+
+ len = pclose (fp);
+ remove (aout);
+ if (len)
+ abort ();
+}
+#endif
+
+#if defined(__OpenBSD__)
+static void
+get_stackprotector(FILE *inFile)
+{
+ FILE *fp;
+ char *cc;
+ char command[1024], buf[1024];
- len = pclose (fp);
- remove (aout);
- if (len)
- abort ();
+ cc = getenv("CC");
+ if (cc == NULL) {
+ cc = "cc";
+ }
+ snprintf(command, sizeof(command), "%s -v 2>&1", cc);
+ fp = popen(command, "r");
+ if (fp == NULL)
+ abort();
+ while (fgets(buf, sizeof(buf), fp)) {
+ if (strstr(buf, "propolice") != NULL) {
+ fprintf(inFile, "#define HasGccStackProtector YES\n");
+ break;
}
}
+ if (pclose(fp))
+ abort();
}
+#endif
+
-static void get_ld_version(inFile)
- FILE* inFile;
+#if defined CROSSCOMPILE || defined linux
+static void
+get_distrib(FILE *inFile)
{
- FILE* ldprog = popen ("ld -v", "r");
- char c;
+ struct stat sb;
+
+ static char* suse = "/etc/SuSE-release";
+ static char* redhat = "/etc/redhat-release";
+ static char* debian = "/etc/debian_version";
+
+ fprintf (inFile, "%s\n", "#define LinuxUnknown 0");
+ fprintf (inFile, "%s\n", "#define LinuxSuSE 1");
+ fprintf (inFile, "%s\n", "#define LinuxCaldera 2");
+ fprintf (inFile, "%s\n", "#define LinuxCraftworks 3");
+ fprintf (inFile, "%s\n", "#define LinuxDebian 4");
+ fprintf (inFile, "%s\n", "#define LinuxInfoMagic 5");
+ fprintf (inFile, "%s\n", "#define LinuxKheops 6");
+ fprintf (inFile, "%s\n", "#define LinuxPro 7");
+ fprintf (inFile, "%s\n", "#define LinuxRedHat 8");
+ fprintf (inFile, "%s\n", "#define LinuxSlackware 9");
+ fprintf (inFile, "%s\n", "#define LinuxTurbo 10");
+ fprintf (inFile, "%s\n", "#define LinuxWare 11");
+ fprintf (inFile, "%s\n", "#define LinuxYggdrasil 12");
+
+#ifdef CROSSCOMPILE
+ if (CrossCompiling) {
+ fprintf (inFile, "%s\n",
+ "#define DefaultLinuxDistribution LinuxUnknown");
+ fprintf (inFile, "%s\n", "#define DefaultLinuxDistName Unknown");
+ return;
+ }
+#endif
+ if (lstat (suse, &sb) == 0) {
+ fprintf (inFile, "%s\n", "#define DefaultLinuxDistribution LinuxSuSE");
+ fprintf (inFile, "%s\n", "#define DefaultLinuxDistName SuSE");
+ return;
+ }
+ if (lstat (redhat, &sb) == 0) {
+ fprintf (inFile, "%s\n", "#define DefaultLinuxDistribution LinuxRedHat");
+ fprintf (inFile, "%s\n", "#define DefaultLinuxDistName RedHat");
+ return;
+ }
+ if (lstat (debian, &sb) == 0) {
+ fprintf (inFile, "%s\n", "#define DefaultLinuxDistribution LinuxDebian");
+ fprintf (inFile, "%s\n", "#define DefaultLinuxDistName Debian");
+ /* You could also try to get the version of the Debian distrib by looking
+ * at the content of /etc/debian_version */
+ return;
+ }
+ /* what's the definitive way to tell what any particular distribution is? */
+
+ fprintf (inFile, "%s\n", "#define DefaultLinuxDistribution LinuxUnknown");
+ fprintf (inFile, "%s\n", "#define DefaultLinuxDistName Unknown");
+ /* would like to know what version of the distribution it is */
+}
+
+static void
+get_ld_version(FILE *inFile)
+{
+ FILE* ldprog;
+ signed char c;
int ldmajor, ldminor;
+ const char *ld = "ld -v";
+
+#ifdef CROSSCOMPILE
+ if (CrossCompiling) {
+ char cmd[PATH_MAX];
+ strcpy (cmd, CrossCompileDir);
+ strcat (cmd,"/");
+ strcat (cmd,ld);
+ ldprog = popen (cmd, "r");
+ } else
+#endif
+ ldprog = popen (ld, "r");
if (ldprog) {
do {
@@ -986,20 +1129,57 @@ static void get_ld_version(inFile)
} while (c != EOF && !isdigit (c));
ungetc (c, ldprog);
(void) fscanf (ldprog, "%d.%d", &ldmajor, &ldminor);
- fprintf(inFile, "#define DefaultLinuxBinUtilsMajorVersion %d\n",
- ldmajor * 10 + ldminor);
+ /* Start conversion to a more rational number */
+ if ((ldmajor > 2) || ((ldmajor == 2) && (ldminor > 9)))
+ ldmajor *= 100;
+ else
+ ldmajor *= 10;
+
+ fprintf(inFile, "#define DefaultLinuxBinUtilsMajorVersion %d\n",
+ ldmajor + ldminor);
pclose (ldprog);
}
}
#endif
-#ifndef PATH_MAX
-#define PATH_MAX 1024
+#if defined __FreeBSD__
+static void
+get_binary_format(FILE *inFile)
+{
+ int mib[2];
+ size_t len;
+ int osrel = 0;
+ FILE *objprog = NULL;
+ int iself = 0;
+ char buf[10];
+ char cmd[PATH_MAX];
+
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_OSRELDATE;
+ len = sizeof(osrel);
+ sysctl(mib, 2, &osrel, &len, NULL, 0);
+ if (CrossCompiling) {
+ strcpy (cmd, CrossCompileDir);
+ strcat (cmd, "/");
+ strcat (cmd,"objformat");
+ } else
+ strcpy (cmd, "objformat");
+
+ if (osrel >= 300004 &&
+ (objprog = popen(cmd, "r")) != NULL &&
+ fgets(buf, sizeof(buf), objprog) != NULL &&
+ strncmp(buf, "elf", 3) == 0)
+ iself = 1;
+ if (objprog)
+ pclose(objprog);
+
+ fprintf(inFile, "#define DefaultToElfFormat %s\n", iself ? "YES" : "NO");
+}
#endif
#if defined(sun) && defined(__SVR4)
-static void get_sun_compiler_versions (inFile)
- FILE* inFile;
+static void
+get_sun_compiler_versions (FILE *inFile)
{
char buf[PATH_MAX];
char cmd[PATH_MAX];
@@ -1010,6 +1190,18 @@ static void get_sun_compiler_versions (inFile)
struct stat sb;
FILE* ccproc;
+#if defined CROSSCOMPILE
+ if (CrossCompiling) {
+ int len = strlen(CrossCompileDir);
+ len += 3;
+ sunpro_cc = (char *) malloc(len);
+ sunpro_CC = (char *) malloc(len);
+ strcpy(sunpro_cc,CrossCompileDir);
+ strcpy(sunpro_CC,CrossCompileDir);
+ strcat(sunpro_cc,"/cc");
+ strcat(sunpro_CC,"/CC");
+ }
+#endif
if (lstat (sunpro_cc, &sb) == 0) {
strcpy (cmd, sunpro_cc);
strcat (cmd, " -V 2>&1");
@@ -1018,10 +1210,10 @@ static void get_sun_compiler_versions (inFile)
vptr = strrchr (buf, 'C');
for (; !isdigit(*vptr); vptr++);
(void) sscanf (vptr, "%d.%d", &cmajor, &cminor);
- fprintf (inFile,
+ fprintf (inFile,
"#define DefaultSunProCCompilerMajorVersion %d\n",
cmajor);
- fprintf (inFile,
+ fprintf (inFile,
"#define DefaultSunProCCompilerMinorVersion %d\n",
cminor);
}
@@ -1037,10 +1229,10 @@ static void get_sun_compiler_versions (inFile)
vptr = strrchr (buf, 'C');
for (; !isdigit(*vptr); vptr++);
(void) sscanf (vptr, "%d.%d", &cmajor, &cminor);
- fprintf (inFile,
+ fprintf (inFile,
"#define DefaultSunProCplusplusCompilerMajorVersion %d\n",
cmajor);
- fprintf (inFile,
+ fprintf (inFile,
"#define DefaultSunProCplusplusCompilerMinorVersion %d\n",
cminor);
}
@@ -1051,119 +1243,375 @@ static void get_sun_compiler_versions (inFile)
}
#endif
-static void get_gcc_incdir(inFile)
- FILE* inFile;
+#if defined CROSSCOMPILE || defined __GNUC__
+static void
+get_gcc_version(FILE *inFile, char *name)
{
- static char* gcc_path[] = {
-#ifdef linux
- "/usr/bin/cc", /* for Linux PostIncDir */
+ fprintf (inFile, "#define HasGcc 1\n");
+#ifdef CROSSCOMPILE
+ if (CrossCompiling)
+ {
+ if (gnu_c > 1) {
+ fprintf (inFile, "#define HasGcc2 1\n");
+ if (gnu_c > 2)
+ fprintf (inFile, "#define HasGcc3 1\n");
+ }
+ fprintf (inFile, "#define GccMajorVersion %d\n", gnu_c);
+ fprintf (inFile, "#define GccMinorVersion %d\n", gnu_c_minor);
+ } else
+#endif
+ {
+#if __GNUC__ > 1
+ fprintf (inFile, "#define HasGcc2 1\n");
+# if __GNUC__ > 2
+ fprintf (inFile, "#define HasGcc3 1\n");
+# endif
+#endif
+ fprintf (inFile, "#define GccMajorVersion %d\n", __GNUC__);
+ fprintf (inFile, "#define GccMinorVersion %d\n", __GNUC_MINOR__);
+ }
+#if defined(HAS_MERGE_CONSTANTS)
+ fprintf (inFile, "#define HasGccMergeConstants %d\n", HAS_MERGE_CONSTANTS);
+#endif
+}
#endif
- "/usr/local/bin/gcc",
- "/opt/gnu/bin/gcc"
- };
+
+static boolean
+get_gcc(char *cmd)
+{
struct stat sb;
- int i;
+ static char* gcc_path[] = {
+# if defined(linux) || \
+ defined(__NetBSD__) || \
+ defined(__OpenBSD__) || \
+ defined(__FreeBSD__) || \
+ defined(__APPLE__) || \
+ defined(__GNU__)
+ "/usr/bin/cc", /* for Linux PostIncDir */
+# endif
+ "/usr/local/bin/gcc",
+ "/opt/gnu/bin/gcc",
+ "/usr/pkg/bin/gcc"
+ };
+
+#ifdef CROSSCOMPILE
+ static char* cross_cc_name[] = {
+ "cc",
+ "gcc"
+ };
+
+ if (CrossCompiling) {
+ int i;
+ for (i = 0; i < sizeof (cross_cc_name) / sizeof cross_cc_name[0]; i++){
+ strcpy (cmd, CrossCompileDir);
+ strcat (cmd, "/");
+ strcat (cmd, cross_cc_name[i]);
+ if (lstat (cmd, &sb) == 0) {
+ return TRUE;
+ break;
+ }
+ }
+ } else
+#endif
+ {
+ int i;
+ for (i = 0; i < sizeof (gcc_path) / sizeof gcc_path[0]; i++) {
+ if (lstat (gcc_path[i], &sb) == 0) {
+ strcpy (cmd, gcc_path[i]);
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+#if defined CROSSCOMPILE || !defined __UNIXOS2__
+static void
+get_gcc_incdir(FILE *inFile, char* name)
+{
FILE* gccproc;
char buf[PATH_MAX];
char cmd[PATH_MAX];
char* ptr;
+ strcpy(cmd,name);
+
buf[0] = '\0';
- for (i = 0; i < sizeof gcc_path / sizeof gcc_path[0]; i++) {
- if (lstat (gcc_path[i], &sb) == 0) {
- strcpy (cmd, gcc_path[i]);
- strcat (cmd, " --print-libgcc-file-name");
- if ((gccproc = popen (cmd, "r")) != NULL) {
- if (fgets (buf, PATH_MAX, gccproc) != NULL) {
+ strcat (cmd, " --print-libgcc-file-name");
+ if ((gccproc = popen (cmd, "r")) != NULL) {
+ if (fgets (buf, PATH_MAX, gccproc) != NULL) {
ptr = strstr (buf, "libgcc.a");
if (ptr) strcpy (ptr, "include");
- }
- (void) pclose (gccproc);
- break;
}
- }
+ (void) pclose (gccproc);
}
+
if (buf[0])
- fprintf (inFile, "#define DefaultGccIncludeDir %s\n", buf);
+ fprintf (inFile, "#define DefaultGccIncludeDir \"%s\"\n", buf);
}
+#endif
boolean
-define_os_defaults(inFile)
- FILE *inFile;
+define_os_defaults(FILE *inFile)
{
-#ifndef WIN32
-#if (defined(DEFAULT_OS_NAME) || defined(DEFAULT_OS_MAJOR_REV) || \
- defined(DEFAULT_OS_MINOR_REV) || defined(DEFAUL_OS_TEENY_REV))
- struct utsname name;
+#if defined CROSSCOMPILE || ( !defined(WIN32) && !defined(__UNIXOS2__) )
+#ifdef CROSSCOMPILE
+ if ((sys != win32) && (sys != emx))
+#endif
+ {
+# if (defined(DEFAULT_OS_NAME) || defined(DEFAULT_OS_MAJOR_REV) || \
+ defined(DEFAULT_OS_MINOR_REV) || defined(DEFAULT_OS_TEENY_REV))
+ struct utsname *name = NULL;
+ struct utsname uts_name;
char buf[SYS_NMLN * 5 + 1];
/* Obtain the system information. */
- if (uname(&name) < 0)
- LogFatal("Cannot invoke uname", "");
-
-# ifdef DEFAULT_OS_NAME
- parse_utsname(&name, DEFAULT_OS_NAME, buf,
- "Bad DEFAULT_OS_NAME syntax %s");
- if (buf[0] != '\0')
- fprintf(inFile, "#define DefaultOSName %s\n", buf);
-# endif
+#ifdef CROSSCOMPILE
+ if (!CrossCompiling)
+#endif
+ {
+ if (uname(&uts_name) < 0)
+ LogFatal("Cannot invoke uname", "");
+ else
+ name = &uts_name;
+ }
+#if defined CROSSCOMPILE && defined linux
+ else {
+ strncpy(uts_name.sysname,cross_uts_sysname,SYS_NMLN);
+ strncpy(uts_name.release,cross_uts_release,SYS_NMLN);
+ strncpy(uts_name.version,cross_uts_version,SYS_NMLN);
+ strncpy(uts_name.machine,cross_uts_machine,SYS_NMLN);
+ name = &uts_name;
+ }
+#endif
-# ifdef DEFAULT_OS_MAJOR_REV
- parse_utsname(&name, DEFAULT_OS_MAJOR_REV, buf,
- "Bad DEFAULT_OS_MAJOR_REV syntax %s");
- fprintf(inFile, "#define DefaultOSMajorVersion %s\n",
- *buf ? trim_version(buf) : "0");
-# endif
+# if defined DEFAULT_OS_NAME
+# if defined CROSSCOMPILE
+ if (!CrossCompiling)
+# endif
+ {
+ parse_utsname(name, DEFAULT_OS_NAME, buf,
+ "Bad DEFAULT_OS_NAME syntax %s");
+# ifdef DEFAULT_OS_NAME_FROB
+ DEFAULT_OS_NAME_FROB(buf, sizeof buf);
+# endif
+ if (buf[0] != '\0')
+ fprintf(inFile, "#define DefaultOSName %s\n", buf);
+ }
+# endif
-# ifdef DEFAULT_OS_MINOR_REV
- parse_utsname(&name, DEFAULT_OS_MINOR_REV, buf,
- "Bad DEFAULT_OS_MINOR_REV syntax %s");
- fprintf(inFile, "#define DefaultOSMinorVersion %s\n",
- *buf ? trim_version(buf) : "0");
-# endif
+# if defined CROSSCOMPILE
+ if (CrossCompiling && defaultOsName) {
+ parse_utsname(name, defaultOsName, buf,
+ "Bad DEFAULT_OS_NAME syntax %s");
+ if (defaultOsNameFrob)
+ defaultOsNameFrob(buf, sizeof buf);
+ if (buf[0] != '\0')
+ fprintf(inFile, "#define DefaultOSName %s\n", buf);
+ }
+# endif
+
+# ifdef DEFAULT_OS_MAJOR_REV
+# if defined CROSSCOMPILE
+ if (!CrossCompiling)
+# endif
+ {
+ parse_utsname(name, DEFAULT_OS_MAJOR_REV, buf,
+ "Bad DEFAULT_OS_MAJOR_REV syntax %s");
+# ifdef DEFAULT_OS_MAJOR_REV_FROB
+ DEFAULT_OS_MAJOR_REV_FROB(buf, sizeof buf);
+# endif
+ fprintf(inFile, "#define DefaultOSMajorVersion %s\n",
+ *buf ? trim_version(buf) : "0");
+ }
+# endif
+
+# if defined CROSSCOMPILE
+ if (CrossCompiling && defaultOsMajorRev) {
+ parse_utsname(name, defaultOsMajorRev, buf,
+ "Bad defaultOsMajorRev syntax %s");
+ if (defaultOsMajorRevFrob)
+ defaultOsMajorRevFrob(buf, sizeof buf);
+ fprintf(inFile, "#define DefaultOSMajorVersion %s\n",
+ *buf ? trim_version(buf) : "0");
+ }
+# endif
+
+# ifdef DEFAULT_OS_MINOR_REV
+# if defined CROSSCOMPILE
+ if (!CrossCompiling)
+# endif
+ {
+ parse_utsname(name, DEFAULT_OS_MINOR_REV, buf,
+ "Bad DEFAULT_OS_MINOR_REV syntax %s");
+# ifdef DEFAULT_OS_MINOR_REV_FROB
+ DEFAULT_OS_MINOR_REV_FROB(buf, sizeof buf);
+# endif
+ fprintf(inFile, "#define DefaultOSMinorVersion %s\n",
+ *buf ? trim_version(buf) : "0");
+ }
+# endif
+
+# if defined CROSSCOMPILE
+ if (CrossCompiling && defaultOsMinorRev) {
+ parse_utsname(name, defaultOsMinorRev, buf,
+ "Bad defaultOsMinorRev syntax %s");
+ if (defaultOsMinorRevFrob)
+ defaultOsMinorRevFrob(buf, sizeof buf);
+ fprintf(inFile, "#define DefaultOSMinorVersion %s\n",
+ *buf ? trim_version(buf) : "0");
+ }
+# endif
+
+# ifdef DEFAULT_OS_TEENY_REV
+# if defined CROSSCOMPILE
+ if (!CrossCompiling)
+# endif
+ {
+ parse_utsname(name, DEFAULT_OS_TEENY_REV, buf,
+ "Bad DEFAULT_OS_TEENY_REV syntax %s");
+# ifdef DEFAULT_OS_TEENY_REV_FROB
+ DEFAULT_OS_TEENY_REV_FROB(buf, sizeof buf);
+# endif
+ fprintf(inFile, "#define DefaultOSTeenyVersion %s\n",
+ *buf ? trim_version(buf) : "0");
+ }
+# endif
+
+# if defined CROSSCOMPILE
+ if (CrossCompiling && defaultOsTeenyRev) {
+ parse_utsname(name, defaultOsTeenyRev, buf,
+ "Bad defaultOsTeenyRev syntax %s");
+ if (defaultOsTeenyRevFrob)
+ defaultOsTeenyRevFrob(buf, sizeof buf);
+ fprintf(inFile, "#define DefaultOSTeenyVersion %s\n",
+ *buf ? trim_version(buf) : "0");
+ }
+# endif
+
+# ifdef DEFAULT_MACHINE_ARCHITECTURE
+# if defined CROSSCOMPILE
+ if (!CrossCompiling)
+# endif
+ {
+ parse_utsname(name, DEFAULT_MACHINE_ARCHITECTURE, buf,
+ "Bad DEFAULT_MACHINE_ARCHITECTURE %s");
+ fprintf(inFile, "#ifndef %s\n# define %s\n#endif\n", buf, buf);
+ }
+# endif
-# ifdef DEFAULT_OS_TEENY_REV
- parse_utsname(&name, DEFAULT_OS_TEENY_REV, buf,
- "Bad DEFAULT_OS_TEENY_REV syntax %s");
- fprintf(inFile, "#define DefaultOSTeenyVersion %s\n",
- *buf ? trim_version(buf) : "0");
+# if defined CROSSCOMPILE
+ if (CrossCompiling && defaultMachineArchitecture) {
+ parse_utsname(name, defaultMachineArchitecture, buf,
+ "Bad defaultMachineArchitecture syntax %s");
+ fprintf(inFile, "#ifndef %s\n# define %s\n#endif\n", buf, buf);
+ }
+# endif
# endif
-#endif
-#ifdef linux
- get_distrib (inFile);
- get_libc_version (inFile);
- get_ld_version(inFile);
-#endif
- get_gcc_incdir(inFile);
-#if defined (sun) && defined(SVR4)
- get_sun_compiler_versions (inFile);
-#endif
-#else /* WIN32 */
- OSVERSIONINFO osvi;
- static char* os_names[] = { "Win32s", "Windows 95", "Windows NT" };
+# if defined CROSSCOMPILE
+ if (CrossCompiling)
+ get_cross_compile_dir(inFile);
+ else
+# endif
+ fprintf(inFile, "#define CrossCompiling NO\n");
+# if defined CROSSCOMPILE
+ if (CrossCompiling && sys == LinuX)
+# endif
+# if defined CROSSCOMPILE || defined linux
+# ifdef CROSSCOMPILE
+ if (sys == LinuX)
+# endif
+ get_distrib (inFile);
+# endif
+# if defined linux
+# if defined CROSSCOMPILE
+ if (!CrossCompiling)
+# endif
+ get_libc_version (inFile);
+# if defined CROSSCOMPILE
+ else {
+ fprintf(inFile,"#define DefaultLinuxCLibMajorVersion %d\n",
+ glibc_major);
+ fprintf(inFile,"#define DefaultLinuxCLibMinorVersion %d\n",
+ glibc_minor);
+ fprintf(inFile,"#define DefaultLinuxCLibTeenyVersion 0\n");
+ }
+# endif
+# endif /* linux */
+# if defined CROSSCOMPILE || defined linux
+# if defined CROSSCOMPILE
+ if (sys == LinuX)
+# endif
+ get_ld_version(inFile);
+# endif
+# if defined (sun) && defined(SVR4)
+ get_sun_compiler_versions (inFile);
+# endif
+# if defined CROSSCOMPILE || defined __GNUC__
+# if defined CROSSCOMPILE
+ if (gnu_c)
+# endif
+ {
+ char name[PATH_MAX];
+ if (get_gcc(name)) {
+ get_gcc_version (inFile,name);
+# if defined CROSSCOMPILE || !defined __UNIXOS2__
+# if defined CROSSCOMPILE
+ if (sys != emx)
+# endif
+ get_gcc_incdir(inFile,name);
+# endif
+ }
+ }
+# endif
+# if defined __FreeBSD__
+# if defined CROSSCOMPILE
+ if (sys == freeBSD)
+# endif
+ get_binary_format(inFile);
+# endif
+ }
+#endif /* !WIN32 && !__UNIXOS2__*/
+#if defined WIN32
+# ifdef CROSSCOMPILE
+ else if (sys == win32 && !CrossCompiling)
+# endif
+ {
+ OSVERSIONINFO osvi;
+ static char* os_names[] = { "Win32s", "Windows 95", "Windows NT" };
- memset(&osvi, 0, sizeof(OSVERSIONINFO));
- osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
- GetVersionEx (&osvi);
+ memset(&osvi, 0, sizeof(OSVERSIONINFO));
+ osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
+ GetVersionEx (&osvi);
- fprintf (inFile, "#define DefaultOSName Microsoft %s\n",
- os_names[osvi.dwPlatformId]);
+ fprintf (inFile, "#define DefaultOSName Microsoft %s\n",
+ os_names[osvi.dwPlatformId]);
- fprintf(inFile, "#define DefaultOSMajorVersion %d\n", osvi.dwMajorVersion);
- fprintf(inFile, "#define DefaultOSMinorVersion %d\n", osvi.dwMinorVersion);
- fprintf(inFile, "#define DefaultOSTeenyVersion %d\n",
- osvi.dwBuildNumber & 0xFFFF);
+ fprintf(inFile, "#define DefaultOSMajorVersion %d\n", osvi.dwMajorVersion);
+ fprintf(inFile, "#define DefaultOSMinorVersion %d\n", osvi.dwMinorVersion);
+ fprintf(inFile, "#define DefaultOSTeenyVersion %d\n",
+ osvi.dwBuildNumber & 0xFFFF);
+ }
#endif /* WIN32 */
- return FALSE;
+#ifdef CROSSCOMPILE
+ else if (sys == emx)
+#endif
+#if defined CROSSCOMPILE || defined __UNIXOS2__
+ {
+ fprintf(inFile, "#define DefaultOSMajorVersion 4\n");
+ fprintf(inFile, "#define DefaultOSMinorVersion 0\n");
+ fprintf(inFile, "#define DefaultOSTeenyVersion 0\n");
+ }
+#endif /* EMX */
+#if defined(__OpenBSD__)
+ get_stackprotector(inFile);
+#endif
+ return FALSE;
}
void
-cppit(imakefile, template, masterc, outfd, outfname)
- char *imakefile;
- char *template;
- char *masterc;
- FILE *outfd;
- char *outfname;
+cppit(char *imakefile, char *template, char *masterc,
+ FILE *outfd, char *outfname)
{
FILE *inFile;
@@ -1180,7 +1628,7 @@ cppit(imakefile, template, masterc, outfd, outfname)
fprintf(inFile, IncludeFmt, ImakeTmplSym) < 0 ||
optional_include(inFile, "IMAKE_ADMIN_MACROS", "adminmacros") ||
optional_include(inFile, "IMAKE_LOCAL_MACROS", "localmacros") ||
- fflush(inFile) ||
+ fflush(inFile) ||
fclose(inFile))
LogFatal("Cannot write to %s.", masterc);
/*
@@ -1191,14 +1639,13 @@ cppit(imakefile, template, masterc, outfd, outfname)
}
void
-makeit()
+makeit(void)
{
doit(NULL, make_argv[0], make_argv);
}
char *
-CleanCppInput(imakefile)
- char *imakefile;
+CleanCppInput(char *imakefile)
{
FILE *outFile = NULL;
FILE *inFile;
@@ -1220,7 +1667,7 @@ CleanCppInput(imakefile)
LogFatal("Cannot stat %s for size.", imakefile);
buf = Emalloc((int)st.st_size+3);
count = fread(buf + 2, 1, st.st_size, inFile);
- if (count == 0 && st.st_size != 0)
+ if (count == 0 && st.st_size != 0)
LogFatal("Cannot read %s:", imakefile);
fclose(inFile);
buf[0] = '\n';
@@ -1235,7 +1682,7 @@ CleanCppInput(imakefile)
while (*ptoken == ' ' || *ptoken == '\t')
ptoken++;
pend = ptoken;
- while (*pend && *pend != ' ' && *pend != '\t' && *pend != '\n')
+ while (*pend && *pend != ' ' && *pend != '\t' && *pend != '\n' && *pend != '\r')
pend++;
savec = *pend;
*pend = '\0';
@@ -1252,12 +1699,28 @@ CleanCppInput(imakefile)
strcmp(ptoken, "pragma") &&
strcmp(ptoken, "undef")) {
if (outFile == NULL) {
+#ifdef HAS_MKSTEMP
+ int fd;
+#endif
tmpImakefile = Strdup(tmpImakefile);
- (void) mktemp(tmpImakefile);
- outFile = fopen(tmpImakefile, "w");
- if (outFile == NULL)
+#ifndef HAS_MKSTEMP
+ if (mktemp(tmpImakefile) == NULL ||
+ (outFile = fopen(tmpImakefile, "w+")) == NULL) {
LogFatal("Cannot open %s for write.",
tmpImakefile);
+ }
+#else
+ fd=mkstemp(tmpImakefile);
+ if (fd != -1)
+ outFile = fdopen(fd, "w");
+ if (outFile == NULL) {
+ if (fd != -1) {
+ unlink(tmpImakefile); close(fd);
+ }
+ LogFatal("Cannot open %s for write.",
+ tmpImakefile);
+ }
+#endif
}
writetmpfile(outFile, punwritten, pbuf-punwritten,
tmpImakefile);
@@ -1274,6 +1737,7 @@ CleanCppInput(imakefile)
if (outFile) {
writetmpfile(outFile, punwritten, pbuf-punwritten, tmpImakefile);
fclose(outFile);
+
return tmpImakefile;
}
@@ -1281,9 +1745,7 @@ CleanCppInput(imakefile)
}
void
-CleanCppOutput(tmpfd, tmpfname)
- FILE *tmpfd;
- char *tmpfname;
+CleanCppOutput(FILE *tmpfd, char *tmpfname)
{
char *input;
int blankline = 0;
@@ -1292,10 +1754,20 @@ CleanCppOutput(tmpfd, tmpfname)
if (isempty(input)) {
if (blankline++)
continue;
- KludgeResetRule();
+#ifdef CROSSCOMPILE
+ if (fixup_whitespace)
+#endif
+#if defined CROSSCOMPILE || defined FIXUP_CPP_WHITESPACE
+ KludgeResetRule();
+#endif
} else {
blankline = 0;
- KludgeOutputLine(&input);
+#ifdef CROSSCOMPILE
+ if (fixup_whitespace)
+#endif
+#if defined CROSSCOMPILE || defined FIXUP_CPP_WHITESPACE
+ KludgeOutputLine(&input);
+#endif
writetmpfile(tmpfd, input, strlen(input), tmpfname);
}
writetmpfile(tmpfd, "\n", 1, tmpfname);
@@ -1317,10 +1789,9 @@ CleanCppOutput(tmpfd, tmpfname)
* "XCOMM" token is transformed to "#".
*/
boolean
-isempty(line)
- register char *line;
+isempty(char *line)
{
- register char *pend;
+ char *pend;
/*
* Check for lines of the form
@@ -1336,7 +1807,7 @@ isempty(line)
pend[3] == 'e' && pend[4] == ' ')
pend += 5;
if (isdigit(*pend)) {
- do {
+ do {
pend++;
} while (isdigit(*pend));
if (*pend == '\n' || *pend == '\0')
@@ -1350,50 +1821,53 @@ isempty(line)
for (pend = line; *pend; pend++) {
if (*pend == 'X' && pend[1] == 'C' && pend[2] == 'O' &&
pend[3] == 'M' && pend[4] == 'M' &&
- (pend == line || pend[-1] == ' ' || pend[-1] == '\t') &&
- (pend[5] == ' ' || pend[5] == '\t' || pend[5] == '\0'))
+ (pend == line || pend[-1] == ' ' || pend[-1] == '\t' || pend[-1] == '\r') &&
+ (pend[5] == ' ' || pend[5] == '\t' || pend[5] == '\r' || pend[5] == '\0'))
{
*pend = '#';
strcpy(pend+1, pend+5);
}
-#ifdef MAGIC_MAKE_VARS
- if (*pend == 'X' && pend[1] == 'V' && pend[2] == 'A' &&
- pend[3] == 'R')
- {
- char varbuf[5];
- int i;
-
- if (pend[4] == 'd' && pend[5] == 'e' && pend[6] == 'f' &&
- pend[7] >= '0' && pend[7] <= '9')
- {
- i = pend[7] - '0';
- sprintf(varbuf, "%0.4d", xvariable);
- strncpy(pend+4, varbuf, 4);
- xvariables[i] = xvariable;
- xvariable = (xvariable + 1) % 10000;
- }
- else if (pend[4] == 'u' && pend[5] == 's' &&
- pend[6] == 'e' && pend[7] >= '0' &&
- pend[7] <= '9')
+#ifdef CROSSCOMPILE
+ if (magic_make_vars)
+#endif
+ {
+#if defined CROSSCOMPILE || defined MAGIC_MAKE_VARS
+ if (*pend == 'X' && pend[1] == 'V' && pend[2] == 'A' &&
+ pend[3] == 'R')
{
- i = pend[7] - '0';
- sprintf(varbuf, "%0.4d", xvariables[i]);
- strncpy(pend+4, varbuf, 4);
+ char varbuf[5];
+ int i;
+
+ if (pend[4] == 'd' && pend[5] == 'e' && pend[6] == 'f' &&
+ pend[7] >= '0' && pend[7] <= '9')
+ {
+ i = pend[7] - '0';
+ sprintf(varbuf, "%0.4d", xvariable);
+ strncpy(pend+4, varbuf, 4);
+ xvariables[i] = xvariable;
+ xvariable = (xvariable + 1) % 10000;
+ }
+ else if (pend[4] == 'u' && pend[5] == 's' &&
+ pend[6] == 'e' && pend[7] >= '0' &&
+ pend[7] <= '9')
+ {
+ i = pend[7] - '0';
+ sprintf(varbuf, "%0.4d", xvariables[i]);
+ strncpy(pend+4, varbuf, 4);
+ }
}
- }
#endif
+ }
}
}
- while (--pend >= line && (*pend == ' ' || *pend == '\t')) ;
+ while (--pend >= line && (*pend == ' ' || *pend == '\t' || *pend == '\r')) ;
pend[1] = '\0';
return (*line == '\0');
}
/*ARGSUSED*/
char *
-ReadLine(tmpfd, tmpfname)
- FILE *tmpfd;
- char *tmpfname;
+ReadLine(FILE *tmpfd, char *tmpfname)
{
static boolean initialized = FALSE;
static char *buf, *pline, *end;
@@ -1403,8 +1877,8 @@ ReadLine(tmpfd, tmpfname)
#ifdef WIN32
FILE *fp = tmpfd;
#endif
- int total_red;
- struct stat st;
+ int total_red;
+ struct stat st;
/*
* Slurp it all up.
@@ -1414,12 +1888,12 @@ ReadLine(tmpfd, tmpfname)
LogFatal("cannot stat %s for size", tmpMakefile);
pline = buf = Emalloc((int)st.st_size+1);
total_red = fread(buf, 1, st.st_size, tmpfd);
- if (total_red == 0 && st.st_size != 0)
+ if (total_red == 0 && st.st_size != 0)
LogFatal("cannot read %s", tmpMakefile);
end = buf + total_red;
*end = '\0';
fseek(tmpfd, 0, 0);
-#if defined(SYSV) || defined(WIN32)
+#if defined(SYSV) || defined(WIN32) || defined(USE_FREOPEN)
tmpfd = freopen(tmpfname, "w+", tmpfd);
#ifdef WIN32
if (! tmpfd) /* if failed try again */
@@ -1446,9 +1920,14 @@ ReadLine(tmpfd, tmpfname)
break;
}
else if (*p1 == '\n') { /* real EOL */
-#ifdef WIN32
+#if defined CROSSCOMPILE || defined WIN32
+# if defined CROSSCOMPILE
+ if (sys == win32)
+# endif
+ {
if (p1 > pline && p1[-1] == '\r')
p1[-1] = '\0';
+ }
#endif
*p1++ = '\0';
break;
@@ -1464,19 +1943,14 @@ ReadLine(tmpfd, tmpfname)
}
void
-writetmpfile(fd, buf, cnt, fname)
- FILE *fd;
- int cnt;
- char *buf;
- char *fname;
+writetmpfile(FILE *fd, char *buf, int cnt, char *fname)
{
if (fwrite(buf, sizeof(char), cnt, fd) == -1)
LogFatal("Cannot write to %s.", fname);
}
char *
-Emalloc(size)
- int size;
+Emalloc(int size)
{
char *p;
@@ -1485,10 +1959,9 @@ Emalloc(size)
return(p);
}
-#ifdef FIXUP_CPP_WHITESPACE
+#if defined CROSSCOMPILE || defined FIXUP_CPP_WHITESPACE
void
-KludgeOutputLine(pline)
- char **pline;
+KludgeOutputLine(char **pline)
{
char *p = *pline;
char quotechar = '\0';
@@ -1497,29 +1970,38 @@ KludgeOutputLine(pline)
case '#': /*Comment - ignore*/
break;
case '\t': /*Already tabbed - ignore it*/
- break;
+ break;
case ' ': /*May need a tab*/
default:
-# ifdef INLINE_SYNTAX
- if (*p == '<' && p[1] == '<') { /* inline file close */
- InInline--;
- InRule = TRUE;
- break;
+#ifdef CROSSCOMPILE
+ if (inline_syntax)
+#endif
+#if defined CROSSCOMPILE || defined INLINE_SYNTAX
+ {
+ if (*p == '<' && p[1] == '<') { /* inline file close */
+ InInline--;
+ InRule = TRUE;
+ break;
+ }
}
-# endif
+#endif
/*
- * The following cases should not be treated as beginning of
+ * The following cases should not be treated as beginning of
* rules:
- * variable := name (GNU make)
- * variable = .*:.* (':' should be allowed as value)
- * sed 's:/a:/b:' (: used in quoted values)
+ * variable := name (GNU make)
+ * variable = .*:.* (':' should be allowed as value)
+ * sed 's:/a:/b:' (: used in quoted values)
*/
for (; *p; p++) {
if (quotechar) {
if (quotechar == '\\' ||
(*p == quotechar &&
-# ifdef WIN32
- quotechar != ')' &&
+# if defined CROSSCOMPILE || defined WIN32
+ (
+# if defined CROSSCOMPILE
+ (sys == win32) &&
+# endif
+ quotechar != ')') &&
# endif
p[-1] != '\\'))
quotechar = '\0';
@@ -1541,19 +2023,26 @@ KludgeOutputLine(pline)
quotechar = ']';
break;
case '=':
-# ifdef REMOVE_CPP_LEADSPACE
- if (!InRule && **pline == ' ') {
- while (**pline == ' ')
- (*pline)++;
+#ifdef CROSSCOMPILE
+ if (remove_cpp_leadspace)
+#endif
+#if defined CROSSCOMPILE || defined REMOVE_CPP_LEADSPACE
+ {
+ if (!InRule && **pline == ' ') {
+ while (**pline == ' ')
+ (*pline)++;
+ }
}
-# endif
+#endif
goto breakfor;
-# ifdef INLINE_SYNTAX
+#if defined CROSSCOMPILE || defined INLINE_SYNTAX
case '<':
- if (p[1] == '<') /* inline file start */
- InInline++;
+ if (inline_syntax) {
+ if (p[1] == '<') /* inline file start */
+ InInline++;
+ }
break;
-# endif
+#endif
case ':':
if (p[1] == '=')
goto breakfor;
@@ -1571,18 +2060,51 @@ breakfor:
}
void
-KludgeResetRule()
+KludgeResetRule(void)
{
InRule = FALSE;
}
-#endif /* FIXUP_CPP_WHITESPACE */
-
+#endif
char *
-Strdup(cp)
- register char *cp;
+Strdup(char *cp)
{
- register char *new = Emalloc(strlen(cp) + 1);
+ char *new = Emalloc(strlen(cp) + 1);
strcpy(new, cp);
return new;
}
+
+#ifdef CROSSCOMPILE
+char*
+CrossCompileCPP(void)
+{
+ char *cpp, *c;
+ int len ;
+ if (crosscompile_use_cc_e)
+ AddCppArg("-E");
+
+ cpp = strrchr(crosscompile_cpp,'/');
+ if (!cpp)
+ cpp = crosscompile_cpp;
+ else
+ cpp++;
+
+ len = strlen(cpp) + strlen(CrossCompileDir) + 2;
+ c = Emalloc(len);
+
+ (void)snprintf(c, len,"%s/%s",CrossCompileDir,cpp);
+
+ return c;
+}
+
+#endif
+
+#ifdef CROSSCOMPILE
+static void
+get_cross_compile_dir(FILE *inFile)
+{
+ fprintf(inFile, "#define CrossCompileDir %s\n",
+ CrossCompileDir);
+ fprintf(inFile, "#define CrossCompiling YES\n");
+}
+#endif
diff --git a/imake.man b/imake.man
index 2372d3f..a3b47bf 100644
--- a/imake.man
+++ b/imake.man
@@ -22,11 +22,15 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from The Open Group.
-.TH IMAKE 1 "Release 6.1" "X Version 11"
+.\"
+.\" $XFree86: xc/config/imake/imake.man,v 1.9 2002/11/20 21:48:46 herrb Exp $
+.\"
+.TH IMAKE 1 __xorgversion__
.SH NAME
imake \- C preprocessor interface to the make utility
.SH SYNOPSIS
\fBimake\fP [ \fB\-D\fP\fIdefine\fP ] [ \fB\-I\fP\fIdir\fP ]
+[ \fB\-U\fP\fIdefine\fP ]
[ \fB\-T\fP\fItemplate\fP ]
[ \fB\-f\fP \fIfilename\fP ] [ \fB\-C\fP \fIfilename\fP ]
[ \fB\-s\fP \fIfilename\fP ] [ \fB\-e\fP ]
@@ -54,6 +58,10 @@ This option is passed directly to \fIcpp\fP. It is typically used to
indicate the directory in which the \fIimake\fP template and configuration
files may be found.
.TP 8
+.B \-U\fIdefine\fP
+This option is passed directly to \fIcpp\fP. It is typically used to
+unset variables when debugging \fIimake\fP configuration files.
+.TP 8
.B \-T\fItemplate\fP
This option specifies the name of the master template file (which is usually
located in the directory specified with \fI\-I\fP) used by \fIcpp\fP.
@@ -87,9 +95,9 @@ on the command line and passes the name of a file containing the
following 3 lines:
.sp
.nf
- #define IMAKE_TEMPLATE "Imake.tmpl"
- #define INCLUDE_IMAKEFILE <Imakefile>
- #include IMAKE_TEMPLATE
+\& #define IMAKE_TEMPLATE "Imake.tmpl"
+\& #define INCLUDE_IMAKEFILE <Imakefile>
+\& #include IMAKE_TEMPLATE
.fi
.sp
where \fIImake.tmpl\fP and \fIImakefile\fP may be overridden by the
@@ -126,8 +134,8 @@ For example, the macro
.ta 1i 1.6i 5i
.nf
-#define program_target(program, objlist) @@\e
-program: objlist @@\e
+\& #define program_target(program, objlist) @@\e
+ program: objlist @@\e
$(CC) \-o $@ objlist $(LDFLAGS)
.fi
@@ -136,7 +144,7 @@ when called with
will expand to
.nf
-foo: foo1.o foo2.o
+ foo: foo1.o foo2.o
$(CC) \-o $@ foo1.o foo2.o $(LDFLAGS)
.fi
@@ -216,7 +224,7 @@ Imakefile.c temporary input file for cpp
.br
/tmp/IIf.XXXXXX temporary Imakefile if specified Imakefile uses # comments
.br
-/lib/cpp default C preprocessor
+__cpp__ default C preprocessor
.DT
.SH "SEE ALSO"
make(1), xmkmf(1)
@@ -238,7 +246,7 @@ If defined, this should be a valid path to a preprocessor program.
E.g., ``/usr/local/cpp''.
By default,
.I imake
-will use /lib/cpp.
+will use cc -E or __cpp__, depending on the OS specific configuration.
.TP 5
.B IMAKEMAKE
If defined, this should be a valid path to a make program,
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/makeg.man b/makeg.man
index 6f5ded4..1259d43 100644
--- a/makeg.man
+++ b/makeg.man
@@ -23,7 +23,10 @@
.\" other dealings in this Software without prior written authorization
.\" from The Open Group.
.\"
-.TH MAKEG 1 "Release 6.4" "X Version 11"
+.\"
+.\" $XFree86: xc/config/util/makeg.man,v 1.3 2001/12/14 19:53:22 dawes Exp $
+.\"
+.TH MAKEG 1 __xorgversion__
.SH NAME
makeg \- make a debuggable executable
.SH SYNOPSIS
diff --git a/mdepend.cpp b/mdepend.cpp
index 75b0652..617051b 100644
--- a/mdepend.cpp
+++ b/mdepend.cpp
@@ -22,11 +22,14 @@ XCOMM work on both USG and BSD systems. However, when System V.4 comes out,
XCOMM USG users will probably have to change "silent" to "-s" instead of
XCOMM "-" (at least, that is what the documentation implies).
XCOMM
+XCOMM $XFree86: xc/config/util/mdepend.cpp,v 3.10 2001/08/17 13:27:50 dawes Exp $
+XCOMM
+
CC=PREPROC
silent='-'
-TMP=/tmp/mdep$$
+TMP=`pwd`/.mdep$$
CPPCMD=${TMP}a
DEPENDLINES=${TMP}b
TMPMAKEFILE=${TMP}c
@@ -63,7 +66,7 @@ do
endmarker=""
else
case "$1" in
- -D*|-I*)
+ -D*|-I*|-U*)
echo $n " '$1'$c" >> $ARGS
;;
@@ -84,9 +87,13 @@ do
-f*)
if [ "$1" = "-f-" ]; then
makefile="-"
- else
+ elif [ "$1" = "-f" ]; then
makefile="$2"
shift
+ else
+ echo "$1" | sed 's/^\-f//' >${TMP}arg
+ makefile="`cat ${TMP}arg`"
+ rm -f ${TMP}arg
fi
;;
-o)
@@ -168,8 +175,15 @@ done \
| awk '{
if ($1 != $4 && $2 != "#ident" && $2 != "#pragma")
{
- ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'"
- print ofile, $4
+ numparts = split( $1, ofileparts, "\." )
+ ofile = ""
+ for ( i = 1; i < numparts; i = i+1 )
+ {
+ if (i != 1 )
+ ofile = ofile "."
+ ofile = ofile ofileparts[i]
+ }
+ print ofile "'"$objsuffix"'", $4
}
}' \
| sort -u \
diff --git a/mergelib.cpp b/mergelib.cpp
index c0d7c02..1c7cc64 100644
--- a/mergelib.cpp
+++ b/mergelib.cpp
@@ -61,9 +61,14 @@ XCOMM
tmpdir=tmp.$$
origdir=..
+XCOMM Remove directory if we fail
+trap "rm -rf $tmpdir; exit 1" 1 2 15
+trap "rm -rf $tmpdir; exit 0" 1 2 13
+
mkdir $tmpdir
-if [ ! -d $tmpdir ]; then
+XCOMM Security: if $tmpdir exists before mkdir exit immediately
+if [ $? -gt 0 -o ! -d $tmpdir ]; then
echo "$0: unable to create temporary directory $tmpdir" 1>&2
exit 1
fi
@@ -83,7 +88,7 @@ XCOMM
XCOMM In the temp directory, extract all of the object files and prefix
XCOMM them with some symbol to avoid name clashes with the base library.
XCOMM
-cd $tmpdir
+cd $tmpdir || exit 1
ar x ${upfrom}$fromlib
for i in *.o; do
mv $i ${objprefix}$i
@@ -98,5 +103,3 @@ RANLIB ${upto}$tolib
cd $origdir
rm -rf $tmpdir
-
-
diff --git a/mkdirhier b/mkdirhier
index 17390f4..09b89ee 100644
--- a/mkdirhier
+++ b/mkdirhier
@@ -51,7 +51,7 @@ do
paths=$path
for filename
do
- if [ "$filename" != "." ]; then
+ if [ -n "$filename" -a "$filename" != "." ]; then
path=$path/$filename
paths=$paths$newline$path
fi
diff --git a/mkdirhier.man b/mkdirhier.man
index ea85390..0fd893b 100644
--- a/mkdirhier.man
+++ b/mkdirhier.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 MKDIRHIER 1 "Release 6.4" "X Version 11"
+.\"
+.\" $XFree86: xc/config/util/mkdirhier.man,v 1.3 2001/12/14 19:53:22 dawes Exp $
+.\"
+.TH MKDIRHIER 1 __xorgversion__
.SH NAME
mkdirhier \- makes a directory hierarchy
.SH SYNOPSIS
diff --git a/xmkmf.cpp b/xmkmf.cpp
index 0eedb54..7baf0ea 100644
--- a/xmkmf.cpp
+++ b/xmkmf.cpp
@@ -1,5 +1,6 @@
XCOMM!/bin/sh
+XCOMM $XFree86: xc/config/util/xmkmf.cpp,v 1.4 2001/01/17 16:39:02 dawes Exp $
XCOMM
XCOMM make a Makefile from an Imakefile from inside or outside the sources
XCOMM
@@ -11,13 +12,24 @@ configdirspec=CONFIGDIRSPEC
topdir=
curdir=.
do_all=
+imake_defines=
-case "$1" in
--a)
- do_all="yes"
- shift
- ;;
-esac
+while [ $# -gt 0 ]
+do
+ case "$1" in
+ -D*)
+ imake_defines="$imake_defines $1"
+ shift
+ ;;
+ -a)
+ do_all="yes"
+ shift
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
case $# in
0) ;;
@@ -41,10 +53,10 @@ else
args="-I$topdir/config/cf -DTOPDIR=$topdir -DCURDIR=$curdir"
fi
-echo imake $args
+echo imake $imake_defines $args
case "$do_all" in
yes)
- imake $args &&
+ imake $imake_defines $args &&
echo "make Makefiles" &&
make Makefiles &&
echo "make includes" &&
@@ -53,6 +65,6 @@ yes)
make depend
;;
*)
- imake $args
+ imake $imake_defines $args
;;
esac
diff --git a/xmkmf.man b/xmkmf.man
index f1094bd..bd018d6 100644
--- a/xmkmf.man
+++ b/xmkmf.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 XMKMF 1 "Release 6.4" "X Version 11"
+.\"
+.\" $XFree86: xc/config/util/xmkmf.man,v 1.3 2001/12/14 19:53:22 dawes Exp $
+.\"
+.TH XMKMF 1 __xorgversion__
.SH NAME
xmkmf \- create a Makefile from an Imakefile
.SH SYNOPSIS