summaryrefslogtreecommitdiff
path: root/m4/mingw.m4
blob: d75d6a0bdddf9aaac49a6557733ead4c2cd0eb6d (plain)
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
dnl
dnl This file is part of the LibreOffice project.
dnl
dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
dnl

# libo_MINGW_CHECK_DLL(dll-name-stem,[action-if-found],[action-if-not-found])
#
# Checks for presence of dll dll-name-stem . Appends the dll name to
# variable MINGW_DLLS 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:
# MINGW_DLLS=
# libo_MINGW_CHECK_DLL([libexpat])
# might result in MINGW_DLLS containing libexpat-1.dll .
#
# uses MINGW_SYSROOT, WITH_MINGW
# changes MINGW_DLLS
# ------------------------------------------------------------------------------------------
AC_DEFUN([libo_MINGW_CHECK_DLL],
[dnl

if test -n "$WITH_MINGW"; then
    _libo_mingw_dlldir="[$MINGW_SYSROOT]"/bin
    _libo_mingw_dllname=
    AC_MSG_CHECKING([for $1 dll])

    dnl try one- or two-numbered version
    _libo_mingw_try_dll([$1][-?.dll])
    if test "$_libo_mingw_dllname" = ""; then
        _libo_mingw_try_dll([$1][-??.dll])
    fi
    dnl maybe the version contains a dot (e.g., libdb)
    if test "$_libo_mingw_dllname" = ""; then
        _libo_mingw_try_dll([$1][-?.?.dll])
    fi
    dnl maybe the version contains a dash (e.g., libpixman)
    if test "$_libo_mingw_dllname" = ""; then
        _libo_mingw_try_dll([$1][-?-?.dll])
    fi
    dnl maybe it is not versioned
    if test "$_libo_mingw_dllname" = ""; then
        _libo_mingw_try_dll([$1][.dll])
    fi

    if test "$_libo_mingw_dllname" = ""; then
        AC_MSG_RESULT([no])
        m4_default([$3],[AC_MSG_ERROR([no dll found for $1])])
    else
        AC_MSG_RESULT([$_libo_mingw_dllname])
        MINGW_DLLS="$MINGW_DLLS $_libo_mingw_dllname"
        m4_default([$2],[])
    fi
fi[]dnl
]) # libo_MINGW_CHECK_DLL

# libo_MINGW_TRY_DLL(dll-name-stem)
#
# Checks for presence of dll dll-name-stem . Appends the dll name to
# variable MINGW_DLLS if found, does nothing otherwise.
#
# See libo_MINGW_CHECK_DLL for further info.
#
# uses MINGW_SYSROOT, WITH_MINGW
# changes MINGW_DLLS
# ------------------------------------------------
AC_DEFUN([libo_MINGW_TRY_DLL],
[dnl TODO: ignore already tested for dlls
libo_MINGW_CHECK_DLL([$1],[[]],[[]])dnl
]) # libo_MINGW_TRY_DLL

# _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

dnl vim:set shiftwidth=4 softtabstop=4 expandtab: