summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog33
-rw-r--r--NEWS12
-rw-r--r--NMakefile.template5
-rw-r--r--ar.c3
-rw-r--r--config.h.W32.template15
-rw-r--r--configure.in9
-rw-r--r--doc/make.texi203
-rw-r--r--job.c10
-rw-r--r--main.c12
-rw-r--r--make.h15
-rw-r--r--misc.c28
-rw-r--r--rule.c5
-rw-r--r--tests/scripts/targets/ONESHELL3
-rw-r--r--tests/scripts/targets/POSIX8
-rw-r--r--tests/scripts/variables/SHELL23
-rw-r--r--vpath.c6
-rw-r--r--w32/compat/dirent.c3
-rw-r--r--w32/pathstuff.c2
-rw-r--r--w32/subproc/misc.c3
-rw-r--r--w32/subproc/sub_proc.c8
20 files changed, 314 insertions, 92 deletions
diff --git a/ChangeLog b/ChangeLog
index a4d0600..3dfdcfd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2010-07-18 Paul Smith <psmith@gnu.org>
+
+ * configure.in: Switch bsd_signal to AC_CHECK_DECLS() to make sure
+ we have a declaration. Fixes Savannah bug #25713 (maybe?)
+ * doc/make.texi (Complex Makefile): Cleanup variable assignments.
+ (One Shell): New subsection for the .ONESHELL special target.
+
+ Patches by Ozkan Sezer <sezeroz@gmail.com>:
+
+ * misc.c (strncasecmp): Local implementation for systems without.
+ * config.h.W32.template (HAVE_STRNICMP): Define on Windows.
+ * configure.in: Check for strncasecmp/strncmpi/strnicmp.
+ * job.c [WINDOWS32]: Don't define dup2 on Windows.
+ (pid2str): Use "%Id" even with MSVC
+ (exec_command): Cast to pid_t when calling pid2str().
+ * w32/subproc/sub_proc.c [WINDOWS32]: Include config.h first.
+ Use stddef.h on MSVC to get intptr_t.
+ * w32/subproc/misc.c [WINDOWS32]: Include config.h first.
+ * w32/compat/dirent.c [WINDOWS32]: Include config.h first.
+ (readdir): Cast -1 to correct type for d_ino.
+ * w32/pathstuff.c [WINDOWS32]: Ensure make.h is included first.
+ * make.h [WINDOWS32]: Don't prototype alloca() on Windows.
+ Add configuration for strncasecmp().
+ * main.c (ADD_SIG) [WINDOWS32]: Avoid warnings in MSVC.
+ * config.h.W32.template [WINDOWS32]: Don't warn on unsafe
+ functions or variables.
+ * NMakefile.template [WINDOWS32]: Remove /MACHINE:I386.
+ * main.c (clean_jobserver): Cast due to MSVC brokenness.
+ (decode_switches): Ditto.
+ * vpath.c (construct_vpath_list): Ditto.
+ * rule.c (freerule): Ditto.
+ * ar.c (ar_glob): Ditto.
+
2010-07-16 Boris Kolpackov <boris@codesynthesis.com>
* misc.c (concat): Fix buffer overrun.
diff --git a/NEWS b/NEWS
index f3e25a3..ed6593a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,6 @@
GNU make NEWS -*-indented-text-*-
History of user-visible changes.
- 25 Oct 2009
+ 16 July 2010
See the end of this file for copyrights and conditions.
@@ -9,7 +9,7 @@ manual, which is contained in this distribution as the file doc/make.texi.
See the README file and the GNU make manual for instructions for
reporting bugs.
-Version 3.81.90
+Version 3.81.91
* Compiling GNU make now requires a conforming ISO C 1989 compiler and
standard runtime library.
@@ -48,12 +48,12 @@ Version 3.81.90
* WARNING: Backward-incompatibility!
The library search behavior has changed to be compatible with the standard
- linker behavior. Prior to this version for prerequisites specified using
- the -lfoo syntax make fist searched for libfoo.so in the current directory,
+ linker behavior. Prior to this version for prerequisites specified using the
+ -lfoo syntax make first searched for libfoo.so in the current directory,
vpath directories, and system directories. If that didn't yield a match,
make then searched for libfoo.a in these directories. Starting with this
- version make searches first for libfoo.so and then for libfoo.a in each
- of these directories in order.
+ version make searches first for libfoo.so and then for libfoo.a in each of
+ these directories in order.
* New command line option: --eval=STRING causes STRING to be evaluated as
makefile syntax (akin to using the $(eval ...) function). The evaluation is
diff --git a/NMakefile.template b/NMakefile.template
index 5303778..35fafbe 100644
--- a/NMakefile.template
+++ b/NMakefile.template
@@ -33,10 +33,9 @@ CFLAGS_debug = $(CFLAGS_any) /Od /D DEBUG /D _DEBUG /FR.\WinDebug/ /Fp.\WinDebug
CFLAGS_release = $(CFLAGS_any) /O2 /D NDEBUG /FR.\WinRel/ /Fp.\WinRel/make.pch /Fo.\WinRel/
LDFLAGS_debug = w32\subproc\WinDebug\subproc.lib /NOLOGO /SUBSYSTEM:console\
- /INCREMENTAL:no /PDB:WinDebug/make.pdb /MACHINE:I386 \
- /OUT:WinDebug/make.exe /DEBUG
+ /INCREMENTAL:no /PDB:WinDebug/make.pdb /OUT:WinDebug/make.exe /DEBUG
LDFLAGS_release = w32\subproc\WinRel\subproc.lib /NOLOGO /SUBSYSTEM:console\
- /INCREMENTAL:no /MACHINE:I386 /OUT:WinRel/make.exe
+ /INCREMENTAL:no /OUT:WinRel/make.exe
all: config.h subproc Release Debug
diff --git a/ar.c b/ar.c
index 8bfca1c..95dcbbb 100644
--- a/ar.c
+++ b/ar.c
@@ -273,7 +273,8 @@ ar_glob (const char *arname, const char *member_pattern, unsigned int size)
names[i++] = n->name;
/* Sort them alphabetically. */
- qsort (names, i, sizeof (*names), alpha_compare);
+ /* MSVC erroneously warns without a cast here. */
+ qsort ((void *)names, i, sizeof (*names), alpha_compare);
/* Put them back into the chain in the sorted order. */
i = 0;
diff --git a/config.h.W32.template b/config.h.W32.template
index 1fd98f4..9b4138e 100644
--- a/config.h.W32.template
+++ b/config.h.W32.template
@@ -24,6 +24,8 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
# pragma warning(disable:4127) /* conditional expression is constant */
# pragma warning(disable:4131) /* uses old-style declarator */
# pragma warning(disable:4702) /* unreachable code */
+# define _CRT_SECURE_NO_WARNINGS /* function or variable may be unsafe */
+# define _CRT_NONSTDC_NO_WARNINGS /* functions w/o a leading underscore */
#endif
/* Define to 1 if the `closedir' function returns void instead of `int'. */
@@ -227,10 +229,19 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* #undef HAVE_STRCASECMP */
/* Define to 1 if you have the `strcmpi' function. */
-#define HAVE_STRCMPI 1
+/* #undef HAVE_STRCMPI */
/* Define to 1 if you have the `stricmp' function. */
-/* #undef HAVE_STRICMP */
+#define HAVE_STRICMP 1
+
+/* Define to 1 if you have the `strncasecmp' function. */
+/* #undef HAVE_STRNCASECMP */
+
+/* Define to 1 if you have the `strncmpi' function. */
+/* #undef HAVE_STRNCMPI */
+
+/* Define to 1 if you have the `strnicmp' function. */
+#define HAVE_STRNICMP 1
/* Define to 1 if you have the `strchr' function. */
#define HAVE_STRCHR 1
diff --git a/configure.in b/configure.in
index ab43ce3..b0dd44b 100644
--- a/configure.in
+++ b/configure.in
@@ -148,17 +148,22 @@ if test "$ac_cv_func_gettimeofday" = yes; then
fi
AC_CHECK_FUNCS( strdup strndup mkstemp mktemp fdopen fileno \
- bsd_signal dup2 getcwd realpath sigsetmask sigaction \
+ dup2 getcwd realpath sigsetmask sigaction \
getgroups seteuid setegid setlinebuf setreuid setregid \
getrlimit setrlimit setvbuf pipe strerror strsignal \
lstat readlink atexit)
+# We need to check declarations, not just existence, because on Tru64 this
+# function is not declared without special flags, which themselves cause
+# other problems. We'll just use our own.
+AC_CHECK_DECLS([bsd_signal], [], [], [[#include <signal.h>]])
+
AC_FUNC_SETVBUF_REVERSED
# Rumor has it that strcasecmp lives in -lresolv on some odd systems.
# It doesn't hurt much to use our own if we can't find it so I don't
# make the effort here.
-AC_CHECK_FUNCS(strcasecmp strcmpi stricmp)
+AC_CHECK_FUNCS(strcasecmp strncasecmp strcmpi strncmpi stricmp strnicmp)
# strcoll() is used by the GNU glob library
AC_FUNC_STRCOLL
diff --git a/doc/make.texi b/doc/make.texi
index 35a40dd..b7c54bf 100644
--- a/doc/make.texi
+++ b/doc/make.texi
@@ -3,7 +3,7 @@
@setfilename make.info
@include version.texi
-@set EDITION 0.70
+@set EDITION 0.71
@set RCSID $Id$
@settitle GNU @code{make}
@@ -25,9 +25,9 @@ and issues the commands to recompile them.
This is Edition @value{EDITION}, last updated @value{UPDATED},
of @cite{The GNU Make Manual}, for GNU @code{make} version @value{VERSION}.
-Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
-1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-Free Software Foundation, Inc.
+Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007,
+2008, 2009, 2010 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
@@ -524,13 +524,13 @@ A @dfn{prerequisite} is a file that is used as input to create the
target. A target often depends on several files.
@cindex tabs in rules
-A @dfn{recipe} is an action that @code{make} carries out.
-A recipe may have more than one command, each on its own line.
-@strong{Please note:} you need to put a tab character at the beginning of
-every command line! This is an obscurity that catches the unwary. If
-you prefer to prefix your recipes with a character other than tab,
-you can set the @code{.CMDPREFIX} variable to an alternate character
-(@pxref{Special Variables}).
+A @dfn{recipe} is an action that @code{make} carries out. A recipe
+may have more than one command, either on the same line or each on its
+own line. @strong{Please note:} you need to put a tab character at
+the beginning of every recipe line! This is an obscurity that catches
+the unwary. If you prefer to prefix your recipes with a character
+other than tab, you can set the @code{.RECIPEPREFIX} variable to an
+alternate character (@pxref{Special Variables}).
Usually a recipe is in a rule with prerequisites and serves to create a
target file if any of the prerequisites change. However, the rule that
@@ -629,13 +629,13 @@ on the header file @file{defs.h}.
A recipe may follow each line that contains a target and
prerequisites. These recipes say how to update the target file. A
tab character (or whatever character is specified by the
-@code{.CMDPREFIX} variable; @pxref{Special Variables}) must come at
+@code{.RECIPEPREFIX} variable; @pxref{Special Variables}) must come at
the beginning of every line in the recipe to distinguish recipes from
other lines in the makefile. (Bear in mind that @code{make} does not
know anything about how the recipes work. It is up to you to supply
recipes that will update the target file properly. All @code{make}
-does is execute the commands in the recipe you have specified when the
-target file needs to be updated.)@refill
+does is execute the recipe you have specified when the target file
+needs to be updated.)@refill
@cindex recipe
The target @samp{clean} is not a file, but merely the name of an
@@ -1097,7 +1097,7 @@ include @var{filenames}@dots{}
Extra spaces are allowed and ignored at the beginning of the line, but
the first character must not be a tab (or the value of
-@code{.CMDPREFIX})---if the line begins with a tab, it will be
+@code{.RECIPEPREFIX})---if the line begins with a tab, it will be
considered a recipe line. Whitespace is required between
@code{include} and the file names, and between file names; extra
whitespace is ignored there and at the end of the directive. A
@@ -1768,7 +1768,7 @@ target per rule, but occasionally there is a reason to have more
@cindex recipes
@cindex tab character (in commands)
The @var{recipe} lines start with a tab character (or the first
-character in the value of the @code{.CMDPREFIX} variable;
+character in the value of the @code{.RECIPEPREFIX} variable;
@pxref{Special Variables}). The first recipe line may appear on the line
after the prerequisites, with a tab character, or may appear on the
same line, with a semicolon. Either way, the effect is the same.
@@ -1822,12 +1822,12 @@ extra features (@pxref{Recipes, ,Writing Recipes in Rules}).
There are actually two different types of prerequisites understood by
GNU @code{make}: normal prerequisites such as described in the
previous section, and @dfn{order-only} prerequisites. A normal
-prerequisite makes two statements: first, it imposes an order of
-execution of recipes: any recipes necessary to build any of a
-target's prerequisites will be fully executed before any recipe
-necessary to build the target. Second, it imposes a dependency
-relationship: if any prerequisite is newer than the target, then the
-target is considered out-of-date and must be rebuilt.
+prerequisite makes two statements: first, it imposes an order in which
+recipes will be invoked: the recipes for all prerequisites of a target
+will be completed before the recipe for the target is run. Second, it
+imposes a dependency relationship: if any prerequisite is newer than
+the target, then the target is considered out-of-date and must be
+rebuilt.
Normally, this is exactly what you want: if a target's prerequisite is
updated, then the target should also be updated.
@@ -2874,6 +2874,15 @@ given. Any recursively invoked @code{make} command will still run
recipes in parallel (unless its makefile also contains this target).
Any prerequisites on this target are ignored.
+@findex .ONESHELL
+@item .ONESHELL
+@cindex recipe execution, single invocation
+
+If @code{.ONESHELL} is mentioned as a target, then when a target is
+built all lines of the recipe will be given to a single invocation of
+the shell rather than each line being invoked separately
+(@pxref{Execution, ,Recipe Execution}).
+
@findex .POSIX
@item .POSIX
@cindex POSIX-conforming mode, setting
@@ -3387,7 +3396,7 @@ brought up to date.
Users use many different shell programs, but recipes in makefiles are
always interpreted by @file{/bin/sh} unless the makefile specifies
-otherwise. @xref{Execution, ,Command Execution}.
+otherwise. @xref{Execution, ,Recipe Execution}.
@menu
* Recipe Syntax:: Recipe syntax features and pitfalls.
@@ -3415,7 +3424,7 @@ syntax: it performs only a very few specific translations on the
content of the recipe before handing it to the shell.
Each line in the recipe must start with a tab (or the first character
-in the value of the @code{.CMDPREFIX} variable; @pxref{Special
+in the value of the @code{.RECIPEPREFIX} variable; @pxref{Special
Variables}), except that the first recipe line may be attached to the
target-and-prerequisites line with a semicolon in between. @emph{Any}
line in the makefile that begins with a tab and appears in a ``rule
@@ -3690,9 +3699,10 @@ started with @samp{@@}. A rule in the makefile for the special target
@vindex @code{SHELL} @r{(recipe execution)}
When it is time to execute recipes to update a target, they are
-executed by invoking a new subshell for each line of the recipe. (In
-practice, @code{make} may take shortcuts that do not affect the
-results.)
+executed by invoking a new subshell for each line of the recipe,
+unless the @code{.ONESHELL} special target is in effect
+(@pxref{One Shell, ,Using One Shell}) (In practice, @code{make} may
+take shortcuts that do not affect the results.)
@cindex @code{cd} (shell command)
@cindex shell variables, setting in recipes
@@ -3720,11 +3730,113 @@ problems (in this case it would certainly cause @file{../foo} to be
truncated, at least).
@menu
+* One Shell:: One shell for all lines in a recipe
* Choosing the Shell:: How @code{make} chooses the shell used
to run recipes.
@end menu
-@node Choosing the Shell, , Execution, Execution
+@node One Shell, Choosing the Shell, Execution, Execution
+@subsection Using One Shell
+@cindex recipe lines, single shell
+@cindex @code{.ONESHELL}, use of
+@findex .ONESHELL
+
+Sometimes you would prefer that all the lines in the recipe be passed
+to a single invocation of the shell. There are generally two
+situations where this is useful: first, it can improve performance in
+makefiles where recipes consist of many command lines, by avoiding
+extra processes. Second, you might want newlines to be included in
+your recipe command (for example perhaps you are using a very
+different interpreter as your @code{SHELL}). If the @code{.ONESHELL}
+special target appears anywhere in the makefile then @emph{all}
+recipe lines for each target will be provided to a single invocation
+of the shell. Newlines between recipe lines will be preserved. For
+example:
+
+@example
+.ONESHELL:
+foo : bar/lose
+ cd $(@@D)
+ gobble $(@@F) > ../$@@
+@end example
+
+@noindent
+would now work as expected even though the commands are on different
+recipe lines.
+
+If @code{.ONESHELL} is provided, then only the first line of the
+recipe will be checked for the special prefix characters (@samp{@@},
+@samp{-}, and @samp{+}). Subsequent lines will include the special
+characters in the recipe line when the @code{SHELL} is invoked. If
+you want your recipe to start with one of these special characters
+you'll need to arrange for them to not be the first characters on the
+first line, perhaps by adding a comment or similar. For example, this
+would be a syntax error in Perl because the first @samp{@@} is removed
+by make:
+
+@example
+.ONESHELL:
+SHELL = /usr/bin/perl
+.SHELLFLAGS = -e
+show :
+ @@f = qw(a b c);
+ print "@@f\n";
+@end example
+
+@noindent
+However, either of these alternatives would work properly:
+
+@example
+.ONESHELL:
+SHELL = /usr/bin/perl
+.SHELLFLAGS = -e
+show :
+ # Make sure "@@" is not the first character on the first line
+ @@f = qw(a b c);
+ print "@@f\n";
+@end example
+
+@noindent
+or
+
+@example
+.ONESHELL:
+SHELL = /usr/bin/perl
+.SHELLFLAGS = -e
+show :
+ my @@f = qw(a b c);
+ print "@@f\n";
+@end example
+
+As a special feature, if @code{SHELL} is determined to be a
+POSIX-style shell, the special prefix characters in ``internal''
+recipe lines will @emph{removed} before the recipe is processed. This
+feature is intended to allow existing makefiles to add the
+@code{.ONESHELL} special target and still run properly without
+extensive modifications. Since the special prefix characters are not
+legal at the beginning of a line in a POSIX shell script this is not a
+loss in functionality. For example, this works as expected:
+
+@example
+.ONESHELL:
+foo : bar/lose
+ @@cd $(@@D)
+ @@gobble $(@@F) > ../$@@
+@end example
+
+Even with this special feature, however, makefiles with
+@code{.ONESHELL} will behave differently in ways that could be
+noticeable. For example, normally if any line in the recipe fails,
+that causes the rule to fail and no more recipe lines are processed.
+Under @code{.ONESHELL} a failure of any but the final recipe line will
+not be noticed by @code{make}. You can modify @code{.SHELLFLAGS} to
+add the @code{-e} option to the shell which will cause any failure
+anywhere in the command line to cause the shell to fail, but this
+could itself cause your recipe to behave differently. Ultimately you
+may need to harden your recipe lines to allow them to work with
+@code{.ONESHELL}.
+
+@node Choosing the Shell, , One Shell, Execution
@subsection Choosing the Shell
@cindex shell, choosing the
@cindex @code{SHELL}, value of
@@ -3828,6 +3940,9 @@ contains @samp{SHELL = /bin/sh} (as many Unix makefiles do), will work
on MS-DOS unaltered if you have e.g.@: @file{sh.exe} installed in some
directory along your @code{PATH}.
+@vindex SHELL
+@vindex .SHELLFLAGS
+
@node Parallel, Errors, Execution, Recipes
@section Parallel Execution
@cindex recipes, execution in parallel
@@ -5964,8 +6079,8 @@ will contain the number of times this instance has restarted. Note
this is not the same as recursion (counted by the @code{MAKELEVEL}
variable). You should not set, modify, or export this variable.
-@vindex .CMDPREFIX @r{(change the recipe prefix character)}
-@item .CMDPREFIX
+@vindex .RECIPEPREFIX @r{(change the recipe prefix character)}
+@item .RECIPEPREFIX
The first character of the value of this variable is used as the
character make assumes is introducing a recipe line. If the variable
is empty (as it is by default) that character is the standard tab
@@ -5973,13 +6088,13 @@ character. For example, this is a valid makefile:
@example
@group
-.CMDPREFIX = >
+.RECIPEPREFIX = >
all:
> @@echo Hello, world
@end group
@end example
-The value of @code{.CMDPREFIX} can be changed multiple times; once set
+The value of @code{.RECIPEPREFIX} can be changed multiple times; once set
it stays in effect for all rules parsed until it is modified.
@vindex .VARIABLES @r{(list of variables)}
@@ -10941,7 +11056,7 @@ editors) have attempted to indent your recipe lines with spaces
instead of a tab character. In this case, @code{make} will use the
second form of the error above. Remember that every line in the
recipe must begin with a tab character (unless you set
-@code{.CMDPREFIX}; @pxref{Special Variables}). Eight spaces do not
+@code{.RECIPEPREFIX}; @pxref{Special Variables}). Eight spaces do not
count. @xref{Rule Syntax}.
@item recipe commences before first target. Stop.
@@ -11201,18 +11316,16 @@ infodir = $(prefix)/info
#### End of system configuration section. ####
-SRC1 = tar.c create.c extract.c buffer.c \
- getoldopt.c update.c gnu.c mangle.c
-SRC2 = version.c list.c names.c diffarch.c \
- port.c wildmat.c getopt.c
-SRC3 = getopt1.c regex.c getdate.y
-SRCS = $(SRC1) $(SRC2) $(SRC3)
-OBJ1 = tar.o create.o extract.o buffer.o \
- getoldopt.o update.o gnu.o mangle.o
-OBJ2 = version.o list.o names.o diffarch.o \
- port.o wildmat.o getopt.o
-OBJ3 = getopt1.o regex.o getdate.o $(RTAPELIB)
-OBJS = $(OBJ1) $(OBJ2) $(OBJ3)
+@group
+SRCS_C = tar.c create.c extract.c buffer.c \
+ getoldopt.c update.c gnu.c mangle.c \
+ version.c list.c names.c diffarch.c \
+ port.c wildmat.c getopt.c getopt1.c \
+ regex.c
+SRCS_Y = getdate.y
+SRCS = $(SRCS_C) $(SRCS_Y)
+OBJS = $(SRCS_C:.c=.o) $(SRCS_Y:.y=.o) $(RTAPELIB)
+@end group
@group
AUX = README COPYING ChangeLog Makefile.in \
makefile.pc configure configure.in \
diff --git a/job.c b/job.c
index 8b4d716..de4f79e 100644
--- a/job.c
+++ b/job.c
@@ -174,11 +174,9 @@ int wait ();
#endif /* Don't have `union wait'. */
-#ifndef HAVE_UNISTD_H
+#if !defined(HAVE_UNISTD_H) && !defined(WINDOWS32)
int dup2 ();
-#if !(defined(_MSC_VER) && defined(_WIN64))
int execve ();
-#endif
void _exit ();
# ifndef VMS
int geteuid ();
@@ -194,7 +192,7 @@ static const char *
pid2str (pid_t pid)
{
static char pidstring[100];
-#if defined(WINDOWS32) && __GNUC__ > 3
+#ifdef WINDOWS32
sprintf (pidstring, "%Id", pid);
#else
sprintf (pidstring, "%lu", (unsigned long) pid);
@@ -2121,11 +2119,11 @@ exec_command (char **argv, char **envp)
break;
else
{
- char *pidstr = xstrdup (pid2str ((DWORD_PTR)hWaitPID));
+ char *pidstr = xstrdup (pid2str ((pid_t)hWaitPID));
fprintf(stderr,
_("make reaped child pid %s, still waiting for pid %s\n"),
- pidstr, pid2str ((DWORD_PTR)hPID));
+ pidstr, pid2str ((pid_t)hPID));
free (pidstr);
}
}
diff --git a/main.c b/main.c
index a1a3e8f..c6989e3 100644
--- a/main.c
+++ b/main.c
@@ -523,7 +523,7 @@ int fatal_signal_mask;
# endif
#endif
-#if !defined HAVE_BSD_SIGNAL && !defined bsd_signal
+#if !HAVE_DECL_BSD_SIGNAL && !defined bsd_signal
# if !defined HAVE_SIGACTION
# define bsd_signal signal
# else
@@ -986,7 +986,7 @@ main (int argc, char **argv, char **envp)
fatal_signal_mask = 0;
#define ADD_SIG(sig) fatal_signal_mask |= sigmask (sig)
#else
-#define ADD_SIG(sig)
+#define ADD_SIG(sig) (void)sig /* Needed to avoid warnings in MSVC. */
#endif
#endif
@@ -2577,7 +2577,8 @@ decode_switches (int argc, char **argv, int env)
else if (sl->idx == sl->max - 1)
{
sl->max += 5;
- sl->list = xrealloc (sl->list,
+ /* MSVC erroneously warns without a cast here. */
+ sl->list = xrealloc ((void *)sl->list,
sl->max * sizeof (char *));
}
if (cs->type == filename)
@@ -3060,7 +3061,7 @@ print_version (void)
year, and none of the rest of it should be translated (including the
word "Copyright", so it hardly seems worth it. */
- printf ("%sCopyright (C) 2009 Free Software Foundation, Inc.\n", precede);
+ printf ("%sCopyright (C) 2010 Free Software Foundation, Inc.\n", precede);
printf (_("%sLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\
%sThis is free software: you are free to change and redistribute it.\n\
@@ -3149,7 +3150,8 @@ clean_jobserver (int status)
job_slots = default_job_slots;
if (jobserver_fds)
{
- free (jobserver_fds->list);
+ /* MSVC erroneously warns without a cast here. */
+ free ((void *)jobserver_fds->list);
free (jobserver_fds);
jobserver_fds = 0;
}
diff --git a/make.h b/make.h
index af35eaf..4bc54cf 100644
--- a/make.h
+++ b/make.h
@@ -35,7 +35,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
# ifdef _AIX
#pragma alloca
# else
-# ifndef __GNUC__
+# if !defined(__GNUC__) && !defined(WINDOWS32)
# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
# endif
@@ -487,7 +487,18 @@ char *getwd ();
# define strcasecmp strcmpi
# else
/* Create our own, in misc.c */
-int strcasecmp (const char *s1, const char *s2);
+int strcasecmp (const char *s1, const char *s2, int n);
+# endif
+#endif
+
+#if !HAVE_STRNCASECMP
+# if HAVE_STRNICMP
+# define strncasecmp strnicmp
+# elif HAVE_STRNCMPI
+# define strncasecmp strncmpi
+# else
+/* Create our own, in misc.c */
+int strncasecmp (const char *s1, const char *s2);
# endif
#endif
diff --git a/misc.c b/misc.c
index 39c2835..7a6f773 100644
--- a/misc.c
+++ b/misc.c
@@ -614,6 +614,34 @@ strcasecmp (const char *s1, const char *s2)
}
}
#endif
+
+#if !HAVE_STRNCASECMP && !HAVE_STRNICMP && !HAVE_STRNCMPI
+
+/* If we don't have strncasecmp() (from POSIX), or anything that can
+ substitute for it, define our own version. */
+
+int
+strncasecmp (const char *s1, const char *s2, int n)
+{
+ while (n-- > 0)
+ {
+ int c1 = (int) *(s1++);
+ int c2 = (int) *(s2++);
+
+ if (isalpha (c1))
+ c1 = tolower (c1);
+ if (isalpha (c2))
+ c2 = tolower (c2);
+
+ if (c1 != '\0' && c1 == c2)
+ continue;
+
+ return (c1 - c2);
+ }
+
+ return 0;
+}
+#endif
#ifdef GETLOADAVG_PRIVILEGED
diff --git a/rule.c b/rule.c
index 0e6ddb7..a966cc9 100644
--- a/rule.c
+++ b/rule.c
@@ -404,8 +404,9 @@ freerule (struct rule *rule, struct rule *lastrule)
free_dep_chain (rule->deps);
- free (rule->targets);
- free (rule->suffixes);
+ /* MSVC erroneously warns without a cast here. */
+ free ((void *)rule->targets);
+ free ((void *)rule->suffixes);
free (rule->lens);
/* We can't free the storage for the commands because there
diff --git a/tests/scripts/targets/ONESHELL b/tests/scripts/targets/ONESHELL
index 5b86e48..997423f 100644
--- a/tests/scripts/targets/ONESHELL
+++ b/tests/scripts/targets/ONESHELL
@@ -62,8 +62,7 @@ all:
> @$$a=5
> +7;
> @y=qw(a b c);
->print "a = $$a, \
-y = (@y)\n";
+>print "a = $$a, y = (@y)\n";
!,
'', "a = 12, y = (a b c)\n");
diff --git a/tests/scripts/targets/POSIX b/tests/scripts/targets/POSIX
index 662c16d..1b57448 100644
--- a/tests/scripts/targets/POSIX
+++ b/tests/scripts/targets/POSIX
@@ -6,10 +6,12 @@ $details = "";
# Ensure turning on .POSIX enables the -e flag for the shell
+# We can't just use "false" because on different systems it provides a
+# different exit code.
run_make_test(q!
.POSIX:
-all: ; @false; true
+all: ; @r() { return 1; }; r; true
!,
'', "#MAKE#: *** [all] Error 1\n", 512);
@@ -18,9 +20,9 @@ all: ; @false; true
run_make_test(q!
.SHELLFLAGS = -xc
.POSIX:
-all: ; @false; true
+all: ; @r() { return 1; }; r; true
!,
- '', "+ false\n+ true\n");
+ '', "+ r\n+ return 1\n+ true\n");
# This tells the test driver that the perl test script executed properly.
1;
diff --git a/tests/scripts/variables/SHELL b/tests/scripts/variables/SHELL
index 69871d2..0028d9f 100644
--- a/tests/scripts/variables/SHELL
+++ b/tests/scripts/variables/SHELL
@@ -58,16 +58,27 @@ one two:;@echo "$@: $(SHELL) $$SHELL"
# Test .SHELLFLAGS
-run_make_test(q!
+# We can't assume the value here: on Solaris for example, every line printed
+# by the shell in -x mode has a trailing space (!!)
+my $script = 'true';
+my $out = `/bin/sh -xc '$script' 2>&1`;
+
+run_make_test(qq!
.SHELLFLAGS = -xc
-all: ; @true
+all: ; \@$script
!,
- '', "+ true\n");
+ '', $out);
+
+# We can't just use "false" because on different systems it provides a
+# different exit code.
+
+my $script = 'r() { return 1; }; true; r; true';
+my $out = `/bin/sh -xec '$script' 2>&1`;
-run_make_test(q!
+run_make_test(qq!
.SHELLFLAGS = -xec
-all: ; @true; false; true
+all: ; \@$script
!,
- '', "+ true\n+ false\n#MAKE#: *** [all] Error 1\n", 512);
+ '', "$out#MAKE#: *** [all] Error 1\n", 512);
1;
diff --git a/vpath.c b/vpath.c
index 2d3a833..9f41b27 100644
--- a/vpath.c
+++ b/vpath.c
@@ -192,7 +192,8 @@ construct_vpath_list (char *pattern, char *dirpath)
lastpath->next = next;
/* Free its unused storage. */
- free (path->searchpath);
+ /* MSVC erroneously warns without a cast here. */
+ free ((void *)path->searchpath);
free (path);
}
else
@@ -297,7 +298,8 @@ construct_vpath_list (char *pattern, char *dirpath)
}
else
/* There were no entries, so free whatever space we allocated. */
- free (vpath);
+ /* MSVC erroneously warns without a cast here. */
+ free ((void *)vpath);
}
/* Search the GPATH list for a pathname string that matches the one passed
diff --git a/w32/compat/dirent.c b/w32/compat/dirent.c
index ea1259c..8d66e47 100644
--- a/w32/compat/dirent.c
+++ b/w32/compat/dirent.c
@@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
+#include <config.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
@@ -132,7 +133,7 @@ readdir(DIR* pDir)
pDir->dir_nNumFiles++;
/* fill in struct dirent values */
- pDir->dir_sdReturn.d_ino = -1;
+ pDir->dir_sdReturn.d_ino = (ino_t)-1;
strcpy(pDir->dir_sdReturn.d_name, wfdFindData.cFileName);
return &pDir->dir_sdReturn;
diff --git a/w32/pathstuff.c b/w32/pathstuff.c
index 91ae1fb..1f8269e 100644
--- a/w32/pathstuff.c
+++ b/w32/pathstuff.c
@@ -15,9 +15,9 @@ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
+#include "make.h"
#include <string.h>
#include <stdlib.h>
-#include "make.h"
#include "pathstuff.h"
/*
diff --git a/w32/subproc/misc.c b/w32/subproc/misc.c
index 298db48..6759c17 100644
--- a/w32/subproc/misc.c
+++ b/w32/subproc/misc.c
@@ -15,6 +15,7 @@ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
+#include <config.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -77,6 +78,6 @@ arr2envblk(char **arr, char **envblk_out)
arrcnt++;
}
- free(tmp);
+ free(tmp);
return TRUE;
}
diff --git a/w32/subproc/sub_proc.c b/w32/subproc/sub_proc.c
index f0597b0..dcb77bf 100644
--- a/w32/subproc/sub_proc.c
+++ b/w32/subproc/sub_proc.c
@@ -15,9 +15,14 @@ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
+#include <config.h>
#include <stdlib.h>
#include <stdio.h>
-#include <stdint.h>
+#ifdef _MSC_VER
+# include <stddef.h> /* for intptr_t */
+#else
+# include <stdint.h>
+#endif
#include <process.h> /* for msvc _beginthreadex, _endthreadex */
#include <signal.h>
#include <windows.h>
@@ -25,7 +30,6 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sub_proc.h"
#include "proc.h"
#include "w32err.h"
-#include "config.h"
#include "debug.h"
static char *make_command_line(char *shell_name, char *exec_path, char **argv);