Patchwork [google] Add --with-native-system-header-dir to specify the location of /usr/include

login
register
mail settings
Submitter Simon Baldwin
Date Jan. 25, 2011, 8:33 p.m.
Message ID <20110125203347.5E03E1C656D@hpgntab-ubiq73.eem.corp.google.com>
Download mbox | patch
Permalink /patch/80402/
State New
Headers show

Comments

Simon Baldwin - Jan. 25, 2011, 8:33 p.m.
Add --with-native-system-header-dir to specify the location of /usr/include
instead of having it hard-coded.

Useful when building a sysroot'ed cross-compiler and you want to relocate
everything inside the system root.  Without this, the makefile and configure
scripts assume system header files live in /usr/include (or in usr/include
under the system root directory).

Targetted for the google/integration branch.

gcc/ChangeLog.google:
2011-01-25  Simon Baldwin  <simonb@google.com>

	* configure.ac: Add --with-native-system-header-dir option.
	* configure: Rebuild from configure.ac.
	* Makefile.in: Support --with-native-system-header-dir.
	* doc/install.texi: Document --with-native-system-header-dir.

Google ref: 38871, 37499, 24118, 12980
Diego Novillo - Jan. 25, 2011, 8:37 p.m.
On Tue, Jan 25, 2011 at 15:33, Simon Baldwin <simonb@google.com> wrote:

>        * configure.ac: Add --with-native-system-header-dir option.
>        * configure: Rebuild from configure.ac.
>        * Makefile.in: Support --with-native-system-header-dir.
>        * doc/install.texi: Document --with-native-system-header-dir.

OK.


Diego.
Gerald Pfeifer - Jan. 25, 2011, 11:12 p.m.
On Tue, 25 Jan 2011, Simon Baldwin wrote:
> Index: gcc/doc/install.texi
> ===================================================================
> +If you specify the @option{--with-native-system-header-dir} option
> +then the compiler will search that directory within @var{dir} for
> +native system headers rather than the default @file{/usr/include}.

I am wondering, should this be
  @option{--with-native-system-header-dir=@var{dir}}
?  Otherwise, where is @var{dir} introduced?

Also, in the documentation of --with-native-system-header-dir= you
use dirname instead of dir which indeed seems to be common practice.

Gerald
Simon Baldwin - Jan. 26, 2011, 11:34 a.m.
On 26 January 2011 00:12, Gerald Pfeifer <gerald@pfeifer.com> wrote:
>
> On Tue, 25 Jan 2011, Simon Baldwin wrote:
> > Index: gcc/doc/install.texi
> > ===================================================================
> > +If you specify the @option{--with-native-system-header-dir} option
> > +then the compiler will search that directory within @var{dir} for
> > +native system headers rather than the default @file{/usr/include}.
>
> I am wondering, should this be
>  @option{--with-native-system-header-dir=@var{dir}}
> ?  Otherwise, where is @var{dir} introduced?
>
> Also, in the documentation of --with-native-system-header-dir= you
> use dirname instead of dir which indeed seems to be common practice.

Thanks for the note.

install.texi is itself internally inconsistent around @var{dir} and
@var{dirname}, and uses them interchangeably, with @var{dirname} as
the most common choice.  From trunk at r169283:

  $ grep '^@item.*=@var{dir}$' doc/install.texi | wc -l
  5
  $ grep '^@item.*=@var{dirname}$' doc/install.texi | wc -l
  17

The new --with-native-system-header-dir= documentation section
directly follows "@item --with-local-prefix=@var{dirname}", and uses
@{dirname} for local consistency.

The two places where --with-native-system-header-dir referred to by
other options are both in @item...=@var{dir} sections.  In these, I've
updated the references to it to append =@var{dirname}, to be both
consistent with the main --with-native-system-header-dir documentation
section and also to differentiate from the @var{dir} used by the
enclosing section (here the dir/dirname difference is an advantage!).

Patch change detail:

$ diff ../37499.patch.old ../37499.patch
49,50c49,50
< +If you specify the @option{--with-native-system-header-dir} option
< +then the compiler will search that directory within @var{dir} for
---
> +If you specify the @option{--with-native-system-header-dir=@var{dirname}}
> +option then the compiler will search that directory within @var{dirname} for
60,61c60,61
< +If you specify the @option{--with-native-system-header-dir} option
< +then the compiler will search that directory within @var{dir} for
---
> +If you specify the @option{--with-native-system-header-dir=@var{dirname}}
> +option then the compiler will search that directory within @var{dirname} for

--
Google UK Limited | Registered Office: Belgrave House, 76 Buckingham
Palace Road, London SW1W 9TQ | Registered in England Number: 3977902
Diego Novillo - Jan. 26, 2011, 2:14 p.m.
On Wed, Jan 26, 2011 at 06:34, Simon Baldwin <simonb@google.com> wrote:

> $ diff ../37499.patch.old ../37499.patch
> 49,50c49,50
> < +If you specify the @option{--with-native-system-header-dir} option
> < +then the compiler will search that directory within @var{dir} for
> ---
>> +If you specify the @option{--with-native-system-header-dir=@var{dirname}}
>> +option then the compiler will search that directory within @var{dirname} for
> 60,61c60,61
> < +If you specify the @option{--with-native-system-header-dir} option
> < +then the compiler will search that directory within @var{dir} for
> ---
>> +If you specify the @option{--with-native-system-header-dir=@var{dirname}}
>> +option then the compiler will search that directory within @var{dirname} for

Sounds good.  I agree that using dirname is better in this case.  If
you haven't committed the original form, feel free to commit these
changes now.

Gerald, I'll send a patch to change all other instances of 'dir' to
'dirname' for trunk.  Would that be OK?


Thanks.  Diego.
Gerald Pfeifer - Jan. 26, 2011, 10:20 p.m.
On Wed, 26 Jan 2011, Diego Novillo wrote:
> Gerald, I'll send a patch to change all other instances of 'dir' to
> 'dirname' for trunk.  Would that be OK?

Sounds good, thank you, Diego.

(Also thanks, Simon, for digging into this and providing more analysis!)

Gerald

Patch

Index: gcc/doc/install.texi
===================================================================
--- gcc/doc/install.texi	(revision 169243)
+++ gcc/doc/install.texi	(working copy)
@@ -874,6 +874,18 @@  ideas of what it is for.  People use it 
 install part of GCC@.  Perhaps they make this assumption because
 installing GCC creates the directory.
 
+@item --with-native-system-header-dir=@var{dirname}
+Specifies that @var{dirname} is the directory that contains native system
+header files, rather than @file{/usr/include}. This option is most useful
+if you are creating a compiler that should be isolated from the system
+as much as possible.  It is most commonly used with the
+@option{--with-sysroot} option and will cause GCC to search
+@var{dirname} inside the system root specified by that option.
+
+Please note that for certain targets, such as DJGPP, this value is
+ignored. If the target specifies a default value for native system
+header files then this option is ignored.
+
 @item --enable-shared[=@var{package}[,@dots{}]]
 Build shared versions of libraries, if shared libraries are supported on
 the target platform.  Unlike GCC 2.95.x and earlier, shared libraries
