1
2
3# OMAC_PATH_PERL
4# --------------
5AC_DEFUN([OMAC_PATH_PERL],
6[AC_PATH_PROG(PERL, perl)])
7
8# OMAC_PERL_EMBED_FLAGS
9# ---------------------
10AC_DEFUN([OMAC_PERL_EMBED_FLAGS],[
11	AC_REQUIRE([OMAC_PATH_PERL])
12	AC_MSG_CHECKING(for flags to compile embedded Perl)
13	perl_embed_ldflags=`$PERL -MExtUtils::Embed -e ldopts`
14	perl_embed_ccflags=`$PERL -MExtUtils::Embed -e ccopts`
15	AC_SUBST(perl_embed_ldflags)
16	AC_SUBST(perl_embed_ccflags)
17	AC_MSG_RESULT([$perl_embed_ccflags])
18])
19
20# Configure paths for SDL
21# Sam Lantinga 9/21/99
22# stolen from Manish Singh
23# stolen back from Frank Belew
24# stolen from Manish Singh
25# Shamelessly stolen from Owen Taylor
26
27dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
28dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
29dnl
30AC_DEFUN(AM_PATH_SDL,
31[dnl
32dnl Get the cflags and libraries from the sdl-config script
33dnl
34AC_ARG_WITH(sdl-prefix,[  --with-sdl-prefix=PFX   Prefix where SDL is installed (optional)],
35            sdl_prefix="$withval", sdl_prefix="")
36AC_ARG_WITH(sdl-exec-prefix,[  --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
37            sdl_exec_prefix="$withval", sdl_exec_prefix="")
38AC_ARG_ENABLE(sdltest, [  --disable-sdltest       Do not try to compile and run a test SDL program],
39		    , enable_sdltest=yes)
40
41  if test x$sdl_exec_prefix != x ; then
42     sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
43     if test x${SDL_CONFIG+set} != xset ; then
44        SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
45     fi
46  fi
47  if test x$sdl_prefix != x ; then
48     sdl_args="$sdl_args --prefix=$sdl_prefix"
49     if test x${SDL_CONFIG+set} != xset ; then
50        SDL_CONFIG=$sdl_prefix/bin/sdl-config
51     fi
52  fi
53
54  AC_REQUIRE([AC_CANONICAL_TARGET])
55  PATH="$prefix/bin:$prefix/usr/bin:$PATH"
56  AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
57  min_sdl_version=ifelse([$1], ,0.11.0,$1)
58  AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
59  no_sdl=""
60  if test "$SDL_CONFIG" = "no" ; then
61    no_sdl=yes
62  else
63    SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
64    SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
65
66    sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
67           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
68    sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
69           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
70    sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
71           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
72    if test "x$enable_sdltest" = "xyes" ; then
73      ac_save_CFLAGS="$CFLAGS"
74      ac_save_LIBS="$LIBS"
75      CFLAGS="$CFLAGS $SDL_CFLAGS"
76      LIBS="$LIBS $SDL_LIBS"
77dnl
78dnl Now check if the installed SDL is sufficiently new. (Also sanity
79dnl checks the results of sdl-config to some extent
80dnl
81      rm -f conf.sdltest
82      AC_TRY_RUN([
83#include <stdio.h>
84#include <stdlib.h>
85#include <string.h>
86#include "SDL.h"
87
88char*
89my_strdup (char *str)
90{
91  char *new_str;
92
93  if (str)
94    {
95      new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
96      strcpy (new_str, str);
97    }
98  else
99    new_str = NULL;
100
101  return new_str;
102}
103
104int main (int argc, char *argv[])
105{
106  int major, minor, micro;
107  char *tmp_version;
108
109  /* This hangs on some systems (?)
110  system ("touch conf.sdltest");
111  */
112  { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
113
114  /* HP/UX 9 (%@#!) writes to sscanf strings */
115  tmp_version = my_strdup("$min_sdl_version");
116  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
117     printf("%s, bad version string\n", "$min_sdl_version");
118     exit(1);
119   }
120
121   if (($sdl_major_version > major) ||
122      (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
123      (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
124    {
125      return 0;
126    }
127  else
128    {
129      printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
130      printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
131      printf("*** best to upgrade to the required version.\n");
132      printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
133      printf("*** to point to the correct copy of sdl-config, and remove the file\n");
134      printf("*** config.cache before re-running configure\n");
135      return 1;
136    }
137}
138
139],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
140       CFLAGS="$ac_save_CFLAGS"
141       LIBS="$ac_save_LIBS"
142     fi
143  fi
144  if test "x$no_sdl" = x ; then
145     AC_MSG_RESULT(yes)
146     ifelse([$2], , :, [$2])
147  else
148     AC_MSG_RESULT(no)
149     if test "$SDL_CONFIG" = "no" ; then
150       echo "*** The sdl-config script installed by SDL could not be found"
151       echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
152       echo "*** your path, or set the SDL_CONFIG environment variable to the"
153       echo "*** full path to sdl-config."
154     else
155       if test -f conf.sdltest ; then
156        :
157       else
158          echo "*** Could not run SDL test program, checking why..."
159          CFLAGS="$CFLAGS $SDL_CFLAGS"
160          LIBS="$LIBS $SDL_LIBS"
161          AC_TRY_LINK([
162#include <stdio.h>
163#include "SDL.h"
164
165int main(int argc, char *argv[])
166{ return 0; }
167#undef  main
168#define main K_and_R_C_main
169],      [ return 0; ],
170        [ echo "*** The test program compiled, but did not run. This usually means"
171          echo "*** that the run-time linker is not finding SDL or finding the wrong"
172          echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
173          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
174          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
175          echo "*** is required on your system"
176	  echo "***"
177          echo "*** If you have an old version installed, it is best to remove it, although"
178          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
179        [ echo "*** The test program failed to compile or link. See the file config.log for the"
180          echo "*** exact error that occured. This usually means SDL was incorrectly installed"
181          echo "*** or that you have moved SDL since it was installed. In the latter case, you"
182          echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
183          CFLAGS="$ac_save_CFLAGS"
184          LIBS="$ac_save_LIBS"
185       fi
186     fi
187     SDL_CFLAGS=""
188     SDL_LIBS=""
189     ifelse([$3], , :, [$3])
190  fi
191  AC_SUBST(SDL_CFLAGS)
192  AC_SUBST(SDL_LIBS)
193  rm -f conf.sdltest
194])
195
196
197
198# Configure paths for FreeType2
199# Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor
200
201dnl AC_CHECK_FT2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
202dnl Test for FreeType2, and define FT2_CFLAGS and FT2_LIBS
203dnl
204AC_DEFUN(AC_CHECK_FT2,
205[dnl
206dnl Get the cflags and libraries from the freetype-config script
207dnl
208AC_ARG_WITH(ft-prefix,
209[  --with-ft-prefix=PREFIX
210                          Prefix where FreeType is installed (optional)],
211            ft_config_prefix="$withval", ft_config_prefix="")
212AC_ARG_WITH(ft-exec-prefix,
213[  --with-ft-exec-prefix=PREFIX
214                          Exec prefix where FreeType is installed (optional)],
215            ft_config_exec_prefix="$withval", ft_config_exec_prefix="")
216AC_ARG_ENABLE(freetypetest,
217[  --disable-freetypetest  Do not try to compile and run
218                          a test FreeType program],
219              [], enable_fttest=yes)
220
221if test x$ft_config_exec_prefix != x ; then
222  ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix"
223  if test x${FT2_CONFIG+set} != xset ; then
224    FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config
225  fi
226fi
227if test x$ft_config_prefix != x ; then
228  ft_config_args="$ft_config_args --prefix=$ft_config_prefix"
229  if test x${FT2_CONFIG+set} != xset ; then
230    FT2_CONFIG=$ft_config_prefix/bin/freetype-config
231  fi
232fi
233AC_PATH_PROG(FT2_CONFIG, freetype-config, no)
234
235min_ft_version=ifelse([$1], ,6.1.0,$1)
236AC_MSG_CHECKING(for FreeType - version >= $min_ft_version)
237no_ft=""
238if test "$FT2_CONFIG" = "no" ; then
239  no_ft=yes
240else
241  FT2_CFLAGS=`$FT2_CONFIG $ft_config_args --cflags`
242  FT2_LIBS=`$FT2_CONFIG $ft_config_args --libs`
243  ft_config_major_version=`$FT2_CONFIG $ft_config_args --version | \
244         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
245  ft_config_minor_version=`$FT2_CONFIG $ft_config_args --version | \
246         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
247  ft_config_micro_version=`$FT2_CONFIG $ft_config_args --version | \
248         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
249  ft_min_major_version=`echo $min_ft_version | \
250         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
251  ft_min_minor_version=`echo $min_ft_version | \
252         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
253  ft_min_micro_version=`echo $min_ft_version | \
254         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
255  if test x$enable_fttest = xyes ; then
256    ft_config_is_lt=""
257    if test $ft_config_major_version -lt $ft_min_major_version ; then
258      ft_config_is_lt=yes
259    else
260      if test $ft_config_major_version -eq $ft_min_major_version ; then
261        if test $ft_config_minor_version -lt $ft_min_minor_version ; then
262          ft_config_is_lt=yes
263        else
264          if test $ft_config_minor_version -eq $ft_min_minor_version ; then
265            if test $ft_config_micro_version -lt $ft_min_micro_version ; then
266              ft_config_is_lt=yes
267            fi
268          fi
269        fi
270      fi
271    fi
272    if test x$ft_config_is_lt = xyes ; then
273      no_ft=yes
274    else
275      ac_save_CFLAGS="$CFLAGS"
276      ac_save_LIBS="$LIBS"
277      CFLAGS="$CFLAGS $FT2_CFLAGS"
278      LIBS="$FT2_LIBS $LIBS"
279dnl
280dnl Sanity checks for the results of freetype-config to some extent
281dnl
282      AC_TRY_RUN([
283#include <ft2build.h>
284#include FT_FREETYPE_H
285#include <stdio.h>
286#include <stdlib.h>
287
288int
289main()
290{
291  FT_Library library;
292  FT_Error error;
293
294  error = FT_Init_FreeType(&library);
295
296  if (error)
297    return 1;
298  else
299  {
300    FT_Done_FreeType(library);
301    return 0;
302  }
303}
304],, no_ft=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
305      CFLAGS="$ac_save_CFLAGS"
306      LIBS="$ac_save_LIBS"
307    fi             # test $ft_config_version -lt $ft_min_version
308  fi               # test x$enable_fttest = xyes
309fi                 # test "$FT2_CONFIG" = "no"
310if test x$no_ft = x ; then
311   AC_MSG_RESULT(yes)
312   ifelse([$2], , :, [$2])
313else
314   AC_MSG_RESULT(no)
315   if test "$FT2_CONFIG" = "no" ; then
316     echo "*** The freetype-config script installed by FreeType 2 could not be found."
317     echo "*** If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in"
318     echo "*** your path, or set the FT2_CONFIG environment variable to the"
319     echo "*** full path to freetype-config."
320   else
321     if test x$ft_config_is_lt = xyes ; then
322       echo "*** Your installed version of the FreeType 2 library is too old."
323       echo "*** If you have different versions of FreeType 2, make sure that"
324       echo "*** correct values for --with-ft-prefix or --with-ft-exec-prefix"
325       echo "*** are used, or set the FT2_CONFIG environment variable to the"
326       echo "*** full path to freetype-config."
327     else
328       echo "*** The FreeType test program failed to run.  If your system uses"
329       echo "*** shared libraries and they are installed outside the normal"
330       echo "*** system library path, make sure the variable LD_LIBRARY_PATH"
331       echo "*** (or whatever is appropiate for your system) is correctly set."
332     fi
333   fi
334   FT2_CFLAGS=""
335   FT2_LIBS=""
336   ifelse([$3], , :, [$3])
337fi
338AC_SUBST(FT2_CFLAGS)
339AC_SUBST(FT2_LIBS)
340])
341