aclocal.m4
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 dnl
       
     2 dnl Autoconf support for Bundle Security Protocol
       
     3 dnl
       
     4 
       
     5 AC_DEFUN(AC_CONFIG_BSP, [
       
     6     ac_bsp='no'
       
     7     AC_ARG_WITH(bsp,
       
     8         AC_HELP_STRING([--with-bsp],
       
     9     		   	[enable Bundle Security Protocol support (EXPERIMENTAL)]),
       
    10         ac_bsp=$withval)
       
    11     dnl
       
    12     dnl First make sure we even want it
       
    13     dnl
       
    14     if test "$ac_bsp" = no; then
       
    15         BSP_ENABLED=0
       
    16     else
       
    17         BSP_ENABLED=1
       
    18         AC_DEFINE_UNQUOTED(BSP_ENABLED, 1, [whether Bundle Security Protocol support is enabled])
       
    19     fi # BSP_ENABLED
       
    20 ])
       
    21 dnl
       
    22 dnl Autoconf support for external convergence layer
       
    23 dnl
       
    24 
       
    25 AC_DEFUN(AC_CONFIG_EXTERNAL_CL, [
       
    26     ac_ecl='yes'
       
    27     AC_ARG_ENABLE(ecl,
       
    28         AC_HELP_STRING([--disable-ecl],
       
    29     		   	[disable external convergence layer support]),
       
    30         ac_ecl=$enableval) 
       
    31     dnl
       
    32     dnl First make sure we even want it
       
    33     dnl
       
    34     AC_MSG_CHECKING(whether to enable external convergence layer support)
       
    35     if test "$ac_ecl" = no; then
       
    36         AC_MSG_RESULT(no)
       
    37         EXTERNAL_CL_ENABLED=0
       
    38     else
       
    39         AC_MSG_RESULT(yes)
       
    40 
       
    41         AC_OASYS_SUPPORTS(XERCES_C_ENABLED)
       
    42 	if test $ac_oasys_supports_result != yes ; then
       
    43 	    AC_MSG_ERROR([external convergence layer support requires xerces... install it or configure --disable-ecl])
       
    44 	fi
       
    45 
       
    46         EXTERNAL_CL_ENABLED=1
       
    47         AC_DEFINE_UNQUOTED(EXTERNAL_CL_ENABLED, 1, [whether external convergence layer support is enabled])
       
    48     fi # EXTERNAL_CL_ENABLED
       
    49 ])
       
    50 dnl
       
    51 dnl Autoconf support for external decision plane
       
    52 dnl
       
    53 
       
    54 AC_DEFUN(AC_CONFIG_EXTERNAL_DP, [
       
    55     ac_edp='yes'
       
    56     AC_ARG_ENABLE(edp,
       
    57         AC_HELP_STRING([--disable-edp],
       
    58     		   	[disable external decision plane support]),
       
    59         ac_edp=$enableval) 
       
    60     dnl
       
    61     dnl First make sure we even want it
       
    62     dnl
       
    63     AC_MSG_CHECKING(whether to enable external decision plane support)
       
    64     if test "$ac_edp" = no; then
       
    65         AC_MSG_RESULT(no)
       
    66         EXTERNAL_DP_ENABLED=0
       
    67     else
       
    68         AC_MSG_RESULT(yes)
       
    69 
       
    70         AC_OASYS_SUPPORTS(XERCES_C_ENABLED)
       
    71 	if test $ac_oasys_supports_result != yes ; then
       
    72 	    AC_MSG_ERROR([external decision plane support requires xerces... install it or configure --disable-edp])
       
    73 	fi
       
    74 
       
    75         AC_DEFINE_UNQUOTED(EXTERNAL_DP_ENABLED, 1, [whether external decision plane support is enabled])
       
    76     fi # EXTERNAL_DP_ENABLED
       
    77 ])
       
    78 dnl
       
    79 dnl    Copyright 2005-2006 Intel Corporation
       
    80 dnl 
       
    81 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
    82 dnl    you may not use this file except in compliance with the License.
       
    83 dnl    You may obtain a copy of the License at
       
    84 dnl 
       
    85 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
    86 dnl 
       
    87 dnl    Unless required by applicable law or agreed to in writing, software
       
    88 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
    89 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    90 dnl    See the License for the specific language governing permissions and
       
    91 dnl    limitations under the License.
       
    92 dnl
       
    93 
       
    94 
       
    95 #
       
    96 # Macro based on AC_CHECK_LIB but which takes a particular
       
    97 # LFLAGS setting as another argument to go into the cache.
       
    98 #
       
    99 
       
   100 # AC_CHECK_LIB_FLAGS(LIBRARY, FUNCTION, LDFLAGS,
       
   101 #                    [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
       
   102 #                    [OTHER-LIBRARIES])
       
   103 # ------------------------------------------------------
       
   104 #
       
   105 # Use a cache variable name containing both the library and function name,
       
   106 # because the test really is for library $1 defining function $2, not
       
   107 # just for library $1.  Separate tests with the same $1 and different $2s
       
   108 # may have different results.
       
   109 #
       
   110 # Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$2])
       
   111 # is asking for troubles, since AC_CHECK_LIB($lib, fun) would give
       
   112 # ac_cv_lib_$lib_fun, which is definitely not what was meant.  Hence
       
   113 # the AS_LITERAL_IF indirection.
       
   114 #
       
   115 # FIXME: This macro is extremely suspicious.  It DEFINEs unconditionally,
       
   116 # whatever the FUNCTION, in addition to not being a *S macro.  Note
       
   117 # that the cache does depend upon the function we are looking for.
       
   118 #
       
   119 # It is on purpose we used `ac_check_lib_save_LIBS' and not just
       
   120 # `ac_save_LIBS': there are many macros which don't want to see `LIBS'
       
   121 # changed but still want to use AC_CHECK_LIB, so they save `LIBS'.
       
   122 # And ``ac_save_LIBS' is too tempting a name, so let's leave them some
       
   123 # freedom.
       
   124 AC_DEFUN([AC_CHECK_LIB_FLAGS],
       
   125 [m4_ifval([$4], , [AH_CHECK_LIB([$1])])dnl
       
   126 AS_LITERAL_IF([$1],
       
   127               [AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$2_$3])],
       
   128               [AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1''_$2_$3])])dnl
       
   129 AC_CACHE_CHECK([for $2 in -l$1 with $3], ac_Lib,
       
   130 [ac_check_lib_save_LIBS=$LIBS
       
   131 ac_check_lib_save_LDFLAGS=$LDFLAGS
       
   132 LIBS="-l$1 $6 $LIBS"
       
   133 LDFLAGS="$3 $LDFLAGS"
       
   134 AC_LINK_IFELSE([AC_LANG_CALL([], [$2])],
       
   135                [AS_VAR_SET(ac_Lib, yes)],
       
   136                [AS_VAR_SET(ac_Lib, no)])
       
   137 LIBS=$ac_check_lib_save_LIBS
       
   138 LDFLAGS=$ac_check_lib_save_LDFLAGS])
       
   139 AS_IF([test AS_VAR_GET(ac_Lib) = yes],
       
   140       [m4_default([$4], [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
       
   141   LIBS="-l$1 $LIBS"
       
   142 ])],
       
   143       [$5])dnl
       
   144 AS_VAR_POPDEF([ac_Lib])dnl
       
   145 ])# AC_CHECK_LIB
       
   146 dnl 
       
   147 dnl Autoconf support for LTP convergence layer based on TCD's LTPLib
       
   148 dnl
       
   149 
       
   150 AC_DEFUN(AC_CONFIG_LTP, [
       
   151 
       
   152     AC_ARG_WITH(ltp,
       
   153       [AC_HELP_STRING([--with-ltp],
       
   154                       [enable LTP convergence layer support using TCD's LTPlib (EXPERIMENTAL)])],
       
   155       [ac_use_ltp=$withval],
       
   156       [ac_use_ltp="no"])
       
   157     
       
   158     AC_MSG_CHECKING([whether to enable LTP convergence layer support])
       
   159 
       
   160     dnl
       
   161     dnl Disable LTP if requested
       
   162     dnl
       
   163     if test "$ac_use_ltp" = "no"; then
       
   164         AC_MSG_RESULT(no)
       
   165         LTP_ENABLED=0
       
   166     else
       
   167 
       
   168     dnl
       
   169     dnl Find the LTPlib installation
       
   170     dnl
       
   171     if test "$ac_use_ltp" = try \
       
   172          -o "$ac_use_ltp" = yes \ 
       
   173          -o "$ac_use_ltp" = "" ; then
       
   174         AC_MSG_RESULT([try])
       
   175         ac_ltp_inst_dirs="$ac_pwd/../LTPlib /usr /usr/local"
       
   176     else
       
   177         AC_MSG_RESULT([yes (dir $ac_use_ltp)])
       
   178         ac_ltp_inst_dirs="$ac_use_ltp"
       
   179     fi
       
   180 
       
   181     ac_save_EXTLIB_CFLAGS="$EXTLIB_CFLAGS"
       
   182     ac_save_EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS"
       
   183     
       
   184     AC_MSG_CHECKING([whether ltp libraries are available])
       
   185     AC_CACHE_VAL(dtn_cv_path_ltp,
       
   186     [
       
   187         for ac_ltp_inst_dir in $ac_ltp_inst_dirs; do
       
   188             if test -d "$ac_ltp_inst_dir"; then
       
   189                 AC_LANG([C++])
       
   190                 EXTLIB_CFLAGS="-DFILE_OFFSET_BITS=64"
       
   191                 EXTLIB_LDFLAGS="-L$ac_pwd/../LTPlib/lib \
       
   192                                 -lltp -lpthread -lcrypto -lm"
       
   193     
       
   194                 AC_COMPILE_IFELSE(
       
   195                     AC_LANG_PROGRAM(
       
   196                         [
       
   197                             #include "$ac_ltp_inst_dir/include/ltp.h"
       
   198                         ],
       
   199     
       
   200                         [
       
   201                             ltpaddr la; 
       
   202                         ]),
       
   203                     [
       
   204                         dtn_cv_path_ltp="$ac_ltp_inst_dir"
       
   205                         break
       
   206                     ],
       
   207                     [
       
   208                         dtn_cv_path_ltp=
       
   209                     ]
       
   210                 )
       
   211             fi
       
   212         done
       
   213     ])
       
   214     
       
   215     EXTLIB_CFLAGS="$ac_save_EXTLIB_CFLAGS"
       
   216     EXTLIB_LDFLAGS="$ac_save_EXTLIB_LDFLAGS"
       
   217 
       
   218     if test -z "$dtn_cv_path_ltp"; then
       
   219         AC_MSG_RESULT([no])
       
   220         LTP_ENABLED=0
       
   221     else
       
   222         AC_MSG_RESULT([yes])
       
   223         LTP_ENABLED=1
       
   224         AC_DEFINE(LTP_ENABLED, 1, [whether LTP support is enabled])
       
   225         if test ! "$dtn_cv_path_ltp" = /usr && test ! "$dtn_cv_path_ltp" = /usr/local; then
       
   226             EXTLIB_CFLAGS="$EXTLIB_CFLAGS -I$dtn_cv_path_ltp/include"
       
   227             EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -L$dtn_cv_path_ltp/lib"
       
   228         fi
       
   229         EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -lltp -lpthread -lcrypto -lm"
       
   230     fi
       
   231 
       
   232     fi
       
   233 ])
       
   234 
       
   235 
       
   236 dnl 
       
   237 dnl   Copyright 2008 The MITRE Corporation
       
   238 dnl
       
   239 dnl   Licensed under the Apache License, Version 2.0 (the "License");
       
   240 dnl   you may not use this file except in compliance with the License.
       
   241 dnl   You may obtain a copy of the License at
       
   242 dnl
       
   243 dnl       http://www.apache.org/licenses/LICENSE-2.0
       
   244 dnl
       
   245 dnl   Unless required by applicable law or agreed to in writing, software
       
   246 dnl   distributed under the License is distributed on an "AS IS" BASIS,
       
   247 dnl   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
   248 dnl   See the License for the specific language governing permissions and
       
   249 dnl   limitations under the License.
       
   250 dnl
       
   251 dnl   The US Government will not be charged any license fee and/or royalties
       
   252 dnl   related to this software. Neither name of The MITRE Corporation; nor the
       
   253 dnl   names of its contributors may be used to endorse or promote products
       
   254 dnl   derived from this software without specific prior written permission.
       
   255 dnl
       
   256 
       
   257 dnl 
       
   258 dnl Autoconf support for NORM convergence layer
       
   259 dnl
       
   260 
       
   261 AC_DEFUN(AC_CONFIG_NORM, [
       
   262 
       
   263     AC_ARG_WITH(norm,
       
   264       [AC_HELP_STRING([--with-norm],
       
   265                       [enable NORM convergence layer support (EXPERIMENTAL)])],
       
   266       [ac_use_norm=$withval],
       
   267       [ac_use_norm="no"])
       
   268     
       
   269     AC_MSG_CHECKING([whether to enable NORM convergence layer support])
       
   270 
       
   271     dnl
       
   272     dnl Disable norm if requested
       
   273     dnl
       
   274     if test "$ac_use_norm" = "no"; then
       
   275         AC_MSG_RESULT(no)
       
   276         NORM_ENABLED=0
       
   277     else
       
   278 
       
   279     dnl
       
   280     dnl Find the norm installation
       
   281     dnl
       
   282     if test "$ac_use_norm" = try \
       
   283          -o "$ac_use_norm" = yes \ 
       
   284          -o "$ac_use_norm" = "" ; then
       
   285         AC_MSG_RESULT([try])
       
   286         ac_norm_inst_dirs="$ac_pwd/../norm /usr /usr/local"
       
   287     else
       
   288         AC_MSG_RESULT([yes (dir $ac_use_norm)])
       
   289         ac_norm_inst_dirs="$ac_use_norm"
       
   290     fi
       
   291 
       
   292     ac_save_EXTLIB_CFLAGS="$EXTLIB_CFLAGS"
       
   293     ac_save_EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS"
       
   294     
       
   295     AC_MSG_CHECKING([whether norm libraries are available])
       
   296     AC_CACHE_VAL(dtn_cv_path_norm,
       
   297     [
       
   298         for ac_norm_inst_dir in $ac_norm_inst_dirs; do
       
   299             if test -d "$ac_norm_inst_dir"; then
       
   300                 AC_LANG([C++])
       
   301                 EXTLIB_CFLAGS="-DFILE_OFFSET_BITS=64"
       
   302                 EXTLIB_LDFLAGS="-L$ac_pwd/../norm/build/default \
       
   303                                 -L$ac_pwd/../norm/build/default/protolib \
       
   304                                 -lnorm -lprotokit -lpthread"
       
   305     
       
   306                 AC_COMPILE_IFELSE(
       
   307                     AC_LANG_PROGRAM(
       
   308                         [
       
   309                             #include "$ac_norm_inst_dir/include/normApi.h"
       
   310                         ],
       
   311     
       
   312                         [
       
   313                             NormInstanceHandle handle = NormCreateInstance();
       
   314                             NormDestroyInstance(handle);
       
   315                         ]),
       
   316                     [
       
   317                         dtn_cv_path_norm="$ac_norm_inst_dir"
       
   318                         break
       
   319                     ],
       
   320                     [
       
   321                         dtn_cv_path_norm=
       
   322                     ]
       
   323                 )
       
   324             fi
       
   325         done
       
   326     ])
       
   327     
       
   328     EXTLIB_CFLAGS="$ac_save_EXTLIB_CFLAGS"
       
   329     EXTLIB_LDFLAGS="$ac_save_EXTLIB_LDFLAGS"
       
   330 
       
   331     if test -z "$dtn_cv_path_norm"; then
       
   332         AC_MSG_RESULT([no])
       
   333         NORM_ENABLED=0
       
   334     else
       
   335         AC_MSG_RESULT([yes])
       
   336         NORM_ENABLED=1
       
   337         AC_DEFINE(NORM_ENABLED, 1, [whether norm support is enabled])
       
   338         if test ! "$dtn_cv_path_norm" = /usr && test ! "$dtn_cv_path_norm" = /usr/local; then
       
   339             EXTLIB_CFLAGS="$EXTLIB_CFLAGS -I$dtn_cv_path_norm/include"
       
   340             EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -L$dtn_cv_path_norm/build/default -L$dtn_cv_path_norm/build/default/protolib"
       
   341         fi
       
   342         EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -lnorm -lprotokit"
       
   343     fi
       
   344 
       
   345     fi
       
   346 ])
       
   347 dnl
       
   348 dnl Autoconf support for finding OpenSSL
       
   349 dnl
       
   350 dnl
       
   351 
       
   352 AC_DEFUN(AC_CONFIG_OPENSSL, [
       
   353     if test "$ac_bsp" = yes; then
       
   354         ac_openssldir='yes'
       
   355         
       
   356         AC_ARG_WITH(openssl,
       
   357             AC_HELP_STRING([--with-openssl=DIR],
       
   358                 [location of an OpenSSL installation (default system)]),
       
   359             ac_openssldir=$withval)
       
   360         
       
   361         ac_save_CPPFLAGS="$CPPFLAGS"
       
   362         ac_save_LDFLAGS="$LDFLAGS"
       
   363         ac_save_LIBS="$LIBS"
       
   364         
       
   365         dnl
       
   366         dnl Now check if we have a cached value, unless the user specified
       
   367         dnl something explicit with the --with-openssl= argument, in
       
   368         dnl which case we force it to redo the checks (i.e. ignore the
       
   369         dnl cached values)
       
   370         dnl
       
   371         if test "$ac_openssldir" = yes -a ! x$openssl_cv_include = x ; then
       
   372             echo "checking for OpenSSL installation... (cached) $openssl_cv_include/openssl/evp.h, $openssl_cv_lib -lcrypto"
       
   373         else
       
   374             if test "$ac_openssldir" = system -o \
       
   375                     "$ac_openssldir" = yes -o \
       
   376                     "$ac_openssldir" = "" ; 
       
   377             then
       
   378                 ac_openssldir="/usr/include"
       
   379                 
       
   380                 openssl_include=$ac_openssldir
       
   381                 openssl_lib="/usr/lib"
       
   382             else
       
   383                 openssl_include=$ac_openssldir/include
       
   384                 CPPFLAGS="-I$openssl_include"
       
   385                 openssl_lib=$ac_openssldir/lib
       
   386                 LDFLAGS="-L$openssl_lib"
       
   387            fi
       
   388             
       
   389         fi
       
   390         
       
   391         AC_CHECK_HEADERS([$openssl_include/openssl/evp.h], [], [AC_MSG_FAILURE([Cannot find OpenSSL.
       
   392        On Debian-based Linux systems, you need the 'libssl-dev' package.])])
       
   393         
       
   394         AC_CHECK_LIB([crypto], [EVP_DigestInit], [], [AC_MSG_FAILURE([Cannot find OpenSSL.
       
   395        On Debian-based Linux systems, you need the 'libssl-dev' package.])])
       
   396         
       
   397         AC_CHECK_LIB([crypto], [EVP_sha256], [], [AC_MSG_FAILURE([Cannot find EVP_sha256.
       
   398        On Mac OS X systems, you probably need an updated OpenSSL package, version 0.9.8.
       
   399        Specify   --with-openssl=/path/to/openssl LDFLAGS="-Wl,-search_paths_first"])])
       
   400 
       
   401        if test "$openssl_include" != /usr/include ; then
       
   402           EXTLIB_CFLAGS="$EXTLIB_CFLAGS -I$openssl_include"
       
   403        fi
       
   404 
       
   405        if test "$openssl_lib" != /usr/lib ; then
       
   406 	   EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -L$openssl_lib"
       
   407        fi
       
   408        
       
   409        EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -lcrypto"
       
   410 
       
   411        CPPFLAGS=$ac_save_CPPFLAGS
       
   412        LDFLAGS=$ac_save_LDFLAGS
       
   413        LIBS=$ac_save_LIBS
       
   414     fi
       
   415 ])
       
   416 dnl
       
   417 dnl    Copyright 2006 Intel Corporation
       
   418 dnl 
       
   419 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
   420 dnl    you may not use this file except in compliance with the License.
       
   421 dnl    You may obtain a copy of the License at
       
   422 dnl 
       
   423 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
   424 dnl 
       
   425 dnl    Unless required by applicable law or agreed to in writing, software
       
   426 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
   427 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
   428 dnl    See the License for the specific language governing permissions and
       
   429 dnl    limitations under the License.
       
   430 dnl
       
   431 
       
   432 dnl -------------------------------------------------------------------------
       
   433 dnl Configure the options for oasys atomic functions
       
   434 dnl -------------------------------------------------------------------------
       
   435 AC_DEFUN(AC_OASYS_CONFIG_ATOMIC, [
       
   436     dnl
       
   437     dnl Handle --enable-atomic-nonatomic[=yes|no]
       
   438     dnl
       
   439     dnl
       
   440     AC_ARG_ENABLE(atomic_nonatomic,
       
   441                   AC_HELP_STRING([--enable-atomic-nonatomic],
       
   442                     [compile with non-atomic "atomic" routines (testing only)]),
       
   443                   [atomic_nonatomic=$enableval],
       
   444                   [atomic_nonatomic=no])
       
   445     
       
   446     AC_MSG_CHECKING([whether to compile with non-atomic "atomic" routines])
       
   447     AC_MSG_RESULT($atomic_nonatomic)
       
   448 
       
   449     if test $atomic_nonatomic = yes ; then
       
   450         AC_MSG_NOTICE([***])
       
   451         AC_MSG_NOTICE([*** WARNING: non-atomic "atomic" routines are for testing only ***])
       
   452         AC_MSG_NOTICE([***])
       
   453 
       
   454         AC_DEFINE_UNQUOTED(OASYS_ATOMIC_NONATOMIC, 1,
       
   455                        [whether non-atomic "atomic" routines are enabled])
       
   456     else
       
   457 
       
   458     dnl
       
   459     dnl Handle --enable-atomic-asm[=yes|no]
       
   460     dnl        --disable-atomic-asm
       
   461     dnl
       
   462     AC_ARG_ENABLE(atomic_asm,
       
   463                   AC_HELP_STRING([--disable-atomic-asm],
       
   464                          [compile without assembly-based atomic functions]),
       
   465                   [atomic_asm=$enableval],
       
   466                   [atomic_asm=yes])
       
   467     
       
   468     AC_MSG_CHECKING([whether to compile with assembly-based atomic functions])
       
   469     AC_MSG_RESULT($atomic_asm)
       
   470 
       
   471     if test $atomic_asm = no ; then
       
   472         AC_DEFINE_UNQUOTED(OASYS_ATOMIC_MUTEX, 1,
       
   473                       [whether atomic routines are implemented with a mutex])
       
   474     fi
       
   475 
       
   476     fi
       
   477 ])
       
   478 
       
   479 dnl
       
   480 dnl    Copyright 2008 Darren Long, darren.long@mac.com
       
   481 dnl    Copyright 2007 Intel Corporation
       
   482 dnl 
       
   483 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
   484 dnl    you may not use this file except in compliance with the License.
       
   485 dnl    You may obtain a copy of the License at
       
   486 dnl 
       
   487 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
   488 dnl 
       
   489 dnl    Unless required by applicable law or agreed to in writing, software
       
   490 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
   491 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
   492 dnl    See the License for the specific language governing permissions and
       
   493 dnl    limitations under the License.
       
   494 dnl
       
   495 
       
   496 dnl 
       
   497 dnl Autoconf support for configuring whether ax25 stack is 
       
   498 dnl available on the system
       
   499 dnl
       
   500 
       
   501 AC_DEFUN(AC_CONFIG_AX25, [
       
   502 
       
   503     AC_ARG_WITH(ax25,
       
   504       [AC_HELP_STRING([--with-ax25],
       
   505                       [compile in ax25 support (default try)])],
       
   506       [ac_use_ax25=$withval],
       
   507       [ac_use_ax25=try])
       
   508     
       
   509     ac_has_ax25_lib="no"
       
   510     ac_has_axconfig_h="no"
       
   511     ac_has_ax25_h="no"
       
   512     ac_has_axlib_h="no"
       
   513 
       
   514     AC_MSG_CHECKING([whether ax25 support should be enabled])
       
   515 
       
   516     if test "$ac_use_ax25" = "no"; then
       
   517         AC_MSG_RESULT(no)
       
   518 
       
   519     else
       
   520         AC_MSG_RESULT($ac_use_ax25)
       
   521 	
       
   522 	dnl look for the library and the headers
       
   523 	AC_EXTLIB_PREPARE
       
   524         AC_CHECK_HEADERS([netax25/ax25.h], ac_has_ax25_h=yes)
       
   525         AC_CHECK_HEADERS([netax25/axlib.h], ac_has_axlib_h=yes)
       
   526         AC_CHECK_HEADERS([netax25/axconfig.h], ac_has_axconfig_h=yes, [],
       
   527      	[#if HAVE_NETAX25_AX25_H
       
   528      	# include <netax25/ax25.h>
       
   529      	#endif
       
   530      	#if HAVE_NETAX25_AXLIB_H
       
   531      	# include <netax25/axlib.h>
       
   532      	#endif
       
   533      	])       
       
   534         AC_SEARCH_LIBS(ax25_config_load_ports, ax25, ac_has_ax25_lib=yes)
       
   535 	AC_EXTLIB_SAVE
       
   536 
       
   537 	dnl print the result
       
   538         AC_MSG_CHECKING([whether ax25 support was found])
       
   539         if test "$ac_has_ax25_lib" = yes -a "$ac_has_axconfig_h" = yes -a "$ac_has_ax25_h" = yes -a "$ac_has_axlib_h" = yes ; then
       
   540           AC_DEFINE(OASYS_AX25_ENABLED, 1,
       
   541               [whether ax25 support is enabled])
       
   542           AC_MSG_RESULT(yes)
       
   543 
       
   544 	elif test "$ac_use_ax25" = "try" ; then
       
   545           AC_MSG_RESULT(no)
       
   546 
       
   547         else
       
   548           AC_MSG_ERROR([can't find ax25 headers or library])
       
   549         fi
       
   550     fi
       
   551 ])
       
   552 dnl
       
   553 dnl    Copyright 2006 Intel Corporation
       
   554 dnl 
       
   555 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
   556 dnl    you may not use this file except in compliance with the License.
       
   557 dnl    You may obtain a copy of the License at
       
   558 dnl 
       
   559 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
   560 dnl 
       
   561 dnl    Unless required by applicable law or agreed to in writing, software
       
   562 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
   563 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
   564 dnl    See the License for the specific language governing permissions and
       
   565 dnl    limitations under the License.
       
   566 dnl
       
   567 
       
   568 dnl 
       
   569 dnl Autoconf support for configuring whether BlueZ bluetooth is available
       
   570 dnl on the system
       
   571 dnl
       
   572 
       
   573 AC_DEFUN(AC_CONFIG_BLUEZ, [
       
   574 
       
   575     AC_ARG_WITH(bluez,
       
   576       [AC_HELP_STRING([--with-bluez],
       
   577                       [compile in bluetooth support (default try)])],
       
   578       [ac_use_bluez=$withval],
       
   579       [ac_use_bluez=try])
       
   580     
       
   581     ac_has_libbluetooth="no"
       
   582     ac_has_bluetooth_h="no"
       
   583 
       
   584     AC_MSG_CHECKING([whether bluetooth support should be enabled])
       
   585 
       
   586     if test "$ac_use_bluez" = "no"; then
       
   587         AC_MSG_RESULT(no)
       
   588 
       
   589     else
       
   590         AC_MSG_RESULT($ac_use_bluez)
       
   591 	
       
   592         dnl
       
   593         dnl Look for the baswap() function in libbluetooth
       
   594         dnl
       
   595 	AC_EXTLIB_PREPARE
       
   596         AC_SEARCH_LIBS(baswap, bluetooth, ac_has_libbluetooth="yes") 
       
   597 	AC_EXTLIB_SAVE
       
   598 
       
   599         dnl
       
   600         dnl Locate standard Bluetooth header file
       
   601         dnl
       
   602         AC_CHECK_HEADERS([bluetooth/bluetooth.h],
       
   603           ac_has_bluetooth_h="yes")
       
   604 
       
   605         dnl
       
   606         dnl Print out whether or not we found the libraries
       
   607         dnl
       
   608         AC_MSG_CHECKING([whether bluetooth support was found])
       
   609 
       
   610         dnl
       
   611         dnl Check which defines, if any, are set
       
   612         dnl
       
   613         if test "$ac_has_libbluetooth" = yes -a "$ac_has_bluetooth_h" = yes; then
       
   614           dnl
       
   615           dnl Enable Bluetooth-dependent code
       
   616           dnl
       
   617           AC_DEFINE(OASYS_BLUETOOTH_ENABLED, 1,
       
   618               [whether bluetooth support is enabled])
       
   619           AC_MSG_RESULT(yes)
       
   620 
       
   621 	elif test "$ac_use_bluez" = "try" ; then
       
   622           AC_MSG_RESULT(no)
       
   623 
       
   624         else
       
   625           AC_MSG_ERROR([can't find bluez headers or library])
       
   626         fi
       
   627     fi
       
   628 ])
       
   629 dnl
       
   630 dnl    Copyright 2007 Intel Corporation
       
   631 dnl 
       
   632 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
   633 dnl    you may not use this file except in compliance with the License.
       
   634 dnl    You may obtain a copy of the License at
       
   635 dnl 
       
   636 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
   637 dnl 
       
   638 dnl    Unless required by applicable law or agreed to in writing, software
       
   639 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
   640 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
   641 dnl    See the License for the specific language governing permissions and
       
   642 dnl    limitations under the License.
       
   643 dnl
       
   644 
       
   645 dnl 
       
   646 dnl Autoconf support for configuring whether Apple's Bonjour stack is 
       
   647 dnl available on the system
       
   648 dnl
       
   649 AC_DEFUN(AC_BONJOUR_HELP, [
       
   650 cat <<EOF
       
   651 
       
   652 Configure error with bonjour...
       
   653 
       
   654 The default is to try to compile in bonjour support and
       
   655 if development headers and libraries are not present
       
   656 proceed. You appear to have stated '[$ac_use_bonjour]' 
       
   657 when asked whether bonjour support should be enabled
       
   658 Can't find the required development headers (dns_sd.h) or 
       
   659 function (DNSServiceRegister) in dns_sd of the Avahi 
       
   660 Apple Bonjour library. 
       
   661 
       
   662 
       
   663 If you do not want bonjour support at all, you can specify
       
   664 --without-bonjour.
       
   665 
       
   666 
       
   667 EOF
       
   668 ])
       
   669 AC_DEFUN(AC_CONFIG_BONJOUR, [
       
   670 
       
   671     AC_ARG_WITH(bonjour,
       
   672       [AC_HELP_STRING([--with-bonjour],
       
   673                       [compile in bonjour support (default try)])],
       
   674       [ac_use_bonjour=$withval],
       
   675       [ac_use_bonjour=try])
       
   676     
       
   677     ac_has_bonjour_lib="no"
       
   678     ac_has_bonjour_h="no"
       
   679 
       
   680     AC_MSG_CHECKING([whether bonjour support should be enabled])
       
   681 
       
   682 
       
   683 	if test "$ac_use_bonjour" = "no"; then
       
   684 	AC_MSG_RESULT(no)
       
   685 
       
   686 	else
       
   687 	AC_MSG_RESULT($ac_use_bonjour)
       
   688 	
       
   689 	dnl look for the library and the header
       
   690 	AC_EXTLIB_PREPARE
       
   691 	AC_MSG_CHECKING([searching for the bonjour library development headers])
       
   692         AC_CHECK_HEADERS([dns_sd.h], ac_has_bonjour_h=yes, AC_MSG_RESULT(bonjour header not found))
       
   693         AC_SEARCH_LIBS(DNSServiceRegister, dns_sd, ac_has_bonjour_lib=yes, AC_MSG_RESULT(function not found in bonjour library))
       
   694 	AC_EXTLIB_SAVE
       
   695 
       
   696 	dnl print the result
       
   697         AC_MSG_CHECKING([whether bonjour support was found])
       
   698         if test "$ac_has_bonjour_lib" = yes -a "$ac_has_bonjour_h" = yes ; then
       
   699           AC_DEFINE(OASYS_BONJOUR_ENABLED, 1,
       
   700               [whether bonjour support is enabled])
       
   701           AC_MSG_RESULT(yes)
       
   702 
       
   703 	elif test "$ac_use_bonjour" = "try" ; then
       
   704           AC_MSG_RESULT(no)
       
   705 
       
   706         else
       
   707 	AC_BONJOUR_HELP
       
   708           AC_MSG_ERROR([can't find the required development headers for the Avahi Apple Bonjour library])
       
   709         fi
       
   710     fi
       
   711 ])
       
   712 dnl
       
   713 dnl    Copyright 2005-2006 Intel Corporation
       
   714 dnl 
       
   715 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
   716 dnl    you may not use this file except in compliance with the License.
       
   717 dnl    You may obtain a copy of the License at
       
   718 dnl 
       
   719 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
   720 dnl 
       
   721 dnl    Unless required by applicable law or agreed to in writing, software
       
   722 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
   723 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
   724 dnl    See the License for the specific language governing permissions and
       
   725 dnl    limitations under the License.
       
   726 dnl
       
   727 
       
   728 dnl
       
   729 dnl Autoconf support for finding Berkeley DB
       
   730 dnl
       
   731 
       
   732 AC_DEFUN(AC_DB_HELP, [
       
   733 cat <<EOF
       
   734 
       
   735 Configure error with Berkeley DB...
       
   736 
       
   737 If you do not want Berkeley DB support at all, you can specify
       
   738 --without-db.
       
   739 
       
   740 If your installed version is not one of the following versions:
       
   741 '[$ac_dbvers]', you may have to specify the version explicitly 
       
   742 with --with-dbver=<version>.
       
   743 
       
   744 If your installation is in a non-standard path, you can specify
       
   745 the path with --with-db=DIR.
       
   746 
       
   747 To download the latest version, go to http://www.sleepycat.com
       
   748 To build and install to /usr/local/BerkeleyDB-<version>:
       
   749 
       
   750 # cd <db_download_dir>/build_unix
       
   751 # ../dist/configure
       
   752 # make
       
   753 # make install
       
   754 
       
   755 EOF
       
   756 
       
   757 ])
       
   758 
       
   759 dnl
       
   760 dnl Main macro for finding a usable db installation 
       
   761 dnl
       
   762 AC_DEFUN(AC_CONFIG_DB, [
       
   763     ac_dbvers='4.8 4.7 4.6 4.5 4.4 4.3 4.2 4.1'
       
   764     ac_dbdir='yes'
       
   765 
       
   766     AC_ARG_WITH(db,
       
   767         AC_HELP_STRING([--with-db=DIR],
       
   768     		   [location of a Berkeley DB installation (default system)]),
       
   769         ac_dbdir=$withval) 
       
   770 
       
   771     AC_ARG_WITH(dbver,
       
   772         AC_HELP_STRING([--with-dbver=VERSION],
       
   773     		   Berkeley DB versions to try (default 4.7-4.2)),
       
   774         ac_dbvers=$withval)
       
   775 
       
   776     dnl
       
   777     dnl First make sure we even want it
       
   778     dnl
       
   779     if test "$ac_dbdir" = no ; then
       
   780     LIBDB_ENABLED=0
       
   781     else
       
   782 
       
   783     LIBDB_ENABLED=1
       
   784     AC_DEFINE_UNQUOTED(LIBDB_ENABLED, 1, 
       
   785         [whether berkeley db storage support is enabled])
       
   786 
       
   787     dnl
       
   788     dnl Now check if we have a cached value, unless the user specified
       
   789     dnl something explicit with the --with-db= argument, in
       
   790     dnl which case we force it to redo the checks (i.e. ignore the
       
   791     dnl cached values)
       
   792     dnl
       
   793     if test "$ac_dbdir" = yes -a ! x$oasys_cv_db_incpath = x ; then
       
   794         echo "checking for Berkeley DB installation... (cached) -I$oasys_cv_db_incpath -L$oasys_cv_db_libpath -l$oasys_cv_db_lib"
       
   795     else
       
   796         AC_FIND_DB
       
   797     fi # no cache
       
   798  
       
   799     if test ! $oasys_cv_db_incpath = /usr/include ; then
       
   800         EXTLIB_CFLAGS="$EXTLIB_CFLAGS -I$oasys_cv_db_incpath"
       
   801     fi
       
   802 
       
   803     if test ! $oasys_cv_db_libpath = /usr/lib ; then
       
   804         EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -L$oasys_cv_db_libpath"
       
   805     fi
       
   806 
       
   807     EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -l$oasys_cv_db_lib"
       
   808 
       
   809     fi # LIBDB_ENABLED
       
   810 ])
       
   811 
       
   812 dnl
       
   813 dnl Find db
       
   814 dnl
       
   815 AC_DEFUN(AC_FIND_DB, [
       
   816     oasys_cv_db_incpath=
       
   817     oasys_cv_db_libpath=
       
   818     oasys_cv_db_lib=
       
   819 
       
   820     ac_save_CPPFLAGS="$CPPFLAGS"
       
   821     ac_save_LDFLAGS="$LDFLAGS"
       
   822     ac_save_LIBS="$LIBS"
       
   823 
       
   824     for ac_dbver in $ac_dbvers ; do
       
   825 
       
   826     ac_dbver_major=`echo $ac_dbver | cut -d . -f1`
       
   827     ac_dbver_minor=`echo $ac_dbver | cut -d . -f2`
       
   828 
       
   829     dnl
       
   830     dnl For each version, we look in /usr, /usr/local, and /usr/local/BerkeleyDB.XX
       
   831     dnl making sure that the resulting include and lib paths must match.
       
   832     dnl
       
   833     if test "$ac_dbdir" = system -o \
       
   834             "$ac_dbdir" = yes -o \
       
   835             "$ac_dbdir" = "" ; 
       
   836     then
       
   837 	ac_dbdirs="/usr /usr/local /usr/local/BerkeleyDB.$ac_dbver"
       
   838     else
       
   839 	ac_dbdirs="$ac_dbdir"
       
   840     fi
       
   841 
       
   842     for dir in $ac_dbdirs; do
       
   843         ac_dbincdirs="$dir/include"
       
   844         ac_dblibdirs="$dir/lib"
       
   845 
       
   846 	dnl
       
   847 	dnl Need to also check variations in /usr/local/include/dbXXX
       
   848 	dnl
       
   849 	if test $dir = /usr/local ; then
       
   850  	    ac_dbincdirs="$ac_dbincdirs /usr/local/include/db$ac_dbver"
       
   851  	    ac_dbincdirs="$ac_dbincdirs /usr/local/include/db$ac_dbver_major"
       
   852  	    ac_dbincdirs="$ac_dbincdirs /usr/local/include/db$ac_dbver_major$ac_dbver_minor"
       
   853 
       
   854  	    ac_dblibdirs="$ac_dblibdirs /usr/local/lib/db$ac_dbver"
       
   855  	    ac_dblibdirs="$ac_dblibdirs /usr/local/lib/db$ac_dbver_major"
       
   856  	    ac_dblibdirs="$ac_dblibdirs /usr/local/lib/db$ac_dbver_major$ac_dbver_minor"
       
   857 	fi
       
   858 
       
   859 	for ac_dbincdir in $ac_dbincdirs ; do
       
   860 
       
   861 	CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dbincdir"
       
   862 	LDFLAGS="$ac_save_LDFLAGS"
       
   863 	LIBS="$ac_save_LIBS"
       
   864 
       
   865 	dnl
       
   866 	dnl First check the version in the header file. If there's a match, 
       
   867 	dnl fall through to the other check to make sure it links.
       
   868 	dnl If not, then we can break out of the two inner loops.
       
   869 	dnl
       
   870         AC_MSG_CHECKING([for Berkeley DB header (version $ac_dbver) in $ac_dbincdir])
       
   871 	AC_LINK_IFELSE(
       
   872 	  AC_LANG_PROGRAM(
       
   873 	    [
       
   874                 #include <db.h>
       
   875            
       
   876                 #if (DB_VERSION_MAJOR != ${ac_dbver_major}) || \
       
   877                     (DB_VERSION_MINOR != ${ac_dbver_minor})
       
   878                 #error "incorrect version"
       
   879                 #endif
       
   880             ],
       
   881             
       
   882             [
       
   883             ]),
       
   884           [ 
       
   885 	      AC_MSG_RESULT([yes])
       
   886           ],
       
   887           [
       
   888               AC_MSG_RESULT([no])
       
   889 	      continue
       
   890           ])
       
   891 	
       
   892           for ac_dblibdir in $ac_dblibdirs; do
       
   893           for ac_dblib    in db-$ac_dbver; do
       
   894   
       
   895           LDFLAGS="$ac_save_LDFLAGS -L$ac_dblibdir"
       
   896           if test x"$STATIC" = x"extlibs" ; then
       
   897                   LIBS="-Wl,-Bstatic -l$ac_dblib -Wl,-Bdynamic $ac_save_LIBS"
       
   898           else
       
   899                   LIBS="-l$ac_dblib $ac_save_LIBS"
       
   900           fi
       
   901   
       
   902           AC_MSG_CHECKING([for Berkeley DB library in $ac_dblibdir, -l$ac_dblib])
       
   903           AC_LINK_IFELSE(
       
   904             AC_LANG_PROGRAM(
       
   905               [
       
   906                   #include <db.h>
       
   907               ],
       
   908               
       
   909               [
       
   910                   DB *db;
       
   911                   db_create(&db, NULL, 0);
       
   912               ]),
       
   913   
       
   914             [
       
   915                 AC_MSG_RESULT([yes])
       
   916                 oasys_cv_db_incpath=$ac_dbincdir
       
   917                 oasys_cv_db_libpath=$ac_dblibdir
       
   918                 oasys_cv_db_lib=$ac_dblib
       
   919                 break 5
       
   920             ],
       
   921             [
       
   922                 AC_MSG_RESULT([no])
       
   923             ])
       
   924 
       
   925           done # foreach ac_dblib
       
   926           done # foreach ac_dblibdir
       
   927         done # foreach ac_dbincdir
       
   928     done # foreach ac_dbdir
       
   929     done # foreach ac_dbver
       
   930 
       
   931     AC_DEFINE_UNQUOTED(BERKELEY_DB_VERSION, $ac_dbver, 
       
   932         [configured version of berkeley db])
       
   933 
       
   934     CPPFLAGS="$ac_save_CPPFLAGS"
       
   935     LDFLAGS="$ac_save_LDFLAGS"
       
   936     LIBS="$ac_save_LIBS"
       
   937 
       
   938     if test x$oasys_cv_db_incpath = x ; then
       
   939         AC_DB_HELP
       
   940         AC_MSG_ERROR([can't find usable Berkeley DB installation])
       
   941     fi
       
   942 ])
       
   943 dnl
       
   944 dnl    Copyright 2006 Intel Corporation
       
   945 dnl 
       
   946 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
   947 dnl    you may not use this file except in compliance with the License.
       
   948 dnl    You may obtain a copy of the License at
       
   949 dnl 
       
   950 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
   951 dnl 
       
   952 dnl    Unless required by applicable law or agreed to in writing, software
       
   953 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
   954 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
   955 dnl    See the License for the specific language governing permissions and
       
   956 dnl    limitations under the License.
       
   957 dnl
       
   958 
       
   959 dnl
       
   960 dnl Autoconf support for finding expat
       
   961 dnl
       
   962 
       
   963 dnl
       
   964 dnl Main macro for finding a usable db installation 
       
   965 dnl
       
   966 AC_DEFUN(AC_CONFIG_EXPAT, [
       
   967     AC_ARG_WITH(expat,
       
   968         AC_HELP_STRING([--with-expat=DIR],
       
   969     		   [location of an expat installation (default try)]),
       
   970         [ac_expatdir=$withval],
       
   971         [ac_expatdir=try])
       
   972 
       
   973     AC_MSG_CHECKING([whether expat support should be enabled])
       
   974 
       
   975     dnl
       
   976     dnl First make sure we even want it
       
   977     dnl
       
   978     if test "$ac_expatdir" = no ; then
       
   979     AC_MSG_RESULT([no])
       
   980     LIBEXPAT_ENABLED=0
       
   981     else
       
   982     
       
   983     if test "$ac_expatdir" = try ; then
       
   984        AC_MSG_RESULT([try])
       
   985     else
       
   986        AC_MSG_RESULT([yes (dir $ac_expatdir)])
       
   987     fi
       
   988     dnl
       
   989     dnl Now check if we have a cached value, unless the user specified
       
   990     dnl something explicit with the --with-expat= argument, in
       
   991     dnl which case we force it to redo the checks (i.e. ignore the
       
   992     dnl cached values)
       
   993     dnl
       
   994     if test "$ac_expatdir" = yes -a ! x$oasys_cv_path_expat_h = x ; then
       
   995         if test ! "$oasys_cv_lib_expat" = "" ; then
       
   996             echo "checking for expat installation... (cached) $oasys_cv_path_expat_h/expat.h, $oasys_cv_path_expat_lib -l$oasys_cv_lib_expat"
       
   997         else
       
   998             echo "checking for expat installation... (cached) disabled"
       
   999         fi
       
  1000     else
       
  1001         AC_FIND_EXPAT
       
  1002     fi
       
  1003 
       
  1004     if test ! "$oasys_cv_lib_expat" = "" ; then
       
  1005         LIBEXPAT_ENABLED=1
       
  1006         AC_DEFINE_UNQUOTED(LIBEXPAT_ENABLED, 1, 
       
  1007             [whether expat is enabled])
       
  1008 
       
  1009         if test ! $oasys_cv_path_expat_h = /usr/include ; then
       
  1010            EXTLIB_CFLAGS="$EXTLIB_CFLAGS -I$oasys_cv_path_expat_h"
       
  1011         fi
       
  1012 
       
  1013         if test ! $oasys_cv_path_expat_lib = /usr/lib ; then
       
  1014             EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -L$oasys_cv_path_expat_lib"
       
  1015         fi
       
  1016 
       
  1017         EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -l$oasys_cv_lib_expat"
       
  1018     else
       
  1019         LIBEXPAT_ENABLED=0
       
  1020     fi
       
  1021 
       
  1022     fi # ac_expatdir != no
       
  1023 ])
       
  1024 
       
  1025 dnl
       
  1026 dnl Find expat
       
  1027 dnl
       
  1028 AC_DEFUN(AC_FIND_EXPAT, [
       
  1029     oasys_cv_path_expat_h=
       
  1030     oasys_cv_path_expat_lib=
       
  1031     oasys_cv_lib_expat=
       
  1032 
       
  1033     ac_save_CPPFLAGS="$CPPFLAGS"
       
  1034     ac_save_LDFLAGS="$LDFLAGS"
       
  1035     ac_save_LIBS="$LIBS"
       
  1036 
       
  1037     if test "$ac_expatdir" = system -o \
       
  1038             "$ac_expatdir" = yes -o \
       
  1039             "$ac_expatdir" = try -o \
       
  1040             "$ac_expatdir" = "" ; 
       
  1041     then
       
  1042         ac_expatincdirs="/usr/include /usr/local/include"
       
  1043         ac_expatlibdirs="/usr/lib     /usr/local/lib"
       
  1044     else
       
  1045         ac_expatincdirs="$ac_expatdir/include"
       
  1046         ac_expatlibdirs="$ac_expatdir/lib"
       
  1047     fi
       
  1048 
       
  1049     for ac_expatincdir in $ac_expatincdirs; do
       
  1050     for ac_expatlibdir in $ac_expatlibdirs; do
       
  1051         ac_expatlib="expat"
       
  1052 
       
  1053 	CPPFLAGS="$ac_save_CPPFLAGS -I$ac_expatincdir"
       
  1054 	LDFLAGS="$ac_save_LDFLAGS -L$ac_expatlibdir"
       
  1055 	if test x"$STATIC" = x"extlibs" ; then
       
  1056 		LIBS="-Wl,-Bstatic -l$ac_expatlib -Wl,-Bdynamic $ac_save_LIBS"
       
  1057 	else
       
  1058 		LIBS="-l$ac_expatlib $ac_save_LIBS"
       
  1059 	fi
       
  1060 
       
  1061         AC_MSG_CHECKING([for expat in $ac_expatincdir, $ac_expatlibdir, -l$ac_expatlib])
       
  1062 	AC_LINK_IFELSE(
       
  1063 	  AC_LANG_PROGRAM(
       
  1064 	    [
       
  1065                 #include <expat.h>
       
  1066             ],
       
  1067             [
       
  1068 		XML_Parser parser;
       
  1069 		parser = XML_ParserCreate(NULL);
       
  1070             ]),
       
  1071 
       
  1072           [
       
  1073               AC_MSG_RESULT([yes])
       
  1074               oasys_cv_path_expat_h=$ac_expatincdir
       
  1075               oasys_cv_path_expat_lib=$ac_expatlibdir
       
  1076               oasys_cv_lib_expat=$ac_expatlib
       
  1077               break 4
       
  1078           ],
       
  1079           [
       
  1080               AC_MSG_RESULT([no])
       
  1081               oasys_cv_path_expat_h=
       
  1082               oasys_cv_path_expat_lib=
       
  1083               oasys_cv_lib_expat=
       
  1084           ])
       
  1085     done
       
  1086     done
       
  1087 
       
  1088     CPPFLAGS="$ac_save_CPPFLAGS"
       
  1089     LDFLAGS="$ac_save_LDFLAGS"
       
  1090     LIBS="$ac_save_LIBS"
       
  1091 
       
  1092     AC_MSG_CHECKING([whether libexpat was found])
       
  1093     if test ! x$oasys_cv_path_expat_h = x ; then
       
  1094         AC_MSG_RESULT(yes)
       
  1095     elif test $ac_expatdir = try ; then
       
  1096         AC_MSG_RESULT(no)
       
  1097     else
       
  1098         AC_MSG_ERROR([can't find usable expat installation])
       
  1099     fi
       
  1100 ])
       
  1101 dnl
       
  1102 dnl Autoconf support for external data store
       
  1103 dnl
       
  1104 
       
  1105 AC_DEFUN(AC_CONFIG_EXTERNAL_DS, [
       
  1106     ac_eds='no'
       
  1107     AC_ARG_ENABLE(eds,
       
  1108         AC_HELP_STRING([--enable-eds],
       
  1109     		   	[enable external data store support]),
       
  1110         ac_eds=$enableval) 
       
  1111     dnl
       
  1112     dnl First make sure we even want it
       
  1113     dnl
       
  1114     if test "$ac_eds" = no; then
       
  1115         EXTERNAL_DS_ENABLED=0
       
  1116     else
       
  1117         if test ! "$XERCES_C_ENABLED" = 1 ; then
       
  1118 	    AC_MSG_ERROR([external data store support requires xerces... install it or configure --disable-eds])
       
  1119         fi
       
  1120         EXTERNAL_DS_ENABLED=1
       
  1121         AC_DEFINE_UNQUOTED(EXTERNAL_DS_ENABLED, 1, [whether external data store support is enabled])
       
  1122     fi # EXTERNAL_DS_ENABLED
       
  1123 ])
       
  1124 dnl
       
  1125 dnl    Copyright 2007 Intel Corporation
       
  1126 dnl 
       
  1127 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
  1128 dnl    you may not use this file except in compliance with the License.
       
  1129 dnl    You may obtain a copy of the License at
       
  1130 dnl 
       
  1131 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
  1132 dnl 
       
  1133 dnl    Unless required by applicable law or agreed to in writing, software
       
  1134 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
  1135 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
  1136 dnl    See the License for the specific language governing permissions and
       
  1137 dnl    limitations under the License.
       
  1138 dnl
       
  1139 
       
  1140 dnl
       
  1141 dnl Helper macros to handle compilation tests on external libraries.
       
  1142 dnl
       
  1143 dnl Before configuring the library, a test should call AC_EXTLIB_PREPARE,
       
  1144 dnl then set CFLAGS, LDFLAGS, and LIBS accordingly to properly configure
       
  1145 dnl the library, and finally call AC_EXTLIB_SAVE to record the settings
       
  1146 dnl in the EXTLIB_CFLAGS and EXTLIB_LDFLAGS variables.
       
  1147 dnl
       
  1148 
       
  1149 
       
  1150 AC_DEFUN(AC_EXTLIB_PREPARE, [
       
  1151     ac_extlib_save_CFLAGS=$CFLAGS
       
  1152     ac_extlib_save_LDFLAGS=$LDFLAGS
       
  1153     ac_extlib_save_LIBS=$LIBS
       
  1154 
       
  1155     CFLAGS=
       
  1156     LDFLAGS=
       
  1157     LIBS=
       
  1158 ])
       
  1159 
       
  1160 AC_DEFUN(AC_EXTLIB_SAVE, [
       
  1161     if test ! "$CFLAGS" = "" ; then
       
  1162         EXTLIB_CFLAGS="$EXTLIB_CFLAGS $CFLAGS"
       
  1163     fi
       
  1164 
       
  1165     if test ! "$LDFLAGS" = "" ; then
       
  1166         EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS $LDFLAGS"
       
  1167     fi
       
  1168 
       
  1169     if test ! "$LIBS" = "" ; then
       
  1170         EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS $LIBS"
       
  1171     fi
       
  1172     
       
  1173     CFLAGS=$ac_extlib_save_CFLAGS
       
  1174     LDFLAGS=$ac_extlib_save_LDFLAGS
       
  1175     LIBS=$ac_extlib_save_LIBS
       
  1176 ])
       
  1177 dnl
       
  1178 dnl    Copyright 2005-2006 Intel Corporation
       
  1179 dnl 
       
  1180 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
  1181 dnl    you may not use this file except in compliance with the License.
       
  1182 dnl    You may obtain a copy of the License at
       
  1183 dnl 
       
  1184 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
  1185 dnl 
       
  1186 dnl    Unless required by applicable law or agreed to in writing, software
       
  1187 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
  1188 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
  1189 dnl    See the License for the specific language governing permissions and
       
  1190 dnl    limitations under the License.
       
  1191 dnl
       
  1192 
       
  1193 
       
  1194 dnl
       
  1195 dnl Figure out which version of gcc/g++ to use.
       
  1196 dnl
       
  1197 AC_DEFUN(AC_OASYS_CONFIG_GCC_VERSION, [
       
  1198     dnl
       
  1199     dnl Handle --with-cc=CC and --with-cxx=CXX
       
  1200     dnl
       
  1201     ac_with_cc=$CC
       
  1202     AC_ARG_WITH(cc,
       
  1203         AC_HELP_STRING([--with-cc=CC],
       
  1204     		   [name (or path) of the C compiler to use]),
       
  1205                        ac_with_cc=$withval)
       
  1206 
       
  1207     ac_with_cxx=$CXX
       
  1208     AC_ARG_WITH(cxx,
       
  1209         AC_HELP_STRING([--with-cxx=CXX],
       
  1210     		   [name (or path) of the C++ compiler to use]),
       
  1211                        ac_with_cxx=$withval)
       
  1212     
       
  1213     if test "x$ac_with_cc" = "x" ; then
       
  1214         ac_try_cc="gcc gcc-4.4 gcc-4.3 gcc-4.2 gcc-4.1 gcc-4.0 gcc-3.4 gcc-3.3"
       
  1215         ac_try_cxx="g++ g++-4.4 g++-4.3 g++-4.2 g++-4.1 g++-4.0 g++-3.4 g++-3.3"
       
  1216     else
       
  1217         ac_try_cc=$ac_with_cc
       
  1218 
       
  1219 	if test x"$ac_with_cxx" = x ; then
       
  1220             ac_try_cxx=`echo $ac_with_cc | sed 's/cc/++/'`
       
  1221 	    AC_MSG_NOTICE([inferring C++ compiler '$ac_try_cxx' from C compiler setting])
       
  1222 	else
       
  1223 	    ac_try_cxx=$ac_with_cxx
       
  1224 	fi
       
  1225 
       
  1226 	CC=$ac_try_cc
       
  1227 	CXX=$ac_try_cxx
       
  1228     fi
       
  1229 
       
  1230     dnl
       
  1231     dnl Check that the compiler specified works
       
  1232     dnl
       
  1233     AC_MSG_CHECKING([for a C compiler (trying $ac_try_cc)])
       
  1234     AC_MSG_RESULT([])
       
  1235     AC_PROG_CC($ac_try_cc)
       
  1236     
       
  1237     AC_MSG_CHECKING([for a C++ compiler (trying $ac_try_cxx)])
       
  1238     AC_MSG_RESULT([])
       
  1239     AC_PROG_CXX($ac_try_cxx)
       
  1240 
       
  1241     dnl
       
  1242     dnl Apparently AC_PROG_CXX isn't enough to actually test the c++
       
  1243     dnl compiler...
       
  1244     dnl
       
  1245     AC_MSG_CHECKING([whether the C++ compiler works])
       
  1246     AC_LANG_PUSH(C++)
       
  1247     AC_LINK_IFELSE(AC_LANG_PROGRAM([/*nothing*/],[/*nothing*/]),
       
  1248 		   AC_MSG_RESULT(yes),
       
  1249 		   AC_MSG_RESULT(no) 
       
  1250 		   AC_MSG_FAILURE(C++ compiler does not work))
       
  1251     AC_LANG_POP(C++)
       
  1252     
       
  1253     dnl 
       
  1254     dnl We want the C preprocessor as well
       
  1255     dnl    
       
  1256     AC_PROG_CPP
       
  1257 
       
  1258     dnl
       
  1259     dnl Figure out the version and set version-specific options
       
  1260     dnl
       
  1261     AC_CACHE_CHECK(for the version of the GNU C compiler, oasys_cv_prog_gccver, [
       
  1262       oasys_cv_prog_gccver=`$CC -dumpversion | cut -d. -f1-2`
       
  1263     ])      
       
  1264 
       
  1265     AC_CACHE_CHECK(for the version of the GNU C++ compiler, oasys_cv_prog_gxxver, [
       
  1266       oasys_cv_prog_gxxver=`$CXX -dumpversion | cut -d. -f1-2`
       
  1267     ])
       
  1268 
       
  1269     if test $oasys_cv_prog_gccver != $oasys_cv_prog_gxxver ; then
       
  1270         echo "*** "
       
  1271 	echo "*** warning: C compiler version $oasys_cv_prog_gccver doesn't equal"
       
  1272 	echo "***          C++ compiler version $oasys_cv_prog_gxxver"
       
  1273         echo "*** "
       
  1274     fi
       
  1275 
       
  1276     # 
       
  1277     # Set version-specific compiler options
       
  1278     #
       
  1279     case "$oasys_cv_prog_gccver" in
       
  1280         #
       
  1281         # for gcc 2.9.X and 3.1, the auto-dependency features don't work, and 
       
  1282         # _GNU_SOURCE isn't defined, so do both those things here
       
  1283         #
       
  1284         3.1*|2.9*)
       
  1285             CFLAGS="$CFLAGS -D_GNU_SOURCE"
       
  1286 	    DEPFLAGS=""
       
  1287             echo "*** "
       
  1288 	    echo "*** warning: using old compiler $cc version $oasys_cv_prog_gccver,"
       
  1289 	    echo "***          automatic dependency generation will not work"
       
  1290             echo "*** "
       
  1291 	    ;;
       
  1292 	#
       
  1293 	# For 3.2 and beyond, use auto-dependency flags. 
       
  1294 	# Note that for m4 to output a '$' requires the '@S|@' heinosity below.
       
  1295 	#
       
  1296 	3.*|4.*)
       
  1297 	    DEPFLAGS=['-MMD -MP -MT "@S|@*.o @S|@*.E"']
       
  1298 	    ;;
       
  1299 	#
       
  1300 	# Otherwise bail
       
  1301 	#
       
  1302         *)
       
  1303 	    echo "error: unsupported compiler version $oasys_cv_prog_gccver"
       
  1304 	    exit  1
       
  1305 	    ;;
       
  1306     esac
       
  1307     AC_SUBST(DEPFLAGS)
       
  1308 
       
  1309     dnl
       
  1310     dnl Look for the appropriate ar and ranlib tools for this build
       
  1311     dnl
       
  1312     AC_CHECK_TOOL(AR, ar)
       
  1313     AC_CHECK_TOOL(RANLIB, ranlib)
       
  1314 
       
  1315     if test -z "$AR" ; then
       
  1316        AC_MSG_ERROR([can't find a working ar tool])
       
  1317     fi
       
  1318 ])
       
  1319 
       
  1320 dnl
       
  1321 dnl GCC options
       
  1322 dnl
       
  1323 AC_DEFUN(AC_OASYS_CONFIG_GCC_OPTS, [
       
  1324     dnl
       
  1325     dnl Handle --enable-debug[=yes|no]
       
  1326     dnl 	   --disable-debug
       
  1327     dnl
       
  1328     AC_ARG_ENABLE(debug,
       
  1329                   AC_HELP_STRING([--disable-debug],
       
  1330                                  [compile with debugging turned off]),
       
  1331                   [debug=$enableval],
       
  1332                   [debug=yes])
       
  1333     
       
  1334     AC_MSG_CHECKING([whether to compile with debugging])
       
  1335     AC_MSG_RESULT($debug)
       
  1336     
       
  1337     DEBUG=
       
  1338     if test $debug = yes ; then 
       
  1339         DEBUG="-g -fno-inline"
       
  1340     else
       
  1341         DEBUG="-DNDEBUG"
       
  1342     fi
       
  1343     AC_SUBST(DEBUG)
       
  1344 	
       
  1345     dnl
       
  1346     dnl Handle --enable-debug-memory[=yes|no]
       
  1347     dnl 	   --disable-debug-memory
       
  1348     dnl
       
  1349     AC_ARG_ENABLE(debug_memory,
       
  1350                   AC_HELP_STRING([--enable-debug-memory],
       
  1351                                  [enable memory debugging]),
       
  1352                   [debug_memory=$enableval],
       
  1353                   [debug_memory=no])
       
  1354     
       
  1355     AC_MSG_CHECKING([whether to compile with memory debugging])
       
  1356     AC_MSG_RESULT($debug_memory)
       
  1357     
       
  1358     if test $debug_memory = yes ; then
       
  1359         AC_DEFINE_UNQUOTED(OASYS_DEBUG_MEMORY_ENABLED, 1,
       
  1360                        [whether oasys memory debugging is enabled])
       
  1361     fi
       
  1362 
       
  1363     dnl
       
  1364     dnl Handle --enable-debug-locking[=yes|no]
       
  1365     dnl --disable-debug-locking
       
  1366     dnl
       
  1367     AC_ARG_ENABLE(debug_locking,
       
  1368                   AC_HELP_STRING([--disable-debug-locking],
       
  1369                                  [disable lock debugging]),
       
  1370                   [debug_locking=$enableval],
       
  1371                   [debug_locking=$debug])
       
  1372     
       
  1373     AC_MSG_CHECKING([whether to compile with lock debugging (default $debug)])
       
  1374     AC_MSG_RESULT($debug_locking)
       
  1375     
       
  1376     if test $debug_locking = yes ; then
       
  1377         AC_DEFINE_UNQUOTED(OASYS_DEBUG_LOCKING_ENABLED, 1,
       
  1378                        [whether oasys lock debugging is enabled])
       
  1379     fi
       
  1380     
       
  1381     dnl
       
  1382     dnl Handle --enable-optimize[=yes|no]
       
  1383     dnl 	   --disable-optimize
       
  1384     dnl
       
  1385     optimize=yes
       
  1386     AC_ARG_ENABLE(optimize,
       
  1387                   AC_HELP_STRING([--disable-optimize],
       
  1388                                  [compile with optimization turned off]),
       
  1389                   [optimize=$enableval],
       
  1390                   [optimize=no])
       
  1391     
       
  1392     AC_MSG_CHECKING([whether to compile with optimization])
       
  1393     AC_MSG_RESULT($optimize)
       
  1394 
       
  1395     OPTIMIZE=
       
  1396     OPTIMIZE_WARN=
       
  1397     if test $optimize = yes ; then
       
  1398         OPTIMIZE="-O2 -fno-strict-aliasing"
       
  1399         OPTIMIZE_WARN=-Wuninitialized
       
  1400     fi
       
  1401     AC_SUBST(OPTIMIZE)
       
  1402     AC_SUBST(OPTIMIZE_WARN)
       
  1403 
       
  1404     dnl
       
  1405     dnl Handle --enable-profiling[=yes|no]
       
  1406     dnl        --disable-profiling
       
  1407     profile=
       
  1408     AC_ARG_ENABLE(profile,
       
  1409                   AC_HELP_STRING([--enable-profile],[compile with profiling]),
       
  1410                   [profile=$enableval],
       
  1411                   [profile=no])
       
  1412     
       
  1413     AC_MSG_CHECKING([whether to compile with profiling])
       
  1414     AC_MSG_RESULT($profile)
       
  1415 
       
  1416     PROFILE=
       
  1417     if test $profile = yes ; then
       
  1418         PROFILE="-pg"   
       
  1419     fi
       
  1420     AC_SUBST(PROFILE)
       
  1421 
       
  1422     dnl
       
  1423     dnl Handle --enable-static[=yes|no]
       
  1424     dnl        --enable-static-external-libs[=yes|no]
       
  1425     dnl
       
  1426     AC_ARG_ENABLE(static,
       
  1427                   AC_HELP_STRING([--enable-static],
       
  1428                                  [statically link all binaries]),
       
  1429                   [static=$enableval],
       
  1430                   [static=no])
       
  1431 
       
  1432     AC_MSG_CHECKING([whether to link statically])
       
  1433     AC_MSG_RESULT($static)
       
  1434 
       
  1435     AC_ARG_ENABLE(static-external-libs,
       
  1436                   AC_HELP_STRING([--enable-static-external-libs],
       
  1437                                  [use static external libraries]),
       
  1438                   [staticextlibs=$enableval],
       
  1439                   [staticextlibs=no])
       
  1440 
       
  1441     AC_MSG_CHECKING([whether to link using static external libraries])
       
  1442     AC_MSG_RESULT($staticextlibs)
       
  1443 
       
  1444     STATIC=no
       
  1445     if [[ $static = yes ]] ; then
       
  1446        STATIC=yes
       
  1447        LDFLAGS="$LDFLAGS -static"
       
  1448     elif [[ $staticextlibs = yes ]] ; then
       
  1449        STATIC=extlibs
       
  1450     fi
       
  1451     AC_SUBST(STATIC)
       
  1452 
       
  1453     AC_MSG_CHECKING([whether to try to build shared libraries])
       
  1454     if [[ $static = yes ]] ; then
       
  1455         AC_MSG_RESULT(no)
       
  1456     else
       
  1457 
       
  1458     dnl    
       
  1459     dnl Handle --enable-shlibs 
       
  1460     dnl
       
  1461     dnl Turns on shared library building which also builds all code 
       
  1462     dnl with -fPIC -DPIC.
       
  1463     dnl
       
  1464     AC_ARG_ENABLE(shlibs,
       
  1465                   AC_HELP_STRING([--enable-shlibs],
       
  1466                                  [enable building of shared libraries (default try)]),
       
  1467                   [shlibs=$enableval],
       
  1468                   [shlibs=yes])
       
  1469 
       
  1470     AC_MSG_RESULT($shlibs)
       
  1471 
       
  1472     SHLIBS=no
       
  1473     PICFLAGS=""
       
  1474     LDFLAGS_SHLIB=""
       
  1475     if [[ $shlibs = yes ]] ; then
       
  1476        ac_save_LDFLAGS=$LDFLAGS
       
  1477        ac_save_CFLAGS=$CFLAGS
       
  1478        picflags="-fPIC -DPIC"
       
  1479        CFLAGS="$picflags $ac_save_CFLAGS -Werror"
       
  1480        AC_MSG_CHECKING([whether the compiler supports -fPIC])
       
  1481        AC_COMPILE_IFELSE([int myfunc() {return 0;}], [pic=yes], [pic=no])
       
  1482        AC_MSG_RESULT($pic)
       
  1483 
       
  1484        if [[ $pic = yes ]] ; then
       
  1485            
       
  1486            for shopt in -shared "-dynamiclib -single_module" ; do
       
  1487              AC_MSG_CHECKING([whether the compiler can link a dynamic library with $shopt])
       
  1488 	     LDFLAGS="$shopt $ac_save_LDFLAGS"
       
  1489              AC_LINK_IFELSE([void myfunc() {}], [shlink=yes], [shlink=no])
       
  1490              AC_MSG_RESULT($shlink)
       
  1491 
       
  1492              if [[ $shlink = yes ]] ; then
       
  1493                  SHLIBS=yes
       
  1494                  PICFLAGS=$picflags
       
  1495                  LDFLAGS_SHLIB="$shopt $PICFLAGS"
       
  1496 
       
  1497 		 AC_MSG_CHECKING([extension for dynamic libraries])
       
  1498 		 dnl XXX/demmer this could be done in some better way but I don't know how
       
  1499 		 if [[ "$shopt" = "-dynamiclib -single_module" ]] ; then
       
  1500                      SHLIB_EXT=dylib
       
  1501                  elif [[ $shopt = -shared ]] ; then
       
  1502                      SHLIB_EXT=so
       
  1503                  else
       
  1504                      # shouldn't happen if above options are correctly checked
       
  1505                      AC_MSG_ERROR(internal error in configure script)
       
  1506                  fi
       
  1507 		 AC_MSG_RESULT($SHLIB_EXT)
       
  1508 
       
  1509 		 AC_MSG_CHECKING([if the compiler supports -Wl,--rpath=.])
       
  1510 		 LDFLAGS="$LDFLAGS -Wl,-rpath=/foo"
       
  1511 		 AC_LINK_IFELSE([void myfunc() {}], [rpath=yes], [rpath=no])
       
  1512 		 AC_MSG_RESULT($rpath)
       
  1513 		 if [[ $rpath = yes ]] ; then
       
  1514 		     RPATH="-Wl,-rpath=. -Wl,-rpath=\$(prefix)/lib"
       
  1515 		 fi
       
  1516                  break
       
  1517              fi
       
  1518            done
       
  1519        fi
       
  1520 
       
  1521        CFLAGS=$ac_save_CFLAGS
       
  1522        LDFLAGS=$ac_save_LDFLAGS
       
  1523     fi
       
  1524     AC_SUBST(SHLIBS)
       
  1525     AC_SUBST(SHLIB_EXT)
       
  1526     AC_SUBST(PICFLAGS)
       
  1527     AC_SUBST(RPATH)
       
  1528     AC_SUBST(LDFLAGS_SHLIB)
       
  1529 
       
  1530     fi # ! $static = yes
       
  1531 
       
  1532     dnl
       
  1533     dnl Add options to add extra compilation flags
       
  1534     dnl
       
  1535     EXTRA_CFLAGS=""
       
  1536     AC_ARG_WITH(extra-cflags,
       
  1537         AC_HELP_STRING([--with-extra-cflags=?],
       
  1538 	 	       [additional options to pass to the compiler]),
       
  1539                        EXTRA_CFLAGS=$withval)
       
  1540     AC_SUBST(EXTRA_CFLAGS)
       
  1541 
       
  1542     EXTRA_LDFLAGS=""
       
  1543     AC_ARG_WITH(extra-ldflags,
       
  1544         AC_HELP_STRING([--with-extra-ldflags=?],
       
  1545 	 	       [additional options to pass to the linker]),
       
  1546                        EXTRA_LDFLAGS=$withval)
       
  1547     AC_SUBST(EXTRA_LDFLAGS)
       
  1548 ])
       
  1549 
       
  1550 dnl
       
  1551 dnl Configure gcc
       
  1552 dnl
       
  1553 AC_DEFUN(AC_OASYS_CONFIG_GCC, [
       
  1554     dnl
       
  1555     dnl Handle the various autoconf options for cross compilation that 
       
  1556     dnl set either --target or (better?) both --build and --host.
       
  1557     dnl
       
  1558     if test ! -z "$host_alias" ; then
       
  1559         TARGET=$host_alias
       
  1560     elif test ! -z "$target_alias" ; then
       
  1561         TARGET=$target_alias
       
  1562     elif test ! -z "$target" ; then
       
  1563         TARGET=$target
       
  1564     else
       
  1565         TARGET=native
       
  1566     fi
       
  1567     AC_SUBST(TARGET)
       
  1568 
       
  1569     AC_OASYS_CONFIG_GCC_VERSION
       
  1570     AC_OASYS_CONFIG_GCC_OPTS
       
  1571 
       
  1572     dnl
       
  1573     dnl Set the build system in a variable so it's usable by
       
  1574     dnl Makefiles and other scripts
       
  1575     dnl
       
  1576     BUILD_SYSTEM=`uname -s || echo UNKNOWN | sed 's/CYGWIN.*/CYGWIN/'`
       
  1577     AC_SUBST(BUILD_SYSTEM)
       
  1578 ])
       
  1579 dnl
       
  1580 dnl    Copyright 2005-2006 Intel Corporation
       
  1581 dnl 
       
  1582 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
  1583 dnl    you may not use this file except in compliance with the License.
       
  1584 dnl    You may obtain a copy of the License at
       
  1585 dnl 
       
  1586 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
  1587 dnl 
       
  1588 dnl    Unless required by applicable law or agreed to in writing, software
       
  1589 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
  1590 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
  1591 dnl    See the License for the specific language governing permissions and
       
  1592 dnl    limitations under the License.
       
  1593 dnl
       
  1594 
       
  1595 dnl
       
  1596 dnl Autoconf support for linking with google's performace code
       
  1597 dnl
       
  1598 
       
  1599 AC_DEFUN(AC_CONFIG_GOOGLE_PERFTOOLS, [
       
  1600 
       
  1601     ac_google_perfdir='no'
       
  1602     AC_ARG_WITH(google-perftools,
       
  1603         AC_HELP_STRING([--with-google-perftools=DIR],
       
  1604             [location of a google perftools installation (default none)]),
       
  1605         ac_google_perfdir=$withval) 
       
  1606 
       
  1607     AC_ARG_ENABLE(google-profiling,
       
  1608                   AC_HELP_STRING([--enable-google-profiling],
       
  1609 		  [compile with google profiling]),
       
  1610                   [google_profile=$enableval],
       
  1611                   [google_profile=no])
       
  1612     
       
  1613     AC_MSG_CHECKING([whether to compile with google profiling])
       
  1614     AC_MSG_RESULT($google_profile)
       
  1615 
       
  1616     GOOGLE_PROFILE_ENABLED=0
       
  1617     if test $google_profile = yes ; then
       
  1618         if test $ac_google_perfdir = no ; then
       
  1619 	   AC_MSG_ERROR([must specify --with-google-perftools to use google profiling])
       
  1620 	fi
       
  1621         GOOGLE_PROFILE_ENABLED=1
       
  1622     fi
       
  1623     
       
  1624     AC_DEFINE_UNQUOTED(GOOGLE_PROFILE_ENABLED, $GOOGLE_PROFILE_ENABLED,
       
  1625 	 [whether google profiling support is enabled])
       
  1626 
       
  1627     dnl
       
  1628     dnl First make sure we even want it
       
  1629     dnl
       
  1630     if test "$ac_google_perfdir" = no; then
       
  1631     GOOGLE_PERFTOOLS_ENABLED=0
       
  1632     else
       
  1633 
       
  1634     GOOGLE_PERFTOOLS_ENABLED=1
       
  1635     AC_DEFINE_UNQUOTED(GOOGLE_PERFTOOLS_ENABLED, 1, 
       
  1636 	 [whether google perftools support is enabled])
       
  1637 
       
  1638     dnl
       
  1639     dnl Now check if we have a cached value, unless the user specified
       
  1640     dnl something explicit with the --with-google-perf= argument, in
       
  1641     dnl which case we force it to redo the checks (i.e. ignore the
       
  1642     dnl cached values)
       
  1643     dnl
       
  1644     if test "$ac_google_perfdir" = yes -a \
       
  1645 	    ! "$oasys_cv_path_google_perf_h" = "" ; then
       
  1646         echo "checking for google_perf installation... (cached)"
       
  1647     else
       
  1648         AC_OASYS_FIND_GOOGLE_PERFTOOLS
       
  1649     fi
       
  1650 
       
  1651     if test ! $oasys_cv_path_google_perf_h = /usr/include ; then
       
  1652         EXTLIB_CFLAGS="$EXTLIB_CFLAGS -I$oasys_cv_path_google_perf_h"
       
  1653     fi
       
  1654 
       
  1655     if test ! $oasys_cv_path_google_perf_lib = /usr/lib ; then
       
  1656         EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -L$oasys_cv_path_google_perf_lib"
       
  1657     fi
       
  1658     
       
  1659     EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -Wl,-Bstatic -lprofiler -Wl,-Bdynamic"
       
  1660     
       
  1661     fi # GOOGLE_PERF_ENABLED
       
  1662 ])
       
  1663 
       
  1664 AC_DEFUN(AC_OASYS_FIND_GOOGLE_PERFTOOLS, [
       
  1665     oasys_cv_path_google_perf_h=
       
  1666     oasys_cv_path_google_perf_lib=
       
  1667 
       
  1668     ac_save_CPPFLAGS="$CPPFLAGS"
       
  1669     ac_save_LDFLAGS="$LDFLAGS"
       
  1670     ac_save_LIBS="$LIBS"
       
  1671 
       
  1672     AC_LANG_PUSH(C++)
       
  1673 
       
  1674     if test "$ac_google_perfdir" = system -o \
       
  1675             "$ac_google_perfdir" = yes -o \
       
  1676             "$ac_google_perfdir" = "" ; 
       
  1677     then
       
  1678         ac_google_perfincdirs="/usr/local/include \
       
  1679 	                       /usr/local/google-perftools/include"
       
  1680         ac_google_perflibdirs="/usr/local/lib \
       
  1681 	                       /usr/local/google-perftools/lib"
       
  1682     else
       
  1683         ac_google_perfincdirs="$ac_google_perfdir/include"
       
  1684         ac_google_perflibdirs="$ac_google_perfdir/lib"
       
  1685     fi
       
  1686 
       
  1687     for ac_google_perfincdir in $ac_google_perfincdirs; do
       
  1688 
       
  1689 	CPPFLAGS="$ac_save_CPPFLAGS -I$ac_google_perfincdir"
       
  1690 	LDFLAGS="$ac_save_LDFLAGS"
       
  1691 	LIBS="$ac_save_LIBS"
       
  1692 
       
  1693 	dnl
       
  1694 	dnl First check the version in the header file. If there's a match, 
       
  1695 	dnl fall through to the other check to make sure it links.
       
  1696 	dnl If not, then we can break out of the two inner loops.
       
  1697 	dnl
       
  1698         AC_MSG_CHECKING([for google perftools header profiler.h in $ac_google_perfincdir])
       
  1699 	AC_LINK_IFELSE(
       
  1700 	  AC_LANG_PROGRAM(
       
  1701 	    [
       
  1702                 #include <google/profiler.h>
       
  1703             ],
       
  1704             
       
  1705             [
       
  1706             ]),
       
  1707           [ 
       
  1708 	      AC_MSG_RESULT([yes])
       
  1709               oasys_cv_path_google_perf_h=$ac_google_perfincdir
       
  1710 	      break
       
  1711           ],
       
  1712           [
       
  1713               AC_MSG_RESULT([no])
       
  1714 	      continue
       
  1715           ])
       
  1716     done
       
  1717 
       
  1718     AC_LANG_POP(C++)
       
  1719 
       
  1720     if test x$oasys_cv_path_google_perf_h = x ; then
       
  1721         AC_MSG_ERROR([can't find usable google perftools installation])
       
  1722     fi
       
  1723 
       
  1724     AC_LANG_PUSH(C++)
       
  1725 
       
  1726     for ac_google_perflibdir in $ac_google_perflibdirs; do
       
  1727 
       
  1728 	LDFLAGS="$ac_save_LDFLAGS -L$ac_google_perflibdir"
       
  1729         LIBS="$ac_save_LIBS -lprofiler"
       
  1730 
       
  1731         AC_MSG_CHECKING([for google perftolos library libprofiler in $ac_google_perflibdir])
       
  1732 	AC_LINK_IFELSE(
       
  1733 	  AC_LANG_PROGRAM(
       
  1734 	    [
       
  1735                 #include <google/profiler.h>
       
  1736             ],
       
  1737             
       
  1738             [
       
  1739 		ProfilerStart("test");
       
  1740             ]),
       
  1741 
       
  1742           [
       
  1743               AC_MSG_RESULT([yes])
       
  1744               oasys_cv_path_google_perf_lib=$ac_google_perflibdir
       
  1745               break
       
  1746           ],
       
  1747           [
       
  1748               AC_MSG_RESULT([no])
       
  1749           ])
       
  1750     done
       
  1751 
       
  1752     CPPFLAGS="$ac_save_CPPFLAGS"
       
  1753     LDFLAGS="$ac_save_LDFLAGS"
       
  1754     LIBS="$ac_save_LIBS"
       
  1755 
       
  1756     AC_LANG_POP(C++)
       
  1757 
       
  1758     if test x$oasys_cv_path_google_perf_lib = x ; then
       
  1759         AC_MSG_ERROR([can't find usable google perftools library])
       
  1760     fi
       
  1761 ])
       
  1762 dnl
       
  1763 dnl    Copyright 2005-2006 Intel Corporation
       
  1764 dnl 
       
  1765 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
  1766 dnl    you may not use this file except in compliance with the License.
       
  1767 dnl    You may obtain a copy of the License at
       
  1768 dnl 
       
  1769 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
  1770 dnl 
       
  1771 dnl    Unless required by applicable law or agreed to in writing, software
       
  1772 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
  1773 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
  1774 dnl    See the License for the specific language governing permissions and
       
  1775 dnl    limitations under the License.
       
  1776 dnl
       
  1777 
       
  1778 dnl
       
  1779 dnl Autoconf support for finding mysql
       
  1780 dnl
       
  1781 
       
  1782 dnl
       
  1783 dnl Main macro for finding a usable mysql installation 
       
  1784 dnl
       
  1785 AC_DEFUN(AC_CONFIG_MYSQL, [
       
  1786     ac_mysqldir='no'
       
  1787 
       
  1788     AC_ARG_WITH(mysql,
       
  1789         AC_HELP_STRING([--with-mysql=DIR],
       
  1790     		   [location of a mysql installation (default none)]),
       
  1791         ac_mysqldir=$withval) 
       
  1792 
       
  1793     ac_mysqldaemon='no'
       
  1794     AC_ARG_WITH(mysql-daemon,
       
  1795         AC_HELP_STRING([--with-mysql-daemon],
       
  1796     		   [use the daemon library (not the client library)]),
       
  1797         ac_mysqldaemon=$withval)
       
  1798 
       
  1799     dnl
       
  1800     dnl First make sure we even want it
       
  1801     dnl
       
  1802     if test "$ac_mysqldir" = no; then
       
  1803     MYSQL_ENABLED=0
       
  1804     else
       
  1805 
       
  1806     MYSQL_ENABLED=1
       
  1807     AC_DEFINE_UNQUOTED(MYSQL_ENABLED, 1, [whether mysql support is enabled])
       
  1808 
       
  1809     dnl
       
  1810     dnl If the user wants to use the embedded libmysqld, then we have
       
  1811     dnl some additional external library dependencies
       
  1812     dnl    
       
  1813     if test ! "$ac_mysqldaemon" = "no" ; then
       
  1814        AC_DEFINE_UNQUOTED(LIBMYSQLD_ENABLED, 1, 
       
  1815            [whether the mysql embedded server is enabled])
       
  1816 
       
  1817 	AC_MSG_CHECKING([for mysql external dependencies.: checking for request_init() in libwrap])
       
  1818 	AC_SEARCH_LIBS(request_init, wrap, [], 
       
  1819                       AC_MSG_ERROR([can't find request_init() in libwrap]))
       
  1820 	AC_MSG_CHECKING([for mysql external dependencies.: checking for exp() in libm])
       
  1821 	AC_SEARCH_LIBS(exp, m, [],
       
  1822                       AC_MSG_ERROR([can't find exp() in libm]))
       
  1823 	AC_MSG_CHECKING([for mysql external dependencies.: checking for crypt() in libcrypt])
       
  1824 	AC_SEARCH_LIBS(crypt, crypt, [],
       
  1825                       AC_MSG_ERROR([can't find crypt() in libcrypt]))
       
  1826 	AC_MSG_CHECKING([for mysql external dependencies.: checking for compress() in libz])
       
  1827 	AC_SEARCH_LIBS(compress, z, [],
       
  1828                       AC_MSG_ERROR([can't find compress() in libz]))
       
  1829     fi
       
  1830 
       
  1831     dnl
       
  1832     dnl Now check if we have a cached value, unless the user specified
       
  1833     dnl something explicit with the --with-mysql= argument, in
       
  1834     dnl which case we force it to redo the checks (i.e. ignore the
       
  1835     dnl cached values)
       
  1836     dnl
       
  1837     if test "$ac_mysqldir" = yes -a ! x$oasys_cv_path_mysql_h = x ; then
       
  1838         echo "checking for mysql installation... (cached) $oasys_cv_path_mysql_h/mysql.h, $oasys_cv_path_mysql_lib -lmysql"
       
  1839     else
       
  1840         AC_OASYS_FIND_MYSQL
       
  1841     fi
       
  1842 
       
  1843     if test ! $oasys_cv_path_mysql_h = /usr/include ; then
       
  1844         EXTLIB_CFLAGS="$EXTLIB_CFLAGS -I$oasys_cv_path_mysql_h"
       
  1845     fi
       
  1846 
       
  1847     if test ! $oasys_cv_path_mysql_lib = /usr/lib ; then
       
  1848         EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -L$oasys_cv_path_mysql_lib"
       
  1849     fi
       
  1850 
       
  1851     if test "$ac_mysqldaemon" = "no" ; then
       
  1852         EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -lmysqlclient"
       
  1853     else
       
  1854         EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -lmysqld"
       
  1855     fi
       
  1856     
       
  1857     fi # MYSQL_ENABLED
       
  1858 ])
       
  1859 
       
  1860 dnl
       
  1861 dnl Find mysql
       
  1862 dnl
       
  1863 AC_DEFUN(AC_OASYS_FIND_MYSQL, [
       
  1864     oasys_cv_path_mysql_h=
       
  1865     oasys_cv_path_mysql_lib=
       
  1866 
       
  1867     ac_save_CPPFLAGS="$CPPFLAGS"
       
  1868     ac_save_LDFLAGS="$LDFLAGS"
       
  1869     ac_save_LIBS="$LIBS"
       
  1870 
       
  1871     if test "$ac_mysqldir" = system -o \
       
  1872             "$ac_mysqldir" = yes -o \
       
  1873             "$ac_mysqldir" = "" ; 
       
  1874     then
       
  1875         ac_mysqlincdirs="/usr/include /usr/include/mysql \
       
  1876                          /usr/local/mysql/include"
       
  1877         ac_mysqllibdirs="/usr/lib /usr/lib/mysql /usr/local/mysql/lib"
       
  1878     else
       
  1879         ac_mysqlincdirs="$ac_mysqldir/include"
       
  1880         ac_mysqllibdirs="$ac_mysqldir/lib"
       
  1881     fi
       
  1882 
       
  1883     AC_LANG_PUSH(C++)
       
  1884     for ac_mysqlincdir in $ac_mysqlincdirs; do
       
  1885 
       
  1886 	CPPFLAGS="$ac_save_CPPFLAGS -I$ac_mysqlincdir"
       
  1887 	LDFLAGS="$ac_save_LDFLAGS"
       
  1888 	LIBS="$ac_save_LIBS"
       
  1889 
       
  1890 	dnl
       
  1891 	dnl First check the version in the header file. If there's a match, 
       
  1892 	dnl fall through to the other check to make sure it links.
       
  1893 	dnl If not, then we can break out of the two inner loops.
       
  1894 	dnl
       
  1895         AC_MSG_CHECKING([for mysql header mysql.h in $ac_mysqlincdir])
       
  1896 	AC_LINK_IFELSE(
       
  1897 	  AC_LANG_PROGRAM(
       
  1898 	    [
       
  1899                 #include <mysql.h>
       
  1900             ],
       
  1901             
       
  1902             [
       
  1903             ]),
       
  1904           [ 
       
  1905 	      AC_MSG_RESULT([yes])
       
  1906               oasys_cv_path_mysql_h=$ac_mysqlincdir
       
  1907 	      break
       
  1908           ],
       
  1909           [
       
  1910               AC_MSG_RESULT([no])
       
  1911 	      continue
       
  1912           ])
       
  1913     done
       
  1914 
       
  1915     if test x$oasys_cv_path_mysql_h = x ; then
       
  1916         AC_MSG_ERROR([can't find usable mysql installation])
       
  1917     fi
       
  1918 
       
  1919     for ac_mysqllibdir in $ac_mysqllibdirs; do
       
  1920 
       
  1921 	LDFLAGS="$ac_save_LDFLAGS -L$ac_mysqllibdir"
       
  1922 	if test "$ac_mysqldaemon" = "no" ; then
       
  1923  	    LIBS="$ac_save_LIBS -lmysqlclient"
       
  1924         else
       
  1925  	    LIBS="$ac_save_LIBS -lmysqld"
       
  1926         fi
       
  1927 
       
  1928         AC_MSG_CHECKING([for mysql library libmysql in $ac_mysqllibdir])
       
  1929 	AC_LINK_IFELSE(
       
  1930 	  AC_LANG_PROGRAM(
       
  1931 	    [
       
  1932                 #include <mysql.h>
       
  1933             ],
       
  1934             
       
  1935             [
       
  1936 		MYSQL m;
       
  1937 	        mysql_init(&m);
       
  1938             ]),
       
  1939 
       
  1940           [
       
  1941               AC_MSG_RESULT([yes])
       
  1942               oasys_cv_path_mysql_lib=$ac_mysqllibdir
       
  1943               break
       
  1944           ],
       
  1945           [
       
  1946               AC_MSG_RESULT([no])
       
  1947           ])
       
  1948     done
       
  1949     AC_LANG_POP(C++)
       
  1950 
       
  1951     CPPFLAGS="$ac_save_CPPFLAGS"
       
  1952     LDFLAGS="$ac_save_LDFLAGS"
       
  1953     LIBS="$ac_save_LIBS"
       
  1954 
       
  1955     if test x$oasys_cv_path_mysql_lib = x ; then
       
  1956         AC_MSG_ERROR([can't find usable mysql library])
       
  1957     fi
       
  1958 ])
       
  1959 
       
  1960 dnl
       
  1961 dnl Check if oasys has support for the given feature. Returns result
       
  1962 dnl in ac_oasys_supports_result.
       
  1963 dnl
       
  1964 AC_DEFUN(AC_OASYS_SUPPORTS, [
       
  1965     AC_MSG_CHECKING(whether oasys is configured with $1)
       
  1966 
       
  1967     if test x$cv_oasys_supports_$1 != x ; then
       
  1968         ac_oasys_supports_result=$cv_oasys_supports_$1
       
  1969         AC_MSG_RESULT($ac_oasys_supports_result (cached))
       
  1970     else
       
  1971 
       
  1972     ac_save_CPPFLAGS="$CPPFLAGS"
       
  1973     CPPFLAGS="$CPPFLAGS -I$OASYS_INCDIR"
       
  1974     AC_LINK_IFELSE(
       
  1975       AC_LANG_PROGRAM(
       
  1976         [
       
  1977             #include <oasys/oasys-config.h>
       
  1978             #ifndef $1
       
  1979             #error $1 not configured
       
  1980             #endif
       
  1981         ], [] ),
       
  1982       ac_oasys_supports_result=yes,
       
  1983       ac_oasys_supports_result=no)
       
  1984 
       
  1985     cv_oasys_supports_$1=$ac_oasys_supports_result
       
  1986     
       
  1987     AC_MSG_RESULT([$ac_oasys_supports_result])
       
  1988     CPPFLAGS=$ac_save_CPPFLAGS
       
  1989 
       
  1990     fi
       
  1991 ])
       
  1992 dnl
       
  1993 dnl    Copyright 2007 Intel Corporation
       
  1994 dnl 
       
  1995 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
  1996 dnl    you may not use this file except in compliance with the License.
       
  1997 dnl    You may obtain a copy of the License at
       
  1998 dnl 
       
  1999 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
  2000 dnl 
       
  2001 dnl    Unless required by applicable law or agreed to in writing, software
       
  2002 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
  2003 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
  2004 dnl    See the License for the specific language governing permissions and
       
  2005 dnl    limitations under the License.
       
  2006 dnl
       
  2007 
       
  2008 dnl 
       
  2009 dnl Autoconf support for configuring an external package to use oasys
       
  2010 dnl itself.
       
  2011 dnl
       
  2012 
       
  2013 AC_DEFUN(AC_OASYS_CONFIG_HELP, [
       
  2014 cat <<EOF
       
  2015     
       
  2016 Configure error finding oasys.
       
  2017 
       
  2018 This script first looks for an oasys installation in the same location
       
  2019 as the tool that is using the oasys library (where this configure
       
  2020 script is run from). In other words, it first tries ../oasys.
       
  2021 
       
  2022 If ../oasys does not exist, it looks for an oasys installation in
       
  2023 /usr. If that is not found, you need to specify the location of oasys
       
  2024 using the --with-oasys argument to configure.
       
  2025 
       
  2026 If problems still exist, then look in the config.log to see exactly
       
  2027 what the failing command was.
       
  2028 
       
  2029 Download oasys-$ac_oasysver_major.$ac_oasysver_minor (or later) 
       
  2030 from http://dtn.hg.sourceforge.net/hgweb/dtn/oasys to $ac_oasysdir. 
       
  2031 You will then probably have to run ./configure and make  
       
  2032 in the oasys code tree in order to be able to compile DTN2
       
  2033 
       
  2034 EOF
       
  2035 
       
  2036 ])
       
  2037 
       
  2038 dnl
       
  2039 dnl AC_OASYS_CONFIG [major] [minor]
       
  2040 dnl
       
  2041 AC_DEFUN(AC_OASYS_CONFIG, [
       
  2042     rm -rf oasys
       
  2043 
       
  2044     ac_oasysver_major=$1
       
  2045     ac_oasysver_minor=$2
       
  2046     ac_oasysdir_ver_base="oasys-$ac_oasysver_major.$ac_oasysver_minor"
       
  2047     ac_oasysdir=
       
  2048 
       
  2049     AC_ARG_WITH(oasys,
       
  2050         AC_HELP_STRING([--with-oasys=DIR],
       
  2051     		   [location of an oasys installation (default ../oasys-<major>.<minor>.* or ../oasys or /usr)]),
       
  2052         ac_oasysdir=$withval)
       
  2053 
       
  2054     AC_MSG_CHECKING([for an oasys installation (version $ac_oasysver_major.$ac_oasysver_minor or better)])
       
  2055 
       
  2056     ac_oasysdir_ver=`find .. -maxdepth 1 -type d -name $ac_oasysdir_ver_base.* | tail -1`
       
  2057     if test "$ac_oasysdir" = "" ; then
       
  2058 	if test -d "$ac_oasysdir_ver" ; then
       
  2059 	    ac_oasysdir=$ac_oasysdir_ver
       
  2060 	elif test -d ../oasys ; then
       
  2061 	    ac_oasysdir=../oasys
       
  2062 
       
  2063 	else
       
  2064 	    ac_oasysdir=/usr
       
  2065 	    # Set the oasys paths properly. OASYS_INCDIR points to the parent
       
  2066 	    # directory containing the oasys header files or the source
       
  2067 	    # directory itself with a symlink (include/oasys -> .),
       
  2068 	    # OASYS_LIBDIR points to the directory where the libraries are.
       
  2069 	    # OASYS_ETCDIR points to where the various scripts are.
       
  2070 	    #
       
  2071 	    OASYS_INCDIR="$ac_oasysdir/include"
       
  2072 	    OASYS_LIBDIR="$ac_oasysdir/lib"
       
  2073 	    OASYS_ETCDIR="$ac_oasysdir/share/oasys"
       
  2074 	fi
       
  2075     	if test -d oasys ; then
       
  2076 	    	rm -rf oasys
       
  2077 	fi
       
  2078 	    mkdir oasys oasys/include
       
  2079 	    OASYS_INCDIR="oasys/include"
       
  2080 	    OASYS_LIBDIR="oasys/lib"
       
  2081 	    OASYS_ETCDIR="oasys/share"
       
  2082 	    ln -s ../../$ac_oasysdir $OASYS_INCDIR
       
  2083 	    ln -s ../$ac_oasysdir/lib $OASYS_LIBDIR
       
  2084 	    ln -s ../$ac_oasysdir $OASYS_ETCDIR
       
  2085     fi
       
  2086 
       
  2087     #
       
  2088     if test ! -d $OASYS_INCDIR ; then echo ""
       
  2089     AC_OASYS_CONFIG_HELP
       
  2090     AC_MSG_ERROR(nonexistent oasys include directory $OASYS_INCDIR)
       
  2091     fi
       
  2092 
       
  2093     if test ! -d $OASYS_LIBDIR ; then echo ""
       
  2094     AC_OASYS_CONFIG_HELP
       
  2095     AC_MSG_ERROR(nonexistent oasys library directory $OASYS_LIBDIR)
       
  2096     fi
       
  2097 
       
  2098     if test ! -d $OASYS_ETCDIR ; then echo ""
       
  2099     AC_OASYS_CONFIG_HELP
       
  2100     AC_MSG_ERROR(nonexistent oasys tools directory $OASYS_ETCDIR)
       
  2101     fi
       
  2102 
       
  2103     if test "$ac_oasysver_major" = "" ; then
       
  2104        ac_oasysver_major=1
       
  2105     fi
       
  2106 
       
  2107     if test "$ac_oasysver_minor" = "" ; then
       
  2108        ac_oasysver_minor=1
       
  2109     fi
       
  2110 
       
  2111     AC_OASYS_SUBST_CONFIG
       
  2112 
       
  2113     #
       
  2114     # Check the settings to make sure that we can build a program.
       
  2115     #
       
  2116     ac_save_CFLAGS=$CFLAGS
       
  2117     CFLAGS="$CFLAGS -I$OASYS_INCDIR"
       
  2118     
       
  2119     ac_save_LDFLAGS=$LDFLAGS
       
  2120     LDFLAGS="$LDFLAGS $OASYS_LDFLAGS"
       
  2121     AC_LINK_IFELSE(
       
  2122 	AC_LANG_PROGRAM(
       
  2123     [
       
  2124 	#include <oasys/oasys-version.h>
       
  2125 	#if (OASYS_VERSION_MAJOR != ${ac_oasysver_major}) || \
       
  2126             (OASYS_VERSION_MINOR <  ${ac_oasysver_minor})
       
  2127 	#error incorrect oasys version (wanted ${ac_oasysver_major}.${ac_oasysver_minor})
       
  2128 	#endif
       
  2129     ], 
       
  2130     [
       
  2131 	const char* s = oasys_version;
       
  2132 	(void)s;
       
  2133     ]),
       
  2134     [ 
       
  2135     AC_MSG_RESULT($ac_oasysdir)
       
  2136     ],
       
  2137     [
       
  2138     AC_MSG_RESULT([no])
       
  2139     AC_OASYS_CONFIG_HELP
       
  2140     AC_MSG_ERROR([Can't find compatible oasys libraries which are a required for DTN2.]) 
       
  2141       ])
       
  2142 
       
  2143     CFLAGS=$ac_save_CFLAGS
       
  2144     LDFLAGS=$ac_save_LDFLAGS
       
  2145 ])
       
  2146 
       
  2147 AC_DEFUN(AC_OASYS_SUBST_CONFIG, [
       
  2148     #
       
  2149     # XXX/demmer is there a better way to make the paths absolute??
       
  2150     #
       
  2151     OASYS_INCDIR=`cd $OASYS_INCDIR && pwd`
       
  2152     OASYS_LIBDIR=`cd $OASYS_LIBDIR && pwd`
       
  2153     OASYS_ETCDIR=`cd $OASYS_ETCDIR && pwd`
       
  2154 
       
  2155     OASYS_VERSION=`$OASYS_ETCDIR/tools/extract-version $OASYS_ETCDIR/oasys-version.dat version`
       
  2156 
       
  2157     #
       
  2158     # By default, oasys apps link statically to make it easier when
       
  2159     # linking with a source directory, and for building the test apps
       
  2160     # that are part of the library itself.
       
  2161     #
       
  2162     OASYS_LDFLAGS_STATIC="$OASYS_LIBDIR/liboasys-$OASYS_VERSION.a"
       
  2163 
       
  2164     if test -f $OASYS_LIBDIR/liboasys-$OASYS_VERSION.a ; then
       
  2165 	OASYS_LDFLAGS="$OASYS_LIBDIR/liboasys-$OASYS_VERSION.a"
       
  2166 	OASYS_COMPAT_LDFLAGS="$OASYS_LIBDIR/liboasyscompat-$OASYS_VERSION.a"
       
  2167 
       
  2168     elif test "$ac_oasysdir" = /usr ; then
       
  2169 	OASYS_LDFLAGS="-loasys-$OASYS_VERSION"
       
  2170 	OASYS_COMPAT_LDFLAGS="-loasyscompat-$OASYS_VERSION"
       
  2171 
       
  2172     else
       
  2173 	OASYS_LDFLAGS="-L$OASYS_LIBDIR -loasys-$OASYS_VERSION"
       
  2174 	OASYS_COMPAT_LDFLAGS="-L$OASYS_LIBDIR -loasyscompat-$OASYS_VERSION"
       
  2175     fi
       
  2176         
       
  2177     AC_SUBST(OASYS_INCDIR)
       
  2178     AC_SUBST(OASYS_LIBDIR)
       
  2179     AC_SUBST(OASYS_ETCDIR)
       
  2180     AC_SUBST(OASYS_LDFLAGS)
       
  2181     AC_SUBST(OASYS_LDFLAGS_STATIC)
       
  2182     AC_SUBST(OASYS_COMPAT_LDFLAGS)
       
  2183     AC_SUBST(OASYS_VERSION)
       
  2184 
       
  2185     AC_SUBST(EXTLIB_CFLAGS)
       
  2186     AC_SUBST(EXTLIB_LDFLAGS)
       
  2187 
       
  2188     AC_SUBST(SYS_EXTLIB_CFLAGS)
       
  2189     AC_SUBST(SYS_EXTLIB_LDFLAGS)
       
  2190 ])
       
  2191 dnl
       
  2192 dnl    Copyright 2005-2006 Intel Corporation
       
  2193 dnl 
       
  2194 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
  2195 dnl    you may not use this file except in compliance with the License.
       
  2196 dnl    You may obtain a copy of the License at
       
  2197 dnl 
       
  2198 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
  2199 dnl 
       
  2200 dnl    Unless required by applicable law or agreed to in writing, software
       
  2201 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
  2202 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
  2203 dnl    See the License for the specific language governing permissions and
       
  2204 dnl    limitations under the License.
       
  2205 dnl
       
  2206 
       
  2207 dnl
       
  2208 dnl Autoconf support for finding postgres
       
  2209 dnl
       
  2210 
       
  2211 dnl
       
  2212 dnl Main macro for finding a usable postgres installation 
       
  2213 dnl
       
  2214 AC_DEFUN(AC_CONFIG_POSTGRES, [
       
  2215     ac_postgresdir='no'
       
  2216 
       
  2217     AC_ARG_WITH(postgres,
       
  2218         AC_HELP_STRING([--with-postgres=DIR],
       
  2219     		   [location of a postgres installation (default none)]),
       
  2220         ac_postgresdir=$withval) 
       
  2221 
       
  2222     dnl
       
  2223     dnl First make sure we even want it
       
  2224     dnl
       
  2225     if test "$ac_postgresdir" = no ; then
       
  2226     POSTGRES_ENABLED=0
       
  2227     else
       
  2228 
       
  2229     POSTGRES_ENABLED=1
       
  2230     AC_DEFINE_UNQUOTED(POSTGRES_ENABLED, 1, 
       
  2231         [whether postgres support is enabled])
       
  2232 
       
  2233     dnl
       
  2234     dnl Now check if we have a cached value, unless the user specified
       
  2235     dnl something explicit with the --with-postgres= argument, in
       
  2236     dnl which case we force it to redo the checks (i.e. ignore the
       
  2237     dnl cached values)
       
  2238     dnl
       
  2239     if test "$ac_postgresdir" = yes -a ! x$oasys_cv_path_postgres_h = x ; then
       
  2240         echo "checking for postgres installation... (cached) $oasys_cv_path_postgres_h/libpq-fe.h, $oasys_cv_path_postgres_lib -lpq"
       
  2241     else
       
  2242         AC_OASYS_FIND_POSTGRES
       
  2243     fi
       
  2244 
       
  2245     if test ! $oasys_cv_path_postgres_h = /usr/include ; then
       
  2246         EXTLIB_CFLAGS="$EXTLIB_CFLAGS -I$oasys_cv_path_postgres_h"
       
  2247     fi
       
  2248 
       
  2249     if test ! $oasys_cv_path_postgres_lib = /usr/lib ; then
       
  2250         EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -L$oasys_cv_path_postgres_lib"
       
  2251     fi
       
  2252 
       
  2253     EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -lpq"
       
  2254     
       
  2255     fi # POSTGRES_ENABLED
       
  2256 ])
       
  2257 
       
  2258 dnl
       
  2259 dnl Find postgres
       
  2260 dnl
       
  2261 AC_DEFUN(AC_OASYS_FIND_POSTGRES, [
       
  2262     oasys_cv_path_postgres_h=
       
  2263     oasys_cv_path_postgres_lib=
       
  2264 
       
  2265     ac_save_CPPFLAGS="$CPPFLAGS"
       
  2266     ac_save_LDFLAGS="$LDFLAGS"
       
  2267     ac_save_LIBS="$LIBS"
       
  2268 
       
  2269     if test "$ac_postgresdir" = system -o \
       
  2270             "$ac_postgresdir" = yes -o \
       
  2271             "$ac_postgresdir" = "" ; 
       
  2272     then
       
  2273         ac_postgresincdirs="/usr/include /usr/include/postgresql \
       
  2274                             /usr/local/pgsql/include"
       
  2275         ac_postgreslibdirs="/usr/lib /usr/lib/pgsql /usr/local/pgsql/lib"
       
  2276     else
       
  2277         ac_postgresincdirs="$ac_postgresdir/include"
       
  2278         ac_postgreslibdirs="$ac_postgresdir/lib"
       
  2279     fi
       
  2280 
       
  2281     for ac_postgresincdir in $ac_postgresincdirs; do
       
  2282 
       
  2283 	CPPFLAGS="$ac_save_CPPFLAGS -I$ac_postgresincdir"
       
  2284 	LDFLAGS="$ac_save_LDFLAGS"
       
  2285 	LIBS="$ac_save_LIBS"
       
  2286 
       
  2287 	dnl
       
  2288 	dnl First check the version in the header file. If there's a match, 
       
  2289 	dnl fall through to the other check to make sure it links.
       
  2290 	dnl If not, then we can break out of the two inner loops.
       
  2291 	dnl
       
  2292         AC_MSG_CHECKING([for postgres header libpq-fe.h in $ac_postgresincdir])
       
  2293 	AC_LINK_IFELSE(
       
  2294 	  AC_LANG_PROGRAM(
       
  2295 	    [
       
  2296                 #include <libpq-fe.h>
       
  2297             ],
       
  2298             
       
  2299             [
       
  2300             ]),
       
  2301           [ 
       
  2302 	      AC_MSG_RESULT([yes])
       
  2303               oasys_cv_path_postgres_h=$ac_postgresincdir
       
  2304 	      break
       
  2305           ],
       
  2306           [
       
  2307               AC_MSG_RESULT([no])
       
  2308 	      continue
       
  2309           ])
       
  2310     done
       
  2311 
       
  2312     if test x$oasys_cv_path_postgres_h = x ; then
       
  2313         AC_MSG_ERROR([can't find usable postgres installation])
       
  2314     fi
       
  2315 
       
  2316     for ac_postgreslibdir in $ac_postgreslibdirs; do
       
  2317 
       
  2318 	LDFLAGS="$ac_save_LDFLAGS -L$ac_postgreslibdir"
       
  2319 	LIBS="$ac_save_LIBS -lpq"
       
  2320 
       
  2321         AC_MSG_CHECKING([for postgres library libpq in $ac_postgreslibdir])
       
  2322 	AC_LINK_IFELSE(
       
  2323 	  AC_LANG_PROGRAM(
       
  2324 	    [
       
  2325                 #include <libpq-fe.h>
       
  2326             ],
       
  2327             
       
  2328             [
       
  2329 	        PGconn *conn = PQconnectStart("");
       
  2330             ]),
       
  2331 
       
  2332           [
       
  2333               AC_MSG_RESULT([yes])
       
  2334               oasys_cv_path_postgres_lib=$ac_postgreslibdir
       
  2335               break
       
  2336           ],
       
  2337           [
       
  2338               AC_MSG_RESULT([no])
       
  2339           ])
       
  2340     done
       
  2341 
       
  2342     CPPFLAGS="$ac_save_CPPFLAGS"
       
  2343     LDFLAGS="$ac_save_LDFLAGS"
       
  2344     LIBS="$ac_save_LIBS"
       
  2345 
       
  2346     if test x$oasys_cv_path_postgres_lib = x ; then
       
  2347         AC_MSG_ERROR([can't find usable postgres library])
       
  2348     fi
       
  2349 ])
       
  2350 ##### http://autoconf-archive.cryp.to/ax_with_python.html
       
  2351 #
       
  2352 # SYNOPSIS
       
  2353 #
       
  2354 #   AX_WITH_PYTHON([minimum-version], [value-if-not-found], [path])
       
  2355 #
       
  2356 # DESCRIPTION
       
  2357 #
       
  2358 #   Locates an installed Python binary, placing the result in the
       
  2359 #   precious variable $PYTHON. Accepts a present $PYTHON, then
       
  2360 #   --with-python, and failing that searches for python in the given
       
  2361 #   path (which defaults to the system path). If python is found,
       
  2362 #   $PYTHON is set to the full path of the binary; if it is not found,
       
  2363 #   $PYTHON is set to VALUE-IF-NOT-FOUND, which defaults to 'python'.
       
  2364 #
       
  2365 #   Example:
       
  2366 #
       
  2367 #     AX_WITH_PYTHON(2.2, missing)
       
  2368 #
       
  2369 # LAST MODIFICATION
       
  2370 #
       
  2371 #   2007-07-29
       
  2372 #
       
  2373 # COPYLEFT
       
  2374 #
       
  2375 #   Copyright (c) 2007 Dustin J. Mitchell <dustin@cs.uchicago.edu>
       
  2376 #
       
  2377 #   Copying and distribution of this file, with or without
       
  2378 #   modification, are permitted in any medium without royalty provided
       
  2379 #   the copyright notice and this notice are preserved.
       
  2380 
       
  2381 AC_DEFUN([AX_WITH_PYTHON],
       
  2382 [
       
  2383   AC_ARG_VAR([PYTHON])
       
  2384 
       
  2385   dnl unless PYTHON was supplied to us (as a precious variable)
       
  2386   if test -z "$PYTHON"
       
  2387   then
       
  2388     AC_MSG_CHECKING(for --with-python)
       
  2389     AC_ARG_WITH(python,
       
  2390                 AC_HELP_STRING([--with-python=PYTHON],
       
  2391                                [absolute path name of Python executable]),
       
  2392                 [ if test "$withval" != "yes"
       
  2393                   then
       
  2394                     PYTHON="$withval"
       
  2395                     AC_MSG_RESULT($withval)
       
  2396                   else
       
  2397                     AC_MSG_RESULT(no)
       
  2398                   fi
       
  2399                 ],
       
  2400                 [ AC_MSG_RESULT(no)
       
  2401                 ])
       
  2402   fi
       
  2403 
       
  2404   dnl if it's still not found, check the paths, or use the fallback
       
  2405   if test -z "$PYTHON"
       
  2406   then
       
  2407     AC_PATH_PROG([PYTHON], python, m4_ifval([$2],[$2],[python]), $3)
       
  2408   fi
       
  2409 
       
  2410   dnl check version if required
       
  2411   m4_ifvaln([$1], [
       
  2412     dnl do this only if we didn't fall back
       
  2413     if test "$PYTHON" != "m4_ifval([$2],[$2],[python])"
       
  2414     then
       
  2415       AC_MSG_CHECKING($PYTHON version >= $1)
       
  2416       if test `$PYTHON -c ["import sys; print sys.version[:3] >= \"$1\" and \"OK\" or \"OLD\""]` = "OK"
       
  2417       then
       
  2418         AC_MSG_RESULT(ok)
       
  2419       else
       
  2420         AC_MSG_RESULT(no)
       
  2421         PYTHON="$2"
       
  2422       fi
       
  2423     fi])
       
  2424 ])
       
  2425 
       
  2426 dnl
       
  2427 dnl Simple autoconf test for whether distutils is properly set up to
       
  2428 dnl build an extension module. 
       
  2429 dnl
       
  2430 AC_DEFUN(AC_PYTHON_BUILD_EXT, [
       
  2431     
       
  2432     if test ! -z "$PYTHON" ; then
       
  2433 
       
  2434     AC_MSG_CHECKING([whether python distutils can build an extension module])
       
  2435 
       
  2436     cat > conftest.c <<_ACEOF
       
  2437 [
       
  2438 #include <Python.h>
       
  2439 
       
  2440 int main(int argc, char** argv)
       
  2441 {
       
  2442     Py_InitModule("conftest", NULL);
       
  2443 }
       
  2444 ]
       
  2445 _ACEOF
       
  2446 
       
  2447     cat > conftest.py <<_ACEOF
       
  2448 [
       
  2449 from distutils.core import setup, Extension
       
  2450 setup(name='conftest',
       
  2451       version='1.0',
       
  2452       ext_modules=[Extension('_conftest', ['conftest.c'])]
       
  2453       )
       
  2454 ]
       
  2455 _ACEOF
       
  2456 
       
  2457      # Current versions of autoconf access config.log 
       
  2458      # through file descriptor 5, so use it here to
       
  2459      # redirect output from the build operation.
       
  2460      _ACCMD="$PYTHON conftest.py build -b conftest_build"
       
  2461      echo "$as_me:$LINENO: running $_ACCMD... output:" >&5
       
  2462      $_ACCMD >&5 2>&5
       
  2463      ac_python_build=$?
       
  2464      
       
  2465      if test $ac_python_build = 0 ; then
       
  2466      	AC_MSG_RESULT([yes])
       
  2467 	PYTHON_BUILD_EXT=yes
       
  2468      	AC_SUBST(PYTHON_BUILD_EXT)
       
  2469      else
       
  2470         AC_MSG_RESULT([no])
       
  2471      fi
       
  2472      
       
  2473      rm -rf conftest_build conftest.py conftest.c
       
  2474      
       
  2475      fi # PYTHON != ""
       
  2476 ])
       
  2477 dnl
       
  2478 dnl    Copyright 2005-2006 Intel Corporation
       
  2479 dnl 
       
  2480 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
  2481 dnl    you may not use this file except in compliance with the License.
       
  2482 dnl    You may obtain a copy of the License at
       
  2483 dnl 
       
  2484 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
  2485 dnl 
       
  2486 dnl    Unless required by applicable law or agreed to in writing, software
       
  2487 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
  2488 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
  2489 dnl    See the License for the specific language governing permissions and
       
  2490 dnl    limitations under the License.
       
  2491 dnl
       
  2492 
       
  2493 dnl
       
  2494 dnl Autoconf support for configuring the various storage options
       
  2495 dnl that really just dispatches to the other macros
       
  2496 dnl
       
  2497 
       
  2498 AC_DEFUN(AC_CONFIG_STORAGE, [
       
  2499     AC_CONFIG_DB
       
  2500     AC_CONFIG_MYSQL
       
  2501     AC_CONFIG_POSTGRES
       
  2502     AC_CONFIG_EXTERNAL_DS
       
  2503 
       
  2504     dnl
       
  2505     dnl Figure out if at least one sql option is enabled.
       
  2506     dnl
       
  2507     if test "$MYSQL_ENABLED" = "1" -o "$POSTGRES_ENABLED" = "1" ; then
       
  2508         AC_DEFINE_UNQUOTED(SQL_ENABLED, 1,
       
  2509              [whether some sql storage system is enabled])
       
  2510     fi
       
  2511 ])
       
  2512 dnl
       
  2513 dnl    Copyright 2005-2006 Intel Corporation
       
  2514 dnl 
       
  2515 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
  2516 dnl    you may not use this file except in compliance with the License.
       
  2517 dnl    You may obtain a copy of the License at
       
  2518 dnl 
       
  2519 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
  2520 dnl 
       
  2521 dnl    Unless required by applicable law or agreed to in writing, software
       
  2522 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
  2523 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
  2524 dnl    See the License for the specific language governing permissions and
       
  2525 dnl    limitations under the License.
       
  2526 dnl
       
  2527 
       
  2528 dnl -------------------------------------------------------------------------
       
  2529 dnl Checks for system programs
       
  2530 dnl -------------------------------------------------------------------------
       
  2531 AC_DEFUN(AC_OASYS_SYSTEM_PROGRAMS, [
       
  2532     AC_PROG_AWK
       
  2533     AC_PROG_INSTALL
       
  2534     AC_PROG_MAKE_SET
       
  2535     AC_PROG_RANLIB
       
  2536 ])
       
  2537 
       
  2538 dnl -------------------------------------------------------------------------
       
  2539 dnl Checks for system libraries
       
  2540 dnl -------------------------------------------------------------------------
       
  2541 AC_DEFUN(AC_OASYS_SYSTEM_LIBRARIES, [
       
  2542     AC_EXTLIB_PREPARE
       
  2543 
       
  2544     AC_SEARCH_LIBS(pthread_create, pthread, [], 
       
  2545       AC_MSG_ERROR([can't find required library function (pthread_create)]))
       
  2546 
       
  2547     AC_SEARCH_LIBS(pthread_yield, [rt pthread],
       
  2548                    AC_DEFINE_UNQUOTED(HAVE_PTHREAD_YIELD, 1, [wether pthread_yield exists]),
       
  2549                    [])
       
  2550 
       
  2551     AC_SEARCH_LIBS(sched_yield, [rt],
       
  2552                    AC_DEFINE_UNQUOTED(HAVE_SCHED_YIELD, 1, [wether sched_yield exists]),
       
  2553                    [])
       
  2554 
       
  2555     AC_SEARCH_LIBS(pthread_setspecific, pthread, 
       
  2556                    AC_DEFINE_UNQUOTED(HAVE_PTHREAD_SETSPECIFIC, 1, 
       
  2557                                       [whether pthread_setspecific is defined]), 
       
  2558                    [])
       
  2559 
       
  2560     AC_SEARCH_LIBS(socket, socket, [],
       
  2561       AC_MSG_ERROR([can't find required library function (socket)]))
       
  2562 
       
  2563     AC_SEARCH_LIBS(gethostbyname, [socket nsl xnet],
       
  2564                    AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME, 1, [wether gethostbyname exists]),
       
  2565                    [])
       
  2566 
       
  2567     AC_SEARCH_LIBS(gethostbyname_r, [socket nsl],
       
  2568                    AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1, [wether gethostbyname_r exists]),
       
  2569                    [])
       
  2570 
       
  2571     AC_SEARCH_LIBS(xdr_int, rpc, [],
       
  2572       AC_MSG_ERROR([can't find required library function (xdr_int)]))
       
  2573 
       
  2574     AC_SEARCH_LIBS(xdr_u_int64_t, rpc,
       
  2575                    AC_DEFINE_UNQUOTED(HAVE_XDR_U_INT64_T, 1, [whether xdr_u_int64_t exists]),
       
  2576                    [])
       
  2577 
       
  2578     AC_SEARCH_LIBS(xdr_u_quad_t, rpc,
       
  2579                    AC_DEFINE_UNQUOTED(HAVE_XDR_U_QUAD_T, 1, [whether xdr_u_quad_t exists]),
       
  2580                    [])
       
  2581 
       
  2582     AC_SEARCH_LIBS(inet_aton, [nsl resolv socket],
       
  2583                    AC_DEFINE_UNQUOTED(HAVE_INET_ATON, 1, [wether inet_aton exists]),
       
  2584                    [])
       
  2585 
       
  2586     AC_SEARCH_LIBS(inet_pton, [nsl resolv socket],
       
  2587                    AC_DEFINE_UNQUOTED(HAVE_INET_PTON, 1, [wether inet_pton exists]),
       
  2588                    [])
       
  2589 
       
  2590     AC_EXTLIB_SAVE
       
  2591 ])
       
  2592 
       
  2593 dnl -------------------------------------------------------------------------
       
  2594 dnl Checks for header files.
       
  2595 dnl -------------------------------------------------------------------------
       
  2596 AC_DEFUN(AC_OASYS_SYSTEM_HEADERS, [
       
  2597     AC_HEADER_STDC
       
  2598     AC_CHECK_HEADERS([err.h execinfo.h stdint.h string.h synch.h sys/cdefs.h sys/types.h])
       
  2599 ])
       
  2600 
       
  2601 dnl -------------------------------------------------------------------------
       
  2602 dnl Checks for typedefs, structures, and compiler characteristics.
       
  2603 dnl -------------------------------------------------------------------------
       
  2604 AC_DEFUN(AC_OASYS_SYSTEM_TYPES, [
       
  2605     AC_C_CONST
       
  2606     AC_C_INLINE
       
  2607     AC_C_VOLATILE
       
  2608     AC_TYPE_MODE_T
       
  2609     AC_MSG_CHECKING([value for _FILE_OFFSET_BITS preprocessor symbol])
       
  2610     ac_file_offset_bits=64
       
  2611     AC_ARG_WITH(file-offset-bits,
       
  2612 	AC_HELP_STRING([--with-file-offset-bits=N],
       
  2613 		       [value for _FILE_OFFSET_BITS (default 64)]),
       
  2614 		       ac_file_offset_bits=$withval)
       
  2615     AC_MSG_RESULT($ac_file_offset_bits)
       
  2616     if test $ac_file_offset_bits = 64 ; then
       
  2617         SYS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
       
  2618     else 
       
  2619         SYS_CFLAGS="-D_FILE_OFFSET_BITS=$ac_file_offset_bits"
       
  2620     fi
       
  2621     AC_SUBST(SYS_CFLAGS)
       
  2622     oasys_ac_cppflags_save="$CPPFLAGS"
       
  2623     CPPFLAGS="$SYS_CFLAGS $CPPFLAGS"
       
  2624     AC_CHECK_SIZEOF(off_t)
       
  2625     CPPFLAGS="$oasys_ac_cppflags_save"
       
  2626     AC_TYPE_SIGNAL
       
  2627     AC_TYPE_SIZE_T
       
  2628     AC_CHECK_TYPES([ptrdiff_t])
       
  2629     AC_CHECK_TYPES([uint32_t])
       
  2630     AC_CHECK_TYPES([u_int32_t])
       
  2631 ])
       
  2632 
       
  2633 dnl -------------------------------------------------------------------------
       
  2634 dnl Checks for library functions.
       
  2635 dnl -------------------------------------------------------------------------
       
  2636 AC_DEFUN(AC_OASYS_SYSTEM_FUNCTIONS, [
       
  2637     # XXX/demmer get rid of me
       
  2638     AC_CHECK_FUNCS([getaddrinfo getopt_long cfmakeraw cfsetspeed])
       
  2639 ])                                
       
  2640 
       
  2641 
       
  2642 AC_DEFUN(AC_OASYS_SYSTEM_FDATASYNC, [
       
  2643     AC_CACHE_CHECK([working fdatasync],[ac_cv_func_fdatasync],[
       
  2644      ÊAC_LANG_PUSH(C++)
       
  2645      ÊAC_RUN_IFELSE([AC_LANG_PROGRAM([[
       
  2646     #include <unistd.h>
       
  2647      Ê Ê]],[[
       
  2648     fdatasync(4);
       
  2649      Ê Ê]])],
       
  2650      Ê[ac_cv_func_fdatasync=yes],
       
  2651      Ê[ac_cv_func_fdatasync=no])
       
  2652      ÊAC_LANG_POP()
       
  2653     ])
       
  2654     AS_IF([test "x${ac_cv_func_fdatasync}" = "xyes"],
       
  2655      Ê[AC_DEFINE([HAVE_FDATASYNC],[1],[If the system has a working fdatasync])])
       
  2656 ])                                
       
  2657 
       
  2658 dnl -------------------------------------------------------------------------
       
  2659 dnl Check all the system requirements
       
  2660 dnl -------------------------------------------------------------------------
       
  2661 AC_DEFUN(AC_OASYS_CONFIG_SYSTEM, [
       
  2662     AC_OASYS_SYSTEM_PROGRAMS
       
  2663     AC_OASYS_SYSTEM_LIBRARIES
       
  2664     AC_OASYS_SYSTEM_HEADERS
       
  2665     AC_OASYS_SYSTEM_TYPES
       
  2666     AC_OASYS_SYSTEM_FUNCTIONS
       
  2667 ])
       
  2668 
       
  2669 dnl
       
  2670 dnl    Copyright 2005-2006 Intel Corporation
       
  2671 dnl 
       
  2672 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
  2673 dnl    you may not use this file except in compliance with the License.
       
  2674 dnl    You may obtain a copy of the License at
       
  2675 dnl 
       
  2676 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
  2677 dnl 
       
  2678 dnl    Unless required by applicable law or agreed to in writing, software
       
  2679 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
  2680 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
  2681 dnl    See the License for the specific language governing permissions and
       
  2682 dnl    limitations under the License.
       
  2683 dnl
       
  2684 
       
  2685 dnl
       
  2686 dnl Autoconf support for finding tcl
       
  2687 dnl
       
  2688 
       
  2689 dnl
       
  2690 dnl Main macro for finding a usable tcl installation 
       
  2691 dnl
       
  2692 AC_DEFUN(AC_CONFIG_TCL, [
       
  2693     ac_tclvers='8.5 8.4 8.3'
       
  2694     ac_tcldir='system'
       
  2695 
       
  2696     AC_ARG_WITH(tcl,
       
  2697         AC_HELP_STRING([--with-tcl=DIR],
       
  2698     		   [location of a tcl installation (default system)]),
       
  2699         ac_tcldir=$withval) 
       
  2700 
       
  2701     AC_ARG_WITH(tcldir,
       
  2702         AC_HELP_STRING([--with-tcldir=DIR],
       
  2703     		   [same as --with-tcl]),
       
  2704         ac_tcldir=$withval) 
       
  2705 
       
  2706     AC_ARG_WITH(tclver,
       
  2707         AC_HELP_STRING([--with-tclver=VERSION],
       
  2708     		   [tcl version to use (default 8.5 - 8.3)]),
       
  2709         ac_tclvers=$withval)
       
  2710 
       
  2711     dnl
       
  2712     dnl We don't accept --without-tcl
       
  2713     dnl
       
  2714     if test $ac_tcldir = no ; then
       
  2715        AC_MSG_ERROR([tcl MUST be installed to configure])
       
  2716     fi
       
  2717 
       
  2718     dnl
       
  2719     dnl Tcl requires other libraries
       
  2720     dnl
       
  2721     AC_EXTLIB_PREPARE
       
  2722     AC_SEARCH_LIBS(pow, m, [],
       
  2723       AC_MSG_ERROR([can't find standard C library function (pow) required by tcl]))
       
  2724     AC_SEARCH_LIBS(dlopen, dl, [],
       
  2725       AC_MSG_ERROR([can't find standard library function (dlopen) required by tcl]))
       
  2726     AC_EXTLIB_SAVE
       
  2727 
       
  2728     dnl
       
  2729     dnl First check if we have a cached value, unless the user
       
  2730     dnl specified something with --with-tcl, in which case we force 
       
  2731     dnl it to redo the checks (i.e. ignore the cached values).
       
  2732     dnl
       
  2733     if test $ac_tcldir = system -a ! x$oasys_cv_path_tcl_h = x ; then \
       
  2734 	echo "checking for tcl installation... (cached) $oasys_cv_path_tcl_h/tcl.h, $oasys_cv_path_tcl_lib -l$oasys_cv_lib_tcl"
       
  2735     else
       
  2736         AC_FIND_TCL
       
  2737     fi
       
  2738 
       
  2739     TCL_CFLAGS=        
       
  2740     if test ! $oasys_cv_path_tcl_h = /usr/include ; then
       
  2741 	TCL_CFLAGS=-I$oasys_cv_path_tcl_h
       
  2742         EXTLIB_CFLAGS="$EXTLIB_CFLAGS $TCL_CFLAGS"
       
  2743     fi
       
  2744 
       
  2745     TCL_LDFLAGS=
       
  2746     if test ! x"$oasys_cv_path_tcl_lib" = x"/usr/lib" ; then
       
  2747 	TCL_LDFLAGS="-L$oasys_cv_path_tcl_lib -l$oasys_cv_lib_tcl"
       
  2748     else
       
  2749 	TCL_LDFLAGS=-l$oasys_cv_lib_tcl
       
  2750     fi
       
  2751 
       
  2752     EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS $TCL_LDFLAGS"
       
  2753     AC_SUBST(TCL_LDFLAGS)
       
  2754 ])
       
  2755 
       
  2756 dnl
       
  2757 dnl Find tcl
       
  2758 dnl
       
  2759 AC_DEFUN(AC_FIND_TCL, [
       
  2760     oasys_cv_path_tcl_h=
       
  2761 
       
  2762     ac_save_CPPFLAGS="$CPPFLAGS"
       
  2763     ac_save_LDFLAGS="$LDFLAGS"
       
  2764     ac_save_LIBS="$LIBS"
       
  2765 
       
  2766     if test $ac_tcldir = system -o $ac_tcldir = yes -o $ac_tcldir = "" ; then
       
  2767         ac_tcldir=system
       
  2768         ac_tclincdirs="/usr/include /usr/local/include"
       
  2769 	for ac_tclver in $ac_tclvers ; do
       
  2770            ac_tclincdirs="$ac_tclincdirs /usr/include/tcl$ac_tclver /usr/local/include/tcl$ac_tclver"
       
  2771            ac_tclincdirs="$ac_tclincdirs"
       
  2772        done
       
  2773         ac_tcllibdirs="/usr/lib /usr/local/lib"
       
  2774     else
       
  2775         ac_tclincdirs=$ac_tcldir/include
       
  2776         ac_tcllibdirs="$ac_tcldir/lib"
       
  2777     fi
       
  2778 
       
  2779     for ac_tclver in $ac_tclvers ; do	
       
  2780         echo ""
       
  2781         AC_MSG_NOTICE([checking for tcl installation (version $ac_tclver)])
       
  2782 
       
  2783     for ac_tclincdir in $ac_tclincdirs; do
       
  2784 
       
  2785         ac_tclver_major=`echo $ac_tclver | cut -d . -f1`
       
  2786 	ac_tclver_minor=`echo $ac_tclver | cut -d . -f2`
       
  2787 	CPPFLAGS="$ac_save_CPPFLAGS -I$ac_tclincdir"
       
  2788 	LDFLAGS="$ac_save_LDFLAGS"
       
  2789 	LIBS="$ac_save_LIBS"
       
  2790 	
       
  2791 	dnl
       
  2792 	dnl First check the version in the header file. If there's a match, 
       
  2793 	dnl fall through to the other check to make sure it links.
       
  2794 	dnl If not, then we can break out of the two inner loops.
       
  2795 	dnl
       
  2796         AC_MSG_CHECKING([for tcl.h (version $ac_tclver) in $ac_tclincdir])
       
  2797 
       
  2798 	AC_LINK_IFELSE(
       
  2799 	  AC_LANG_PROGRAM(
       
  2800 	    [
       
  2801                 #include <tcl.h>
       
  2802            
       
  2803                 #if (TCL_MAJOR_VERSION != ${ac_tclver_major}) || \
       
  2804                     (TCL_MINOR_VERSION != ${ac_tclver_minor})
       
  2805                 #error "incorrect version"
       
  2806                 #endif
       
  2807             ],
       
  2808             
       
  2809             [
       
  2810             ]),
       
  2811 
       
  2812           [
       
  2813               AC_MSG_RESULT([yes])
       
  2814           ],
       
  2815           [
       
  2816               AC_MSG_RESULT([no])
       
  2817               continue
       
  2818           ])
       
  2819 
       
  2820       for ac_tcllibdir in $ac_tcllibdirs; do
       
  2821       for ac_tcllib in tcl$ac_tclver tcl$ac_tclver_major$ac_tclver_minor tcl; do
       
  2822 
       
  2823 	LDFLAGS="$ac_save_LDFLAGS -L$ac_tcllibdir"
       
  2824     	if test x"$STATIC" = x"extlibs" ; then
       
  2825 		LIBS="-Wl,-Bstatic -l$ac_tcllib -Wl,-Bdynamic -ldl -lm $ac_save_LIBS"
       
  2826 	else
       
  2827 		LIBS="-l$ac_tcllib $ac_save_LIBS"
       
  2828 	fi
       
  2829 
       
  2830         AC_MSG_CHECKING([for tcl library in $ac_tcllibdir: $LIBS])
       
  2831 
       
  2832 	AC_LINK_IFELSE(
       
  2833 	  AC_LANG_PROGRAM(
       
  2834 	    [
       
  2835                 #include <tcl.h>
       
  2836            
       
  2837                 #if (TCL_MAJOR_VERSION != ${ac_tclver_major}) || \
       
  2838                     (TCL_MINOR_VERSION != ${ac_tclver_minor})
       
  2839                 #error "incorrect version"
       
  2840                 #endif
       
  2841             ],
       
  2842             
       
  2843             [
       
  2844                 Tcl_Interp* interp = Tcl_CreateInterp();
       
  2845             ]),
       
  2846 
       
  2847           [
       
  2848               AC_MSG_RESULT([yes])
       
  2849               oasys_cv_path_tcl_h=$ac_tclincdir
       
  2850               oasys_cv_path_tcl_lib=$ac_tcllibdir
       
  2851               oasys_cv_lib_tcl=$ac_tcllib
       
  2852 
       
  2853               #Buggy 
       
  2854               #if test ! x"$STATIC" = x"yes" ; then
       
  2855                   #oasys_cv_path_tcl_lib="${ac_tcllibdir} -Wl,-rpath,${ac_tcllibdir}"
       
  2856                   #oasys_cv_lib_tcl="${ac_tcllib} -Wl,-rpath,${ac_tcllibdir}"
       
  2857               #fi
       
  2858 
       
  2859               break 4
       
  2860           ],
       
  2861           [
       
  2862               AC_MSG_RESULT([no])
       
  2863           ])
       
  2864     done
       
  2865     done
       
  2866     done
       
  2867     done
       
  2868 
       
  2869     CPPFLAGS="$ac_save_CPPFLAGS"
       
  2870     LDFLAGS="$ac_save_LDFLAGS"
       
  2871     LIBS="$ac_save_LIBS"
       
  2872 
       
  2873     if test x$oasys_cv_path_tcl_h = x ; then
       
  2874         AC_MSG_ERROR([Please install the tcl development files headers and libraries. Can't find usable tcl.h ])
       
  2875     fi
       
  2876 ])
       
  2877 dnl
       
  2878 dnl    Copyright 2006 Intel Corporation
       
  2879 dnl 
       
  2880 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
  2881 dnl    you may not use this file except in compliance with the License.
       
  2882 dnl    You may obtain a copy of the License at
       
  2883 dnl 
       
  2884 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
  2885 dnl 
       
  2886 dnl    Unless required by applicable law or agreed to in writing, software
       
  2887 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
  2888 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
  2889 dnl    See the License for the specific language governing permissions and
       
  2890 dnl    limitations under the License.
       
  2891 dnl
       
  2892 
       
  2893 dnl
       
  2894 dnl Autoconf support for tclreadline
       
  2895 dnl
       
  2896 
       
  2897 dnl
       
  2898 dnl help 
       
  2899 dnl
       
  2900 AC_DEFUN(AC_TCLRL_HELP, [
       
  2901 cat <<EOF
       
  2902 
       
  2903 Configure error with tclreadline...
       
  2904 
       
  2905 If you do not want tclreadline support at all, you can specify
       
  2906 --without-tclreadline.
       
  2907 
       
  2908 Download tclreadline from http://tclreadline.sourceforge.net/
       
  2909 
       
  2910 Before trying to compile tclreadline you should do the following things:
       
  2911 
       
  2912     (a) Make sure you have tcl 8.0 or higher.
       
  2913         tclreadline relies on a proper tcl installation:
       
  2914         It uses the tclConfig.sh file, which should reside somewhere
       
  2915         in /usr/local/lib/ or /usr/local/lib/tcl8.0/...
       
  2916 
       
  2917     (b) Make sure you have gnu readline 2.2 or higher.
       
  2918         tclreadline uses the gnu readline callback handler
       
  2919 
       
  2920     (c) The usual ./configure; make; make install sequence should do the rest.
       
  2921 
       
  2922 
       
  2923 EOF
       
  2924 
       
  2925 ])
       
  2926 dnl
       
  2927 dnl Main macro for finding a usable db installation 
       
  2928 dnl
       
  2929 AC_DEFUN(AC_CONFIG_TCLREADLINE, [
       
  2930 #ac_tclreadlinedir='system'
       
  2931 
       
  2932     AC_ARG_WITH(tclreadline,
       
  2933         AC_HELP_STRING([--with-tclreadline],
       
  2934     		   [enable or disable tclreadline (default try)]),
       
  2935         [ac_tclreadline=$withval],
       
  2936         [ac_tclreadline=try])
       
  2937 
       
  2938     dnl
       
  2939     dnl First make sure we even want it
       
  2940     dnl
       
  2941 	AC_MSG_CHECKING([whether tclreadline support should be enabled])
       
  2942     if test "$ac_tclreadline" = no ; then
       
  2943     AC_MSG_RESULT([no])
       
  2944     TCLREADLINE_ENABLED=0
       
  2945 
       
  2946     else
       
  2947 
       
  2948     dnl
       
  2949     dnl If we do, tell the user what we're about to do
       
  2950     dnl    
       
  2951     if test "$ac_tclreadline" = try ; then
       
  2952        AC_MSG_RESULT([try])
       
  2953     else
       
  2954        AC_MSG_RESULT([yes])
       
  2955     fi
       
  2956 
       
  2957     dnl
       
  2958     dnl Now check for an installation of libreadline (except on Cygwin)
       
  2959     dnl
       
  2960     if test "$BUILD_SYSTEM" = 'CYGWIN' ; then
       
  2961         TCLREADLINE_ENABLED=0
       
  2962     else 
       
  2963     dnl	
       
  2964     dnl look for the library and the header
       
  2965     dnl
       
  2966 	AC_EXTLIB_PREPARE
       
  2967         AC_MSG_CHECKING([searching for the readline library development headers])
       
  2968         AC_CHECK_HEADERS([readline/readline.h], TCLREADLINE_ENABLED=1, TCLREADLINE_ENABLED=0)
       
  2969 	AC_SEARCH_LIBS(readline, readline, TCLREADLINE_ENABLED=1, TCLREADLINE_ENABLED=0)
       
  2970         AC_EXTLIB_SAVE
       
  2971     fi
       
  2972 
       
  2973     dnl
       
  2974     dnl Find out if we're using the BSD libedit implementation of 
       
  2975     dnl readline functionality.
       
  2976     dnl
       
  2977     if test "$TCLREADLINE_ENABLED" = 1; then
       
  2978          AC_CACHE_CHECK([whether readline is GNU readline or BSD editline],
       
  2979 	  	        [oasys_cv_readline_is_editline],
       
  2980  		        [AC_LINK_IFELSE([AC_LANG_CALL([], [rl_extend_line_buffer])],
       
  2981  		       		        [oasys_cv_readline_is_editline=GNU],
       
  2982  		       		        [oasys_cv_readline_is_editline=editline])])
       
  2983         if test $oasys_cv_readline_is_editline = editline ; then
       
  2984             AC_DEFINE_UNQUOTED(READLINE_IS_EDITLINE, 1,
       
  2985                                [whether readline is actually BSD's libedit])
       
  2986         fi
       
  2987 
       
  2988 	dnl Finally, spit out an informative message
       
  2989 	AC_MSG_CHECKING([whether tclreadline support was found])
       
  2990         AC_MSG_RESULT([yes])
       
  2991 
       
  2992     else
       
  2993 
       
  2994 	dnl Finally, spit out an informative message
       
  2995 	AC_MSG_CHECKING([whether tclreadline support was found])
       
  2996 	AC_MSG_RESULT([no])
       
  2997 	if test "$ac_tclreadline" = yes; then
       
  2998 	AC_TCLRL_HELP
       
  2999 	AC_MSG_ERROR([can't find usable tclreadline])
       
  3000 	fi
       
  3001     fi
       
  3002 
       
  3003     fi # ac_tclreadline != no
       
  3004 
       
  3005     AC_DEFINE_UNQUOTED(TCLREADLINE_ENABLED, $TCLREADLINE_ENABLED,
       
  3006                        [whether tclreadline is enabled])
       
  3007 ])
       
  3008 dnl 
       
  3009 dnl   Copyright 2006-2007 The MITRE Corporation
       
  3010 dnl
       
  3011 dnl   Licensed under the Apache License, Version 2.0 (the "License");
       
  3012 dnl   you may not use this file except in compliance with the License.
       
  3013 dnl   You may obtain a copy of the License at
       
  3014 dnl
       
  3015 dnl       http://www.apache.org/licenses/LICENSE-2.0
       
  3016 dnl
       
  3017 dnl   Unless required by applicable law or agreed to in writing, software
       
  3018 dnl   distributed under the License is distributed on an "AS IS" BASIS,
       
  3019 dnl   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
  3020 dnl   See the License for the specific language governing permissions and
       
  3021 dnl   limitations under the License.
       
  3022 dnl
       
  3023 dnl   The US Government will not be charged any license fee and/or royalties
       
  3024 dnl   related to this software. Neither name of The MITRE Corporation; nor the
       
  3025 dnl   names of its contributors may be used to endorse or promote products
       
  3026 dnl   derived from this software without specific prior written permission.
       
  3027 dnl
       
  3028 
       
  3029 dnl
       
  3030 dnl Autoconf support for finding xerces-c
       
  3031 dnl
       
  3032 
       
  3033 AC_DEFUN(AC_CONFIG_XERCES, [
       
  3034     dnl
       
  3035     dnl Handle --with-xerces-c=DIR
       
  3036     dnl
       
  3037     AC_ARG_WITH(xerces-c,
       
  3038         AC_HELP_STRING([--with-xerces-c=DIR],
       
  3039             [location of a xerces-c installation (default try)]),
       
  3040         [ac_with_xerces_c=$withval],
       
  3041         [ac_with_xerces_c=try])
       
  3042 
       
  3043     AC_MSG_CHECKING([whether xerces-c support should be enabled])
       
  3044 
       
  3045     dnl
       
  3046     dnl Disable xerces-c if requested
       
  3047     dnl
       
  3048     if test "$ac_with_xerces_c" = no; then
       
  3049         AC_MSG_RESULT([no])
       
  3050         XERCES_C_ENABLED=0
       
  3051 	echo ""
       
  3052 	AC_MSG_NOTICE([Proceeding without xerces-c support as requested])
       
  3053 	echo ""
       
  3054     else
       
  3055 
       
  3056     dnl
       
  3057     dnl Find the xerces-c installation
       
  3058     dnl
       
  3059     if test "$ac_with_xerces_c" = try \
       
  3060          -o "$ac_with_xerces_c" = yes \ 
       
  3061          -o "$ac_with_xerces_c" = "" ; then
       
  3062         AC_MSG_RESULT([try])
       
  3063         ac_xerces_inst_dirs="/usr /usr/local"
       
  3064     else
       
  3065         AC_MSG_RESULT([yes (dir $ac_with_xerces_c)])
       
  3066         ac_xerces_inst_dirs="$ac_with_xerces_c"
       
  3067     fi
       
  3068 
       
  3069     ac_save_CPPFLAGS="$CPPFLAGS"
       
  3070     ac_save_LDFLAGS="$LDFLAGS"
       
  3071     ac_save_LIBS="$LIBS"
       
  3072 
       
  3073     AC_MSG_CHECKING([whether xerces-c (>= v2.6.0) was found])
       
  3074     AC_CACHE_VAL(oasys_cv_path_xerces_c,
       
  3075     [
       
  3076         for ac_xerces_inst_dir in $ac_xerces_inst_dirs; do
       
  3077             if test -d "$ac_xerces_inst_dir"; then
       
  3078                 AC_LANG([C++])
       
  3079                 CPPFLAGS="-I$ac_xerces_inst_dir/include"
       
  3080                 LDFLAGS="-L$ac_xerces_inst_dir/lib"
       
  3081                 LIBS="-lxerces-c"
       
  3082 
       
  3083                 AC_LINK_IFELSE(
       
  3084                     AC_LANG_PROGRAM(
       
  3085                         [
       
  3086                             #include <xercesc/util/PlatformUtils.hpp>
       
  3087                             #include <xercesc/util/XMLString.hpp>
       
  3088                             #include <xercesc/dom/DOM.hpp>
       
  3089                         ],
       
  3090     
       
  3091                         [
       
  3092                             #if _XERCES_VERSION >= 20600
       
  3093 
       
  3094                             xercesc::XMLPlatformUtils::Initialize();
       
  3095                             {
       
  3096                                 xercesc::DOMImplementation* impl
       
  3097                                     = xercesc::DOMImplementationRegistry::getDOMImplementation
       
  3098                                         (xercesc::XMLString::transcode("XML 1.0"));
       
  3099                             }
       
  3100                             xercesc::XMLPlatformUtils::Terminate();
       
  3101 
       
  3102                             #else
       
  3103                                 #error
       
  3104                             #endif
       
  3105                         ]),
       
  3106                     [
       
  3107                         oasys_cv_path_xerces_c="$ac_xerces_inst_dir"
       
  3108                         break
       
  3109                     ],
       
  3110                     [
       
  3111                         oasys_cv_path_xerces_c=
       
  3112                     ]
       
  3113                 )
       
  3114             fi
       
  3115         done
       
  3116     ])
       
  3117 
       
  3118     CPPFLAGS="$ac_save_CPPFLAGS"
       
  3119     LDFLAGS="$ac_save_LDFLAGS"
       
  3120     LIBS="$ac_save_LIBS"
       
  3121 
       
  3122     if test -z "$oasys_cv_path_xerces_c"; then
       
  3123         AC_MSG_RESULT([no])
       
  3124         XERCES_C_ENABLED=0
       
  3125     else
       
  3126 	AC_MSG_RESULT([yes])
       
  3127         XERCES_C_ENABLED=1
       
  3128         AC_DEFINE(XERCES_C_ENABLED, 1, [whether xerces support is enabled])
       
  3129         if test ! "$oasys_cv_path_xerces_c" = /usr ; then
       
  3130             EXTLIB_CFLAGS="$EXTLIB_CFLAGS -I$oasys_cv_path_xerces_c/include"
       
  3131             EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -L$oasys_cv_path_xerces_c/lib"
       
  3132         fi
       
  3133         EXTLIB_LDFLAGS="$EXTLIB_LDFLAGS -lxerces-c"
       
  3134     fi
       
  3135 
       
  3136     fi
       
  3137 ])
       
  3138 dnl Copyright 2004-2006 BBN Technologies Corporation
       
  3139 dnl
       
  3140 dnl Licensed under the Apache License, Version 2.0 (the "License"); you may not
       
  3141 dnl use this file except in compliance with the License. You may obtain a copy
       
  3142 dnl of the License at http://www.apache.org/licenses/LICENSE-2.0
       
  3143 dnl
       
  3144 dnl Unless required by applicable law or agreed to in writing, software
       
  3145 dnl distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
       
  3146 dnl WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
  3147 dnl
       
  3148 dnl See the License for the specific language governing permissions and
       
  3149 dnl limitations under the License.
       
  3150 dnl
       
  3151 
       
  3152 dnl
       
  3153 dnl Autoconf support for finding xsd
       
  3154 dnl
       
  3155 
       
  3156 AC_DEFUN(AC_CONFIG_XSD, [
       
  3157     dnl
       
  3158     dnl Handle --with-xsd-tool=xsd
       
  3159     dnl
       
  3160     AC_ARG_WITH(xsd-tool,
       
  3161         AC_HELP_STRING([--with-xsd-tool=xsd],
       
  3162             [name or path of the xsd tool (default: xsd)]),
       
  3163         [ac_with_xsd_tool=$withval],
       
  3164         [ac_with_xsd_tool=xsd])
       
  3165 
       
  3166     AC_CHECK_TOOL(XSD_TOOL, $ac_with_xsd_tool)
       
  3167     if test -z "$XSD_TOOL" ; then
       
  3168        AC_MSG_NOTICE([Cannot find a working xsd tool])
       
  3169        AC_MSG_NOTICE([   You will not be able to regenerate XML schema bindings])
       
  3170        AC_MSG_NOTICE([   if you make changes to the .xsd file])
       
  3171        AC_MSG_NOTICE([   Use --with-xsd-tool=(name) to specify the location of this tool])
       
  3172     fi
       
  3173 ])
       
  3174 dnl
       
  3175 dnl    Copyright 2006 Intel Corporation
       
  3176 dnl 
       
  3177 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
  3178 dnl    you may not use this file except in compliance with the License.
       
  3179 dnl    You may obtain a copy of the License at
       
  3180 dnl 
       
  3181 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
  3182 dnl 
       
  3183 dnl    Unless required by applicable law or agreed to in writing, software
       
  3184 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
  3185 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
  3186 dnl    See the License for the specific language governing permissions and
       
  3187 dnl    limitations under the License.
       
  3188 dnl
       
  3189 
       
  3190 dnl 
       
  3191 dnl Autoconf support for configuring whether Zlib is available
       
  3192 dnl on the system
       
  3193 dnl
       
  3194 
       
  3195 AC_DEFUN(AC_CONFIG_ZLIB, [
       
  3196 
       
  3197     AC_ARG_WITH(zlib,
       
  3198       [AC_HELP_STRING([--with-zlib],
       
  3199                       [compile in zlib support (default try)])],
       
  3200       [ac_use_zlib=$withval],
       
  3201       [ac_use_zlib=try])
       
  3202     
       
  3203     AC_MSG_CHECKING([whether zlib support should be enabled])
       
  3204 
       
  3205     if test "$ac_use_zlib" = "no"; then
       
  3206         AC_MSG_RESULT(no)
       
  3207 
       
  3208     else
       
  3209         AC_MSG_RESULT($ac_use_zlib)
       
  3210 
       
  3211         dnl
       
  3212         dnl Look for the compress() and compressBound() functions in libz
       
  3213         dnl
       
  3214         AC_EXTLIB_PREPARE
       
  3215         AC_SEARCH_LIBS(compress, z, ac_has_libz="yes") 
       
  3216         AC_SEARCH_LIBS(compressBound, z, ac_zlib_has_compressBound="yes") 
       
  3217         AC_EXTLIB_SAVE
       
  3218 
       
  3219         dnl
       
  3220         dnl Print out whether or not we found the libraries
       
  3221         dnl
       
  3222         AC_MSG_CHECKING([whether zlib support was found])
       
  3223 
       
  3224         dnl
       
  3225         dnl Check which defines, if any, are set
       
  3226         dnl
       
  3227         if test "$ac_has_libz" = yes ; then
       
  3228           AC_DEFINE(OASYS_ZLIB_ENABLED, 1,
       
  3229               [whether zlib support is enabled])
       
  3230           AC_MSG_RESULT(yes)
       
  3231 
       
  3232 	  if test "$ac_zlib_has_compressBound" = yes ; then
       
  3233 	      AC_DEFINE(OASYS_ZLIB_HAS_COMPRESS_BOUND, 1,
       
  3234                   [whether zlib contains compressBound])
       
  3235 	  fi
       
  3236 
       
  3237 	elif test "$ac_use_zlib" = "try" ; then
       
  3238           AC_MSG_RESULT(no)
       
  3239 
       
  3240         else
       
  3241           AC_MSG_ERROR([can't find zlib library])
       
  3242         fi
       
  3243     fi
       
  3244 ])