Statistics
| Revision:

root / branches / nntpgrab-0.6 / client / web / module / config.m4 @ 1640

History | View | Annotate | Download (16.3 KB)

1
# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
2
# 
3
# Copyright © 2004 Scott James Remnant .
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
#
19
# As a special exception to the GNU General Public License, if you
20
# distribute this file as part of a program that contains a
21
# configuration script generated by Autoconf, you may include it under
22
# the same distribution terms that you use for the rest of that program.
23

                
24
# PKG_PROG_PKG_CONFIG([MIN-VERSION])
25
# ----------------------------------
26
AC_DEFUN([PKG_PROG_PKG_CONFIG],
27
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
28
m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
29
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
30
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
31
 AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
32
fi
33
if test -n "$PKG_CONFIG"; then
34
 _pkg_min_version=m4_default([$1], [0.9.0])
35
 AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
36
 if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
37
         AC_MSG_RESULT([yes])
38
 else
39
         AC_MSG_RESULT([no])
40
         PKG_CONFIG=""
41
 fi
42
         
43
fi[]dnl
44
])# PKG_PROG_PKG_CONFIG
45

                
46
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
47
#
48
# Check to see whether a particular set of modules exists.  Similar
49
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
50
#
51
#
52
# Similar to PKG_CHECK_MODULES, make sure that the first instance of
53
# this or PKG_CHECK_MODULES is called, or make sure to call
54
# PKG_CHECK_EXISTS manually
55
# --------------------------------------------------------------
56
AC_DEFUN([PKG_CHECK_EXISTS],
57
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
58
if test -n "$PKG_CONFIG" && \
59
    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
60
  m4_ifval([$2], [$2], [:])
61
m4_ifvaln([$3], [else
62
  $3])dnl
63
fi])
64

                
65

                
66
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
67
# ---------------------------------------------
68
m4_define([_PKG_CONFIG],
69
[if test -n "$PKG_CONFIG"; then
70
    if test -n "$$1"; then
71
        pkg_cv_[]$1="$$1"
72
    else
73
        PKG_CHECK_EXISTS([$3],
74
                         [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
75
                  [pkg_failed=yes])
76
    fi
77
else
78
 pkg_failed=untried
79
fi[]dnl
80
])# _PKG_CONFIG
81

                
82
# _PKG_SHORT_ERRORS_SUPPORTED
83
# -----------------------------
84
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
85
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
86
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
87
        _pkg_short_errors_supported=yes
88
else
89
        _pkg_short_errors_supported=no
90
fi[]dnl
91
])# _PKG_SHORT_ERRORS_SUPPORTED
92

                
93

                
94
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
95
# [ACTION-IF-NOT-FOUND])
96
#
97
#
98
# Note that if there is a possibility the first call to
99
# PKG_CHECK_MODULES might not happen, you should be sure to include an
100
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
101
#
102
#
103
# --------------------------------------------------------------
104
AC_DEFUN([PKG_CHECK_MODULES],
105
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
106
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
107
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
108

                
109
pkg_failed=no
110
AC_MSG_CHECKING([for $1])
111

                
112
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
113
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
114

                
115
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
116
and $1[]_LIBS to avoid the need to call pkg-config.
117
See the pkg-config man page for more details.])
118

                
119
if test $pkg_failed = yes; then
120
        _PKG_SHORT_ERRORS_SUPPORTED
121
        if test $_pkg_short_errors_supported = yes; then
122
              $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
123
        else 
124
              $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
125
        fi
126
      # Put the nasty error message in config.log where it belongs
127
      echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
128

                
129
      ifelse([$4], , [AC_MSG_ERROR(dnl
130
[Package requirements ($2) were not met:
131

                
132
$$1_PKG_ERRORS
133

                
134
Consider adjusting the PKG_CONFIG_PATH environment variable if you
135
installed software in a non-standard prefix.
136

                
137
_PKG_TEXT
138
])],
139
              [AC_MSG_RESULT([no])
140
                $4])
141
elif test $pkg_failed = untried; then
142
      ifelse([$4], , [AC_MSG_FAILURE(dnl
143
[The pkg-config script could not be found or is too old.  Make sure it
144
is in your PATH or set the PKG_CONFIG environment variable to the full
145
path to pkg-config.
146

                
147
_PKG_TEXT
148

                
149
To get pkg-config, see .])],
150
              [$4])
151
else
152
      $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
153
      $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
154
        AC_MSG_RESULT([yes])
