Changeset 2596 for vendor/gnumake/current/main.c
- Timestamp:
- Jun 20, 2012, 12:44:52 AM (13 years ago)
- Location:
- vendor/gnumake/current
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/gnumake/current
- Property svn:ignore deleted
-
vendor/gnumake/current/main.c
r1989 r2596 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 … … 45 45 #endif 46 46 47 #if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)48 # define SET_STACK_SIZE49 #endif50 51 #ifdef SET_STACK_SIZE52 # include <sys/resource.h>53 #endif54 55 47 #ifdef _AMIGA 56 48 int __stack = 20000; /* Make sure we have 20K of stack space */ … … 65 57 void print_dir_data_base (void); 66 58 void print_rule_data_base (void); 67 void print_file_data_base (void);68 59 void print_vpath_data_base (void); 69 60 … … 89 80 static void decode_switches (int argc, char **argv, int env); 90 81 static void decode_env_switches (char *envar, unsigned int len); 91 static voiddefine_makeflags (int all, int makefile);82 static const char *define_makeflags (int all, int makefile); 92 83 static char *quote_for_env (char *out, const char *in); 93 84 static void initialize_global_hash_tables (void); … … 222 213 static struct stringlist *makefiles = 0; 223 214 215 /* Size of the stack when we started. */ 216 217 #ifdef SET_STACK_SIZE 218 struct rlimit stack_limit; 219 #endif 220 221 224 222 /* Number of job slots (commands that can be run at once). */ 225 223 … … 266 264 267 265 static struct stringlist *new_files = 0; 266 267 /* List of strings to be eval'd. */ 268 static struct stringlist *eval_strings = 0; 268 269 269 270 /* If nonzero, we should just print usage and exit. */ … … 317 318 -e, --environment-overrides\n\ 318 319 Environment variables override makefiles.\n"), 320 N_("\ 321 --eval=STRING Evaluate STRING as a makefile statement.\n"), 319 322 N_("\ 320 323 -f FILE, --file=FILE, --makefile=FILE\n\ … … 423 426 { CHAR_MAX+5, flag, &warn_undefined_variables_flag, 1, 1, 0, 0, 0, 424 427 "warn-undefined-variables" }, 428 { CHAR_MAX+6, string, &eval_strings, 1, 0, 0, 0, 0, "eval" }, 425 429 { 0, 0, 0, 0, 0, 0, 0, 0, 0 } 426 430 }; … … 472 476 unsigned int makelevel; 473 477 474 /* First file defined in the makefile whose name does not 475 start with `.'. This is the default to remake if the 476 command line does not specify. */ 477 478 struct file *default_goal_file; 479 480 /* Pointer to the value of the .DEFAULT_GOAL special 481 variable. */ 482 char ** default_goal_name; 478 /* Pointer to the value of the .DEFAULT_GOAL special variable. 479 The value will be the name of the goal to remake if the command line 480 does not override it. It can be set by the makefile, or else it's 481 the first target defined in the makefile whose name does not start 482 with '.'. */ 483 484 struct variable * default_goal_var; 483 485 484 486 /* Pointer to structure for the file .DEFAULT … … 497 499 498 500 int second_expansion; 501 502 /* Nonzero if we have seen the '.ONESHELL' target. 503 This causes the entire recipe to be handed to SHELL 504 as a single string, potentially containing newlines. */ 505 506 int one_shell; 499 507 500 508 /* Nonzero if we have seen the `.NOTPARALLEL' target. … … 520 528 #endif 521 529 522 #if ! defined HAVE_BSD_SIGNAL && !defined bsd_signal530 #if !HAVE_DECL_BSD_SIGNAL && !defined bsd_signal 523 531 # if !defined HAVE_SIGACTION 524 532 # define bsd_signal signal 525 533 # else 526 typedef RETSIGTYPE (*bsd_signal_ret_t) ( );534 typedef RETSIGTYPE (*bsd_signal_ret_t) (int); 527 535 528 536 static bsd_signal_ret_t … … 684 692 { 685 693 sprintf(errmsg, 686 _("%s: Interrupt/Exception caught (code = 0x%lx, addr = 0x% lx)\n"),687 prg, exrec->ExceptionCode, (DWORD)exrec->ExceptionAddress);694 _("%s: Interrupt/Exception caught (code = 0x%lx, addr = 0x%p)\n"), 695 prg, exrec->ExceptionCode, exrec->ExceptionAddress); 688 696 fprintf(stderr, errmsg); 689 697 exit(255); … … 691 699 692 700 sprintf(errmsg, 693 _("\nUnhandled exception filter called from program %s\nExceptionCode = %lx\nExceptionFlags = %lx\nExceptionAddress = %lx\n"),701 _("\nUnhandled exception filter called from program %s\nExceptionCode = %lx\nExceptionFlags = %lx\nExceptionAddress = 0x%p\n"), 694 702 prg, exrec->ExceptionCode, exrec->ExceptionFlags, 695 (DWORD)exrec->ExceptionAddress);703 exrec->ExceptionAddress); 696 704 697 705 if (exrec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION … … 699 707 sprintf(&errmsg[strlen(errmsg)], 700 708 (exrec->ExceptionInformation[0] 701 ? _("Access violation: write operation at address %lx\n")702 : _("Access violation: read operation at address %lx\n")),703 exrec->ExceptionInformation[1]);709 ? _("Access violation: write operation at address 0x%p\n") 710 : _("Access violation: read operation at address 0x%p\n")), 711 (PVOID)exrec->ExceptionInformation[1]); 704 712 705 713 /* turn this on if we want to put stuff in the event log too */ … … 775 783 sprintf (sh_path, "%s", search_token); 776 784 default_shell = xstrdup (w32ify (sh_path, 0)); 777 DB (DB_VERBOSE, 778 (_("find_and_set_shell setting default_shell = %s\n"),default_shell));785 DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"), 786 default_shell)); 779 787 sh_found = 1; 780 788 } else if (!no_default_sh_exe && … … 786 794 sprintf (sh_path, "%s", search_token); 787 795 default_shell = xstrdup (w32ify (sh_path, 0)); 788 DB (DB_VERBOSE, 789 (_("find_and_set_shell setting default_shell = %s\n"),default_shell));796 DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"), 797 default_shell)); 790 798 sh_found = 1; 791 799 } else { … … 828 836 if (sh_found) 829 837 DB (DB_VERBOSE, 830 (_("find_and_set_shell path search set default_shell = %s\n"),838 (_("find_and_set_shell() path search set default_shell = %s\n"), 831 839 default_shell)); 832 840 } … … 935 943 936 944 /* Set the stack limit huge so that alloca does not fail. */ 937 if (getrlimit (RLIMIT_STACK, &rlim) == 0) 945 if (getrlimit (RLIMIT_STACK, &rlim) == 0 946 && rlim.rlim_cur > 0 && rlim.rlim_cur < rlim.rlim_max) 938 947 { 948 stack_limit = rlim; 939 949 rlim.rlim_cur = rlim.rlim_max; 940 950 setrlimit (RLIMIT_STACK, &rlim); 941 951 } 952 else 953 stack_limit.rlim_cur = 0; 942 954 } 943 955 #endif … … 950 962 initialize_main(&argc, &argv); 951 963 952 default_goal_file = 0;953 964 reading_file = 0; 954 965 … … 967 978 /* Set up gettext/internationalization support. */ 968 979 setlocale (LC_ALL, ""); 969 bindtextdomain (PACKAGE, LOCALEDIR); 970 textdomain (PACKAGE); 980 /* The cast to void shuts up compiler warnings on systems that 981 disable NLS. */ 982 (void)bindtextdomain (PACKAGE, LOCALEDIR); 983 (void)textdomain (PACKAGE); 971 984 972 985 #ifdef POSIX … … 978 991 #define ADD_SIG(sig) fatal_signal_mask |= sigmask (sig) 979 992 #else 980 #define ADD_SIG(sig) 993 #define ADD_SIG(sig) (void)sig /* Needed to avoid warnings in MSVC. */ 981 994 #endif 982 995 #endif … … 1120 1133 1121 1134 /* Initialize the special variables. */ 1122 define_variable (".VARIABLES", 10, "", o_default, 0)->special = 1; 1123 /* define_variable (".TARGETS", 8, "", o_default, 0)->special = 1; */ 1124 define_variable (".RECIPEPREFIX", 13, "", o_default, 0)->special = 1; 1125 1126 /* Set up .FEATURES */ 1127 define_variable (".FEATURES", 9, 1128 "target-specific order-only second-expansion else-if", 1129 o_default, 0); 1135 define_variable_cname (".VARIABLES", "", o_default, 0)->special = 1; 1136 /* define_variable_cname (".TARGETS", "", o_default, 0)->special = 1; */ 1137 define_variable_cname (".RECIPEPREFIX", "", o_default, 0)->special = 1; 1138 define_variable_cname (".SHELLFLAGS", "-c", o_default, 0); 1139 1140 /* Set up .FEATURES 1141 We must do this in multiple calls because define_variable_cname() is 1142 a macro and some compilers (MSVC) don't like conditionals in macros. */ 1143 { 1144 const char *features = "target-specific order-only second-expansion" 1145 " else-if shortest-stem undefine" 1130 1146 #ifndef NO_ARCHIVES 1131 do_variable_definition (NILF, ".FEATURES", "archives", 1132 o_default, f_append, 0); 1147 " archives" 1133 1148 #endif 1134 1149 #ifdef MAKE_JOBSERVER 1135 do_variable_definition (NILF, ".FEATURES", "jobserver", 1136 o_default, f_append, 0); 1150 " jobserver" 1137 1151 #endif 1138 1152 #ifdef MAKE_SYMLINKS 1139 do_variable_definition (NILF, ".FEATURES", "check-symlink", 1140 o_default, f_append, 0); 1141 #endif 1153 " check-symlink" 1154 #endif 1155 ; 1156 1157 define_variable_cname (".FEATURES", features, o_default, 0); 1158 } 1142 1159 1143 1160 /* Read in variables from the environment. It is important that this be … … 1191 1208 #endif 1192 1209 shell_var.name = "SHELL"; 1210 shell_var.length = 5; 1193 1211 shell_var.value = xstrdup (ep + 1); 1194 1212 } … … 1208 1226 */ 1209 1227 if (!unix_path) 1210 define_variable("PATH", 4, 1211 windows32_path ? windows32_path : "", 1212 o_env, 1)->export = v_export; 1228 define_variable_cname ("PATH", windows32_path ? windows32_path : "", 1229 o_env, 1)->export = v_export; 1213 1230 #endif 1214 1231 #else /* For Amiga, read the ENV: device, ignoring all dirs */ … … 1252 1269 decode_env_switches (STRING_SIZE_TUPLE ("MFLAGS")); 1253 1270 #endif 1271 1254 1272 decode_switches (argc, argv, 0); 1273 1255 1274 #ifdef WINDOWS32 1256 1275 if (suspend_flag) { … … 1316 1335 # endif 1317 1336 ) 1318 argv[0] = xstrdup (concat ( current_directory, "/", argv[0]));1337 argv[0] = xstrdup (concat (3, current_directory, "/", argv[0])); 1319 1338 #else /* !__MSDOS__ */ 1320 1339 if (current_directory[0] != '\0' … … 1325 1344 #endif 1326 1345 ) 1327 argv[0] = xstrdup (concat ( current_directory, "/", argv[0]));1346 argv[0] = xstrdup (concat (3, current_directory, "/", argv[0])); 1328 1347 #endif /* !__MSDOS__ */ 1329 1348 #endif /* WINDOWS32 */ … … 1332 1351 /* The extra indirection through $(MAKE_COMMAND) is done 1333 1352 for hysterical raisins. */ 1334 (void) define_variable ("MAKE_COMMAND", 12, argv[0], o_default, 0);1335 (void) define_variable ("MAKE", 4, "$(MAKE_COMMAND)", o_default, 1);1353 define_variable_cname ("MAKE_COMMAND", argv[0], o_default, 0); 1354 define_variable_cname ("MAKE", "$(MAKE_COMMAND)", o_default, 1); 1336 1355 1337 1356 if (command_variables != 0) … … 1371 1390 /* Define an unchangeable variable with a name that no POSIX.2 1372 1391 makefile could validly use for its own variable. */ 1373 (void) define_variable ("-*-command-variables-*-", 23, 1374 value, o_automatic, 0); 1392 define_variable_cname ("-*-command-variables-*-", value, o_automatic, 0); 1375 1393 1376 1394 /* Define the variable; this will not override any user definition. … … 1380 1398 allow the user's setting of MAKEOVERRIDES to affect MAKEFLAGS, so 1381 1399 a reference to this hidden variable is written instead. */ 1382 (void) define_variable ("MAKEOVERRIDES", 13,1383 "${-*-command-variables-*-}",o_env, 1);1400 define_variable_cname ("MAKEOVERRIDES", "${-*-command-variables-*-}", 1401 o_env, 1); 1384 1402 } 1385 1403 … … 1395 1413 But allow -C/ just in case someone wants that. */ 1396 1414 { 1397 char *p = dir + strlen (dir) - 1;1415 char *p = (char *)dir + strlen (dir) - 1; 1398 1416 while (p > dir && (p[0] == '/' || p[0] == '\\')) 1399 1417 --p; … … 1468 1486 } 1469 1487 1470 (void) define_variable ("CURDIR", 6, current_directory, o_file, 0);1488 define_variable_cname ("CURDIR", current_directory, o_file, 0); 1471 1489 1472 1490 /* Read any stdin makefiles into temporary files. */ … … 1608 1626 default_file = enter_file (strcache_add (".DEFAULT")); 1609 1627 1610 { 1611 struct variable *v = define_variable (".DEFAULT_GOAL", 13, "", o_file, 0); 1612 default_goal_name = &v->value; 1613 } 1628 default_goal_var = define_variable_cname (".DEFAULT_GOAL", "", o_file, 0); 1629 1630 /* Evaluate all strings provided with --eval. 1631 Also set up the $(-*-eval-flags-*-) variable. */ 1632 1633 if (eval_strings) 1634 { 1635 char *p, *value; 1636 unsigned int i; 1637 unsigned int len = sizeof ("--eval=") * eval_strings->idx; 1638 1639 for (i = 0; i < eval_strings->idx; ++i) 1640 { 1641 p = xstrdup (eval_strings->list[i]); 1642 len += 2 * strlen (p); 1643 eval_buffer (p); 1644 free (p); 1645 } 1646 1647 p = value = alloca (len); 1648 for (i = 0; i < eval_strings->idx; ++i) 1649 { 1650 strcpy (p, "--eval="); 1651 p += strlen (p); 1652 p = quote_for_env (p, eval_strings->list[i]); 1653 *(p++) = ' '; 1654 } 1655 p[-1] = '\0'; 1656 1657 define_variable_cname ("-*-eval-flags-*-", value, o_automatic, 0); 1658 } 1614 1659 1615 1660 /* Read all the makefiles. */ … … 1670 1715 1671 1716 if (jobserver_fds) 1672 { 1673 const char *cp; 1674 unsigned int ui; 1675 1676 for (ui=1; ui < jobserver_fds->idx; ++ui) 1677 if (!streq (jobserver_fds->list[0], jobserver_fds->list[ui])) 1678 fatal (NILF, _("internal error: multiple --jobserver-fds options")); 1679 1680 /* Now parse the fds string and make sure it has the proper format. */ 1681 1682 cp = jobserver_fds->list[0]; 1683 1684 if (sscanf (cp, "%d,%d", &job_fds[0], &job_fds[1]) != 2) 1685 fatal (NILF, 1686 _("internal error: invalid --jobserver-fds string `%s'"), cp); 1687 1688 DB (DB_JOBS, 1689 (_("Jobserver client (fds %d,%d)\n"), job_fds[0], job_fds[1])); 1690 1691 /* The combination of a pipe + !job_slots means we're using the 1692 jobserver. If !job_slots and we don't have a pipe, we can start 1693 infinite jobs. If we see both a pipe and job_slots >0 that means the 1694 user set -j explicitly. This is broken; in this case obey the user 1695 (ignore the jobserver pipe for this make) but print a message. */ 1696 1697 if (job_slots > 0) 1698 error (NILF, 1699 _("warning: -jN forced in submake: disabling jobserver mode.")); 1700 1701 /* Create a duplicate pipe, that will be closed in the SIGCHLD 1702 handler. If this fails with EBADF, the parent has closed the pipe 1703 on us because it didn't think we were a submake. If so, print a 1704 warning then default to -j1. */ 1705 1706 else if ((job_rfd = dup (job_fds[0])) < 0) 1707 { 1708 if (errno != EBADF) 1709 pfatal_with_name (_("dup jobserver")); 1710 1717 { 1718 const char *cp; 1719 unsigned int ui; 1720 1721 for (ui=1; ui < jobserver_fds->idx; ++ui) 1722 if (!streq (jobserver_fds->list[0], jobserver_fds->list[ui])) 1723 fatal (NILF, _("internal error: multiple --jobserver-fds options")); 1724 1725 /* Now parse the fds string and make sure it has the proper format. */ 1726 1727 cp = jobserver_fds->list[0]; 1728 1729 if (sscanf (cp, "%d,%d", &job_fds[0], &job_fds[1]) != 2) 1730 fatal (NILF, 1731 _("internal error: invalid --jobserver-fds string `%s'"), cp); 1732 1733 DB (DB_JOBS, 1734 (_("Jobserver client (fds %d,%d)\n"), job_fds[0], job_fds[1])); 1735 1736 /* The combination of a pipe + !job_slots means we're using the 1737 jobserver. If !job_slots and we don't have a pipe, we can start 1738 infinite jobs. If we see both a pipe and job_slots >0 that means the 1739 user set -j explicitly. This is broken; in this case obey the user 1740 (ignore the jobserver pipe for this make) but print a message. */ 1741 1742 if (job_slots > 0) 1711 1743 error (NILF, 1712 _("warning: jobserver unavailable: using -j1. Add `+' to parent make rule.")); 1713 job_slots = 1; 1714 } 1715 1716 if (job_slots > 0) 1717 { 1718 close (job_fds[0]); 1719 close (job_fds[1]); 1720 job_fds[0] = job_fds[1] = -1; 1721 free (jobserver_fds->list); 1722 free (jobserver_fds); 1723 jobserver_fds = 0; 1724 } 1725 } 1744 _("warning: -jN forced in submake: disabling jobserver mode.")); 1745 1746 /* Create a duplicate pipe, that will be closed in the SIGCHLD 1747 handler. If this fails with EBADF, the parent has closed the pipe 1748 on us because it didn't think we were a submake. If so, print a 1749 warning then default to -j1. */ 1750 1751 else if ((job_rfd = dup (job_fds[0])) < 0) 1752 { 1753 if (errno != EBADF) 1754 pfatal_with_name (_("dup jobserver")); 1755 1756 error (NILF, 1757 _("warning: jobserver unavailable: using -j1. Add `+' to parent make rule.")); 1758 job_slots = 1; 1759 } 1760 1761 if (job_slots > 0) 1762 { 1763 close (job_fds[0]); 1764 close (job_fds[1]); 1765 job_fds[0] = job_fds[1] = -1; 1766 free (jobserver_fds->list); 1767 free (jobserver_fds); 1768 jobserver_fds = 0; 1769 } 1770 } 1726 1771 1727 1772 /* If we have >1 slot but no jobserver-fds, then we're a top-level make. … … 1841 1886 FILE_TIMESTAMP *makefile_mtimes = 0; 1842 1887 unsigned int mm_idx = 0; 1843 char **nargv = argv;1844 int nargc = argc;1888 char **nargv; 1889 int nargc; 1845 1890 int orig_db_level = db_level; 1846 1891 int status; … … 2011 2056 if (strneq (argv[i], "-f", 2)) /* XXX */ 2012 2057 { 2013 char *p = &argv[i][2]; 2014 if (*p == '\0') 2058 if (argv[i][2] == '\0') 2015 2059 /* This cast is OK since we never modify argv. */ 2016 2060 argv[++i] = (char *) makefiles->list[j]; 2017 2061 else 2018 argv[i] = xstrdup (concat ( "-f", makefiles->list[j], ""));2062 argv[i] = xstrdup (concat (2, "-f", makefiles->list[j])); 2019 2063 ++j; 2020 2064 } … … 2022 2066 2023 2067 /* Add -o option for the stdin temporary file, if necessary. */ 2068 nargc = argc; 2024 2069 if (stdin_nm) 2025 2070 { 2026 2071 nargv = xmalloc ((nargc + 2) * sizeof (char *)); 2027 2072 memcpy (nargv, argv, argc * sizeof (char *)); 2028 nargv[nargc++] = xstrdup (concat ( "-o", stdin_nm, ""));2073 nargv[nargc++] = xstrdup (concat (2, "-o", stdin_nm)); 2029 2074 nargv[nargc] = 0; 2030 2075 } 2076 else 2077 nargv = argv; 2031 2078 2032 2079 if (directories != 0 && directories->idx > 0) … … 2045 2092 2046 2093 ++restarts; 2094 2095 /* Reset makeflags in case they were changed. */ 2096 { 2097 const char *pv = define_makeflags (1, 1); 2098 char *p = alloca (sizeof ("MAKEFLAGS=") + strlen (pv) + 1); 2099 sprintf (p, "MAKEFLAGS=%s", pv); 2100 putenv (p); 2101 } 2047 2102 2048 2103 if (ISDB (DB_BASIC)) … … 2164 2219 perror_with_name (_("unlink (temporary file): "), stdin_nm); 2165 2220 2221 /* If there were no command-line goals, use the default. */ 2222 if (goals == 0) 2223 { 2224 char *p; 2225 2226 if (default_goal_var->recursive) 2227 p = variable_expand (default_goal_var->value); 2228 else 2229 { 2230 p = variable_buffer_output (variable_buffer, default_goal_var->value, 2231 strlen (default_goal_var->value)); 2232 *p = '\0'; 2233 p = variable_buffer; 2234 } 2235 2236 if (*p != '\0') 2237 { 2238 struct file *f = lookup_file (p); 2239 2240 /* If .DEFAULT_GOAL is a non-existent target, enter it into the 2241 table and let the standard logic sort it out. */ 2242 if (f == 0) 2243 { 2244 struct nameseq *ns; 2245 2246 ns = PARSE_FILE_SEQ (&p, struct nameseq, '\0', NULL, 0); 2247 if (ns) 2248 { 2249 /* .DEFAULT_GOAL should contain one target. */ 2250 if (ns->next != 0) 2251 fatal (NILF, _(".DEFAULT_GOAL contains more than one target")); 2252 2253 f = enter_file (strcache_add (ns->name)); 2254 2255 ns->name = 0; /* It was reused by enter_file(). */ 2256 free_ns_chain (ns); 2257 } 2258 } 2259 2260 if (f) 2261 { 2262 goals = alloc_dep (); 2263 goals->file = f; 2264 } 2265 } 2266 } 2267 else 2268 lastgoal->next = 0; 2269 2270 2271 if (!goals) 2272 { 2273 if (read_makefiles == 0) 2274 fatal (NILF, _("No targets specified and no makefile found")); 2275 2276 fatal (NILF, _("No targets")); 2277 } 2278 2279 /* Update the goals. */ 2280 2281 DB (DB_BASIC, (_("Updating goal targets....\n"))); 2282 2166 2283 { 2167 2284 int status; 2168 2169 /* If there were no command-line goals, use the default. */2170 if (goals == 0)2171 {2172 if (**default_goal_name != '\0')2173 {2174 if (default_goal_file == 0 ||2175 strcmp (*default_goal_name, default_goal_file->name) != 0)2176 {2177 default_goal_file = lookup_file (*default_goal_name);2178 2179 /* In case user set .DEFAULT_GOAL to a non-existent target2180 name let's just enter this name into the table and let2181 the standard logic sort it out. */2182 if (default_goal_file == 0)2183 {2184 struct nameseq *ns;2185 char *p = *default_goal_name;2186 2187 ns = multi_glob (2188 parse_file_seq (&p, '\0', sizeof (struct nameseq), 1),2189 sizeof (struct nameseq));2190 2191 /* .DEFAULT_GOAL should contain one target. */2192 if (ns->next != 0)2193 fatal (NILF, _(".DEFAULT_GOAL contains more than one target"));2194 2195 default_goal_file = enter_file (strcache_add (ns->name));2196 2197 ns->name = 0; /* It was reused by enter_file(). */2198 free_ns_chain (ns);2199 }2200 }2201 2202 goals = alloc_dep ();2203 goals->file = default_goal_file;2204 }2205 }2206 else2207 lastgoal->next = 0;2208 2209 2210 if (!goals)2211 {2212 if (read_makefiles == 0)2213 fatal (NILF, _("No targets specified and no makefile found"));2214 2215 fatal (NILF, _("No targets"));2216 }2217 2218 /* Update the goals. */2219 2220 DB (DB_BASIC, (_("Updating goal targets....\n")));2221 2285 2222 2286 switch (update_goal_chain (goals)) … … 2391 2455 value = vp; 2392 2456 } 2393 define_variable ("MAKECMDGOALS", 12, value, o_default, 0);2457 define_variable_cname ("MAKECMDGOALS", value, o_default, 0); 2394 2458 } 2395 2459 } … … 2493 2557 else if (*optarg == '\0') 2494 2558 { 2495 error (NILF, _("the `-%c' option requires a non-empty string argument"), 2496 cs->c); 2559 char opt[2] = "c"; 2560 const char *op = opt; 2561 2562 if (short_option (cs->c)) 2563 opt[0] = cs->c; 2564 else 2565 op = cs->long_name; 2566 2567 error (NILF, _("the `%s%s' option requires a non-empty string argument"), 2568 short_option (cs->c) ? "-" : "--", op); 2497 2569 bad = 1; 2498 2570 } … … 2511 2583 { 2512 2584 sl->max += 5; 2513 sl->list = xrealloc (sl->list, 2585 /* MSVC erroneously warns without a cast here. */ 2586 sl->list = xrealloc ((void *)sl->list, 2514 2587 sl->max * sizeof (char *)); 2515 2588 } … … 2658 2731 need permanent storage for this in case decode_switches saves 2659 2732 pointers into the value. */ 2660 argv[1] = xstrdup (concat ( "-", argv[1], ""));2733 argv[1] = xstrdup (concat (2, "-", argv[1])); 2661 2734 2662 2735 /* Parse those words. */ … … 2690 2763 Don't include options with the `no_makefile' flag set if MAKEFILE. */ 2691 2764 2692 static void2765 static const char * 2693 2766 define_makeflags (int all, int makefile) 2694 2767 { 2695 static const char ref[] = "$(MAKEOVERRIDES)"; 2696 static const char posixref[] = "$(-*-command-variables-*-)"; 2697 register const struct command_switch *cs; 2768 const char ref[] = "$(MAKEOVERRIDES)"; 2769 const char posixref[] = "$(-*-command-variables-*-)"; 2770 const char evalref[] = "$(-*-eval-flags-*-)"; 2771 const struct command_switch *cs; 2698 2772 char *flagstring; 2699 2773 register char *p; … … 2716 2790 #define ADD_FLAG(ARG, LEN) \ 2717 2791 do { \ 2718 struct flag *new = alloca (sizeof (struct flag)); 2792 struct flag *new = alloca (sizeof (struct flag)); \ 2719 2793 new->cs = cs; \ 2720 2794 new->arg = (ARG); \ … … 2724 2798 ++flagslen; /* Just a single flag letter. */ \ 2725 2799 else \ 2726 flagslen += 1 + 1 + 1 + 1 + 3 * (LEN); /* " -x foo" */ \ 2800 /* " -x foo", plus space to expand "foo". */ \ 2801 flagslen += 1 + 1 + 1 + 1 + (3 * (LEN)); \ 2727 2802 if (!short_option (cs->c)) \ 2728 2803 /* This switch has no single-letter version, so we use the long. */ \ … … 2811 2886 } 2812 2887 2813 flagslen += 4 + sizeof posixref; /* Four more for the possible " -- ". */ 2888 /* Four more for the possible " -- ". */ 2889 flagslen += 4 + sizeof (posixref) + sizeof (evalref); 2814 2890 2815 2891 #undef ADD_FLAG … … 2883 2959 /* Since MFLAGS is not parsed for flags, there is no reason to 2884 2960 override any makefile redefinition. */ 2885 (void) define_variable ("MFLAGS", 6, flagstring, o_env, 1); 2961 define_variable_cname ("MFLAGS", flagstring, o_env, 1); 2962 2963 /* Write a reference to -*-eval-flags-*-, which contains all the --eval 2964 flag options. */ 2965 if (eval_strings) 2966 { 2967 if (p == &flagstring[1]) 2968 /* No flags written, so elide the leading dash already written. */ 2969 p = flagstring; 2970 else 2971 *p++ = ' '; 2972 memcpy (p, evalref, sizeof (evalref) - 1); 2973 p += sizeof (evalref) - 1; 2974 } 2886 2975 2887 2976 if (all && command_variables != 0) … … 2910 2999 if (posix_pedantic) 2911 3000 { 2912 memcpy (p, posixref, sizeof posixref- 1);2913 p += sizeof posixref- 1;3001 memcpy (p, posixref, sizeof (posixref) - 1); 3002 p += sizeof (posixref) - 1; 2914 3003 } 2915 3004 else 2916 3005 { 2917 memcpy (p, ref, sizeof ref- 1);2918 p += sizeof ref- 1;3006 memcpy (p, ref, sizeof (ref) - 1); 3007 p += sizeof (ref) - 1; 2919 3008 } 2920 3009 } … … 2930 3019 *p = '\0'; 2931 3020 2932 v = define_variable ("MAKEFLAGS", 9,2933 /* If there are switches, omit the leading dash 2934 unless it is a single long option with two 2935 leading dashes. */ 2936 &flagstring[(flagstring[0] == '-' 2937 && flagstring[1] != '-') 2938 ? 1 : 0], 2939 /* This used to use o_env, but that lost when a 2940 makefile defined MAKEFLAGS. Makefiles set2941 MAKEFLAGS to add switches, but we still want 2942 to redefine its value with the full set of 2943 switches. Of course, an override or command 2944 definition will still take precedence. */ 2945 o_file, 1); 3021 /* If there are switches, omit the leading dash unless it is a single long 3022 option with two leading dashes. */ 3023 if (flagstring[0] == '-' && flagstring[1] != '-') 3024 ++flagstring; 3025 3026 v = define_variable_cname ("MAKEFLAGS", flagstring, 3027 /* This used to use o_env, but that lost when a 3028 makefile defined MAKEFLAGS. Makefiles set 3029 MAKEFLAGS to add switches, but we still want 3030 to redefine its value with the full set of 3031 switches. Of course, an override or command 3032 definition will still take precedence. */ 3033 o_file, 1); 3034 2946 3035 if (! all) 2947 3036 /* The first time we are called, set MAKEFLAGS to always be exported. … … 2949 3038 after reading makefiles which might have done `unexport MAKEFLAGS'. */ 2950 3039 v->export = v_export; 3040 3041 return v->value; 2951 3042 } 2952 3043 … … 2978 3069 word "Copyright", so it hardly seems worth it. */ 2979 3070 2980 printf ("%sCopyright (C) 20 07Free Software Foundation, Inc.\n", precede);3071 printf ("%sCopyright (C) 2010 Free Software Foundation, Inc.\n", precede); 2981 3072 2982 3073 printf (_("%sLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\ … … 3060 3151 3061 3152 close (job_fds[0]); 3153 3154 /* Clean out jobserver_fds so we don't pass this information to any 3155 sub-makes. Also reset job_slots since it will be put on the command 3156 line, not in MAKEFLAGS. */ 3157 job_slots = default_job_slots; 3158 if (jobserver_fds) 3159 { 3160 /* MSVC erroneously warns without a cast here. */ 3161 free ((void *)jobserver_fds->list); 3162 free (jobserver_fds); 3163 jobserver_fds = 0; 3164 } 3062 3165 } 3063 3166 } … … 3104 3207 of relative pathnames fail. */ 3105 3208 if (directory_before_chdir != 0) 3106 chdir (directory_before_chdir); 3209 { 3210 /* If it fails we don't care: shut up GCC. */ 3211 int _x; 3212 _x = chdir (directory_before_chdir); 3213 } 3107 3214 3108 3215 log_working_directory (0);
Note:
See TracChangeset
for help on using the changeset viewer.