1 /*
2  * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
3  *
4  * This file is part of Jam - see jam.c for Copyright information.
5  */
6 
7 /*
8  * jam.h - includes and globals for jam
9  *
10  * 04/08/94 (seiwald) - Coherent/386 support added.
11  * 04/21/94 (seiwald) - DGUX is __DGUX__, not just __DGUX.
12  * 05/04/94 (seiwald) - new globs.jobs (-j jobs)
13  * 11/01/94 (wingerd) - let us define path of Jambase at compile time.
14  * 12/30/94 (wingerd) - changed command buffer size for NT (MS-DOS shell).
15  * 02/22/95 (seiwald) - Jambase now in /usr/local/lib.
16  * 04/30/95 (seiwald) - FreeBSD added.  Live Free or Die.
17  * 05/10/95 (seiwald) - SPLITPATH character set up here.
18  * 08/20/95 (seiwald) - added LINUX.
19  * 08/21/95 (seiwald) - added NCR.
20  * 10/23/95 (seiwald) - added SCO.
21  * 01/03/96 (seiwald) - SINIX (nixdorf) added.
22  * 03/13/96 (seiwald) - Jambase now compiled in; remove JAMBASE variable.
23  * 04/29/96 (seiwald) - AIX now has 31 and 42 OSVERs.
24  * 11/21/96 (peterk)  - added BeOS with MW CW mwcc
25  * 12/21/96 (seiwald) - OSPLAT now defined for NT.
26  * 07/19/99 (sickel)  - Mac OS X Server and Client support added
27  * 02/22/01 (seiwald) - downshift paths on case-insensitive macintosh
28  * 03/23/01 (seiwald) - VMS C++ changes.
29  * 10/29/01 (brett) - More IA64 ifdefs for MS.
30  * 02/18/00 (belmonte)- Support for Cygwin.
31  * 09/12/00 (seiwald) - OSSYMS split to OSMAJOR/OSMINOR/OSPLAT
32  * 12/29/00 (seiwald) - OSVER dropped.
33  * 01/21/02 (seiwald) - new -q to quit quickly on build failure
34  * 03/16/02 (seiwald) - support for -g (reorder builds by source time)
35  * 03/20/02 (seiwald) - MINGW porting from Max Blagai
36  * 08/16/02 (seiwald) - BEOS porting from Ingo Weinhold
37  * 09/19/02 (seiwald) - new -d displays
38  * 11/05/02 (seiwald) - OSPLAT now set to sparc on solaris.
39  */
40 
41 /*
42  * VMS, OPENVMS
43  */
44 
45 # ifdef VMS
46 
47 # define unlink remove
48 
49 # include <types.h>
50 # include <file.h>
51 # include <stat.h>
52 # include <stdio.h>
53 # include <ctype.h>
54 # include <stdlib.h>
55 # include <signal.h>
56 # include <string.h>
57 # include <time.h>
58 # include <unixlib.h>
59 
60 # define OSMINOR "OS=VMS"
61 # define OSMAJOR "VMS=true"
62 # define OS_VMS
63 # define MAXLINE 1024 /* longest 'together' actions */
64 # define SPLITPATH ','
65 # define EXITOK 1
66 # define EXITBAD 0
67 # define DOWNSHIFT_PATHS
68 
69 /* Do any of these work? */
70 # if defined( VAX ) || defined( __VAX ) || defined( vax )
71 # define OSPLAT "OSPLAT=VAX"
72 # endif
73 
74 # endif
75 
76 /*
77  * Windows NT
78  */
79 
80 # ifdef NT
81 
82 # include <fcntl.h>
83 # include <stdlib.h>
84 # include <stdio.h>
85 # include <ctype.h>
86 # include <malloc.h>
87 # include <memory.h>
88 # include <signal.h>
89 # include <string.h>
90 # include <time.h>
91 
92 # define OSMAJOR "NT=true"
93 # define OSMINOR "OS=NT"
94 # define OS_NT
95 # define SPLITPATH ';'
96 # define MAXLINE 2046	/* longest 'together' actions */
97 # define USE_EXECUNIX
98 # define USE_PATHUNIX
99 # define PATH_DELIM '\\'
100 # define DOWNSHIFT_PATHS
101 
102 /* AS400 cross-compile from NT */
103 
104 # ifdef AS400
105 # undef OSMINOR
106 # undef OSMAJOR
107 # define OSMAJOR "AS400=true"
108 # define OSMINOR "OS=AS400"
109 # define OS_AS400
110 # endif
111 
112 # endif
113 
114 /*
115  * Windows MingW32
116  */
117 
118 # ifdef MINGW
119 
120 # include <fcntl.h>
121 # include <stdlib.h>
122 # include <stdio.h>
123 # include <ctype.h>
124 # include <malloc.h>
125 # include <memory.h>
126 # include <signal.h>
127 # include <string.h>
128 # include <time.h>
129 
130 # define OSMAJOR "MINGW=true"
131 # define OSMINOR "OS=MINGW"
132 # define OS_NT
133 # define SPLITPATH ';'
134 # define MAXLINE 996	/* longest 'together' actions */
135 # define USE_EXECUNIX
136 # define USE_PATHUNIX
137 # define PATH_DELIM '\\'
138 # define DOWNSHIFT_PATHS
139 
140 # endif
141 
142 /*
143  * OS2
144  */
145 
146 # ifdef __OS2__
147 
148 # include <fcntl.h>
149 # include <stdlib.h>
150 # include <stdio.h>
151 # include <ctype.h>
152 # include <malloc.h>
153 # include <signal.h>
154 # include <string.h>
155 # include <time.h>
156 
157 # define OSMAJOR "OS2=true"
158 # define OSMINOR "OS=OS2"
159 # define OS_OS2
160 # define SPLITPATH ';'
161 # define MAXLINE 996	/* longest 'together' actions */
162 # define USE_EXECUNIX
163 # define USE_PATHUNIX
164 # define PATH_DELIM '\\'
165 # define DOWNSHIFT_PATHS
166 
167 # endif
168 
169 /*
170  * Macintosh MPW
171  */
172 
173 # ifdef macintosh
174 
175 # include <time.h>
176 # include <stdlib.h>
177 # include <string.h>
178 # include <stdio.h>
179 # include <ctype.h>
180 
181 # define OSMAJOR "MAC=true"
182 # define OSMINOR "OS=MAC"
183 # define OS_MAC
184 # define SPLITPATH ','
185 # define DOWNSHIFT_PATHS
186 
187 # endif
188 
189 /*
190  * God fearing UNIX
191  */
192 
193 # ifndef OSMINOR
194 
195 # define OSMAJOR "UNIX=true"
196 # define USE_EXECUNIX
197 # define USE_FILEUNIX
198 # define USE_PATHUNIX
199 # define PATH_DELIM '/'
200 
201 # ifdef _AIX
202 # define unix
203 # define OSMINOR "OS=AIX"
204 # define OS_AIX
205 # define NO_VFORK
206 # endif
207 # ifdef AMIGA
208 # define OSMINOR "OS=AMIGA"
209 # define OS_AMIGA
210 # endif
211 # ifdef __BEOS__
212 # define unix
213 # define OSMINOR "OS=BEOS"
214 # define OS_BEOS
215 # define NO_VFORK
216 # endif
217 # ifdef __bsdi__
218 # define OSMINOR "OS=BSDI"
219 # define OS_BSDI
220 # endif
221 # if defined (COHERENT) && defined (_I386)
222 # define OSMINOR "OS=COHERENT"
223 # define OS_COHERENT
224 # define NO_VFORK
225 # endif
226 # ifdef __cygwin__
227 # define OSMINOR "OS=CYGWIN"
228 # define OS_CYGWIN
229 # endif
230 # if defined __FreeBSD__ || defined __DragonFly__
231 # define OSMINOR "OS=FREEBSD"
232 # define OS_FREEBSD
233 # endif
234 # ifdef __DGUX__
235 # define OSMINOR "OS=DGUX"
236 # define OS_DGUX
237 # endif
238 # ifdef __hpux
239 # define OSMINOR "OS=HPUX"
240 # define OS_HPUX
241 # endif
242 # ifdef __OPENNT
243 # define unix
244 # define OSMINOR "OS=INTERIX"
245 # define OS_INTERIX
246 # define NO_VFORK
247 # endif
248 # ifdef __sgi
249 # define OSMINOR "OS=IRIX"
250 # define OS_IRIX
251 # define NO_VFORK
252 # endif
253 # ifdef __ISC
254 # define OSMINOR "OS=ISC"
255 # define OS_ISC
256 # define NO_VFORK
257 # endif
258 # ifdef linux
259 # define OSMINOR "OS=LINUX"
260 # define OS_LINUX
261 # endif
262 # ifdef __Lynx__
263 # define OSMINOR "OS=LYNX"
264 # define OS_LYNX
265 # define NO_VFORK
266 # define unix
267 # endif
268 # ifdef __MACHTEN__
269 # define OSMINOR "OS=MACHTEN"
270 # define OS_MACHTEN
271 # endif
272 # ifdef mpeix
273 # define unix
274 # define OSMINOR "OS=MPEIX"
275 # define OS_MPEIX
276 # define NO_VFORK
277 # endif
278 # ifdef __MVS__
279 # define unix
280 # define OSMINOR "OS=MVS"
281 # define OS_MVS
282 # endif
283 # ifdef _ATT4
284 # define OSMINOR "OS=NCR"
285 # define OS_NCR
286 # endif
287 # ifdef __NetBSD__
288 # define unix
289 # define OSMINOR "OS=NETBSD"
290 # define OS_NETBSD
291 # define NO_VFORK
292 # endif
293 # ifdef __QNX__
294 # ifdef __QNXNTO__
295 # define OSMINOR "OS=QNXNTO"
296 # define OS_QNXNTO
297 # else
298 # define unix
299 # define OSMINOR "OS=QNX"
300 # define OS_QNX
301 # define NO_VFORK
302 # define MAXLINE 996
303 # endif
304 # endif
305 # ifdef NeXT
306 # ifdef __APPLE__
307 # define OSMINOR "OS=RHAPSODY"
308 # define OS_RHAPSODY
309 # else
310 # define OSMINOR "OS=NEXT"
311 # define OS_NEXT
312 # endif
313 # endif
314 # ifdef __APPLE__
315 # define unix
316 # define OSMINOR "OS=MACOSX"
317 # define OS_MACOSX
318 # endif
319 # ifdef __osf__
320 # define OSMINOR "OS=OSF"
321 # define OS_OSF
322 # endif
323 # ifdef _SEQUENT_
324 # define OSMINOR "OS=PTX"
325 # define OS_PTX
326 # endif
327 # ifdef M_XENIX
328 # define OSMINOR "OS=SCO"
329 # define OS_SCO
330 # define NO_VFORK
331 # endif
332 # ifdef sinix
333 # define unix
334 # define OSMINOR "OS=SINIX"
335 # define OS_SINIX
336 # endif
337 # ifdef sun
338 # if defined(__svr4__) || defined(__SVR4)
339 # define OSMINOR "OS=SOLARIS"
340 # define OS_SOLARIS
341 # else
342 # define OSMINOR "OS=SUNOS"
343 # define OS_SUNOS
344 # endif
345 # endif
346 # ifdef ultrix
347 # define OSMINOR "OS=ULTRIX"
348 # define OS_ULTRIX
349 # endif
350 # ifdef _UNICOS
351 # define OSMINOR "OS=UNICOS"
352 # define OS_UNICOS
353 # endif
354 # if defined(__USLC__) && !defined(M_XENIX)
355 # define OSMINOR "OS=UNIXWARE"
356 # define OS_UNIXWARE
357 # endif
358 # ifndef OSMINOR
359 # define OSMINOR "OS=UNKNOWN"
360 # endif
361 
362 /* All the UNIX includes */
363 
364 # include <sys/types.h>
365 # include <sys/stat.h>
366 
367 # ifndef OS_MPEIX
368 # include <sys/file.h>
369 # endif
370 
371 # include <fcntl.h>
372 # include <stdio.h>
373 # include <ctype.h>
374 # include <signal.h>
375 # include <string.h>
376 # include <time.h>
377 
378 # ifndef OS_QNX
379 # include <memory.h>
380 # endif
381 
382 # ifndef OS_ULTRIX
383 # include <stdlib.h>
384 # endif
385 
386 # if !defined(OS_BSDI) && \
387      !defined(OS_FREEBSD) && \
388      !defined(OS_NEXT) && \
389      !defined(OS_MACHTEN) && \
390      !defined(OS_MACOSX) && \
391      !defined(OS_RHAPSODY) && \
392      !defined(OS_MVS)
393 # include <malloc.h>
394 # endif
395 
396 # endif
397 
398 /*
399  * OSPLAT definitions - suppressed when it's a one-of-a-kind
400  */
401 
402 # if defined( _M_PPC ) || \
403      defined( PPC ) || \
404      defined( ppc ) || \
405      defined( __powerpc__ ) || \
406      defined( __POWERPC__ ) || \
407      defined( __ppc__ )
408 # define OSPLAT "OSPLAT=PPC"
409 # endif
410 
411 # if defined( _ALPHA_ ) || \
412      defined( __alpha__ )
413 # define OSPLAT "OSPLAT=AXP"
414 # endif
415 
416 # if defined( _i386_ ) || \
417      defined( __i386__ ) || \
418      defined( _M_IX86 )
419 # if !defined( OS_FREEBSD ) && \
420      !defined( OS_OS2 ) && \
421      !defined( OS_AS400 )
422 # define OSPLAT "OSPLAT=X86"
423 # endif
424 # endif
425 
426 # ifdef __sparc__
427 # if !defined( OS_SUNOS )
428 # define OSPLAT "OSPLAT=SPARC"
429 # endif
430 # endif
431 
432 # ifdef __mips__
433 # if !defined( OS_SGI )
434 # define OSPLAT "OSPLAT=MIPS"
435 # endif
436 # endif
437 
438 # ifdef __arm__
439 # define OSPLAT "OSPLAT=ARM"
440 # endif
441 
442 # if defined( __ia64__ ) || \
443      defined( __IA64__ ) || \
444      defined( _M_IA64 )
445 # define OSPLAT "OSPLAT=IA64"
446 # endif
447 
448 # ifdef __s390__
449 # define OSPLAT "OSPLAT=390"
450 # endif
451 
452 # ifndef OSPLAT
453 # define OSPLAT ""
454 # endif
455 
456 /*
457  * Jam implementation misc.
458  */
459 
460 # ifndef MAXLINE
461 # define MAXLINE 10240	/* longest 'together' actions' */
462 # endif
463 
464 # ifndef EXITOK
465 # define EXITOK 0
466 # define EXITBAD 1
467 # endif
468 
469 # ifndef SPLITPATH
470 # define SPLITPATH ':'
471 # endif
472 
473 /* You probably don't need to muck with these. */
474 
475 # define MAXSYM	1024	/* longest symbol in the environment */
476 # define MAXJPATH 1024	/* longest filename */
477 
478 # define MAXJOBS 64	/* silently enforce -j limit */
479 # define MAXARGC 32	/* words in $(JAMSHELL) */
480 
481 /* Jam private definitions below. */
482 
483 # define DEBUG_MAX	15
484 
485 struct globs {
486 	int	noexec;
487 	int	jobs;
488 	int	quitquick;
489 	int	newestfirst;		/* build newest sources first */
490 	char	debug[DEBUG_MAX];
491 	FILE	*cmdout;		/* print cmds, not run them */
492 } ;
493 
494 extern struct globs globs;
495 
496 # define DEBUG_MAKE	( globs.debug[ 1 ] )	/* -da show actions when executed */
497 # define DEBUG_MAKEPROG	( globs.debug[ 3 ] )	/* -dm show progress of make0 */
498 
499 # define DEBUG_EXECCMD	( globs.debug[ 4 ] )	/* show execcmds()'s work */
500 
501 # define DEBUG_COMPILE	( globs.debug[ 5 ] )	/* show rule invocations */
502 
503 # define DEBUG_HEADER	( globs.debug[ 6 ] )	/* show result of header scan */
504 # define DEBUG_BINDSCAN	( globs.debug[ 6 ] )	/* show result of dir scan */
505 # define DEBUG_SEARCH	( globs.debug[ 6 ] )	/* show attempts at binding */
506 
507 # define DEBUG_VARSET	( globs.debug[ 7 ] )	/* show variable settings */
508 # define DEBUG_VARGET	( globs.debug[ 8 ] )	/* show variable fetches */
509 # define DEBUG_VAREXP	( globs.debug[ 8 ] )	/* show variable expansions */
510 # define DEBUG_IF	( globs.debug[ 8 ] )	/* show 'if' calculations */
511 # define DEBUG_LISTS	( globs.debug[ 9 ] )	/* show list manipulation */
512 # define DEBUG_SCAN	( globs.debug[ 9 ] )	/* show scanner tokens */
513 # define DEBUG_MEM	( globs.debug[ 9 ] )	/* show memory use */
514 
515 # define DEBUG_MAKEQ	( globs.debug[ 11 ] )	/* -da show even quiet actions */
516 # define DEBUG_EXEC	( globs.debug[ 12 ] )	/* -dx show text of actions */
517 # define DEBUG_DEPENDS	( globs.debug[ 13 ] )	/* -dd show dependency graph */
518 # define DEBUG_CAUSES	( globs.debug[ 14 ] )	/* -dc show dependency graph */
519 
520