diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 15:54:29 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 15:54:29 +0000 |
commit | 86fae01174ab672736557a4bb1b2188cf3cec064 (patch) | |
tree | dad83c22400ce37c5d996bde76dffdb95866e0e6 |
R6.6 is the Xorg base-lineXORG-MAIN
-rw-r--r-- | imake.c | 1588 | ||||
-rw-r--r-- | imake.man | 254 | ||||
-rw-r--r-- | imakemdep.h | 815 | ||||
-rw-r--r-- | makeg | 13 | ||||
-rw-r--r-- | makeg.man | 61 | ||||
-rw-r--r-- | mdepend.cpp | 243 | ||||
-rw-r--r-- | mergelib.cpp | 102 | ||||
-rw-r--r-- | mkdirhier | 67 | ||||
-rw-r--r-- | mkdirhier.man | 39 | ||||
-rw-r--r-- | xmkmf.cpp | 58 | ||||
-rw-r--r-- | xmkmf.man | 86 |
11 files changed, 3326 insertions, 0 deletions
@@ -0,0 +1,1588 @@ +/* $Id */ + +/*************************************************************************** + * * + * Porting Note * + * * + * Add the value of BOOTSTRAPCFLAGS to the cpp_argv table so that it will * + * be passed to the template file. * + * * + ***************************************************************************/ + +/* + * +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. + * -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 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> + */ +#include <stdio.h> +#include <ctype.h> +#include "Xosdefs.h" +#ifdef WIN32 +# include "Xw32defs.h" +#endif +#ifndef X_NOT_POSIX +# ifndef _POSIX_SOURCE +# define _POSIX_SOURCE +# 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 +#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE) +# include <signal.h> +#else +# define _POSIX_SOURCE +# include <signal.h> +# undef _POSIX_SOURCE +#endif +#include <sys/stat.h> +#ifndef X_NOT_POSIX +# ifdef _POSIX_SOURCE +# 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 */ +#ifndef X_NOT_STDC_ENV +# include <stdlib.h> +#else +char *malloc(), *realloc(); +void exit(); +#endif +#if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */ +char *malloc(), *realloc(); +#endif /* macII */ +#ifdef X_NOT_STDC_ENV +extern char *getenv(); +#endif +#include <errno.h> +#ifdef X_NOT_STDC_ENV +extern int errno; +#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 +#ifdef linux +#include <limits.h> +#endif +/* + * is strstr() in <strings.h> on X_NOT_STDC_ENV? + * are there any X_NOT_STDC_ENV machines left in the world? + */ +#include <string.h> +#include "imakemdep.h" + +/* + * This define of strerror is copied from (and should be identical to) + * Xos.h, which we don't want to include here for bootstrapping reasons. + */ +#if defined(X_NOT_STDC_ENV) || (defined(sun) && !defined(SVR4)) || defined(macII) +# ifndef strerror +extern char *sys_errlist[]; +extern int sys_nerr; +# define strerror(n) \ + (((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error") +# endif +#endif + +#define TRUE 1 +#define FALSE 0 + +#ifdef FIXUP_CPP_WHITESPACE +int InRule = FALSE; +# ifdef INLINE_SYNTAX +int InInline = 0; +# endif +#endif +#ifdef MAGIC_MAKE_VARS +int xvariable = 0; +int xvariables[10]; +#endif + +/* + * Some versions of cpp reduce all tabs in macro expansion to a single + * space. In addition, the escaped newline may be replaced with a + * space instead of being deleted. Blech. + */ +#ifdef FIXUP_CPP_WHITESPACE +void KludgeOutputLine(), KludgeResetRule(); +#else +# define KludgeOutputLine(arg) +# define KludgeResetRule() +#endif + +typedef unsigned char boolean; + +#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 + +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 *ReadLine(); +char *CleanCppInput(); +char *Strdup(); +char *Emalloc(); +void LogFatalI(), LogFatal(), LogMsg(); + +void showit(); +void wrapup(); +void init(); +void AddMakeArg(); +void AddCppArg(); +void SetOpts(); +void CheckImakefileC(); +void cppit(); +void makeit(); +void CleanCppOutput(); +boolean isempty(); +void writetmpfile(); + +boolean verbose = FALSE; +boolean show = TRUE; + +int +main(argc, argv) + int argc; + char **argv; +{ + FILE *tmpfd; + char makeMacro[ BUFSIZ ]; + char makefileMacro[ BUFSIZ ]; + + program = argv[0]; + init(); + SetOpts(argc, argv); + + Imakefile = FindImakefile(Imakefile); + CheckImakefileC(ImakefileC); + if (Makefile) + tmpMakefile = Makefile; + else { + tmpMakefile = Strdup(tmpMakefile); + (void) mktemp(tmpMakefile); + } + AddMakeArg("-f"); + AddMakeArg( tmpMakefile ); + sprintf(makeMacro, "MAKE=%s", program); + AddMakeArg( makeMacro ); + sprintf(makefileMacro, "MAKEFILE=%s", Imakefile); + AddMakeArg( makefileMacro ); + + if ((tmpfd = fopen(tmpMakefile, "w+")) == NULL) + LogFatal("Cannot create temporary file %s.", tmpMakefile); + + cleanedImakefile = CleanCppInput(Imakefile); + cppit(cleanedImakefile, Template, ImakefileC, tmpfd, tmpMakefile); + + if (show) { + if (Makefile == NULL) + showit(tmpfd); + } else + makeit(); + wrapup(); + exit(0); +} + +void +showit(fd) + 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() +{ + if (tmpMakefile != Makefile) + unlink(tmpMakefile); + if (cleanedImakefile && cleanedImakefile != Imakefile) + unlink(cleanedImakefile); + if (haveImakefileC) + unlink(ImakefileC); +} + +#ifdef SIGNALRETURNSINT +int +#else +void +#endif +catch(sig) + int sig; +{ + errno = 0; + LogFatalI("Signal %d.", sig); +} + +/* + * Initialize some variables. + */ +void +init() +{ + 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++; + + /* + * 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); +} + +void +AddMakeArg(arg) + 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(arg) + 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(argc, argv) + 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] == '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]); + } +#ifdef USE_CC_E + if (!cpp) + { + AddCppArg("-E"); + cpp = DEFAULT_CC; + } +#else + if (!cpp) + cpp = DEFAULT_CPP; +#endif + cpp_argv[0] = cpp; + AddCppArg(ImakefileC); +} + +char * +FindImakefile(Imakefile) + 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(s, i) + char *s; + int i; +{ + /*NOSTRICT*/ + LogFatal(s, (char *)i); +} + +void +LogFatal(x0,x1) + char *x0, *x1; +{ + static boolean entered = FALSE; + + if (entered) + return; + entered = TRUE; + + LogMsg(x0, x1); + fprintf(stderr, " Stop.\n"); + wrapup(); + exit(1); +} + +void +LogMsg(x0,x1) + char *x0, *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(argv) + char **argv; +{ + for (; *argv; argv++) + fprintf(stderr, "%s ", *argv); + fprintf(stderr, "\n"); +} + +#define ImakefileCHeader "/* imake - temporary file */" + +void +CheckImakefileC(masterc) + 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(inFile, defsym, fname) + 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(outfd, cmd, argv) + 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 +} + +#ifndef WIN32 +static void +parse_utsname(name, fmt, result, msg) + struct utsname *name; + char *fmt; + char *result; + char *msg; +{ + char buf[SYS_NMLN * 5 + 1]; + char *ptr = buf; + int arg; + + /* 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(p) + char *p; +{ + + if (p != 0 && *p != '\0') + { + while ((*p == '0' || *p == '.') && *(p + 1) != '\0') + ++p; + } + return (p); +} +#endif + +#ifdef linux +static void get_distrib(inFile) + FILE* inFile; +{ + struct stat sb; + + static char* yast = "/sbin/YaST"; + static char* redhat = "/etc/redhat-release"; + + fprintf (inFile, "%s\n", "#define LinuxUnknown 0"); + fprintf (inFile, "%s\n", "#define LinuxSuSE 1"); + fprintf (inFile, "%s\n", "#define LinuxCaldera 2"); + fprintf (inFile, "%s\n", "#define LinuxCraftworks 3"); + fprintf (inFile, "%s\n", "#define LinuxDebian 4"); + fprintf (inFile, "%s\n", "#define LinuxInfoMagic 5"); + fprintf (inFile, "%s\n", "#define LinuxKheops 6"); + fprintf (inFile, "%s\n", "#define LinuxPro 7"); + fprintf (inFile, "%s\n", "#define LinuxRedHat 8"); + fprintf (inFile, "%s\n", "#define LinuxSlackware 9"); + fprintf (inFile, "%s\n", "#define LinuxTurbo 10"); + fprintf (inFile, "%s\n", "#define LinuxWare 11"); + fprintf (inFile, "%s\n", "#define LinuxYggdrasil 12"); + + if (lstat (yast, &sb) == 0) { + fprintf (inFile, "%s\n", "#define DefaultLinuxDistribution LinuxSuSE"); + return; + } + if (lstat (redhat, &sb) == 0) { + fprintf (inFile, "%s\n", "#define DefaultLinuxDistribution LinuxRedHat"); + return; + } + /* what's the definitive way to tell what any particular distribution is? */ + + fprintf (inFile, "%s\n", "#define DefaultLinuxDistribution LinuxUnknown"); + /* would like to know what version of the distribution it is */ +} + +static const char *libc_c= +"#include <stdio.h>\n" +"#include <ctype.h>\n" +"\n" +"#if 0\n" +"#pragma weak gnu_get_libc_version\n" +"#pragma weak __libc_version\n" +"#pragma weak __linux_C_lib_version\n" +"#else\n" +"asm (\".weak gnu_get_libc_version\");\n" +"asm (\".weak __libc_version\");\n" +"asm (\".weak __linux_C_lib_version\");\n" +"#endif\n" +"\n" +"extern const char * gnu_get_libc_version (void);\n" +"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" +"\n" +" if (((&__linux_C_lib_version != 0)\n" +" && ((&__libc_version != 0) || (gnu_get_libc_version != 0)))\n" +" || (!(&__linux_C_lib_version != 0) && !(&__libc_version != 0)\n" +" && !(gnu_get_libc_version != 0)))\n" +" {\n" +" libcmajor = 0;\n" +" libcminor = 0;\n" +" libcteeny = 0;\n" +" }\n" +" else\n" +" {\n" +" const char * ptr;\n" +" int glibcmajor = 0;\n" +"\n" +" if (gnu_get_libc_version != 0)\n" +" {\n" +" ptr = gnu_get_libc_version ();\n" +" glibcmajor = 4;\n" +" }\n" +" else if (&__libc_version != 0)\n" +" {\n" +" ptr = __libc_version;\n" +" glibcmajor = 4;\n" +" }\n" +" else\n" +" ptr = __linux_C_lib_version;\n" +"\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(inFile) + FILE* inFile; +{ + static char* libcso = "/usr/lib/libc.so"; + struct stat sb; + char buf[PATH_MAX]; + char* ptr; + int libcmajor, libcminor, libcteeny; + + if (lstat (libcso, &sb) == 0) { + if (S_ISLNK (sb.st_mode)) { + /* + * /usr/lib/libc.so is a symlink -- this is libc 5.x + * we can do this the quick way + */ + if (readlink (libcso, buf, PATH_MAX) >= 0) { + for (ptr = buf; *ptr && !isdigit (*ptr); ptr++); + (void) sscanf (ptr, "%d.%d.%d", &libcmajor, &libcminor, &libcteeny); + fprintf(inFile, "#define DefaultLinuxCLibMajorVersion %d\n", libcmajor); + fprintf(inFile, "#define DefaultLinuxCLibMinorVersion %d\n", libcminor); + fprintf(inFile, "#define DefaultLinuxCLibTeenyVersion %d\n", libcteeny); + } + } else { + /* + * /usr/lib/libc.so is NOT a symlink -- this is libc 6.x / glibc 2.x + * now we have to figure this out the hard way. + */ + char *aout = tmpnam (NULL); + FILE *fp; + const char *format = "%s -o %s -x c -"; + char *cc; + int len; + char *command; + + cc = getenv ("CC"); + if (cc == NULL) + cc = "gcc"; + len = strlen (aout) + strlen (format) + strlen (cc); + if (len < 128) len = 128; + command = alloca (len); + + if (snprintf (command , len, format, cc, aout) == len) + abort (); + + fp = popen (command, "w"); + if (fp == NULL || fprintf (fp, "%s\n", libc_c) < 0 || pclose (fp) != 0) + abort (); + + fp = popen (aout, "r"); + if (fp == NULL) + abort (); + + while (fgets (command, len, fp)) + fprintf (inFile, command); + + len = pclose (fp); + remove (aout); + if (len) + abort (); + } + } +} + +static void get_ld_version(inFile) + FILE* inFile; +{ + FILE* ldprog = popen ("ld -v", "r"); + char c; + int ldmajor, ldminor; + + if (ldprog) { + do { + c = fgetc (ldprog); + } while (c != EOF && !isdigit (c)); + ungetc (c, ldprog); + (void) fscanf (ldprog, "%d.%d", &ldmajor, &ldminor); + fprintf(inFile, "#define DefaultLinuxBinUtilsMajorVersion %d\n", + ldmajor * 10 + ldminor); + pclose (ldprog); + } +} +#endif + +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +#if defined(sun) && defined(__SVR4) +static void get_sun_compiler_versions (inFile) + FILE* inFile; +{ + char buf[PATH_MAX]; + char cmd[PATH_MAX]; + static char* sunpro_cc = "/opt/SUNWspro/bin/cc"; + static char* sunpro_CC = "/opt/SUNWspro/bin/CC"; + int cmajor, cminor; + char* vptr; + struct stat sb; + FILE* ccproc; + + if (lstat (sunpro_cc, &sb) == 0) { + strcpy (cmd, sunpro_cc); + strcat (cmd, " -V 2>&1"); + if ((ccproc = popen (cmd, "r")) != NULL) { + if (fgets (buf, PATH_MAX, ccproc) != NULL) { + vptr = strrchr (buf, 'C'); + for (; !isdigit(*vptr); vptr++); + (void) sscanf (vptr, "%d.%d", &cmajor, &cminor); + fprintf (inFile, + "#define DefaultSunProCCompilerMajorVersion %d\n", + cmajor); + fprintf (inFile, + "#define DefaultSunProCCompilerMinorVersion %d\n", + cminor); + } + while (fgets (buf, PATH_MAX, ccproc) != NULL) {}; + pclose (ccproc); + } + } + if (lstat (sunpro_CC, &sb) == 0) { + strcpy (cmd, sunpro_CC); + strcat (cmd, " -V 2>&1"); + if ((ccproc = popen (cmd, "r")) != NULL) { + if (fgets (buf, PATH_MAX, ccproc) != NULL) { + vptr = strrchr (buf, 'C'); + for (; !isdigit(*vptr); vptr++); + (void) sscanf (vptr, "%d.%d", &cmajor, &cminor); + fprintf (inFile, + "#define DefaultSunProCplusplusCompilerMajorVersion %d\n", + cmajor); + fprintf (inFile, + "#define DefaultSunProCplusplusCompilerMinorVersion %d\n", + cminor); + } + while (fgets (buf, PATH_MAX, ccproc) != NULL) {}; + pclose (ccproc); + } + } +} +#endif + +static void get_gcc_incdir(inFile) + FILE* inFile; +{ + static char* gcc_path[] = { +#ifdef linux + "/usr/bin/cc", /* for Linux PostIncDir */ +#endif + "/usr/local/bin/gcc", + "/opt/gnu/bin/gcc" + }; + struct stat sb; + int i; + FILE* gccproc; + char buf[PATH_MAX]; + char cmd[PATH_MAX]; + char* ptr; + + buf[0] = '\0'; + for (i = 0; i < sizeof gcc_path / sizeof gcc_path[0]; i++) { + if (lstat (gcc_path[i], &sb) == 0) { + strcpy (cmd, gcc_path[i]); + strcat (cmd, " --print-libgcc-file-name"); + if ((gccproc = popen (cmd, "r")) != NULL) { + if (fgets (buf, PATH_MAX, gccproc) != NULL) { + ptr = strstr (buf, "libgcc.a"); + if (ptr) strcpy (ptr, "include"); + } + (void) pclose (gccproc); + break; + } + } + } + if (buf[0]) + fprintf (inFile, "#define DefaultGccIncludeDir %s\n", buf); +} + +boolean +define_os_defaults(inFile) + FILE *inFile; +{ +#ifndef WIN32 +#if (defined(DEFAULT_OS_NAME) || defined(DEFAULT_OS_MAJOR_REV) || \ + defined(DEFAULT_OS_MINOR_REV) || defined(DEFAUL_OS_TEENY_REV)) + struct utsname name; + char buf[SYS_NMLN * 5 + 1]; + + /* Obtain the system information. */ + if (uname(&name) < 0) + LogFatal("Cannot invoke uname", ""); + +# ifdef DEFAULT_OS_NAME + parse_utsname(&name, DEFAULT_OS_NAME, buf, + "Bad DEFAULT_OS_NAME syntax %s"); + if (buf[0] != '\0') + fprintf(inFile, "#define DefaultOSName %s\n", buf); +# endif + +# ifdef DEFAULT_OS_MAJOR_REV + parse_utsname(&name, DEFAULT_OS_MAJOR_REV, buf, + "Bad DEFAULT_OS_MAJOR_REV syntax %s"); + fprintf(inFile, "#define DefaultOSMajorVersion %s\n", + *buf ? trim_version(buf) : "0"); +# endif + +# ifdef DEFAULT_OS_MINOR_REV + parse_utsname(&name, DEFAULT_OS_MINOR_REV, buf, + "Bad DEFAULT_OS_MINOR_REV syntax %s"); + fprintf(inFile, "#define DefaultOSMinorVersion %s\n", + *buf ? trim_version(buf) : "0"); +# endif + +# ifdef DEFAULT_OS_TEENY_REV + parse_utsname(&name, DEFAULT_OS_TEENY_REV, buf, + "Bad DEFAULT_OS_TEENY_REV syntax %s"); + fprintf(inFile, "#define DefaultOSTeenyVersion %s\n", + *buf ? trim_version(buf) : "0"); +# endif +#endif +#ifdef linux + get_distrib (inFile); + get_libc_version (inFile); + get_ld_version(inFile); +#endif + get_gcc_incdir(inFile); +#if defined (sun) && defined(SVR4) + get_sun_compiler_versions (inFile); +#endif +#else /* WIN32 */ + OSVERSIONINFO osvi; + static char* os_names[] = { "Win32s", "Windows 95", "Windows NT" }; + + 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 */ + return FALSE; +} + +void +cppit(imakefile, template, masterc, outfd, outfname) + 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() +{ + doit(NULL, make_argv[0], make_argv); +} + +char * +CleanCppInput(imakefile) + 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++; + 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) { + tmpImakefile = Strdup(tmpImakefile); + (void) mktemp(tmpImakefile); + outFile = fopen(tmpImakefile, "w"); + if (outFile == NULL) + LogFatal("Cannot open %s for write.", + tmpImakefile); + } + 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(tmpfd, tmpfname) + FILE *tmpfd; + char *tmpfname; +{ + char *input; + int blankline = 0; + + while((input = ReadLine(tmpfd, tmpfname))) { + if (isempty(input)) { + if (blankline++) + continue; + KludgeResetRule(); + } else { + blankline = 0; + KludgeOutputLine(&input); + 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(line) + register char *line; +{ + register 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[5] == ' ' || pend[5] == '\t' || pend[5] == '\0')) + { + *pend = '#'; + strcpy(pend+1, pend+5); + } +#ifdef MAGIC_MAKE_VARS + if (*pend == 'X' && pend[1] == 'V' && pend[2] == 'A' && + pend[3] == 'R') + { + char varbuf[5]; + int i; + + if (pend[4] == 'd' && pend[5] == 'e' && pend[6] == 'f' && + pend[7] >= '0' && pend[7] <= '9') + { + i = pend[7] - '0'; + sprintf(varbuf, "%0.4d", xvariable); + strncpy(pend+4, varbuf, 4); + xvariables[i] = xvariable; + xvariable = (xvariable + 1) % 10000; + } + else if (pend[4] == 'u' && pend[5] == 's' && + pend[6] == 'e' && pend[7] >= '0' && + pend[7] <= '9') + { + i = pend[7] - '0'; + sprintf(varbuf, "%0.4d", xvariables[i]); + strncpy(pend+4, varbuf, 4); + } + } +#endif + } + } + while (--pend >= line && (*pend == ' ' || *pend == '\t')) ; + pend[1] = '\0'; + return (*line == '\0'); +} + +/*ARGSUSED*/ +char * +ReadLine(tmpfd, tmpfname) + 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) + 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 */ +#ifdef WIN32 + 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(fd, buf, cnt, fname) + FILE *fd; + int cnt; + char *buf; + char *fname; +{ + if (fwrite(buf, sizeof(char), cnt, fd) == -1) + LogFatal("Cannot write to %s.", fname); +} + +char * +Emalloc(size) + int size; +{ + char *p; + + if ((p = malloc(size)) == NULL) + LogFatalI("Cannot allocate %d bytes", size); + return(p); +} + +#ifdef FIXUP_CPP_WHITESPACE +void +KludgeOutputLine(pline) + 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 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 && +# ifdef WIN32 + 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 REMOVE_CPP_LEADSPACE + if (!InRule && **pline == ' ') { + while (**pline == ' ') + (*pline)++; + } +# endif + goto breakfor; +# ifdef INLINE_SYNTAX + case '<': + 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() +{ + InRule = FALSE; +} +#endif /* FIXUP_CPP_WHITESPACE */ + +char * +Strdup(cp) + register char *cp; +{ + register char *new = Emalloc(strlen(cp) + 1); + + strcpy(new, cp); + return new; +} diff --git a/imake.man b/imake.man new file mode 100644 index 0000000..2372d3f --- /dev/null +++ b/imake.man @@ -0,0 +1,254 @@ +.\" $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. +.TH IMAKE 1 "Release 6.1" "X Version 11" +.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\-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 \-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 +/lib/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 /lib/cpp. +.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/imakemdep.h b/imakemdep.h new file mode 100644 index 0000000..b6ebd42 --- /dev/null +++ b/imakemdep.h @@ -0,0 +1,815 @@ +/* $Xorg: imakemdep.h,v 1.6 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. + +*/ + + +/* + * 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 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. + */ +#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 + +#if defined(USL) || defined(__USLC__) || defined(Oki) || defined(NCR) +#define imake_ccflags "-Xa -DSVR4" +#endif + +/* SCO may define __USLC__ so put this after the USL check */ +#if defined(M_UNIX) || defined(_SCO_DS) +#ifdef imake_ccflags +#undef imake_ccflags +#endif +#define imake_ccflags "-Dsco" +#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 + +#ifdef __convex__ +#define imake_ccflags "-fn -tm c1" +#endif + +#ifdef apollo +#define imake_ccflags "-DX_NOT_POSIX" +#endif + +#ifdef WIN32 +#if _MSC_VER < 1000 +#define imake_ccflags "-nologo -batch -D__STDC__" +#else +#define imake_ccflags "-nologo -D__STDC__" +#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 + +#ifdef MACH +#define imake_ccflags "-DNOSTDHDRS" +#endif + +/* this is for OS/2 under EMX. This won't work with DOS */ +#if defined(__EMX__) +#define imake_ccflags "-DBSD43" +#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 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)) +#define FIXUP_CPP_WHITESPACE +#endif +#ifdef WIN32 +#define REMOVE_CPP_LEADSPACE +#define INLINE_SYNTAX +#define MAGIC_MAKE_VARS +#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. + */ +#ifdef hpux +#define USE_CC_E +#endif +#ifdef WIN32 +#define USE_CC_E +#define DEFAULT_CC "cl" +#endif +#ifdef apollo +#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__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) +#define DEFAULT_CPP "/usr/libexec/cpp" +#endif +#if defined(__sgi) && defined(__ANSI_CPP__) +#define USE_CC_E +#endif +#ifdef MACH +#define USE_CC_E +#endif +#ifdef __minix_vmd +#define DEFAULT_CPP "/usr/lib/cpp" +#endif +#if defined(__EMX__) +/* expects cpp in PATH */ +#define DEFAULT_CPP "cpp" +#endif + +/* + * 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.tmpl 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 */ +char *cpp_argv[ARGUMENTS] = { + "cc", /* replaced by the actual program to exec */ + "-I.", /* add current directory to include path */ +#ifdef unix + "-Uunix", /* remove unix symbol so that filename unix.c okay */ +#endif +#if defined(__386BSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(MACH) +# ifdef __i386__ + "-D__i386__", +# 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(__USLC__) + "-DUSL", /* USL */ +#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) + "-Dsco", +# if defined(sco324) + "-Dsco324", +# endif +#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 +# ifdef SCO + "-DSCO", +# ifdef SCO324 + "-DSCO324", +# endif +# endif +# ifdef ESIX + "-DESIX", +# endif +# ifdef ATT + "-DATT", +# endif +# ifdef DELL + "-DDELL", +# endif +# endif +#endif +#ifdef SYSV386 /* System V/386 folks, obsolete */ + "-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 +# ifdef SCO + "-DSCO", +# ifdef SCO324 + "-DSCO324", +# endif +# endif +# ifdef ESIX + "-DESIX", +# endif +# ifdef ATT + "-DATT", +# endif +# ifdef DELL + "-DDELL", +# endif +# endif +#endif +#ifdef __osf__ + "-D__osf__", +# ifdef __mips__ + "-D__mips__", +# 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 +#endif +#ifdef WIN32 + "-DWIN32", + "-nologo", +#if _MSC_VER < 1000 + "-batch", +#endif + "-D__STDC__", +#endif +#ifdef NCR + "-DNCR", /* NCR */ +#endif +#ifdef linux + "-traditional", + "-Dlinux", +#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 + "-DCROSS_i80386", +# endif +# ifdef CROSS_sparc + "-DCROSS_sparc", +# endif +# ifdef CROSS_mc68000 + "-DCROSS_mc68000", +# 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(__EMX__) + "-traditional", + "-Demxos2", +#endif + +}; + + +/* + * Step 6: DEFAULT_OS_MAJOR_REV, DEFAULT_OS_MINOR_REV, DEFAULT_OS_TEENY_REV, + * and DEFAULT_OS_NAME. + * If your systems provides a way to generate the default major, + * 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. + */ +#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(linux) || 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__) +/* uname -v returns "x.yz" or "x.y.z", e.g. "2.02" or "2.1.2". */ +# define DEFAULT_OS_MAJOR_REV "v %[0-9]" +# define DEFAULT_OS_MINOR_REV "v %*d.%1s" +# define DEFAULT_OS_TEENY_REV "v %*d.%*c%[.0-9]" +# define DEFAULT_OS_NAME "srvm %[^\n]" +#elif defined(__osf__) +/* 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(__FreeBSD__) +/* NetBSD, OpenBSD, 386BSD, and BSD/OS too? */ +/* uname -r returns "x.y[.z]-mumble", e.g. "2.1.5-RELEASE" or "2.2-0801SNAP" */ +# define DEFAULT_OS_MAJOR_REV "r %[0-9]" +# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]" +# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]" +# define DEFAULT_OS_NAME "srm %[^\n]" +#elif defined(_SEQUENT_) +/* 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 + +#else /* else MAKEDEPEND */ +/* + * 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. + */ +struct symtab predefs[] = { +#ifdef apollo + {"apollo", "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 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__", "1"}, +#endif +#if __STDC__ + {"__STDC__", "1"}, +#endif +#ifdef __HIGHC__ + {"__HIGHC__", "1"}, +#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 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 __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 __FreeBSD__ + {"__FreeBSD__", "1"}, +#endif +#ifdef __OpenBSD__ + {"__OpenBSD__", "1"}, +#endif +#ifdef __NetBSD__ + {"__NetBSD__", "1"}, +#endif +#ifdef __EMX__ + {"__EMX__", "1"}, +#endif + /* add any additional symbols before this line */ + {NULL, NULL} +}; + +#endif /* MAKEDEPEND */ +#endif /* CCIMAKE */ @@ -0,0 +1,13 @@ +#! /bin/sh +# makeg - run "make" with options necessary to make a debuggable executable +# $Xorg: makeg.sh,v 1.3 2000/08/17 19:41:52 cpqbld Exp $ + +# set GDB=1 in your environment if using gdb on Solaris 2. + +make="${MAKE-make}" +flags="CDEBUGFLAGS=-g CXXDEBUGFLAGS=-g" + +# gdb on Solaris needs the stabs included in the executable +test "${GDB+yes}" = yes && flags="$flags -xs" + +exec "$make" $flags LDSTRIPFLAGS= ${1+"$@"} diff --git a/makeg.man b/makeg.man new file mode 100644 index 0000000..6f5ded4 --- /dev/null +++ b/makeg.man @@ -0,0 +1,61 @@ +.\" $Xorg: makeg.man,v 1.4 2001/02/09 02:03:17 xorgcvs Exp $ +.\" Copyright (c) 1996, 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. +.\" +.TH MAKEG 1 "Release 6.4" "X Version 11" +.SH NAME +makeg \- make a debuggable executable +.SH SYNOPSIS +.B makeg +[ +.I make-options .\|.\|. +] [ +.I targets .\|.\|. +] +.SH DESCRIPTION +The +.I makeg +script runs +.I make, +passing it variable settings to create a debuggable target when used +with a Makefile generated by +.I imake. +For example, it arranges for the C compiler to be called with the +.B \-g +option. +.SH ENVIRONMENT +.TP 8 +.B MAKE +The +.I make +program to use. Default ``make''. +.TP 8 +.B GDB +Set to a non-null value if using the +.I gdb +debugger on Solaris 2, which requires additional debugging options to +be passed to the compiler. +.SH "SEE ALSO" +.I make (1), +.I imake (1) diff --git a/mdepend.cpp b/mdepend.cpp new file mode 100644 index 0000000..75b0652 --- /dev/null +++ b/mdepend.cpp @@ -0,0 +1,243 @@ +XCOMM!/bin/sh +XCOMM +XCOMM $Xorg: mdepend.cpp,v 1.3 2000/08/17 19:41:52 cpqbld Exp $ +XCOMM +XCOMM Do the equivalent of the 'makedepend' program, but do it right. +XCOMM +XCOMM Usage: +XCOMM +XCOMM makedepend [cpp-flags] [-w width] [-s magic-string] [-f makefile] +XCOMM [-o object-suffix] +XCOMM +XCOMM Notes: +XCOMM +XCOMM The C compiler used can be overridden with the environment +XCOMM variable "CC". +XCOMM +XCOMM The "-v" switch of the "makedepend" program is not supported. +XCOMM +XCOMM +XCOMM This script should +XCOMM work on both USG and BSD systems. However, when System V.4 comes out, +XCOMM USG users will probably have to change "silent" to "-s" instead of +XCOMM "-" (at least, that is what the documentation implies). +XCOMM +CC=PREPROC + +silent='-' + +TMP=/tmp/mdep$$ +CPPCMD=${TMP}a +DEPENDLINES=${TMP}b +TMPMAKEFILE=${TMP}c +MAGICLINE=${TMP}d +ARGS=${TMP}e + +trap "rm -f ${TMP}*; exit 1" 1 2 15 +trap "rm -f ${TMP}*; exit 0" 1 2 13 + +echo " \c" > $CPPCMD +if [ `wc -c < $CPPCMD` -eq 1 ] +then + c="\c" + n= +else + c= + n="-n" +fi + +echo $n "$c" >$ARGS + +files= +makefile= +magic_string='# DO NOT DELETE' +objsuffix='.o' +width=78 +endmarker="" +verbose=n +append=n + +while [ $# != 0 ] +do + if [ "$endmarker"x != x ] && [ "$endmarker" = "$1" ]; then + endmarker="" + else + case "$1" in + -D*|-I*) + echo $n " '$1'$c" >> $ARGS + ;; + + -g|-O) # ignore so we can just pass $(CFLAGS) in + ;; + + *) + if [ "$endmarker"x = x ]; then + case "$1" in + -w) + width="$2" + shift + ;; + -s) + magic_string="$2" + shift + ;; + -f*) + if [ "$1" = "-f-" ]; then + makefile="-" + else + makefile="$2" + shift + fi + ;; + -o) + objsuffix="$2" + shift + ;; + + --*) + echo "$1" | sed 's/^\-\-//' >${TMP}end + endmarker="`cat ${TMP}end`" + rm -f ${TMP}end + if [ "$endmarker"x = x ]; then + endmarker="--" + fi + ;; + -v) + verbose="y" + ;; + + -a) + append="y" + ;; + + -cc) + CC="$2" + shift + ;; + + -*) + echo "Unknown option '$1' ignored" 1>&2 + ;; + *) + files="$files $1" + ;; + esac + fi + ;; + esac + fi + shift +done +echo ' $*' >> $ARGS + +echo "#!/bin/sh" > $CPPCMD +echo "exec $CC `cat $ARGS`" >> $CPPCMD +chmod +x $CPPCMD +rm $ARGS + +case "$makefile" in + '') + if [ -r makefile ] + then + makefile=makefile + elif [ -r Makefile ] + then + makefile=Makefile + else + echo 'no makefile or Makefile found' 1>&2 + exit 1 + fi + ;; + -) + makefile=$TMPMAKEFILE + ;; +esac + +if [ "$verbose"x = "y"x ]; then + cat $CPPCMD +fi + +echo '' > $DEPENDLINES +for i in $files +do + $CPPCMD $i \ + | sed -n "/^#/s;^;$i ;p" +done \ + | sed -e 's|/[^/.][^/]*/\.\.||g' -e 's|/\.[^.][^/]*/\.\.||g' \ + -e 's|"||g' -e 's| \./| |' \ + | awk '{ + if ($1 != $4 && $2 != "#ident" && $2 != "#pragma") + { + ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'" + print ofile, $4 + } + }' \ + | sort -u \ + | awk ' + { + newrec = rec " " $2 + if ($1 != old1) + { + old1 = $1 + if (rec != "") + print rec + rec = $1 ": " $2 + } + else if (length (newrec) > '"$width"') + { + print rec + rec = $1 ": " $2 + } + else + rec = newrec + } + END \ + { + if (rec != "") + print rec + }' \ + | egrep -v '^[^:]*:[ ]*$' >> $DEPENDLINES + +trap "" 1 2 13 15 # Now we are committed +case "$makefile" in + $TMPMAKEFILE) + ;; + *) + rm -f $makefile.bak + cp $makefile $makefile.bak + echo "Appending dependencies to $makefile" + ;; +esac + +XCOMM +XCOMM If not -a, append the magic string and a blank line so that +XCOMM /^$magic_string/+1,\$d can be used to delete everything from after +XCOMM the magic string to the end of the file. Then, append a blank +XCOMM line again and then the dependencies. +XCOMM +if [ "$append" = "n" ] +then + cat >> $makefile << END_OF_APPEND + +$magic_string + +END_OF_APPEND + ed $silent $makefile << END_OF_ED_SCRIPT +/^$magic_string/+1,\$d +w +q +END_OF_ED_SCRIPT + echo '' >>$makefile +fi + +cat $DEPENDLINES >>$makefile + +case "$makefile" in + $TMPMAKEFILE) + cat $TMPMAKEFILE + ;; + +esac + +rm -f ${TMP}* +exit 0 diff --git a/mergelib.cpp b/mergelib.cpp new file mode 100644 index 0000000..c0d7c02 --- /dev/null +++ b/mergelib.cpp @@ -0,0 +1,102 @@ +XCOMM!/bin/sh +XCOMM +XCOMM $Xorg: mergelib.cpp,v 1.4 2001/02/09 02:03:17 xorgcvs Exp $ +XCOMM +XCOMM Copyright (c) 1989, 1998 The Open Group +XCOMM +XCOMM Permission to use, copy, modify, distribute, and sell this software and +XCOMM its documentation for any purpose is hereby granted without fee, provided +XCOMM that the above copyright notice appear in all copies and that both that +XCOMM copyright notice and this permission notice appear in supporting +XCOMM documentation. +XCOMM +XCOMM The above copyright notice and this permission notice shall be included in +XCOMM all copies or substantial portions of the Software. +XCOMM +XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +XCOMM IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +XCOMM FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +XCOMM OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +XCOMM AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +XCOMM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +XCOMM +XCOMM Except as contained in this notice, the name of The Open Group shall not be +XCOMM used in advertising or otherwise to promote the sale, use or other dealings +XCOMM in this Software without prior written authorization from The Open Group. +XCOMM +XCOMM Author: Jim Fulton, MIT X Consortium +XCOMM +XCOMM mergelib - merge one library into another; this is commonly used by X +XCOMM to add the extension library into the base Xlib. +XCOMM + +usage="usage: $0 to-library from-library [object-filename-prefix]" +objprefix=_ + +case $# in + 2) ;; + 3) objprefix=$3 ;; + *) echo "$usage" 1>&2; exit 1 ;; +esac + +tolib=$1 +fromlib=$2 + +if [ ! -f $fromlib ]; then + echo "$0: no such from-library $fromlib" 1>&2 + exit 1 +fi + +if [ ! -f $tolib ]; then + echo "$0: no such to-library $tolib" 1>&2 + exit 1 +fi + + +XCOMM +XCOMM Create a temp directory, and figure out how to reference the +XCOMM object files from it (i.e. relative vs. absolute path names). +XCOMM + +tmpdir=tmp.$$ +origdir=.. + +mkdir $tmpdir + +if [ ! -d $tmpdir ]; then + echo "$0: unable to create temporary directory $tmpdir" 1>&2 + exit 1 +fi + +case "$fromlib" in + /?*) upfrom= ;; + *) upfrom=../ ;; +esac + +case "$tolib" in + /?*) upto= ;; + *) upto=../ ;; +esac + + +XCOMM +XCOMM In the temp directory, extract all of the object files and prefix +XCOMM them with some symbol to avoid name clashes with the base library. +XCOMM +cd $tmpdir +ar x ${upfrom}$fromlib +for i in *.o; do + mv $i ${objprefix}$i +done + + +XCOMM +XCOMM Merge in the object modules, ranlib (if appropriate) and cleanup +XCOMM +ARCMD ${upto}$tolib *.o +RANLIB ${upto}$tolib +cd $origdir +rm -rf $tmpdir + + + diff --git a/mkdirhier b/mkdirhier new file mode 100644 index 0000000..17390f4 --- /dev/null +++ b/mkdirhier @@ -0,0 +1,67 @@ +#!/bin/sh +# $Xorg: mkdirhier.sh,v 1.3 2000/08/17 19:41:53 cpqbld Exp $ +# Courtesy of Paul Eggert + +newline=' +' +IFS=$newline + +case ${1--} in +-*) echo >&2 "mkdirhier: usage: mkdirhier directory ..."; exit 1 +esac + +status= + +for directory +do + case $directory in + '') + echo >&2 "mkdirhier: empty directory name" + status=1 + continue;; + *"$newline"*) + echo >&2 "mkdirhier: directory name contains a newline: \`\`$directory''" + status=1 + continue;; + ///*) prefix=/;; # See Posix 2.3 "path". + //*) prefix=//;; + /*) prefix=/;; + -*) prefix=./;; + *) prefix= + esac + + IFS=/ + set x $directory + case $2 in + */*) # IFS parsing is broken + IFS=' ' + set x `echo $directory | tr / ' '` + ;; + esac + IFS=$newline + shift + + for filename + do + path=$prefix$filename + prefix=$path/ + shift + + test -d "$path" || { + paths=$path + for filename + do + if [ "$filename" != "." ]; then + path=$path/$filename + paths=$paths$newline$path + fi + done + + mkdir $paths || status=$? + + break + } + done + done + +exit $status diff --git a/mkdirhier.man b/mkdirhier.man new file mode 100644 index 0000000..ea85390 --- /dev/null +++ b/mkdirhier.man @@ -0,0 +1,39 @@ +.\" $Xorg: mkdirhier.man,v 1.4 2001/02/09 02:03:17 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 +.\" dealing in this Software without prior written authorization from The +.\" Open Group. +.TH MKDIRHIER 1 "Release 6.4" "X Version 11" +.SH NAME +mkdirhier \- makes a directory hierarchy +.SH SYNOPSIS +.B mkdirhier +directory ... +.SH DESCRIPTION +The +.I mkdirhier +command creates the specified directories. Unlike +.I mkdir +if any of the parent directories of the specified directory +do not exist, it creates them as well. +.SH "SEE ALSO" +mkdir(1) diff --git a/xmkmf.cpp b/xmkmf.cpp new file mode 100644 index 0000000..0eedb54 --- /dev/null +++ b/xmkmf.cpp @@ -0,0 +1,58 @@ +XCOMM!/bin/sh + +XCOMM +XCOMM make a Makefile from an Imakefile from inside or outside the sources +XCOMM +XCOMM $Xorg: xmkmf.cpp,v 1.3 2000/08/17 19:41:53 cpqbld Exp $ + +usage="usage: $0 [-a] [top_of_sources_pathname [current_directory]]" + +configdirspec=CONFIGDIRSPEC +topdir= +curdir=. +do_all= + +case "$1" in +-a) + do_all="yes" + shift + ;; +esac + +case $# in + 0) ;; + 1) topdir=$1 ;; + 2) topdir=$1 curdir=$2 ;; + *) echo "$usage" 1>&2; exit 1 ;; +esac + +case "$topdir" in + -*) echo "$usage" 1>&2; exit 1 ;; +esac + +if [ -f Makefile ]; then + echo mv -f Makefile Makefile.bak + mv -f Makefile Makefile.bak +fi + +if [ "$topdir" = "" ]; then + args="-DUseInstalled "$configdirspec +else + args="-I$topdir/config/cf -DTOPDIR=$topdir -DCURDIR=$curdir" +fi + +echo imake $args +case "$do_all" in +yes) + imake $args && + echo "make Makefiles" && + make Makefiles && + echo "make includes" && + make includes && + echo "make depend" && + make depend + ;; +*) + imake $args + ;; +esac diff --git a/xmkmf.man b/xmkmf.man new file mode 100644 index 0000000..f1094bd --- /dev/null +++ b/xmkmf.man @@ -0,0 +1,86 @@ +.\" $Xorg: xmkmf.man,v 1.4 2001/02/09 02:03:17 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 +.\" dealing in this Software without prior written authorization from The +.\" Open Group. +.TH XMKMF 1 "Release 6.4" "X Version 11" +.SH NAME +xmkmf \- create a Makefile from an Imakefile +.SH SYNOPSIS +.B xmkmf +[ -a ] [ +.I topdir +[ +.I curdir +] ] +.SH DESCRIPTION +The +.I xmkmf +command is the normal way to create a +.I Makefile +from an +.I Imakefile +shipped with third-party software. +.PP +When invoked with no arguments in a directory containing an +.I Imakefile, +the +.I imake +program is run with arguments appropriate for your system +(configured into +.I xmkmf +when X was built) and generates a +.I Makefile. +.PP +When invoked with the +.I \-a +option, +.I xmkmf +builds the +.I Makefile +in the current directory, and then automatically executes +``make Makefiles'' (in case there are subdirectories), +``make includes'', +and ``make depend'' for you. +This is the normal way to configure software that is outside +the X Consortium build tree. +.PP +If working inside the X Consortium build tree (unlikely unless you +are an X developer, and even then this option is never really used), the +.I topdir +argument should be specified as the relative pathname from the +current directory to the top of the build tree. Optionally, +.I curdir +may be specified as a relative pathname from the top of the build +tree to the current directory. It is necessary to supply +.I curdir +if the current directory has subdirectories, or the +.I Makefile +will not be able to build the subdirectories. +If a +.I topdir +is given, +.I xmkmf +assumes nothing is installed on your system and looks for files in +the build tree instead of using the installed versions. +.SH "SEE ALSO" +imake(1) |