summaryrefslogtreecommitdiff
path: root/Build/source/texk/xdvipdfmx/acinclude.m4
blob: c99ed5b77a07820d0c6e55689588c471034ec161 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275

#
# Check for kpathsea
#
AC_DEFUN([AC_CHECK_KPSE_SUPPORT], [
  AC_MSG_CHECKING([whether you have kpathsea headers and they know about the required file formats])
  AC_TRY_COMPILE(
    [
#include <stdio.h>
#include <kpathsea/kpathsea.h>
      ], [
kpse_tex_ps_header_format;
kpse_type1_format;
kpse_vf_format;
kpse_ofm_format;
kpse_ovf_format;
kpse_truetype_format;
    ],
    [ AC_MSG_RESULT(yes)
      AC_CHECK_LIB(kpathsea, xbasename,
        [],
        [ AC_MSG_ERROR([
This version of dvipdfmx requires xbasename() in kpathsea library.
          ]) ]
      )
    ],
    [ AC_MSG_RESULT(no);
      AC_MSG_ERROR([
This version of dvipdfmx requires that kpathsea and its headers be installed.
If you are sure they are installed and in a standard place, maybe you need a
newer version of kpathsea?  You also might try setting the environment
variable CPPFLAGS (or CFLAGS) with -I pointing to the directory containing
the file "tex-file.h"
      ]) ]
  )
])


#
# Check for enc, cmap, sfd formats
#
AC_DEFUN([AC_CHECK_KPSE_TDS_VERSION], [
  AC_MSG_CHECKING([whether kpathsea library supports TDS version 1.1 installation])
  AC_TRY_COMPILE(
    [
#include <stdio.h>
#include <kpathsea/kpathsea.h>
#include <kpathsea/tex-file.h>
      ], [
kpse_enc_format;
kpse_cmap_format;
kpse_sfd_format;
kpse_opentype_format;
    ],
    [ AC_MSG_RESULT(yes);
      AC_DEFINE([__TDS_VERSION__],  0x200406L, [Define if your libkpathsea supports enc formats])
      AM_CONDITIONAL(TDS_VERSION_11, true)
    ],
    [ AC_MSG_RESULT(no);
      AC_DEFINE([__TDS_VERSION__],  0x200302L, [Define if your libkpathsea supports enc formats])
      AM_CONDITIONAL(TDS_VERSION_11, false)
    ]
  )
])


#
# Check for zlib
#
AC_DEFUN([AC_HAS_ZLIB], [
  _cppflags=$CPPFLAGS _ldflags=$LDFLAGS
  AC_ARG_WITH(zlib,  
    [  --with-zlib=DIR         use zlib include/library files from DIR],
    [
if test -d "$withval"; then
  CPPFLAGS="$CPPFLAGS -I$withval/include"
  LDFLAGS="$LDFLAGS -L$withval/lib"
fi
    ]
  )
  AC_MSG_CHECKING([for zlib header files])
  AC_TRY_COMPILE(
    [
#include <zlib.h>
      ], [
z_stream p;
    ],
    [ AC_MSG_RESULT(yes)
      AC_CHECK_LIB(z, compress, [
        AC_DEFINE(HAVE_ZLIB, 1, [Define if you have zlib and its headers])
        LIBS="$LIBS -lz"
        AC_CHECK_LIB(z, compress2, [
          AC_DEFINE(HAVE_ZLIB_COMPRESS2, 1, [Define if your zlib has the compress2 function])
        ])
      ])
    ],
    [CPPFLAGS=$_cppflags LDDFLAGS=$_ldflags AC_MSG_RESULT(no)]
 )
])

#
#   Check for libpng
#
AC_DEFUN([AC_HAS_LIBPNG], [
  _cppflags=$CPPFLAGS _ldflags=$LDFLAGS
  AC_ARG_WITH(png,
    [  --with-png=DIR          use png include/library files from DIR],
    [
if test -d "$withval"; then
  CPPFLAGS="$CPPFLAGS -I$withval/include"
  LDFLAGS="$LDFLAGS -L$withval/lib"
fi
    ]
  )
  AC_CHECK_FUNC(pow, , AC_CHECK_LIB(m, pow, LIBS="$LIBS -lm"))
  AC_MSG_CHECKING([for png header files])
  AC_TRY_COMPILE(
    [
#include <png.h>
      ], [
png_infop p;
    ],
    [ AC_MSG_RESULT(yes)
      AC_CHECK_LIB(png, png_get_image_width,
        [ AC_DEFINE(HAVE_LIBPNG, 1, [Define if you have libpng])
          LIBS="$LIBS -lpng" ], , -lz
      )
    ],
    [CPPFLAGS=$_cppflags LDDFLAGS=$_ldflags AC_MSG_RESULT(no)]
  )
])

