1 /*
2  * Copyright 1993, 1995 Christopher Seiwald.
3  *
4  * This file is part of Jam - see jam.c for Copyright information.
5  */
6 
7 /* This file is ALSO:
8  * Copyright 2001-2004 David Abrahams.
9  * Distributed under the Boost Software License, Version 1.0.
10  * (See accompanying file LICENSE_1_0.txt or copy at
11  * http://www.boost.org/LICENSE_1_0.txt)
12  */
13 
14 /*
15  * jam.h - includes and globals for jam
16  */
17 
18 #ifndef JAM_H_VP_2003_08_01
19 #define JAM_H_VP_2003_08_01
20 
21 #include "config.h"
22 
23 #ifdef HAVE_PYTHON
24 #include <Python.h>
25 #endif
26 
27 /* Assume popen support is available unless known otherwise. */
28 #define HAVE_POPEN 1
29 
30 /*
31  * VMS, OPENVMS
32  */
33 
34 #ifdef VMS
35 
36 #include <types.h>
37 #include <file.h>
38 #include <stat.h>
39 #include <stdio.h>
40 #include <ctype.h>
41 #include <stdlib.h>
42 #include <signal.h>
43 #include <string.h>
44 #include <time.h>
45 #include <unistd.h>
46 #include <unixlib.h>
47 
48 #define OSMINOR "OS=VMS"
49 #define OSMAJOR "VMS=true"
50 #define OS_VMS
51 #define MAXLINE 1024 /* longest 'together' actions */
52 #define PATH_DELIM '/'  /* use CRTL POSIX-style handling */
53 #define SPLITPATH ','
54 #define EXITOK EXIT_SUCCESS
55 #define EXITBAD EXIT_FAILURE
56 #define DOWNSHIFT_PATHS
57 
58 /* This may be inaccurate. */
59 #ifndef __DECC
60 #define OSPLAT "OSPLAT=VAX"
61 #endif
62 
63 #define glob jam_glob  /* use jam's glob, not CRTL's */
64 
65 #endif
66 
67 /*
68  * Windows NT
69  */
70 
71 #ifdef NT
72 
73 #include <ctype.h>
74 #include <fcntl.h>
75 #include <malloc.h>
76 #ifndef __MWERKS__
77     #include <memory.h>
78 #endif
79 #include <stdio.h>
80 #include <stdlib.h>
81 #include <signal.h>
82 #include <string.h>
83 #include <time.h>
84 
85 #define OSMAJOR "NT=true"
86 #define OSMINOR "OS=NT"
87 #define OS_NT
88 #define SPLITPATH ';'
89 #define MAXLINE (undefined__see_execnt_c)  /* max chars per command line */
90 #define USE_EXECNT
91 #define PATH_DELIM '\\'
92 
93 /* AS400 cross-compile from NT. */
94 
95 #ifdef AS400
96     #undef OSMINOR
97     #undef OSMAJOR
98     #define OSMAJOR "AS400=true"
99     #define OSMINOR "OS=AS400"
100     #define OS_AS400
101 #endif
102 
103 /* Metrowerks Standard Library on Windows. */
104 
105 #ifdef __MSL__
106     #undef HAVE_POPEN
107 #endif
108 
109 #endif  /* #ifdef NT */
110 
111 
112 /*
113  * Windows MingW32
114  */
115 
116 #ifdef MINGW
117 
118 #include <fcntl.h>
119 #include <stdlib.h>
120 #include <stdio.h>
121 #include <ctype.h>
122 #include <malloc.h>
123 #include <memory.h>
124 #include <signal.h>
125 #include <string.h>
126 #include <time.h>
127 
128 #define OSMAJOR "MINGW=true"
129 #define OSMINOR "OS=MINGW"
130 #define OS_NT
131 #define SPLITPATH ';'
132 #define MAXLINE 996  /* max chars per command line */
133 #define USE_EXECUNIX
134 #define PATH_DELIM '\\'
135 
136 #endif  /* #ifdef MINGW */
137 
138 
139 /*
140  * God fearing UNIX.
141  */
142 
143 #ifndef OSMINOR
144 
145 #define OSMAJOR "UNIX=true"
146 #define USE_EXECUNIX
147 #define USE_FILEUNIX
148 #define PATH_DELIM '/'
149 
150 #ifdef _AIX
151     #define unix
152     #define MAXLINE 23552  /* 24k - 1k, max chars per command line */
153     #define OSMINOR "OS=AIX"
154     #define OS_AIX
155     #define NO_VFORK
156 #endif
157 #ifdef AMIGA
158     #define OSMINOR "OS=AMIGA"
159     #define OS_AMIGA
160 #endif
161 #ifdef __BEOS__
162     #define unix
163     #define OSMINOR "OS=BEOS"
164     #define OS_BEOS
165     #define NO_VFORK
166 #endif
167 #ifdef __bsdi__
168     #define OSMINOR "OS=BSDI"
169     #define OS_BSDI
170 #endif
171 #if defined (COHERENT) && defined (_I386)
172     #define OSMINOR "OS=COHERENT"
173     #define OS_COHERENT
174     #define NO_VFORK
175 #endif
176 #if defined(__cygwin__) || defined(__CYGWIN__)
177     #define OSMINOR "OS=CYGWIN"
178     #define OS_CYGWIN
179 #endif
180 #if defined(__FreeBSD__) && !defined(__DragonFly__)
181     #define OSMINOR "OS=FREEBSD"
182     #define OS_FREEBSD
183 #endif
184 #ifdef __DragonFly__
185     #define OSMINOR "OS=DRAGONFLYBSD"
186     #define OS_DRAGONFLYBSD
187 #endif
188 #ifdef __DGUX__
189     #define OSMINOR "OS=DGUX"
190     #define OS_DGUX
191 #endif
192 #ifdef __hpux
193     #define OSMINOR "OS=HPUX"
194     #define OS_HPUX
195 #endif
196 #ifdef __HAIKU__
197     #define unix
198     #define OSMINOR "OS=HAIKU"
199     #define OS_HAIKU
200 #endif
201 #ifdef __OPENNT
202     #define unix
203     #define OSMINOR "OS=INTERIX"
204     #define OS_INTERIX
205     #define NO_VFORK
206 #endif
207 #ifdef __sgi
208     #define OSMINOR "OS=IRIX"
209     #define OS_IRIX
210     #define NO_VFORK
211 #endif
212 #ifdef __ISC
213     #define OSMINOR "OS=ISC"
214     #define OS_ISC
215     #define NO_VFORK
216 #endif
217 #if defined(linux) || defined(__linux) || \
218     defined(__linux__) || defined(__gnu_linux__)
219     #define OSMINOR "OS=LINUX"
220     #define OS_LINUX
221 #endif
222 #ifdef __Lynx__
223     #define OSMINOR "OS=LYNX"
224     #define OS_LYNX
225     #define NO_VFORK
226     #define unix
227 #endif
228 #ifdef __MACHTEN__
229     #define OSMINOR "OS=MACHTEN"
230     #define OS_MACHTEN
231 #endif
232 #ifdef mpeix
233     #define unix
234     #define OSMINOR "OS=MPEIX"
235     #define OS_MPEIX
236     #define NO_VFORK
237 #endif
238 #ifdef __MVS__
239     #define unix
240     #define OSMINOR "OS=MVS"
241     #define OS_MVS
242 #endif
243 #ifdef _ATT4
244     #define OSMINOR "OS=NCR"
245     #define OS_NCR
246 #endif
247 #ifdef __NetBSD__
248     #define unix
249     #define OSMINOR "OS=NETBSD"
250     #define OS_NETBSD
251     #define NO_VFORK
252 #endif
253 #ifdef __QNX__
254     #define unix
255     #ifdef __QNXNTO__
256         #define OSMINOR "OS=QNXNTO"
257         #define OS_QNXNTO
258     #else
259         #define OSMINOR "OS=QNX"
260         #define OS_QNX
261         #define NO_VFORK
262         #define MAXLINE 996  /* max chars per command line */
263     #endif
264 #endif
265 #ifdef NeXT
266     #ifdef __APPLE__
267         #define OSMINOR "OS=RHAPSODY"
268         #define OS_RHAPSODY
269     #else
270         #define OSMINOR "OS=NEXT"
271         #define OS_NEXT
272     #endif
273 #endif
274 #ifdef __APPLE__
275     #define unix
276     #define OSMINOR "OS=MACOSX"
277     #define OS_MACOSX
278 #endif
279 #ifdef __osf__
280     #ifndef unix
281         #define unix
282     #endif
283     #define OSMINOR "OS=OSF"
284     #define OS_OSF
285 #endif
286 #ifdef _SEQUENT_
287     #define OSMINOR "OS=PTX"
288     #define OS_PTX
289 #endif
290 #ifdef M_XENIX
291     #define OSMINOR "OS=SCO"
292     #define OS_SCO
293     #define NO_VFORK
294 #endif
295 #ifdef sinix
296     #define unix
297     #define OSMINOR "OS=SINIX"
298     #define OS_SINIX
299 #endif
300 #ifdef sun
301     #if defined(__svr4__) || defined(__SVR4)
302         #define OSMINOR "OS=SOLARIS"
303         #define OS_SOLARIS
304     #else
305         #define OSMINOR "OS=SUNOS"
306         #define OS_SUNOS
307     #endif
308 #endif
309 #ifdef ultrix
310     #define OSMINOR "OS=ULTRIX"
311     #define OS_ULTRIX
312 #endif
313 #ifdef _UNICOS
314     #define OSMINOR "OS=UNICOS"
315     #define OS_UNICOS
316 #endif
317 #if defined(__USLC__) && !defined(M_XENIX)
318     #define OSMINOR "OS=UNIXWARE"
319     #define OS_UNIXWARE
320 #endif
321 #ifdef __OpenBSD__
322     #define OSMINOR "OS=OPENBSD"
323     #define OS_OPENBSD
324     #define unix
325 #endif
326 #if defined (__FreeBSD_kernel__) && !defined(__FreeBSD__)
327     #define OSMINOR "OS=KFREEBSD"
328     #define OS_KFREEBSD
329 #endif
330 #ifndef OSMINOR
331     #define OSMINOR "OS=UNKNOWN"
332 #endif
333 
334 /* All the UNIX includes */
335 
336 #include <sys/types.h>
337 
338 #ifndef OS_MPEIX
339     #include <sys/file.h>
340 #endif
341 
342 #include <fcntl.h>
343 #include <stdio.h>
344 #include <ctype.h>
345 #include <signal.h>
346 #include <string.h>
347 #include <time.h>
348 #include <unistd.h>
349 
350 #ifndef OS_QNX
351     #include <memory.h>
352 #endif
353 
354 #ifndef OS_ULTRIX
355     #include <stdlib.h>
356 #endif
357 
358 #if !defined( OS_BSDI         ) && \
359     !defined( OS_FREEBSD      ) && \
360     !defined( OS_DRAGONFLYBSD ) && \
361     !defined( OS_NEXT         ) && \
362     !defined( OS_MACHTEN      ) && \
363     !defined( OS_MACOSX       ) && \
364     !defined( OS_RHAPSODY     ) && \
365     !defined( OS_MVS          ) && \
366     !defined( OS_OPENBSD      )
367     #include <malloc.h>
368 #endif
369 
370 #endif  /* #ifndef OSMINOR */
371 
372 
373 /*
374  * OSPLAT definitions - suppressed when it is a one-of-a-kind.
375  */
376 
377 #if defined( _M_PPC      ) || \
378     defined( PPC         ) || \
379     defined( ppc         ) || \
380     defined( __powerpc__ ) || \
381     defined( __ppc__     )
382     #define OSPLAT "OSPLAT=PPC"
383 #endif
384 
385 #if defined( _ALPHA_   ) || \
386     defined( __alpha__ )
387     #define OSPLAT "OSPLAT=AXP"
388 #endif
389 
390 #if defined( _i386_   ) || \
391     defined( __i386__ ) || \
392     defined( __i386   ) || \
393     defined( _M_IX86  )
394     #define OSPLAT "OSPLAT=X86"
395 #endif
396 
397 #if defined( __ia64__ ) || \
398     defined( __IA64__ ) || \
399     defined( __ia64   )
400     #define OSPLAT "OSPLAT=IA64"
401 #endif
402 
403 #if defined( __x86_64__ ) || \
404     defined( __amd64__  ) || \
405     defined( _M_AMD64   )
406     #define OSPLAT "OSPLAT=X86_64"
407 #endif
408 
409 #if defined( __sparc__ ) || \
410     defined( __sparc   )
411     #define OSPLAT "OSPLAT=SPARC"
412 #endif
413 
414 #ifdef __mips__
415     #define OSPLAT "OSPLAT=MIPS"
416 #endif
417 
418 #if defined( __arm__ ) || \
419     defined( __aarch64__ )
420     #define OSPLAT "OSPLAT=ARM"
421 #endif
422 
423 #ifdef __s390__
424     #define OSPLAT "OSPLAT=390"
425 #endif
426 
427 #ifdef __hppa
428     #define OSPLAT "OSPLAT=PARISC"
429 #endif
430 
431 #ifndef OSPLAT
432     #define OSPLAT ""
433 #endif
434 
435 
436 /*
437  * Jam implementation misc.
438  */
439 
440 #ifndef MAXLINE
441     #define MAXLINE 102400  /* max chars per command line */
442 #endif
443 
444 #ifndef EXITOK
445     #define EXITOK 0
446     #define EXITBAD 1
447 #endif
448 
449 #ifndef SPLITPATH
450     #define SPLITPATH ':'
451 #endif
452 
453 /* You probably do not need to muck with these. */
454 
455 #define MAXSYM   1024  /* longest symbol in the environment */
456 #define MAXJPATH 1024  /* longest filename */
457 
458 #define MAXARGC  32    /* words in $(JAMSHELL) */
459 
460 /* Jam private definitions below. */
461 
462 #define DEBUG_MAX  14
463 
464 
465 struct globs
466 {
467     int    noexec;
468     int    jobs;
469     int    quitquick;
470     int    newestfirst;         /* build newest sources first */
471     int    pipe_action;
472     char   debug[ DEBUG_MAX ];
473     FILE * out;                 /* mirror output here */
474     long   timeout;             /* number of seconds to limit actions to,
475                                  * default 0 for no limit.
476                                  */
477     int    dart;                /* output build and test results formatted for
478                                  * Dart
479                                  */
480     int    max_buf;             /* maximum amount of output saved from target
481                                  * (kb)
482                                  */
483 };
484 
485 extern struct globs globs;
486 
487 #define DEBUG_MAKE     ( globs.debug[ 1 ] )   /* show actions when executed */
488 #define DEBUG_MAKEQ    ( globs.debug[ 2 ] )   /* show even quiet actions */
489 #define DEBUG_EXEC     ( globs.debug[ 2 ] )   /* show text of actons */
490 #define DEBUG_MAKEPROG ( globs.debug[ 3 ] )   /* show make0 progress */
491 #define DEBUG_BIND     ( globs.debug[ 3 ] )   /* show when files bound */
492 
493 #define DEBUG_EXECCMD  ( globs.debug[ 4 ] )   /* show execcmds()'s work */
494 
495 #define DEBUG_COMPILE  ( globs.debug[ 5 ] )   /* show rule invocations */
496 
497 #define DEBUG_HEADER   ( globs.debug[ 6 ] )   /* show result of header scan */
498 #define DEBUG_BINDSCAN ( globs.debug[ 6 ] )   /* show result of dir scan */
499 #define DEBUG_SEARCH   ( globs.debug[ 6 ] )   /* show binding attempts */
500 
501 #define DEBUG_VARSET   ( globs.debug[ 7 ] )   /* show variable settings */
502 #define DEBUG_VARGET   ( globs.debug[ 8 ] )   /* show variable fetches */
503 #define DEBUG_VAREXP   ( globs.debug[ 8 ] )   /* show variable expansions */
504 #define DEBUG_IF       ( globs.debug[ 8 ] )   /* show 'if' calculations */
505 #define DEBUG_LISTS    ( globs.debug[ 9 ] )   /* show list manipulation */
506 #define DEBUG_SCAN     ( globs.debug[ 9 ] )   /* show scanner tokens */
507 #define DEBUG_MEM      ( globs.debug[ 9 ] )   /* show memory use */
508 
509 #define DEBUG_PROFILE  ( globs.debug[ 10 ] )  /* dump rule execution times */
510 #define DEBUG_PARSE    ( globs.debug[ 11 ] )  /* debug parsing */
511 #define DEBUG_GRAPH    ( globs.debug[ 12 ] )  /* debug dependencies */
512 #define DEBUG_FATE     ( globs.debug[ 13 ] )  /* show fate changes in make0() */
513 
514 /* Everyone gets the memory definitions. */
515 #include "mem.h"
516 
517 /* They also get the profile functions. */
518 #include "debug.h"
519 
520 #endif
521