155
      ifelse([$3], , :, [$3])
156
fi[]dnl
157
])# PKG_CHECK_MODULES
158

                
159
# Configure paths for GLIB
160
# Owen Taylor     1997-2001
161

                
162
dnl AM_PATH_GLIB_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
163
dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if gmodule, gobject,
164
dnl gthread, or gio is specified in MODULES, pass to pkg-config
165
dnl
166
AC_DEFUN([AM_PATH_GLIB_2_0],
167
[dnl 
168
dnl Get the cflags and libraries from pkg-config
169
dnl
170
AC_ARG_ENABLE(glibtest, [  --disable-glibtest      do not try to compile and run a test GLIB program],
171
                  , enable_glibtest=yes)
172

                
173
  pkg_config_args=glib-2.0
174
  for module in . $4
175
  do
176
      case "$module" in
177
         gmodule) 
178
             pkg_config_args="$pkg_config_args gmodule-2.0"
179
         ;;
180
         gmodule-no-export) 
181
             pkg_config_args="$pkg_config_args gmodule-no-export-2.0"
182
         ;;
183
         gobject) 
184
             pkg_config_args="$pkg_config_args gobject-2.0"
185
         ;;
186
         gthread) 
187
             pkg_config_args="$pkg_config_args gthread-2.0"
188
         ;;
189
         gio*) 
190
             pkg_config_args="$pkg_config_args $module-2.0"
191
         ;;
192
      esac
193
  done
194

                
195
  PKG_PROG_PKG_CONFIG([0.16])
196

                
197
  no_glib=""
198

                
199
  if test "x$PKG_CONFIG" = x ; then
200
    no_glib=yes
201
    PKG_CONFIG=no
202
  fi
203

                
204
  min_glib_version=ifelse([$1], ,2.0.0,$1)
205
  AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
206

                
207
  if test x$PKG_CONFIG != xno ; then
208
    ## don't try to run the test against uninstalled libtool libs
209
    if $PKG_CONFIG --uninstalled $pkg_config_args; then
210
        echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH"
211
        enable_glibtest=no
212
    fi
213

                
214
    if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then
215
        :
216
    else
217
        no_glib=yes
218
    fi
219
  fi
220

                
221
  if test x"$no_glib" = x ; then
222
    GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
223
    GOBJECT_QUERY=`$PKG_CONFIG --variable=gobject_query glib-2.0`
224
    GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
225

                
226
    GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args`
227
    GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args`
228
    glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \
229
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
230
    glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \
231
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
232
    glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \
233
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
234
    if test "x$enable_glibtest" = "xyes" ; then
235
      ac_save_CFLAGS="$CFLAGS"
236
      ac_save_LIBS="$LIBS"
237
      CFLAGS="$CFLAGS $GLIB_CFLAGS"
238
      LIBS="$GLIB_LIBS $LIBS"
239
dnl
240
dnl Now check if the installed GLIB is sufficiently new. (Also sanity
241
dnl checks the results of pkg-config to some extent)
242
dnl
243
      rm -f conf.glibtest
244
      AC_TRY_RUN([
245
#include 
246
#include 
247
#include 
248

                
249
int 
250
main ()
251
{
252
  int major, minor, micro;
253
  char *tmp_version;
254

                
255
  system ("touch conf.glibtest");
256

                
257
  /* HP/UX 9 (%@#!) writes to sscanf strings */
258
  tmp_version = g_strdup("$min_glib_version");
259
  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
260
     printf("%s, bad version string\n", "$min_glib_version");
261
     exit(1);
262
   }
263

                
264
  if ((glib_major_version != $glib_config_major_version) ||
265
      (glib_minor_version != $glib_config_minor_version) ||
266
      (glib_micro_version != $glib_config_micro_version))
267
    {
268
      printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", 
269
             $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
270
             glib_major_version, glib_minor_version, glib_micro_version);
271
      printf ("*** was found! If pkg-config was correct, then it is best\n");
272
      printf ("*** to remove the old version of GLib. You may also be able to fix the error\n");
273
      printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
274
      printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
275
      printf("*** required on your system.\n");
276
      printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
277
      printf("*** to point to the correct configuration files\n");
278
    } 
279
  else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
280
         (glib_minor_version != GLIB_MINOR_VERSION) ||
281
           (glib_micro_version != GLIB_MICRO_VERSION))
