summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4')
-rw-r--r--m4/mingw.m4170
1 files changed, 96 insertions, 74 deletions
diff --git a/m4/mingw.m4 b/m4/mingw.m4
index 35d638c9565d..1cf5649e5014 100644
--- a/m4/mingw.m4
+++ b/m4/mingw.m4
@@ -1,82 +1,104 @@
-# libo_FIND_MINGW_EXTERNAL_DLLS([library-names],[variable],[?exclude],[?default-value])
-# uses: CC, SED, WITH_MINGW
-# --------------------------------------------------------------------
-AC_DEFUN([libo_FIND_MINGW_EXTERNAL_DLLS],
-[if test "$WITH_MINGW" = yes -a -n "$CC"; then
- _libo_mingw_libdir=`$CC -print-sysroot`/mingw/lib
- _libo_mingw_found_la=
- _libo_mingw_test_la([$1],[_libo_mingw_found_la],[$_libo_mingw_libdir])
- if test "$_libo_mingw_found_la" = yes; then
- _libo_mingw_find_dlls([$1],[$2],[$3],[$_libo_mingw_libdir])
- else
- # no .la files found, use defaults
- $2="$4"
- fi
-fi[]dnl
-]) # libo_FIND_MINGW_EXTERNAL_DLLS
+dnl Version: MPL 1.1 / GPLv3+ / LGPLv3+
+dnl
+dnl The contents of this file are subject to the Mozilla Public License Version
+dnl 1.1 (the "License"); you may not use this file except in compliance with
+dnl the License or as specified alternatively below. You may obtain a copy of
+dnl the License at http://www.mozilla.org/MPL/
+dnl
+dnl Software distributed under the License is distributed on an "AS IS" basis,
+dnl WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+dnl for the specific language governing rights and limitations under the
+dnl License.
+dnl
+dnl Major Contributor(s):
+dnl Copyright (C) 2012 Red Hat, Inc., David Tardon <dtardon@redhat.com>
+dnl (initial developer)
+dnl
+dnl All Rights Reserved.
+dnl
+dnl For minor contributions see the git repository.
+dnl
+dnl Alternatively, the contents of this file may be used under the terms of
+dnl either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+dnl the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+dnl in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+dnl instead of those above.
-# libo_ADD_MINGW_EXTERNAL_DLLS([library-names],[variable],[?default-value])
-# uses: CC, SED, WITH_MINGW
-# --------------------------------------------------------
-AC_DEFUN([libo_ADD_MINGW_EXTERNAL_DLLS],
-[libo_FIND_MINGW_EXTERNAL_DLLS([$1],[_libo_mingw_found_dlls],[$$2],[$3])
-if test -n "$_libo_mingw_found_dlls"; then
- $2="$$2 $_libo_mingw_found_dlls"
-fi[]dnl
-]) # libo_ADD_MINGW_EXTERNAL_DLLS
+# libo_MINGW_CHECK_DLL(variable-infix,dll-name-stem,[action-if-found],[action-if-not-found])
+#
+# Checks for presence of dll dll-name-stem . Sets variable
+# MINGW_variable-infix_DLL if found, issues an error otherwise.
+#
+# It recognizes these dll patterns (x, y match any character, but they
+# are supposed to be numerals):
+# * name-x.dll
+# * name-xy.dll
+# * name-x.y.dll
+# * name.dll
+#
+#
+# Example:
+# libo_MINGW_CHECK_DLL([EXPAT], [libexpat])
+# might result in MINGW_EXPAT_DLL=libexpat-1.dll being set.
+#
+# uses CC, WITH_MINGW
+# ------------------------------------------------------------------------------------------
+AC_DEFUN([libo_MINGW_CHECK_DLL],
+[AC_ARG_VAR([MINGW_][$1][_DLL],[output variable containing the found dll name])dnl
-# _libo_mingw_get_libtool_var([key],[lib],[out-var])
-m4_define([_libo_mingw_get_libtool_var],
-[$3=`$SED -n -e '/^$1=/{' -e "s/.*='//" -e "s/'//" -e p -e '}' $2`[]dnl
-]) # _libo_mingw_get_libtool_var
+if test -n "$WITH_MINGW"; then
+ dnl TODO move this to configure: there is no need to call $CC more than once
+ _libo_mingw_dlldir=`$CC -print-sysroot`/mingw/bin
+ _libo_mingw_dllname=
+ AC_MSG_CHECKING([for $2 dll])
-# _libo_mingw_find_dll([library],[dlls],[out-var])
-m4_define([_libo_mingw_find_dll],
-[_libo_mingw_get_libtool_var([dlname],[$1],[_libo_mingw_dlname])
-_libo_mingw_dlname=`basename $_libo_mingw_dlname`
-_libo_mingw_dll_present=
-for _libo_mingw_dll in $2; do
- if test "$_libo_mingw_dlname" = "$_libo_mingw_dll"; then
- _libo_mingw_dll_present=yes
- break
+ dnl try one- or two-numbered version
+ _libo_mingw_try_dll([$2][-?.dll])
+ if test "$_libo_mingw_dllname" = ""; then
+ _libo_mingw_try_dll([$2][-??.dll])
+ fi
+ dnl maybe the version contains a dot (e.g., libdb)
+ if test "$_libo_mingw_dllname" = ""; then
+ _libo_mingw_try_dll([$2][-?.?.dll])
+ fi
+ dnl maybe it is not versioned
+ if test "$_libo_mingw_dllname" = ""; then
+ _libo_mingw_try_dll([$2][.dll])
fi
-done
-if test -z "$_libo_mingw_dll_present"; then
- $3="$_libo_mingw_dlname"
-fi[]dnl
-]) # _libo_mingw_find_dll
-# _libo_mingw_find_dlls([libraries],[dlls],[out-var],[libdir])
-m4_define([_libo_mingw_find_dlls],
-[_libo_mingw_new_dlls=
-for _libo_mingw_lib in $1; do
- _libo_mingw_lib="$4/$_libo_mingw_lib.la"
- _libo_mingw_new_dll=
- _libo_mingw_find_dll([$_libo_mingw_lib],[$3 $_libo_mingw_new_dlls],[_libo_mingw_new_dll])
- if test -n "$_libo_mingw_new_dll"; then
- _libo_mingw_new_dlls="$_libo_mingw_new_dlls $_libo_mingw_new_dll"
+ if test "$_libo_mingw_dllname" = ""; then
+ AC_MSG_RESULT([no])
+ m4_default([$4],[AC_MSG_ERROR([no dll found for $2])])
+ else
+ AC_MSG_RESULT([$_libo_mingw_dllname])
+ [MINGW_][$1][_DLL]="$_libo_mingw_dllname"
+ m4_default([$3],[])
fi
+fi[]dnl
+]) # libo_MINGW_CHECK_DLL
+
+# libo_MINGW_TRY_DLL(variable-infix,dll-name-stem)
+#
+# Checks for presence of dll dll-name-stem . Sets variable
+# MINGW_variable-infix_DLL if found, does nothing otherwise.
+#
+# See libo_MINGW_CHECK_DLL for further info.
+#
+# uses CC, WITH_MINGW
+# ------------------------------------------------
+AC_DEFUN([libo_MINGW_TRY_DLL],
+[dnl shortcut: do not test for already found dlls
+if test -z "$[MINGW_][$1][_DLL]"; then
+ libo_MINGW_CHECK_DLL([$1],[$2],[[]],[[]])
+fi[]dnl
+]) # libo_MINGW_TRY_DLL
- _libo_mingw_get_libtool_var([dependency_libs],[$_libo_mingw_lib],[_libo_mingw_dep_libs])
- for _libo_mingw_dep_lib in $_libo_mingw_dep_libs; do
- if test "${_libo_mingw_dep_lib%.la}" != "$_libo_mingw_dep_lib"; then
- _libo_mingw_new_dll=''
- _libo_mingw_find_dll([$_libo_mingw_dep_lib],[$3 $_libo_mingw_new_dlls],[_libo_mingw_new_dll])
- if test -n "$_libo_mingw_new_dll"; then
- _libo_mingw_new_dlls="$_libo_mingw_new_dlls $_libo_mingw_new_dll"
- fi
- fi
- done
-done
-$2="$_libo_mingw_new_dlls"[]dnl
-]) # _libo_mingw_find_dlls
+# _libo_mingw_try_dll(dll-name,dll-dir)
+m4_define([_libo_mingw_try_dll],
+[_libo_mingw_trying_dll=`ls "[$_libo_mingw_dlldir]"/[$1] 2>/dev/null`
+if test -f "$_libo_mingw_trying_dll"; then
+ _libo_mingw_dllname=`basename "$_libo_mingw_trying_dll"`
+fi[]dnl
+]) # _libo_mingw_try_dll
-# _libo_mingw_test_la([libraries],[out-var],[libdir])
-m4_define([_libo_mingw_test_la],
-[for _libo_mingw_lib in $1; do
- if test -f "$3/$_libo_mingw_lib.la"; then
- $2=yes
- break
- fi
-done[]dnl
-]) # _libo_mingw_test_la
+dnl vim:set shiftwidth=4 softtabstop=4 expandtab: