summaryrefslogtreecommitdiff
path: root/lang/gcc2/patches
diff options
context:
space:
mode:
authorwiz <wiz>2015-04-25 10:32:07 +0000
committerwiz <wiz>2015-04-25 10:32:07 +0000
commit9f44df3d791e4ca03bb6259c8c0d64633a2b0c65 (patch)
treee5a6190170e738b22c0f961aae9579f147aa6573 /lang/gcc2/patches
parent61a2d89326831d8344f93ec56cc004bd0e467652 (diff)
downloadpkgsrc-9f44df3d791e4ca03bb6259c8c0d64633a2b0c65.tar.gz
Re-Import gcc2-2.95.3nb7 as lang/gcc2 (previously lang/gcc).
This directory contains the GNU Compiler Collection (GCC) version 2.95. It includes all of the support for compiling C, C++, Objective C, Fortran, Java, and Chill. The GNU Compiler Collection is free software. See the file COPYING for copying permission. See the file gcc.texi (together with other files that it includes) for installation and porting information. The file INSTALL contains a copy of the installation information, as plain ASCII. See the Bugs chapter of the GCC Manual for how to report bugs usefully. An online readable version of the manual is in the files gcc.info*.
Diffstat (limited to 'lang/gcc2/patches')
-rw-r--r--lang/gcc2/patches/patch-Makefile.in15
-rw-r--r--lang/gcc2/patches/patch-aa42
-rw-r--r--lang/gcc2/patches/patch-ab75
-rw-r--r--lang/gcc2/patches/patch-ac26
-rw-r--r--lang/gcc2/patches/patch-ad7
-rw-r--r--lang/gcc2/patches/patch-ae7
-rw-r--r--lang/gcc2/patches/patch-af161
-rw-r--r--lang/gcc2/patches/patch-ag361
-rw-r--r--lang/gcc2/patches/patch-ah15
-rw-r--r--lang/gcc2/patches/patch-ai20
-rw-r--r--lang/gcc2/patches/patch-aj13
-rw-r--r--lang/gcc2/patches/patch-ak13
-rw-r--r--lang/gcc2/patches/patch-al13
-rw-r--r--lang/gcc2/patches/patch-am20
-rw-r--r--lang/gcc2/patches/patch-gcc_Makefile.in356
-rw-r--r--lang/gcc2/patches/patch-gcc_ch_Make-lang.in36
-rw-r--r--lang/gcc2/patches/patch-gcc_cp_Make-lang.in68
-rw-r--r--lang/gcc2/patches/patch-gcc_f_Make-lang.in105
-rw-r--r--lang/gcc2/patches/patch-gcc_intl_Makefile.in39
-rw-r--r--lang/gcc2/patches/patch-gcc_java_Make-lang.in34
-rw-r--r--lang/gcc2/patches/patch-libchill_Makefile.in19
-rw-r--r--lang/gcc2/patches/patch-libf2c_Makefile.in19
-rw-r--r--lang/gcc2/patches/patch-libio_Makefile.in31
23 files changed, 1495 insertions, 0 deletions
diff --git a/lang/gcc2/patches/patch-Makefile.in b/lang/gcc2/patches/patch-Makefile.in
new file mode 100644
index 00000000000..0f438e2b00e
--- /dev/null
+++ b/lang/gcc2/patches/patch-Makefile.in
@@ -0,0 +1,15 @@
+$NetBSD: patch-Makefile.in,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- Makefile.in.orig 1999-06-22 22:44:42.000000000 +0000
++++ Makefile.in
+@@ -1670,8 +1670,8 @@ install-target: $(INSTALL_TARGET_MODULES
+ ### other supporting targets
+
+ MAKEDIRS= \
+- $(prefix) \
+- $(exec_prefix)
++ $(DESTDIR)$(prefix) \
++ $(DESTDIR)$(exec_prefix)
+ .PHONY: installdirs
+ installdirs: mkinstalldirs
+ $(SHELL) $(srcdir)/mkinstalldirs $(MAKEDIRS)
diff --git a/lang/gcc2/patches/patch-aa b/lang/gcc2/patches/patch-aa
new file mode 100644
index 00000000000..136e0805467
--- /dev/null
+++ b/lang/gcc2/patches/patch-aa
@@ -0,0 +1,42 @@
+$NetBSD: patch-aa,v 1.1 2015/04/25 10:32:07 wiz Exp $
+from revision 1.5 of patch-ae:
+
+Hand edit the alpha/netbsd.h patch. -current gcc relies on a new linker script
+which only differs in setting the entry point. Let this use the default
+linker script for alpha but force the entry point so this will work on older
+NetBSD installs for alpha. For NetBSD-1.6 and newer, we don't need to change
+the link spec.
+
+--- ../gcc-2.95.3/gcc/config/alpha/netbsd.h.orig Tue Nov 25 17:51:14 2003
++++ ../gcc-2.95.3/gcc/config/alpha/netbsd.h
+@@ -58,6 +58,8 @@ Boston, MA 02111-1307, USA. */
+ common to all ELF targets, except for the name of the start function. */
+
+ #undef LINK_SPEC
++#include <sys/param.h>
++#if defined(__NetBSD_Version__) && __NetBSD_Version__ >= 106000000
+ #define LINK_SPEC \
+ "-m elf64alpha_nbsd \
+ %{O*:-O3} %{!O*:-O1} \
+@@ -70,6 +72,21 @@ Boston, MA 02111-1307, USA. */
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
+ %{static:-static}}"
++#else
++#define LINK_SPEC \
++ "-m elf64alpha \
++ -e __start \
++ %{O*:-O3} %{!O*:-O1} \
++ %{assert*} %{R*} \
++ %{shared:-shared} \
++ %{!shared: \
++ -dc -dp \
++ %{!nostdlib:%{!r*:%{!e*:-e __start}}} \
++ %{!static: \
++ %{rdynamic:-export-dynamic} \
++ %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
++ %{static:-static}}"
++#endif
+
+ /* Names to predefine in the preprocessor for this target machine.
+ XXX NetBSD, by convention, shouldn't do __alpha, but lots of applications
diff --git a/lang/gcc2/patches/patch-ab b/lang/gcc2/patches/patch-ab
new file mode 100644
index 00000000000..1c95a32f369
--- /dev/null
+++ b/lang/gcc2/patches/patch-ab
@@ -0,0 +1,75 @@
+$NetBSD: patch-ab,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+Enable building the shared libstdc++
+
+also make the sersion number the same as the one we ship with netbsd-1.6 as
+we use the same sources.
+
+--- libstdc++/Makefile.in.orig 2011-07-12 16:44:41.000000000 +0400
++++ libstdc++/Makefile.in 2011-07-12 16:56:07.000000000 +0400
+@@ -14,7 +14,7 @@
+ # along with this library; see the file COPYING. If not, write to the Free
+ # Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+-VERSION = 2.10.0nb1
++VERSION = 4.0
+ INTERFACE = 3
+
+ gxx_include_dir=${includedir}/g++
+@@ -43,7 +43,7 @@
+
+ STAMP = bigstmp
+
+-LIBS = $(ARLIB) $(ARLINK)
++LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK)
+
+ #### package, host, target, and site dependent Makefile fragments come in here.
+ ##
+@@ -263,34 +263,34 @@
+ if [ -z "$(MULTISUBDIR)" ]; then \
+ cd $(srcdir); \
+ for FILE in $(HEADERS); do \
+- rm -f $(gxx_include_dir)/$$FILE ; \
++ rm -f $(DESTDIR)$(gxx_include_dir)/$$FILE ; \
+ if [ -f stl/$$FILE ]; then \
+- $(INSTALL_DATA) stl/$$FILE $(gxx_include_dir)/$$FILE ; \
++ $(INSTALL_DATA) stl/$$FILE $(DESTDIR)$(gxx_include_dir)/$$FILE ; \
+ else \
+- $(INSTALL_DATA) $$FILE $(gxx_include_dir)/$$FILE ; \
++ $(INSTALL_DATA) $$FILE $(DESTDIR)$(gxx_include_dir)/$$FILE ; \
+ fi ; \
+- chmod a-x $(gxx_include_dir)/$$FILE ; \
++ chmod a-x $(DESTDIR)$(gxx_include_dir)/$$FILE ; \
+ done ; \
+ for FILE in *.h std/*.h std/*.cc std/*.tcc; do \
+- rm -f $(gxx_include_dir)/$$FILE ; \
+- $(INSTALL_DATA) $$FILE $(gxx_include_dir)/$$FILE ; \
+- chmod a-x $(gxx_include_dir)/$$FILE ; \
++ rm -f $(DESTDIR)$(gxx_include_dir)/$$FILE ; \
++ $(INSTALL_DATA) $$FILE $(DESTDIR)$(gxx_include_dir)/$$FILE ; \
++ chmod a-x $(DESTDIR)$(gxx_include_dir)/$$FILE ; \
+ done ; \
+ cd stl; \
+ for FILE in *.h; do \
+- rm -f $(gxx_include_dir)/$$FILE ; \
+- $(INSTALL_DATA) $$FILE $(gxx_include_dir)/$$FILE ; \
+- chmod a-x $(gxx_include_dir)/$$FILE ; \
++ rm -f $(DESTDIR)$(gxx_include_dir)/$$FILE ; \
++ $(INSTALL_DATA) $$FILE $(DESTDIR)$(gxx_include_dir)/$$FILE ; \
++ chmod a-x $(DESTDIR)$(gxx_include_dir)/$$FILE ; \
+ done ; \
+ else true ; \
+ fi
+ rootme=`pwd`/ ; export rootme ; \
+ if [ x$(enable_version_specific_runtime_libs) != xyes ]; then \
+- INSTALLDIR=$(libdir); \
++ INSTALLDIR=$(DESTDIR)$(libdir); \
+ else \
+- INSTALLDIR=$(libsubdir); \
++ INSTALLDIR=$(DESTDIR)$(libsubdir); \
+ fi; \
+- INSTALLLINKDIR=$(libsubdir); \
++ INSTALLLINKDIR=$(DESTDIR)$(libsubdir); \
+ if [ $${INSTALLLINKDIR}$(MULTISUBDIR) = $${INSTALLDIR}$(MULTISUBDIR) ]; then \
+ RELINSTALLDIR=; \
+ elif [ x$(MULTISUBDIR) = x ]; then \
diff --git a/lang/gcc2/patches/patch-ac b/lang/gcc2/patches/patch-ac
new file mode 100644
index 00000000000..c325be408e0
--- /dev/null
+++ b/lang/gcc2/patches/patch-ac
@@ -0,0 +1,26 @@
+$NetBSD: patch-ac,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- libiberty/Makefile.in.orig 2011-07-12 16:13:20.000000000 +0400
++++ libiberty/Makefile.in 2011-07-12 16:41:39.000000000 +0400
+@@ -57,7 +57,7 @@
+ LIBCFLAGS = $(CFLAGS)
+ RANLIB = @RANLIB@
+
+-PICFLAG =
++PICFLAG = -fPIC -DPIC
+
+ MAKEOVERRIDES =
+
+@@ -155,9 +155,9 @@
+ install: install_to_$(INSTALL_DEST) install-subdir
+
+ install_to_libdir: all
+- $(INSTALL_DATA) $(TARGETLIB) $(libdir)$(MULTISUBDIR)/$(TARGETLIB)n
+- ( cd $(libdir)$(MULTISUBDIR) ; $(RANLIB) $(TARGETLIB)n )
+- mv -f $(libdir)$(MULTISUBDIR)/$(TARGETLIB)n $(libdir)$(MULTISUBDIR)/$(TARGETLIB)
++ $(INSTALL_DATA) $(TARGETLIB) $(DESTDIR)$(libdir)$(MULTISUBDIR)/$(TARGETLIB)n
++ ( cd $(DESTDIR)$(libdir)$(MULTISUBDIR) ; $(RANLIB) $(TARGETLIB)n )
++ mv -f $(DESTDIR)$(libdir)$(MULTISUBDIR)/$(TARGETLIB)n $(DESTDIR)$(libdir)$(MULTISUBDIR)/$(TARGETLIB)
+ @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
+
+ install_to_tooldir: all
diff --git a/lang/gcc2/patches/patch-ad b/lang/gcc2/patches/patch-ad
new file mode 100644
index 00000000000..163523ef17d
--- /dev/null
+++ b/lang/gcc2/patches/patch-ad
@@ -0,0 +1,7 @@
+$NetBSD: patch-ad,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- ../gcc-2.95.3/config/mh-sparcpic.orig Thu Feb 5 19:33:03 1998
++++ ../gcc-2.95.3/config/mh-sparcpic
+@@ -1 +1 @@
+-PICFLAG=`case "${LIBCFLAGS} ${LIBCXXFLAGS}" in *-fpic* ) echo -fpic ;; * ) echo -fPIC ;; esac`
++PICFLAG=`case '${LIBCFLAGS} ${LIBCXXFLAGS}' in *-fpic* ) echo -fpic ;; * ) echo -fPIC ;; esac`
diff --git a/lang/gcc2/patches/patch-ae b/lang/gcc2/patches/patch-ae
new file mode 100644
index 00000000000..3280b9bc4c0
--- /dev/null
+++ b/lang/gcc2/patches/patch-ae
@@ -0,0 +1,7 @@
+$NetBSD: patch-ae,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- ../gcc-2.95.3/config/mt-sparcpic.orig Thu Feb 5 19:33:04 1998
++++ ../gcc-2.95.3/config/mt-sparcpic
+@@ -1 +1 @@
+-PICFLAG_FOR_TARGET=`case "${LIBCFLAGS} ${LIBCXXFLAGS}" in *-fpic* ) echo -fpic ;; * ) echo -fPIC ;; esac`
++PICFLAG_FOR_TARGET=`case '${LIBCFLAGS} ${LIBCXXFLAGS}' in *-fpic* ) echo -fpic ;; * ) echo -fPIC ;; esac`
diff --git a/lang/gcc2/patches/patch-af b/lang/gcc2/patches/patch-af
new file mode 100644
index 00000000000..cedb7b2e3cc
--- /dev/null
+++ b/lang/gcc2/patches/patch-af
@@ -0,0 +1,161 @@
+$NetBSD: patch-af,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- ../gcc-2.95.3/gcc/config/netbsd.h
++++ ../gcc-2.95.3/gcc/config/netbsd.h.orig
+@@ -36,10 +36,13 @@
+
+
+ /* Provide a CPP_SPEC appropriate for NetBSD. Current we just deal with
+- the GCC option `-posix'. */
++ the GCC option `-posix'. We also deal with -pthread, which is required
++ for the 2.95.3 STL to work. */
+
+ #undef CPP_SPEC
+-#define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE}"
++#define CPP_SPEC \
++ "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
++ %{pthread:-D_REENTRANT -D_PTHREADS}"
+
+ /* Provide an ASM_SPEC appropriate for NetBSD. Currently we only deal
+ with the options for generating PIC code. */
+@@ -54,7 +57,8 @@
+
+ #undef LIB_SPEC
+ #define LIB_SPEC \
+- "%{posix:%{!p:%{!pg:-lposix}}%{p:-lposix_p}%{pg:-lposix_p}} \
++ "%{pthread:%{!p:%{!pg:-lpthread}}%{p:-lpthread_p}%{pg:-lpthread_p}} \
++ %{posix:%{!p:%{!pg:-lposix}}%{p:-lposix_p}%{pg:-lposix_p}} \
+ %{!shared:%{!symbolic:%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}}"
+
+ /* Provide a LIBGCC_SPEC appropriate for NetBSD. We also want to exclude
+@@ -64,7 +68,7 @@
+ #ifdef NETBSD_NATIVE
+ #define LIBGCC_SPEC "%{!symbolic:%{!shared:%{!p:%{!pg:-lgcc}}}%{shared:-lgcc_pic}%{p:-lgcc_p}%{pg:-lgcc_p}}"
+ #else
+-#define LIBGCC_SPEC "%{!shared:%{!symbolic:-lgcc}}"
++#define LIBGCC_SPEC "%{!symbolic:%{!shared:-lgcc}%{shared:-lgcc_pic}}"
+ #endif
+
+ /* #ifdef NETBSD_AOUT */
+@@ -147,6 +151,96 @@
+ #define ASM_DECLARE_RESULT(FILE, RESULT)
+ #endif
+
++/* NetBSD a.out support begins here. */
++
++#ifndef NETBSD_ELF
++
++#undef DWARF_DEBUGGING_INFO /* XXX */
++#undef DWARF2_DEBUGGING_INFO /* XXX */
++
++/* Write the extra assembler code needed to declare a function properly.
++ Some svr4 assemblers need to also have something extra said about the
++ function's return value. We allow for that here. */
++
++#undef ASM_DECLARE_FUNCTION_NAME
++#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
++ do { \
++ fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
++ assemble_name (FILE, NAME); \
++ putc (',', FILE); \
++ fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
++ putc ('\n', FILE); \
++ ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
++ ASM_OUTPUT_LABEL(FILE, NAME); \
++ } while (0)
++
++/* Write the extra assembler code needed to declare an object properly. */
++
++#undef ASM_DECLARE_OBJECT_NAME
++#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
++ do { \
++ fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
++ assemble_name (FILE, NAME); \
++ putc (',', FILE); \
++ fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
++ putc ('\n', FILE); \
++ size_directive_output = 0; \
++ if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
++ { \
++ size_directive_output = 1; \
++ fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
++ assemble_name (FILE, NAME); \
++ fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
++ } \
++ ASM_OUTPUT_LABEL(FILE, NAME); \
++ } while (0)
++
++/* Output the size directive for a decl in rest_of_decl_compilation
++ in the case where we did not do so before the initializer.
++ Once we find the error_mark_node, we know that the value of
++ size_directive_output was set
++ by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
++
++#undef ASM_FINISH_DECLARE_OBJECT
++#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
++do { \
++ char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
++ if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
++ && ! AT_END && TOP_LEVEL \
++ && DECL_INITIAL (DECL) == error_mark_node \
++ && !size_directive_output) \
++ { \
++ size_directive_output = 1; \
++ fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
++ assemble_name (FILE, name); \
++ fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
++ } \
++ } while (0)
++
++/* This is how to declare the size of a function. */
++
++#undef ASM_DECLARE_FUNCTION_SIZE
++#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
++ do { \
++ if (!flag_inhibit_size_directive) \
++ { \
++ char label[256]; \
++ static int labelno; \
++ labelno++; \
++ ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \
++ ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \
++ fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
++ assemble_name (FILE, (FNAME)); \
++ fprintf (FILE, ","); \
++ assemble_name (FILE, label); \
++ fprintf (FILE, "-"); \
++ assemble_name (FILE, (FNAME)); \
++ putc ('\n', FILE); \
++ } \
++ } while (0)
++
++#endif
++
+ /* NetBSD ELF support begins here. */
+
+ #ifdef NETBSD_ELF
+@@ -167,6 +261,7 @@
+ %{!pg: \
+ %{p:gcrt0%O%s} \
+ %{!p:crt0%O%s}}} \
++ %:if-exists(crti%O%s) \
+ %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}"
+
+ /* Provide an ENDFILE_SPEC appropriate for NetBSD ELF targets. Here we
+@@ -175,13 +270,14 @@
+
+ #undef ENDFILE_SPEC
+ #define ENDFILE_SPEC \
+- "%{!shared:crtend%O%s} %{shared:crtendS%O%s}"
++ "%{!shared:crtend%O%s} %{shared:crtendS%O%s} \
++ %:if-exists(crtn%O%s)"
+
+ /* Provide a LINK_SPEC appropriate for a NetBSD ELF target. */
+
+ #undef LINK_SPEC
+ #define LINK_SPEC \
+- "%{assert*} \
++ "%{assert*} %{R*} \
+ %{shared:-shared} \
+ %{!shared: \
+ -dc -dp \
diff --git a/lang/gcc2/patches/patch-ag b/lang/gcc2/patches/patch-ag
new file mode 100644
index 00000000000..1050f37f12b
--- /dev/null
+++ b/lang/gcc2/patches/patch-ag
@@ -0,0 +1,361 @@
+$NetBSD: patch-ag,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- ../gcc-2.95.3/gcc/gcc.c.orig
++++ ../gcc-2.95.3/gcc/gcc.c
+@@ -189,9 +189,13 @@
+ static void clear_failure_queue PROTO((void));
+ static int check_live_switch PROTO((int, int));
+ static const char *handle_braces PROTO((const char *));
++static const struct spec_function *lookup_spec_function PROTO((const char *));
++static const char *eval_spec_function PROTO((const char *, const char *));
++static const char *handle_spec_function PROTO((const char *));
+ static char *save_string PROTO((const char *, int));
+ extern int do_spec PROTO((const char *));
+ static int do_spec_1 PROTO((const char *, int, const char *));
++static int do_spec_2 PROTO((const char *));
+ static const char *find_file PROTO((const char *));
+ static int is_directory PROTO((const char *, const char *, int));
+ static void validate_switches PROTO((const char *));
+@@ -216,6 +220,7 @@
+ static void process_command PROTO ((int, char **));
+ static int execute PROTO ((void));
+ static void unused_prefix_warnings PROTO ((struct path_prefix *));
++static void alloc_args PROTO ((void));
+ static void clear_args PROTO ((void));
+ static void fatal_error PROTO ((int));
+
+@@ -231,6 +236,8 @@
+ /* Number of extra output files that lang_specific_pre_link may generate. */
+ extern int lang_specific_extra_outfiles;
+
++static const char *if_exists_spec_function PROTO ((int, const char **));
++
+ /* Specs are strings containing lines, each of which (if not blank)
+ is made up of a program name, and arguments separated by spaces.
+ The program name must be exact and start from root, since no path
+@@ -335,6 +342,12 @@
+ %* substitute the variable part of a matched option. (See below.)
+ Note that each comma in the substituted string is replaced by
+ a single space.
++ %:function(args)
++ Call the named function FUNCTION, passing it ARGS. ARGS is
++ first processed as a nested spec string, then split into an
++ argument vector in the usual fashion. The function returns
++ a string which is processed as if it had appeared literally
++ as part of the current spec.
+ %{S} substitutes the -S switch, if that switch was given to CC.
+ If that switch was not specified, this substitutes nothing.
+ Here S is a metasyntactic variable.
+@@ -1162,6 +1175,24 @@
+ static struct spec_list *specs = (struct spec_list *)0;
+
+
++/* The mapping of a spec function name to the C function that
++ implements it. */
++struct spec_function
++{
++ const char *name;
++ const char *(*func) PROTO ((int, const char **));
++};
++
++/* List of static spec functions. */
++
++static const struct spec_function static_spec_functions[] =
++{
++ { "if-exists", if_exists_spec_function },
++ { 0, 0 }
++};
++
++static int processing_spec_function;
++
+ /* Initialize the specs lookup routines. */
+
+ static void
+@@ -1404,6 +1435,15 @@
+
+ static const char *multilib_dir;
+
++/* Allocate the argument vector. */
++
++static void
++alloc_args ()
++{
++ argbuf_length = 10;
++ argbuf = (char **) xmalloc (argbuf_length * sizeof (char *));
++}
++
+ /* Clear out the vector of arguments (after a command is executed). */
+
+ static void
+@@ -2211,6 +2251,9 @@
+
+ struct command *commands; /* each command buffer with above info. */
+
++ if (processing_spec_function)
++ abort ();
++
+ /* Count # of piped commands. */
+ for (n_commands = 1, i = 0; i < argbuf_index; i++)
+ if (strcmp (argbuf[i], "|") == 0)
+@@ -3360,14 +3403,7 @@
+ {
+ int value;
+
+- clear_args ();
+- arg_going = 0;
+- delete_this_arg = 0;
+- this_is_output_file = 0;
+- this_is_library_file = 0;
+- input_from_pipe = 0;
+-
+- value = do_spec_1 (spec, 0, NULL_PTR);
++ value = do_spec_2 (spec);
+
+ /* Force out any unfinished command.
+ If -pipe, this forces out the last command if it ended in `|'. */
+@@ -3383,6 +3419,20 @@
+ return value;
+ }
+
++static int
++do_spec_2 (spec)
++ const char *spec;
++{
++ clear_args ();
++ arg_going = 0;
++ delete_this_arg = 0;
++ this_is_output_file = 0;
++ this_is_library_file = 0;
++ input_from_pipe = 0;
++
++ return do_spec_1 (spec, 0, NULL_PTR);
++}
++
+ /* Process the sub-spec SPEC as a portion of a larger spec.
+ This is like processing a whole spec except that we do
+ not initialize at the beginning and we do not supply a
+@@ -4068,6 +4118,12 @@
+ return -1;
+ break;
+
++ case ':':
++ p = handle_spec_function (p);
++ if (p == 0)
++ return -1;
++ break;
++
+ case '%':
+ obstack_1grow (&obstack, '%');
+ break;
+@@ -4222,7 +4278,173 @@
+ arg_going = 1;
+ }
+
+- return 0; /* End of string */
++ /* End of string. If we are processing a spec function, we need to
++ end any pending argument. */
++ if (processing_spec_function && arg_going)
++ {
++ obstack_1grow (&obstack, 0);
++ string = obstack_finish (&obstack);
++ if (this_is_library_file)
++ string = find_file (string);
++ store_arg (string, delete_this_arg, this_is_output_file);
++ if (this_is_output_file)
++ outfiles[input_file_number] = string;
++ arg_going = 0;
++ }
++
++ return 0;
++}
++
++/* Look up a spec function. */
++
++static const struct spec_function *
++lookup_spec_function (name)
++ const char *name;
++{
++ static const struct spec_function * const spec_function_tables[] =
++ {
++ static_spec_functions,
++ };
++ const struct spec_function *sf;
++ unsigned int i;
++
++ for (i = 0; i < ARRAY_SIZE (spec_function_tables); i++)
++ {
++ for (sf = spec_function_tables[i]; sf->name != NULL; sf++)
++ if (strcmp (sf->name, name) == 0)
++ return sf;
++ }
++
++ return NULL;
++}
++
++/* Evaluate a spec function. */
++
++static const char *
++eval_spec_function (func, args)
++ const char *func, *args;
++{
++ const struct spec_function *sf;
++ const char *funcval;
++
++ /* Saved spec processing context. */
++ int save_argbuf_index;
++ int save_argbuf_length;
++ char **save_argbuf;
++
++ int save_arg_going;
++ int save_delete_this_arg;
++ int save_this_is_output_file;
++ int save_this_is_library_file;
++ int save_input_from_pipe;
++
++
++ sf = lookup_spec_function (func);
++ if (sf == NULL)
++ fatal ("unknown spec function `%s'", func);
++
++ /* Push the spec processing context. */
++ save_argbuf_index = argbuf_index;
++ save_argbuf_length = argbuf_length;
++ save_argbuf = argbuf;
++
++ save_arg_going = arg_going;
++ save_delete_this_arg = delete_this_arg;
++ save_this_is_output_file = this_is_output_file;
++ save_this_is_library_file = this_is_library_file;
++ save_input_from_pipe = input_from_pipe;
++
++ /* Create a new spec processing context, and build the function
++ arguments. */
++
++ alloc_args ();
++ if (do_spec_2 (args) < 0)
++ fatal ("error in args to spec function `%s'", func);
++
++ /* argbuf_index is an index for the next argument to be inserted, and
++ so contains the count of the args already inserted. */
++
++ funcval = (*sf->func) (argbuf_index, (const char **) argbuf);
++
++ /* Pop the spec processing context. */
++ argbuf_index = save_argbuf_index;
++ argbuf_length = save_argbuf_length;
++ free (argbuf);
++ argbuf = save_argbuf;
++
++ arg_going = save_arg_going;
++ delete_this_arg = save_delete_this_arg;
++ this_is_output_file = save_this_is_output_file;
++ this_is_library_file = save_this_is_library_file;
++ input_from_pipe = save_input_from_pipe;
++
++ return funcval;
++}
++
++/* Handle a spec function call of the form:
++
++ %:function(args)
++
++ ARGS is processed as a spec in a separate context and split into an
++ argument vector in the normal fashion. The function returns a string
++ containing a spec which we then process in the caller's context, or
++ NULL if no processing is required. */
++
++static const char *
++handle_spec_function (p)
++ const char *p;
++{
++ char *func, *args;
++ const char *endp, *funcval;
++ int count;
++
++ processing_spec_function++;
++
++ /* Get the function name. */
++ for (endp = p; *endp != '\0'; endp++)
++ {
++ if (*endp == '(') /* ) */
++ break;
++ /* Only allow [A-Za-z0-9], -, and _ in function names. */
++ if (!ISALNUM (*endp) && !(*endp == '-' || *endp == '_'))
++ fatal ("malformed spec function name");
++ }
++ if (*endp != '(') /* ) */
++ fatal ("no arguments for spec function");
++ func = save_string (p, endp - p);
++ p = ++endp;
++
++ /* Get the arguments. */
++ for (count = 0; *endp != '\0'; endp++)
++ {
++ /* ( */
++ if (*endp == ')')
++ {
++ if (count == 0)
++ break;
++ count--;
++ }
++ else if (*endp == '(') /* ) */
++ count++;
++ }
++ /* ( */
++ if (*endp != ')')
++ fatal ("malformed spec function arguments");
++ args = save_string (p, endp - p);
++ p = ++endp;
++
++ /* p now points to just past the end of the spec function expression. */
++
++ funcval = eval_spec_function (func, args);
++ if (funcval != NULL && do_spec_1 (funcval, 0, NULL) < 0)
++ p = NULL;
++
++ free (func);
++ free (args);
++
++ processing_spec_function--;
++
++ return p;
+ }
+
+ /* Return 0 if we call do_spec_1 and that returns -1. */
+@@ -4674,8 +4896,8 @@
+ signal (SIGPIPE, fatal_error);
+ #endif
+
+- argbuf_length = 10;
+- argbuf = (char **) xmalloc (argbuf_length * sizeof (char *));
++ /* Allocate the argument vector. */
++ alloc_args ();
+
+ obstack_init (&obstack);
+
+@@ -5846,3 +6068,25 @@
+ ++p;
+ }
+ }
++
++/* if-exists built-in spec function.
++
++ Checks to see if the file specified by the absolute pathname in
++ ARGS exists. Returns that pathname if found.
++
++ The usual use for this function is to check for a library file
++ (whose name has been expanded with %s). */
++
++#define IS_ABSOLUTE_PATHNAME(cp) ((cp)[0] == '/')
++
++static const char *
++if_exists_spec_function (argc, argv)
++ int argc;
++ const char **argv;
++{
++ /* Must have only one argument. */
++ if (argc == 1 && IS_ABSOLUTE_PATHNAME (argv[0]) && ! access (argv[0], R_OK))
++ return argv[0];
++
++ return NULL;
++}
diff --git a/lang/gcc2/patches/patch-ah b/lang/gcc2/patches/patch-ah
new file mode 100644
index 00000000000..9177d65546e
--- /dev/null
+++ b/lang/gcc2/patches/patch-ah
@@ -0,0 +1,15 @@
+$NetBSD: patch-ah,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- gcc/ch/loop.c.orig 1999-01-11 05:17:29.000000000 -0800
++++ gcc/ch/loop.c
+@@ -318,8 +318,8 @@ the 'increment_temps' step must incremen
+ (associated with all iterators).
+
+ NOTE: Z.200, section 10.1 says that a block is ...
+- "the actions statement list in a do action, including any
+- loop counter and while control". This means that an exp-
++ ``the actions statement list in a do action, including any
++ loop counter and while control''. This means that an exp-
+ ression in a WHILE control can include references to the
+ loop counters created for the loop''s exclusive use.
+ Example:
diff --git a/lang/gcc2/patches/patch-ai b/lang/gcc2/patches/patch-ai
new file mode 100644
index 00000000000..6333e3fbcf8
--- /dev/null
+++ b/lang/gcc2/patches/patch-ai
@@ -0,0 +1,20 @@
+$NetBSD: patch-ai,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- gcc/java/parse.y.orig 2010-10-12 22:33:34.000000000 +0000
++++ gcc/java/parse.y
+@@ -10164,6 +10164,7 @@ resolve_type_during_patch (type)
+ }
+ /* 5.5 Casting Conversion. error_mark_node is returned if an error is
+ found. Otherwise NODE or something meant to replace it is returned. */
++static tree convert_narrow ();
+
+ static tree
+ patch_cast (node, wfl_operator)
+@@ -10182,7 +10183,6 @@ patch_cast (node, wfl_operator)
+ /* Check on cast that are proven correct at compile time */
+ if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
+ {
+- static tree convert_narrow ();
+ /* Same type */
+ if (cast_type == op_type)
+ return node;
diff --git a/lang/gcc2/patches/patch-aj b/lang/gcc2/patches/patch-aj
new file mode 100644
index 00000000000..d606b5e1562
--- /dev/null
+++ b/lang/gcc2/patches/patch-aj
@@ -0,0 +1,13 @@
+$NetBSD: patch-aj,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- gcc/f/com.c.orig 2010-10-12 22:37:49.000000000 +0000
++++ gcc/f/com.c
+@@ -11539,7 +11539,7 @@ ffecom_get_invented_identifier (const ch
+ return decl;
+ }
+
+-ffeinfoBasictype
++ffeinfoKindtype
+ ffecom_gfrt_basictype (ffecomGfrt gfrt)
+ {
+ assert (gfrt < FFECOM_gfrt);
diff --git a/lang/gcc2/patches/patch-ak b/lang/gcc2/patches/patch-ak
new file mode 100644
index 00000000000..965fd82c4fa
--- /dev/null
+++ b/lang/gcc2/patches/patch-ak
@@ -0,0 +1,13 @@
+$NetBSD: patch-ak,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- gcc/ch/decl.c.orig 2010-10-12 22:41:57.000000000 +0000
++++ gcc/ch/decl.c
+@@ -4446,7 +4446,7 @@ complete_array_type (type, initial_value
+
+ tree
+ start_struct (code, name)
+- enum chill_tree_code code;
++ enum tree_code code;
+ tree name ATTRIBUTE_UNUSED;
+ {
+ /* If there is already a tag defined at this binding level
diff --git a/lang/gcc2/patches/patch-al b/lang/gcc2/patches/patch-al
new file mode 100644
index 00000000000..e6a94a789a5
--- /dev/null
+++ b/lang/gcc2/patches/patch-al
@@ -0,0 +1,13 @@
+$NetBSD: patch-al,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- gcc/ch/expr.c.orig 2010-10-12 22:47:21.000000000 +0000
++++ gcc/ch/expr.c
+@@ -3490,7 +3490,7 @@ compare_records (exp0, exp1)
+
+ int
+ compare_int_csts (op, val1, val2)
+- enum tree_code op;
++ enum chill_tree_code op;
+ tree val1, val2;
+ {
+ int result;
diff --git a/lang/gcc2/patches/patch-am b/lang/gcc2/patches/patch-am
new file mode 100644
index 00000000000..1a862e4129b
--- /dev/null
+++ b/lang/gcc2/patches/patch-am
@@ -0,0 +1,20 @@
+$NetBSD: patch-am,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- gcc/java/parse.c.orig 2001-03-16 14:13:48.000000000 +0000
++++ gcc/java/parse.c
+@@ -12818,6 +12818,7 @@ resolve_type_during_patch (type)
+ }
+ /* 5.5 Casting Conversion. error_mark_node is returned if an error is
+ found. Otherwise NODE or something meant to replace it is returned. */
++static tree convert_narrow ();
+
+ static tree
+ patch_cast (node, wfl_operator)
+@@ -12836,7 +12837,6 @@ patch_cast (node, wfl_operator)
+ /* Check on cast that are proven correct at compile time */
+ if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
+ {
+- static tree convert_narrow ();
+ /* Same type */
+ if (cast_type == op_type)
+ return node;
diff --git a/lang/gcc2/patches/patch-gcc_Makefile.in b/lang/gcc2/patches/patch-gcc_Makefile.in
new file mode 100644
index 00000000000..8ec95519437
--- /dev/null
+++ b/lang/gcc2/patches/patch-gcc_Makefile.in
@@ -0,0 +1,356 @@
+$NetBSD: patch-gcc_Makefile.in,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- gcc/Makefile.in.orig 2011-07-15 08:28:24.000000000 +0000
++++ gcc/Makefile.in
+@@ -2159,10 +2159,10 @@ stmp-fixinc: fixinc.sh gsyslimits.h
+ # won't work because libsubdir doesn't exist yet.
+ if [ "$(SYSTEM_HEADER_DIR)" = "$(tooldir)/sys-include" ] \
+ && [ -d $(tooldir)/sys-include ]; then \
+- if [ -d $(libdir) ] ; then true ; else mkdir $(libdir) ; fi; \
+- if [ -d $(libdir)/gcc-lib ] ; then true ; else mkdir $(libdir)/gcc-lib; fi; \
+- if [ -d $(libdir)/gcc-lib/$(target_alias) ] ; then true ; else mkdir $(libdir)/gcc-lib/$(target_alias) ; fi; \
+- if [ -d $(libdir)/gcc-lib/$(target_alias)/$(version) ] ; then true ; else mkdir $(libdir)/gcc-lib/$(target_alias)/$(version) ; fi; \
++ if [ -d $(DESTDIR)$(libdir) ] ; then true ; else mkdir $(DESTDIR)$(libdir) ; fi; \
++ if [ -d $(DESTDIR)$(libdir)/gcc-lib ] ; then true ; else mkdir $(DESTDIR)$(libdir)/gcc-lib; fi; \
++ if [ -d $(DESTDIR)$(libdir)/gcc-lib/$(target_alias) ] ; then true ; else mkdir $(DESTDIR)$(libdir)/gcc-lib/$(target_alias) ; fi; \
++ if [ -d $(DESTDIR)$(libdir)/gcc-lib/$(target_alias)/$(version) ] ; then true ; else mkdir $(DESTDIR)$(libdir)/gcc-lib/$(target_alias)/$(version) ; fi; \
+ else true; fi
+
+ touch stmp-fixinc
+@@ -2429,11 +2429,11 @@ install-cross-rest: install-float-h-cros
+
+ # Handle cpp installation.
+ install-cpp: cpp$(exeext)
+- -rm -f $(bindir)/$(CPP_INSTALL_NAME)$(exeext)
+- $(INSTALL_PROGRAM) -m 755 cpp$(exeext) $(bindir)/$(CPP_INSTALL_NAME)$(exeext)
++ -rm -f $(DESTDIR)$(bindir)/$(CPP_INSTALL_NAME)$(exeext)
++ $(INSTALL_PROGRAM) -m 755 cpp$(exeext) $(DESTDIR)$(bindir)/$(CPP_INSTALL_NAME)$(exeext)
+ if [ x$(cpp_install_dir) != x ]; then \
+- rm -f $(prefix)/$(cpp_install_dir)/$(CPP_INSTALL_NAME)$(exeext); \
+- $(INSTALL_PROGRAM) -m 755 cpp$(exeext) $(prefix)/$(cpp_install_dir)/$(CPP_INSTALL_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(prefix)/$(cpp_install_dir)/$(CPP_INSTALL_NAME)$(exeext); \
++ $(INSTALL_PROGRAM) -m 755 cpp$(exeext) $(DESTDIR)$(prefix)/$(cpp_install_dir)/$(CPP_INSTALL_NAME)$(exeext); \
+ else true; fi
+
+ uninstall-cpp:
+@@ -2449,163 +2449,163 @@ install-float-h-cross: installdirs
+ # if [ -f enquire ] ; then true; else false; fi
+ # Note: don't use -. We should fail right away if enquire was not made.
+ ./enquire -f > $(tmpdir)/float.h
+- -rm -f $(libsubdir)/include/float.h
+- $(INSTALL_DATA) $(tmpdir)/float.h $(libsubdir)/include/float.h
++ -rm -f $(DESTDIR)$(libsubdir)/include/float.h
++ $(INSTALL_DATA) $(tmpdir)/float.h $(DESTDIR)$(libsubdir)/include/float.h
+ -rm -f $(tmpdir)/float.h
+- chmod a-x $(libsubdir)/include/float.h
++ chmod a-x $(DESTDIR)$(libsubdir)/include/float.h
+
+ # Create the installation directories.
+ installdirs:
+- -if [ -d $(prefix) ] ; then true ; else mkdir $(prefix) ; chmod a+rx $(prefix) ; fi
+- -if [ -d $(exec_prefix) ] ; then true ; else mkdir $(exec_prefix) ; chmod a+rx $(exec_prefix) ; fi
+- -if [ -d $(libdir) ] ; then true ; else mkdir $(libdir) ; chmod a+rx $(libdir) ; fi
+- -if [ -d $(libdir)/gcc-lib ] ; then true ; else mkdir $(libdir)/gcc-lib ; chmod a+rx $(libdir)/gcc-lib ; fi
++ -if [ -d $(DESTDIR)$(prefix) ] ; then true ; else mkdir $(DESTDIR)$(prefix) ; chmod a+rx $(DESTDIR)$(prefix) ; fi
++ -if [ -d $(DESTDIR)$(exec_prefix) ] ; then true ; else mkdir $(DESTDIR)$(exec_prefix) ; chmod a+rx $(DESTDIR)$(exec_prefix) ; fi
++ -if [ -d $(DESTDIR)$(libdir) ] ; then true ; else mkdir $(DESTDIR)$(libdir) ; chmod a+rx $(DESTDIR)$(libdir) ; fi
++ -if [ -d $(DESTDIR)$(libdir)/gcc-lib ] ; then true ; else mkdir $(DESTDIR)$(libdir)/gcc-lib ; chmod a+rx $(DESTDIR)$(libdir)/gcc-lib ; fi
+ # This dir isn't currently searched by cpp.
+ # -if [ -d $(libdir)/gcc-lib/include ] ; then true ; else mkdir $(libdir)/gcc-lib/include ; chmod a+rx $(libdir)/gcc-lib/include ; fi
+ -fdir= ; for dir in `echo $(libsubdir) | tr '/' ' '`; do \
+ fdir=$${fdir}/$${dir}; \
+- if [ -d $${fdir} ] ; then true ; else mkdir $${fdir}; chmod a+rx $${fdir}; fi ; \
++ if [ -d $(DESTDIR)$${fdir} ] ; then true ; else mkdir $(DESTDIR)$${fdir}; chmod a+rx $(DESTDIR)$${fdir}; fi ; \
+ done
+- -if [ -d $(bindir) ] ; then true ; else mkdir $(bindir) ; chmod a+rx $(bindir) ; fi
+- -if [ -d $(includedir) ] ; then true ; else mkdir $(includedir) ; chmod a+rx $(includedir) ; fi
+- -if [ -d $(gcc_tooldir) ] ; then true ; else mkdir $(gcc_tooldir) ; chmod a+rx $(gcc_tooldir) ; fi
+- -if [ -d $(assertdir) ] ; then true ; else mkdir $(assertdir) ; chmod a+rx $(assertdir) ; fi
+- -if [ -d $(infodir) ] ; then true ; else mkdir $(infodir) ; chmod a+rx $(infodir) ; fi
++ -if [ -d $(DESTDIR)$(bindir) ] ; then true ; else mkdir $(DESTDIR)$(bindir) ; chmod a+rx $(DESTDIR)$(bindir) ; fi
++ -if [ -d $(DESTDIR)$(includedir) ] ; then true ; else mkdir $(DESTDIR)$(includedir) ; chmod a+rx $(DESTDIR)$(includedir) ; fi
++ -if [ -d $(DESTDIR)$(gcc_tooldir) ] ; then true ; else mkdir $(DESTDIR)$(gcc_tooldir) ; chmod a+rx $(DESTDIR)$(gcc_tooldir) ; fi
++ -if [ -d $(DESTDIR)$(assertdir) ] ; then true ; else mkdir $(DESTDIR)$(assertdir) ; chmod a+rx $(DESTDIR)$(assertdir) ; fi
++ -if [ -d $(DESTDIR)$(infodir) ] ; then true ; else mkdir $(DESTDIR)$(infodir) ; chmod a+rx $(DESTDIR)$(infodir) ; fi
+ # We don't use mkdir -p to create the parents of man1dir,
+ # because some systems don't support it.
+ # Instead, we use this technique to create the immediate parent of man1dir.
+ -parent=`echo $(man1dir)|sed -e 's@/[^/]*$$@@'`; \
+- if [ -d $$parent ] ; then true ; else mkdir $$parent ; chmod a+rx $$parent ; fi
+- -if [ -d $(man1dir) ] ; then true ; else mkdir $(man1dir) ; chmod a+rx $(man1dir) ; fi
++ if [ -d $(DESTDIR)$$parent ] ; then true ; else mkdir $(DESTDIR)$$parent ; chmod a+rx $(DESTDIR)$$parent ; fi
++ -if [ -d $(DESTDIR)$(man1dir) ] ; then true ; else mkdir $(DESTDIR)$(man1dir) ; chmod a+rx $(DESTDIR)$(man1dir) ; fi
+
+ # Install the compiler executables built during cross compilation.
+ install-common: native installdirs $(EXTRA_PARTS) lang.install-common
+ for file in $(COMPILERS); do \
+ if [ -f $$file ] ; then \
+- rm -f $(libsubdir)/$$file; \
+- $(INSTALL_PROGRAM) $$file $(libsubdir)/$$file; \
++ rm -f $(DESTDIR)$(libsubdir)/$$file; \
++ $(INSTALL_PROGRAM) $$file $(DESTDIR)$(libsubdir)/$$file; \
+ else true; \
+ fi; \
+ done
+ for file in $(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(USE_COLLECT2) ..; do \
+ if [ x"$$file" != x.. ]; then \
+- rm -f $(libsubdir)/$$file; \
+- $(INSTALL_PROGRAM) $$file $(libsubdir)/$$file; \
++ rm -f $(DESTDIR)$(libsubdir)/$$file; \
++ $(INSTALL_PROGRAM) $$file $(DESTDIR)$(libsubdir)/$$file; \
+ else true; fi; \
+ done
+ for file in $(EXTRA_PARTS) ..; do \
+ if [ x"$$file" != x.. ]; then \
+- rm -f $(libsubdir)/$$file; \
+- $(INSTALL_DATA) $$file $(libsubdir)/$$file; \
+- chmod a-x $(libsubdir)/$$file; \
++ rm -f $(DESTDIR)$(libsubdir)/$$file; \
++ $(INSTALL_DATA) $$file $(DESTDIR)$(libsubdir)/$$file; \
++ chmod a-x $(DESTDIR)$(libsubdir)/$$file; \
+ else true; fi; \
+ done
+ # Don't mess with specs if it doesn't exist yet.
+ -if [ -f specs ] ; then \
+- rm -f $(libsubdir)/specs; \
+- $(INSTALL_DATA) specs $(libsubdir)/specs; \
+- chmod a-x $(libsubdir)/specs; \
++ rm -f $(DESTDIR)$(libsubdir)/specs; \
++ $(INSTALL_DATA) specs $(DESTDIR)$(libsubdir)/specs; \
++ chmod a-x $(DESTDIR)$(libsubdir)/specs; \
+ fi
+ # Install protoize if it was compiled.
+ -if [ -f protoize$(exeext) ]; \
+ then \
+ if [ -f gcc-cross$(exeext) ] ; then \
+- rm -f $(bindir)/$(PROTOIZE_CROSS_NAME)$(exeext); \
+- $(INSTALL_PROGRAM) protoize$(exeext) $(bindir)/$(PROTOIZE_CROSS_NAME)$(exeext); \
+- rm -f $(bindir)/$(UNPROTOIZE_CROSS_NAME)$(exeext); \
+- $(INSTALL_PROGRAM) unprotoize$(exeext) $(bindir)/$(UNPROTOIZE_CROSS_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(PROTOIZE_CROSS_NAME)$(exeext); \
++ $(INSTALL_PROGRAM) protoize$(exeext) $(DESTDIR)$(bindir)/$(PROTOIZE_CROSS_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(UNPROTOIZE_CROSS_NAME)$(exeext); \
++ $(INSTALL_PROGRAM) unprotoize$(exeext) $(DESTDIR)$(bindir)/$(UNPROTOIZE_CROSS_NAME)$(exeext); \
+ else \
+- rm -f $(bindir)/$(PROTOIZE_INSTALL_NAME)$(exeext); \
+- $(INSTALL_PROGRAM) protoize$(exeext) $(bindir)/$(PROTOIZE_INSTALL_NAME)$(exeext); \
+- rm -f $(bindir)/$(UNPROTOIZE_INSTALL_NAME)$(exeext); \
+- $(INSTALL_PROGRAM) unprotoize$(exeext) $(bindir)/$(UNPROTOIZE_INSTALL_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(PROTOIZE_INSTALL_NAME)$(exeext); \
++ $(INSTALL_PROGRAM) protoize$(exeext) $(DESTDIR)$(bindir)/$(PROTOIZE_INSTALL_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(UNPROTOIZE_INSTALL_NAME)$(exeext); \
++ $(INSTALL_PROGRAM) unprotoize$(exeext) $(DESTDIR)$(bindir)/$(UNPROTOIZE_INSTALL_NAME)$(exeext); \
+ fi ; \
+- rm -f $(libsubdir)/SYSCALLS.c.X; \
+- $(INSTALL_DATA) SYSCALLS.c.X $(libsubdir)/SYSCALLS.c.X; \
+- chmod a-x $(libsubdir)/SYSCALLS.c.X; \
++ rm -f $(DESTDIR)$(libsubdir)/SYSCALLS.c.X; \
++ $(INSTALL_DATA) SYSCALLS.c.X $(DESTDIR)$(libsubdir)/SYSCALLS.c.X; \
++ chmod a-x $(DESTDIR)$(libsubdir)/SYSCALLS.c.X; \
+ fi
+- -rm -f $(libsubdir)/cpp0$(exeext)
+- $(INSTALL_PROGRAM) cpp0$(exeext) $(libsubdir)/cpp0$(exeext)
++ -rm -f $(DESTDIR)$(libsubdir)/cpp0$(exeext)
++ $(INSTALL_PROGRAM) cpp0$(exeext) $(DESTDIR)$(libsubdir)/cpp0$(exeext)
+ # Install gcov if it was compiled.
+ -if [ -f gcov$(exeext) ]; \
+ then \
+- rm -f $(bindir)/gcov$(exeext); \
+- $(INSTALL_PROGRAM) gcov$(exeext) $(bindir)/$(GCOV_INSTALL_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/gcov$(exeext); \
++ $(INSTALL_PROGRAM) gcov$(exeext) $(DESTDIR)$(bindir)/$(GCOV_INSTALL_NAME)$(exeext); \
+ fi
+
+ # Install the driver program as $(target_alias)-gcc
+ # and also as either gcc (if native) or $(gcc_tooldir)/bin/gcc.
+ install-driver: xgcc$(exeext)
+ -if [ -f gcc-cross$(exeext) ] ; then \
+- rm -f $(bindir)/$(GCC_CROSS_NAME)$(exeext); \
+- $(INSTALL_PROGRAM) gcc-cross$(exeext) $(bindir)/$(GCC_CROSS_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(GCC_CROSS_NAME)$(exeext); \
++ $(INSTALL_PROGRAM) gcc-cross$(exeext) $(DESTDIR)$(bindir)/$(GCC_CROSS_NAME)$(exeext); \
+ if [ -d $(gcc_tooldir)/bin/. ] ; then \
+ rm -f $(gcc_tooldir)/bin/gcc$(exeext); \
+ $(INSTALL_PROGRAM) gcc-cross$(exeext) $(gcc_tooldir)/bin/gcc$(exeext); \
+ else true; fi; \
+ else \
+- rm -f $(bindir)/$(GCC_INSTALL_NAME)$(exeext); \
+- $(INSTALL_PROGRAM) xgcc$(exeext) $(bindir)/$(GCC_INSTALL_NAME)$(exeext); \
+- rm -f $(bindir)/$(target_alias)-gcc-1$(exeext); \
+- $(LN) $(bindir)/$(GCC_INSTALL_NAME)$(exeext) $(bindir)/$(target_alias)-gcc-1$(exeext); \
+- mv $(bindir)/$(target_alias)-gcc-1$(exeext) $(bindir)/$(target_alias)-gcc$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(GCC_INSTALL_NAME)$(exeext); \
++ $(INSTALL_PROGRAM) xgcc$(exeext) $(DESTDIR)$(bindir)/$(GCC_INSTALL_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(target_alias)-gcc-1$(exeext); \
++ $(LN) $(DESTDIR)$(bindir)/$(GCC_INSTALL_NAME)$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gcc-1$(exeext); \
++ mv $(DESTDIR)$(bindir)/$(target_alias)-gcc-1$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gcc$(exeext); \
+ fi
+
+ # Install the info files.
+ # $(INSTALL_DATA) might be a relative pathname, so we can't cd into srcdir
+ # to do the install.
+ install-info: doc installdirs lang.install-info
+- -rm -f $(infodir)/cpp.info* $(infodir)/gcc.info*
++ -rm -f $(DESTDIR)$(infodir)/cpp.info* $(DESTDIR)$(infodir)/gcc.info*
+ for f in cpp.info* gcc.info*; do \
+- $(INSTALL_DATA) $$f $(infodir)/$$f; \
++ $(INSTALL_DATA) $$f $(DESTDIR)$(infodir)/$$f; \
+ done
+ -if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
+- if [ -f $(infodir)/dir ] ; then \
++ if [ -f $(DESTDIR)$(infodir)/dir ] ; then \
+ for f in cpp.info gcc.info; do \
+- install-info --dir-file=$(infodir)/dir $(infodir)/$$f; \
++ install-info --dir-file=$(infodir)/dir $(DESTDIR)$(infodir)/$$f; \
+ done; \
+ else true; fi; \
+ else true; fi;
+- -chmod a-x $(infodir)/cpp.info* $(infodir)/gcc.info*
++ -chmod a-x $(DESTDIR)$(infodir)/cpp.info* $(DESTDIR)$(infodir)/gcc.info*
+
+ # Install the man pages.
+ install-man: installdirs $(srcdir)/gcc.1 $(srcdir)/cccp.1 lang.install-man
+ -if [ -f gcc-cross$(exeext) ] ; then \
+- rm -f $(man1dir)/$(GCC_CROSS_NAME)$(manext); \
+- $(INSTALL_DATA) $(srcdir)/gcc.1 $(man1dir)/$(GCC_CROSS_NAME)$(manext); \
+- chmod a-x $(man1dir)/$(GCC_CROSS_NAME)$(manext); \
++ rm -f $(DESTDIR)$(man1dir)/$(GCC_CROSS_NAME)$(manext); \
++ $(INSTALL_DATA) $(srcdir)/gcc.1 $(DESTDIR)$(man1dir)/$(GCC_CROSS_NAME)$(manext); \
++ chmod a-x $(DESTDIR)$(man1dir)/$(GCC_CROSS_NAME)$(manext); \
+ else \
+- rm -f $(man1dir)/$(GCC_INSTALL_NAME)$(manext); \
+- $(INSTALL_DATA) $(srcdir)/gcc.1 $(man1dir)/$(GCC_INSTALL_NAME)$(manext); \
+- chmod a-x $(man1dir)/$(GCC_INSTALL_NAME)$(manext); \
+- fi
+- -rm -f $(man1dir)/cccp$(manext)
+- -$(INSTALL_DATA) $(srcdir)/cccp.1 $(man1dir)/cccp$(manext)
+- -chmod a-x $(man1dir)/cccp$(manext)
++ rm -f $(DESTDIR)$(man1dir)/$(GCC_INSTALL_NAME)$(manext); \
++ $(INSTALL_DATA) $(srcdir)/gcc.1 $(DESTDIR)$(man1dir)/$(GCC_INSTALL_NAME)$(manext); \
++ chmod a-x $(DESTDIR)$(man1dir)/$(GCC_INSTALL_NAME)$(manext); \
++ fi
++ -rm -f $(DESTDIR)$(man1dir)/cccp$(manext)
++ -$(INSTALL_DATA) $(srcdir)/cccp.1 $(DESTDIR)$(man1dir)/cccp$(manext)
++ -chmod a-x $(DESTDIR)$(man1dir)/cccp$(manext)
+
+ # Install the library.
+ install-libgcc: libgcc.a installdirs
+ -if [ -f libgcc.a ] ; then \
+- rm -f $(libsubdir)/libgcc.a; \
+- $(INSTALL_DATA) libgcc.a $(libsubdir)/libgcc.a; \
++ rm -f $(DESTDIR)$(libsubdir)/libgcc.a; \
++ $(INSTALL_DATA) libgcc.a $(DESTDIR)$(libsubdir)/libgcc.a; \
+ if $(RANLIB_TEST_FOR_TARGET) ; then \
+- (cd $(libsubdir); $(RANLIB_FOR_TARGET) libgcc.a); else true; fi; \
+- chmod a-x $(libsubdir)/libgcc.a; \
++ (cd $(DESTDIR)$(libsubdir); $(RANLIB_FOR_TARGET) libgcc.a); else true; fi; \
++ chmod a-x $(DESTDIR)$(libsubdir)/libgcc.a; \
+ else true; fi
+
+ # Install multiple versions of libgcc.a.
+ install-multilib: stmp-multilib installdirs
+ for i in `$(GCC_FOR_TARGET) --print-multi-lib`; do \
+ dir=`echo $$i | sed -e 's/;.*$$//'`; \
+- if [ -d $(libsubdir)/$${dir} ]; then true; else mkdir $(libsubdir)/$${dir}; fi; \
++ if [ -d $(DESTDIR)$(libsubdir)/$${dir} ]; then true; else mkdir $(DESTDIR)$(libsubdir)/$${dir}; fi; \
+ for f in libgcc.a $(EXTRA_MULTILIB_PARTS); do \
+- rm -f $(libsubdir)/$${dir}/$${f}; \
+- $(INSTALL_DATA) $${dir}/$${f} $(libsubdir)/$${dir}/$${f}; \
++ rm -f $(DESTDIR)$(libsubdir)/$${dir}/$${f}; \
++ $(INSTALL_DATA) $${dir}/$${f} $(DESTDIR)$(libsubdir)/$${dir}/$${f}; \
+ done; \
+ if $(RANLIB_TEST_FOR_TARGET); then \
+- (cd $(libsubdir)/$${dir}; $(RANLIB_FOR_TARGET) libgcc.a); \
++ (cd $(DESTDIR)$(libsubdir)/$${dir}; $(RANLIB_FOR_TARGET) libgcc.a); \
+ else true; fi; \
+- chmod a-x $(libsubdir)/$${dir}/libgcc.a; \
++ chmod a-x $(DESTDIR)$(libsubdir)/$${dir}/libgcc.a; \
+ done
+
+ # Install all the header files built in the include subdirectory.
+@@ -2613,23 +2613,23 @@ install-headers: install-include-dir $(I
+ # Fix symlinks to absolute paths in the installed include directory to
+ # point to the installed directory, not the build directory.
+ # Don't need to use LN_S here since we really do need ln -s and no substitutes.
+- -files=`cd $(libsubdir)/include; find . -type l -print 2>/dev/null`; \
++ -files=`cd $(DESTDIR)$(libsubdir)/include; find . -type l -print 2>/dev/null`; \
+ if [ $$? -eq 0 ]; then \
+ dir=`cd include; pwd`; \
+ for i in $$files; do \
+- dest=`ls -ld $(libsubdir)/include/$$i | sed -n 's/.*-> //p'`; \
++ dest=`ls -ld $(DESTDIR)$(libsubdir)/include/$$i | sed -n 's/.*-> //p'`; \
+ if expr "$$dest" : "$$dir.*" > /dev/null; then \
+- rm -f $(libsubdir)/include/$$i; \
+- ln -s `echo $$i | sed "s|/[^/]*|/..|g" | sed 's|/..$$||'``echo "$$dest" | sed "s|$$dir||"` $(libsubdir)/include/$$i; \
++ rm -f $(DESTDIR)$(libsubdir)/include/$$i; \
++ ln -s `echo $$i | sed "s|/[^/]*|/..|g" | sed 's|/..$$||'``echo "$$dest" | sed "s|$$dir||"` $(DESTDIR)$(libsubdir)/include/$$i; \
+ fi; \
+ done; \
+ fi
+
+ # Create or recreate the gcc private include file directory.
+ install-include-dir: installdirs
+- -rm -rf $(libsubdir)/include
+- mkdir $(libsubdir)/include
+- -chmod a+rx $(libsubdir)/include
++ -rm -rf $(DESTDIR)$(libsubdir)/include
++ mkdir $(DESTDIR)$(libsubdir)/include
++ -chmod a+rx $(DESTDIR)$(libsubdir)/include
+
+ # Install the include directory using tar.
+ install-headers-tar: stmp-headers $(STMP_FIXPROTO) install-include-dir
+@@ -2638,7 +2638,7 @@ install-headers-tar: stmp-headers $(STMP
+ # found in CDPATH, corrupting the output. We could just redirect the
+ # output of `cd', but some shells lose on redirection within `()'s
+ (cd `pwd`/include ; \
+- tar -cf - .; exit 0) | (cd $(libsubdir)/include; tar $(TAROUTOPTS) - )
++ tar -cf - .; exit 0) | (cd $(DESTDIR)$(libsubdir)/include; tar $(TAROUTOPTS) - )
+ # /bin/sh on some systems returns the status of the first tar,
+ # and that can lose with GNU tar which always writes a full block.
+ # So use `exit 0' to ignore its exit status.
+@@ -2647,7 +2647,7 @@ install-headers-tar: stmp-headers $(STMP
+ install-headers-cpio: stmp-headers $(STMP_FIXPROTO) install-include-dir
+ # See discussion about the use of `pwd` above
+ cd `pwd`/include ; \
+- find . -print | cpio -pdum $(libsubdir)/include
++ find . -print | cpio -pdum $(DESTDIR)$(libsubdir)/include
+
+ # Put assert.h where it won't override GNU libc's assert.h.
+ # It goes in a dir that is searched after GNU libc's headers;
+@@ -2657,26 +2657,26 @@ install-headers-cpio: stmp-headers $(STM
+ ## This code would be simpler if it tested for -f ... && ! grep ...
+ ## but supposedly the ! operator is missing in sh on some systems.
+ install-assert-h: assert.h installdirs
+- if [ -f $(assertdir)/assert.h ]; \
++ if [ -f $(DESTDIR)$(assertdir)/assert.h ]; \
+ then \
+- if grep "__eprintf" $(assertdir)/assert.h >/dev/null; \
++ if grep "__eprintf" $(DESTDIR)$(assertdir)/assert.h >/dev/null; \
+ then \
+- rm -f $(assertdir)/assert.h; \
+- $(INSTALL_DATA) $(srcdir)/assert.h $(assertdir)/assert.h; \
+- chmod a-x $(assertdir)/assert.h; \
++ rm -f $(DESTDIR)$(assertdir)/assert.h; \
++ $(INSTALL_DATA) $(srcdir)/assert.h $(DESTDIR)$(assertdir)/assert.h; \
++ chmod a-x $(DESTDIR)$(assertdir)/assert.h; \
+ else true; \
+ fi; \
+ else \
+- rm -f $(assertdir)/assert.h; \
+- $(INSTALL_DATA) $(srcdir)/assert.h $(assertdir)/assert.h; \
+- chmod a-x $(assertdir)/assert.h; \
++ rm -f $(DESTDIR)$(assertdir)/assert.h; \
++ $(INSTALL_DATA) $(srcdir)/assert.h $(DESTDIR)$(assertdir)/assert.h; \
++ chmod a-x $(DESTDIR)$(assertdir)/assert.h; \
+ fi
+
+ # Use this target to install the program `collect2' under the name `collect2'.
+ install-collect2: collect2 installdirs
+- $(INSTALL_PROGRAM) collect2$(exeext) $(libsubdir)/collect2$(exeext)
++ $(INSTALL_PROGRAM) collect2$(exeext) $(DESTDIR)$(libsubdir)/collect2$(exeext)
+ # Install the driver program as $(libsubdir)/gcc for collect2.
+- $(INSTALL_PROGRAM) xgcc$(exeext) $(libsubdir)/gcc$(exeext)
++ $(INSTALL_PROGRAM) xgcc$(exeext) $(DESTDIR)$(libsubdir)/gcc$(exeext)
+
+ # Cancel installation by deleting the installed files.
+ uninstall: intl.uninstall lang.uninstall $(UNINSTALL_CPP)
diff --git a/lang/gcc2/patches/patch-gcc_ch_Make-lang.in b/lang/gcc2/patches/patch-gcc_ch_Make-lang.in
new file mode 100644
index 00000000000..e63ffcb9060
--- /dev/null
+++ b/lang/gcc2/patches/patch-gcc_ch_Make-lang.in
@@ -0,0 +1,36 @@
+$NetBSD: patch-gcc_ch_Make-lang.in,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- gcc/ch/Make-lang.in.orig 1999-06-25 08:26:19.000000000 +0000
++++ gcc/ch/Make-lang.in
+@@ -130,13 +130,13 @@ CHILL.install-common:
+ -if [ -f cc1chill$(exeext) ] ; then \
+ if [ -f chill.install ] ; then \
+ if [ -f gcc-cross$(exeext) ]; then \
+- rm -f $(bindir)/$(CHILL_CROSS_NAME); \
+- $(INSTALL_PROGRAM) chill.install $(bindir)/$(CHILL_CROSS_NAME); \
+- chmod a+x $(bindir)/$(CHILL_CROSS_NAME); \
++ rm -f $(DESTDIR)$(bindir)/$(CHILL_CROSS_NAME); \
++ $(INSTALL_PROGRAM) chill.install $(DESTDIR)$(bindir)/$(CHILL_CROSS_NAME); \
++ chmod a+x $(DESTDIR)$(bindir)/$(CHILL_CROSS_NAME); \
+ else \
+- rm -f $(bindir)/$(CHILL_INSTALL_NAME); \
+- $(INSTALL_PROGRAM) chill.install $(bindir)/$(CHILL_INSTALL_NAME); \
+- chmod a+x $(bindir)/$(CHILL_INSTALL_NAME); \
++ rm -f $(DESTDIR)$(bindir)/$(CHILL_INSTALL_NAME); \
++ $(INSTALL_PROGRAM) chill.install $(DESTDIR)$(bindir)/$(CHILL_INSTALL_NAME); \
++ chmod a+x $(DESTDIR)$(bindir)/$(CHILL_INSTALL_NAME); \
+ fi ; \
+ fi ; \
+ fi
+@@ -145,9 +145,9 @@ CHILL.install-common:
+ # docs to install (in case LANGUAGES didn't contain chill earlier).
+ CHILL.install-info:
+ -for i in ch/chill.info*; do \
+- rm -f $(infodir)/chill.info*; \
++ rm -f $(DESTDIR)$(infodir)/chill.info*; \
+ realfile=`echo $$i | sed -e 's|.*/\([^/]*\)$$|\1|'`; \
+- $(INSTALL_DATA) $$i $(infodir)/$$realfile; \
++ $(INSTALL_DATA) $$i $(DESTDIR)$(infodir)/$$realfile; \
+ done
+
+ CHILL.install-man:
diff --git a/lang/gcc2/patches/patch-gcc_cp_Make-lang.in b/lang/gcc2/patches/patch-gcc_cp_Make-lang.in
new file mode 100644
index 00000000000..b9b0e9f45d6
--- /dev/null
+++ b/lang/gcc2/patches/patch-gcc_cp_Make-lang.in
@@ -0,0 +1,68 @@
+$NetBSD: patch-gcc_cp_Make-lang.in,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- gcc/cp/Make-lang.in.orig 1999-04-26 23:50:36.000000000 +0000
++++ gcc/cp/Make-lang.in
+@@ -214,27 +214,27 @@ c++.install-normal:
+ c++.install-common:
+ -if [ -f cc1plus$(exeext) ] ; then \
+ if [ -f g++-cross$(exeext) ] ; then \
+- rm -f $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
+- $(INSTALL_PROGRAM) g++-cross$(exeext) $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
+- chmod a+x $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
+- rm -f $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
+- $(LN) $(bindir)/$(GXX_CROSS_NAME)$(exeext) $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(GXX_CROSS_NAME)$(exeext); \
++ $(INSTALL_PROGRAM) g++-cross$(exeext) $(DESTDIR)$(bindir)/$(GXX_CROSS_NAME)$(exeext); \
++ chmod a+x $(DESTDIR)$(bindir)/$(GXX_CROSS_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(CXX_CROSS_NAME)$(exeext); \
++ $(LN) $(DESTDIR)$(bindir)/$(GXX_CROSS_NAME)$(exeext) $(DESTDIR)$(bindir)/$(CXX_CROSS_NAME)$(exeext); \
+ else \
+- rm -f $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
+- $(INSTALL_PROGRAM) g++$(exeext) $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
+- chmod a+x $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
+- rm -f $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
+- $(LN) $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
++ $(INSTALL_PROGRAM) g++$(exeext) $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
++ chmod a+x $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
++ $(LN) $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
+ fi ; \
+ if [ x$(DEMANGLER_PROG) != x ] && [ -x "$(DEMANGLER_PROG)" ]; then \
+ if [ -f g++-cross$(exeext) ] ; then \
+- rm -f $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
+- $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
+- chmod a+x $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
++ $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(DESTDIR)$(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
++ chmod a+x $(DESTDIR)$(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
+ else \
+- rm -f $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
+- $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
+- chmod a+x $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
++ $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(DESTDIR)$(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
++ chmod a+x $(DESTDIR)$(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
+ fi ; \
+ fi ; \
+ fi
+@@ -244,13 +244,13 @@ c++.install-info:
+ c++.install-man: $(srcdir)/cp/g++.1
+ -if [ -f cc1plus$(exeext) ] ; then \
+ if [ -f g++-cross$(exeext) ] ; then \
+- rm -f $(man1dir)/$(GXX_CROSS_NAME)$(manext); \
+- $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(man1dir)/$(GXX_CROSS_NAME)$(manext); \
+- chmod a-x $(man1dir)/$(GXX_CROSS_NAME)$(manext); \
++ rm -f $(DESTDIR)$(man1dir)/$(GXX_CROSS_NAME)$(manext); \
++ $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(DESTDIR)$(man1dir)/$(GXX_CROSS_NAME)$(manext); \
++ chmod a-x $(DESTDIR)$(man1dir)/$(GXX_CROSS_NAME)$(manext); \
+ else \
+- rm -f $(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
+- $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
+- chmod a-x $(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
++ rm -f $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
++ $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
++ chmod a-x $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
+ fi; \
+ else true; fi
+
diff --git a/lang/gcc2/patches/patch-gcc_f_Make-lang.in b/lang/gcc2/patches/patch-gcc_f_Make-lang.in
new file mode 100644
index 00000000000..1a5a3ad79ad
--- /dev/null
+++ b/lang/gcc2/patches/patch-gcc_f_Make-lang.in
@@ -0,0 +1,105 @@
+$NetBSD: patch-gcc_f_Make-lang.in,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- gcc/f/Make-lang.in.orig 1999-06-07 06:44:57.000000000 +0000
++++ gcc/f/Make-lang.in
+@@ -312,18 +312,18 @@ f77.install-normal:
+ # run, since we use libsubdir to store our `flag' file, lang-f77.
+ f77.install-common: installdirs
+ case "$(LANGUAGES)" in \
+- *[fF]77*) touch $(libsubdir)/lang-f77;; \
+- *) rm -f $(libsubdir)/lang-f77;; \
++ *[fF]77*) touch $(DESTDIR)$(libsubdir)/lang-f77;; \
++ *) rm -f $(DESTDIR)$(libsubdir)/lang-f77;; \
+ esac
+- -if [ -f $(libsubdir)/lang-f77 -a -f f771$(exeext) ] ; then \
++ -if [ -f $(DESTDIR)$(libsubdir)/lang-f77 -a -f f771$(exeext) ] ; then \
+ if [ -f g77-cross$(exeext) ] ; then \
+- rm -f $(bindir)/$(G77_CROSS_NAME)$(exeext); \
+- $(INSTALL_PROGRAM) g77-cross$(exeext) $(bindir)/$(G77_CROSS_NAME)$(exeext); \
+- chmod a+x $(bindir)/$(G77_CROSS_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(G77_CROSS_NAME)$(exeext); \
++ $(INSTALL_PROGRAM) g77-cross$(exeext) $(DESTDIR)$(bindir)/$(G77_CROSS_NAME)$(exeext); \
++ chmod a+x $(DESTDIR)$(bindir)/$(G77_CROSS_NAME)$(exeext); \
+ else \
+- rm -f $(bindir)/$(G77_INSTALL_NAME)$(exeext); \
+- $(INSTALL_PROGRAM) g77$(exeext) $(bindir)/$(G77_INSTALL_NAME)$(exeext); \
+- chmod a+x $(bindir)/$(G77_INSTALL_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(G77_INSTALL_NAME)$(exeext); \
++ $(INSTALL_PROGRAM) g77$(exeext) $(DESTDIR)$(bindir)/$(G77_INSTALL_NAME)$(exeext); \
++ chmod a+x $(DESTDIR)$(bindir)/$(G77_INSTALL_NAME)$(exeext); \
+ fi ; \
+ else true; fi
+ @if [ -f f77-install-ok -o -f $(srcdir)/f77-install-ok ]; then \
+@@ -335,7 +335,7 @@ f77.install-common: installdirs
+ echo ' f77-install-ok in the source or build directory.)'; \
+ echo ''; \
+ else true; fi
+- rm -f $(libsubdir)/lang-f77
++ rm -f $(DESTDIR)$(libsubdir)/lang-f77
+
+ # $(INSTALL_DATA) might be a relative pathname, so we can't cd into srcdir
+ # to do the install. The sed rule was copied from stmp-int-hdrs.
+@@ -343,44 +343,44 @@ f77.install-common: installdirs
+ # run, since we use libsubdir to store our `flag' file, lang-f77.
+ f77.install-info: f77.info installdirs
+ case "$(LANGUAGES)" in \
+- *[fF]77*) touch $(libsubdir)/lang-f77;; \
+- *) rm -f $(libsubdir)/lang-f77;; \
++ *[fF]77*) touch $(DESTDIR)$(libsubdir)/lang-f77;; \
++ *) rm -f $(DESTDIR)$(libsubdir)/lang-f77;; \
+ esac
+- if [ -f $(libsubdir)/lang-f77 -a -f f/g77.info ] ; then \
+- rm -f $(infodir)/g77.info*; \
++ if [ -f $(DESTDIR)$(libsubdir)/lang-f77 -a -f f/g77.info ] ; then \
++ rm -f $(DESTDIR)$(infodir)/g77.info*; \
+ for f in f/g77.info*; do \
+ realfile=`echo $$f | sed -e 's|.*/\([^/]*\)$$|\1|'`; \
+- $(INSTALL_DATA) $$f $(infodir)/$$realfile; \
++ $(INSTALL_DATA) $$f $(DESTDIR)$(infodir)/$$realfile; \
+ done; \
+- chmod a-x $(infodir)/g77.info*; \
++ chmod a-x $(DESTDIR)$(infodir)/g77.info*; \
+ else true; fi
+- @if [ -f $(libsubdir)/lang-f77 -a -f $(srcdir)/f/g77.info ] ; then \
++ @if [ -f $(DESTDIR)$(libsubdir)/lang-f77 -a -f $(srcdir)/f/g77.info ] ; then \
+ if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
+ echo " install-info --info-dir=$(infodir) $(infodir)/g77.info"; \
+- install-info --info-dir=$(infodir) $(infodir)/g77.info || : ; \
++ install-info --info-dir=$(infodir) $(DESTDIR)$(infodir)/g77.info || : ; \
+ else : ; fi; \
+ else : ; fi
+- rm -f $(libsubdir)/lang-f77
++ rm -f $(DESTDIR)$(libsubdir)/lang-f77
+
+ # Make sure `installdirs' target (from gcc Makefile) has been
+ # run, since we use libsubdir to store our `flag' file, lang-f77.
+ f77.install-man: $(srcdir)/f/g77.1 installdirs
+ case "$(LANGUAGES)" in \
+- *[fF]77*) touch $(libsubdir)/lang-f77;; \
+- *) rm -f $(libsubdir)/lang-f77;; \
++ *[fF]77*) touch $(DESTDIR)$(libsubdir)/lang-f77;; \
++ *) rm -f $(DESTDIR)$(libsubdir)/lang-f77;; \
+ esac
+- -if [ -f $(libsubdir)/lang-f77 -a -f f771$(exeext) ] ; then \
++ -if [ -f $(DESTDIR)$(libsubdir)/lang-f77 -a -f f771$(exeext) ] ; then \
+ if [ -f g77-cross$(exeext) ] ; then \
+- rm -f $(man1dir)/$(G77_CROSS_NAME)$(manext); \
+- $(INSTALL_DATA) $(srcdir)/f/g77.1 $(man1dir)/$(G77_CROSS_NAME)$(manext); \
+- chmod a-x $(man1dir)/$(G77_CROSS_NAME)$(manext); \
++ rm -f $(DESTDIR)$(man1dir)/$(G77_CROSS_NAME)$(manext); \
++ $(INSTALL_DATA) $(srcdir)/f/g77.1 $(DESTDIR)$(man1dir)/$(G77_CROSS_NAME)$(manext); \
++ chmod a-x $(DESTDIR)$(man1dir)/$(G77_CROSS_NAME)$(manext); \
+ else \
+- rm -f $(man1dir)/$(G77_INSTALL_NAME)$(manext); \
+- $(INSTALL_DATA) $(srcdir)/f/g77.1 $(man1dir)/$(G77_INSTALL_NAME)$(manext); \
+- chmod a-x $(man1dir)/$(G77_INSTALL_NAME)$(manext); \
++ rm -f $(DESTDIR)$(man1dir)/$(G77_INSTALL_NAME)$(manext); \
++ $(INSTALL_DATA) $(srcdir)/f/g77.1 $(DESTDIR)$(man1dir)/$(G77_INSTALL_NAME)$(manext); \
++ chmod a-x $(DESTDIR)$(man1dir)/$(G77_INSTALL_NAME)$(manext); \
+ fi; \
+ else true; fi
+- rm -f $(libsubdir)/lang-f77
++ rm -f $(DESTDIR)$(libsubdir)/lang-f77
+
+ # Make sure `installdirs' target (from gcc Makefile) has been
+ # run, since we use libsubdir to store our `flag' file, lang-f77.
diff --git a/lang/gcc2/patches/patch-gcc_intl_Makefile.in b/lang/gcc2/patches/patch-gcc_intl_Makefile.in
new file mode 100644
index 00000000000..c9f770bbee3
--- /dev/null
+++ b/lang/gcc2/patches/patch-gcc_intl_Makefile.in
@@ -0,0 +1,39 @@
+$NetBSD: patch-gcc_intl_Makefile.in,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- gcc/intl/Makefile.in.orig 1999-02-02 18:49:16.000000000 +0000
++++ gcc/intl/Makefile.in
+@@ -114,26 +114,26 @@ install-exec: all
+ if test "$(PACKAGE)" = "gettext" \
+ && test '@INTLOBJS@' = '$(GETTOBJS)'; then \
+ if test -r $(MKINSTALLDIRS); then \
+- $(MKINSTALLDIRS) $(libdir) $(includedir); \
++ $(MKINSTALLDIRS) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \
+ else \
+- $(top_srcdir)/mkinstalldirs $(libdir) $(includedir); \
++ $(top_srcdir)/mkinstalldirs $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \
+ fi; \
+- $(INSTALL_DATA) intlh.inst $(includedir)/libintl.h; \
+- $(INSTALL_DATA) libintl.a $(libdir)/libintl.a; \
++ $(INSTALL_DATA) intlh.inst $(DESTDIR)$(includedir)/libintl.h; \
++ $(INSTALL_DATA) libintl.a $(DESTDIR)$(libdir)/libintl.a; \
+ else \
+ : ; \
+ fi
+ install-data: all
+ if test "$(PACKAGE)" = "gettext"; then \
+ if test -r $(MKINSTALLDIRS); then \
+- $(MKINSTALLDIRS) $(gettextsrcdir); \
++ $(MKINSTALLDIRS) $(DESTDIR)$(gettextsrcdir); \
+ else \
+- $(top_srcdir)/mkinstalldirs $(gettextsrcdir); \
++ $(top_srcdir)/mkinstalldirs $(DESTDIR)$(gettextsrcdir); \
+ fi; \
+- $(INSTALL_DATA) VERSION $(gettextsrcdir)/VERSION; \
++ $(INSTALL_DATA) VERSION $(DESTDIR)$(gettextsrcdir)/VERSION; \
+ dists="$(DISTFILES.common)"; \
+ for file in $$dists; do \
+- $(INSTALL_DATA) $(srcdir)/$$file $(gettextsrcdir)/$$file; \
++ $(INSTALL_DATA) $(srcdir)/$$file $(DESTDIR)$(gettextsrcdir)/$$file; \
+ done; \
+ else \
+ : ; \
diff --git a/lang/gcc2/patches/patch-gcc_java_Make-lang.in b/lang/gcc2/patches/patch-gcc_java_Make-lang.in
new file mode 100644
index 00000000000..3e76f1ebc5b
--- /dev/null
+++ b/lang/gcc2/patches/patch-gcc_java_Make-lang.in
@@ -0,0 +1,34 @@
+$NetBSD: patch-gcc_java_Make-lang.in,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- gcc/java/Make-lang.in.orig 1999-06-25 08:26:23.000000000 +0000
++++ gcc/java/Make-lang.in
+@@ -144,20 +144,20 @@ java.install-normal:
+ java.install-common:
+ -if [ -f $(GCJ)$(exeext) ]; then \
+ if [ -f $(GCJ)-cross$(exeext) ]; then \
+- rm -f $(bindir)/$(JAVA_CROSS_NAME)$(exeext); \
+- $(INSTALL_PROGRAM) $(GCJ)-cross$(exeext) $(bindir)/$(JAVA_CROSS_NAME)$(exeext); \
+- chmod a+x $(bindir)/$(JAVA_CROSS_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(JAVA_CROSS_NAME)$(exeext); \
++ $(INSTALL_PROGRAM) $(GCJ)-cross$(exeext) $(DESTDIR)$(bindir)/$(JAVA_CROSS_NAME)$(exeext); \
++ chmod a+x $(DESTDIR)$(bindir)/$(JAVA_CROSS_NAME)$(exeext); \
+ else \
+- rm -f $(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \
+- $(INSTALL_PROGRAM) $(GCJ)$(exeext) $(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \
+- chmod a+x $(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \
++ $(INSTALL_PROGRAM) $(GCJ)$(exeext) $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \
++ chmod a+x $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \
+ fi ; \
+ fi ; \
+ for tool in $(JAVA_TARGET_INDEPENDENT_BIN_TOOLS); do \
+ if [ -f $$tool$(exeext) ]; then \
+- rm -f $(bindir)/$$tool$(exeext); \
+- $(INSTALL_PROGRAM) $$tool$(exeext) $(bindir)/$$tool$(exeext); \
+- chmod a+x $(bindir)/$$tool$(exeext); \
++ rm -f $(DESTDIR)$(bindir)/$$tool$(exeext); \
++ $(INSTALL_PROGRAM) $$tool$(exeext) $(DESTDIR)$(bindir)/$$tool$(exeext); \
++ chmod a+x $(DESTDIR)$(bindir)/$$tool$(exeext); \
+ fi ; \
+ done
+
diff --git a/lang/gcc2/patches/patch-libchill_Makefile.in b/lang/gcc2/patches/patch-libchill_Makefile.in
new file mode 100644
index 00000000000..b13db1433b0
--- /dev/null
+++ b/lang/gcc2/patches/patch-libchill_Makefile.in
@@ -0,0 +1,19 @@
+$NetBSD: patch-libchill_Makefile.in,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- libchill/Makefile.in.orig 1999-08-07 05:36:10.000000000 +0000
++++ libchill/Makefile.in
+@@ -217,10 +217,10 @@ ${srcdir}/configure: configure.in
+ cd ${srcdir} && autoconf
+
+ install: all
+- $(INSTALL_DATA) libchill.a $(libsubdir)$(MULTISUBDIR)/libchill.a.n
+- $(RANLIB) $(libsubdir)$(MULTISUBDIR)/libchill.a.n
+- mv $(libsubdir)$(MULTISUBDIR)/libchill.a.n $(libsubdir)$(MULTISUBDIR)/libchill.a
+- $(INSTALL_DATA) chillrt0.o $(libsubdir)$(MULTISUBDIR)/chillrt0.o
++ $(INSTALL_DATA) libchill.a $(DESTDIR)$(libsubdir)$(MULTISUBDIR)/libchill.a.n
++ $(RANLIB) $(DESTDIR)$(libsubdir)$(MULTISUBDIR)/libchill.a.n
++ mv $(DESTDIR)$(libsubdir)$(MULTISUBDIR)/libchill.a.n $(DESTDIR)$(libsubdir)$(MULTISUBDIR)/libchill.a
++ $(INSTALL_DATA) chillrt0.o $(DESTDIR)$(libsubdir)$(MULTISUBDIR)/chillrt0.o
+ @rootme=`pwd`/ ; export rootme ; \
+ $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
+
diff --git a/lang/gcc2/patches/patch-libf2c_Makefile.in b/lang/gcc2/patches/patch-libf2c_Makefile.in
new file mode 100644
index 00000000000..1471c1a75c5
--- /dev/null
+++ b/lang/gcc2/patches/patch-libf2c_Makefile.in
@@ -0,0 +1,19 @@
+$NetBSD: patch-libf2c_Makefile.in,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- libf2c/Makefile.in.orig 1999-08-07 05:36:10.000000000 +0000
++++ libf2c/Makefile.in
+@@ -197,10 +197,10 @@ check:
+ cd libU77; $(MAKE) G77DIR=../../../gcc/ check
+
+ install: all
+- $(INSTALL_DATA) $(LIBG2C) $(libsubdir)/$(MULTISUBDIR)/$(LIBG2C).n
+- ( cd $(libsubdir)/$(MULTISUBDIR) ; $(RANLIB) $(LIBG2C).n )
+- mv -f $(libsubdir)/$(MULTISUBDIR)/$(LIBG2C).n $(libsubdir)/$(MULTISUBDIR)/$(LIBG2C)
+- $(INSTALL_DATA) g2c.h $(libsubdir)/include/g2c.h
++ $(INSTALL_DATA) $(LIBG2C) $(DESTDIR)$(libsubdir)/$(MULTISUBDIR)/$(LIBG2C).n
++ ( cd $(DESTDIR)$(libsubdir)/$(MULTISUBDIR) ; $(RANLIB) $(LIBG2C).n )
++ mv -f $(DESTDIR)$(libsubdir)/$(MULTISUBDIR)/$(LIBG2C).n $(DESTDIR)$(libsubdir)/$(MULTISUBDIR)/$(LIBG2C)
++ $(INSTALL_DATA) g2c.h $(DESTDIR)$(libsubdir)/include/g2c.h
+ @if [ -f f2c-install-ok -o -f $(srcdir)/f2c-install-ok ]; then \
+ echo ''; \
+ echo 'Warning: g77 no longer installs libf2c.a or f2c.h.'; \
diff --git a/lang/gcc2/patches/patch-libio_Makefile.in b/lang/gcc2/patches/patch-libio_Makefile.in
new file mode 100644
index 00000000000..6764925a661
--- /dev/null
+++ b/lang/gcc2/patches/patch-libio_Makefile.in
@@ -0,0 +1,31 @@
+$NetBSD: patch-libio_Makefile.in,v 1.1 2015/04/25 10:32:07 wiz Exp $
+
+--- libio/Makefile.in.orig 2011-07-15 08:16:38.000000000 +0000
++++ libio/Makefile.in
+@@ -113,19 +113,19 @@ install:
+ if [ -z "$(MULTISUBDIR)" ]; then \
+ if [ "$(_G_CONFIG_H)" != "" ]; then \
+ if [ x$(enable_version_specific_runtime_libs) = xyes ]; then \
+- rm -f $(gxx_include_dir)/_G_config.h ; \
+- $(INSTALL_DATA) _G_config.h $(gxx_include_dir)/_G_config.h || exit 1; \
++ rm -f $(DESTDIR)$(gxx_include_dir)/_G_config.h ; \
++ $(INSTALL_DATA) _G_config.h $(DESTDIR)$(gxx_include_dir)/_G_config.h || exit 1; \
+ else \
+- rm -f $(tooldir)/include/_G_config.h ; \
+- $(INSTALL_DATA) _G_config.h $(tooldir)/include/_G_config.h || exit 1; \
++ rm -f $(DESTDIR)$(tooldir)/include/_G_config.h ; \
++ $(INSTALL_DATA) _G_config.h $(DESTDIR)$(tooldir)/include/_G_config.h || exit 1; \
+ fi; \
+ else true; \
+ fi ; \
+ cd $(srcdir); \
+ for FILE in $(USER_INCLUDES); do if [ $$FILE != _G_config.h ]; then \
+- rm -f $(gxx_include_dir)/$$FILE ; \
+- $(INSTALL_DATA) $$FILE $(gxx_include_dir)/$$FILE ; \
+- chmod a-x $(gxx_include_dir)/$$FILE ; \
++ rm -f $(DESTDIR)$(gxx_include_dir)/$$FILE ; \
++ $(INSTALL_DATA) $$FILE $(DESTDIR)$(gxx_include_dir)/$$FILE ; \
++ chmod a-x $(DESTDIR)$(gxx_include_dir)/$$FILE ; \
+ else true; fi; done ; \
+ else true; \
+ fi