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 * 06/03/03 (seiwald) - OpenBSD porting from Michael Champigny. 40 * 05/06/04 (seiwald) - OSPLAT amd64. 41 * 06/23/04 (seiwald) - Nonstop unix porting from Kim Hae-Joo. 42 * 09/02/04 (tony) - Zeta porting 43 * 05/18/06 (seiwald) - OSPLAT to X86_64 for non-Windows. 44 * 07/15/10 (noahf) - increase generic execcmd buffer to 20kib. 45 * 11/22/13 (brett) - Darwin 9.0 support. 46 */ 47 48 /* 49 * VMS, OPENVMS 50 */ 51 52 # ifdef VMS 53 54 # define unlink remove 55 56 # include <types.h> 57 # include <file.h> 58 # include <stat.h> 59 # include <stdio.h> 60 # include <ctype.h> 61 # include <stdlib.h> 62 # include <signal.h> 63 # include <string.h> 64 # include <time.h> 65 # include <unixlib.h> 66 67 # define OSMINOR "OS=VMS" 68 # define OSMAJOR "VMS=true" 69 # define OS_VMS 70 # define MAXLINE 2048 /* longest execcmd() */ 71 # define SPLITPATH ',' 72 # define EXITOK 1 73 # define EXITBAD 0 74 # define DOWNSHIFT_PATHS 75 76 /* Do any of these work? */ 77 # if defined( VAX ) || defined( __VAX ) || defined( vax ) 78 # define OSPLAT "OSPLAT=VAX" 79 # endif 80 81 # endif 82 83 /* 84 * Windows NT 85 */ 86 87 # ifdef NT 88 89 # include <fcntl.h> 90 # include <stdlib.h> 91 # include <stdio.h> 92 # include <ctype.h> 93 # include <malloc.h> 94 # include <memory.h> 95 # include <signal.h> 96 # include <string.h> 97 # include <time.h> 98 99 # define OSMAJOR "NT=true" 100 # define OSMINOR "OS=NT" 101 # define OS_NT 102 # define SPLITPATH ';' 103 # define MAXLINE 996 /* longest execcmd() */ 104 # define USE_EXECUNIX 105 # define USE_PATHUNIX 106 # define PATH_DELIM '\\' 107 # define DOWNSHIFT_PATHS 108 109 # endif 110 111 /* 112 * Windows MingW32 113 */ 114 115 # ifdef MINGW 116 117 # include <fcntl.h> 118 # include <stdlib.h> 119 # include <stdio.h> 120 # include <ctype.h> 121 # include <malloc.h> 122 # include <memory.h> 123 # include <signal.h> 124 # include <string.h> 125 # include <time.h> 126 127 # define OSMAJOR "MINGW=true" 128 # define OSMINOR "OS=MINGW" 129 # define OS_NT 130 # define SPLITPATH ';' 131 # define MAXLINE 996 /* longest execcmd() */ 132 # define USE_EXECUNIX 133 # define USE_PATHUNIX 134 # define PATH_DELIM '\\' 135 # define DOWNSHIFT_PATHS 136 137 # endif 138 139 /* 140 * AS400 - mostly unix-like superficially. 141 */ 142 143 # ifdef AS400 144 145 # include <sys/types.h> 146 # include <sys/stat.h> 147 # include <sys/wait.h> 148 # include <fcntl.h> 149 # include <stdio.h> 150 # include <ctype.h> 151 # include <signal.h> 152 # include <string.h> 153 # include <time.h> 154 # include <memory.h> 155 # include <stdlib.h> 156 157 # define OSMAJOR "AS400=true" 158 # define OSMINOR "OS=AS400" 159 # define OS_AS400 160 # define USE_FILEUNIX 161 # define USE_PATHUNIX 162 # define PATH_DELIM '/' 163 164 # endif 165 166 /* 167 * OS2 168 */ 169 170 # ifdef __OS2__ 171 172 # include <fcntl.h> 173 # include <stdlib.h> 174 # include <stdio.h> 175 # include <ctype.h> 176 # include <malloc.h> 177 # include <signal.h> 178 # include <string.h> 179 # include <time.h> 180 181 # define OSMAJOR "OS2=true" 182 # define OSMINOR "OS=OS2" 183 # define OS_OS2 184 # define SPLITPATH ';' 185 # define MAXLINE 996 /* longest execcmd() */ 186 # define USE_EXECUNIX 187 # define USE_PATHUNIX 188 # define PATH_DELIM '\\' 189 # define DOWNSHIFT_PATHS 190 191 # endif 192 193 /* 194 * Macintosh MPW 195 */ 196 197 # ifdef macintosh 198 199 # include <time.h> 200 # include <stdlib.h> 201 # include <string.h> 202 # include <stdio.h> 203 # include <ctype.h> 204 205 # define OSMAJOR "MAC=true" 206 # define OSMINOR "OS=MAC" 207 # define OS_MAC 208 # define SPLITPATH ',' 209 # define DOWNSHIFT_PATHS 210 211 # endif 212 213 /* 214 * God fearing UNIX 215 */ 216 217 # ifndef OSMINOR 218 219 # define OSMAJOR "UNIX=true" 220 # define USE_EXECUNIX 221 # define USE_FILEUNIX 222 # define USE_PATHUNIX 223 # define PATH_DELIM '/' 224 225 # ifdef _AIX 226 # define unix 227 # define OSMINOR "OS=AIX" 228 # define OS_AIX 229 # define NO_VFORK 230 # endif 231 # ifdef AMIGA 232 # define OSMINOR "OS=AMIGA" 233 # define OS_AMIGA 234 # endif 235 # ifdef __BEOS__ 236 # include <BeBuild.h> 237 # define unix 238 # ifdef B_ZETA_VERSION 239 # define OSMINOR "OS=ZETA" 240 # define OS_ZETA 241 # define NO_VFORK 242 # else 243 # define OSMINOR "OS=BEOS" 244 # define OS_BEOS 245 # define NO_VFORK 246 # endif 247 # endif 248 # ifdef __bsdi__ 249 # define OSMINOR "OS=BSDI" 250 # define OS_BSDI 251 # endif 252 # if defined (COHERENT) && defined (_I386) 253 # define OSMINOR "OS=COHERENT" 254 # define OS_COHERENT 255 # define NO_VFORK 256 # endif 257 # ifdef __cygwin__ 258 # define OSMINOR "OS=CYGWIN" 259 # define OS_CYGWIN 260 # endif 261 # if defined __FreeBSD__ || defined __DragonFly__ 262 # include <sys/wait.h> 263 # include <unistd.h> 264 # define OSMINOR "OS=FREEBSD" 265 # define OS_FREEBSD 266 # endif 267 # ifdef __DGUX__ 268 # define OSMINOR "OS=DGUX" 269 # define OS_DGUX 270 # endif 271 # ifdef __hpux 272 # define OSMINOR "OS=HPUX" 273 # define OS_HPUX 274 # endif 275 # ifdef __OPENNT 276 # define unix 277 # define OSMINOR "OS=INTERIX" 278 # define OS_INTERIX 279 # define NO_VFORK 280 # endif 281 # ifdef __sgi 282 # define OSMINOR "OS=IRIX" 283 # define OS_IRIX 284 # define NO_VFORK 285 # endif 286 # ifdef __ISC 287 # define OSMINOR "OS=ISC" 288 # define OS_ISC 289 # define NO_VFORK 290 # endif 291 # ifdef linux 292 # define OSMINOR "OS=LINUX" 293 # define OS_LINUX 294 # endif 295 # ifdef __Lynx__ 296 # define OSMINOR "OS=LYNX" 297 # define OS_LYNX 298 # define NO_VFORK 299 # define unix 300 # endif 301 # ifdef __MACHTEN__ 302 # define OSMINOR "OS=MACHTEN" 303 # define OS_MACHTEN 304 # endif 305 # ifdef mpeix 306 # define unix 307 # define OSMINOR "OS=MPEIX" 308 # define OS_MPEIX 309 # define NO_VFORK 310 # endif 311 # ifdef __MVS__ 312 # define unix 313 # define OSMINOR "OS=MVS" 314 # define OS_MVS 315 # endif 316 # ifdef _ATT4 317 # define OSMINOR "OS=NCR" 318 # define OS_NCR 319 # endif 320 # ifdef __NetBSD__ 321 # define unix 322 # define OSMINOR "OS=NETBSD" 323 # define OS_NETBSD 324 # define NO_VFORK 325 # endif 326 # ifdef __OpenBSD__ 327 # define unix 328 # define OSMINOR "OS=OPENBSD" 329 # define OS_OPENBSD 330 # endif 331 # ifdef __QNX__ 332 # ifdef __QNXNTO__ 333 # define OSMINOR "OS=QNXNTO" 334 # define OS_QNXNTO 335 # else 336 # define unix 337 # define OSMINOR "OS=QNX" 338 # define OS_QNX 339 # define NO_VFORK 340 # define MAXLINE 996 341 # endif 342 # endif 343 # ifdef NeXT 344 # ifdef __APPLE__ 345 # define OSMINOR "OS=RHAPSODY" 346 # define OS_RHAPSODY 347 # else 348 # define OSMINOR "OS=NEXT" 349 # define OS_NEXT 350 # endif 351 # endif 352 # ifdef __APPLE__ 353 # ifdef __DARWIN__ 354 # define unix 355 # define OSMINOR "OS=DARWIN" 356 # define OS_DARWIN 357 # else 358 # define unix 359 # define OSMINOR "OS=MACOSX" 360 # define OS_MACOSX 361 # endif 362 # endif 363 # ifdef __osf__ 364 # define OSMINOR "OS=OSF" 365 # define OS_OSF 366 # endif 367 # ifdef _SEQUENT_ 368 # define OSMINOR "OS=PTX" 369 # define OS_PTX 370 # endif 371 # ifdef M_XENIX 372 # define OSMINOR "OS=SCO" 373 # define OS_SCO 374 # define NO_VFORK 375 # endif 376 # ifdef sinix 377 # define unix 378 # define OSMINOR "OS=SINIX" 379 # define OS_SINIX 380 # endif 381 # ifdef sun 382 # if defined(__svr4__) || defined(__SVR4) 383 # define OSMINOR "OS=SOLARIS" 384 # define OS_SOLARIS 385 # else 386 # define OSMINOR "OS=SUNOS" 387 # define OS_SUNOS 388 # endif 389 # endif 390 # ifdef ultrix 391 # define OSMINOR "OS=ULTRIX" 392 # define OS_ULTRIX 393 # endif 394 # ifdef _UNICOS 395 # define OSMINOR "OS=UNICOS" 396 # define OS_UNICOS 397 # endif 398 # if defined(__USLC__) && !defined(M_XENIX) 399 # define OSMINOR "OS=UNIXWARE" 400 # define OS_UNIXWARE 401 # endif 402 # ifdef __nonstopux 403 # define OSMINOR "OS=NONSTOP" 404 # define OS_NONSTOP 405 # endif 406 # ifndef OSMINOR 407 # define OSMINOR "OS=UNKNOWN" 408 # endif 409 410 /* All the UNIX includes */ 411 412 # include <sys/types.h> 413 # include <sys/stat.h> 414 415 # ifdef OS_HPUX 416 # include <unistd.h> 417 # endif 418 419 # ifndef OS_MPEIX 420 # include <sys/file.h> 421 # endif 422 423 # include <fcntl.h> 424 # include <stdio.h> 425 # include <ctype.h> 426 # include <signal.h> 427 # include <string.h> 428 # include <time.h> 429 430 # ifndef OS_QNX 431 # include <memory.h> 432 # endif 433 434 # ifndef OS_ULTRIX 435 # include <stdlib.h> 436 # endif 437 438 # if !defined(OS_BSDI) && \ 439 !defined(OS_FREEBSD) && \ 440 !defined(OS_NEXT) && \ 441 !defined(OS_MACHTEN) && \ 442 !defined(OS_MACOSX) && \ 443 !defined(OS_DARWIN) && \ 444 !defined(OS_RHAPSODY) && \ 445 !defined(OS_MVS) && \ 446 !defined(OS_OPENBSD) 447 # include <malloc.h> 448 # endif 449 450 # endif 451 452 /* 453 * OSPLAT definitions - suppressed when it's a one-of-a-kind 454 */ 455 456 # if defined( _M_PPC ) || \ 457 defined( PPC ) || \ 458 defined( ppc ) || \ 459 defined( __powerpc__ ) || \ 460 defined( __POWERPC__ ) || \ 461 defined( __ppc__ ) 462 # define OSPLAT "OSPLAT=PPC" 463 # endif 464 465 # if defined( _ALPHA_ ) || \ 466 defined( __alpha__ ) 467 # define OSPLAT "OSPLAT=AXP" 468 # endif 469 470 # if defined( _i386_ ) || \ 471 defined( __i386__ ) || \ 472 defined( _M_IX86 ) 473 # define OSPLAT "OSPLAT=X86" 474 # endif 475 476 # if defined (__sparc__) 477 # if defined( __sparcv9 ) || \ 478 defined( __sparc64__ ) 479 # define OSPLAT "OSPLAT=SPARC64" 480 # else 481 # if !defined( OS_SUNOS ) 482 # define OSPLAT "OSPLAT=SPARC" 483 # endif 484 # endif 485 # endif 486 487 # ifdef __mips__ 488 # if !defined( OS_SGI ) 489 # define OSPLAT "OSPLAT=MIPS" 490 # endif 491 # endif 492 493 # ifdef __arm__ 494 # define OSPLAT "OSPLAT=ARM" 495 # endif 496 497 # if defined( __ia64__ ) || \ 498 defined( __IA64__ ) || \ 499 defined( _M_IA64 ) 500 # define OSPLAT "OSPLAT=IA64" 501 # endif 502 503 # ifdef __s390x__ 504 # define OSPLAT "OSPLAT=s390x" 505 # else 506 # ifdef __s390__ 507 # define OSPLAT "OSPLAT=390" 508 # endif 509 # endif 510 511 # if defined( __amd64__ ) || \ 512 defined( __AMD64__ ) || \ 513 defined( _M_AMD64 ) 514 # ifdef OS_NT 515 # define OSPLAT "OSPLAT=X64" /* bless bill */ 516 # else 517 # define OSPLAT "OSPLAT=X86_64" /* curse linus */ 518 # endif 519 # endif 520 521 # ifndef OSPLAT 522 # define OSPLAT "" 523 # endif 524 525 /* 526 * Jam implementation misc. 527 */ 528 529 # ifndef MAXLINE 530 # define MAXLINE 20480 /* longest execcmd() */ 531 # endif 532 533 # ifndef EXITOK 534 # define EXITOK 0 535 # define EXITBAD 1 536 # endif 537 538 # ifndef SPLITPATH 539 # define SPLITPATH ':' 540 # endif 541 542 /* You probably don't need to muck with these. */ 543 544 # define MAXSYM 1024 /* longest symbol in the environment */ 545 # define MAXJPATH 1024 /* longest filename */ 546 547 # define MAXJOBS 64 /* silently enforce -j limit */ 548 # define MAXARGC 32 /* words in $(JAMSHELL) */ 549 550 /* Jam private definitions below. */ 551 552 # define DEBUG_MAX 15 553 554 struct globs { 555 int noexec; 556 int jobs; 557 int quitquick; 558 int newestfirst; /* build newest sources first */ 559 char debug[DEBUG_MAX]; 560 FILE *cmdout; /* print cmds, not run them */ 561 } ; 562 563 extern struct globs globs; 564 565 # define DEBUG_MAKE ( globs.debug[ 1 ] ) /* -da show executed actions */ 566 # define DEBUG_MAKEPROG ( globs.debug[ 3 ] ) /* -dm show progress of make0 */ 567 568 # define DEBUG_EXECCMD ( globs.debug[ 4 ] ) /* show execcmds()'s work */ 569 570 # define DEBUG_COMPILE ( globs.debug[ 5 ] ) /* -dr show rule invocations */ 571 572 # define DEBUG_HEADER ( globs.debug[ 6 ] ) /* show result of header scan */ 573 # define DEBUG_BINDSCAN ( globs.debug[ 6 ] ) /* show result of dir scan */ 574 # define DEBUG_SEARCH ( globs.debug[ 6 ] ) /* show attempts at binding */ 575 576 # define DEBUG_VARSET ( globs.debug[ 7 ] ) /* show variable settings */ 577 # define DEBUG_VARGET ( globs.debug[ 8 ] ) /* show variable fetches */ 578 # define DEBUG_VAREXP ( globs.debug[ 8 ] ) /* show variable expansions */ 579 # define DEBUG_IF ( globs.debug[ 8 ] ) /* show 'if' calculations */ 580 # define DEBUG_LISTS ( globs.debug[ 9 ] ) /* show list manipulation */ 581 # define DEBUG_SCAN ( globs.debug[ 9 ] ) /* show scanner tokens */ 582 # define DEBUG_MEM ( globs.debug[ 9 ] ) /* show memory use */ 583 584 # define DEBUG_MAKEQ ( globs.debug[ 11 ] ) /* -da show quiet actions */ 585 # define DEBUG_EXEC ( globs.debug[ 12 ] ) /* -dx show text of actions */ 586 # define DEBUG_DEPENDS ( globs.debug[ 13 ] ) /* -dd show dependency graph */ 587 # define DEBUG_CAUSES ( globs.debug[ 14 ] ) /* -dc show dependency graph */ 588