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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
# Process this file with autoconf to produce a configure script.
AC_INIT(gdk_imlib/gdk_imlib.h)
# Save this value here, since automake will set cflags later
cflags_set=${CFLAGS+set}
AC_CONFIG_HEADERS(config.h)
AM_INIT_AUTOMAKE(imlib, 1.9.15)
AC_PROG_CC
AM_PROG_LIBTOOL
dnl Initialize maintainer mode
AM_MAINTAINER_MODE
dnl Give the user an option to compile without shared memory support,
dnl incase it is broken for example.
AC_ARG_ENABLE(shm, [ --enable-shm support shared memory if available [default=yes]], echo $enable_shm, enable_shm="yes")
AM_PATH_GTK(1.2.1,[
GDK_IMLIB="gdk_imlib utils"],[
GDK_IMLIB=""
AC_MSG_WARN([*** gdk_imlib will not be built ***])])
AC_MSG_CHECKING(whether to build gmodulized imlib)
AC_ARG_ENABLE(modules, [ --disable-modules Disables dynamic module loading],[
if test x$withval = xyes; then
with_modules=yes
else
with_modules=no
fi
])
dynworks=false
if test x$with_modules = xno; then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
if test "x$GDK_IMLIB" != x; then
oLIBS="$LIBS"
oCFLAGS="$CFLAGS"
LIBS="$LIBS `glib-config --libs gmodule`"
CFLAGS="$CFLAGS `glib-config --cflags gmodule`"
AC_TRY_RUN([
#include <glib.h>
#include <gmodule.h>
main ()
{
if (g_module_supported ())
exit (0);
else
exit (1);
}
], dynworks=true)
LIBS="$oLIBS"
CFLAGS="$oCFLAGS"
fi
dnl Now we check to see if our libtool supports shared lib deps
dnl (in a rather ugly way even)
builddir=`pwd`
if $dynworks; then
imlib_libtool_config="$builddir/libtool --config"
imlib_deplibs_check=`$imlib_libtool_config | \
grep '^[[a-z_]]*check[[a-z_]]*_method=[['\''"]]' | \
sed 's/.*[['\''"]]\(.*\)[['\''"]]$/\1/'`
if test "x$imlib_deplibs_check" = "xnone" || \
test "x$imlib_deplibs_check" = "xunknown" || \
test "x$imlib_deplibs_check" = "x"; then
dynworks=false
fi
fi
if $dynworks; then
AC_DEFINE(USE_GMODULE, 1, [ ])
GMODULE_LIBS="`glib-config --libs gmodule`"
GMODULE_FLAGS="`glib-config --cflags gmodule`"
AC_SUBST(GMODULE_LIBS)
AC_SUBST(GMODULE_FLAGS)
fi
fi
AC_SUBST(TIFFLIBS)
AC_SUBST(GIFLIBS)
AC_SUBST(JPEGLIBS)
AC_SUBST(PNGLIBS)
AC_SUBST(GDK_IMLIB)
AM_CONDITIONAL(DYNAMIC_MODULES_WORK, $dynworks)
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_HEADER_SYS_WAIT
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(vsnprintf)
AC_CHECK_FUNCS(snprintf)
AC_CHECK_FUNCS(basename)
AC_CHECK_FUNCS(blumfrub)
AC_CHECK_FUNCS(buckets_of_erogenous_nym)
AC_CHECK_FUNCS(buttox)
AC_CHECK_HEADER(stdarg.h, AC_DEFINE(HAVE_STDARGS, 1, [ ]))
AC_CHECK_HEADER(string.h)
AC_CHECK_HEADER(strings.h)
AC_PATH_X
AC_PATH_XTRA
if test "x$x_includes" = "x"; then
x_includes="/usr/include"
fi
dnl If we are compiling without shared memory support, then don\'t do
dnl the checks for XShm
if test "x$enable_shm" = "xyes"; then
# Check for the Xext library (needed for XShm extension)
AC_CHECK_LIB(Xext, XShmAttach,
X_LIBS="-lXext $X_LIBS",
# On AIX, it is in XextSam instead, but we still need -lXext
AC_CHECK_LIB(XextSam, XShmAttach,
X_LIBS="-lXextSam -lXext $X_LIBS",
no_xshm_ext=yes, $X_LIBS),
$X_LIBS)
fi
if test -z "$GDK_IMLIB"; then
# see macros/gnome-x-checks.m4, and gtk.m4
CPPFLAGS="$CPPFLAGS $X_CFLAGS"
GX_LIBS="$X_PRE_LIBS $X_LIBS -lX11 -lm"
else
CPPFLAGS="$CPPFLAGS $GTK_CFLAGS"
GX_LIBS="$GTK_LIBS"
fi
AC_SUBST(GX_LIBS)
CPPFLAGS="$CPPFLAGS -I$includedir -I$prefix/include"
SUPPORT_LIBS=""
dnl Test for shared memory headers and semantics, unless we are
dnl configured to build without shared memory extensions.
if test "x$enable_shm" = "xyes"; then
# Check for shared memory
AC_CHECK_HEADER(sys/ipc.h, AC_DEFINE(HAVE_IPC_H, 1, [ ]), no_sys_ipc=yes)
AC_CHECK_HEADER(sys/shm.h, AC_DEFINE(HAVE_SHM_H, 1, [ ]), no_sys_shm=yes)
if test "x$no_sys_ipc" != "xyes" \
&& test "x$no_sys_shm" != "xyes" \
&& test "x$no_xshm_ext" != "xyes" ; then
AC_DEFINE(HAVE_SHM, 1, [ ])
fi
# Check whether shmctl IPC_RMID allowes subsequent attaches
if test "$ac_cv_header_sys_shm_h" = "yes"; then
AC_MSG_CHECKING(whether shmctl IPC_RMID allowes subsequent attaches)
AC_TRY_RUN([
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
int main()
{
int id;
char *shmaddr;
id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0777);
if (id == -1)
exit (2);
shmaddr = shmat (id, 0, 0);
shmctl (id, IPC_RMID, 0);
if ((char*) shmat (id, 0, 0) == (char*) -1)
{
shmdt (shmaddr);
exit (1);
}
shmdt (shmaddr);
shmdt (shmaddr);
exit (0);
}
],
AC_DEFINE(IPC_RMID_DEFERRED_RELEASE, 1, [ ])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no),
AC_MSG_RESULT(assuming no))
fi
# Check for the X shared memory extension header file
AC_MSG_CHECKING(X11/extensions/XShm.h)
if test "x$no_xext_lib" = "xyes"; then
# If we couldn't find XShmAttach earlier, don't use the header
AC_MSG_RESULT(no)
no_xshm=yes
else
if test -f "$x_includes/X11/extensions/XShm.h"; then
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_XSHM_H, 1, [ ])
else
AC_MSG_RESULT(no)
no_xshm=yes
fi
fi
fi
dnl Test for libjpeg
AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
jpeg_ok=yes,
jpeg_ok=no
AC_MSG_ERROR(*** JPEG library not found ***), $GX_LIBS)
if test "$jpeg_ok" = yes; then
AC_MSG_CHECKING([for jpeglib.h])
AC_TRY_CPP(
[#include <stdio.h>
#undef PACKAGE
#undef VERSION
#include <jpeglib.h>],
jpeg_ok=yes,
jpeg_ok=no)
AC_MSG_RESULT($jpeg_ok)
if test "$jpeg_ok" = yes; then
JPEGLIBS="-ljpeg"
SUPPORT_LIBS="$SUPPORT_LIBS -ljpeg"; AC_DEFINE(HAVE_LIBJPEG, 1, [ ])
else
AC_MSG_ERROR(*** JPEG header file not found ***)
fi
fi
dnl Test for libtiff
AC_CHECK_LIB(tiff, TIFFReadScanline,
[AC_CHECK_HEADER(tiffio.h,
[TIFFLIBS="-ltiff"
SUPPORT_LIBS="$SUPPORT_LIBS -ltiff"; AC_DEFINE(HAVE_LIBTIFF, 1, [ ])],
[AC_MSG_ERROR(*** TIFF header files not found ***)])],
[AC_CHECK_LIB(tiff, TIFFWriteScanline,
[AC_CHECK_HEADER(tiffio.h,
[TIFFLIBS="-ltiff -ljpeg -lz"
SUPPORT_LIBS="$SUPPORT_LIBS -ltiff -ljpeg -lz"; AC_DEFINE(HAVE_LIBTIFF, 1, [ ])],
[AC_MSG_ERROR(*** TIFF header files not found ***)])],
[AC_CHECK_LIB(tiff34, TIFFFlushData,
[AC_CHECK_HEADER(tiffio.h,
[TIFFLIBS="-ltiff34 -ljpeg -lz"
SUPPORT_LIBS="$SUPPORT_LIBS -ltiff34 -ljpeg -lz"; AC_DEFINE(HAVE_LIBTIFF, 1, [ ])],
[AC_MSG_ERROR(*** TIFF header files not found ***)])],
[AC_MSG_ERROR(*** TIFF library not found ***)], -ljpeg -lz $GX_LIBS)], -ljpeg -lz $GX_LIBS)], $GX_LIBS)
AC_CHECK_HEADER(gif_lib.h,
[AC_CHECK_LIB(ungif, DGifOpenFileName,
[GIFLIBS="-lungif"
SUPPORT_LIBS="$SUPPORT_LIBS -lungif"; AC_DEFINE(HAVE_LIBGIF, 1, [ ])],
[AC_CHECK_LIB(gif, DGifOpenFileName,
[GIFLIBS="-lgif"
SUPPORT_LIBS="$SUPPORT_LIBS -lgif"
AC_DEFINE(HAVE_LIBGIF, 1, [ ])],
[AC_MSG_ERROR(*** GIF library file not found ***)],
$GX_LIBS)],
$GX_LIBS)],
[AC_MSG_ERROR(*** GIF header not found ***)])
AC_CHECK_LIB(png, png_read_info,
[AC_CHECK_HEADER(png.h,
png_ok=yes,
png_ok=no)],
[AC_MSG_ERROR(*** PNG library not found ***)], -lz -lm $GX_LIBS)
if test "$png_ok" = yes; then
AC_MSG_CHECKING([for png_structp in png.h])
AC_TRY_COMPILE([#include <png.h>],
[png_structp pp; png_infop info; png_colorp cmap; png_create_read_struct
; png_set_IHDR;],
png_ok=yes,
png_ok=no)
AC_MSG_RESULT($png_ok)
if test "$png_ok" = no; then
AC_MSG_ERROR(*** PNG library is too old ***)
fi
else
AC_MSG_ERROR(*** PNG header file not found ***)
fi
if test "$png_ok" = yes; then
PNGLIBS="-lpng -lz"
AC_SUBST(HAVE_LIBPNG)
SUPPORT_LIBS="$SUPPORT_LIBS -lpng -lz"; AC_DEFINE(HAVE_LIBPNG, 1, [ ])
fi
SUPPORT_LIBS="$SUPPORT_LIBS -lm"
GDK_SUPPORT_LIBS="$SUPPORT_LIBS"
if test $dynworks = false; then
GIFLIBS=
TIFFLIBS=
PNGLIBS=
JPEGLIBS=
else
GDK_SUPPORT_LIBS=
fi
AM_CONDITIONAL(HAVE_GIF, test "x$GIFLIBS" != x)
AM_CONDITIONAL(HAVE_TIFF, test "x$TIFFLIBS" != x)
AM_CONDITIONAL(HAVE_PNG, test "x$PNGLIBS" != x)
AM_CONDITIONAL(HAVE_JPEG, test "x$JPEGLIBS" != x)
AC_SUBST(SUPPORT_LIBS)
AC_SUBST(GDK_SUPPORT_LIBS)
AC_SUBST(CPPFLAGS)
AC_SUBST(X_CFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(X_PRE_LIBS)
AC_SUBST(X_LIBS)
AC_SUBST(X_EXTRA_LIBS)
AC_OUTPUT([
imlib.spec
gdk_imlib/Makefile
Imlib/Makefile
utils/Makefile
config/Makefile
doc/Makefile
Makefile
imlib-config
imlib.pc
imlibgdk.pc
], [
case "$CONFIG_FILES" in
*imlib-config*)
chmod +x imlib-config
;;
esac])
|