282
    {
283
      printf("*** GLIB header files (version %d.%d.%d) do not match\n",
284
           GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
285
      printf("*** library (version %d.%d.%d)\n",
286
           glib_major_version, glib_minor_version, glib_micro_version);
287
    }
288
  else
289
    {
290
      if ((glib_major_version > major) ||
291
        ((glib_major_version == major) && (glib_minor_version > minor)) ||
292
        ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
293
      {
294
        return 0;
295
       }
296
     else
297
      {
298
        printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n",
299
               glib_major_version, glib_minor_version, glib_micro_version);
300
        printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n",
301
             major, minor, micro);
302
        printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
303
        printf("***\n");
304
        printf("*** If you have already installed a sufficiently new version, this error\n");
305
        printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
306
        printf("*** being found. The easiest way to fix this is to remove the old version\n");
307
        printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n");
308
        printf("*** correct copy of pkg-config. (In this case, you will have to\n");
309
        printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
310
        printf("*** so that the correct libraries are found at run-time))\n");
311
      }
312
    }
313
  return 1;
314
}
315
],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
316
       CFLAGS="$ac_save_CFLAGS"
317
       LIBS="$ac_save_LIBS"
318
     fi
319
  fi
320
  if test "x$no_glib" = x ; then
321
     AC_MSG_RESULT(yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version))
322
     ifelse([$2], , :, [$2])     
323
  else
324
     AC_MSG_RESULT(no)
325
     if test "$PKG_CONFIG" = "no" ; then
326
       echo "*** A new enough version of pkg-config was not found."
327
       echo "*** See https://www.freedesktop.org/software/pkgconfig/"
328
     else
329
       if test -f conf.glibtest ; then
330
        :
331
       else
332
          echo "*** Could not run GLIB test program, checking why..."
333
          ac_save_CFLAGS="$CFLAGS"
334
          ac_save_LIBS="$LIBS"
335
          CFLAGS="$CFLAGS $GLIB_CFLAGS"
336
          LIBS="$LIBS $GLIB_LIBS"
337
          AC_TRY_LINK([
338
#include 
339
#include 
340
],      [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ],
341
        [ echo "*** The test program compiled, but did not run. This usually means"
342
          echo "*** that the run-time linker is not finding GLIB or finding the wrong"
343
          echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your"
344
          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
345
          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
346
          echo "*** is required on your system"
347
        echo "***"
348
          echo "*** If you have an old version installed, it is best to remove it, although"
349
          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
350
        [ echo "*** The test program failed to compile or link. See the file config.log for the"
351
          echo "*** exact error that occured. This usually means GLIB is incorrectly installed."])
352
          CFLAGS="$ac_save_CFLAGS"
353
          LIBS="$ac_save_LIBS"
354
       fi
355
     fi
356
     GLIB_CFLAGS=""
357
     GLIB_LIBS=""
358
     GLIB_GENMARSHAL=""
359
     GOBJECT_QUERY=""
360
     GLIB_MKENUMS=""
361
     ifelse([$3], , :, [$3])
362
  fi
363
  AC_SUBST(GLIB_CFLAGS)
364
  AC_SUBST(GLIB_LIBS)
365
  AC_SUBST(GLIB_GENMARSHAL)
366
  AC_SUBST(GOBJECT_QUERY)
367
  AC_SUBST(GLIB_MKENUMS)
368
  rm -f conf.glibtest
369
])
370

                
371
PHP_ARG_ENABLE(nntpgrab, whether to enable nntpgrab support,
372
[ --enable-nntpgrab   Enable nntpgrab support])
373

                
374
if test "$PHP_NNTPGRAB" = "yes"; then
375
  AC_DEFINE(HAVE_NNTPGRAB, 1, [Whether you have nntpgrab])
376
  PHP_NEW_EXTENSION(php_nntpgrab, nntpgrab.c, $ext_shared)
377

                
378
  PHP_ADD_INCLUDE(../../../glue)
379
  PHP_ADD_INCLUDE(../../../base)
380
  PHP_ADD_INCLUDE(../../../nntpgrab_core)
381

                
382
  define(glib_required_version,  2.8.0)
383

                
384
  if test "$host_os" = "mingw32" ; then
385
    OBJDUMP=i686-pc-mingw32-objdump
386
    if test "$build_os" = "linux-gnu" -o "$build_os" = "linux-gnuaout" ; then
