[SV 63516] [DOS] Support include files with drivespecs

* src/makeint.h (HAVE_DRIVESPEC): Create a macro to check.
* src/main.c (.FEATURES): Add "dospaths" as a feature.
* src/read.c (eval_makefile) [DOS]: If the included makefile name
starts with a drivespec, don't search the include directories.
* doc/make.texi (Include): Document this behavior.
* tests/scripts/features/include: Add a test.
This commit is contained in:
Paul Smith
2022-12-17 11:01:31 -05:00
parent c0023150f1
commit 5d1b757517
5 changed files with 39 additions and 16 deletions

View File

@@ -1279,19 +1279,16 @@ makefile as has been traditionally done with other versions of
@findex /usr/gnu/include @findex /usr/gnu/include
@findex /usr/local/include @findex /usr/local/include
@findex /usr/include @findex /usr/include
If the specified name does not start with a slash, and the file is not If the specified name does not start with a slash (or a drive letter and colon
found in the current directory, several other directories are searched. when GNU Make is compiled with MS-DOS / MS-Windows path support), and the file
is not found in the current directory, several other directories are searched.
First, any directories you have specified with the @samp{-I} or First, any directories you have specified with the @samp{-I} or
@samp{--include-dir} options are searched @samp{--include-dir} options are searched (@pxref{Options Summary, ,Summary of
(@pxref{Options Summary, ,Summary of Options}). Options}). Then the following directories (if they exist) are searched, in
Then the following directories (if they exist) this order: @file{@var{prefix}/include} (normally @file{/usr/local/include}
are searched, in this order:
@file{@var{prefix}/include} (normally @file{/usr/local/include}
@footnote{GNU Make compiled for MS-DOS and MS-Windows behaves as if @footnote{GNU Make compiled for MS-DOS and MS-Windows behaves as if
@var{prefix} has been defined to be the root of the DJGPP tree @var{prefix} has been defined to be the root of the DJGPP tree hierarchy.})
hierarchy.}) @file{/usr/gnu/include}, @file{/usr/local/include}, @file{/usr/include}.
@file{/usr/gnu/include},
@file{/usr/local/include}, @file{/usr/include}.
The @code{.INCLUDE_DIRS} variable will contain the current list of The @code{.INCLUDE_DIRS} variable will contain the current list of
directories that make will search for included files. @xref{Special directories that make will search for included files. @xref{Special

View File

@@ -1455,6 +1455,9 @@ main (int argc, char **argv, char **envp)
#ifdef MAKE_LOAD #ifdef MAKE_LOAD
" load" " load"
#endif #endif
#ifdef HAVE_DOS_PATHS
" dospaths"
#endif
#ifdef MAKE_MAINTAINER_MODE #ifdef MAKE_MAINTAINER_MODE
" maintainer" " maintainer"
#endif #endif

View File

@@ -414,6 +414,7 @@ extern int unixy_shell;
#define NONE_SET(_v,_m) (! ANY_SET ((_v),(_m))) #define NONE_SET(_v,_m) (! ANY_SET ((_v),(_m)))
#define ALL_SET(_v,_m) (((_v)&(_m)) == (_m)) #define ALL_SET(_v,_m) (((_v)&(_m)) == (_m))
/* Bitmasks for the STOPCHAR array. */
#define MAP_NUL 0x0001 #define MAP_NUL 0x0001
#define MAP_BLANK 0x0002 /* space, TAB */ #define MAP_BLANK 0x0002 /* space, TAB */
#define MAP_NEWLINE 0x0004 #define MAP_NEWLINE 0x0004
@@ -463,14 +464,13 @@ extern int unixy_shell;
# define MAP_PATHSEP MAP_SEMI # define MAP_PATHSEP MAP_SEMI
#elif PATH_SEPARATOR_CHAR == ',' #elif PATH_SEPARATOR_CHAR == ','
# define MAP_PATHSEP MAP_COMMA # define MAP_PATHSEP MAP_COMMA
#else #else
# error "Unknown PATH_SEPARATOR_CHAR" # error "Unknown PATH_SEPARATOR_CHAR"
#endif #endif
#define STOP_SET(_v,_m) ANY_SET(stopchar_map[(unsigned char)(_v)],(_m)) #define STOP_SET(_v,_m) ANY_SET(stopchar_map[(unsigned char)(_v)],(_m))
/* True if C is a directory separator on the current system. */
#define ISDIRSEP(c) STOP_SET((c),MAP_DIRSEP)
/* True if C is whitespace but not newline. */ /* True if C is whitespace but not newline. */
#define ISBLANK(c) STOP_SET((c),MAP_BLANK) #define ISBLANK(c) STOP_SET((c),MAP_BLANK)
/* True if C is whitespace including newlines. */ /* True if C is whitespace including newlines. */
@@ -480,6 +480,18 @@ extern int unixy_shell;
/* Move S past all whitespace (including newlines). */ /* Move S past all whitespace (including newlines). */
#define NEXT_TOKEN(s) while (ISSPACE (*(s))) ++(s) #define NEXT_TOKEN(s) while (ISSPACE (*(s))) ++(s)
/* True if C is a directory separator on the current system. */
#define ISDIRSEP(c) STOP_SET((c),MAP_DIRSEP)
/* True if S starts with a drive specifier. */
#if defined(HAVE_DOS_PATHS)
# define HAS_DRIVESPEC(_s) ((((_s)[0] >= 'a' && (_s)[0] <= 'z') \
|| ((_s)[0] >= 'A' && (_s)[0] <= 'Z')) \
&& (_s)[1] == ':')
#else
# define HAS_DRIVESPEC(_s) 0
#endif
/* We can't run setrlimit when using posix_spawn. */ /* We can't run setrlimit when using posix_spawn. */
#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) && !defined(USE_POSIX_SPAWN) #if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) && !defined(USE_POSIX_SPAWN)
# define SET_STACK_SIZE # define SET_STACK_SIZE

