diff options
author | Reinhard Tartler <siretart@tauware.de> | 2011-10-10 17:43:39 +0200 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2011-10-10 17:43:39 +0200 |
commit | f4092abdf94af6a99aff944d6264bc1284e8bdd4 (patch) | |
tree | 2ac1c9cc16ceb93edb2c4382c088dac5aeafdf0f /nx-X11/config/imake | |
parent | a840692edc9c6d19cd7c057f68e39c7d95eb767d (diff) | |
download | nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.gz nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.bz2 nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.zip |
Imported nx-X11-3.1.0-1.tar.gznx-X11/3.1.0-1
Summary: Imported nx-X11-3.1.0-1.tar.gz
Keywords:
Imported nx-X11-3.1.0-1.tar.gz
into Git repository
Diffstat (limited to 'nx-X11/config/imake')
-rw-r--r-- | nx-X11/config/imake/Imakefile | 84 | ||||
-rw-r--r-- | nx-X11/config/imake/Makefile.ini | 86 | ||||
-rw-r--r-- | nx-X11/config/imake/ccimake.c | 62 | ||||
-rw-r--r-- | nx-X11/config/imake/imake.c | 2203 | ||||
-rw-r--r-- | nx-X11/config/imake/imake.man | 262 | ||||
-rw-r--r-- | nx-X11/config/imake/imakemdep.h | 1532 | ||||
-rw-r--r-- | nx-X11/config/imake/imakesvc.cmd | 302 |
7 files changed, 4531 insertions, 0 deletions
diff --git a/nx-X11/config/imake/Imakefile b/nx-X11/config/imake/Imakefile new file mode 100644 index 000000000..13645443b --- /dev/null +++ b/nx-X11/config/imake/Imakefile @@ -0,0 +1,84 @@ +XCOMM $XdotOrg: xc/config/imake/Imakefile,v 1.3 2005/10/10 23:49:09 kem Exp $ +XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:41:50 cpqbld Exp $ +XCOMM +XCOMM +XCOMM +XCOMM +XCOMM $XFree86: xc/config/imake/Imakefile,v 3.18 2003/10/21 17:41:44 tsi Exp $ + +XCOMM Some compilers generate fatal errors if an -L directory does +XCOMM not exist. Since BUILDLIBDIR may not exist yet suppress its use. + LDPRELIB = + LDPRELIBS = + +DEPLIBS = + +INCLUDES = -I$(TOP)/include $(TOP_X_INCLUDES)/X11 +CPP_PROGRAM = CppCmd +CPP_DEFINES = -DCPP_PROGRAM="\"$(CPP_PROGRAM)\"" +GCC_COMMAND = $(CC) -fmerge-constants -xc /dev/null -S -o /dev/null 2> /dev/null 1> /dev/null +GCC_DEFINES = -DHAS_MERGE_CONSTANTS=`if $(GCC_COMMAND); then echo 1; else echo 0; fi` + +EXTRA_DEFINES=-DMONOLITH + +#ifdef CrossCompileDir +CROSSCOMPILEDIR = CrossCompileDir +CROSSCOMPILEDEFINES=-DCROSSCOMPILE -DCROSSCOMPILEDIR=\"$(CROSSCOMPILEDIR)\" +#else +CROSSCOMPILEDIR = +CROSSCOMPILEDEFINES= +BOOTSTRAPDEFINES = +#endif + +DEFINES = $(SIGNAL_DEFINES) $(BOOTSTRAPCFLAGS) $(CPP_DEFINES) $(GCC_DEFINES) \ + $(CROSSCOMPILEDEFINES) + +EXTRAMANDEFS = -D__cpp__="\"$(CPP_PROGRAM)\"" + +#if defined(MacIIArchitecture) || defined(SequentArchitecture) || defined(i386ScoArchitecture) +XBSDLIB = /**/ +#endif + +#ifdef CrossCompileDir +# ifdef TargetPreProcessCmd +CPP = TargetPreProcessCmd +# else +CPP = CrossCompileDir/cc -E - +# endif +IMAKEMDEFS_CPPDEFINES = $(DEFINES) -DCROSSCOMPILE_CPP +CppFileTarget(imakemdep_cpp.h,imakemdep.h,$(IMAKEMDEFS_CPPDEFINES),\ + NullParameter) +#endif + +#undef ImakeDependency +#define ImakeDependency(dummy) @@\ +imake.o: imakemdep_cpp.h @@\ +Makefile:: ProgramTargetName(imake) + +#if CrossCompiling +SimpleHostProgramTarget(imake) +#else +SimpleProgramTarget(imake) +#endif + +imakeonly:: $(PROGRAM) + +InstallDriverSDKNamedProg(imake,imake,$(DRIVERSDKDIR)/config/imake) + +#if HasClearmake +bootstrapdepend: depend +#else +bootstrapdepend: +#endif + +clean:: + RemoveFile(ProgramTargetName(ccimake)) + RemoveFile(Makefile.proto) + RemoveFile(imakemdep_cpp.h) + $(RM) -r bootstrap + +#ifdef OS2Architecture +clean:: + RemoveFiles(imake ccimake) + +#endif diff --git a/nx-X11/config/imake/Makefile.ini b/nx-X11/config/imake/Makefile.ini new file mode 100644 index 000000000..b9c22963e --- /dev/null +++ b/nx-X11/config/imake/Makefile.ini @@ -0,0 +1,86 @@ +# $Xorg: Makefile.ini,v 1.3 2000/08/17 19:41:50 cpqbld Exp $ +# +# WARNING WARNING WARNING WARNING WARNING WARNING WARNING +# +# This is NOT an automatically generated Makefile! It is hand-crafted as a +# bootstrap, may need editing for your system. The BOOTSTRAPCFLAGS variable +# may be given at the top of the build tree for systems that do not define +# any machine-specific preprocessor symbols. +# +# $XFree86: xc/config/imake/Makefile.ini,v 3.9 2000/10/26 17:57:45 dawes Exp $ + +CROSSCOMPILEDIR = +CROSSCOMPILEFLAGS = -DCROSSCOMPILEDIR=\"$(CROSSCOMPILEDIR)\" +BOOTSTRAPCFLAGS = +CC = cc +PREPROCESS_CMD = cc -E +CDEBUGFLAGS = -O +INCLUDES = -I../../include -I../../imports/x11/include/X11 +CFLAGS = $(BOOTSTRAPCFLAGS) $(CDEBUGFLAGS) $(INCLUDES) -DMONOLITH +IMAKEMDEP_CROSSCOMPILE = -DCROSSCOMPILE_CPP +SHELL = /bin/sh +RM = rm -f +MV = mv +MAKE = make +RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \ + tags TAGS make.log +NPROC = 1 + +imake:: + @echo "making imake with BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS) and CROSSCOMPILEFLAGS=$(CROSSCOMPILEFLAGS) in config/imake" + +imake:: imake.o + $(CC) -o imake $(CFLAGS) imake.o + +imake.o: ccimake imake.c imakemdep_cpp.h + $(CC) -c $(CFLAGS) `./ccimake` imake.c + +ccimake: ccimake.c + $(CC) -o ccimake $(CROSSCOMPILEFLAGS) $(CFLAGS) ccimake.c + +imakemdep_cpp.h: ccimake imakemdep.h + if [ -n "$(CROSSCOMPILEDIR)" ] ; then \ + $(CROSSCOMPILEDIR)/$(PREPROCESS_CMD) `./ccimake` \ + $(IMAKEMDEP_CROSSCOMPILE) imakemdep.h > imakemdep_cpp.h; \ + else touch imakemdep_cpp.h; fi + +# a derived object erroneously would get shared across platforms by clearmake +.NO_CONFIG_REC: ccimake + +bootstrap: + -@if [ -d bootstrap ]; then exit 0; else set -x; mkdir bootstrap; fi + $(MV) *.o bootstrap + @if [ -f imake.exe ]; then set -x; $(MV) imake.exe bootstrap; \ + elif [ -f imake ]; then set -x; $(MV) imake bootstrap; else exit 0; fi + +relink: + $(RM) imake + $(MAKE) $(MFLAGS) imake + +clean: + $(RM) ccimake imake.o imake + $(RM_CMD) \#* + $(RM) -r Makefile.proto Makefile Makefile.dep bootstrap + $(RM) imakemdep_cpp.h + +depend: + +imake.exe:: + @echo making imake with BOOTSTRAPCFLAGS=-DWIN32 + +imake.exe:: imake.obj + cl -nologo imake.obj libc.lib kernel32.lib + +imake.obj: imake.c + cl -nologo -W2 -D__STDC__ -c -DWIN32 $(CFLAGS) imake.c + +clean.Win32: + if exist imake.exe del imake.exe + if exist imake.obj del imake.obj + +clean.os2: + imakesvc 4 imake imake.exe imake.o /imake.exe + +imake.os2: imake.c + $(CC) -DBSD43 $(CFLAGS) -o imake.exe imake.c + copy imake.exe \\ diff --git a/nx-X11/config/imake/ccimake.c b/nx-X11/config/imake/ccimake.c new file mode 100644 index 000000000..30524d55f --- /dev/null +++ b/nx-X11/config/imake/ccimake.c @@ -0,0 +1,62 @@ +/* $Xorg: ccimake.c,v 1.4 2001/02/09 02:03:15 xorgcvs Exp $ */ +/* + +Copyright (c) 1993, 1994, 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 +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the 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 . + +*/ +/* $XFree86: xc/config/imake/ccimake.c,v 1.2 2001/04/01 13:59:56 tsi Exp $ */ + +/* + * Warning: This file must be kept as simple as possible so that it can + * compile without any special flags on all systems. Do not touch it unless + * you *really* know what you're doing. Make changes in imakemdep.h, not here. + */ + +#define CCIMAKE /* only get imake_ccflags definitions */ +#include "imakemdep.h" /* things to set when porting imake */ + +#ifndef imake_ccflags +# define imake_ccflags "-O" +#endif + +#ifndef CROSSCOMPILEDIR +# define CROSSCOMPILEDIR "" +#endif + +#define crosscompile_ccflags " -DCROSSCOMPILE " +#define crosscompiledir_str "-DCROSSCOMPILEDIR=" + +int +main() +{ + if (CROSSCOMPILEDIR[0] != '\0') { + write(1, crosscompiledir_str, sizeof(crosscompiledir_str) - 1); + write(1,"\"",1); + write(1, CROSSCOMPILEDIR, sizeof(CROSSCOMPILEDIR) - 1); + write(1,"\"",1); + write(1, crosscompile_ccflags, sizeof(crosscompile_ccflags) - 1); + } + write(1, imake_ccflags, sizeof(imake_ccflags) - 1); + return 0; +} + diff --git a/nx-X11/config/imake/imake.c b/nx-X11/config/imake/imake.c new file mode 100644 index 000000000..46e03daf2 --- /dev/null +++ b/nx-X11/config/imake/imake.c @@ -0,0 +1,2203 @@ + +/*************************************************************************** + * * + * Porting Note * + * * + * Add the value of BOOTSTRAPCFLAGS to the cpp_argv table so that it will * + * be passed to the template file. * + * * + ***************************************************************************/ +/* $XFree86: xc/config/imake/imake.c,v 3.63tsi Exp $ */ + +/* + * +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 +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +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. + * While a guest engineer at Project Athena, MIT + * + * imake: the include-make program. + * + * Usage: imake [-Idir] [-Ddefine] [-T template] [-f imakefile ] [-C Imakefile.c ] [-s] [-e] [-v] [make flags] + * + * Imake takes a template file (Imake.tmpl) and a prototype (Imakefile) + * and runs cpp on them producing a Makefile. It then optionally runs make + * 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 + * -f specify the Imakefile file + * -C specify the name to use instead of Imakefile.c + * -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 + * -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 + * found by searching the $PATH variable. + * Other features: + * imake reads the entire cpp output into memory and then scans it + * for occurences of "@@". If it encounters them, it replaces it with + * a newline. It also trims any trailing white space on output lines + * (because make gets upset at them). This helps when cpp expands + * multi-line macros but you want them to appear on multiple lines. + * It also changes occurences of "XCOMM" to "#", to avoid problems + * with treating commands as invalid preprocessor commands. + * + * The macros MAKEFILE and MAKE are provided as macros + * to make. MAKEFILE is set to imake's makefile (not the constructed, + * preprocessed one) and MAKE is set to argv[0], i.e. the name of + * the imake program. + * + * Theory of operation: + * 1. Determine the name of the imakefile from the command line (-f) + * or from the content of the current directory (Imakefile or imakefile). + * Call this <imakefile>. This gets added to the arguments for + * make as MAKEFILE=<imakefile>. + * 2. Determine the name of the template from the command line (-T) + * or the default, Imake.tmpl. Call this <template> + * 3. Determine the name of the imakeCfile from the command line (-C) + * or the default, Imakefile.c. Call this <imakeCfile> + * 4. Store lines of input into <imakeCfile>: + * - A c-style comment header (see ImakefileCHeader below), used + * to recognize temporary files generated by imake. + * - If DEFAULT_OS_NAME is defined, format the utsname struct and + * call the result <defaultOsName>. Add: + * #define DefaultOSName <defaultOsName> + * - If DEFAULT_OS_MAJOR_REV is defined, format the utsname struct + * and call the result <defaultOsMajorVersion>. Add: + * #define DefaultOSMajorVersion <defaultOsMajorVersion> + * - If DEFAULT_OS_MINOR_REV is defined, format the utsname struct + * and call the result <defaultOsMinorVersion>. Add: + * #define DefaultOSMinorVersion <defaultOsMinorVersion> + * - 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: + * #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: + * #define IMAKE_ADMIN_DEFINES "admindefines" + * #include IMAKE_ADMIN_DEFINES + * - The following lines: + * #define INCLUDE_IMAKEFILE < <imakefile> > + * #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: + * #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: + * #define IMAKE_LOCAL_MACROS "localmacros" + * #include IMAKE_LOCAL_MACROS + * 5. Start up cpp and provide it with this file. + * Note that the define for INCLUDE_IMAKEFILE is intended for + * use in the template file. This implies that the imake is + * useless unless the template file contains at least the line + * #include INCLUDE_IMAKEFILE + * 6. Gather the output from cpp, and clean it up, expanding @@ to + * newlines, stripping trailing white space, cpp control lines, + * and extra blank lines, and changing XCOMM to #. This cleaned + * output is placed in a new file, default "Makefile", but can + * be specified with -s or -e options. + * 7. Optionally start up make on the resulting file. + * + * The design of the template makefile should therefore be: + * <set global macros like CFLAGS, etc.> + * <include machine dependent additions> + * #include INCLUDE_IMAKEFILE + * <add any global targets like 'clean' and long dependencies> + */ +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) +/* 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> +#ifdef MONOLITH +# include "Xosdefs.h" +#else +# include <X11/Xosdefs.h> +#endif +#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 +# ifndef WIN32 +# include <sys/file.h> +# endif +#else +# include <unistd.h> +#endif +#ifdef ISC +# include <unistd.h> +#endif +#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE) +# include <signal.h> +#else +# define _POSIX_SOURCE +# 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 __SCO__ +# include <sys/procset.h> +# include <sys/siginfo.h> +# endif +# include <sys/wait.h> +# else +# define _POSIX_SOURCE +# include <sys/wait.h> +# undef _POSIX_SOURCE +# endif +# define waitCode(w) WEXITSTATUS(w) +# define waitSig(w) WTERMSIG(w) +typedef int waitType; +#else /* X_NOT_POSIX */ +# ifdef SYSV +# define waitCode(w) (((w) >> 8) & 0x7f) +# define waitSig(w) ((w) & 0xff) +typedef int waitType; +# else /* SYSV */ +# ifdef WIN32 +# include <process.h> +typedef int waitType; +# else +# include <sys/wait.h> +# define waitCode(w) ((w).w_T.w_Retcode) +# define waitSig(w) ((w).w_T.w_Termsig) +typedef union wait waitType; +# endif +# endif +# ifndef WIFSIGNALED +# define WIFSIGNALED(w) waitSig(w) +# endif +# ifndef WIFEXITED +# define WIFEXITED(w) waitCode(w) +# endif +#endif /* X_NOT_POSIX */ +# include <stdlib.h> +#if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */ +char *malloc(), *realloc(); +#endif /* macII */ +#include <errno.h> +#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> +#else +#include <windows.h> +#endif +#ifndef SYS_NMLN +# ifdef _SYS_NMLN +# define SYS_NMLN _SYS_NMLN +# else +# define SYS_NMLN 257 +# endif +#endif +#if defined(linux) || defined(__GNU__) || defined(__GLIBC__) +#include <limits.h> +#include <stdio.h> +#endif +#ifdef __QNX__ +#include <unix.h> +#endif + +/* + * 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. + */ +#ifndef USE_STRERROR +# ifndef strerror +extern char *sys_errlist[]; +extern int sys_nerr; +# define strerror(n) \ + (((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error") +# endif +#endif + +#if defined(__NetBSD__) /* see code clock in init() below */ +#include <sys/utsname.h> +#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 + +#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. + */ +void KludgeOutputLine(char **), KludgeResetRule(void); + +#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 *make_argv[ ARGUMENTS ] = { +#ifdef WIN32 + "nmake" +#else + "make" +#endif +}; + +int make_argindex; +int cpp_argindex; +char *Imakefile = NULL; +char *Makefile = "Makefile"; +char *Template = "Imake.tmpl"; +char *ImakefileC = "Imakefile.c"; +boolean haveImakefileC = FALSE; +char *cleanedImakefile = NULL; +char *program; +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(int argc, char *argv[]) +{ + FILE *tmpfd = NULL; + char makeMacro[ BUFSIZ ]; + char makefileMacro[ BUFSIZ ]; + int lenCrossCompileDir = 0; + + program = argv[0]; + init(); + + 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) { + tmpMakefile = Makefile; + if ((tmpfd = fopen(tmpMakefile, "w+")) == NULL) + LogFatal("Cannot create temporary file %s.", tmpMakefile); + } else { +#ifdef HAS_MKSTEMP + int fd; +#endif + tmpMakefile = Strdup(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 ); + sprintf(makeMacro, "MAKE=%s", program); + AddMakeArg( makeMacro ); + sprintf(makefileMacro, "MAKEFILE=%s", Imakefile); + AddMakeArg( makefileMacro ); + + cleanedImakefile = CleanCppInput(Imakefile); + cppit(cleanedImakefile, Template, ImakefileC, tmpfd, tmpMakefile); + + if (show) { + if (Makefile == NULL) + showit(tmpfd); + } else + makeit(); + wrapup(); + exit(0); +} + +void +showit(FILE *fd) +{ + char buf[ BUFSIZ ]; + int red; + + fseek(fd, 0, 0); + while ((red = fread(buf, 1, BUFSIZ, fd)) > 0) + writetmpfile(stdout, buf, red, "stdout"); + if (red < 0) + LogFatal("Cannot read %s.", tmpMakefile); +} + +void +wrapup(void) +{ + if (tmpMakefile != Makefile) + unlink(tmpMakefile); + if (cleanedImakefile && cleanedImakefile != Imakefile) + unlink(cleanedImakefile); + if (haveImakefileC) + unlink(ImakefileC); +} + +#ifdef SIGNALRETURNSINT +int +#else +void +#endif +catch(int sig) +{ + errno = 0; + LogFatalI("Signal %d.", sig); +} + +/* + * Initialize some variables. + */ +void +init(void) +{ + register char *p; + + make_argindex=0; + while (make_argv[ make_argindex ] != NULL) + make_argindex++; + cpp_argindex = 0; + 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 + * found by the PATH variable is not the default. + */ + if ((p = getenv("IMAKEINCLUDE"))) { + if (*p != '-' || *(p+1) != 'I') + LogFatal("Environment var IMAKEINCLUDE %s", + "must begin with -I"); + AddCppArg(p); + for (; *p; p++) + if (*p == ' ') { + *p++ = '\0'; + AddCppArg(p); + } + } + if ((p = getenv("IMAKECPP"))) + cpp = p; + if ((p = getenv("IMAKEMAKE"))) + make_argv[0] = p; + + if (signal(SIGINT, SIG_IGN) != SIG_IGN) + signal(SIGINT, catch); +#ifdef SIGCHLD + signal(SIGCHLD, SIG_DFL); +#endif +} + +void +AddMakeArg(char *arg) +{ + errno = 0; + if (make_argindex >= ARGUMENTS-1) + LogFatal("Out of internal storage.", ""); + make_argv[ make_argindex++ ] = arg; + make_argv[ make_argindex ] = NULL; +} + +void +AddCppArg(char *arg) +{ + errno = 0; + if (cpp_argindex >= ARGUMENTS-1) + LogFatal("Out of internal storage.", ""); + cpp_argv[ cpp_argindex++ ] = arg; + cpp_argv[ cpp_argindex ] = NULL; +} + +void +SetOpts(int argc, char **argv) +{ + + errno = 0; + /* + * Now gather the arguments for make + */ + for(argc--, argv++; argc; argc--, argv++) { + /* + * We intercept these flags. + */ + if (argv[0][0] == '-') { + if (argv[0][1] == 'D') { + 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; + else { + argc--, argv++; + if (! argc) + LogFatal("No description arg after -f flag", ""); + Imakefile = argv[0]; + } + } else if (argv[0][1] == 's') { + if (argv[0][2]) + Makefile = ((argv[0][2] == '-') && !argv[0][3]) ? + NULL : argv[0]+2; + else { + argc--, argv++; + if (!argc) + LogFatal("No description arg after -s flag", ""); + Makefile = ((argv[0][0] == '-') && !argv[0][1]) ? + NULL : argv[0]; + } + show = TRUE; + } else if (argv[0][1] == 'e') { + Makefile = (argv[0][2] ? argv[0]+2 : NULL); + show = FALSE; + } else if (argv[0][1] == 'T') { + if (argv[0][2]) + Template = argv[0]+2; + else { + argc--, argv++; + if (! argc) + LogFatal("No description arg after -T flag", ""); + Template = argv[0]; + } + } else if (argv[0][1] == 'C') { + if (argv[0][2]) + ImakefileC = argv[0]+2; + else { + argc--, argv++; + if (! argc) + LogFatal("No imakeCfile arg after -C flag", ""); + ImakefileC = argv[0]; + } + } else if (argv[0][1] == 'v') { + verbose = TRUE; + } else + AddMakeArg(argv[0]); + } else + AddMakeArg(argv[0]); + } + +#ifndef CROSSCOMPILE +# ifdef USE_CC_E + if (!cpp) + { + AddCppArg("-E"); +#ifdef __GNUC__ + if (verbose) + AddCppArg("-v"); +#endif + cpp = DEFAULT_CC; + } +# else + if (!cpp) + cpp = DEFAULT_CPP; +# endif +#else + if (!cpp) + cpp = CrossCompileCPP(); +#endif + + cpp_argv[0] = cpp; + AddCppArg(ImakefileC); +} + +char * +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) + LogFatal("No description file.", ""); + else + Imakefile = "imakefile"; + } else + Imakefile = "Imakefile"; + } + return(Imakefile); +} + +void +LogFatalI(char *s, int i) +{ + /*NOSTRICT*/ + LogFatal(s, (char *)(long)i); +} + +void +LogFatal(char *x0, char *x1) +{ + static boolean entered = FALSE; + + if (entered) + return; + entered = TRUE; + + LogMsg(x0, x1); + fprintf(stderr, " Stop.\n"); + wrapup(); + exit(1); +} + +void +LogMsg(char *x0, char *x1) +{ + int error_number = errno; + + if (error_number) { + fprintf(stderr, "%s: ", program); + fprintf(stderr, "%s\n", strerror(error_number)); + } + fprintf(stderr, "%s: ", program); + fprintf(stderr, x0, x1); + fprintf(stderr, "\n"); +} + +void +showargs(char **argv) +{ + for (; *argv; argv++) + fprintf(stderr, "%s ", *argv); + fprintf(stderr, "\n"); +} + +#define ImakefileCHeader "/* imake - temporary file */" + +void +CheckImakefileC(char *masterc) +{ + char mkcbuf[1024]; + FILE *inFile; + + if (access(masterc, F_OK) == 0) { + inFile = fopen(masterc, "r"); + if (inFile == NULL) + LogFatal("Refuse to overwrite: %s", masterc); + if ((fgets(mkcbuf, sizeof(mkcbuf), inFile) && + strncmp(mkcbuf, ImakefileCHeader, + sizeof(ImakefileCHeader)-1))) + { + fclose(inFile); + LogFatal("Refuse to overwrite: %s", masterc); + } + fclose(inFile); + } +} + +#define LocalDefineFmt "#define %s \"%s\"\n" +#define IncludeFmt "#include %s\n" +#define ImakeDefSym "INCLUDE_IMAKEFILE" +#define ImakeTmplSym "IMAKE_TEMPLATE" +#define OverrideWarning "Warning: local file \"%s\" overrides global macros." + +boolean +optional_include(FILE *inFile, char *defsym, char *fname) +{ + errno = 0; + if (access(fname, R_OK) == 0) { + LogMsg(OverrideWarning, fname); + return (fprintf(inFile, LocalDefineFmt, defsym, fname) < 0 || + fprintf(inFile, IncludeFmt, defsym) < 0); + } + return FALSE; +} + +void +doit(FILE *outfd, char *cmd, char **argv) +{ + int pid; + waitType status; + + /* + * Fork and exec the command. + */ +#ifdef WIN32 + if (outfd) + dup2(fileno(outfd), 1); + status = _spawnvp(_P_WAIT, cmd, argv); + if (status < 0) + LogFatal("Cannot spawn %s.", cmd); + if (status > 0) + LogFatalI("Exit code %d.", status); +#else + pid = fork(); + if (pid < 0) + LogFatal("Cannot fork.", ""); + if (pid) { /* parent... simply wait */ + while (wait(&status) > 0) { + errno = 0; + if (WIFSIGNALED(status)) + LogFatalI("Signal %d.", waitSig(status)); + if (WIFEXITED(status) && waitCode(status)) + LogFatalI("Exit code %d.", waitCode(status)); + } + } + else { /* child... dup and exec cmd */ + if (verbose) + showargs(argv); + if (outfd) + dup2(fileno(outfd), 1); + execvp(cmd, argv); + LogFatal("Cannot exec %s.", cmd); + } +#endif +} + +#if !defined WIN32 +static void +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++) + { + /* Our buffer is only guaranteed to hold 5 arguments. */ + if (arg >= 5) + LogFatal(msg, fmt); + + switch (fmt[arg]) + { + case 's': + if (arg > 0) + *ptr++ = ' '; + strcpy(ptr, name->sysname); + ptr += strlen(ptr); + break; + + case 'n': + if (arg > 0) + *ptr++ = ' '; + strcpy(ptr, name->nodename); + ptr += strlen(ptr); + break; + + case 'r': + if (arg > 0) + *ptr++ = ' '; + strcpy(ptr, name->release); + ptr += strlen(ptr); + break; + + case 'v': + if (arg > 0) + *ptr++ = ' '; + strcpy(ptr, name->version); + ptr += strlen(ptr); + break; + + case 'm': + if (arg > 0) + *ptr++ = ' '; + strcpy(ptr, name->machine); + ptr += strlen(ptr); + break; + + default: + LogFatal(msg, fmt); + } + } + + /* Just in case... */ + if (strlen(buf) >= sizeof(buf)) + LogFatal("Buffer overflow parsing uname.", ""); + + /* Parse the buffer. The sscanf() return value is rarely correct. */ + *result = '\0'; + (void) sscanf(buf, fmt + arg + 1, result); +} + +/* Trim leading 0's and periods from version names. The 0's cause + 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(char *p) +{ + + if (p != 0 && *p != '\0') + { + while ((*p == '0' || *p == '.') && *(p + 1) != '\0') + ++p; + } + return (p); +} +#endif + +#if defined(linux) || defined(__GLIBC__) +const char *libc_c= +"#include <stdio.h>\n" +"#include <ctype.h>\n" +"\n" +"#if 1\n" +"#pragma weak gnu_get_libc_version\n" +"#pragma weak __libc_version\n" +"#pragma weak __linux_C_lib_version\n" +"#endif\n" +"\n" +"extern const char * gnu_get_libc_version (void);\n" +"extern const char * __linux_C_lib_version;\n" +"extern const char __libc_version [];\n" +"\n" +"int\n" +"main ()\n" +"{\n" +" int libcmajor = 0, libcminor = 0, libcteeny = 0;\n" +" const char * ptr = NULL;\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 if (&__linux_C_lib_version != 0)\n" +" {\n" +" ptr = __linux_C_lib_version;\n" +" }\n" +" else\n" +" {\n" +" libcmajor = 0; libcminor = 0; libcteeny = 0;\n" +" }\n" +"\n" +" if (ptr)\n" +" {\n" +" while (!isdigit (*ptr))\n" +" ptr++;\n" +"\n" +" sscanf (ptr, \"%d.%d.%d\", &libcmajor, &libcminor, &libcteeny);\n" +" libcmajor += glibcmajor;\n" +" }\n" +"\n" +" printf(\"#define DefaultLinuxCLibMajorVersion %d\\n\", libcmajor);\n" +" printf(\"#define DefaultLinuxCLibMinorVersion %d\\n\", libcminor);\n" +" printf(\"#define DefaultLinuxCLibTeenyVersion %d\\n\", libcteeny);\n" +"\n" +" return 0;\n" +"}\n" +; + +static void +get_libc_version(FILE *inFile) +{ + 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__) || defined(__DragonFly__) +static void +get_stackprotector(FILE *inFile) +{ + FILE *fp; + char *cc; + char command[1024], buf[1024]; + + 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 ProPoliceSupport YES\n"); + break; + } + } + if (pclose(fp)) + abort(); +} +#endif + + +#if defined CROSSCOMPILE || defined linux || defined(__GLIBC__) +static void +get_distrib(FILE *inFile) +{ + 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 { + c = fgetc (ldprog); + } while (c != EOF && !isdigit (c)); + ungetc (c, ldprog); + (void) fscanf (ldprog, "%d.%d", &ldmajor, &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 + +#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) +/* Runs Sun compiler command and parses output - this is a bit of a hack + * as it depends on the particular output format of the -V flag, but it's + * worked for many releases. + * + * Input : cmd - command to run (called with -V flag) + * path - path to command to run (use $PATH if NULL) + * Output: cmajor & cminor - major and minor versions if found + * Returns: 0 if successful, -1 if not. + */ +static int +ask_sun_compiler_for_versions(const char *cmd, const char *path, + int *cmajor, int *cminor) +{ + char buf[BUFSIZ]; + char cmdtorun[PATH_MAX]; + char* vptr; + FILE* ccproc; + const char vflag[] = " -V 2>&1"; + int retval = -1; + + int len = strlen(cmd) + sizeof(vflag); + + if (path != NULL) { + len += strlen(path) + 1; + } + + if (len < sizeof(cmdtorun)) { + if (path != NULL) { + sprintf(cmdtorun, "%s/%s %s", path, cmd, vflag); + } else { + sprintf(cmdtorun, "%s %s", cmd, vflag); + } + + if ((ccproc = popen (cmdtorun, "r")) != NULL) { + if (fgets (buf, sizeof(buf), ccproc) != NULL) { + vptr = strrchr (buf, 'C'); + if (vptr) { + for (; (*vptr != '\0') && !isdigit(*vptr); vptr++) { + /* Do nothing - just scanning for first digit */ + } + if (*vptr != '\0') { + if (sscanf (vptr, "%d.%d", cmajor, cminor) == 2) { + retval = 0; + } + } + } + if (retval != 0) { + fprintf(stderr, + "warning: could not parse version number in output of:\n" + " %s\n", cmdtorun); + } + while (fgets (buf, sizeof(buf), ccproc) != NULL) {}; + } + pclose (ccproc); + } + } + return retval; +} + +/* Find Sun compilers and their versions if present */ +static void +get_sun_compiler_versions (FILE *inFile) +{ + const char* sunpro_path = "/opt/SUNWspro/bin"; + int cmajor, cminor, found = 0; + struct stat sb; + + /* If cross-compiling, only check CrossCompilerDir for compilers. + * If not cross-compiling, first check cc in users $PATH, + * then try /opt/SUNWspro if not found in the users $PATH + */ + +#if defined CROSSCOMPILE + if (CrossCompiling) { + if (ask_sun_compiler_for_versions("cc", CrossCompileDir, + &cmajor, &cminor) == 0) { + found = 1; + } + } + else +#endif + { + if (ask_sun_compiler_for_versions("cc", NULL, &cmajor, &cminor) == 0) { + found = 1; + } else if (ask_sun_compiler_for_versions("cc", sunpro_path, + &cmajor, &cminor) == 0) { + found = 1; + fprintf(inFile, "#define DefaultSunProCCompilerDir %s", sunpro_path); + } + } + + if (found) { + fprintf (inFile, + "#define DefaultSunProCCompilerMajorVersion %d\n", cmajor); + fprintf (inFile, + "#define DefaultSunProCCompilerMinorVersion %d\n", cminor); + } + + /* Now do it again for C++ compiler (CC) */ + found = 0; +#if defined CROSSCOMPILE + if (CrossCompiling) { + if (ask_sun_compiler_for_versions("CC", CrossCompileDir, + &cmajor, &cminor) == 0) { + found = 1; + } + } + else +#endif + { + if (ask_sun_compiler_for_versions("CC", NULL, &cmajor, &cminor) == 0) { + found = 1; + } else if (ask_sun_compiler_for_versions("CC", sunpro_path, + &cmajor, &cminor) == 0) { + found = 1; + fprintf(inFile, + "#define DefaultSunProCplusplusCompilerDir %s", sunpro_path); + } + } + + if (found) { + fprintf (inFile, + "#define DefaultSunProCplusplusCompilerMajorVersion %d\n", + cmajor); + fprintf (inFile, + "#define DefaultSunProCplusplusCompilerMinorVersion %d\n", + cminor); + } +} +#endif + +#if defined CROSSCOMPILE || defined __GNUC__ +static void +get_gcc_version(FILE *inFile, char *name) +{ + 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 + +static boolean +get_gcc(char *cmd) +{ + struct stat sb; + static char* gcc_path[] = { +# if defined(linux) || \ + defined(__NetBSD__) || \ + defined(__OpenBSD__) || \ + defined(__FreeBSD__) || \ + defined(__DragonFly__) || \ + defined(__APPLE__) || \ + defined(__CYGWIN__) || \ + defined(__MINGW32__) || \ + defined(__GNU__) || \ + defined(__GLIBC__) + "/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'; + 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); + } + + if (buf[0]) + fprintf (inFile, "#define DefaultGccIncludeDir \"%s\"\n", buf); +} +#endif + +boolean +define_os_defaults(FILE *inFile) +{ +#if defined CROSSCOMPILE || ( !defined(WIN32) && !defined(__UNIXOS2__) ) +#ifdef CROSSCOMPILE +#ifdef __GNUC__ + if (1) +#else + if ((sys != win32) && (sys != emx)) +#endif +#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. */ +#ifdef CROSSCOMPILE + if (!CrossCompiling) +#endif + { + if (uname(&uts_name) < 0) + LogFatal("Cannot invoke uname", ""); + else + name = &uts_name; + } +#if defined CROSSCOMPILE && (defined linux || defined(__GLIBC__)) + 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 __FreeBSD__ + /* Override for compiling in chroot of other OS version, such as + * in the bento build cluster. + */ + { + char *e; + if ((e = getenv("OSREL")) != NULL && + strlen(name->sysname) + strlen(e) + 1 < SYS_NMLN) { + strcpy(name->release, e); + strcpy(name->version, name->sysname); + strcat(name->version, " "); + strcat(name->version, e); + } + } +# 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 + +# 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 + +# 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 +# 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 || defined(__GLIBC__) +# if defined(CROSSCOMPILE) && defined(__linux__) + if (sys == LinuX) +# endif + get_distrib (inFile); +# endif +# if defined linux || defined(__GLIBC__) +# 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 || __GLIBC__ */ +# if defined CROSSCOMPILE || defined linux || defined(__GLIBC__) +# if defined CROSSCOMPILE && defined(__linux__) + 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); + + 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); + } +#endif /* WIN32 */ +#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__) || defined(__DragonFly__) + get_stackprotector(inFile); +#endif + return FALSE; +} + +void +cppit(char *imakefile, char *template, char *masterc, + FILE *outfd, char *outfname) +{ + FILE *inFile; + + haveImakefileC = TRUE; + inFile = fopen(masterc, "w"); + if (inFile == NULL) + LogFatal("Cannot open %s for output.", masterc); + if (fprintf(inFile, "%s\n", ImakefileCHeader) < 0 || + define_os_defaults(inFile) || + optional_include(inFile, "IMAKE_LOCAL_DEFINES", "localdefines") || + optional_include(inFile, "IMAKE_ADMIN_DEFINES", "admindefines") || + fprintf(inFile, "#define %s <%s>\n", ImakeDefSym, imakefile) < 0 || + fprintf(inFile, LocalDefineFmt, ImakeTmplSym, template) < 0 || + fprintf(inFile, IncludeFmt, ImakeTmplSym) < 0 || + optional_include(inFile, "IMAKE_ADMIN_MACROS", "adminmacros") || + optional_include(inFile, "IMAKE_LOCAL_MACROS", "localmacros") || + fflush(inFile) || + fclose(inFile)) + LogFatal("Cannot write to %s.", masterc); + /* + * Fork and exec cpp + */ + doit(outfd, cpp, cpp_argv); + CleanCppOutput(outfd, outfname); +} + +void +makeit(void) +{ + doit(NULL, make_argv[0], make_argv); +} + +char * +CleanCppInput(char *imakefile) +{ + FILE *outFile = NULL; + FILE *inFile; + char *buf, /* buffer for file content */ + *pbuf, /* walking pointer to buf */ + *punwritten, /* pointer to unwritten portion of buf */ + *ptoken, /* pointer to # token */ + *pend, /* pointer to end of # token */ + savec; /* temporary character holder */ + int count; + struct stat st; + + /* + * grab the entire file. + */ + if (!(inFile = fopen(imakefile, "r"))) + LogFatal("Cannot open %s for input.", imakefile); + if (fstat(fileno(inFile), &st) < 0) + 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) + LogFatal("Cannot read %s:", imakefile); + fclose(inFile); + buf[0] = '\n'; + buf[1] = '\n'; + buf[count + 2] = '\0'; + + punwritten = pbuf = buf + 2; + while (*pbuf) { + /* for compatibility, replace make comments for cpp */ + if (*pbuf == '#' && pbuf[-1] == '\n' && pbuf[-2] != '\\') { + ptoken = pbuf+1; + while (*ptoken == ' ' || *ptoken == '\t') + ptoken++; + pend = ptoken; + while (*pend && *pend != ' ' && *pend != '\t' && *pend != '\n' && *pend != '\r') + pend++; + savec = *pend; + *pend = '\0'; + if (strcmp(ptoken, "define") && + strcmp(ptoken, "if") && + strcmp(ptoken, "ifdef") && + strcmp(ptoken, "ifndef") && + strcmp(ptoken, "include") && + strcmp(ptoken, "line") && + strcmp(ptoken, "else") && + strcmp(ptoken, "elif") && + strcmp(ptoken, "endif") && + strcmp(ptoken, "error") && + strcmp(ptoken, "pragma") && + strcmp(ptoken, "undef")) { + if (outFile == NULL) { +#ifdef HAS_MKSTEMP + int fd; +#endif + tmpImakefile = Strdup(tmpImakefile); +#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); + if (ptoken > pbuf + 1) + writetmpfile(outFile, "XCOMM", 5, tmpImakefile); + else + writetmpfile(outFile, "XCOMM ", 6, tmpImakefile); + punwritten = pbuf + 1; + } + *pend = savec; + } + pbuf++; + } + if (outFile) { + writetmpfile(outFile, punwritten, pbuf-punwritten, tmpImakefile); + fclose(outFile); + + return tmpImakefile; + } + + return(imakefile); +} + +void +CleanCppOutput(FILE *tmpfd, char *tmpfname) +{ + char *input; + int blankline = 0; + + while((input = ReadLine(tmpfd, tmpfname))) { + if (isempty(input)) { + if (blankline++) + continue; +#ifdef CROSSCOMPILE + if (fixup_whitespace) +#endif +#if defined CROSSCOMPILE || defined FIXUP_CPP_WHITESPACE + KludgeResetRule(); +#endif + } else { + blankline = 0; +#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); + } + fflush(tmpfd); +#ifdef NFS_STDOUT_BUG + /* + * On some systems, NFS seems to leave a large number of nulls at + * the end of the file. Ralph Swick says that this kludge makes the + * problem go away. + */ + ftruncate (fileno(tmpfd), (off_t)ftell(tmpfd)); +#endif +} + +/* + * Determine if a line has nothing in it. As a side effect, we trim white + * space from the end of the line. Cpp magic cookies are also thrown away. + * "XCOMM" token is transformed to "#". + */ +boolean +isempty(char *line) +{ + char *pend; + + /* + * Check for lines of the form + * # n "... + * or + * # line n "... + */ + if (*line == '#') { + pend = line+1; + if (*pend == ' ') + pend++; + if (*pend == 'l' && pend[1] == 'i' && pend[2] == 'n' && + pend[3] == 'e' && pend[4] == ' ') + pend += 5; + if (isdigit(*pend)) { + do { + pend++; + } while (isdigit(*pend)); + if (*pend == '\n' || *pend == '\0') + return(TRUE); + if (*pend++ == ' ' && *pend == '"') + return(TRUE); + } + while (*pend) + pend++; + } else { + 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[-1] == '\r') && + (pend[5] == ' ' || pend[5] == '\t' || pend[5] == '\r' || pend[5] == '\0')) + { + *pend = '#'; + memmove(pend+1, pend+5, strlen(pend+5)+1); + } +#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') + { + 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' || *pend == '\r')) ; + pend[1] = '\0'; + return (*line == '\0'); +} + +/*ARGSUSED*/ +char * +ReadLine(FILE *tmpfd, char *tmpfname) +{ + static boolean initialized = FALSE; + static char *buf, *pline, *end; + register char *p1, *p2; + + if (! initialized) { +#ifdef WIN32 + FILE *fp = tmpfd; +#endif + int total_red; + struct stat st; + + /* + * Slurp it all up. + */ + fseek(tmpfd, 0, 0); + if (fstat(fileno(tmpfd), &st) < 0) + 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) + LogFatal("cannot read %s", tmpMakefile); + end = buf + total_red; + *end = '\0'; + fseek(tmpfd, 0, 0); +#if defined(SYSV) || defined(WIN32) || defined(USE_FREOPEN) + tmpfd = freopen(tmpfname, "w+", tmpfd); +#ifdef WIN32 + if (! tmpfd) /* if failed try again */ + tmpfd = freopen(tmpfname, "w+", fp); +#endif + if (! tmpfd) + LogFatal("cannot reopen %s\n", tmpfname); +#else /* !SYSV */ + ftruncate(fileno(tmpfd), (off_t) 0); +#endif /* !SYSV */ + initialized = TRUE; + fprintf (tmpfd, "# Makefile generated by imake - do not edit!\n"); + fprintf (tmpfd, "# %s\n", + "$Xorg: imake.c,v 1.6 2001/02/09 02:03:15 xorgcvs Exp $"); + } + + for (p1 = pline; p1 < end; p1++) { + if (*p1 == '@' && *(p1+1) == '@' + /* ignore ClearCase version-extended pathnames */ + && !(p1 != pline && !isspace(*(p1-1)) && *(p1+2) == '/')) + { /* soft EOL */ + *p1++ = '\0'; + p1++; /* skip over second @ */ + break; + } + else if (*p1 == '\n') { /* real EOL */ +#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; + } + } + + /* + * return NULL at the end of the file. + */ + p2 = (pline == p1 ? NULL : pline); + pline = p1; + return(p2); +} + +void +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(int size) +{ + char *p; + + if ((p = malloc(size)) == NULL) + LogFatalI("Cannot allocate %d bytes", size); + return(p); +} + +#if defined CROSSCOMPILE || defined FIXUP_CPP_WHITESPACE +void +KludgeOutputLine(char **pline) +{ + char *p = *pline; + char quotechar = '\0'; + + switch (*p) { + case '#': /*Comment - ignore*/ + break; + case '\t': /*Already tabbed - ignore it*/ + break; + case ' ': /*May need a tab*/ + default: +#ifdef CROSSCOMPILE + if (inline_syntax) +#endif +#if defined CROSSCOMPILE || defined INLINE_SYNTAX + { + if (*p == '<' && p[1] == '<') { /* inline file close */ + InInline--; + InRule = TRUE; + break; + } + } +#endif + /* + * 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) + */ + for (; *p; p++) { + if (quotechar) { + if (quotechar == '\\' || + (*p == quotechar && +# if defined CROSSCOMPILE || defined WIN32 + ( +# if defined CROSSCOMPILE + (sys == win32) && +# endif + quotechar != ')') && +# endif + p[-1] != '\\')) + quotechar = '\0'; + continue; + } + switch (*p) { + case '\\': + case '"': + case '\'': + quotechar = *p; + break; + case '(': + quotechar = ')'; + break; + case '{': + quotechar = '}'; + break; + case '[': + quotechar = ']'; + break; + case '=': +#ifdef CROSSCOMPILE + if (remove_cpp_leadspace) +#endif +#if defined CROSSCOMPILE || defined REMOVE_CPP_LEADSPACE + { + if (!InRule && **pline == ' ') { + while (**pline == ' ') + (*pline)++; + } + } +#endif + goto breakfor; +#if defined CROSSCOMPILE || defined INLINE_SYNTAX + case '<': + if (inline_syntax) { + if (p[1] == '<') /* inline file start */ + InInline++; + } + break; +#endif + case ':': + if (p[1] == '=') + goto breakfor; + while (**pline == ' ') + (*pline)++; + InRule = TRUE; + return; + } + } +breakfor: + if (InRule && **pline == ' ') + **pline = '\t'; + break; + } +} + +void +KludgeResetRule(void) +{ + InRule = FALSE; +} +#endif +char * +Strdup(char *cp) +{ + 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/nx-X11/config/imake/imake.man b/nx-X11/config/imake/imake.man new file mode 100644 index 000000000..34d5b9403 --- /dev/null +++ b/nx-X11/config/imake/imake.man @@ -0,0 +1,262 @@ +.\" $Xorg: imake.man,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ +.\" Copyright (c) 1993, 1994, 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 +.\" the above copyright notice appear in all copies and that both that +.\" copyright notice and this permission notice appear in supporting +.\" documentation. +.\" +.\" The above copyright notice and this permission notice shall be included +.\" in all copies or substantial portions of the Software. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +.\" ARISING FROM, OUT OF OR IN 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. +.\" +.\" $XFree86: imake.man,v 1.8 2001/12/14 19:53:19 dawes 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 ] +[ \fB\-v\fP ] +.SH DESCRIPTION +.I Imake +is used to +generate \fIMakefiles\fP from a template, a set of \fIcpp\fP macro functions, +and a per-directory input file called an \fIImakefile\fP. This allows machine +dependencies (such as compiler options, alternate command names, and special +\fImake\fP rules) to be kept separate from the descriptions of the +various items to be built. +.SH OPTIONS +The following command line options may be passed to \fIimake\fP: +.TP 8 +.B \-D\fIdefine\fP +This option is passed directly to \fIcpp\fP. It is typically used to set +directory-specific variables. For example, the X Window System uses this +flag to set \fITOPDIR\fP to the name of the directory containing the top +of the core distribution and \fICURDIR\fP to the name of the current +directory, relative to the top. +.TP 8 +.B \-I\fIdirectory\fP +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. +The default is \fIImake.tmpl\fP. +.TP 8 +.B \-f \fIfilename\fP +This option specifies the name of the per-directory input file. The default +is \fIImakefile\fP. +.TP 8 +.B \-C \fIfilename\fP +This option specifies the name of the .c file that is constructed in the +current directory. The default is \fIImakefile.c\fP. +.TP 8 +.B \-s \fIfilename\fP +This option specifies the name of the \fImake\fP description file to be +generated but \fImake\fP should not be invoked. +If the \fIfilename\fP is a dash (\-), the +output is written to \fIstdout\fP. The default is to generate, but +not execute, a \fIMakefile\fP. +.TP 8 +.B \-e +This option indicates the \fIimake\fP should execute the generated +\fIMakefile\fP. The default is to leave this to the user. +.TP 8 +.B \-v +This option indicates that \fIimake\fP should print the \fIcpp\fP command line +that it is using to generate the \fIMakefile\fP. +.SH "HOW IT WORKS" +\fIImake\fP invokes \fIcpp\fP with any \fI\-I\fP or \fI\-D\fP flags passed +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 +.fi +.sp +where \fIImake.tmpl\fP and \fIImakefile\fP may be overridden by the +\fI\-T\fP and \fI\-f\fP command options, respectively. +.PP +The IMAKE_TEMPLATE typically +reads in a file containing machine-dependent parameters +(specified as \fIcpp\fP symbols), a site-specific parameters file, +a file defining variables, +a file +containing \fIcpp\fP macro functions for generating \fImake\fP rules, and +finally the \fIImakefile\fP (specified by INCLUDE_IMAKEFILE) in the current +directory. The \fIImakefile\fP uses the macro functions to indicate what +targets should be built; \fIimake\fP takes care of generating the appropriate +rules. +.PP +.I Imake +configuration files contain two types of variables, imake variables +and make variables. The imake variables are interpreted by cpp when +.I imake +is run. By convention they are mixed case. The make variables are +written into the +.I Makefile +for later interpretation by +.I make. +By convention make variables are upper case. +.PP +The rules file (usually named \fIImake.rules\fP in the configuration +directory) contains a variety of \fIcpp\fP macro functions that are +configured according to the current platform. \fIImake\fP replaces +any occurrences of the string ``@@'' with a newline to allow macros that +generate more than one line of \fImake\fP rules. +For example, the macro +.ta 1i 1.6i 5i +.nf + +\& #define program_target(program, objlist) @@\e + program: objlist @@\e + $(CC) \-o $@ objlist $(LDFLAGS) + +.fi +when called with +.I "program_target(foo, foo1.o foo2.o)" +will expand to +.nf + + foo: foo1.o foo2.o + $(CC) \-o $@ foo1.o foo2.o $(LDFLAGS) + +.fi +.PP +\fIImake\fP also replaces any occurrences of the word ``XCOMM'' with +the character ``#'' to permit placing comments in the Makefile without +causing ``invalid directive'' errors from the preprocessor. +.PP +Some complex \fIimake\fP macros require generated \fImake\fP variables +local to each invocation of the macro, often because their value +depends on parameters passed to the macro. +Such variables can be created by using an \fIimake\fP variable +of the form \fBXVARdef\fP\fIn\fP, where \fIn\fP is a single digit. +A unique \fImake\fP variable will be substituted. Later occurrences +of the variable \fBXVARuse\fP\fIn\fP will +be replaced by the variable created by the corresponding +\fBXVARdef\fP\fIn\fP. +.PP +On systems whose \fIcpp\fP reduces multiple tabs and spaces to a single +space, \fIimake\fP attempts to put back any necessary tabs (\fImake\fP is +very picky about the difference between tabs and spaces). For this reason, +colons (:) in command lines must be preceded by a backslash (\\). +.SH "USE WITH THE X WINDOW SYSTEM" +The X Window System uses \fIimake\fP extensively, for both full builds within +the source tree and external software. As mentioned above, two special +variables, \fITOPDIR\fP and \fICURDIR,\fP are set to make referencing files +using relative path names easier. For example, the following command is +generated automatically to build the \fIMakefile\fP in the directory +\fIlib/X/\fP (relative to the top of the sources): +.sp +.nf + % ../.././config/imake \-I../.././config \\ + \-DTOPDIR=../../. \-DCURDIR=./lib/X +.fi +.sp +When building X programs outside the source tree, a special symbol +\fIUseInstalled\fP is defined and \fITOPDIR\fP and +\fICURDIR\fP are omitted. If the configuration files have been +properly installed, the script \fIxmkmf\fP(1) may be used. +.SH "INPUT FILES" +Here is a summary of the files read by +.I imake +as used by X. +The indentation shows what files include what other files. +.nf +.sp +.ta 3i + Imake.tmpl generic variables + site.def site-specific, BeforeVendorCF defined + *.cf machine-specific + *Lib.rules shared library rules + site.def site-specific, AfterVendorCF defined + Imake.rules rules + Project.tmpl X-specific variables + *Lib.tmpl shared library variables + Imakefile + Library.tmpl library rules + Server.tmpl server rules + Threads.tmpl multi-threaded rules +.fi +.LP +Note that \fIsite.def\fP gets included twice, once before the +\fI*.cf\fP file and once after. Although most site customizations +should be specified after the \fI*.cf\fP file, some, such as the +choice of compiler, need to be specified before, because other +variable settings may depend on them. +.LP +The first time \fIsite.def\fP is included, the variable BeforeVendorCF +is defined, and the second time, the variable AfterVendorCF is +defined. All code in \fIsite.def\fP should be inside an #ifdef for +one of these symbols. +.SH FILES +.ta 3i +Imakefile.c temporary input file for cpp +.br +/tmp/Imf.XXXXXX temporary Makefile for -s +.br +/tmp/IIf.XXXXXX temporary Imakefile if specified Imakefile uses # comments +.br +__cpp__ default C preprocessor +.DT +.SH "SEE ALSO" +make(1), xmkmf(1) +.br +S. I. Feldman, +.I +Make \(em A Program for Maintaining Computer Programs +.SH "ENVIRONMENT VARIABLES" +The following environment variables may be set, however their use is not +recommended as they introduce dependencies that are not readily apparent +when \fIimake\fP is run: +.TP 5 +.B IMAKEINCLUDE +If defined, this specifies a ``\-I'' include argument to pass to the +C preprocessor. E.g., ``\-I/usr/X11/config''. +.TP 5 +.B IMAKECPP +If defined, this should be a valid path to a preprocessor program. +E.g., ``/usr/local/cpp''. +By default, +.I imake +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, +such as ``/usr/local/make''. +By default, +.I imake +will use whatever +.I make +program is found using +.I execvp(3). +This variable is only used if the ``\-e'' option is specified. +.SH "AUTHOR" +Todd Brunhoff, Tektronix and MIT Project Athena; Jim Fulton, MIT X Consortium diff --git a/nx-X11/config/imake/imakemdep.h b/nx-X11/config/imake/imakemdep.h new file mode 100644 index 000000000..bacc3af54 --- /dev/null +++ b/nx-X11/config/imake/imakemdep.h @@ -0,0 +1,1532 @@ +/* $Xorg: imakemdep.h,v 1.6 2001/02/09 02:03:16 xorgcvs Exp $ */ +/* $XdotOrg: xc/config/imake/imakemdep.h,v 1.12 2005/11/08 06:33:24 jkj Exp $ */ +/* + +Copyright (c) 1993, 1994, 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 +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +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. + +*/ +/* $XFree86: xc/config/imake/imakemdep.h,v 3.71 2003/06/12 14:12:26 eich Exp $ */ + + +/* + * This file contains machine-dependent constants for the imake utility. + * When porting imake, read each of the steps below and add in any necessary + * definitions. In general you should *not* edit ccimake.c or imake.c! + */ + +#ifdef __UNIXOS2__ +#define lstat stat +#endif + +#ifdef CCIMAKE +/* + * Step 1: imake_ccflags + * Define any special flags that will be needed to get imake.c to compile. + * 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" +#else +#define imake_ccflags "-Wc,-Nd4000,-Ns3000 -DSYSV" +#endif +#endif + +#if defined(macII) || defined(_AUX_SOURCE) +#define imake_ccflags "-DmacII -DSYSV" +#endif + +#ifdef stellar +#define imake_ccflags "-DSYSV" +#endif + +/* + * SCO UnixWare and OpenServer 6 are both System V Release 5 based OSes. + * The native C compiler doesn't assert __UNIXWARE__ but gcc does, so + * we don't redefine it if we are using gcc (as it sets it to a specific + * value). On OpenServer 6, which is a multi-ABI world, if you attempt + * to build with -Kosr, then the C compiler will assert __OPENSERVER__ + * and set it to the value 507. That indicates an OSR5 compile, and + * is handled below. + */ + +#if defined(__UNIXWARE__) || defined(__USLC__) || defined(Oki) || defined(NCR) +# ifdef imake_ccflags +# undef imake_ccflags +# endif +# ifdef __UNIXWARE__ +# ifndef __GNUC__ +# define imake_ccflags "-Xa -DSVR4 -DSVR5 -D__UNIXWARE__" +# else +# define imake_ccflags "-Xa -DSVR4 -DSVR5" +# endif +# else +# define imake_ccflags "-Xa -DSVR4" +# endif +#endif + +/* SCO may define __USLC__ so put this after the USL check */ +#if defined(M_UNIX) || defined(_SCO_DS) || defined(__OPENSERVER__) +# ifdef imake_ccflags +# undef imake_ccflags +# endif +# define imake_ccflags "-DSYSV -DSCO325 -D__SCO__" +#endif + +#ifdef sony +#if defined(SYSTYPE_SYSV) || defined(_SYSTYPE_SYSV) +#define imake_ccflags "-DSVR4" +#else +#include <sys/param.h> +#if NEWSOS < 41 +#define imake_ccflags "-Dbsd43 -DNOSTDHDRS" +#else +#if NEWSOS < 42 +#define imake_ccflags "-Dbsd43" +#endif +#endif +#endif +#endif +#ifdef _CRAY +#define imake_ccflags "-DSYSV -DUSG" +#endif + +#if defined(_IBMR2) || defined(aix) +#define imake_ccflags "-Daix -DSYSV" +#endif + +#ifdef Mips +# if defined(SYSTYPE_BSD) || defined(BSD) || defined(BSD43) +# define imake_ccflags "-DBSD43" +# else +# define imake_ccflags "-DSYSV" +# endif +#endif + +#ifdef is68k +#define imake_ccflags "-Dluna -Duniosb" +#endif + +#ifdef SYSV386 +# ifdef SVR4 +# define imake_ccflags "-Xa -DSVR4" +# else +# define imake_ccflags "-DSYSV" +# endif +#endif + +#ifdef SVR4 +# ifdef i386 +# define imake_ccflags "-Xa -DSVR4" +# endif +#endif + +#ifdef SYSV +# ifdef i386 +# define imake_ccflags "-DSYSV" +# endif +#endif + +#if defined(Lynx) || defined(__Lynx__) +#define imake_ccflags "-DLynx" +#endif /* Lynx */ + +#ifdef __convex__ +#define imake_ccflags "-fn -tm c1" +#endif + +#ifdef apollo +#define imake_ccflags "-DX_NOT_POSIX" +#endif + +#ifdef WIN32 +#ifdef __GNUC__ +#define imake_ccflags "-D__STDC__" +#else +#if _MSC_VER < 1000 +#define imake_ccflags "-nologo -batch -D__STDC__" +#else +#define imake_ccflags "-nologo -D__STDC__" +#endif +#endif +#endif + +#ifdef __uxp__ +#define imake_ccflags "-DSVR4 -DANSICPP" +#endif + +#ifdef __sxg__ +#define imake_ccflags "-DSYSV -DUSG -DNOSTDHDRS" +#endif + +#ifdef _SEQUENT_ +#define imake_ccflags "-Xa -DSVR4" +#endif + +#if defined(SX) || defined(PC_UX) +#define imake_ccflags "-DSYSV" +#endif + +#ifdef nec_ews_svr2 +#define imake_ccflags "-DUSG" +#endif + +#if defined(nec_ews_svr4) || defined(_nec_ews_svr4) || defined(_nec_up) || defined(_nec_ft) +#define imake_ccflags "-DSVR4" +#endif + +#if defined(MACH) && !defined(__GNU__) +#define imake_ccflags "-DNOSTDHDRS" +#endif + +/* 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 +/* + * Step 2: dup2 + * If your OS doesn't have a dup2() system call to duplicate one file + * descriptor onto another, define such a mechanism here (if you don't + * already fall under the existing category(ies). + */ +#if defined(SYSV) && !defined(_CRAY) && !defined(Mips) && !defined(_SEQUENT_) && !defined(__SCO__) +#define dup2(fd1,fd2) ((fd1 == fd2) ? fd1 : (close(fd2), \ + fcntl(fd1, F_DUPFD, fd2))) +#endif + + +/* + * Step 3: FIXUP_CPP_WHITESPACE + * 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)) || defined(__QNX__) || defined(__sgi) || defined(__UNIXOS2__) || defined(__UNIXWARE__) +#define FIXUP_CPP_WHITESPACE +#endif +#ifdef WIN32 +#define REMOVE_CPP_LEADSPACE +#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 + * If you want to use cc -E instead of cpp, define USE_CC_E. + * 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 +#ifdef WIN32 +#define USE_CC_E +#ifdef __GNUC__ +#define DEFAULT_CC "gcc" +#else +#define DEFAULT_CC "cl" +#endif +#endif +#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 +#if defined(sun) && (defined(SVR4) || defined(__svr4__) || defined(__SVR4) || defined(__sol__)) +#define DEFAULT_CPP "/usr/ccs/lib/cpp" +#endif +#ifdef __bsdi__ +#define DEFAULT_CPP "/usr/bin/cpp" +#endif +#ifdef __uxp__ +#define DEFAULT_CPP "/usr/ccs/lib/cpp" +#endif +#ifdef __sxg__ +#define DEFAULT_CPP "/usr/lib/cpp" +#endif +#ifdef _CRAY +#define DEFAULT_CPP "/lib/pcpp" +#endif +#if defined(__386BSD__) +#define DEFAULT_CPP "/usr/libexec/cpp" +#endif +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) +#define USE_CC_E +#endif +#if defined(__sgi) && defined(__ANSI_CPP__) +#define USE_CC_E +#endif +#if defined(MACH) && !defined(__GNU__) +#define USE_CC_E +#endif +#ifdef __minix_vmd +#define DEFAULT_CPP "/usr/lib/cpp" +#endif +#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 + * whenever a Makefile is being generated. If your preprocessor + * 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.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" + * to the end of the command line. + * + * Note that you may define more than one symbol (useful for platforms + * that support multiple operating systems). + */ + +#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 +#endif +#if defined(__386BSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ + defined(__FreeBSD__) || defined(__DragonFly__) || defined(MACH) || \ + defined(linux) || defined(__GNU__) || defined(__bsdi__) || \ + defined(__GNUC__) || defined(__GLIBC__) +# 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 __amd64__ + "-D__amd64__", +# endif +# ifdef __x86_64__ + "-D__amd64__", +# 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 __hppa__ + "-D__hppa__", +# 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", +# endif +#endif +#ifdef M4330 + "-DM4330", /* Tektronix */ +#endif +#ifdef M4310 + "-DM4310", /* Tektronix */ +#endif +#if defined(macII) || defined(_AUX_SOURCE) + "-DmacII", /* Apple A/UX */ +#endif +#if defined(USL) || defined(__UNIXWARE__) || \ + (defined(__USLC__) && !defined(_SCO_DS)) + "-D__UNIXWARE__", /* SCO UnixWare 7 */ +#endif +#ifdef sony + "-Dsony", /* Sony */ +#if !defined(SYSTYPE_SYSV) && !defined(_SYSTYPE_SYSV) && NEWSOS < 42 + "-Dbsd43", +#endif +#endif +#ifdef _IBMR2 + "-D_IBMR2", /* IBM RS-6000 (we ensured that aix is defined above */ +#ifndef aix +#define aix /* allow BOOTSTRAPCFLAGS="-D_IBMR2" */ +#endif +#endif /* _IBMR2 */ +#ifdef aix + "-Daix", /* AIX instead of AOS */ +#ifndef ibm +#define ibm /* allow BOOTSTRAPCFLAGS="-Daix" */ +#endif +#endif /* aix */ +#ifdef ibm + "-Dibm", /* IBM PS/2 and RT under both AOS and AIX */ +#endif +#ifdef luna + "-Dluna", /* OMRON luna 68K and 88K */ +#ifdef luna1 + "-Dluna1", +#endif +#ifdef luna88k /* need not on UniOS-Mach Vers. 1.13 */ + "-traditional", /* for some older version */ +#endif /* instead of "-DXCOMM=\\#" */ +#ifdef uniosb + "-Duniosb", +#endif +#ifdef uniosu + "-Duniosu", +#endif +#endif /* luna */ +#ifdef _CRAY /* Cray */ + "-Ucray", +#endif +#ifdef Mips + "-DMips", /* Define and use Mips for Mips Co. OS/mach. */ +# if defined(SYSTYPE_BSD) || defined(BSD) || defined(BSD43) + "-DBSD43", /* Mips RISCOS supports two environments */ +# else + "-DSYSV", /* System V environment is the default */ +# endif +#endif /* Mips */ +#ifdef MOTOROLA + "-DMOTOROLA", /* Motorola Delta Systems */ +# ifdef SYSV + "-DSYSV", +# endif +# ifdef SVR4 + "-DSVR4", +# endif +#endif /* MOTOROLA */ +#if defined(M_UNIX) || defined(sco) || defined(__SCO__) || \ + defined(_SCO_DS) || defined(__OPENSERVER__) + "-D__SCO__", + "-DSYSV", +#endif +#ifdef i386 + "-Di386", +# ifdef SVR4 + "-DSVR4", +# endif +# ifdef SYSV + "-DSYSV", +# ifdef ISC + "-DISC", +# ifdef ISC40 + "-DISC40", /* ISC 4.0 */ +# else +# ifdef ISC202 + "-DISC202", /* ISC 2.0.2 */ +# else +# ifdef ISC30 + "-DISC30", /* ISC 3.0 */ +# else + "-DISC22", /* ISC 2.2.1 */ +# endif +# endif +# endif +# endif +# if (_SCO_DS - 0 == 1) + "-DSCO325", +# endif +# if (_SCO_DS - 0 > 1) + "-DSCO5V6", +# endif +# endif +# ifdef ESIX + "-DESIX", +# endif +# ifdef ATT + "-DATT", +# endif +# ifdef DELL + "-DDELL", +# endif +#endif +#ifdef SYSV386 /* System V/386 folks, obsolete */ + "-Di386", +# ifdef SVR4 + "-DSVR4", +# endif +# ifdef ISC + "-DISC", +# ifdef ISC40 + "-DISC40", /* ISC 4.0 */ +# else +# ifdef ISC202 + "-DISC202", /* ISC 2.0.2 */ +# else +# ifdef ISC30 + "-DISC30", /* ISC 3.0 */ +# else + "-DISC22", /* ISC 2.2.1 */ +# endif +# endif +# endif +# endif +# if (_SCO_DS - 0 == 1) + "-DSCO325", +# endif +# if (_SCO_DS - 0 > 1) + "-DSCO5V6", +# endif +# ifdef ESIX + "-DESIX", +# endif +# ifdef ATT + "-DATT", +# endif +# ifdef DELL + "-DDELL", +# endif +#endif +#ifdef __osf__ + "-D__osf__", +# ifdef __mips__ + "-D__mips__", +# endif +# ifdef __alpha + "-D__alpha", +# endif +# ifdef __amiga__ + "-D__amiga__", +# endif +# ifdef __alpha__ + "-D__alpha__", +# endif +# ifdef __i386__ + "-D__i386__", +# endif +# ifdef __GNUC__ + "-traditional", +# endif +#endif +#ifdef Oki + "-DOki", +#endif +#ifdef sun +#if defined(SVR4) || defined(__svr4__) || defined(__SVR4) || defined(__sol__) + "-DSVR4", +#endif +# ifdef __sparcv9 + "-D__sparcv9", +# endif +# ifdef __amd64 + "-D__amd64", +# endif +#endif +#ifdef WIN32 + "-DWIN32", +#ifndef __GNUC__ + "-nologo", +#if _MSC_VER < 1000 + "-batch", +#endif +#endif + "-D__STDC__", +#endif +#ifdef NCR + "-DNCR", /* NCR */ +#endif +#ifdef linux + "-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 +# ifdef ppc64 + "-Dppc64", +# endif +# if defined(m68k) || defined(M68k) || defined(m68040) + "-Dm68k", + "-DM68k", +# endif +# ifdef uSPARC1 + "-Dsparc", +# endif +#endif +#ifdef __uxp__ + "-D__uxp__", +#endif +#ifdef __sxg__ + "-D__sxg__", +#endif +#ifdef nec_ews_svr2 + "-Dnec_ews_svr2", +#endif +#ifdef AMOEBA + "-DAMOEBA", +# ifdef CROSS_COMPILE + "-DCROSS_COMPILE", +# ifdef CROSS_i80386 + "-Di80386", +# endif +# ifdef CROSS_sparc + "-Dsparc", +# endif +# ifdef CROSS_mc68000 + "-Dmc68000", +# endif +# else +# ifdef i80386 + "-Di80386", +# endif +# ifdef sparc + "-Dsparc", +# endif +# ifdef mc68000 + "-Dmc68000", +# endif +# endif +#endif +#if defined(__sgi) && defined(__ANSI_CPP__) + "-cckr", +#endif +#ifdef __minix_vmd + "-Dminix", +#endif + +#if defined(__UNIXOS2__) + "-traditional", + "-Demxos2", +#endif +#ifdef MetroLink + "-DMetroLink", +# ifdef SVR4 + "-DSVR4", +# endif +#endif +#ifdef __powerpc__ + "-D__powerpc__", +#endif +#ifdef __powerpc64__ + "-D__powerpc64__", +#endif +#ifdef PowerMAX_OS + "-DPowerMAX_OS", +#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 __ppc64__ + "-D__ppc64__", +# 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 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 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]" +/* No information available to generate default OSTeenyVersion value. */ +# 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) +/* 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__) || defined(__UNIXWARE__) || \ + defined(__SCO__) || defined(__OPENSERVER__) || defined(_SCO_DS) +/* 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 "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__) +/* 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(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(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__DragonFly__) +/* 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]" +# if defined(__FreeBSD__) || defined(__DragonFly__) +/* 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 +#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 + * them to the the following table. The definition of struct symtab is + * in util/makedepend/def.h. + */ +#undef DEF_EVALUATE +#undef DEF_STRINGIFY +#define DEF_EVALUATE(__x) #__x +#define DEF_STRINGIFY(_x) DEF_EVALUATE(_x) +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 +#ifdef ibm + {"ibm", "1"}, +#endif +#ifdef aix + {"aix", "1"}, +#endif +#ifdef sun + {"sun", "1"}, +#endif +#ifdef sun2 + {"sun2", "1"}, +#endif +#ifdef sun3 + {"sun3", "1"}, +#endif +#ifdef sun4 + {"sun4", "1"}, +#endif +#ifdef sparc + {"sparc", "1"}, +#endif +#ifdef __sparc + {"__sparc", "1"}, +#endif +#ifdef __sparcv9 + {"__sparcv9", "1"}, +#endif +#ifdef __sparc__ + {"__sparc__", "1"}, +#endif +#ifdef __sparcv9__ + {"__sparcv9__", "1"}, +#endif +#ifdef hpux + {"hpux", "1"}, +#endif +#ifdef __hpux + {"__hpux", "1"}, +#endif +#ifdef __hp9000s800 + {"__hp9000s800", "1"}, +#endif +#ifdef __hp9000s700 + {"__hp9000s700", "1"}, +#endif +#ifdef vax + {"vax", "1"}, +#endif +#ifdef VMS + {"VMS", "1"}, +#endif +#ifdef cray + {"cray", "1"}, +#endif +#ifdef CRAY + {"CRAY", "1"}, +#endif +#ifdef _CRAY + {"_CRAY", "1"}, +#endif +#ifdef att + {"att", "1"}, +#endif +#ifdef mips + {"mips", "1"}, +#endif +#ifdef __mips__ + {"__mips__", "1"}, +#endif +#ifdef ultrix + {"ultrix", "1"}, +#endif +#ifdef stellar + {"stellar", "1"}, +#endif +#ifdef mc68000 + {"mc68000", "1"}, +#endif +#ifdef mc68020 + {"mc68020", "1"}, +#endif +#ifdef __GNUC__ + {"__GNUC__", DEF_STRINGIFY(__GNUC__)}, +#endif +#ifdef __STRICT_ANSI__ + {"__STRICT_ANSI__", "1"}, +#endif +#ifdef __STDC__ + {"__STDC__", DEF_STRINGIFY(__STDC__)}, +#endif +#ifdef __HIGHC__ + {"__HIGHC__", "1"}, +#endif +#ifdef __OPENSERVER__ + {"__OPENSERVER__", DEF_STRINGIFY(__OPENSERVER__)}, +#endif +#ifdef _SCO_DS + {"_SCO_DS", DEF_STRINGIFY(_SCO_DS)}, +#endif +#ifdef _SCO_DS_LL + {"_SCO_DS_LL", DEF_STRINGIFY(_SCO_DS_LL)}, +#endif +#ifdef __SCO_VERSION__ + {"__SCO_VERSION__", DEF_STRINGIFY(__SCO_VERSION__)}, +#endif +#ifdef __UNIXWARE__ + {"__UNIXWARE__", DEF_STRINGIFY(__UNIXWARE__)}, +#endif +#ifdef __USLC__ + {"__USLC__", DEF_STRINGIFY(__USLC__)}, +#endif +#ifdef CMU + {"CMU", "1"}, +#endif +#ifdef luna + {"luna", "1"}, +#ifdef luna1 + {"luna1", "1"}, +#endif +#ifdef luna2 + {"luna2", "1"}, +#endif +#ifdef luna88k + {"luna88k", "1"}, +#endif +#ifdef uniosb + {"uniosb", "1"}, +#endif +#ifdef uniosu + {"uniosu", "1"}, +#endif +#endif +#ifdef ieeep754 + {"ieeep754", "1"}, +#endif +#ifdef is68k + {"is68k", "1"}, +#endif +#ifdef m68k + {"m68k", "1"}, +#endif +#ifdef M68k + {"M68k", "1"}, +#endif +#ifdef __m68k__ + {"__m68k__", "1"}, +#endif +#ifdef m88k + {"m88k", "1"}, +#endif +#ifdef __m88k__ + {"__m88k__", "1"}, +#endif +#ifdef bsd43 + {"bsd43", "1"}, +#endif +#ifdef hcx + {"hcx", "1"}, +#endif +#ifdef sony + {"sony", "1"}, +#ifdef SYSTYPE_SYSV + {"SYSTYPE_SYSV", "1"}, +#endif +#ifdef _SYSTYPE_SYSV + {"_SYSTYPE_SYSV", "1"}, +#endif +#endif +#ifdef __OSF__ + {"__OSF__", "1"}, +#endif +#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 +#ifdef __decc + {"__decc", "1"}, +#endif +#ifdef __unix__ + {"__unix__", "1"}, +#endif +#ifdef __uxp__ + {"__uxp__", "1"}, +#endif +#ifdef __sxg__ + {"__sxg__", "1"}, +#endif +#ifdef _SEQUENT_ + {"_SEQUENT_", "1"}, + {"__STDC__", "1"}, +#endif +#ifdef __bsdi__ + {"__bsdi__", "1"}, +#endif +#ifdef nec_ews_svr2 + {"nec_ews_svr2", "1"}, +#endif +#ifdef nec_ews_svr4 + {"nec_ews_svr4", "1"}, +#endif +#ifdef _nec_ews_svr4 + {"_nec_ews_svr4", "1"}, +#endif +#ifdef _nec_up + {"_nec_up", "1"}, +#endif +#ifdef SX + {"SX", "1"}, +#endif +#ifdef nec + {"nec", "1"}, +#endif +#ifdef _nec_ft + {"_nec_ft", "1"}, +#endif +#ifdef PC_UX + {"PC_UX", "1"}, +#endif +#ifdef sgi + {"sgi", "1"}, +#endif +#ifdef __sgi + {"__sgi", "1"}, +#endif +#ifdef _MIPS_FPSET + {"_MIPS_FPSET", DEF_STRINGIFY(_MIPS_FPSET)}, +#endif +#ifdef _MIPS_ISA + {"_MIPS_ISA", DEF_STRINGIFY(_MIPS_ISA)}, +#endif +#ifdef _MIPS_SIM + {"_MIPS_SIM", DEF_STRINGIFY(_MIPS_SIM)}, +#endif +#ifdef _MIPS_SZINT + {"_MIPS_SZINT", DEF_STRINGIFY(_MIPS_SZINT)}, +#endif +#ifdef _MIPS_SZLONG + {"_MIPS_SZLONG", DEF_STRINGIFY(_MIPS_SZLONG)}, +#endif +#ifdef _MIPS_SZPTR + {"_MIPS_SZPTR", DEF_STRINGIFY(_MIPS_SZPTR)}, +#endif +#ifdef __DragonFly__ + {"__DragonFly__", "1"}, +#endif +#ifdef __FreeBSD__ + {"__FreeBSD__", "1"}, +#endif +#ifdef __OpenBSD__ + {"__OpenBSD__", "1"}, +#endif +#ifdef __NetBSD__ + {"__NetBSD__", "1"}, +#endif +#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 __powerpc64__ + {"__powerpc64__", "1"}, +# endif +# ifdef PowerMAX_OS + {"PowerMAX_OS", "1"}, +# endif +# ifdef ia64 + {"ia64", "1"}, +# endif +# ifdef __ia64__ + {"__ia64__", "1"}, +# endif +# if defined (amd64) || defined (x86_64) + {"amd64", "1"}, + {"x86_64", "1"}, +# endif +# if defined (__amd64__) || defined (__x86_64__) + {"__amd64__", "1"}, + {"__x86_64__", "1"}, +# endif +# if defined (__amd64) || defined(__x86_64) + {"__amd64", "1"}, + {"__x86_64", "1"}, +# endif +# ifdef __x86 + {"__x86", "1"}, +# endif +# ifdef __i386 + {"__i386", "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 __hppa__ + {"__hppa__", "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(__ppc64__) + {"__ppc64__", "1"}, +#endif +#if defined(__BIG_ENDIAN__) + {"__BIG_ENDIAN__", "1"}, +#endif +#if defined(__LITTLE_ENDIAN__) + {"__LITTLE_ENDIAN__", "1"}, +#endif +#if defined (__CHAR_BIT__) + {"__CHAR_BIT__", DEF_STRINGIFY(__CHAR_BIT__)}, +#endif +#if defined (__BUILTIN_VA_STRUCT) + {"__BUILTIN_VA_STRUCT", "1"}, +#endif +#if defined (__BUILTIN_VA_ARG_INCR) + {"__BUILTIN_VA_ARG_INCR", "1"}, +#endif + /* add any additional symbols before this line */ + {NULL, NULL} +}; +#undef DEF_EVALUATE +#undef DEF_STRINGIFY +#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, + dragonfly +} System; + +# if defined(linux) || defined(__GLIBC__) +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; +# elif defined __DragonFly__ +System sys = dragonfly; +# 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) || defined(__GLIBC__) +# 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/nx-X11/config/imake/imakesvc.cmd b/nx-X11/config/imake/imakesvc.cmd new file mode 100644 index 000000000..1108c3904 --- /dev/null +++ b/nx-X11/config/imake/imakesvc.cmd @@ -0,0 +1,302 @@ +/* Rexx OS/2 + * This script serves as a helper cmd file for imake. Install this in + * the path just like imake itself. + * + * $XFree86: xc/config/imake/imakesvc.cmd,v 3.13 1999/04/29 09:13:23 dawes Exp $ + */ +'@echo off' +ADDRESS CMD +CALL RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete' +CALL RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree' +CALL RxFuncAdd 'SysRmDir', 'RexxUtil', 'SysRmDir' +CALL RxFuncAdd 'SysMkDir', 'RexxUtil', 'SysMkDir' + +PARSE ARG all +code = WORD(all,1) + +SELECT + WHEN code=1 THEN DO + /* imakesvc 1 u/n dir ruledir top current */ + instflg = WORD(all,2) + imakecmd = '\imake' + ruledir = WORD(all,4) + topdir = WORD(all,5) + currentdir = WORD(all,6) + IF instflg = 'u' THEN DO + root = VALUE('X11ROOT',,'OS2ENVIRONMENT') + IF root = '' THEN DO + SAY 'Fatal error: no X11ROOT environment variable found!' + EXIT 99 + END + imakecmd = 'imake' + IF POS(':',ruledir) = 0 THEN + ruledir1 = root||ruledir + ELSE + ruledir1 = ruledir + topdir1 = topdir + useinst = '-DUseInstalled' + END + ELSE DO + /* in n mode, we must add a prefix ../ for MakeMakeSubdirs */ + ruledir1 = '../'||ruledir + topdir1 = '../'||topdir + useinst = '' + END + + ruledir = ruledir1 + topdir = topdir1 + curdir = DIRECTORY() + dir = fixbadprefix(WORD(all,3)) + d = DIRECTORY(dir) + dirfwd=TRANSLATE(dir,'/','\') + RC = SysFileDelete('Makefile.bak') + IF exists('Makefile') THEN REN Makefile Makefile.bak + /* There is a difficulty in the Imakefiles. Some builds refer + * to directories that are in a different subtree. We need to adjust + * the CURDIR and TOPDIR and -I paths + */ + IF SUBSTR(dirfwd,1,2)='..' THEN DO + /* must recalculate passed topdir, currentdir, and ruledir */ + ndist = nlevels(topdir) + ncurdir = './'striplevel(dirfwd,ndist-1) + ntopdir = maketop(nlevels(ncurdir)) + nruledir = ntopdir||'/config/cf' + END + ELSE DO + /* this is simple it is relative to this dir */ + pfx = downlevels(dirfwd) + nruledir = ruledir + IF instflg = 'n' THEN DO /*sm120296*/ + nruledir = pfx||ruledir + END + ntopdir = pfx||topdir + ncurdir = currentdir /* use to be pfx || currentdir */ + END + imakecmd useinst '-I'nruledir' -DTOPDIR='ntopdir' -DCURDIR='ncurdir'/'dirfwd + 'x11make MAKE=x11make SHELL= Makefiles' + d = DIRECTORY(curdir) + END + WHEN code=2 THEN DO + /* imakesvc 2 buildincdir buildinctop currentdir file */ + bid = WORD(all,3) + cid = WORD(all,4) + fil = WORD(all,5) + curdir = DIRECTORY() + d = DIRECTORY(WORD(all,2)) + rc = SysFileDelete(fil) + dir = TRANSLATE(bid'/'cid'/'fil,'\','/') + COPY dir .' >nul 2>&1 ' + d = DIRECTORY(curdir) + END + WHEN code=3 THEN DO + /* imakesvc 3 subdir updir file */ + sdi = WORD(all,2) + fil = WORD(all,4) + curdir = DIRECTORY() + d = DIRECTORY(WORD(all,3)) + rc = SysFileDelete(fil) + dir = TRANSLATE(sdi'/'fil,'\','/') + COPY dir' . >nul 2>&1' + d = DIRECTORY(curdir) + END + WHEN code=4 THEN DO + /* imakesvc 4 [-r] files... */ + rec = WORD(all,2) + fp = 2 + IF rec = '-r' THEN fp = 3 + ELSE rec = '-n' + DO i=fp TO WORDS(all) + CALL discard rec,TRANSLATE(WORD(all,i),'\','/') + END + END + WHEN code=5 THEN DO + /* imakesvc 5 file */ + file = TRANSLATE(WORD(all,2),'\','/') + RC = SysFileDelete(file'.bak') + if exists(file) THEN 'REN 'file file||'.bak' + END + WHEN code=6 THEN DO + /* imakesvc 6 file */ + file = TRANSLATE(WORD(all,2),'\','/') + CALL SysFileDelete(file||'.bak') + if exists(file) THEN 'REN 'file file||'.bak' + END + WHEN code=7 THEN DO + /* imakesvc 7 from to */ + from = TRANSLATE(WORD(all,2),'\','/') + to = TRANSLATE(WORD(all,3),'\','/') + CALL SysFileDelete(to) + COPY from to' >nul 2>&1' + END + WHEN code=8 THEN DO + /* imakesvc 8 arg */ + SAY SUBWORD(TRANSLATE(all,' ','222c'x),2) + END + WHEN code=9 THEN DO + /* imakesvc 9 dst.c incl.h src.c */ + dst = TRANSLATE(WORD(all,2),'\','/') + src = TRANSLATE(WORD(all,4),'\','/') + CALL SysFileDelete(dst) + CALL LINEOUT dst,'#include "'WORD(all,3)'"' + CALL LINEOUT dst,'#include "'src'"' + CALL LINEOUT dst + END + WHEN code=10 THEN DO + /* imakesvc 10 srcfile destdir destfile suffix */ + src = stripsuffix(WORD(all,2)) + destdir = TRANSLATE(WORD(all,3),'\','/') + dest = stripsuffix(WORD(all,4)) + suffix = WORD(all,5) + tgt = destdir'\'dest'.'suffix + /* if you have no col.exe get one from 4.4BSD */ + 'groff -e -t -man -Tascii 'src'.man | col -b >'tgt + END + WHEN code=11 THEN DO + /* imakesvc 11 dirtomake */ + dirtomake = TRANSLATE(WORD(all,2),'\','/') + rc = SysMkDir(dirtomake) + END + WHEN code=12 THEN DO + /* imakesvc 12 srcfile destdir destfile */ + src = stripsuffix(WORD(all,2)) + destdir = TRANSLATE(WORD(all,3),'\','/') + dest = stripsuffix(WORD(all,4)) + tgt = destdir'\'dest'.gz' + /* if you have no col.exe get one from 4.4BSD */ + 'groff -e -t -man -Tascii 'src'.man | col -b | gzip -n >'tgt + END + WHEN code=13 THEN DO + /* imakesvc 13 indir fromfile tofile */ + ind = TRANSLATE(WORD(all,2),'\','/') + frm = TRANSLATE(WORD(all,3),'\','/') + tof = ind'\'WORD(all,4) + IF \(exists(ind)) THEN call SysMkDir ind + rc = SysFileDelete(tof) + COPY frm' 'tof + END + WHEN code=14 THEN DO + /* imakesvc 14 destdir srcfile... */ + destdir = TRANSLATE(WORD(all,2),'\','/') + DO i=3 TO WORDS(all) + src = stripsuffix(WORD(all,i)) + tgt = destdir'\'src'.gz' + 'groff -e -t -man -Tascii 'src'.man | col -b | gzip -n >'tgt + END + END + WHEN code=15 THEN DO + /* imakesvc 15 destdir suffix srcfile... */ + destdir = TRANSLATE(WORD(all,2),'\','/') + suffix = WORD(all,3) + DO i=4 TO WORDS(all) + src = stripsuffix(WORD(all,i)) + tgt = destdir'\'src'.'suffix + 'groff -e -t -man -Tascii 'src'.man | col -b >'tgt + END + END + WHEN code=16 THEN DO + /* imakesvc 16 dirlist...*/ + mkfontdir = TRANSLATE(WORD(all,2),'\','/') + earg='' + DO i=3 TO WORDS(all) + arg = WORD(all,i) + earg = earg' -e 'arg + END + mkfontdir' -r -p inst/ 'earg' .' + END + OTHERWISE NOP +END +RETURN + +downlevels: +oldpos = 1 +pfx = '' +DO FOREVER + newpos = POS('/',ARG(1),oldpos) + IF newpos = 0 THEN LEAVE + newpfx = '../'pfx + oldpos = newpos+1 + pfx = newpfx +END +RETURN pfx + +/* returns 1, if file exists */ +exists: +'DIR "'arg(1)'" >nul 2>&1' +IF rc = 0 THEN return 1 +RETURN 0 + +discard: PROCEDURE +rec=ARG(1) +files=ARG(2) +IF rec = '-r' THEN DO + old = DIRECTORY() + nd = DIRECTORY + CALL SysFileTree files, 'deld', 'DO' + IF deld.0 > 0 THEN DO + DO m=1 TO deld.0 + CALL DIRECTORY deld.m + CALL discard '-R' . + CALL DIRECTORY .. + CALL SysRmDir deld.m + END + CALL SysRmDir files + END + CALL SysFileTree files, 'delf', 'FO' + DO k=1 TO delf.0 + DEL '"'delf.k'"' '>nul 2>&1' + END + CALL SysRmDir files +END +ELSE DO + DEL '"'files'"' '>nul 2>&1' +END +RETURN + +/* somehow make or cmd manages to convert a relative path ..\..\. to ..... */ +fixbadprefix: +count = 1 +str = ARG(1) +DO WHILE SUBSTR(str,count,2) = '..' + count = count+1 + str = INSERT('\',str,count) + count = count+2 +END +RETURN str + +striplevel: +str=ARG(1) +n=arg(2) +DO count=0 TO n + p = POS('/',str) + IF p = 0 THEN LEAVE + str = DELSTR(str,1,p) +END +RETURN str + +nlevels: +str = ARG(1) +count = 0 +oldpos = 1 +DO FOREVER + newpos = POS('/',str,oldpos) + IF newpos = 0 THEN LEAVE + oldpos = newpos + 1 + count = count + 1 +END +RETURN count + +maketop: +str = '' +n = ARG(1) +DO k=1 TO n + str = str||'../' +END +RETURN str||'.' + +stripsuffix: +str = ARG(1) +spos = POS('.',str) +IF spos = 0 THEN + RETURN str +ELSE + RETURN LEFT(str,spos-1) |