Changeset 2591 for trunk/src/kmk/main.c
- Timestamp:
- Jun 17, 2012, 10:45:31 PM (13 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk
- Property svn:ignore
-
old new 13 13 stamp-* 14 14 makebook* 15 15 16 .*gdbinit 17 .gdb_history 18 16 19 *.dep 17 20 *.dvi … … 31 34 *.pg 32 35 *.pgs 36 33 37 README 34 38 README.DOS 35 39 README.W32 40 README.OS2 36 41 aclocal.m4 37 42 autom4te.cache … … 52 57 config.h.W32 53 58 config.h-vms 59 54 60 loadavg 55 61 loadavg.c 56 62 make 63 57 64 .deps 58 65 .dep_segment 66 ID 67 TAGS 68 59 69 _* 60 70 sun4 … … 72 82 sol2 73 83 i486-linux 84 74 85 customs 86 75 87 install-sh 76 88 mkinstalldirs 89 90 .directive.asc
-
- Property svn:ignore
-
trunk/src/kmk/main.c
r2549 r2591 1 1 /* Argument parsing and main program of GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 81 81 void print_dir_data_base (void); 82 82 void print_rule_data_base (void); 83 void print_file_data_base (void);84 83 void print_vpath_data_base (void); 85 84 … … 110 109 static void decode_switches (int argc, char **argv, int env); 111 110 static void decode_env_switches (char *envar, unsigned int len); 112 static voiddefine_makeflags (int all, int makefile);111 static const char *define_makeflags (int all, int makefile); 113 112 static char *quote_for_env (char *out, const char *in); 114 113 static void initialize_global_hash_tables (void); … … 265 264 static struct stringlist *makefiles = 0; 266 265 266 /* Size of the stack when we started. */ 267 268 #ifdef SET_STACK_SIZE 269 struct rlimit stack_limit; 270 #endif 271 272 267 273 /* Number of job slots (commands that can be run at once). */ 268 274 … … 309 315 310 316 static struct stringlist *new_files = 0; 317 318 /* List of strings to be eval'd. */ 319 static struct stringlist *eval_strings = 0; 311 320 312 321 /* If nonzero, we should just print usage and exit. */ … … 382 391 -e, --environment-overrides\n\ 383 392 Environment variables override makefiles.\n"), 393 N_("\ 394 --eval=STRING Evaluate STRING as a makefile statement.\n"), 384 395 N_("\ 385 396 -f FILE, --file=FILE, --makefile=FILE\n\ … … 544 555 { CHAR_MAX+5, flag, &warn_undefined_variables_flag, 1, 1, 0, 0, 0, 545 556 "warn-undefined-variables" }, 557 { CHAR_MAX+6, string, &eval_strings, 1, 0, 0, 0, 0, "eval" }, 546 558 { 0, 0, 0, 0, 0, 0, 0, 0, 0 } 547 559 }; … … 596 608 unsigned int makelevel; 597 609 598 /* First file defined in the makefile whose name does not 599 start with `.'. This is the default to remake if the 600 command line does not specify. */ 601 602 struct file *default_goal_file; 603 604 /* Pointer to the value of the .DEFAULT_GOAL special 605 variable. */ 606 char ** default_goal_name; 610 /* Pointer to the value of the .DEFAULT_GOAL special variable. 611 The value will be the name of the goal to remake if the command line 612 does not override it. It can be set by the makefile, or else it's 613 the first target defined in the makefile whose name does not start 614 with '.'. */ 615 616 struct variable * default_goal_var; 607 617 608 618 /* Pointer to structure for the file .DEFAULT … … 622 632 int second_expansion; 623 633 634 /* Nonzero if we have seen the '.ONESHELL' target. 635 This causes the entire recipe to be handed to SHELL 636 as a single string, potentially containing newlines. */ 637 638 int one_shell; 639 624 640 #ifdef CONFIG_WITH_2ND_TARGET_EXPANSION 625 641 /* Nonzero if we have seen the '.SECONDTARGETEXPANSION' target. … … 630 646 631 647 #ifndef CONFIG_WITH_EXTENDED_NOTPARALLEL 648 632 649 /* Nonzero if we have seen the `.NOTPARALLEL' target. 633 650 This turns off parallel builds for this invocation of make. */ … … 667 684 #endif 668 685 669 #if ! defined HAVE_BSD_SIGNAL && !defined bsd_signal686 #if !HAVE_DECL_BSD_SIGNAL && !defined bsd_signal 670 687 # if !defined HAVE_SIGACTION 671 688 # define bsd_signal signal 672 689 # else 673 typedef RETSIGTYPE (*bsd_signal_ret_t) ( );690 typedef RETSIGTYPE (*bsd_signal_ret_t) (int); 674 691 675 692 static bsd_signal_ret_t … … 924 941 { 925 942 sprintf(errmsg, 926 _("%s: Interrupt/Exception caught (code = 0x%lx, addr = 0x% lx)\n"),927 prg, exrec->ExceptionCode, (DWORD)exrec->ExceptionAddress);943 _("%s: Interrupt/Exception caught (code = 0x%lx, addr = 0x%p)\n"), 944 prg, exrec->ExceptionCode, exrec->ExceptionAddress); 928 945 fprintf(stderr, errmsg); 929 946 exit(255); … … 931 948 932 949 sprintf(errmsg, 933 _("\nUnhandled exception filter called from program %s\nExceptionCode = %lx\nExceptionFlags = %lx\nExceptionAddress = %lx\n"),950 _("\nUnhandled exception filter called from program %s\nExceptionCode = %lx\nExceptionFlags = %lx\nExceptionAddress = 0x%p\n"), 934 951 prg, exrec->ExceptionCode, exrec->ExceptionFlags, 935 (DWORD)exrec->ExceptionAddress);952 exrec->ExceptionAddress); 936 953 937 954 if (exrec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION … … 939 956 sprintf(&errmsg[strlen(errmsg)], 940 957 (exrec->ExceptionInformation[0] 941 ? _("Access violation: write operation at address %lx\n")942 : _("Access violation: read operation at address %lx\n")),943 exrec->ExceptionInformation[1]);958 ? _("Access violation: write operation at address 0x%p\n") 959 : _("Access violation: read operation at address 0x%p\n")), 960 (PVOID)exrec->ExceptionInformation[1]); 944 961 945 962 /* turn this on if we want to put stuff in the event log too */ … … 1015 1032 sprintf (sh_path, "%s", search_token); 1016 1033 default_shell = xstrdup (w32ify (sh_path, 0)); 1017 DB (DB_VERBOSE, 1018 (_("find_and_set_shell setting default_shell = %s\n"),default_shell));1034 DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"), 1035 default_shell)); 1019 1036 sh_found = 1; 1020 1037 } else if (!no_default_sh_exe && … … 1026 1043 sprintf (sh_path, "%s", search_token); 1027 1044 default_shell = xstrdup (w32ify (sh_path, 0)); 1028 DB (DB_VERBOSE, 1029 (_("find_and_set_shell setting default_shell = %s\n"),default_shell));1045 DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"), 1046 default_shell)); 1030 1047 sh_found = 1; 1031 1048 } else { … … 1068 1085 if (sh_found) 1069 1086 DB (DB_VERBOSE, 1070 (_("find_and_set_shell path search set default_shell = %s\n"),1087 (_("find_and_set_shell() path search set default_shell = %s\n"), 1071 1088 default_shell)); 1072 1089 } … … 1383 1400 1384 1401 /* Set the stack limit huge so that alloca does not fail. */ 1385 if (getrlimit (RLIMIT_STACK, &rlim) == 0) 1402 if (getrlimit (RLIMIT_STACK, &rlim) == 0 1403 && rlim.rlim_cur > 0 && rlim.rlim_cur < rlim.rlim_max) 1386 1404 { 1405 stack_limit = rlim; 1387 1406 rlim.rlim_cur = rlim.rlim_max; 1388 1407 setrlimit (RLIMIT_STACK, &rlim); 1389 1408 } 1409 else 1410 stack_limit.rlim_cur = 0; 1390 1411 } 1391 1412 #endif … … 1402 1423 #endif 1403 1424 1404 default_goal_file = 0;1405 1425 reading_file = 0; 1406 1426 … … 1419 1439 /* Set up gettext/internationalization support. */ 1420 1440 setlocale (LC_ALL, ""); 1441 /* The cast to void shuts up compiler warnings on systems that 1442 disable NLS. */ 1421 1443 #ifdef LOCALEDIR /* bird */ 1422 bindtextdomain (PACKAGE, LOCALEDIR);1423 textdomain (PACKAGE);1444 (void)bindtextdomain (PACKAGE, LOCALEDIR); 1445 (void)textdomain (PACKAGE); 1424 1446 #endif 1425 1447 … … 1432 1454 #define ADD_SIG(sig) fatal_signal_mask |= sigmask (sig) 1433 1455 #else 1434 #define ADD_SIG(sig) 1456 #define ADD_SIG(sig) (void)sig /* Needed to avoid warnings in MSVC. */ 1435 1457 #endif 1436 1458 #endif … … 1587 1609 1588 1610 /* Initialize the special variables. */ 1589 define_variable (".VARIABLES", 10, "", o_default, 0)->special = 1; 1590 /* define_variable (".TARGETS", 8, "", o_default, 0)->special = 1; */ 1591 define_variable (".RECIPEPREFIX", 13, "", o_default, 0)->special = 1; 1592 1593 /* Set up .FEATURES */ 1594 define_variable (".FEATURES", 9, 1595 "target-specific order-only second-expansion else-if", 1596 o_default, 0); 1611 define_variable_cname (".VARIABLES", "", o_default, 0)->special = 1; 1612 /* define_variable_cname (".TARGETS", "", o_default, 0)->special = 1; */ 1613 define_variable_cname (".RECIPEPREFIX", "", o_default, 0)->special = 1; 1614 define_variable_cname (".SHELLFLAGS", "-c", o_default, 0); 1615 1616 /* Set up .FEATURES 1617 We must do this in multiple calls because define_variable_cname() is 1618 a macro and some compilers (MSVC) don't like conditionals in macros. */ 1619 { 1620 const char *features = "target-specific order-only second-expansion" 1621 " else-if shortest-stem undefine" 1597 1622 #ifndef NO_ARCHIVES 1598 do_variable_definition (NILF, ".FEATURES", "archives", 1599 o_default, f_append, 0); 1623 " archives" 1600 1624 #endif 1601 1625 #ifdef MAKE_JOBSERVER 1602 do_variable_definition (NILF, ".FEATURES", "jobserver", 1603 o_default, f_append, 0); 1626 " jobserver" 1604 1627 #endif 1605 1628 #ifdef MAKE_SYMLINKS 1606 do_variable_definition (NILF, ".FEATURES", "check-symlink", 1607 o_default, f_append, 0); 1629 " check-symlink" 1608 1630 #endif 1609 1631 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 1610 do_variable_definition (NILF, ".FEATURES", "explicit-multitarget", 1611 o_default, f_append, 0); 1632 " explicit-multitarget" 1612 1633 #endif 1613 1634 #ifdef CONFIG_WITH_PREPEND_ASSIGNMENT 1614 do_variable_definition (NILF, ".FEATURES", "prepend-assignment", 1615 o_default, f_append, 0); 1616 #endif 1635 " prepend-assignment" 1636 #endif 1637 ; 1638 1639 define_variable_cname (".FEATURES", features, o_default, 0); 1640 } 1617 1641 1618 1642 #ifdef KMK … … 1675 1699 shell_var.name = v->name; 1676 1700 #endif 1677 shell_var.length = 5; /* bird - gotta set the length too! */1701 shell_var.length = 5; 1678 1702 #ifndef CONFIG_WITH_VALUE_LENGTH 1679 1703 shell_var.value = xstrdup (ep + 1); 1680 1704 #else 1681 shell_var.value = savestring(v->value, v->value_length);1705 shell_var.value = xstrndup (v->value, v->value_length); 1682 1706 shell_var.value_length = v->value_length; 1683 1707 #endif 1684 1685 1708 } 1686 1709 … … 1699 1722 */ 1700 1723 if (!unix_path) 1701 define_variable("PATH", 4, 1702 windows32_path ? windows32_path : "", 1703 o_env, 1)->export = v_export; 1724 define_variable_cname ("PATH", windows32_path ? windows32_path : "", 1725 o_env, 1)->export = v_export; 1704 1726 #endif 1705 1727 #else /* For Amiga, read the ENV: device, ignoring all dirs */ … … 1747 1769 #endif 1748 1770 #endif /* !KMK */ 1771 1749 1772 decode_switches (argc, argv, 0); 1773 1750 1774 #ifdef WINDOWS32 1751 1775 if (suspend_flag) { … … 1815 1839 # endif 1816 1840 ) 1817 argv[0] = xstrdup (concat ( current_directory, "/", argv[0]));1841 argv[0] = xstrdup (concat (3, current_directory, "/", argv[0])); 1818 1842 #else /* !__MSDOS__ */ 1819 1843 if (current_directory[0] != '\0' … … 1824 1848 #endif 1825 1849 ) 1826 argv[0] = xstrdup (concat ( current_directory, "/", argv[0]));1850 argv[0] = xstrdup (concat (3, current_directory, "/", argv[0])); 1827 1851 #endif /* !__MSDOS__ */ 1828 1852 #endif /* WINDOWS32 */ … … 1831 1855 /* The extra indirection through $(MAKE_COMMAND) is done 1832 1856 for hysterical raisins. */ 1833 (void) define_variable ("MAKE_COMMAND", 12, argv[0], o_default, 0);1834 (void) define_variable ("MAKE", 4, "$(MAKE_COMMAND)", o_default, 1);1857 define_variable_cname ("MAKE_COMMAND", argv[0], o_default, 0); 1858 define_variable_cname ("MAKE", "$(MAKE_COMMAND)", o_default, 1); 1835 1859 #ifdef KMK 1836 1860 (void) define_variable ("KMK", 3, argv[0], o_default, 1); … … 1873 1897 /* Define an unchangeable variable with a name that no POSIX.2 1874 1898 makefile could validly use for its own variable. */ 1875 (void) define_variable ("-*-command-variables-*-", 23, 1876 value, o_automatic, 0); 1899 define_variable_cname ("-*-command-variables-*-", value, o_automatic, 0); 1877 1900 1878 1901 /* Define the variable; this will not override any user definition. … … 1883 1906 a reference to this hidden variable is written instead. */ 1884 1907 #ifdef KMK 1885 (void) define_variable ("KMK_OVERRIDES", 13,1886 "${-*-command-variables-*-}",o_env, 1);1908 define_variable_cname ("KMK_OVERRIDES", "${-*-command-variables-*-}", 1909 o_env, 1); 1887 1910 #else 1888 (void) define_variable ("MAKEOVERRIDES", 13,1889 "${-*-command-variables-*-}",o_env, 1);1911 define_variable_cname ("MAKEOVERRIDES", "${-*-command-variables-*-}", 1912 o_env, 1); 1890 1913 #endif 1891 1914 } … … 2058 2081 } 2059 2082 2060 (void) define_variable ("CURDIR", 6, current_directory, o_file, 0);2083 define_variable_cname ("CURDIR", current_directory, o_file, 0); 2061 2084 2062 2085 /* Read any stdin makefiles into temporary files. */ … … 2198 2221 default_file = enter_file (strcache_add (".DEFAULT")); 2199 2222 2200 { 2201 struct variable *v = define_variable (".DEFAULT_GOAL", 13, "", o_file, 0); 2202 default_goal_name = &v->value; 2203 } 2223 default_goal_var = define_variable_cname (".DEFAULT_GOAL", "", o_file, 0); 2224 2225 /* Evaluate all strings provided with --eval. 2226 Also set up the $(-*-eval-flags-*-) variable. */ 2227 2228 if (eval_strings) 2229 { 2230 char *p, *value; 2231 unsigned int i; 2232 unsigned int len = sizeof ("--eval=") * eval_strings->idx; 2233 2234 for (i = 0; i < eval_strings->idx; ++i) 2235 { 2236 #ifndef CONFIG_WITH_VALUE_LENGTH 2237 p = xstrdup (eval_strings->list[i]); 2238 len += 2 * strlen (p); 2239 eval_buffer (p); 2240 #else 2241 unsigned int sub_len = strlen(eval_strings->list[i]); 2242 p = xstrndup (eval_strings->list[i], sub_len); 2243 len += 2 * sub_len; 2244 eval_buffer (p, p + sub_len); 2245 #endif 2246 free (p); 2247 } 2248 2249 p = value = alloca (len); 2250 for (i = 0; i < eval_strings->idx; ++i) 2251 { 2252 strcpy (p, "--eval="); 2253 p += strlen (p); 2254 p = quote_for_env (p, eval_strings->list[i]); 2255 *(p++) = ' '; 2256 } 2257 p[-1] = '\0'; 2258 2259 define_variable_cname ("-*-eval-flags-*-", value, o_automatic, 0); 2260 } 2204 2261 2205 2262 /* Read all the makefiles. */ … … 2264 2321 2265 2322 if (jobserver_fds) 2266 { 2267 const char *cp; 2268 unsigned int ui; 2269 2270 for (ui=1; ui < jobserver_fds->idx; ++ui) 2271 if (!streq (jobserver_fds->list[0], jobserver_fds->list[ui])) 2272 fatal (NILF, _("internal error: multiple --jobserver-fds options")); 2273 2274 /* Now parse the fds string and make sure it has the proper format. */ 2275 2276 cp = jobserver_fds->list[0]; 2277 2278 if (sscanf (cp, "%d,%d", &job_fds[0], &job_fds[1]) != 2) 2279 fatal (NILF, 2280 _("internal error: invalid --jobserver-fds string `%s'"), cp); 2281 2282 DB (DB_JOBS, 2283 (_("Jobserver client (fds %d,%d)\n"), job_fds[0], job_fds[1])); 2284 2285 /* The combination of a pipe + !job_slots means we're using the 2286 jobserver. If !job_slots and we don't have a pipe, we can start 2287 infinite jobs. If we see both a pipe and job_slots >0 that means the 2288 user set -j explicitly. This is broken; in this case obey the user 2289 (ignore the jobserver pipe for this make) but print a message. */ 2290 2291 if (job_slots > 0) 2292 error (NILF, 2293 _("warning: -jN forced in submake: disabling jobserver mode.")); 2294 2295 /* Create a duplicate pipe, that will be closed in the SIGCHLD 2296 handler. If this fails with EBADF, the parent has closed the pipe 2297 on us because it didn't think we were a submake. If so, print a 2298 warning then default to -j1. */ 2299 2300 else if ((job_rfd = dup (job_fds[0])) < 0) 2301 { 2302 if (errno != EBADF) 2303 pfatal_with_name (_("dup jobserver")); 2304 2323 { 2324 const char *cp; 2325 unsigned int ui; 2326 2327 for (ui=1; ui < jobserver_fds->idx; ++ui) 2328 if (!streq (jobserver_fds->list[0], jobserver_fds->list[ui])) 2329 fatal (NILF, _("internal error: multiple --jobserver-fds options")); 2330 2331 /* Now parse the fds string and make sure it has the proper format. */ 2332 2333 cp = jobserver_fds->list[0]; 2334 2335 if (sscanf (cp, "%d,%d", &job_fds[0], &job_fds[1]) != 2) 2336 fatal (NILF, 2337 _("internal error: invalid --jobserver-fds string `%s'"), cp); 2338 2339 DB (DB_JOBS, 2340 (_("Jobserver client (fds %d,%d)\n"), job_fds[0], job_fds[1])); 2341 2342 /* The combination of a pipe + !job_slots means we're using the 2343 jobserver. If !job_slots and we don't have a pipe, we can start 2344 infinite jobs. If we see both a pipe and job_slots >0 that means the 2345 user set -j explicitly. This is broken; in this case obey the user 2346 (ignore the jobserver pipe for this make) but print a message. */ 2347 2348 if (job_slots > 0) 2305 2349 error (NILF, 2306 _("warning: jobserver unavailable: using -j1. Add `+' to parent make rule.")); 2307 job_slots = 1; 2308 } 2309 2310 if (job_slots > 0) 2311 { 2312 close (job_fds[0]); 2313 close (job_fds[1]); 2314 job_fds[0] = job_fds[1] = -1; 2315 free (jobserver_fds->list); 2316 free (jobserver_fds); 2317 jobserver_fds = 0; 2318 } 2319 } 2350 _("warning: -jN forced in submake: disabling jobserver mode.")); 2351 2352 /* Create a duplicate pipe, that will be closed in the SIGCHLD 2353 handler. If this fails with EBADF, the parent has closed the pipe 2354 on us because it didn't think we were a submake. If so, print a 2355 warning then default to -j1. */ 2356 2357 else if ((job_rfd = dup (job_fds[0])) < 0) 2358 { 2359 if (errno != EBADF) 2360 pfatal_with_name (_("dup jobserver")); 2361 2362 error (NILF, 2363 _("warning: jobserver unavailable: using -j1. Add `+' to parent make rule.")); 2364 job_slots = 1; 2365 } 2366 2367 if (job_slots > 0) 2368 { 2369 close (job_fds[0]); 2370 close (job_fds[1]); 2371 job_fds[0] = job_fds[1] = -1; 2372 free (jobserver_fds->list); 2373 free (jobserver_fds); 2374 jobserver_fds = 0; 2375 } 2376 } 2320 2377 2321 2378 /* If we have >1 slot but no jobserver-fds, then we're a top-level make. … … 2435 2492 FILE_TIMESTAMP *makefile_mtimes = 0; 2436 2493 unsigned int mm_idx = 0; 2437 char **nargv = argv;2438 int nargc = argc;2494 char **nargv; 2495 int nargc; 2439 2496 int orig_db_level = db_level; 2440 2497 int status; … … 2605 2662 if (strneq (argv[i], "-f", 2)) /* XXX */ 2606 2663 { 2607 char *p = &argv[i][2]; 2608 if (*p == '\0') 2664 if (argv[i][2] == '\0') 2609 2665 /* This cast is OK since we never modify argv. */ 2610 2666 argv[++i] = (char *) makefiles->list[j]; 2611 2667 else 2612 argv[i] = xstrdup (concat ( "-f", makefiles->list[j], ""));2668 argv[i] = xstrdup (concat (2, "-f", makefiles->list[j])); 2613 2669 ++j; 2614 2670 } … … 2616 2672 2617 2673 /* Add -o option for the stdin temporary file, if necessary. */ 2674 nargc = argc; 2618 2675 if (stdin_nm) 2619 2676 { 2620 2677 nargv = xmalloc ((nargc + 2) * sizeof (char *)); 2621 2678 memcpy (nargv, argv, argc * sizeof (char *)); 2622 nargv[nargc++] = xstrdup (concat ( "-o", stdin_nm, ""));2679 nargv[nargc++] = xstrdup (concat (2, "-o", stdin_nm)); 2623 2680 nargv[nargc] = 0; 2624 2681 } 2682 else 2683 nargv = argv; 2625 2684 2626 2685 if (directories != 0 && directories->idx > 0) … … 2639 2698 2640 2699 ++restarts; 2700 2701 /* Reset makeflags in case they were changed. */ 2702 { 2703 const char *pv = define_makeflags (1, 1); 2704 char *p = alloca (sizeof ("MAKEFLAGS=") + strlen (pv) + 1); 2705 sprintf (p, "MAKEFLAGS=%s", pv); 2706 putenv (p); 2707 } 2641 2708 2642 2709 if (ISDB (DB_BASIC)) … … 2758 2825 perror_with_name (_("unlink (temporary file): "), stdin_nm); 2759 2826 2827 /* If there were no command-line goals, use the default. */ 2828 if (goals == 0) 2829 { 2830 char *p; 2831 2832 if (default_goal_var->recursive) 2833 p = variable_expand (default_goal_var->value); 2834 else 2835 { 2836 p = variable_buffer_output (variable_buffer, default_goal_var->value, 2837 strlen (default_goal_var->value)); 2838 *p = '\0'; 2839 p = variable_buffer; 2840 } 2841 2842 if (*p != '\0') 2843 { 2844 struct file *f = lookup_file (p); 2845 2846 /* If .DEFAULT_GOAL is a non-existent target, enter it into the 2847 table and let the standard logic sort it out. */ 2848 if (f == 0) 2849 { 2850 struct nameseq *ns; 2851 ns = PARSE_FILE_SEQ (&p, struct nameseq, '\0', NULL, 0); 2852 if (ns) 2853 { 2854 /* .DEFAULT_GOAL should contain one target. */ 2855 if (ns->next != 0) 2856 fatal (NILF, _(".DEFAULT_GOAL contains more than one target")); 2857 2858 #ifndef CONFIG_WITH_VALUE_LENGTH 2859 f = enter_file (strcache_add (ns->name)); 2860 #else 2861 f = enter_file (ns->name); 2862 #endif 2863 2864 ns->name = 0; /* It was reused by enter_file(). */ 2865 free_ns_chain (ns); 2866 } 2867 } 2868 2869 if (f) 2870 { 2871 goals = alloc_dep (); 2872 goals->file = f; 2873 } 2874 } 2875 } 2876 else 2877 lastgoal->next = 0; 2878 2879 2880 if (!goals) 2881 { 2882 if (read_makefiles == 0) 2883 fatal (NILF, _("No targets specified and no makefile found")); 2884 2885 fatal (NILF, _("No targets")); 2886 } 2887 2888 /* Update the goals. */ 2889 2890 DB (DB_BASIC, (_("Updating goal targets....\n"))); 2891 2760 2892 { 2761 2893 int status; 2762 2763 /* If there were no command-line goals, use the default. */2764 if (goals == 0)2765 {2766 if (**default_goal_name != '\0')2767 {2768 if (default_goal_file == 0 ||2769 strcmp (*default_goal_name, default_goal_file->name) != 0)2770 {2771 default_goal_file = lookup_file (*default_goal_name);2772 2773 /* In case user set .DEFAULT_GOAL to a non-existent target2774 name let's just enter this name into the table and let2775 the standard logic sort it out. */2776 if (default_goal_file == 0)2777 {2778 struct nameseq *ns;2779 char *p = *default_goal_name;2780 2781 #ifndef CONFIG_WITH_ALLOC_CACHES2782 ns = multi_glob (2783 parse_file_seq (&p, '\0', sizeof (struct nameseq), 1),2784 sizeof (struct nameseq));2785 #else2786 ns = multi_glob (2787 parse_file_seq (&p, '\0', &nameseq_cache, 1),2788 &nameseq_cache);2789 #endif2790 2791 /* .DEFAULT_GOAL should contain one target. */2792 if (ns->next != 0)2793 fatal (NILF, _(".DEFAULT_GOAL contains more than one target"));2794 2795 #ifndef CONFIG_WITH_VALUE_LENGTH2796 default_goal_file = enter_file (strcache_add (ns->name));2797 #else2798 default_goal_file = enter_file (ns->name);2799 #endif2800 2801 ns->name = 0; /* It was reused by enter_file(). */2802 free_ns_chain (ns);2803 }2804 }2805 2806 goals = alloc_dep ();2807 goals->file = default_goal_file;2808 }2809 }2810 else2811 lastgoal->next = 0;2812 2813 2814 if (!goals)2815 {2816 if (read_makefiles == 0)2817 fatal (NILF, _("No targets specified and no makefile found"));2818 2819 fatal (NILF, _("No targets"));2820 }2821 2822 /* Update the goals. */2823 2824 DB (DB_BASIC, (_("Updating goal targets....\n")));2825 2894 2826 2895 switch (update_goal_chain (goals)) … … 2933 3002 /* Ignore plain `-' for compatibility. */ 2934 3003 return; 2935 #ifndef CONFIG_WITH_VALUE_LENGTH 2936 v = try_variable_definition (0, arg, o_command, 0); 2937 #else 2938 v = try_variable_definition (0, arg, NULL, o_command, 0); 2939 #endif 3004 v = try_variable_definition (0, arg IF_WITH_VALUE_LENGTH_PARAM(NULL), o_command, 0); 2940 3005 if (v != 0) 2941 3006 { … … 2999 3064 value = vp; 3000 3065 } 3001 define_variable ("MAKECMDGOALS", 12, value, o_default, 0);3066 define_variable_cname ("MAKECMDGOALS", value, o_default, 0); 3002 3067 } 3003 3068 } … … 3110 3175 else if (*optarg == '\0') 3111 3176 { 3112 error (NILF, _("the `-%c' option requires a non-empty string argument"), 3113 cs->c); 3177 char opt[2] = "c"; 3178 const char *op = opt; 3179 3180 if (short_option (cs->c)) 3181 opt[0] = cs->c; 3182 else 3183 op = cs->long_name; 3184 3185 error (NILF, _("the `%s%s' option requires a non-empty string argument"), 3186 short_option (cs->c) ? "-" : "--", op); 3114 3187 bad = 1; 3115 3188 } … … 3128 3201 { 3129 3202 sl->max += 5; 3130 sl->list = xrealloc ((void *)sl->list, /* bird */ 3203 /* MSVC erroneously warns without a cast here. */ 3204 sl->list = xrealloc ((void *)sl->list, 3131 3205 sl->max * sizeof (char *)); 3132 3206 } … … 3275 3349 need permanent storage for this in case decode_switches saves 3276 3350 pointers into the value. */ 3277 argv[1] = xstrdup (concat ( "-", argv[1], ""));3351 argv[1] = xstrdup (concat (2, "-", argv[1])); 3278 3352 3279 3353 /* Parse those words. */ … … 3307 3381 Don't include options with the `no_makefile' flag set if MAKEFILE. */ 3308 3382 3309 static void3383 static const char * 3310 3384 define_makeflags (int all, int makefile) 3311 3385 { … … 3313 3387 static const char ref[] = "$(KMK_OVERRIDES)"; 3314 3388 #else 3315 static const char ref[] = "$(MAKEOVERRIDES)"; 3316 #endif 3317 static const char posixref[] = "$(-*-command-variables-*-)"; 3318 register const struct command_switch *cs; 3389 static /*<- bird*/ const char ref[] = "$(MAKEOVERRIDES)"; 3390 #endif 3391 static /*<- bird*/ const char posixref[] = "$(-*-command-variables-*-)"; 3392 static /*<- bird*/ const char evalref[] = "$(-*-eval-flags-*-)"; 3393 const struct command_switch *cs; 3319 3394 char *flagstring; 3320 3395 register char *p; … … 3337 3412 #define ADD_FLAG(ARG, LEN) \ 3338 3413 do { \ 3339 struct flag *new = alloca (sizeof (struct flag)); 3414 struct flag *new = alloca (sizeof (struct flag)); \ 3340 3415 new->cs = cs; \ 3341 3416 new->arg = (ARG); \ … … 3345 3420 ++flagslen; /* Just a single flag letter. */ \ 3346 3421 else \ 3347 flagslen += 1 + 1 + 1 + 1 + 3 * (LEN); /* " -x foo" */ \ 3422 /* " -x foo", plus space to expand "foo". */ \ 3423 flagslen += 1 + 1 + 1 + 1 + (3 * (LEN)); \ 3348 3424 if (!short_option (cs->c)) \ 3349 3425 /* This switch has no single-letter version, so we use the long. */ \ … … 3434 3510 } 3435 3511 3436 flagslen += 4 + sizeof posixref; /* Four more for the possible " -- ". */ 3512 /* Four more for the possible " -- ". */ 3513 flagslen += 4 + sizeof (posixref) + sizeof (evalref); 3437 3514 3438 3515 #undef ADD_FLAG … … 3507 3584 /* Since MFLAGS is not parsed for flags, there is no reason to 3508 3585 override any makefile redefinition. */ 3509 (void) define_variable ("MFLAGS", 6, flagstring, o_env, 1);3586 define_variable_cname ("MFLAGS", flagstring, o_env, 1); 3510 3587 #endif /* !KMK */ 3588 3589 /* Write a reference to -*-eval-flags-*-, which contains all the --eval 3590 flag options. */ 3591 if (eval_strings) 3592 { 3593 if (p == &flagstring[1]) 3594 /* No flags written, so elide the leading dash already written. */ 3595 p = flagstring; 3596 else 3597 *p++ = ' '; 3598 memcpy (p, evalref, sizeof (evalref) - 1); 3599 p += sizeof (evalref) - 1; 3600 } 3511 3601 3512 3602 if (all && command_variables != 0) … … 3535 3625 if (posix_pedantic) 3536 3626 { 3537 memcpy (p, posixref, sizeof posixref- 1);3538 p += sizeof posixref- 1;3627 memcpy (p, posixref, sizeof (posixref) - 1); 3628 p += sizeof (posixref) - 1; 3539 3629 } 3540 3630 else 3541 3631 { 3542 memcpy (p, ref, sizeof ref- 1);3543 p += sizeof ref- 1;3632 memcpy (p, ref, sizeof (ref) - 1); 3633 p += sizeof (ref) - 1; 3544 3634 } 3545 3635 } … … 3555 3645 *p = '\0'; 3556 3646 3647 /* If there are switches, omit the leading dash unless it is a single long 3648 option with two leading dashes. */ 3649 if (flagstring[0] == '-' && flagstring[1] != '-') 3650 ++flagstring; 3651 3557 3652 #ifdef KMK 3558 v = define_variable ("KMK_FLAGS", 9, 3559 /* If there are switches, omit the leading dash 3560 unless it is a single long option with two 3561 leading dashes. */ 3562 &flagstring[(flagstring[0] == '-' 3563 && flagstring[1] != '-') 3564 ? 1 : 0], 3565 /* This used to use o_env, but that lost when a 3566 makefile defined MAKEFLAGS. Makefiles set 3567 MAKEFLAGS to add switches, but we still want 3568 to redefine its value with the full set of 3569 switches. Of course, an override or command 3570 definition will still take precedence. */ 3571 o_file, 1); 3653 v = define_variable_cname ("KMK_FLAGS", flagstring, 3654 /* This used to use o_env, but that lost when a 3655 makefile defined MAKEFLAGS. Makefiles set 3656 MAKEFLAGS to add switches, but we still want 3657 to redefine its value with the full set of 3658 switches. Of course, an override or command 3659 definition will still take precedence. */ 3660 o_file, 1); 3572 3661 #else 3573 v = define_variable ("MAKEFLAGS", 9, 3574 /* If there are switches, omit the leading dash 3575 unless it is a single long option with two 3576 leading dashes. */ 3577 &flagstring[(flagstring[0] == '-' 3578 && flagstring[1] != '-') 3579 ? 1 : 0], 3580 /* This used to use o_env, but that lost when a 3581 makefile defined MAKEFLAGS. Makefiles set 3582 MAKEFLAGS to add switches, but we still want 3583 to redefine its value with the full set of 3584 switches. Of course, an override or command 3585 definition will still take precedence. */ 3586 o_file, 1); 3587 #endif 3662 v = define_variable_cname ("MAKEFLAGS", flagstring, 3663 /* This used to use o_env, but that lost when a 3664 makefile defined MAKEFLAGS. Makefiles set 3665 MAKEFLAGS to add switches, but we still want 3666 to redefine its value with the full set of 3667 switches. Of course, an override or command 3668 definition will still take precedence. */ 3669 o_file, 1); 3670 #endif 3671 3588 3672 if (! all) 3589 3673 /* The first time we are called, set MAKEFLAGS to always be exported. … … 3597 3681 char val[32]; 3598 3682 sprintf (val, "%u", job_slots); 3599 define_variable ("KMK_OPTS_JOBS", sizeof("KMK_OPTS_JOBS") - 1, 3600 val, o_default, 1); 3601 define_variable ("KMK_OPTS_KEEP_GOING", sizeof("KMK_OPTS_KEEP_GOING") - 1, 3602 keep_going_flag ? "1" : "0", o_default, 1); 3603 define_variable ("KMK_OPTS_JUST_PRINT", sizeof("KMK_OPTS_JUST_PRINT") - 1, 3604 just_print_flag ? "1" : "0", o_default, 1); 3605 define_variable ("KMK_OPTS_PRETTY_COMMAND_PRINTING", sizeof("KMK_OPTS_PRETTY_COMMAND_PRINTING") - 1, 3606 pretty_command_printing ? "1" : "0", o_default, 1); 3683 define_variable_cname ("KMK_OPTS_JOBS", val, o_default, 1); 3684 define_variable_cname ("KMK_OPTS_KEEP_GOING", keep_going_flag ? "1" : "0", o_default, 1); 3685 define_variable_cname ("KMK_OPTS_JUST_PRINT", just_print_flag ? "1" : "0", o_default, 1); 3686 define_variable_cname ("KMK_OPTS_PRETTY_COMMAND_PRINTING", 3687 pretty_command_printing ? "1" : "0", o_default, 1); 3607 3688 sprintf (val, "%u", process_priority); 3608 define_variable ("KMK_OPTS_PRORITY", sizeof("KMK_OPTS_PRORITY") - 1, 3609 val, o_default, 1); 3689 define_variable_cname ("KMK_OPTS_PRORITY", val, o_default, 1); 3610 3690 sprintf (val, "%u", process_affinity); 3611 define_variable ("KMK_OPTS_AFFINITY", sizeof("KMK_OPTS_AFFINITY") - 1, 3612 val, o_default, 1); 3613 #if defined (CONFIG_WITH_MAKE_STATS) || defined (CONFIG_WITH_MINIMAL_STATS) 3614 define_variable ("KMK_OPTS_STATISTICS", sizeof("KMK_OPTS_STATISTICS") - 1, 3615 make_expensive_statistics ? "1" : "0", o_default, 1); 3691 define_variable_cname ("KMK_OPTS_AFFINITY", val, o_default, 1); 3692 # if defined (CONFIG_WITH_MAKE_STATS) || defined (CONFIG_WITH_MINIMAL_STATS) 3693 define_variable_cname ("KMK_OPTS_STATISTICS", make_expensive_statistics ? "1" : "0", 3694 o_default, 1); 3616 3695 # endif 3617 # ifdef CONFIG_WITH_PRINT_TIME_SWITCH3696 # ifdef CONFIG_WITH_PRINT_TIME_SWITCH 3618 3697 sprintf (val, "%u", print_time_min); 3619 define_variable ("KMK_OPTS_PRINT_TIME", sizeof("KMK_OPTS_PRINT_TIME") - 1, 3620 val, o_default, 1); 3621 #endif 3698 define_variable_cname ("KMK_OPTS_PRINT_TIME", val, o_default, 1); 3699 # endif 3622 3700 } 3623 3701 #endif 3702 3703 return v->value; 3624 3704 } 3625 3705 … … 3661 3741 word "Copyright", so it hardly seems worth it. */ 3662 3742 3663 printf ("%sCopyright (C) 20 07Free Software Foundation, Inc.\n", precede);3743 printf ("%sCopyright (C) 2010 Free Software Foundation, Inc.\n", precede); 3664 3744 3665 3745 printf (_("%sLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\ … … 3818 3898 3819 3899 close (job_fds[0]); 3900 3901 /* Clean out jobserver_fds so we don't pass this information to any 3902 sub-makes. Also reset job_slots since it will be put on the command 3903 line, not in MAKEFLAGS. */ 3904 job_slots = default_job_slots; 3905 if (jobserver_fds) 3906 { 3907 /* MSVC erroneously warns without a cast here. */ 3908 free ((void *)jobserver_fds->list); 3909 free (jobserver_fds); 3910 jobserver_fds = 0; 3911 } 3820 3912 } 3821 3913 } … … 3882 3974 of relative pathnames fail. */ 3883 3975 if (directory_before_chdir != 0) 3884 chdir (directory_before_chdir); 3976 { 3977 /* If it fails we don't care: shut up GCC. */ 3978 int _x; 3979 _x = chdir (directory_before_chdir); 3980 } 3885 3981 3886 3982 #ifdef CONFIG_WITH_PRINT_TIME_SWITCH
Note:
See TracChangeset
for help on using the changeset viewer.