@@ -1686,6 +1698,10 @@  target libraries (which runs on the buil
 installed with @code{make install}; it does not affect the compiler which is
 used to build GCC itself.
 
+If you specify the @option{--with-native-system-header-dir} option
+then the compiler will search that directory within @var{dir} for
+native system headers rather than the default @file{/usr/include}.
+
 @item --with-build-sysroot
 @itemx --with-build-sysroot=@var{dir}
 Tells GCC to consider @var{dir} as the system root (see
@@ -1700,6 +1716,10 @@  This option affects the system root for 
 target libraries (which runs on the build system); it does not affect
 the compiler which is used to build GCC itself.
 
+If you specify the @option{--with-native-system-header-dir} option
+then the compiler will search that directory within @var{dir} for
+native system headers rather than the default @file{/usr/include}.
+
 @item --with-headers
 @itemx --with-headers=@var{dir}
 Deprecated in favor of @option{--with-sysroot}.
Index: gcc/configure
===================================================================
--- gcc/configure	(revision 169243)
+++ gcc/configure	(working copy)
@@ -759,6 +759,7 @@  CONFIGURE_SPECS
 CROSS_SYSTEM_HEADER_DIR
 TARGET_SYSTEM_ROOT_DEFINE
 TARGET_SYSTEM_ROOT
+NATIVE_SYSTEM_HEADER_DIR
 enable_shared
 enable_fixed_point
 enable_decimal_float
@@ -879,6 +880,7 @@  enable_tls
 enable_objc_gc
 with_dwarf2
 enable_shared
+with_native_system_header_dir
 with_build_sysroot
 with_sysroot
 with_specs
@@ -1643,6 +1645,9 @@  Optional Packages:
   --with-as               arrange to use the specified as (full pathname)
   --with-stabs            arrange to use stabs instead of host debug format
   --with-dwarf2           force the default debug format to be DWARF 2
+  --with-native-system-header-dir=dir
+                          use dir as the directory to look for standard
+                          system header files in.  Defaults to /usr/include.
   --with-build-sysroot=sysroot
                           use sysroot as the system root during the build
   --with-sysroot=DIR Search for usr/lib, usr/include, et al, within DIR.
@@ -7057,6 +7062,27 @@  fi
 
 
 
+# The use of native_system_header_dir here is for the value (optionally)
+# configured here.  Uses of NATIVE_SYSTEM_HEADER_DIR in this file refer
+# to the make variable defined in Makefile or in target make fragments.
+
+# Check whether --with-native-system-header-dir was given.
+if test "${with_native_system_header_dir+set}" = set; then :
+  withval=$with_native_system_header_dir;
+ case ${with_native_system_header_dir} in
+ yes|no) as_fn_error "bad value ${withval} given for native system include directory" "$LINENO" 5 ;;
+ /*) ;;
+ *) as_fn_error "${withval} should be an absolute directory" "$LINENO" 5 ;;
+ esac
+ native_system_header_dir="${withval}"
+
+else
+  native_system_header_dir=/usr/include
+fi
+
+NATIVE_SYSTEM_HEADER_DIR=$native_system_header_dir
+
+
 
 # Check whether --with-build-sysroot was given.
 if test "${with_build_sysroot+set}" = set; then :
@@ -17513,7 +17539,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17516 "configure"
+#line 17542 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -17619,7 +17645,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17622 "configure"
+#line 17648 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -25664,14 +25690,14 @@  if test x$host != x$target || test "x$TA
   elif test "x$with_sysroot" = x; then
     target_header_dir="${exec_prefix}/${target_noncanonical}/sys-include"
   elif test "x$with_build_sysroot" != "x"; then
-    target_header_dir="${with_build_sysroot}/usr/include"
+    target_header_dir="${with_build_sysroot}${native_system_header_dir}"
   elif test "x$with_sysroot" = xyes; then
-    target_header_dir="${exec_prefix}/${target_noncanonical}/sys-root/usr/include"
+    target_header_dir="${exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}"
   else
-    target_header_dir="${with_sysroot}/usr/include"
+    target_header_dir="${with_sysroot}${native_system_header_dir}"
   fi
 else
-  target_header_dir=/usr/include
+  target_header_dir=${native_system_header_dir}
 fi
 
 # Test for stack protector support in target C library.
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 169243)
+++ gcc/configure.ac	(working copy)
@@ -709,6 +709,23 @@  AC_ARG_ENABLE(shared,
 ], [enable_shared=yes])
 AC_SUBST(enable_shared)
 
+# The use of native_system_header_dir here is for the value (optionally)
+# configured here.  Uses of NATIVE_SYSTEM_HEADER_DIR in this file refer
+# to the make variable defined in Makefile or in target make fragments.
+AC_ARG_WITH([native-system-header-dir],
+  [  --with-native-system-header-dir=dir
+                          use dir as the directory to look for standard
+                          system header files in.  Defaults to /usr/include.],
+[
+ case ${with_native_system_header_dir} in
+ yes|no) AC_MSG_ERROR([bad value ${withval} given for native system include directory]) ;;
+ /*) ;;
+ *) AC_MSG_ERROR([${withval} should be an absolute directory]) ;;
+ esac
+ native_system_header_dir="${withval}"
+], [native_system_header_dir=/usr/include])
+AC_SUBST(NATIVE_SYSTEM_HEADER_DIR, $native_system_header_dir)
+
 AC_ARG_WITH(build-sysroot, 
   [  --with-build-sysroot=sysroot
                           use sysroot as the system root during the build])
@@ -4264,14 +4281,14 @@  if test x$host != x$target || test "x$TA
   elif test "x$with_sysroot" = x; then
     target_header_dir="${exec_prefix}/${target_noncanonical}/sys-include"
   elif test "x$with_build_sysroot" != "x"; then
-    target_header_dir="${with_build_sysroot}/usr/include"
+    target_header_dir="${with_build_sysroot}${native_system_header_dir}"
   elif test "x$with_sysroot" = xyes; then
-    target_header_dir="${exec_prefix}/${target_noncanonical}/sys-root/usr/include"
+    target_header_dir="${exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}"
   else
-    target_header_dir="${with_sysroot}/usr/include"
+    target_header_dir="${with_sysroot}${native_system_header_dir}"
   fi
 else
-  target_header_dir=/usr/include
+  target_header_dir=${native_system_header_dir}
 fi
 
 # Test for stack protector support in target C library.
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 169243)
+++ gcc/Makefile.in	(working copy)
@@ -440,7 +440,7 @@  LINKER_PLUGIN_API_H = $(srcdir)/../inclu
 LTO_SYMTAB_H = $(srcdir)/../include/lto-symtab.h
 
 # Default native SYSTEM_HEADER_DIR, to be overridden by targets.
-NATIVE_SYSTEM_HEADER_DIR = /usr/include
+NATIVE_SYSTEM_HEADER_DIR = @NATIVE_SYSTEM_HEADER_DIR@
 # Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
 CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@