View File

@@ -373,8 +373,9 @@ eval_makefile (const char *filename, unsigned short flags)
/* If the makefile wasn't found and it's either a makefile from the /* If the makefile wasn't found and it's either a makefile from the
'MAKEFILES' variable or an included makefile, search the included 'MAKEFILES' variable or an included makefile, search the included
makefile search path for this makefile. */ makefile search path for this makefile. */
if (ebuf.fp == NULL && deps->error == ENOENT && (flags & RM_INCLUDED) if (ebuf.fp == NULL && deps->error == ENOENT && include_directories
&& *filename != '/' && include_directories) && ANY_SET (flags, RM_INCLUDED)
&& !HAS_DRIVESPEC (filename) && !ISDIRSEP (*filename))
{ {
const char **dir; const char **dir;
for (dir = include_directories; *dir != NULL; ++dir) for (dir = include_directories; *dir != NULL; ++dir)

View File

@@ -1,4 +1,4 @@
# -*-mode: perl; rm-trailing-spaces: nil-*- # -*-mode: perl-*-
$description = "Test various forms of the GNU make 'include' command."; $description = "Test various forms of the GNU make 'include' command.";
@@ -462,4 +462,14 @@ run_make_with_options(undef, ['-E', '%:;@echo $@', '-E', 'all:;', '-E', '-includ
$answer = "bizbaz\nbazbiz\nfoobar\nbarfoo\n$defaults\n#MAKE#: 'all' is up to date.\n"; $answer = "bizbaz\nbazbiz\nfoobar\nbarfoo\n$defaults\n#MAKE#: 'all' is up to date.\n";
&compare_output(subst_make_string($answer), &get_logfile(1)); &compare_output(subst_make_string($answer), &get_logfile(1));
# SV 63516
if (exists $FEATURES{'dospaths'}) {
run_make_test(q!
include C:__foobar
%bar: ; @echo $@
all: ;
!,
'', "C:__foobar\n#MAKE#: 'all' is up to date.");
}
1; 1;