23 * Use is subject to license terms.
24 */
25
26 /*
27 * main.cc
28 *
29 * make program main routine plus some helper routines
30 */
31
32 /*
33 * Included files
34 */
35 #if defined(TEAMWARE_MAKE_CMN)
36 # include <avo/intl.h>
37 #endif
38
39 #include <bsd/bsd.h> /* bsd_signal() */
40
41
42 #include <locale.h> /* setlocale() */
43 #include <mk/defs.h>
44 #include <mksdmsi18n/mksdmsi18n.h> /* libmksdmsi18n_init() */
45 #include <mksh/macro.h> /* getvar() */
46 #include <mksh/misc.h> /* getmem(), setup_char_semantics() */
47
48 #if defined(TEAMWARE_MAKE_CMN)
49 #endif
50
51 #include <pwd.h> /* getpwnam() */
52 #include <setjmp.h>
53 #include <signal.h>
54 #include <stdlib.h>
55 #include <sys/errno.h> /* ENOENT */
56 #include <sys/stat.h> /* fstat() */
57 #include <fcntl.h> /* open() */
58
59 # include <sys/systeminfo.h> /* sysinfo() */
60
61 #include <sys/types.h> /* stat() */
62 #include <sys/wait.h> /* wait() */
396 output_mode = txt1_mode;
397 } else {
398 dmake_value2 = prop2->body.macro.value;
399 if ((dmake_value2 == NULL) ||
400 (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("TXT1")))) {
401 output_mode = txt1_mode;
402 } else if (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("TXT2"))) {
403 output_mode = txt2_mode;
404 } else if (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("HTML1"))) {
405 output_mode = html1_mode;
406 } else {
407 warning(catgets(catd, 1, 352, "Unsupported value `%s' for DMAKE_OUTPUT_MODE after -x flag (ignored)"),
408 dmake_value2->string_mb);
409 }
410 }
411 /*
412 * Find the dmake_mode: parallel, or serial.
413 */
414 if ((!pmake_cap_r_specified) &&
415 (!pmake_machinesfile_specified)) {
416 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MODE"));
417 dmake_name2 = GETNAME(wcs_buffer, FIND_LENGTH);
418 prop2 = get_prop(dmake_name2->prop, macro_prop);
419 if (prop2 == NULL) {
420 /* DMAKE_MODE not defined, default to parallel mode */
421 dmake_mode_type = parallel_mode;
422 no_parallel = false;
423 } else {
424 dmake_value2 = prop2->body.macro.value;
425 if (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("parallel"))) {
426 dmake_mode_type = parallel_mode;
427 no_parallel = false;
428 } else if (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("serial"))) {
429 dmake_mode_type = serial_mode;
430 no_parallel = true;
431 } else {
432 fatal(catgets(catd, 1, 307, "Unknown dmake mode argument `%s' after -m flag"), dmake_value2->string_mb);
433 }
434 }
435
436 }
437
438 parallel_flag = true;
439 putenv(strdup(NOCATGETS("DMAKE_CHILD=TRUE")));
440
441 //
442 // If dmake is running with -t option, set dmake_mode_type to serial.
443 // This is done because doname() calls touch_command() that runs serially.
444 // If we do not do that, maketool will have problems.
445 //
446 if(touch) {
447 dmake_mode_type = serial_mode;
448 no_parallel = true;
449 }
450
451 /*
452 * Check whether stdout and stderr are physically same.
453 * This is in order to decide whether we need to redirect
454 * stderr separately from stdout.
455 * This check is performed only if __DMAKE_SEPARATE_STDERR
1346 case 'f': /* Read alternative makefile(s) */
1347 return 1;
1348 case 'g': /* Use alternative DMake group */
1349 if (invert_this) {
1350 dmake_group_specified = false;
1351 } else {
1352 dmake_group_specified = true;
1353 }
1354 return 4;
1355 case 'i': /* Ignore errors */
1356 if (invert_this) {
1357 ignore_errors_all = false;
1358 } else {
1359 ignore_errors_all = true;
1360 }
1361 return 0;
1362 case 'j': /* Use alternative DMake max jobs */
1363 if (invert_this) {
1364 dmake_max_jobs_specified = false;
1365 } else {
1366 dmake_max_jobs_specified = true;
1367 }
1368 return 8;
1369 case 'K': /* Read alternative .make.state */
1370 return 256;
1371 case 'k': /* Keep making even after errors */
1372 if (invert_this) {
1373 continue_after_error = false;
1374 } else {
1375 continue_after_error = true;
1376 continue_after_error_ever_seen = true;
1377 }
1378 return 0;
1379 case 'M': /* Read alternative make.machines file */
1380 if (invert_this) {
1381 pmake_machinesfile_specified = false;
1382 } else {
1383 pmake_machinesfile_specified = true;
1384 dmake_mode_type = parallel_mode;
1385 no_parallel = false;
|
23 * Use is subject to license terms.
24 */
25
26 /*
27 * main.cc
28 *
29 * make program main routine plus some helper routines
30 */
31
32 /*
33 * Included files
34 */
35 #if defined(TEAMWARE_MAKE_CMN)
36 # include <avo/intl.h>
37 #endif
38
39 #include <bsd/bsd.h> /* bsd_signal() */
40
41
42 #include <locale.h> /* setlocale() */
43 #include <libgen.h>
44 #include <mk/defs.h>
45 #include <mksdmsi18n/mksdmsi18n.h> /* libmksdmsi18n_init() */
46 #include <mksh/macro.h> /* getvar() */
47 #include <mksh/misc.h> /* getmem(), setup_char_semantics() */
48
49 #if defined(TEAMWARE_MAKE_CMN)
50 #endif
51
52 #include <pwd.h> /* getpwnam() */
53 #include <setjmp.h>
54 #include <signal.h>
55 #include <stdlib.h>
56 #include <sys/errno.h> /* ENOENT */
57 #include <sys/stat.h> /* fstat() */
58 #include <fcntl.h> /* open() */
59
60 # include <sys/systeminfo.h> /* sysinfo() */
61
62 #include <sys/types.h> /* stat() */
63 #include <sys/wait.h> /* wait() */
397 output_mode = txt1_mode;
398 } else {
399 dmake_value2 = prop2->body.macro.value;
400 if ((dmake_value2 == NULL) ||
401 (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("TXT1")))) {
402 output_mode = txt1_mode;
403 } else if (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("TXT2"))) {
404 output_mode = txt2_mode;
405 } else if (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("HTML1"))) {
406 output_mode = html1_mode;
407 } else {
408 warning(catgets(catd, 1, 352, "Unsupported value `%s' for DMAKE_OUTPUT_MODE after -x flag (ignored)"),
409 dmake_value2->string_mb);
410 }
411 }
412 /*
413 * Find the dmake_mode: parallel, or serial.
414 */
415 if ((!pmake_cap_r_specified) &&
416 (!pmake_machinesfile_specified)) {
417 char *s = strdup(argv[0]);
418
419 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MODE"));
420 dmake_name2 = GETNAME(wcs_buffer, FIND_LENGTH);
421 prop2 = get_prop(dmake_name2->prop, macro_prop);
422 // If we're invoked as 'make' run serially, regardless of DMAKE_MODE
423 // If we're invoked as 'make' but passed -j, run parallel
424 // If we're invoked as 'dmake', without DMAKE_MODE, default parallel
425 // If we're invoked as 'dmake' and DMAKE_MODE is set, honour it.
426 if ((strcmp(basename(s), NOCATGETS("make")) == 0) &&
427 !dmake_max_jobs_specified) {
428 dmake_mode_type = serial_mode;
429 no_parallel = true;
430 } else if (prop2 == NULL) {
431 /* DMAKE_MODE not defined, default based on our name */
432 char *s = strdup(argv[0]);
433
434 if (strcmp(basename(s), NOCATGETS("dmake")) == 0) {
435 dmake_mode_type = parallel_mode;
436 no_parallel = false;
437 }
438 } else {
439 dmake_value2 = prop2->body.macro.value;
440 if (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("parallel"))) {
441 dmake_mode_type = parallel_mode;
442 no_parallel = false;
443 } else if (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("serial"))) {
444 dmake_mode_type = serial_mode;
445 no_parallel = true;
446 } else {
447 fatal(catgets(catd, 1, 307, "Unknown dmake mode argument `%s' after -m flag"), dmake_value2->string_mb);
448 }
449 }
450 free(s);
451 }
452
453 parallel_flag = true;
454 putenv(strdup(NOCATGETS("DMAKE_CHILD=TRUE")));
455
456 //
457 // If dmake is running with -t option, set dmake_mode_type to serial.
458 // This is done because doname() calls touch_command() that runs serially.
459 // If we do not do that, maketool will have problems.
460 //
461 if(touch) {
462 dmake_mode_type = serial_mode;
463 no_parallel = true;
464 }
465
466 /*
467 * Check whether stdout and stderr are physically same.
468 * This is in order to decide whether we need to redirect
469 * stderr separately from stdout.
470 * This check is performed only if __DMAKE_SEPARATE_STDERR
1361 case 'f': /* Read alternative makefile(s) */
1362 return 1;
1363 case 'g': /* Use alternative DMake group */
1364 if (invert_this) {
1365 dmake_group_specified = false;
1366 } else {
1367 dmake_group_specified = true;
1368 }
1369 return 4;
1370 case 'i': /* Ignore errors */
1371 if (invert_this) {
1372 ignore_errors_all = false;
1373 } else {
1374 ignore_errors_all = true;
1375 }
1376 return 0;
1377 case 'j': /* Use alternative DMake max jobs */
1378 if (invert_this) {
1379 dmake_max_jobs_specified = false;
1380 } else {
1381 dmake_mode_type = parallel_mode;
1382 no_parallel = false;
1383 dmake_max_jobs_specified = true;
1384 }
1385 return 8;
1386 case 'K': /* Read alternative .make.state */
1387 return 256;
1388 case 'k': /* Keep making even after errors */
1389 if (invert_this) {
1390 continue_after_error = false;
1391 } else {
1392 continue_after_error = true;
1393 continue_after_error_ever_seen = true;
1394 }
1395 return 0;
1396 case 'M': /* Read alternative make.machines file */
1397 if (invert_this) {
1398 pmake_machinesfile_specified = false;
1399 } else {
1400 pmake_machinesfile_specified = true;
1401 dmake_mode_type = parallel_mode;
1402 no_parallel = false;
|