From 6aaf20931568b7ffd7aae6fb433b8161d2e6c3c8 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 14 Sep 2005 22:15:28 +0200 Subject: [PATCH] [PATCH] add support for -imacros Gcc has two ways to specify on the commandline files to be read before processign normal files: "-include file" will include file in ordinary way. "-imacros file" will include file but do not generate any output gcc will include files specified with -imacros before files specified with -include. This adds some very basic support for -imacros, just duplicating the code used for -include. To obtain the real functionality we would have to build a list of filenames specified, and process all files specifed with -imacros before files specified with -include. In -mm a patch is now included that uses -imacros, so applying following patch will let us stay compatible with kernel source. The last bit deletes two references from lib.h that are there for no good reason. Signed-off-by: Sam Ravnborg Signed-off-by: Linus Torvalds --- lib.c | 9 +++++++++ lib.h | 2 -- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib.c b/lib.c index 59edad6a..f38c3eef 100644 --- a/lib.c +++ b/lib.c @@ -256,6 +256,15 @@ static char **handle_switch_i(char *arg, char **next) if (fd < 0) perror(name); } + if (*next && !strcmp(arg, "imacros")) { + char *name = *++next; + int fd = open(name, O_RDONLY); + + include_fd = fd; + include = name; + if (fd < 0) + perror(name); + } else if (*next && !strcmp(arg, "isystem")) { char *path = *++next; if (!path) diff --git a/lib.h b/lib.h index 5eb755be..40e8b015 100644 --- a/lib.h +++ b/lib.h @@ -71,8 +71,6 @@ extern void error_die(struct position, const char *, ...) FORMAT_ATTR(2); extern char **handle_switch(char *arg, char **next); extern void add_pre_buffer(const char *fmt, ...); -extern int include_fd; -extern char *include; extern int preprocess_only; extern int Wptr_subtraction_blows; extern int Wdefault_bitfield_sign; -- 2.11.4.GIT