relocatable.m4 revision 1.1.1.1
1# relocatable.m4 serial 7 (gettext-0.16) 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_RELOCATABLE_BODY]) 13 if test $RELOCATABLE = yes; then 14 AC_LIBOBJ([relocatable]) 15 fi 16]) 17dnl The guts of AC_RELOCATABLE. Needs to be expanded only once. 18AC_DEFUN([AC_RELOCATABLE_BODY], 19[ 20 AC_REQUIRE([AC_PROG_INSTALL]) 21 dnl This AC_BEFORE invocation leads to unjustified autoconf warnings 22 dnl when AC_RELOCATABLE_BODY is invoked more than once. 23 dnl We need this AC_BEFORE because AC_PROG_INSTALL is documented to 24 dnl overwrite earlier settings of INSTALL and INSTALL_PROGRAM (even 25 dnl though in autoconf-2.52..2.60 it doesn't do so), but we want this 26 dnl macro's setting of INSTALL_PROGRAM to persist. 27 AC_BEFORE([AC_PROG_INSTALL],[AC_RELOCATABLE_BODY]) 28 AC_REQUIRE([AC_LIB_LIBPATH]) 29 AC_REQUIRE([AC_RELOCATABLE_LIBRARY]) 30 AC_REQUIRE([AC_EXEEXT]) 31 is_noop=no 32 use_elf_origin_trick=no 33 if test $RELOCATABLE = yes; then 34 # --enable-relocatable implies --disable-rpath 35 enable_rpath=no 36 AC_DEFINE([ENABLE_RELOCATABLE], 1, 37 [Define to 1 if the package shall run at any location in the filesystem.]) 38 AC_CHECK_HEADERS([unistd.h mach-o/dyld.h]) 39 AC_CHECK_FUNCS([_NSGetExecutablePath]) 40 case "$host_os" in 41 mingw*) is_noop=yes ;; 42 linux*) use_elf_origin_trick=yes ;; 43 esac 44 if test $is_noop = yes; then 45 SET_RELOCATABLE="RELOCATABLE_LDFLAGS = :" 46 else 47 if test $use_elf_origin_trick = yes; then 48 dnl Use the dynamic linker's support for relocatable programs. 49 case "$ac_aux_dir" in 50 /*) reloc_ldflags="$ac_aux_dir/reloc-ldflags" ;; 51 *) reloc_ldflags="\$(top_builddir)/$ac_aux_dir/reloc-ldflags" ;; 52 esac 53 SET_RELOCATABLE="RELOCATABLE_LDFLAGS = \"$reloc_ldflags\" \"\$(host)\" \"\$(RELOCATABLE_LIBRARY_PATH)\"" 54 else 55 dnl Unfortunately we cannot define INSTALL_PROGRAM to a command 56 dnl consisting of more than one word - libtool doesn't support this. 57 dnl So we abuse the INSTALL_PROGRAM_ENV hook, originally meant for the 58 dnl 'install-strip' target. 59 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\"" 60 case "$ac_aux_dir" in 61 /*) INSTALL_PROGRAM="$ac_aux_dir/install-reloc" ;; 62 *) INSTALL_PROGRAM="\$(top_builddir)/$ac_aux_dir/install-reloc" ;; 63 esac 64 fi 65 fi 66 else 67 SET_RELOCATABLE= 68 fi 69 AC_SUBST([SET_RELOCATABLE]) 70 AM_CONDITIONAL([RELOCATABLE_VIA_LD], 71 [test $is_noop = yes || test $use_elf_origin_trick = yes]) 72]) 73 74dnl Support for relocatable libraries. 75AC_DEFUN([AC_RELOCATABLE_LIBRARY], 76[ 77 AC_REQUIRE([AC_RELOCATABLE_NOP]) 78 dnl Easier to put this here once, instead of into the DEFS of each Makefile. 79 if test "X$prefix" = "XNONE"; then 80 reloc_final_prefix="$ac_default_prefix" 81 else 82 reloc_final_prefix="$prefix" 83 fi 84 AC_DEFINE_UNQUOTED([INSTALLPREFIX], ["${reloc_final_prefix}"], 85 [Define to the value of ${prefix}, as a string.]) 86]) 87 88dnl Support for relocatable packages for which it is a nop. 89AC_DEFUN([AC_RELOCATABLE_NOP], 90[ 91 AC_MSG_CHECKING([whether to activate relocatable installation]) 92 AC_ARG_ENABLE(relocatable, 93 [ --enable-relocatable install a package that can be moved in the filesystem], 94 [if test "$enableval" != no; then 95 RELOCATABLE=yes 96 else 97 RELOCATABLE=no 98 fi 99 ], RELOCATABLE=no) 100 AC_SUBST(RELOCATABLE) 101 AC_MSG_RESULT([$RELOCATABLE]) 102]) 103 104dnl Determine the platform dependent parameters needed to use relocatability: 105dnl shlibpath_var. 106AC_DEFUN([AC_LIB_LIBPATH], 107[ 108 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD 109 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host 110 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir 111 AC_CACHE_CHECK([for shared library path variable], acl_cv_libpath, [ 112 LD="$LD" \ 113 ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.libpath" "$host" > conftest.sh 114 . ./conftest.sh 115 rm -f ./conftest.sh 116 acl_cv_libpath=${acl_cv_shlibpath_var:-none} 117 ]) 118 shlibpath_var="$acl_cv_shlibpath_var" 119]) 120