This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

/usr/local/libexec support


This patch implements support in GCC for the 'libexecdir' variable and
configure option, following this part of the GNU Makefile standard:

`libdir'
     The directory for object files and libraries of object code.  Do
     not install executables here, they probably ought to go in
     `$(libexecdir)' instead.

`libexecdir'
     The directory for installing executable programs to be run by other
     programs rather than by users.  This directory should normally be
     `/usr/local/libexec', but write it as `$(exec_prefix)/libexec'.

GCC now places executables in 
$prefix/libexec/gcc/<target>/<version>/{cc1,cc1plus,...}
Data files (include files, etc.) are still placed in
$prefix/lib/gcc-lib/<target>/<version>/...

I would be interested in opinions as to whether we should rename the
redundant "gcc-lib" to "gcc" at this point.

I have checked that the new layout is still relocatable, by installing
into /tmp/geoffk-gcc, renaming it to /tmp/geoffk-gcc-1, and checking
that a short C program still builds.  I also bootstrapped & ran the
testsuite on powerpc-darwin.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-libexec.patch=========================
2003-07-30  Geoffrey Keating  <geoffk@apple.com>

	* Makefile.in (libexecdir): New.
	(libexecsubdir): New.
	(ORDINARY_FLAGS_TO_PASS): Add libexecsubdir.
	(DRIVER_DEFINES): Add STANDARD_LIBEXEC_PREFIX.
	(installdirs): Make libexecsubdir.
	(install-common): Put executables in libexecsubdir.
	(itoolsdir): Use libexecsubdir.
	(itoolsdatadir): New.
	(install-mkheaders): Separate data files and executables.
	(install-collect2): Put executables in libexecsubdir.
	(uninstall): Remove libexecsubdir.
	* mkheaders.in: Update for new arrangement of files.
	(libexecdir): New.
	(libexecsubdir): New.
	(itoolsdir): Use libexecsubdir.
	(itoolsdatadir): New.
	* gcc.c (gcc_libexec_prefix): New.
	(standard_exec_prefix_1): Use libexec.
	(standard_exec_prefix_2): New.
	(standard_libexec_prefix): New.
	(process_command): Update for new arrangement of files.  Compute
	gcc_libexec_prefix.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1130
diff -u -p -u -p -r1.1130 Makefile.in
--- Makefile.in	29 Jul 2003 23:36:46 -0000	1.1130
+++ Makefile.in	30 Jul 2003 06:45:07 -0000
@@ -386,13 +386,17 @@ exec_prefix = @exec_prefix@
 bindir = @bindir@
 # Directory in which to put the directories used by the compiler.
 libdir = @libdir@
+# Directory in which GCC puts its executables.
+libexecdir = @libexecdir@
 
 # --------
 # UNSORTED
 # --------
 
-# Directory in which the compiler finds executables, libraries, etc.
+# Directory in which the compiler finds libraries etc.
 libsubdir = $(libdir)/gcc-lib/$(target_alias)/$(version)
+# Directory in which the compiler finds executables
+libexecsubdir = $(libexecdir)/@libexecsubdirname@/$(target_alias)/$(version)
 # Used to produce a relative $(gcc_tooldir) in gcc.o
 unlibsubdir = ../../..
 # Directory in which to find other cross-compilation tools and headers.
@@ -769,6 +773,7 @@ ORDINARY_FLAGS_TO_PASS = \
 	"gcc_tooldir=$(gcc_tooldir)" \
 	"bindir=$(bindir)" \
 	"libsubdir=$(libsubdir)" \
+	"libexecsubdir=$(libsubdir)" \
 	"datadir=$(datadir)" \
 	"localedir=$(localedir)"
 FLAGS_TO_PASS = $(ORDINARY_FLAGS_TO_PASS) "CC=@cc_set_by_configure@" \
