Hash :
f4e91bfc
Author :
Date :
2017-03-13T12:41:59
automake: Shorter object file names under subdir-objects Combining the 'subdir-objects' option with target-specific flags had the consequence of producing long object file names. This was done to preventively ensure the uniqueness of object file names. We are now using shorter names by default, and handle long names when an actual conflict is detected. This will hopefully reduce the necessity of using the 'prog_SHORTNAME' facility. Example: previously: AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS += path/to/foo path_to_foo_CFLAGS = $(AM_CFLAGS) -g resulted in objects: sub/path_to_foo-foo.o now object file name is: sub/foo-foo.o * bin/automake.in (proglist, liblist, ltliblist) (dup_shortnames): New globals. (initialize_per_input): Initialize them. (handle_targets): New subroutine. (handle_single_transform): Truncate object file names when possible. * t/subobj-objname-clash.sh: New test. * t/list-of-tests.mk (handwritten_TESTS): Add it. * NEWS: Update. Signed-off-by: Mathieu Lirzin <mthl@gnu.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
#! /bin/sh
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
# Make sure that object names don't clash when using subdir-objects.
# The check is done for clashing programs, clashing libraries and
# a program that clashes with a library
. test-init.sh
mkdir src
cat >> configure.ac << 'END'
AC_PROG_CC
AC_PROG_RANLIB
AC_OUTPUT
END
cat > Makefile.am << 'END'
AUTOMAKE_OPTIONS = subdir-objects foreign
noinst_PROGRAMS =
noinst_LIBRARIES =
# CLASHING PROGRAMS
noinst_PROGRAMS += foo src/foo
foo_SOURCES = src/foo.c src/main.c
foo_CPPFLAGS = -DVAL=0
src_foo_CPPFLAGS = -DVAL=1
src_foo_SOURCES = src/foo.c src/main.c
# CLASHING LIBS
noinst_PROGRAMS += bar src/bar
noinst_LIBRARIES += libbar.a src/libbar.a
bar_SOURCES = src/main.c
bar_LDADD = libbar.a
src_bar_SOURCES = src/main.c
src_bar_LDADD = src/libbar.a
libbar_a_SOURCES = src/foo.c
libbar_a_CPPFLAGS = -DVAL=0
src_libbar_a_SOURCES = src/foo.c
src_libbar_a_CPPFLAGS = -DVAL=1
# CLASHING PROGRAM + LIB
noinst_PROGRAMS += libzap_a src/zap
noinst_LIBRARIES += src/libzap.a
libzap_a_SOURCES = src/main.c src/foo.c
libzap_a_CPPFLAGS = -DVAL=2
src_zap_SOURCES = src/main.c
src_zap_LDADD = src/libzap.a
src_libzap_a_SOURCES = src/foo.c
src_libzap_a_CPPFLAGS = -DVAL=3
# NON-CLASHING
noinst_PROGRAMS += src/foo-uniq
src_foo_uniq_SOURCES = src/main.c src/foo.c
src_foo_uniq_CPPFLAGS = -DVAL=4
END
cat > src/foo.c << 'END'
int
foo ()
{
return VAL;
}
END
cat > src/main.c << 'END'
int foo (void);
int
main ()
{
return foo ();
}
END
$ACLOCAL
$AUTOCONF
$AUTOMAKE --add-missing
./configure
$MAKE
set +e
./foo || fail_ "./foo should return 0"
./src/foo; test $? = 1 || fail_ "./src/foo should return 1"
./bar || fail_ "./bar should return 0"
./src/bar; test $? = 1 || fail_ "./src/bar should return 1"
./libzap_a; test $? = 2 || fail_ "./libfoo_a should return 2"
./src/zap; test $? = 3 || fail_ "./src/prog_libfoo should return 3"
./src/foo-uniq; test $? = 4 || fail_ "./foo_uniq should return 4"
set -e
$MAKE clean