File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / ntp / m4 / ntp_openssl.m4
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:08:38 2012 UTC (12 years, 1 month ago) by misho
Branches: ntp, MAIN
CVS tags: v4_2_6p5p0, v4_2_6p5, HEAD
ntp 4.2.6p5

    1: dnl ######################################################################
    2: dnl OpenSSL support shared by top-level and sntp/configure.ac
    3: AC_DEFUN([NTP_OPENSSL], [
    4: 	
    5: AC_SUBST([OPENSSL])
    6: AC_SUBST([OPENSSL_INC])
    7: AC_SUBST([OPENSSL_LIB])
    8: 
    9: AC_MSG_CHECKING([for openssl library directory])
   10: AC_ARG_WITH(
   11:     [openssl-libdir],
   12:     [AS_HELP_STRING(
   13: 	[--with-openssl-libdir], 
   14: 	[+ =/something/reasonable]
   15:     )],
   16:     [ans=$withval],
   17:     [
   18: 	case "$build" in
   19: 	 $host) ans=yes ;;
   20: 	 *)     ans=no ;;
   21: 	esac
   22:     ]
   23: )
   24: case "$ans" in
   25:  no) 
   26:     ;;
   27:  yes) # Look in:
   28:     ans="/usr/lib /usr/lib/openssl /usr/sfw/lib /usr/local/lib /usr/local/ssl/lib /lib"
   29:     ;;
   30:  *) # Look where they said
   31:     ;;
   32: esac
   33: case "$ans" in
   34:  no)
   35:     ;;
   36:  *) # Look for libcrypto.a and libssl.a:
   37:     for i in $ans no
   38:     do
   39: 	case "$host" in
   40: 	 *-*-darwin*)
   41: 	    test -f $i/libcrypto.dylib -a -f $i/libssl.dylib && break
   42: 	    ;;
   43: 	 *)
   44: 	    test -f $i/libcrypto.so -a -f $i/libssl.so && break
   45: 	    test -f $i/libcrypto.a -a -f $i/libssl.a && break
   46: 	    ;;
   47: 	esac
   48:     done
   49:     case "$i" in
   50:      no)
   51: 	ans=no
   52: 	OPENSSL_LIB=
   53: 	;;
   54:      *) ans=$i
   55: 	OPENSSL_LIB=$ans
   56: 	;;
   57:     esac
   58:     ;;
   59: esac
   60: AC_MSG_RESULT([$ans])
   61: 
   62: AC_MSG_CHECKING([for openssl include directory])
   63: AC_ARG_WITH(
   64:     [openssl-incdir],
   65:     [AS_HELP_STRING(
   66: 	[--with-openssl-incdir],
   67: 	[+ =/something/reasonable]
   68:     )],
   69:     [ans=$withval],
   70:     [
   71: 	case "$build" in
   72: 	 $host) ans=yes ;;
   73: 	 *)     ans=no ;;
   74: 	esac
   75:     ]
   76: )
   77: case "$ans" in
   78:  no)
   79:     ;;
   80:  yes) # look in:
   81:     ans="/usr/include /usr/sfw/include /usr/local/include /usr/local/ssl/include"
   82:     ;;
   83:  *) # Look where they said
   84:     ;;
   85: esac
   86: case "$ans" in
   87:  no)
   88:     ;;
   89:  *) # look for openssl/opensslconf.h:
   90:     for i in $ans no
   91:     do
   92: 	test -f $i/openssl/opensslconf.h && break
   93:     done
   94:     case "$i" in
   95:      no)
   96: 	ans=no
   97: 	OPENSSL_INC=
   98: 	;;
   99:      *) ans=$i
  100: 	OPENSSL_INC=$ans
  101: 	;;
  102:     esac
  103:     ;;
  104: esac
  105: AC_MSG_RESULT([$ans])
  106: 
  107: AC_MSG_CHECKING([if we will use crypto])
  108: AC_ARG_WITH(
  109:     [crypto],
  110:     [AS_HELP_STRING(
  111: 	[--with-crypto],
  112: 	[+ =openssl]
  113:     )],
  114:     [ans=$withval],
  115:     [ans=yes]
  116: )
  117: case "$ans" in
  118:  no)
  119:     ;;
  120:  yes|openssl)
  121:     if test -z "$OPENSSL_LIB" -o -z "$OPENSSL_INC"
  122:     then
  123: 	ans=no
  124:     else
  125: 	ans=yes
  126:     fi
  127: esac
  128: ntp_openssl=$ans
  129: AC_MSG_RESULT([$ans])
  130: 
  131: case "$ntp_openssl" in
  132:  yes)
  133:     # We have OpenSSL inc/lib - use them.
  134:     case "$OPENSSL_INC" in
  135:      /usr/include)
  136: 	;;
  137:      *)	
  138: 	CPPFLAGS="$CPPFLAGS -I$OPENSSL_INC"
  139: 	;;
  140:     esac
  141:     case "$OPENSSL_LIB" in
  142:      /usr/lib)
  143: 	;;
  144:      *)	
  145: 	LDFLAGS="$LDFLAGS -L$OPENSSL_LIB"
  146: 	case "$need_dash_r" in
  147: 	 1)
  148: 	    LDFLAGS="$LDFLAGS -R$OPENSSL_LIB"
  149: 	esac
  150: 	;;
  151:     esac
  152:     AC_SUBST([LCRYPTO], [-lcrypto])
  153:     AC_DEFINE([OPENSSL], [1], [Use OpenSSL?])
  154: esac
  155: 
  156: #
  157: # check for linking with -lcrypto failure, and try -lz -lcrypto.
  158: # Helps m68k-atari-mint
  159: #
  160: case "$ntp_openssl" in
  161:  yes)
  162:     NTPO_SAVED_LIBS="$LIBS"
  163:     LIBS="$NTPO_SAVED_LIBS $LCRYPTO"
  164:     AC_CACHE_CHECK(
  165: 	[if linking with $LCRYPTO alone works],
  166: 	[ntp_cv_bare_lcrypto],
  167: 	[AC_LINK_IFELSE(
  168: 	    [AC_LANG_PROGRAM(
  169: 		[[
  170: 		    #include "openssl/err.h"
  171: 		    #include "openssl/evp.h"
  172: 		]],
  173: 		[[
  174: 		    ERR_load_crypto_strings();
  175: 		    OpenSSL_add_all_algorithms();
  176: 		]]
  177: 	    )],
  178: 	    [ntp_cv_bare_lcrypto=yes],
  179: 	    [ntp_cv_bare_lcrypto=no]
  180: 	)]
  181:     )
  182:     case "$ntp_cv_bare_lcrypto" in
  183:      no)
  184: 	LIBS="$NTPO_SAVED_LIBS $LCRYPTO -lz"
  185: 	AC_CACHE_CHECK(
  186: 	    [if linking with $LCRYPTO -lz works],
  187: 	    [ntp_cv_lcrypto_lz],
  188: 	    [AC_LINK_IFELSE(
  189: 		[AC_LANG_PROGRAM(
  190: 		    [[
  191: 			#include "openssl/err.h"
  192: 			#include "openssl/evp.h"
  193: 		    ]],
  194: 		    [[
  195: 			ERR_load_crypto_strings();
  196: 			OpenSSL_add_all_algorithms();
  197: 		    ]]
  198: 		)],
  199: 		[ntp_cv_lcrypto_lz=yes],
  200: 		[ntp_cv_lcrypto_lz=no]
  201: 	    )]
  202: 	)
  203: 	case "$ntp_cv_lcrypto_lz" in
  204: 	 yes)
  205: 	     LCRYPTO="$LCRYPTO -lz"
  206: 	esac
  207:     esac
  208:     LIBS="$NTPO_SAVED_LIBS"
  209:     AS_UNSET([NTPO_SAVED_LIBS])
  210: esac
  211: 
  212: #
  213: # Older OpenSSL headers have a number of callback prototypes inside
  214: # other function prototypes which trigger copious warnings with gcc's
  215: # -Wstrict-prototypes, which is included in -Wall.
  216: #
  217: # An example:
  218: #
  219: # int i2d_RSA_NET(const RSA *a, unsigned char **pp, 
  220: #		  int (*cb)(), int sgckey);
  221: #		  ^^^^^^^^^^^
  222: #
  223: # 
  224: #
  225: openssl_triggers_warnings=unknown
  226: SAVED_CFLAGS="$CFLAGS"
  227: 
  228: case "$GCC$ntp_openssl" in
  229:  yesyes)
  230:     CFLAGS="$CFLAGS -Werror"
  231:     AC_COMPILE_IFELSE(
  232: 	[AC_LANG_PROGRAM(
  233: 	    [[
  234: 	    ]],
  235: 	    [[
  236: 		/* see if -Werror breaks gcc */
  237: 	    ]]
  238: 	)],
  239: 	[gcc_handles_Werror=yes],
  240: 	[gcc_handles_Werror=no]
  241:     )
  242:     case "$gcc_handles_Werror" in
  243:      no)
  244: 	# if this gcc doesn't do -Werror go ahead and use
  245: 	# -Wstrict-prototypes.
  246: 	openssl_triggers_warnings=yes
  247: 	;;
  248:      yes)
  249: 	CFLAGS="$CFLAGS -Wstrict-prototypes"
  250: 	AC_COMPILE_IFELSE(
  251: 	    [AC_LANG_PROGRAM(
  252: 		[[
  253: 		    #include "openssl/asn1_mac.h"
  254: 		    #include "openssl/bn.h"
  255: 		    #include "openssl/err.h"
  256: 		    #include "openssl/evp.h"
  257: 		    #include "openssl/pem.h"
  258: 		    #include "openssl/rand.h"
  259: 		    #include "openssl/x509v3.h"
  260: 		]],
  261: 		[[
  262: 		    /* empty body */
  263: 		]]
  264: 	    )],
  265: 	    [openssl_triggers_warnings=no],
  266: 	    [openssl_triggers_warnings=yes]
  267: 	)
  268:     esac
  269:     case "$openssl_triggers_warnings" in
  270:      yes)
  271: 	CFLAGS="$SAVED_CFLAGS -Wno-strict-prototypes"
  272: 	;;
  273:      *)
  274: 	CFLAGS="$SAVED_CFLAGS -Wstrict-prototypes"
  275:     esac
  276:     ;;
  277:  yesno)
  278:     # gcc without OpenSSL
  279:     CFLAGS="$SAVED_CFLAGS -Wstrict-prototypes"
  280: esac
  281: 
  282: ])
  283: dnl ======================================================================
  284: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>