387
      CFLAGS="$CFLAGS -DGLIB_STATIC_COMPILATION -DGOBJECT_STATIC_COMPILATION -mms-bitfields -I/usr/i686-pc-mingw32/sys-root/mingw/include/glib-2.0 -I/usr/i686-pc-mingw32/sys-root/mingw/lib/glib-2.0/include"
388
      LDFLAGS="-no-undefined -version-info 0:0:0 -Wl,../../../base/.libs/libnntpgrab_utils.a -Wl,../../../glue/.libs/libnntpgrab_glue.a -Wl,/usr/i686-pc-mingw32/sys-root/mingw/lib/libgobject-2.0.a -Wl,/usr/i686-pc-mingw32/sys-root/mingw/lib/libgthread-2.0.a -Wl,/usr/i686-pc-mingw32/sys-root/mingw/lib/libgmodule-2.0.a -Wl,/usr/i686-pc-mingw32/sys-root/mingw/lib/libglib-2.0.a -Wl,/usr/i686-pc-mingw32/sys-root/mingw/lib/libintl.a -Wl,/usr/i686-pc-mingw32/sys-root/mingw/lib/libiconv.a -Wl,-lws2_32 -Wl,-lshlwapi -Wl,-lole32"
389
    else
390
      AM_PATH_GLIB_2_0(glib_required_version,,[AC_MSG_ERROR(NNTPGrab requires GLib glib_required_version or higher)],gobject)
391
      LDFLAGS="-no-undefined -version-info 0:0:0"
392
      PHP_ADD_LIBRARY_WITH_PATH(nntpgrab_glue, ../../../glue/.libs, PHP_NNTPGRAB_SHARED_LIBADD)
393
      PHP_ADD_LIBRARY_WITH_PATH(nntpgrab_utils, ../../../base/.libs, PHP_NNTPGRAB_SHARED_LIBADD)
394
    fi
395
    GLIB_LIBS="$GLIB_LIBS -lphp5ts"
396
  elif test "$host_os" = "darwin9.2.2" ; then
397
    AM_PATH_GLIB_2_0(glib_required_version,,[AC_MSG_ERROR(NNTPGrab requires GLib glib_required_version or higher)],gobject)
398
    LDFLAGS="-version-info 0:0:0 /opt/gtk/lib/libintl.a /opt/gtk/lib/libglib-2.0.a /opt/gtk/lib/libgobject-2.0.a /opt/gtk/lib/libgthread-2.0.a ../../../base/.libs/libnntpgrab_utils.a ../../../glue/.libs/libnntpgrab_glue.a"
399
  elif test "$host_os" = "darwin9" ; then
400
    CFLAGS="$CFLAGS -DGLIB_STATIC_COMPILATION -DGOBJECT_STATIC_COMPILATION -I/usr/darwinx/include/glib-2.0 -I/usr/darwinx/lib/glib-2.0/include"
401
    LDFLAGS="-version-info 0:0:0 /usr/darwinx/lib/libintl.dylib /usr/darwinx/lib/libglib-2.0.a /usr/darwinx/lib/libgobject-2.0.a /usr/darwinx/lib/libgthread-2.0.a ../../../base/.libs/libnntpgrab_utils.a ../../../glue/.libs/libnntpgrab_glue.a"
402
  else
403
    AM_PATH_GLIB_2_0(glib_required_version,,[AC_MSG_ERROR(NNTPGrab requires GLib glib_required_version or higher)],gobject)
404
    LDFLAGS="-no-undefined -version-info 0:0:0"
405
    PHP_ADD_LIBRARY_WITH_PATH(nntpgrab_glue, ../../../glue/.libs, PHP_NNTPGRAB_SHARED_LIBADD)
406
    PHP_ADD_LIBRARY_WITH_PATH(nntpgrab_utils, ../../../base/.libs, PHP_NNTPGRAB_SHARED_LIBADD)
407
  fi
408

                
409
  AC_SUBST(CFLAGS)
410
  AC_SUBST(LDFLAGS)
411
  PHP_EVAL_INCLINE($GLIB_CFLAGS)
412
  PHP_EVAL_LIBLINE($GLIB_LIBS, PHP_NNTPGRAB_SHARED_LIBADD)
413
  PHP_SUBST(PHP_NNTPGRAB_SHARED_LIBADD)
414
fi
415

                
416
AC_DEFINE(MAJOR_VERSION, 0, [Major version number])
417
AC_DEFINE(MINOR_VERSION, 6, [Minor version number])
418
AC_DEFINE(MICRO_VERSION, 2, [Micro version number])