diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7cac0a25977..60b953038fa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2007-03-06 Richard Sandiford + + * configure.ac: Allow tm_file to contain build-directory files. + * configure: Regenerate. + * config.gcc (m68k-*-uclinux*): Add ./sysroot-suffix.h to tm_file. + * config/m68k/t-uclinux (sysroot-suffix.h): New target. + * config/m68k/print-sysroot-suffix.sh: New file. + 2007-03-06 Richard Sandiford * config/m68k/m68k.h (PIC_OFFSET_TABLE_REGNUM): Use the REGNO diff --git a/gcc/config.gcc b/gcc/config.gcc index 55679ba827b..ab33d1b4244 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1548,7 +1548,7 @@ m68k-*-uclinux*) # Motorola m68k/ColdFire running uClinux # ABI. default_m68k_cpu=68020 default_cf_cpu=5206 - tm_file="${tm_file} dbxelf.h elfos.h svr4.h linux.h flat.h m68k/linux.h m68k/uclinux.h" + tm_file="${tm_file} dbxelf.h elfos.h svr4.h linux.h flat.h m68k/linux.h m68k/uclinux.h ./sysroot-suffix.h" tm_defines="${tm_defines} MOTOROLA=1 USE_GAS UCLIBC_DEFAULT=1" extra_options="${extra_options} linux.opt" tmake_file="m68k/t-floatlib m68k/t-uclinux m68k/t-mlibs" diff --git a/gcc/config/m68k/print-sysroot-suffix.sh b/gcc/config/m68k/print-sysroot-suffix.sh new file mode 100644 index 00000000000..ff83ddd107f --- /dev/null +++ b/gcc/config/m68k/print-sysroot-suffix.sh @@ -0,0 +1,82 @@ +#!/bin/sh +# Copyright (C) 2006 Free Software Foundation, Inc. +# This file is part of GCC. + +# GCC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# GCC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING. If not, write to +# the Free Software Foundation, 51 Franklin Street, Fifth Floor, +# Boston MA 02110-1301, USA. + +# This script takes the following arguments: +# +# - the target sysroot +# - the value of $(MULTILIB_MATCHES) +# - the value of $(MULTILIB_OPTIONS) +# +# It uses these arguments to construct a definition of SYSROOT_SUFFIX_SPEC, +# which it prints to the standard output. For each multilib directory FOO, +# the script checks whether $sysroot has a subdirectory FOO, and if so will +# use /FOO for all compatible command-line options. It will not add a +# suffix for /FOO's options otherwise. These suffixes are concatenated, +# with one subspec for each space-separated entry in $(MULTILIB_OPTIONS). +set -e +sysroot=$1 +matches=$2 +options=$3 + +# For each multilib option OPT, add to $substs a sed command of the +# form "-e 's/OPT/OPT/'". +substs="" +for option in `echo "$options" | tr '/' ' '` +do + substs="$substs -e 's/$option/$option/g'" +done + +# For each ALIAS=CANONICAL entry in $MULTILIB_MATCHES, look for sed +# arguments in $substs of the form "-e 's/CANONICAL/.../'". Replace +# such entries with "-e 's/CANONICAL/ALIAS|.../'". Both the ALIAS and +# CANONICAL parts of $MULTILIB_MATCHES use '?' to stand for '='. +# +# After this loop, a command of the form "echo FOO | eval sed $substs" +# will replace a canonical option FOO with a %{...}-style spec pattern. +for match in $matches +do + canonical=`echo "$match" | sed -e 's/=.*//' -e 's/?/=/g'` + alias=`echo "$match" | sed -e 's/.*=//' -e 's/?/=/g'` + substs=`echo "$substs" | sed -e "s,s/$canonical/,&$alias|,"` +done + +# Build up the final SYSROOT_SUFFIX_SPEC in $spec. +spec= +for combo in $options +do + # See which option alternatives in $combo have their own sysroot + # directory. Create a subspec of the form "%{PAT1:/DIR1;...;PATn:DIRn}" + # from each such option OPTi, where DIRi is the directory associated + # with OPTi and PATi is the result of passing OPTi through $substs. + subspec= + for option in `echo "$combo" | tr '/' ' '` + do + dir=`echo "$option" | sed 's/cpu=//'` + if test -d "$sysroot/$dir"; then + test -z "$subspec" || subspec="$subspec;" + subspec="$subspec"`echo "$option" | eval sed $substs`":/$dir" + fi + done + # Concatenate all the subspecs. + test -z "$subspec" || spec="$spec%{$subspec}" +done +if test -n "$spec"; then + echo "#undef SYSROOT_SUFFIX_SPEC" + echo "#define SYSROOT_SUFFIX_SPEC \"$spec\"" +fi diff --git a/gcc/config/m68k/t-uclinux b/gcc/config/m68k/t-uclinux index f7053646c32..3ee359d790f 100644 --- a/gcc/config/m68k/t-uclinux +++ b/gcc/config/m68k/t-uclinux @@ -7,3 +7,10 @@ M68K_MLIB_CPU += && (MLIB == "68020" || !match(FLAGS, "FL_MMU")) # Add multilibs for execute-in-place and shared-library code. M68K_MLIB_OPTIONS += msep-data/mid-shared-library M68K_MLIB_DIRNAMES += msep-data mid-shared-library + +# This rule uses MULTILIB_MATCHES to generate a definition of +# SYSROOT_SUFFIX_SPEC. +sysroot-suffix.h: $(srcdir)/config/m68k/print-sysroot-suffix.sh + $(SHELL) $(srcdir)/config/m68k/print-sysroot-suffix.sh \ + "$(SYSTEM_HEADER_DIR)/../.." "$(MULTILIB_MATCHES)" \ + "$(MULTILIB_OPTIONS)" > $@ diff --git a/gcc/configure b/gcc/configure index 1e63c02811f..fcbcb4f8dc7 100755 --- a/gcc/configure +++ b/gcc/configure @@ -13027,6 +13027,11 @@ tm_file_list="options.h" tm_include_list="options.h" for f in $tm_file; do case $f in + ./* ) + f=`echo $f | sed 's/^..//'` + tm_file_list="${tm_file_list} $f" + tm_include_list="${tm_include_list} $f" + ;; defaults.h ) tm_file_list="${tm_file_list} \$(srcdir)/$f" tm_include_list="${tm_include_list} $f" diff --git a/gcc/configure.ac b/gcc/configure.ac index 83e13dd18f6..0d30652393b 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1610,6 +1610,11 @@ tm_file_list="options.h" tm_include_list="options.h" for f in $tm_file; do case $f in + ./* ) + f=`echo $f | sed 's/^..//'` + tm_file_list="${tm_file_list} $f" + tm_include_list="${tm_include_list} $f" + ;; defaults.h ) tm_file_list="${tm_file_list} \$(srcdir)/$f" tm_include_list="${tm_include_list} $f"