219 * cp is a -> to the value of the MAKEFLAGS env var,
220 * which has to be regular chars.
221 */
222 register char *cp;
223 char make_state_dir[MAXPATHLEN];
224 Boolean parallel_flag = false;
225 char *prognameptr;
226 char *slash_ptr;
227 mode_t um;
228 int i;
229 #ifdef TEAMWARE_MAKE_CMN
230 struct itimerval value;
231 char def_dmakerc_path[MAXPATHLEN];
232 Name dmake_name, dmake_name2;
233 Name dmake_value, dmake_value2;
234 Property prop, prop2;
235 struct stat statbuf;
236 int statval;
237 #endif
238
239 #ifndef PARALLEL
240 struct stat out_stat, err_stat;
241 #endif
242 hostid = gethostid();
243 #ifdef TEAMWARE_MAKE_CMN
244 avo_get_user(NULL, NULL); // Initialize user name
245 #endif
246 bsd_signals();
247
248 (void) setlocale(LC_ALL, "");
249
250
251 #ifdef DMAKE_STATISTICS
252 if (getenv(NOCATGETS("DMAKE_STATISTICS"))) {
253 getname_stat = true;
254 }
255 #endif
256
257
258 /*
259 * avo_init() sets the umask to 0. Save it here and restore
260 * it after the avo_init() call.
261 */
399 * Temporary directory set up.
400 */
401 char * tmpdir_var = getenv(NOCATGETS("TMPDIR"));
402 if (tmpdir_var != NULL && *tmpdir_var == '/' && strlen(tmpdir_var) < MAXPATHLEN) {
403 strcpy(mbs_buffer, tmpdir_var);
404 for (tmpdir_var = mbs_buffer+strlen(mbs_buffer);
405 *(--tmpdir_var) == '/' && tmpdir_var > mbs_buffer;
406 *tmpdir_var = '\0');
407 if (strlen(mbs_buffer) + 32 < MAXPATHLEN) { /* 32 = strlen("/dmake.stdout.%d.%d.XXXXXX") */
408 sprintf(mbs_buffer2, NOCATGETS("%s/dmake.tst.%d.XXXXXX"),
409 mbs_buffer, getpid());
410 int fd = mkstemp(mbs_buffer2);
411 if (fd >= 0) {
412 close(fd);
413 unlink(mbs_buffer2);
414 tmpdir = strdup(mbs_buffer);
415 }
416 }
417 }
418
419 #ifndef PARALLEL
420 /* find out if stdout and stderr point to the same place */
421 if (fstat(1, &out_stat) < 0) {
422 fatal(catgets(catd, 1, 165, "fstat of standard out failed: %s"), errmsg(errno));
423 }
424 if (fstat(2, &err_stat) < 0) {
425 fatal(catgets(catd, 1, 166, "fstat of standard error failed: %s"), errmsg(errno));
426 }
427 if ((out_stat.st_dev == err_stat.st_dev) &&
428 (out_stat.st_ino == err_stat.st_ino)) {
429 stdout_stderr_same = true;
430 } else {
431 stdout_stderr_same = false;
432 }
433 #else
434 stdout_stderr_same = false;
435 #endif
436 /* Make the vroot package scan the path using shell semantics */
437 set_path_style(0);
438
439 setup_char_semantics();
440
441 setup_for_projectdir();
442
443 /*
444 * If running with .KEEP_STATE, curdir will be set with
445 * the connected directory.
446 */
447 (void) atexit(cleanup_after_exit);
448
449 load_cached_names();
450
451 /*
452 * Set command line flags
453 */
454 setup_makeflags_argv();
455 read_command_options(mf_argc, mf_argv);
1316 #endif
1317 break;
1318 case 8: /* -j seen */
1319 argv[i] = (char *)NOCATGETS("-j");
1320 #ifndef TEAMWARE_MAKE_CMN
1321 warning(catgets(catd, 1, 283, "Ignoring DistributedMake -j option"));
1322 #endif
1323 break;
1324 case 16: /* -M seen */
1325 argv[i] = (char *)NOCATGETS("-M");
1326 #ifndef TEAMWARE_MAKE_CMN
1327 warning(catgets(catd, 1, 284, "Ignoring ParallelMake -M option"));
1328 #endif
1329 break;
1330 case 32: /* -m seen */
1331 argv[i] = (char *)NOCATGETS("-m");
1332 #ifndef TEAMWARE_MAKE_CMN
1333 warning(catgets(catd, 1, 285, "Ignoring DistributedMake -m option"));
1334 #endif
1335 break;
1336 #ifndef PARALLEL
1337 case 128: /* -O seen */
1338 argv[i] = (char *)NOCATGETS("-O");
1339 break;
1340 #endif
1341 case 256: /* -K seen */
1342 argv[i] = (char *)NOCATGETS("-K");
1343 break;
1344 case 512: /* -o seen */
1345 argv[i] = (char *)NOCATGETS("-o");
1346 #ifndef TEAMWARE_MAKE_CMN
1347 warning(catgets(catd, 1, 311, "Ignoring DistributedMake -o option"));
1348 #endif
1349 break;
1350 case 1024: /* -x seen */
1351 argv[i] = (char *)NOCATGETS("-x");
1352 #ifndef TEAMWARE_MAKE_CMN
1353 warning(catgets(catd, 1, 353, "Ignoring DistributedMake -x option"));
1354 #endif
1355 break;
1356 default: /* > 1 of -c, f, g, j, K, M, m, O, o, x seen */
1357 fatal(catgets(catd, 1, 286, "Illegal command line. More than one option requiring\nan argument given in the same argument group"));
1358 }
1359
1360 makefile_next = 0;
1680 if (invert_this) {
1681 dmake_add_mode_specified = false;
1682 } else {
1683 dmake_add_mode_specified = true;
1684 }
1685 return 1024;
1686 case 'N': /* Reverse -n */
1687 if (invert_this) {
1688 do_not_exec_rule = true;
1689 } else {
1690 do_not_exec_rule = false;
1691 }
1692 return 0;
1693 case 'n': /* Print, not exec commands */
1694 if (invert_this) {
1695 do_not_exec_rule = false;
1696 } else {
1697 do_not_exec_rule = true;
1698 }
1699 return 0;
1700 #ifndef PARALLEL
1701 case 'O': /* Send job start & result msgs */
1702 if (invert_this) {
1703 send_mtool_msgs = false;
1704 } else {
1705 #ifdef DISTRIBUTED
1706 send_mtool_msgs = true;
1707 #endif
1708 }
1709 return 128;
1710 #endif
1711 case 'o': /* Use alternative dmake output dir */
1712 if (invert_this) {
1713 dmake_odir_specified = false;
1714 } else {
1715 dmake_odir_specified = true;
1716 }
1717 return 512;
1718 case 'P': /* Print for selected targets */
1719 if (invert_this) {
1720 report_dependencies_level--;
1721 } else {
1722 report_dependencies_level++;
1723 }
1724 return 0;
1725 case 'p': /* Print description */
1726 if (invert_this) {
1727 trace_status = false;
1728 do_not_exec_rule = false;
1729 } else {
1730 trace_status = true;
2190 if (quest) {
2191 append_char('q', &makeflags_string);
2192 append_char('q', &makeflags_string_posix);
2193 }
2194 if (silent_all) {
2195 append_char('s', &makeflags_string);
2196 append_char('s', &makeflags_string_posix);
2197 }
2198 if (touch) {
2199 append_char('t', &makeflags_string);
2200 append_char('t', &makeflags_string_posix);
2201 }
2202 if (build_unconditional) {
2203 append_char('u', &makeflags_string);
2204 append_char('u', &makeflags_string_posix);
2205 }
2206 if (report_cwd) {
2207 append_char('w', &makeflags_string);
2208 append_char('w', &makeflags_string_posix);
2209 }
2210 #ifndef PARALLEL
2211 /* -c dmake_rcfile */
2212 if (dmake_rcfile_specified) {
2213 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_RCFILE"));
2214 dmake_rcfile = GETNAME(wcs_buffer, FIND_LENGTH);
2215 append_makeflags_string(dmake_rcfile, &makeflags_string);
2216 append_makeflags_string(dmake_rcfile, &makeflags_string_posix);
2217 }
2218 /* -g dmake_group */
2219 if (dmake_group_specified) {
2220 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_GROUP"));
2221 dmake_group = GETNAME(wcs_buffer, FIND_LENGTH);
2222 append_makeflags_string(dmake_group, &makeflags_string);
2223 append_makeflags_string(dmake_group, &makeflags_string_posix);
2224 }
2225 /* -j dmake_max_jobs */
2226 if (dmake_max_jobs_specified) {
2227 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MAX_JOBS"));
2228 dmake_max_jobs = GETNAME(wcs_buffer, FIND_LENGTH);
2229 append_makeflags_string(dmake_max_jobs, &makeflags_string);
2230 append_makeflags_string(dmake_max_jobs, &makeflags_string_posix);
2256 dmake_odir = GETNAME(wcs_buffer, FIND_LENGTH);
2257 append_makeflags_string(dmake_odir, &makeflags_string);
2258 append_makeflags_string(dmake_odir, &makeflags_string_posix);
2259 }
2260 /* -M pmake_machinesfile */
2261 if (pmake_machinesfile_specified) {
2262 MBSTOWCS(wcs_buffer, NOCATGETS("PMAKE_MACHINESFILE"));
2263 pmake_machinesfile = GETNAME(wcs_buffer, FIND_LENGTH);
2264 append_makeflags_string(pmake_machinesfile, &makeflags_string);
2265 append_makeflags_string(pmake_machinesfile, &makeflags_string_posix);
2266 }
2267 /* -R */
2268 if (pmake_cap_r_specified) {
2269 append_char((int) space_char, &makeflags_string);
2270 append_char((int) hyphen_char, &makeflags_string);
2271 append_char('R', &makeflags_string);
2272 append_char((int) space_char, &makeflags_string_posix);
2273 append_char((int) hyphen_char, &makeflags_string_posix);
2274 append_char('R', &makeflags_string_posix);
2275 }
2276 #endif
2277
2278 /*
2279 * Make sure MAKEFLAGS is exported
2280 */
2281 maybe_append_prop(makeflags, macro_prop)->
2282 body.macro.exported = true;
2283
2284 if (makeflags_string.buffer.start[1] != (int) nul_char) {
2285 if (makeflags_string.buffer.start[1] != (int) space_char) {
2286 MBSTOWCS(wcs_buffer, NOCATGETS("MFLAGS"));
2287 (void) SETVAR(GETNAME(wcs_buffer, FIND_LENGTH),
2288 GETNAME(makeflags_string.buffer.start,
2289 FIND_LENGTH),
2290 false);
2291 } else {
2292 MBSTOWCS(wcs_buffer, NOCATGETS("MFLAGS"));
2293 (void) SETVAR(GETNAME(wcs_buffer, FIND_LENGTH),
2294 GETNAME(makeflags_string.buffer.start + 2,
2295 FIND_LENGTH),
2296 false);
|
219 * cp is a -> to the value of the MAKEFLAGS env var,
220 * which has to be regular chars.
221 */
222 register char *cp;
223 char make_state_dir[MAXPATHLEN];
224 Boolean parallel_flag = false;
225 char *prognameptr;
226 char *slash_ptr;
227 mode_t um;
228 int i;
229 #ifdef TEAMWARE_MAKE_CMN
230 struct itimerval value;
231 char def_dmakerc_path[MAXPATHLEN];
232 Name dmake_name, dmake_name2;
233 Name dmake_value, dmake_value2;
234 Property prop, prop2;
235 struct stat statbuf;
236 int statval;
237 #endif
238
239 struct stat out_stat, err_stat;
240 hostid = gethostid();
241 #ifdef TEAMWARE_MAKE_CMN
242 avo_get_user(NULL, NULL); // Initialize user name
243 #endif
244 bsd_signals();
245
246 (void) setlocale(LC_ALL, "");
247
248
249 #ifdef DMAKE_STATISTICS
250 if (getenv(NOCATGETS("DMAKE_STATISTICS"))) {
251 getname_stat = true;
252 }
253 #endif
254
255
256 /*
257 * avo_init() sets the umask to 0. Save it here and restore
258 * it after the avo_init() call.
259 */
397 * Temporary directory set up.
398 */
399 char * tmpdir_var = getenv(NOCATGETS("TMPDIR"));
400 if (tmpdir_var != NULL && *tmpdir_var == '/' && strlen(tmpdir_var) < MAXPATHLEN) {
401 strcpy(mbs_buffer, tmpdir_var);
402 for (tmpdir_var = mbs_buffer+strlen(mbs_buffer);
403 *(--tmpdir_var) == '/' && tmpdir_var > mbs_buffer;
404 *tmpdir_var = '\0');
405 if (strlen(mbs_buffer) + 32 < MAXPATHLEN) { /* 32 = strlen("/dmake.stdout.%d.%d.XXXXXX") */
406 sprintf(mbs_buffer2, NOCATGETS("%s/dmake.tst.%d.XXXXXX"),
407 mbs_buffer, getpid());
408 int fd = mkstemp(mbs_buffer2);
409 if (fd >= 0) {
410 close(fd);
411 unlink(mbs_buffer2);
412 tmpdir = strdup(mbs_buffer);
413 }
414 }
415 }
416
417 /* find out if stdout and stderr point to the same place */
418 if (fstat(1, &out_stat) < 0) {
419 fatal(catgets(catd, 1, 165, "fstat of standard out failed: %s"), errmsg(errno));
420 }
421 if (fstat(2, &err_stat) < 0) {
422 fatal(catgets(catd, 1, 166, "fstat of standard error failed: %s"), errmsg(errno));
423 }
424 if ((out_stat.st_dev == err_stat.st_dev) &&
425 (out_stat.st_ino == err_stat.st_ino)) {
426 stdout_stderr_same = true;
427 } else {
428 stdout_stderr_same = false;
429 }
430 /* Make the vroot package scan the path using shell semantics */
431 set_path_style(0);
432
433 setup_char_semantics();
434
435 setup_for_projectdir();
436
437 /*
438 * If running with .KEEP_STATE, curdir will be set with
439 * the connected directory.
440 */
441 (void) atexit(cleanup_after_exit);
442
443 load_cached_names();
444
445 /*
446 * Set command line flags
447 */
448 setup_makeflags_argv();
449 read_command_options(mf_argc, mf_argv);
1310 #endif
1311 break;
1312 case 8: /* -j seen */
1313 argv[i] = (char *)NOCATGETS("-j");
1314 #ifndef TEAMWARE_MAKE_CMN
1315 warning(catgets(catd, 1, 283, "Ignoring DistributedMake -j option"));
1316 #endif
1317 break;
1318 case 16: /* -M seen */
1319 argv[i] = (char *)NOCATGETS("-M");
1320 #ifndef TEAMWARE_MAKE_CMN
1321 warning(catgets(catd, 1, 284, "Ignoring ParallelMake -M option"));
1322 #endif
1323 break;
1324 case 32: /* -m seen */
1325 argv[i] = (char *)NOCATGETS("-m");
1326 #ifndef TEAMWARE_MAKE_CMN
1327 warning(catgets(catd, 1, 285, "Ignoring DistributedMake -m option"));
1328 #endif
1329 break;
1330 case 128: /* -O seen */
1331 argv[i] = (char *)NOCATGETS("-O");
1332 break;
1333 case 256: /* -K seen */
1334 argv[i] = (char *)NOCATGETS("-K");
1335 break;
1336 case 512: /* -o seen */
1337 argv[i] = (char *)NOCATGETS("-o");
1338 #ifndef TEAMWARE_MAKE_CMN
1339 warning(catgets(catd, 1, 311, "Ignoring DistributedMake -o option"));
1340 #endif
1341 break;
1342 case 1024: /* -x seen */
1343 argv[i] = (char *)NOCATGETS("-x");
1344 #ifndef TEAMWARE_MAKE_CMN
1345 warning(catgets(catd, 1, 353, "Ignoring DistributedMake -x option"));
1346 #endif
1347 break;
1348 default: /* > 1 of -c, f, g, j, K, M, m, O, o, x seen */
1349 fatal(catgets(catd, 1, 286, "Illegal command line. More than one option requiring\nan argument given in the same argument group"));
1350 }
1351
1352 makefile_next = 0;
1672 if (invert_this) {
1673 dmake_add_mode_specified = false;
1674 } else {
1675 dmake_add_mode_specified = true;
1676 }
1677 return 1024;
1678 case 'N': /* Reverse -n */
1679 if (invert_this) {
1680 do_not_exec_rule = true;
1681 } else {
1682 do_not_exec_rule = false;
1683 }
1684 return 0;
1685 case 'n': /* Print, not exec commands */
1686 if (invert_this) {
1687 do_not_exec_rule = false;
1688 } else {
1689 do_not_exec_rule = true;
1690 }
1691 return 0;
1692 case 'O': /* Send job start & result msgs */
1693 if (invert_this) {
1694 send_mtool_msgs = false;
1695 } else {
1696 #ifdef DISTRIBUTED
1697 send_mtool_msgs = true;
1698 #endif
1699 }
1700 return 128;
1701 case 'o': /* Use alternative dmake output dir */
1702 if (invert_this) {
1703 dmake_odir_specified = false;
1704 } else {
1705 dmake_odir_specified = true;
1706 }
1707 return 512;
1708 case 'P': /* Print for selected targets */
1709 if (invert_this) {
1710 report_dependencies_level--;
1711 } else {
1712 report_dependencies_level++;
1713 }
1714 return 0;
1715 case 'p': /* Print description */
1716 if (invert_this) {
1717 trace_status = false;
1718 do_not_exec_rule = false;
1719 } else {
1720 trace_status = true;
2180 if (quest) {
2181 append_char('q', &makeflags_string);
2182 append_char('q', &makeflags_string_posix);
2183 }
2184 if (silent_all) {
2185 append_char('s', &makeflags_string);
2186 append_char('s', &makeflags_string_posix);
2187 }
2188 if (touch) {
2189 append_char('t', &makeflags_string);
2190 append_char('t', &makeflags_string_posix);
2191 }
2192 if (build_unconditional) {
2193 append_char('u', &makeflags_string);
2194 append_char('u', &makeflags_string_posix);
2195 }
2196 if (report_cwd) {
2197 append_char('w', &makeflags_string);
2198 append_char('w', &makeflags_string_posix);
2199 }
2200 /* -c dmake_rcfile */
2201 if (dmake_rcfile_specified) {
2202 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_RCFILE"));
2203 dmake_rcfile = GETNAME(wcs_buffer, FIND_LENGTH);
2204 append_makeflags_string(dmake_rcfile, &makeflags_string);
2205 append_makeflags_string(dmake_rcfile, &makeflags_string_posix);
2206 }
2207 /* -g dmake_group */
2208 if (dmake_group_specified) {
2209 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_GROUP"));
2210 dmake_group = GETNAME(wcs_buffer, FIND_LENGTH);
2211 append_makeflags_string(dmake_group, &makeflags_string);
2212 append_makeflags_string(dmake_group, &makeflags_string_posix);
2213 }
2214 /* -j dmake_max_jobs */
2215 if (dmake_max_jobs_specified) {
2216 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MAX_JOBS"));
2217 dmake_max_jobs = GETNAME(wcs_buffer, FIND_LENGTH);
2218 append_makeflags_string(dmake_max_jobs, &makeflags_string);
2219 append_makeflags_string(dmake_max_jobs, &makeflags_string_posix);
2245 dmake_odir = GETNAME(wcs_buffer, FIND_LENGTH);
2246 append_makeflags_string(dmake_odir, &makeflags_string);
2247 append_makeflags_string(dmake_odir, &makeflags_string_posix);
2248 }
2249 /* -M pmake_machinesfile */
2250 if (pmake_machinesfile_specified) {
2251 MBSTOWCS(wcs_buffer, NOCATGETS("PMAKE_MACHINESFILE"));
2252 pmake_machinesfile = GETNAME(wcs_buffer, FIND_LENGTH);
2253 append_makeflags_string(pmake_machinesfile, &makeflags_string);
2254 append_makeflags_string(pmake_machinesfile, &makeflags_string_posix);
2255 }
2256 /* -R */
2257 if (pmake_cap_r_specified) {
2258 append_char((int) space_char, &makeflags_string);
2259 append_char((int) hyphen_char, &makeflags_string);
2260 append_char('R', &makeflags_string);
2261 append_char((int) space_char, &makeflags_string_posix);
2262 append_char((int) hyphen_char, &makeflags_string_posix);
2263 append_char('R', &makeflags_string_posix);
2264 }
2265
2266 /*
2267 * Make sure MAKEFLAGS is exported
2268 */
2269 maybe_append_prop(makeflags, macro_prop)->
2270 body.macro.exported = true;
2271
2272 if (makeflags_string.buffer.start[1] != (int) nul_char) {
2273 if (makeflags_string.buffer.start[1] != (int) space_char) {
2274 MBSTOWCS(wcs_buffer, NOCATGETS("MFLAGS"));
2275 (void) SETVAR(GETNAME(wcs_buffer, FIND_LENGTH),
2276 GETNAME(makeflags_string.buffer.start,
2277 FIND_LENGTH),
2278 false);
2279 } else {
2280 MBSTOWCS(wcs_buffer, NOCATGETS("MFLAGS"));
2281 (void) SETVAR(GETNAME(wcs_buffer, FIND_LENGTH),
2282 GETNAME(makeflags_string.buffer.start + 2,
2283 FIND_LENGTH),
2284 false);
|