Don't quit if getpwuid() fails. It can fail if some nameservices are not
[nedit.git] / util / system.h
blobd9ed0509d692fde45dbf6b79fb1b195235f13ef3
1 /* $Id: system.h,v 1.12 2002/08/09 20:48:06 tringali Exp $ */
3 #ifndef NEDIT_SYSTEM_H_INCLUDED
4 #define NEDIT_SYSTEM_H_INCLUDED
6 /*******************************************************************************
7 * *
8 * system.h -- Compile time configuration *
9 * *
10 * Copyright (C) 2001 Scott Tringali *
11 * *
12 * This is free software; you can redistribute it and/or modify it under the *
13 * terms of the GNU General Public License as published by the Free Software *
14 * Foundation; either version 2 of the License, or (at your option) any later *
15 * version. *
16 * *
17 * This software is distributed in the hope that it will be useful, but WITHOUT *
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
20 * for more details. *
21 * *
22 * You should have received a copy of the GNU General Public License along with *
23 * software; if not, write to the Free Software Foundation, Inc., 59 Temple *
24 * Place, Suite 330, Boston, MA 02111-1307 USA *
25 * *
26 * Nirvana Text Editor *
27 * July 23, 2001 *
28 * *
29 * Written by Scott Tringali, http://www.tringali.org *
30 * *
31 *******************************************************************************/
34 Determine which machine we were compiled with. This isn't as accurate
35 as calling uname(), which is preferred. However, this gets us very close
36 for a majority of the machines out there, and doesn't require any games
37 with make.
39 A better, but trickier solution, is to run uname at compile time, capture
40 the string, and place it in the executable.
42 Please update this with the proper symbols for your compiler/CPU. It
43 may take a little sleuthing to find out what the correct symbol is.
44 Better compilers/OSs document the symbols they define, but not all do.
45 Usually, the correct ones are prepended with an _ or __, as this is
46 namespace is reserved by ANSI C for the compiler implementation.
48 The order is important for the x86 macros. Some compilers will
49 simulatenously define __i386 and __pentium, so we pick the highest one.
52 #if defined(__alpha) || defined (_M_ALPHA)
53 # define COMPILE_MACHINE "Alpha"
54 #elif defined(__mips)
55 # define COMPILE_MACHINE "MIPS"
56 #elif defined(__sparc)
57 # define COMPILE_MACHINE "Sparc"
58 #elif defined(__hppa)
59 # define COMPILE_MACHINE "PA-RISC"
60 #elif defined(__PPC__) || defined(_POWER)
61 # define COMPILE_MACHINE "PowerPC"
62 #elif defined(__ia64) || defined(_M_IA64)
63 # define COMPILE_MACHINE "IA64"
64 #elif defined(__k6) || defined(__k6__)
65 # define COMPILE_MACHINE "K6"
66 #elif defined(__athlon) || defined(__athlon__)
67 # define COMPILE_MACHINE "Athlon"
68 #elif defined(__pentiumpro) || defined(__pentiumpro__)
69 # define COMPILE_MACHINE "Pentium Pro"
70 #elif defined(__pentium) || defined(__pentium__)
71 # define COMPILE_MACHINE "Pentium"
72 #elif defined(__i486) || defined(__i486__)
73 # define COMPILE_MACHINE "486"
74 #elif defined(__i386) || defined(__i386__)
75 # define COMPILE_MACHINE "386"
76 #elif defined(_M_IX86) || defined(_X86_)
77 # define COMPILE_MACHINE "x86"
78 #elif defined(__VAX)
79 # define COMPILE_MACHINE "VAX" /* Untested, please verify */
80 #else
81 # define COMPILE_MACHINE "Unknown"
82 #endif
85 #if defined(__osf__)
86 # define COMPILE_OS "Tru64/Digital Unix"
87 #elif defined(__sun)
88 # define COMPILE_OS "Solaris"
89 #elif defined(__hpux)
90 # define COMPILE_OS "HP/UX"
91 #elif defined(_WIN32)
92 # define COMPILE_OS "Win32"
93 #elif defined(__sgi)
94 # define COMPILE_OS "IRIX"
95 #elif defined(__Lynx__)
96 # define COMPILE_OS "Lynx"
97 #elif defined(__linux__)
98 # define COMPILE_OS "Linux"
99 #elif defined(_AIX)
100 # define COMPILE_OS "AIX"
101 #elif defined(__VMS) /* Untested, please verify */
102 # define COMPILE_OS "VMS"
103 #elif defined(__FreeBSD__) /* Untested, please verify */
104 # define COMPILE_OS "FreeBSD"
105 #elif defined(__OpenBSD__) /* Untested, please verify */
106 # define COMPILE_OS "OpenBSD"
107 #elif defined(__NetBSD__) /* Untested, please verify */
108 # define COMPILE_OS "NetBSD"
109 #elif defined(__bsdi) /* Untested, please verify */
110 # define COMPILE_OS "BSDI"
111 #elif defined(__ultrix) /* Untested, please verify */
112 # define COMPILE_OS "Ultrix"
113 #elif defined(__EMX__) /* I think this should be __OS2__ */
114 # define COMPILE_OS "OS/2"
115 #elif defined(__APPLE__) || defined(__MACOSX__)
116 # define COMPILE_OS "MacOS X"
117 #else
118 # define COMPILE_OS "Unknown"
119 #endif
122 /* Some of the info below derived from this excellent reference:
123 http://www.fortran-2000.com/ArnaudRecipes/Version.html */
125 #if defined(__GNUC__)
126 # define COMPILE_COMPILER "GNU C"
127 #elif defined (__DECC)
128 # define COMPILE_COMPILER "DEC C"
129 #elif defined (__DECCXX)
130 # define COMPILE_COMPILER "DEC C++"
131 #elif defined (__APOGEE)
132 # define COMPILE_COMPILER "Apogee"
133 #elif defined (__SUNPRO_C)
134 # define COMPILE_COMPILER "Forte C" /* aka Sun WorkShop Pro */
135 #elif defined (__SUNPRO_CC)
136 # define COMPILE_COMPILER "Forte C++" /* aka Sun WorkShop Pro */
137 #elif defined (__LCC__)
138 # define COMPILE_COMPILER "LCC"
139 #elif defined (_MSC_VER)
140 # define COMPILE_COMPILER "Microsoft C"
141 #elif defined (__BORLANDC__)
142 # define COMPILE_COMPILER "Borland C"
143 #elif defined (__sgi) && defined (_COMPILER_VERSION)
144 # define COMPILE_COMPILER "SGI MipsPro"
145 #elif defined (__xlC__) /* un*x versions of __IBMC__ !? */
146 # define COMPILE_COMPILER "IBM xlC"
147 #elif defined (__IBMC__)
148 # define COMPILE_COMPILER "IBM C" /* PC (OS/2, Windows) versions */
149 #elif defined (__HP_aCC)
150 # define COMPILE_COMPILER "HP aCC"
151 #elif defined (__KCC)
152 # define COMPILE_COMPILER "KAI C++"
153 #elif defined (__MWERKS__)
154 # define COMPILE_COMPILER "Metrowerks CodeWarrior"
155 #elif defined (__WATCOMC__)
156 # define COMPILE_COMPILER "Watcom C/C++"
157 #elif defined (__INTEL_COMPILER)
158 # define COMPILE_COMPILER "Intel C++"
159 #else
160 # define COMPILE_COMPILER "Unknown"
161 #endif
163 #endif /* NEDIT_SYSTEM_H_INCLUDED */