@@ -10,6 +10,7 @@ prefix = @prefix@
1010local_prefix = /usr/local
1111exec_prefix = @exec_prefix@
1212bindir = @bindir@
13+ libdir = @libdir@
1314datadir = @datadir@
1415localedir = $(datadir ) /locale
1516
@@ -39,20 +40,25 @@ SHELL = /bin/sh
3940# Needed by $(LIBTOOL).
4041top_builddir = ..
4142
42- all : iconv
43-
44- # When linking with libintl and producing a shared libiconv, we need to omit
45- # the -liconv flag that might be present in @LTLIBINTL@. Otherwise, on FreeBSD,
46- # when a libiconv <= 1.7 is already installed and we install a libiconv >= 1.8,
47- # we get a link error.
48- iconv : iconv.@OBJEXT@ ../lib/libiconv.la
49- build_shared=` $( LIBTOOL) --config | grep ' ^build_libtool_libs=' | sed -e ' s/build_libtool_libs=//' ` ; \
50- libintl=` if test " $$ build_shared" = yes; then \
51- echo " @LTLIBINTL@ " | sed -e ' s, -liconv , ,g' -e ' s, [^ ]*/libiconv\.[^ ]* , ,g' ; \
52- else \
53- echo " @LTLIBINTL@ " ; \
54- fi` ; \
55- $(LIBTOOL_LINK ) $(CC ) $(LDFLAGS ) iconv.@OBJEXT@ ../lib/libiconv.la $$ libintl -o $@
43+ # We cannot link with libintl until libiconv is installed. (When we call
44+ # libtool with arguments "../lib/libiconv.la -lintl", libtool will call ld
45+ # with "../lib/.libs/libiconv.so $libdir/libintl.so $libdir/libiconv.so",
46+ # (remember that $libdir/libintl.la lists $libdir/libiconv.so as a dependency),
47+ # and this gives a fatal linker error on Solaris because the two libiconv.so
48+ # files are different but have the same soname.
49+ # So we can link the iconv executable only after we have installed libiconv,
50+ # i.e. during "make install". The intermediate 'iconv' executable is built
51+ # without internationalization and not linked with libintl.
52+
53+ all : iconv_no_i18n iconv.@OBJEXT@
54+ chmod 777 .
55+
56+ # This is the temporary iconv executable, without internationalization.
57+ iconv_no_i18n : iconv_no_i18n.@OBJEXT@ ../lib/libiconv.la
58+ $(LIBTOOL_LINK ) $(CC ) $(LDFLAGS ) iconv_no_i18n.@OBJEXT@ ../lib/libiconv.la -o $@
59+
60+ iconv_no_i18n.@OBJEXT@ : $(srcdir ) /iconv_no_i18n.c $(srcdir ) /iconv.c
61+ $(CC ) -c $(INCLUDES ) -I../lib $(CFLAGS ) $(CPPFLAGS ) -DLOCALEDIR=\" $(localedir ) \" $(srcdir ) /iconv_no_i18n.c
5662
5763iconv.@OBJEXT@ : $(srcdir ) /iconv.c
5864 $(CC ) -c $(INCLUDES ) -I../lib $(CFLAGS ) $(CPPFLAGS ) -DLOCALEDIR=\" $(localedir ) \" $(srcdir ) /iconv.c
@@ -61,10 +67,19 @@ iconv.@OBJEXT@ : $(srcdir)/iconv.c
6167../lib/libiconv.la :
6268 cd ../lib && $(MAKE ) libiconv.la
6369
70+ # During "make install", we can build the final iconv executable.
71+ # On HP-UX, in order to ensure that the new libiconv.sl will override the old
72+ # one that is hardcoded in libintl.sl, we need to mention libiconv.sl before
73+ # libintl.sl on the link command line. We have to bypass libtool in order to
74+ # achieve this.
6475install : all force
6576 if [ ! -d $( DESTDIR) $( prefix) ] ; then mkdir $( DESTDIR) $( prefix) ; fi
6677 if [ ! -d $( DESTDIR) $( exec_prefix) ] ; then mkdir $( DESTDIR) $( exec_prefix) ; fi
6778 if [ ! -d $( DESTDIR) $( bindir) ] ; then mkdir $( DESTDIR) $( bindir) ; fi
79+ case " @host_os@" in \
80+ hpux* ) $(CC ) $(LDFLAGS ) iconv.@OBJEXT@ -L$(libdir ) -liconv @LIBINTL@ -o iconv;; \
81+ * ) $(LIBTOOL_LINK ) $(CC ) $(LDFLAGS ) iconv.@OBJEXT@ $(libdir ) /libiconv.la @LTLIBINTL@ -o iconv;; \
82+ esac
6883 $(LIBTOOL_INSTALL ) $(INSTALL_PROGRAM ) iconv $(DESTDIR )$(bindir ) /iconv
6984
7085installdirs : force
@@ -80,7 +95,7 @@ check : all
8095mostlyclean : clean
8196
8297clean : force
83- $(RM ) * .@OBJEXT@ * .lo iconv core
98+ $(RM ) * .@OBJEXT@ * .lo iconv_no_i18n iconv core
8499 $(RM ) -r .libs _libs
85100
86101distclean : clean
0 commit comments