1# relocatable.m4 serial 5 (gettext-0.15) 2dnl Copyright (C) 2003, 2005-2006 Free Software Foundation, Inc. 3dnl This file is free software; the Free Software Foundation 4dnl gives unlimited permission to copy and/or distribute it, 5dnl with or without modifications, as long as this notice is preserved. 6 7dnl From Bruno Haible. 8 9dnl Support for relocateble programs. 10AC_DEFUN([AC_RELOCATABLE], 11[ 12 AC_REQUIRE([AC_PROG_INSTALL]) 13 AC_BEFORE([AC_PROG_INSTALL],[AC_RELOCATABLE]) 14 AC_REQUIRE([AC_LIB_LIBPATH]) 15 AC_REQUIRE([AC_RELOCATABLE_LIBRARY]) 16 AC_REQUIRE([AC_EXEEXT]) 17 is_noop=no 18 use_elf_origin_trick=no 19 if test $RELOCATABLE = yes; then 20 # --enable-relocatable implies --disable-rpath 21 enable_rpath=no 22 AC_LIBOBJ([relocatable]) 23 AC_DEFINE([ENABLE_RELOCATABLE], 1, 24 [Define to 1 if the package shall run at any location in the filesystem.]) 25 AC_CHECK_HEADERS([unistd.h mach-o/dyld.h]) 26 AC_CHECK_FUNCS([_NSGetExecutablePath]) 27 case "$host_os" in 28 mingw*) is_noop=yes ;; 29 linux*) use_elf_origin_trick=yes ;; 30 esac 31 if test $is_noop = yes; then 32 SET_RELOCATABLE="RELOCATABLE_LDFLAGS = :" 33 else 34 if test $use_elf_origin_trick = yes; then 35 dnl Use the dynamic linker's support for relocatable programs. 36 case "$ac_aux_dir" in 37 /*) reloc_ldflags="$ac_aux_dir/reloc-ldflags" ;; 38 *) reloc_ldflags="\$(top_builddir)/$ac_aux_dir/reloc-ldflags" ;; 39 esac 40 SET_RELOCATABLE="RELOCATABLE_LDFLAGS = \"$reloc_ldflags\" \"\$(host)\" \"\$(RELOCATABLE_LIBRARY_PATH)\"" 41 else 42 dnl Unfortunately we cannot define INSTALL_PROGRAM to a command 43 dnl consisting of more than one word - libtool doesn't support this. 44 dnl So we abuse the INSTALL_PROGRAM_ENV hook, originally meant for the 45 dnl 'install-strip' target. 46 SET_RELOCATABLE="INSTALL_PROGRAM_ENV = RELOC_LIBRARY_PATH_VAR=\"$shlibpath_var\" RELOC_LIBRARY_PATH_VALUE=\"\$(RELOCATABLE_LIBRARY_PATH)\" RELOC_PREFIX=\"\$(prefix)\" RELOC_COMPILE_COMMAND=\"\$(CC) \$(CPPFLAGS) \$(CFLAGS) \$(LDFLAGS)\" RELOC_SRCDIR=\"\$(RELOCATABLE_SRC_DIR)\" RELOC_BUILDDIR=\"\$(RELOCATABLE_BUILD_DIR)\" RELOC_CONFIG_H_DIR=\"\$(RELOCATABLE_CONFIG_H_DIR)\" RELOC_EXEEXT=\"\$(EXEEXT)\" RELOC_INSTALL_PROG=\"$INSTALL_PROGRAM\"" 47 case "$ac_aux_dir" in 48 /*) INSTALL_PROGRAM="$ac_aux_dir/install-reloc" ;; 49 *) INSTALL_PROGRAM="\$(top_builddir)/$ac_aux_dir/install-reloc" ;; 50 esac 51 fi 52 fi 53 else 54 SET_RELOCATABLE= 55 fi 56 AC_SUBST([SET_RELOCATABLE]) 57 AM_CONDITIONAL([RELOCATABLE_VIA_LD], 58 [test $is_noop = yes || test $use_elf_origin_trick = yes]) 59]) 60 61dnl Support for relocatable libraries. 62AC_DEFUN([AC_RELOCATABLE_LIBRARY], 63[ 64 AC_REQUIRE([AC_RELOCATABLE_NOP]) 65 dnl Easier to put this here once, instead of into the DEFS of each Makefile. 66 if test "X$prefix" = "XNONE"; then 67 reloc_final_prefix="$ac_default_prefix" 68 else 69 reloc_final_prefix="$prefix" 70 fi 71 AC_DEFINE_UNQUOTED([INSTALLPREFIX], ["${reloc_final_prefix}"], 72 [Define to the value of ${prefix}, as a string.]) 73]) 74 75dnl Support for relocatable packages for which it is a nop. 76AC_DEFUN([AC_RELOCATABLE_NOP], 77[ 78 AC_MSG_CHECKING([whether to activate relocatable installation]) 79 AC_ARG_ENABLE(relocatable, 80 [ --enable-relocatable install a package that can be moved in the filesystem], 81 [if test "$enableval" != no; then 82 RELOCATABLE=yes 83 else 84 RELOCATABLE=no 85 fi 86 ], RELOCATABLE=no) 87 AC_SUBST(RELOCATABLE) 88 AC_MSG_RESULT([$RELOCATABLE]) 89]) 90 91dnl Determine the platform dependent parameters needed to use relocatability: 92dnl shlibpath_var. 93AC_DEFUN([AC_LIB_LIBPATH], 94[ 95 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD 96 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host 97 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir 98 AC_CACHE_CHECK([for shared library path variable], acl_cv_libpath, [ 99 LD="$LD" \ 100 ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.libpath" "$host" > conftest.sh 101 . ./conftest.sh 102 rm -f ./conftest.sh 103 acl_cv_libpath=${acl_cv_shlibpath_var:-none} 104 ]) 105 shlibpath_var="$acl_cv_shlibpath_var" 106]) 107