@@ -1359,6 +1364,7 @@ c-pch.o : c-pch.c $(CONFIG_H) $(SYSTEM_H
 DRIVER_DEFINES = \
   -DSTANDARD_STARTFILE_PREFIX=\"$(unlibsubdir)/\" \
   -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc-lib/\" \
+  -DSTANDARD_LIBEXEC_PREFIX=\"$(libexecdir)/@libexecsubdirname@/\" \
   -DDEFAULT_TARGET_VERSION=\"$(version)\" \
   -DDEFAULT_TARGET_MACHINE=\"$(target_alias)\" \
   -DSTANDARD_BINDIR_PREFIX=\"$(bindir)/\" \
@@ -2939,6 +2945,7 @@ install-cpp: cpp$(exeext)
 # $(libdir)/gcc-lib/include isn't currently searched by cpp.
 installdirs:
 	$(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(libsubdir)
+	$(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(libexecsubdir)
 	$(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(bindir)
 	$(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(includedir)
 	$(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(infodir)
@@ -2950,15 +2957,15 @@ installdirs:
 install-common: native $(EXTRA_PARTS) lang.install-common installdirs
 	for file in $(COMPILERS); do \
 	  if [ -f $$file ] ; then \
-	    rm -f $(DESTDIR)$(libsubdir)/$$file; \
-	    $(INSTALL_PROGRAM) $$file $(DESTDIR)$(libsubdir)/$$file; \
+	    rm -f $(DESTDIR)$(libexecsubdir)/$$file; \
+	    $(INSTALL_PROGRAM) $$file $(DESTDIR)$(libexecsubdir)/$$file; \
 	  else true; \
 	  fi; \
 	done
 	for file in $(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(USE_COLLECT2) ..; do \
 	  if [ x"$$file" != x.. ]; then \
-	    rm -f $(DESTDIR)$(libsubdir)/$$file; \
-	    $(INSTALL_PROGRAM) $$file $(DESTDIR)$(libsubdir)/$$file; \
+	    rm -f $(DESTDIR)$(libexecsubdir)/$$file; \
+	    $(INSTALL_PROGRAM) $$file $(DESTDIR)$(libexecsubdir)/$$file; \
 	  else true; fi; \
 	done
 	for file in $(EXTRA_PARTS) ..; do \
@@ -3165,25 +3172,28 @@ install-headers-cpio: stmp-int-hdrs $(ST
 install-headers-cp: stmp-int-hdrs $(STMP_FIXPROTO) install-include-dir
 	cp -p -r include $(DESTDIR)$(libsubdir)
 
-itoolsdir = $(libsubdir)/install-tools
+itoolsdir = $(libexecsubdir)/install-tools
+itoolsdatadir = $(libsubdir)/install-tools
 # Don't install the headers.  Instead, install appropriate scripts
 # and supporting files for fixincludes to be run later.
 install-mkheaders: stmp-int-hdrs $(STMP_FIXPROTO) install-include-dir \
     mkheaders xlimits.h
-	-rm -rf $(DESTDIR)$(itoolsdir)
-	$(SHELL) $(srcdir)/mkinstalldirs $(DESTDIR)$(itoolsdir)/include
+	-rm -rf $(DESTDIR)$(itoolsdir) $(DESTDIR)$(itoolsdatadir)
+	$(SHELL) $(srcdir)/mkinstalldirs $(DESTDIR)$(itoolsdatadir)/include
+	$(SHELL) $(srcdir)/mkinstalldirs $(DESTDIR)$(itoolsdir)
 	for file in $(USER_H); do \
 	  realfile=`echo $$file | sed -e 's|.*/\([^/]*\)$$|\1|'`; \
 	  $(INSTALL_DATA) $$file \
-	    $(DESTDIR)$(itoolsdir)/include/$$realfile ; \
+	    $(DESTDIR)$(itoolsdatadir)/include/$$realfile ; \
 	done
-	$(INSTALL_DATA) xlimits.h $(DESTDIR)$(itoolsdir)/include/limits.h
+	$(INSTALL_DATA) xlimits.h $(DESTDIR)$(itoolsdatadir)/include/limits.h
 	if [ x$(STMP_FIXINC) != x ] ; then \
 	  $(INSTALL_DATA) $(srcdir)/README-fixinc \
-	    $(DESTDIR)$(itoolsdir)/include/README ; \
+	    $(DESTDIR)$(itoolsdatadir)/include/README ; \
 	  $(INSTALL_SCRIPT) fixinc.sh $(DESTDIR)$(itoolsdir)/fixinc.sh ; \
 	  $(INSTALL_PROGRAM) fixinc/fixincl $(DESTDIR)$(itoolsdir)/fixincl ; \
-	  $(INSTALL_DATA) $(srcdir)/gsyslimits.h $(DESTDIR)$(itoolsdir)/gsyslimits.h ; \
+	  $(INSTALL_DATA) $(srcdir)/gsyslimits.h \
+	    $(DESTDIR)$(itoolsdatadir)/gsyslimits.h ; \
 	else :; fi
 	if [ x$(STMP_FIXPROTO) != x ] ; then \
 	  $(INSTALL_SCRIPT) $(srcdir)/mkinstalldirs \
@@ -3194,23 +3204,26 @@ install-mkheaders: stmp-int-hdrs $(STMP_
 	else :; fi
 	$(INSTALL_SCRIPT) mkheaders $(DESTDIR)$(itoolsdir)/mkheaders
 	echo 'SYSTEM_HEADER_DIR="'"$(SYSTEM_HEADER_DIR)"'"' \
-		> $(DESTDIR)$(itoolsdir)/mkheaders.conf
+		> $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
 	echo 'OTHER_FIXINCLUDES_DIRS="$(OTHER_FIXINCLUDES_DIRS)"' \
-		>> $(DESTDIR)$(itoolsdir)/mkheaders.conf
+		>> $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
 	echo 'FIXPROTO_DEFINES="$(FIXPROTO_DEFINES)"' \
-		>> $(DESTDIR)$(itoolsdir)/mkheaders.conf
-	echo 'STMP_FIXPROTO="$(STMP_FIXPROTO)"' >> $(DESTDIR)$(itoolsdir)/mkheaders.conf
-	echo 'STMP_FIXINC="$(STMP_FIXINC)"' >> $(DESTDIR)$(itoolsdir)/mkheaders.conf
+		>> $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
+	echo 'STMP_FIXPROTO="$(STMP_FIXPROTO)"' \
+		>> $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
+	echo 'STMP_FIXINC="$(STMP_FIXINC)"' \
+		>> $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
 
 # Use this target to install the program `collect2' under the name `collect2'.
 install-collect2: collect2 installdirs
-	$(INSTALL_PROGRAM) collect2$(exeext) $(DESTDIR)$(libsubdir)/collect2$(exeext)
+	$(INSTALL_PROGRAM) collect2$(exeext) $(DESTDIR)$(libexecsubdir)/collect2$(exeext)
 # Install the driver program as $(libsubdir)/gcc for collect2.
-	$(INSTALL_PROGRAM) xgcc$(exeext) $(DESTDIR)$(libsubdir)/gcc$(exeext)
+	$(INSTALL_PROGRAM) xgcc$(exeext) $(DESTDIR)$(libexecsubdir)/gcc$(exeext)
 
 # Cancel installation by deleting the installed files.
 uninstall: lang.uninstall
 	-rm -rf $(DESTDIR)$(libsubdir)
+	-rm -rf $(DESTDIR)$(libexecsubdir)
 	-rm -rf $(DESTDIR)$(bindir)/$(GCC_INSTALL_NAME)$(exeext)
 	-rm -rf $(DESTDIR)$(bindir)/$(GCC_CROSS_NAME)$(exeext)
 	-rm -f $(DESTDIR)$(bindir)/$(CPP_INSTALL_NAME)$(exeext)
Index: gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.389
diff -u -p -u -p -r1.389 gcc.c
--- gcc.c	22 Jul 2003 23:15:27 -0000	1.389
+++ gcc.c	30 Jul 2003 06:45:08 -0000
@@ -1379,6 +1379,10 @@ static const char *just_machine_suffix =
 
 static const char *gcc_exec_prefix;
 
+/* Adjusted value of standard_libexec_prefix.  */
+
+static const char *gcc_libexec_prefix;
+
 /* Default prefixes to attach to command names.  */
 
 #ifdef CROSS_COMPILE  /* Don't use these prefixes for a cross compiler.  */
@@ -1414,7 +1418,8 @@ static const char *gcc_exec_prefix;
 #endif
 
 static const char *const standard_exec_prefix = STANDARD_EXEC_PREFIX;
-static const char *const standard_exec_prefix_1 = "/usr/lib/gcc/";
+static const char *const standard_exec_prefix_1 = "/usr/libexec/gcc/";
+static const char *const standard_exec_prefix_2 = "/usr/lib/gcc/";
 static const char *md_exec_prefix = MD_EXEC_PREFIX;
 
 static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
@@ -1428,6 +1433,8 @@ static const char *tooldir_prefix;
 
 static const char *const standard_bindir_prefix = STANDARD_BINDIR_PREFIX;
 
+static const char *standard_libexec_prefix = STANDARD_LIBEXEC_PREFIX;
+
 /* Subdirectory to use for locating libraries.  Set by
    set_multilib_dir based on the compilation options.  */
 
@@ -3163,15 +3170,24 @@ process_command (int argc, const char *c
   /* Set up the default search paths.  If there is no GCC_EXEC_PREFIX,
      see if we can create it from the pathname specified in argv[0].  */
 
+  gcc_libexec_prefix = standard_libexec_prefix;
 #ifndef VMS
   /* FIXME: make_relative_prefix doesn't yet work for VMS.  */
   if (!gcc_exec_prefix)
     {
       gcc_exec_prefix = make_relative_prefix (argv[0], standard_bindir_prefix,
 					      standard_exec_prefix);
+      gcc_libexec_prefix = make_relative_prefix (argv[0], 
+						 standard_bindir_prefix,
+						 standard_libexec_prefix);
       if (gcc_exec_prefix)
 	putenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL));
     }
+  else
+    gcc_libexec_prefix = make_relative_prefix (gcc_exec_prefix,
+					       standard_exec_prefix,
+					       standard_libexec_prefix);
+#else
 #endif
 
   if (gcc_exec_prefix)
@@ -3190,7 +3206,7 @@ process_command (int argc, const char *c
 	}
 
       set_std_prefix (gcc_exec_prefix, len);
-      add_prefix (&exec_prefixes, gcc_exec_prefix, "GCC",
+      add_prefix (&exec_prefixes, gcc_libexec_prefix, "GCC",
 		  PREFIX_PRIORITY_LAST, 0, NULL, 0);
       add_prefix (&startfile_prefixes, gcc_exec_prefix, "GCC",
 		  PREFIX_PRIORITY_LAST, 0, NULL, 0);
@@ -3729,17 +3745,21 @@ warranty; not even for MERCHANTABILITY o
   /* Use 2 as fourth arg meaning try just the machine as a suffix,
      as well as trying the machine and the version.  */
 #ifndef OS2
-  add_prefix (&exec_prefixes, standard_exec_prefix, "GCC",
+  add_prefix (&exec_prefixes, standard_libexec_prefix, "GCC",
 	      PREFIX_PRIORITY_LAST, 1, warn_std_ptr, 0);
+  add_prefix (&exec_prefixes, standard_libexec_prefix, "BINUTILS",
+	      PREFIX_PRIORITY_LAST, 2, warn_std_ptr, 0);
   add_prefix (&exec_prefixes, standard_exec_prefix, "BINUTILS",
 	      PREFIX_PRIORITY_LAST, 2, warn_std_ptr, 0);
   add_prefix (&exec_prefixes, standard_exec_prefix_1, "BINUTILS",
 	      PREFIX_PRIORITY_LAST, 2, warn_std_ptr, 0);
+  add_prefix (&exec_prefixes, standard_exec_prefix_2, "BINUTILS",
+	      PREFIX_PRIORITY_LAST, 2, warn_std_ptr, 0);
 #endif
 
   add_prefix (&startfile_prefixes, standard_exec_prefix, "BINUTILS",
 	      PREFIX_PRIORITY_LAST, 1, warn_std_ptr, 0);
-  add_prefix (&startfile_prefixes, standard_exec_prefix_1, "BINUTILS",
+  add_prefix (&startfile_prefixes, standard_exec_prefix_2, "BINUTILS",
 	      PREFIX_PRIORITY_LAST, 1, warn_std_ptr, 0);
 
   tooldir_prefix = concat (tooldir_base_prefix, spec_machine,
Index: mkheaders.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/mkheaders.in,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 mkheaders.in
--- mkheaders.in	27 May 2002 04:24:54 -0000	1.1
+++ mkheaders.in	30 Jul 2003 06:45:08 -0000
@@ -64,18 +64,22 @@ local_prefix=@local_prefix@
 exec_prefix=@exec_prefix@
 # Directory in which to put the directories used by the compiler.
 libdir=@libdir@
-# Directory in which the compiler finds executables, libraries, etc.
+libexecdir=@libexecdir@
+# Directory in which the compiler finds libraries, etc.
 libsubdir=${libdir}/gcc-lib/${target_alias}/${version}
+# Directory in which the compiler finds executables
+libexecsubdir=${libexecdir}/gcc/${target_alias}/${version}
 # Since gcc_tooldir does not exist at build-time, use -B${build_tooldir}/bin/
 build_tooldir=${exec_prefix}/${target_alias}
 # Directory to search for site-specific includes.
 local_includedir=${local_prefix}/include
 includedir=${prefix}/include
 
-itoolsdir=${libsubdir}/install-tools
+itoolsdir=${libexecsubdir}/install-tools
+itoolsdatadir=${libsubdir}/install-tools
 incdir=${libsubdir}/include
 
-. ${itoolsdir}/mkheaders.conf
+. ${itoolsdatadir}/mkheaders.conf
 
 cd ${itoolsdir}
 rm -rf ${incdir}/*
@@ -88,11 +92,11 @@ if [ x${STMP_FIXINC} != x ] ; then
 	if [ -f ${incdir}/limits.h ]; then
 	  mv ${incdir}/limits.h ${incdir}/syslimits.h
 	else
-	  cp gsyslimits.h ${incdir}/syslimits.h
+	  cp ${itoolsdatadir}/gsyslimits.h ${incdir}/syslimits.h
 	fi
 fi
 
-cp include/* ${incdir}
+cp ${itoolsdatadir}/include/* ${incdir}
 
 if [ x${STMP_FIXPROTO} != x ] ; then
   mkinstalldirs="${SHELL} ${itoolsdir}/mkinstalldirs"
============================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]