#
#   Check for libpaper
#
AC_DEFUN([AC_HAS_LIBPAPER], [
  _cppflags=$CPPFLAGS _ldflags=$LDFLAGS
  AC_ARG_WITH(paper,
    [  --with-paper=DIR        use paper include/library files from DIR],
    [
if test -d "$withval"; then
  CPPFLAGS="$CPPFLAGS -I$withval/include"
  LDFLAGS="$LDFLAGS -L$withval/lib"
fi
    ]
  )
  AC_MSG_CHECKING([for paper header files])
  AC_TRY_COMPILE(
    [
#include <paper.h>
      ], [
struct paper *p;
    ],
    [ AC_MSG_RESULT(yes)
      AC_CHECK_LIB(paper, paperpswidth, [
        AC_DEFINE(HAVE_LIBPAPER, 1, [Define if you have libpaper])
        LIBS="$LIBS -lpaper"
      ])
    ],
    [CPPFLAGS=$_cppflags LDDFLAGS=$_ldflags AC_MSG_RESULT(no)]
  )
])

#
#   Check for libfontconfig
#
AC_DEFUN([AC_HAS_LIBFONTCONFIG], [
  _cppflags=$CPPFLAGS _ldflags=$LDFLAGS
  AC_ARG_WITH(fontconfig,
    [  --with-fontconfig=DIR   use fontconfig include/library files from DIR],
    [
if test -d "$withval"; then
  CPPFLAGS="$CPPFLAGS -I$withval/include"
  LDFLAGS="$LDFLAGS -L$withval/lib"
  FONTCONFIGLDFLAGS="-L$withval/lib"
fi
    ]
  )
  AC_MSG_CHECKING([for fontconfig header files])
  AC_TRY_COMPILE(
    [
#include <fontconfig/fontconfig.h>
      ], [
FcObjectSet *os;
    ],
    [ AC_MSG_RESULT(yes)
      AC_CHECK_LIB(fontconfig, FcInit, [
        AC_DEFINE(HAVE_LIBFONTCONFIG, 1, [Define if you have libfontconfig])
        LIBS="$LIBS -lfontconfig"
      ])
    ],
    [CPPFLAGS=$_cppflags LDDFLAGS=$_ldflags AC_MSG_RESULT(no)]
  )
])

#
#   Check for libfreetype, fail with error if not found
#
AC_DEFUN([AC_CHECK_LIBFREETYPE], [
  _cppflags=$CPPFLAGS _ldflags=$LDFLAGS
  using_installed_freetype=yes
  AC_ARG_WITH(ft2lib,
    [  --with-ft2lib=LIB       use freetype2 library LIB],
    [
	  if test x"$withval" != x; then
	    LIBS="$LIBS $withval"
	    using_installed_freetype=no
	  fi
    ]
  )
  AC_ARG_WITH(ft2include,
    [  --with-ft2include=DIR   use freetype2 include files from DIR],
    [
	  if test -d "$withval"; then
	    CPPFLAGS="$CPPFLAGS -I$withval"
	  fi
    ]
  )
  AC_ARG_WITH(freetype2,
    [  --with-freetype2=DIR    use installed freetype2 include & lib files from DIR],
    [
	  if test -d "$withval"; then
	    CPPFLAGS="$CPPFLAGS -I$withval/include/freetype2"
	    LDFLAGS="$LDFLAGS -L$withval/lib"
	  fi
    ]
  )
  AC_MSG_CHECKING([for freetype2 header files and library])
  AC_TRY_COMPILE(
    [
#include "ft2build.h"
#include FT_FREETYPE_H
    ],
    [
FT_Face face;
    ],
    [ AC_MSG_RESULT(yes)
      if test x"$using_installed_freetype" = xyes; then
        AC_CHECK_LIB(freetype, FT_Init_FreeType, [
          AC_DEFINE(HAVE_LIBFREETYPE, 1, [Define if you have libfreetype])
          LIBS="$LIBS -lfreetype"
        ])
      else
        AC_DEFINE(HAVE_LIBFREETYPE, 1, [Define if you have libfreetype])
      fi
    ],
    [ AC_MSG_RESULT(no)
          AC_MSG_ERROR([
This version of xdvipdfmx requires that FreeType2 and its headers be available.
You can use the --with-freetype2 option to indicate the location of the installed
freetype2, or --with-ft2lib and --with-ft2include to point to the libfreetype.a
library and the FreeType2 include files.])
    ]
  )
])

#
#   Check for ApplicationServices
#
AC_DEFUN([AC_HAS_APP_SERVICES], [
  AC_MSG_CHECKING([for Mac OS X ApplicationServices framework])
  AC_TRY_COMPILE(
    [
#include <ApplicationServices/ApplicationServices.h>
      ], [
ATSFontRef fontRef;
    ],
    [ AC_MSG_RESULT(yes)
      AC_DEFINE(HAVE_APP_SERVICES, 1, [Define if you have ApplicationServices (Mac OS X)])
      LIBS="$LIBS -framework ApplicationServices"
    ],
    [ AC_MSG_RESULT(no) ]
  )
])