configure.ac 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf and autoheader to produce a configure script.
  3. # This Autoconf file was cobbled from various locations. In particular, a bunch
  4. # of the platform checks have been taken straight from OpenSSH's configure.ac
  5. # Huge thanks to them for dealing with the horrible platform-specifics :)
  6. AC_PREREQ([2.59])
  7. AC_INIT
  8. AC_CONFIG_SRCDIR(buffer.c)
  9. # Record which revision is being built
  10. if test -s "`which hg`" && test -d "$srcdir/.hg"; then
  11. hgrev=`hg id -i -R "$srcdir"`
  12. AC_MSG_NOTICE([Source directory Mercurial base revision $hgrev])
  13. fi
  14. ORIGCFLAGS="$CFLAGS"
  15. LATE_CFLAGS=""
  16. # Checks for programs.
  17. AC_PROG_CC
  18. if test -z "$LD" ; then
  19. LD=$CC
  20. fi
  21. AC_SUBST(LD)
  22. AC_DEFUN(DB_TRYADDCFLAGS,
  23. [{
  24. OLDFLAGS="$CFLAGS"
  25. TESTFLAGS="$1"
  26. CFLAGS="$CFLAGS $TESTFLAGS"
  27. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
  28. [AC_MSG_NOTICE([Setting $TESTFLAGS])],
  29. [AC_MSG_NOTICE([Not setting $TESTFLAGS]); CFLAGS="$OLDFLAGS" ]
  30. )
  31. }])
  32. # set compile flags prior to other tests
  33. if test -z "$ORIGCFLAGS" && test "$GCC" = "yes"; then
  34. AC_MSG_NOTICE(No \$CFLAGS set... using "-Os -W -Wall" for GCC)
  35. CFLAGS="-Os -W -Wall"
  36. fi
  37. AC_MSG_NOTICE([Checking if compiler '$CC' supports -Wno-pointer-sign])
  38. DB_TRYADDCFLAGS([-Wno-pointer-sign])
  39. AC_MSG_NOTICE([Checking if compiler '$CC' supports -fno-strict-overflow])
  40. DB_TRYADDCFLAGS([-fno-strict-overflow])
  41. # needed for various extensions. define early before autoconf tests
  42. AC_DEFINE([_GNU_SOURCE], [], [Use GNU extensions if glibc])
  43. STATIC=0
  44. AC_ARG_ENABLE(static,
  45. [ --enable-static Build static binaries],
  46. [
  47. if test "x$enableval" = "xyes"; then
  48. STATIC=1
  49. AC_MSG_NOTICE(Static Build)
  50. fi
  51. ], [])
  52. AC_SUBST(STATIC)
  53. hardenbuild=1
  54. AC_ARG_ENABLE(harden,
  55. [ --disable-harden Don't set hardened build flags],
  56. [
  57. if test "x$enableval" = "xno"; then
  58. hardenbuild=0
  59. AC_MSG_NOTICE(Disabling hardened build flags)
  60. fi
  61. ], [])
  62. if test "$hardenbuild" -eq 1; then
  63. AC_MSG_NOTICE(Checking for available hardened build flags:)
  64. # relocation flags don't make sense for static builds
  65. if test "$STATIC" -ne 1; then
  66. # pie
  67. DB_TRYADDCFLAGS([-fPIE])
  68. OLDLDFLAGS="$LDFLAGS"
  69. TESTFLAGS="-Wl,-pie"
  70. LDFLAGS="$LDFLAGS $TESTFLAGS"
  71. AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
  72. [AC_MSG_NOTICE([Setting $TESTFLAGS])],
  73. [
  74. LDFLAGS="$OLDLDFLAGS"
  75. TESTFLAGS="-pie"
  76. LDFLAGS="$LDFLAGS $TESTFLAGS"
  77. AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
  78. [AC_MSG_NOTICE([Setting $TESTFLAGS])],
  79. [AC_MSG_NOTICE([Not setting $TESTFLAGS]); LDFLAGS="$OLDLDFLAGS" ]
  80. )
  81. ]
  82. )
  83. # readonly elf relocation sections (relro)
  84. OLDLDFLAGS="$LDFLAGS"
  85. TESTFLAGS="-Wl,-z,now -Wl,-z,relro"
  86. LDFLAGS="$LDFLAGS $TESTFLAGS"
  87. AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
  88. [AC_MSG_NOTICE([Setting $TESTFLAGS])],
  89. [AC_MSG_NOTICE([Not setting $TESTFLAGS]); LDFLAGS="$OLDLDFLAGS" ]
  90. )
  91. fi # non-static
  92. # stack protector. -strong is good but only in gcc 4.9 or later
  93. OLDCFLAGS="$CFLAGS"
  94. TESTFLAGS="-fstack-protector-strong"
  95. CFLAGS="$CFLAGS $TESTFLAGS"
  96. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
  97. [AC_MSG_NOTICE([Setting $TESTFLAGS])],
  98. [
  99. CFLAGS="$OLDCFLAGS"
  100. TESTFLAGS="-fstack-protector --param=ssp-buffer-size=4"
  101. CFLAGS="$CFLAGS $TESTFLAGS"
  102. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
  103. [AC_MSG_NOTICE([Setting $TESTFLAGS])],
  104. [AC_MSG_NOTICE([Not setting $TESTFLAGS]); CFLAGS="$OLDCFLAGS" ]
  105. )
  106. ]
  107. )
  108. # FORTIFY_SOURCE
  109. DB_TRYADDCFLAGS([-D_FORTIFY_SOURCE=2])
  110. # Spectre v2 mitigations
  111. DB_TRYADDCFLAGS([-mfunction-return=thunk])
  112. DB_TRYADDCFLAGS([-mindirect-branch=thunk])
  113. fi
  114. AC_ARG_ENABLE(werror,
  115. [ --enable-werror Set -Werror when building],
  116. [
  117. if test "x$enableval" = "xyes"; then
  118. # -Werror shouldn't be set when configure runs tests.
  119. # We add it to the Makefile's CFLAGS
  120. LATE_CFLAGS+="$LATE_CFLAGS -Werror"
  121. AC_MSG_NOTICE(Enabling -Werror)
  122. fi
  123. ], [])
  124. # large file support is useful for scp
  125. AC_SYS_LARGEFILE
  126. # Host specific options
  127. # this isn't a definitive list of hosts, they are just added as required
  128. AC_CANONICAL_HOST
  129. case "$host" in
  130. *-*-linux*)
  131. no_ptmx_check=1
  132. ;;
  133. *-*-solaris*)
  134. CFLAGS="$CFLAGS -I/usr/local/include"
  135. LDFLAGS="$LDFLAGS -L/usr/local/lib -R/usr/local/lib"
  136. conf_lastlog_location="/var/adm/lastlog"
  137. AC_MSG_CHECKING(for obsolete utmp and wtmp in solaris2.x)
  138. sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'`
  139. if test "$sol2ver" -ge 8; then
  140. AC_MSG_RESULT(yes)
  141. AC_DEFINE(DISABLE_UTMP,1,Disable utmp)
  142. AC_DEFINE(DISABLE_WTMP,1,Disable wtmp)
  143. else
  144. AC_MSG_RESULT(no)
  145. fi
  146. AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
  147. AC_CHECK_LIB(nsl, yp_match, LIBS="$LIBS -lnsl")
  148. ;;
  149. *-*-aix*)
  150. AC_DEFINE(AIX,1,Using AIX)
  151. # OpenSSH thinks it's broken. If it isn't, let me know.
  152. AC_DEFINE(BROKEN_GETADDRINFO,1,Broken getaddrinfo)
  153. ;;
  154. *-*-hpux*)
  155. LIBS="$LIBS -lsec"
  156. # It's probably broken.
  157. AC_DEFINE(BROKEN_GETADDRINFO,1,Broken getaddrinfo)
  158. ;;
  159. *-dec-osf*)
  160. AC_DEFINE(BROKEN_GETADDRINFO,1,Broken getaddrinfo)
  161. ;;
  162. esac
  163. AC_CHECK_TOOL(AR, ar, :)
  164. AC_CHECK_TOOL(RANLIB, ranlib, :)
  165. AC_CHECK_TOOL(STRIP, strip, :)
  166. AC_CHECK_TOOL(INSTALL, install, :)
  167. dnl Can't use login() or logout() with uclibc
  168. AC_CHECK_DECL(__UCLIBC__,
  169. [
  170. no_loginfunc_check=1
  171. AC_MSG_NOTICE([Using uClibc - login() and logout() probably don't work, so we won't use them.])
  172. ],,)
  173. dnl We test for crypt() specially. On Linux (and others?) it resides in libcrypt
  174. dnl but we don't want link all binaries to -lcrypt, just dropbear server.
  175. dnl OS X doesn't need -lcrypt
  176. AC_CHECK_FUNC(crypt, found_crypt_func=here)
  177. AC_CHECK_LIB(crypt, crypt,
  178. [
  179. CRYPTLIB="-lcrypt"
  180. found_crypt_func=here
  181. ])
  182. AC_SUBST(CRYPTLIB)
  183. if test "t$found_crypt_func" = there; then
  184. AC_DEFINE(HAVE_CRYPT, 1, [crypt() function])
  185. fi
  186. # Check if zlib is needed
  187. AC_ARG_WITH(zlib,
  188. [ --with-zlib=PATH Use zlib in PATH],
  189. [
  190. # option is given
  191. if test -d "$withval/lib"; then
  192. LDFLAGS="-L${withval}/lib ${LDFLAGS}"
  193. else
  194. LDFLAGS="-L${withval} ${LDFLAGS}"
  195. fi
  196. if test -d "$withval/include"; then
  197. CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
  198. else
  199. CPPFLAGS="-I${withval} ${CPPFLAGS}"
  200. fi
  201. ]
  202. )
  203. AC_ARG_ENABLE(zlib,
  204. [ --disable-zlib Don't include zlib support],
  205. [
  206. if test "x$enableval" = "xno"; then
  207. AC_DEFINE(DISABLE_ZLIB,1,Use zlib)
  208. AC_MSG_NOTICE(Disabling zlib)
  209. else
  210. AC_CHECK_LIB(z, deflate, , AC_MSG_ERROR([*** zlib missing - install first or check config.log ***]))
  211. AC_MSG_NOTICE(Enabling zlib)
  212. fi
  213. ],
  214. [
  215. # if not disabled, check for zlib
  216. AC_CHECK_LIB(z, deflate, , AC_MSG_ERROR([*** zlib missing - install first or check config.log ***]))
  217. AC_MSG_NOTICE(Enabling zlib)
  218. ]
  219. )
  220. # Check if pam is needed
  221. AC_ARG_WITH(pam,
  222. [ --with-pam=PATH Use pam in PATH],
  223. [
  224. # option is given
  225. if test -d "$withval/lib"; then
  226. LDFLAGS="-L${withval}/lib ${LDFLAGS}"
  227. else
  228. LDFLAGS="-L${withval} ${LDFLAGS}"
  229. fi
  230. if test -d "$withval/include"; then
  231. CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
  232. else
  233. CPPFLAGS="-I${withval} ${CPPFLAGS}"
  234. fi
  235. ]
  236. )
  237. AC_ARG_ENABLE(pam,
  238. [ --enable-pam Try to include PAM support],
  239. [
  240. if test "x$enableval" = "xyes"; then
  241. AC_CHECK_LIB(pam, pam_authenticate, , AC_MSG_ERROR([*** PAM missing - install first or check config.log ***]))
  242. AC_MSG_NOTICE(Enabling PAM)
  243. AC_CHECK_FUNCS(pam_fail_delay)
  244. else
  245. AC_DEFINE(DISABLE_PAM,1,Use PAM)
  246. AC_MSG_NOTICE(Disabling PAM)
  247. fi
  248. ],
  249. [
  250. # disable it by default
  251. AC_DEFINE(DISABLE_PAM,1,Use PAM)
  252. AC_MSG_NOTICE(Disabling PAM)
  253. ]
  254. )
  255. AC_ARG_ENABLE(openpty,
  256. [ --disable-openpty Don't use openpty, use alternative method],
  257. [
  258. if test "x$enableval" = "xno"; then
  259. AC_MSG_NOTICE(Not using openpty)
  260. else
  261. AC_MSG_NOTICE(Using openpty if available)
  262. AC_SEARCH_LIBS(openpty, util, [dropbear_cv_func_have_openpty=yes])
  263. fi
  264. ],
  265. [
  266. AC_MSG_NOTICE(Using openpty if available)
  267. AC_SEARCH_LIBS(openpty, util, [dropbear_cv_func_have_openpty=yes])
  268. ]
  269. )
  270. if test "x$dropbear_cv_func_have_openpty" = "xyes"; then
  271. AC_DEFINE(HAVE_OPENPTY,,Have openpty() function)
  272. no_ptc_check=yes
  273. no_ptmx_check=yes
  274. fi
  275. AC_ARG_ENABLE(syslog,
  276. [ --disable-syslog Don't include syslog support],
  277. [
  278. if test "x$enableval" = "xno"; then
  279. AC_DEFINE(DISABLE_SYSLOG,1,Using syslog)
  280. AC_MSG_NOTICE(Disabling syslog)
  281. else
  282. AC_MSG_NOTICE(Enabling syslog)
  283. fi
  284. ],
  285. [
  286. AC_MSG_NOTICE(Enabling syslog)
  287. ]
  288. )
  289. AC_ARG_ENABLE(shadow,
  290. [ --disable-shadow Don't use shadow passwords (if available)],
  291. [
  292. if test "x$enableval" = "xno"; then
  293. AC_MSG_NOTICE(Not using shadow passwords)
  294. else
  295. AC_CHECK_HEADERS([shadow.h])
  296. AC_MSG_NOTICE(Using shadow passwords if available)
  297. fi
  298. ],
  299. [
  300. AC_CHECK_HEADERS([shadow.h])
  301. AC_MSG_NOTICE(Using shadow passwords if available)
  302. ]
  303. )
  304. AC_ARG_ENABLE(plugin,
  305. [ --enable-plugin Enable support for External Public Key Authentication plug-in],
  306. [
  307. AC_DEFINE(DROPBEAR_PLUGIN, 1, External Public Key Authentication)
  308. AC_MSG_NOTICE(Enabling support for External Public Key Authentication)
  309. DROPBEAR_PLUGIN=1
  310. ],
  311. [
  312. AC_DEFINE(DROPBEAR_PLUGIN, 0, External Public Key Authentication)
  313. DROPBEAR_PLUGIN=0
  314. ]
  315. )
  316. AC_SUBST(DROPBEAR_PLUGIN)
  317. AC_ARG_ENABLE(fuzz,
  318. [ --enable-fuzz Build fuzzing. Not recommended for deployment.],
  319. [
  320. if test "x$enableval" = "xyes"; then
  321. AC_DEFINE(DROPBEAR_FUZZ, 1, Fuzzing)
  322. AC_MSG_NOTICE(Enabling fuzzing)
  323. DROPBEAR_FUZZ=1
  324. # libfuzzer needs linking with c++ libraries
  325. AC_PROG_CXX
  326. mkdir -pv fuzz
  327. else
  328. AC_DEFINE(DROPBEAR_FUZZ, 0, Fuzzing)
  329. AC_MSG_NOTICE(Disabling fuzzing)
  330. DROPBEAR_FUZZ=0
  331. fi
  332. ],
  333. [
  334. AC_DEFINE(DROPBEAR_FUZZ, 0, Fuzzing)
  335. AC_MSG_NOTICE(Disabling fuzzing)
  336. DROPBEAR_FUZZ=0
  337. ]
  338. )
  339. AC_SUBST(DROPBEAR_FUZZ)
  340. AC_SUBST(CXX)
  341. # Checks for header files.
  342. AC_HEADER_SYS_WAIT
  343. AC_CHECK_HEADERS([netinet/in.h netinet/tcp.h \
  344. crypt.h \
  345. pty.h libutil.h libgen.h inttypes.h stropts.h utmp.h \
  346. utmpx.h lastlog.h paths.h util.h netdb.h security/pam_appl.h \
  347. pam/pam_appl.h netinet/in_systm.h sys/uio.h linux/pkt_sched.h \
  348. sys/random.h sys/prctl.h])
  349. # Checks for typedefs, structures, and compiler characteristics.
  350. AC_C_CONST
  351. AC_TYPE_UID_T
  352. AC_TYPE_MODE_T
  353. AC_TYPE_PID_T
  354. AC_TYPE_SIZE_T
  355. AC_CHECK_TYPES([uint8_t, u_int8_t, uint16_t, u_int16_t, uint32_t, u_int32_t])
  356. AC_CHECK_TYPES([struct sockaddr_storage])
  357. AC_CHECK_TYPE([socklen_t], ,[
  358. AC_MSG_CHECKING([for socklen_t equivalent])
  359. AC_CACHE_VAL([curl_cv_socklen_t_equiv],
  360. [
  361. # Systems have either "struct sockaddr *" or
  362. # "void *" as the second argument to getpeername
  363. curl_cv_socklen_t_equiv=
  364. for arg2 in "struct sockaddr" void; do
  365. for t in int size_t unsigned long "unsigned long"; do
  366. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  367. #include <sys/types.h>
  368. #include <sys/socket.h>
  369. int getpeername (int, $arg2 *, $t *);
  370. ]],[[
  371. $t len;
  372. getpeername(0,0,&len);
  373. ]])],[
  374. curl_cv_socklen_t_equiv="$t"
  375. break
  376. ])
  377. done
  378. done
  379. if test "x$curl_cv_socklen_t_equiv" = x; then
  380. AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
  381. fi
  382. ])
  383. AC_MSG_RESULT($curl_cv_socklen_t_equiv)
  384. AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
  385. [type to use in place of socklen_t if not defined])],
  386. [#include <sys/types.h>
  387. #include <sys/socket.h>])
  388. # for the fake-rfc2553 stuff - straight from OpenSSH
  389. AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
  390. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  391. #include <sys/types.h>
  392. #include <sys/socket.h>
  393. ]],
  394. [[ if (sizeof(struct sockaddr_storage)) return 0 ]])],
  395. [ ac_cv_have_struct_sockaddr_storage="yes" ],
  396. [ ac_cv_have_struct_sockaddr_storage="no" ]
  397. )
  398. ])
  399. if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
  400. AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE)
  401. fi
  402. AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
  403. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  404. #include <sys/types.h>
  405. #include <netinet/in.h>
  406. ]],
  407. [[ if (sizeof(struct sockaddr_in6)) return 0 ]])],
  408. [ ac_cv_have_struct_sockaddr_in6="yes" ],
  409. [ ac_cv_have_struct_sockaddr_in6="no" ]
  410. )
  411. ])
  412. if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
  413. AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6,1,Have struct sockaddr_in6)
  414. fi
  415. AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
  416. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  417. #include <sys/types.h>
  418. #include <netinet/in.h>
  419. ]],
  420. [[ if (sizeof(struct in6_addr)) return 0 ]])],
  421. [ ac_cv_have_struct_in6_addr="yes" ],
  422. [ ac_cv_have_struct_in6_addr="no" ]
  423. )
  424. ])
  425. if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
  426. AC_DEFINE(HAVE_STRUCT_IN6_ADDR,1,Have struct in6_addr)
  427. fi
  428. AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
  429. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  430. #include <sys/types.h>
  431. #include <sys/socket.h>
  432. #include <netdb.h>
  433. ]],
  434. [[ if (sizeof(struct addrinfo)) return 0 ]])],
  435. [ ac_cv_have_struct_addrinfo="yes" ],
  436. [ ac_cv_have_struct_addrinfo="no" ]
  437. )
  438. ])
  439. if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
  440. AC_DEFINE(HAVE_STRUCT_ADDRINFO,1,Have struct addrinfo)
  441. fi
  442. # IRIX has a const char return value for gai_strerror()
  443. AC_CHECK_FUNCS(gai_strerror,[
  444. AC_DEFINE(HAVE_GAI_STRERROR)
  445. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  446. #include <sys/types.h>
  447. #include <sys/socket.h>
  448. #include <netdb.h>
  449. const char *gai_strerror(int);]],[[
  450. char *str;
  451. str = gai_strerror(0);]])],[
  452. AC_DEFINE(HAVE_CONST_GAI_STRERROR_PROTO, 1,
  453. [Define if gai_strerror() returns const char *])])])
  454. # for loginrec.c
  455. AC_CHECK_MEMBERS([struct utmp.ut_host, struct utmp.ut_pid, struct utmp.ut_type, struct utmp.ut_tv, struct utmp.ut_id, struct utmp.ut_addr, struct utmp.ut_addr_v6, struct utmp.ut_exit, struct utmp.ut_time],,,[
  456. #include <sys/types.h>
  457. #if HAVE_UTMP_H
  458. #include <utmp.h>
  459. #endif
  460. ])
  461. AC_CHECK_MEMBERS([struct utmpx.ut_host, struct utmpx.ut_syslen, struct utmpx.ut_type, struct utmpx.ut_id, struct utmpx.ut_addr, struct utmpx.ut_addr_v6, struct utmpx.ut_time, struct utmpx.ut_tv],,,[
  462. #include <sys/types.h>
  463. #include <sys/socket.h>
  464. #if HAVE_UTMPX_H
  465. #include <utmpx.h>
  466. #endif
  467. ])
  468. AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family],,,[
  469. #include <sys/types.h>
  470. #include <sys/socket.h>
  471. ])
  472. AC_CHECK_FUNCS(endutent getutent getutid getutline pututline setutent)
  473. AC_CHECK_FUNCS(utmpname)
  474. AC_CHECK_FUNCS(endutxent getutxent getutxid getutxline pututxline )
  475. AC_CHECK_FUNCS(setutxent utmpxname)
  476. AC_CHECK_FUNCS(logout updwtmp logwtmp)
  477. # POSIX monotonic time
  478. AC_CHECK_FUNCS(clock_gettime)
  479. # OS X monotonic time
  480. AC_CHECK_HEADERS([mach/mach_time.h])
  481. AC_CHECK_FUNCS(mach_absolute_time)
  482. AC_CHECK_FUNCS(explicit_bzero memset_s getrandom)
  483. AC_ARG_ENABLE(bundled-libtom,
  484. [ --enable-bundled-libtom Force using bundled libtomcrypt/libtommath even if a system version exists.
  485. --disable-bundled-libtom Force using system libtomcrypt/libtommath, fail if it does not exist.
  486. Default is to use system if available, otherwise bundled.
  487. Dropbear requires system libtommath >= 1.2.0 and libtomcrypt >= 1.18.0],
  488. [
  489. if test "x$enableval" = "xyes"; then
  490. BUNDLED_LIBTOM=1
  491. AC_MSG_NOTICE(Forcing bundled libtom*)
  492. else
  493. BUNDLED_LIBTOM=0
  494. AC_CHECK_LIB(tommath, mp_to_ubin, LIBTOM_LIBS="-ltommath $LIBTOM_LIBS",
  495. [AC_MSG_ERROR([Missing/old system libtommath and --disable-bundled-libtom was specified])] )
  496. AC_CHECK_LIB(tomcrypt, poly1305_init, LIBTOM_LIBS="-ltomcrypt $LIBTOM_LIBS",
  497. [AC_MSG_ERROR([Missing/old system libtomcrypt and --disable-bundled-libtom was specified])] )
  498. fi
  499. ],
  500. [
  501. BUNDLED_LIBTOM=0
  502. AC_CHECK_LIB(tommath, mp_to_ubin, LIBTOM_LIBS="-ltommath $LIBTOM_LIBS", BUNDLED_LIBTOM=1)
  503. AC_CHECK_LIB(tomcrypt, poly1305_init, LIBTOM_LIBS="-ltomcrypt $LIBTOM_LIBS", BUNDLED_LIBTOM=1)
  504. ]
  505. )
  506. if test $BUNDLED_LIBTOM = 1 ; then
  507. AC_DEFINE(BUNDLED_LIBTOM,1,Use bundled libtom)
  508. fi
  509. AC_SUBST(LIBTOM_LIBS)
  510. AC_SUBST(BUNDLED_LIBTOM)
  511. dnl Added from OpenSSH 3.6.1p2's configure.ac
  512. dnl allow user to disable some login recording features
  513. AC_ARG_ENABLE(lastlog,
  514. [ --disable-lastlog Disable use of lastlog even if detected [no]],
  515. [
  516. if test "x$enableval" = "xno" ; then
  517. AC_DEFINE(DISABLE_LASTLOG,1,Disable use of lastlog())
  518. fi
  519. ]
  520. )
  521. AC_ARG_ENABLE(utmp,
  522. [ --disable-utmp Disable use of utmp even if detected [no]],
  523. [
  524. if test "x$enableval" = "xno" ; then
  525. AC_DEFINE(DISABLE_UTMP,1,Disable use of utmp)
  526. fi
  527. ]
  528. )
  529. AC_ARG_ENABLE(utmpx,
  530. [ --disable-utmpx Disable use of utmpx even if detected [no]],
  531. [
  532. if test "x$enableval" = "xno" ; then
  533. AC_DEFINE(DISABLE_UTMPX,1,Disable use of utmpx)
  534. fi
  535. ]
  536. )
  537. AC_ARG_ENABLE(wtmp,
  538. [ --disable-wtmp Disable use of wtmp even if detected [no]],
  539. [
  540. if test "x$enableval" = "xno" ; then
  541. AC_DEFINE(DISABLE_WTMP,1,Disable use of wtmp)
  542. fi
  543. ]
  544. )
  545. AC_ARG_ENABLE(wtmpx,
  546. [ --disable-wtmpx Disable use of wtmpx even if detected [no]],
  547. [
  548. if test "x$enableval" = "xno" ; then
  549. AC_DEFINE(DISABLE_WTMPX,1,Disable use of wtmpx)
  550. fi
  551. ]
  552. )
  553. AC_ARG_ENABLE(loginfunc,
  554. [ --disable-loginfunc Disable use of login() etc. [no]],
  555. [ no_loginfunc_check=1
  556. AC_MSG_NOTICE([Not using login() etc]) ]
  557. )
  558. AC_ARG_ENABLE(pututline,
  559. [ --disable-pututline Disable use of pututline() etc. ([uw]tmp) [no]],
  560. [
  561. if test "x$enableval" = "xno" ; then
  562. AC_DEFINE(DISABLE_PUTUTLINE,1,Disable use of pututline())
  563. fi
  564. ]
  565. )
  566. AC_ARG_ENABLE(pututxline,
  567. [ --disable-pututxline Disable use of pututxline() etc. ([uw]tmpx) [no]],
  568. [
  569. if test "x$enableval" = "xno" ; then
  570. AC_DEFINE(DISABLE_PUTUTXLINE,1,Disable use of pututxline())
  571. fi
  572. ]
  573. )
  574. AC_ARG_WITH(lastlog,
  575. [ --with-lastlog=FILE|DIR specify lastlog location [common locations]],
  576. [
  577. if test "x$withval" = "xno" ; then
  578. AC_DEFINE(DISABLE_LASTLOG)
  579. else
  580. conf_lastlog_location=$withval
  581. fi
  582. ]
  583. )
  584. if test -z "$no_loginfunc_check"; then
  585. dnl Checks for libutil functions (login(), logout() etc, not openpty() )
  586. AC_SEARCH_LIBS(login, util bsd, [AC_DEFINE(HAVE_LOGIN,1,[Have login() function])])
  587. AC_CHECK_FUNCS(logout updwtmp logwtmp)
  588. fi
  589. dnl lastlog, [uw]tmpx? detection
  590. dnl NOTE: set the paths in the platform section to avoid the
  591. dnl need for command-line parameters
  592. dnl lastlog and [uw]tmp are subject to a file search if all else fails
  593. dnl lastlog detection
  594. dnl NOTE: the code itself will detect if lastlog is a directory
  595. AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
  596. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  597. #include <sys/types.h>
  598. #include <utmp.h>
  599. #ifdef HAVE_LASTLOG_H
  600. # include <lastlog.h>
  601. #endif
  602. #ifdef HAVE_PATHS_H
  603. # include <paths.h>
  604. #endif
  605. #ifdef HAVE_LOGIN_H
  606. # include <login.h>
  607. #endif
  608. ]],
  609. [[ char *lastlog = LASTLOG_FILE; ]])],
  610. [ AC_MSG_RESULT(yes) ],
  611. [
  612. AC_MSG_RESULT(no)
  613. AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
  614. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  615. #include <sys/types.h>
  616. #include <utmp.h>
  617. #ifdef HAVE_LASTLOG_H
  618. # include <lastlog.h>
  619. #endif
  620. #ifdef HAVE_PATHS_H
  621. # include <paths.h>
  622. #endif
  623. ]],
  624. [[ char *lastlog = _PATH_LASTLOG; ]])],
  625. [ AC_MSG_RESULT(yes) ],
  626. [
  627. AC_MSG_RESULT(no)
  628. system_lastlog_path=no
  629. ])
  630. ]
  631. )
  632. if test -z "$conf_lastlog_location"; then
  633. if test x"$system_lastlog_path" = x"no" ; then
  634. for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
  635. if (test -d "$f" || test -f "$f") ; then
  636. conf_lastlog_location=$f
  637. fi
  638. done
  639. if test -z "$conf_lastlog_location"; then
  640. AC_MSG_WARN([** Cannot find lastlog **])
  641. dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
  642. fi
  643. fi
  644. fi
  645. if test -n "$conf_lastlog_location"; then
  646. AC_DEFINE_UNQUOTED(CONF_LASTLOG_FILE, "$conf_lastlog_location", lastlog file location)
  647. fi
  648. dnl utmp detection
  649. AC_MSG_CHECKING([if your system defines UTMP_FILE])
  650. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  651. #include <sys/types.h>
  652. #include <utmp.h>
  653. #ifdef HAVE_PATHS_H
  654. # include <paths.h>
  655. #endif
  656. ]],
  657. [[ char *utmp = UTMP_FILE; ]])],
  658. [ AC_MSG_RESULT(yes) ],
  659. [ AC_MSG_RESULT(no)
  660. system_utmp_path=no ]
  661. )
  662. if test -z "$conf_utmp_location"; then
  663. if test x"$system_utmp_path" = x"no" ; then
  664. for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
  665. if test -f $f ; then
  666. conf_utmp_location=$f
  667. fi
  668. done
  669. if test -z "$conf_utmp_location"; then
  670. AC_DEFINE(DISABLE_UTMP)
  671. fi
  672. fi
  673. fi
  674. if test -n "$conf_utmp_location"; then
  675. AC_DEFINE_UNQUOTED(CONF_UTMP_FILE, "$conf_utmp_location", utmp file location)
  676. fi
  677. dnl wtmp detection
  678. AC_MSG_CHECKING([if your system defines WTMP_FILE])
  679. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  680. #include <sys/types.h>
  681. #ifdef HAVE_UTMP_H
  682. # include <utmp.h>
  683. #endif
  684. #ifdef HAVE_PATHS_H
  685. # include <paths.h>
  686. #endif
  687. ]],
  688. [[ char *wtmp = WTMP_FILE; ]])],
  689. [ AC_MSG_RESULT(yes) ],
  690. [ AC_MSG_RESULT(no)
  691. system_wtmp_path=no ]
  692. )
  693. if test -z "$conf_wtmp_location"; then
  694. if test x"$system_wtmp_path" = x"no" ; then
  695. for f in /usr/adm/wtmp /var/log/wtmp; do
  696. if test -f $f ; then
  697. conf_wtmp_location=$f
  698. fi
  699. done
  700. if test -z "$conf_wtmp_location"; then
  701. AC_DEFINE(DISABLE_WTMP)
  702. fi
  703. fi
  704. fi
  705. if test -n "$conf_wtmp_location"; then
  706. AC_DEFINE_UNQUOTED(CONF_WTMP_FILE, "$conf_wtmp_location", wtmp file location)
  707. fi
  708. dnl utmpx detection - I don't know any system so perverse as to require
  709. dnl utmpx, but not define UTMPX_FILE (ditto wtmpx.) No doubt it's out
  710. dnl there, though.
  711. AC_MSG_CHECKING([if your system defines UTMPX_FILE])
  712. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  713. #include <sys/types.h>
  714. #include <utmp.h>
  715. #ifdef HAVE_UTMPX_H
  716. #include <utmpx.h>
  717. #endif
  718. #ifdef HAVE_PATHS_H
  719. # include <paths.h>
  720. #endif
  721. ]],
  722. [[ char *utmpx = UTMPX_FILE; ]])],
  723. [ AC_MSG_RESULT(yes) ],
  724. [ AC_MSG_RESULT(no)
  725. system_utmpx_path=no ]
  726. )
  727. if test -z "$conf_utmpx_location"; then
  728. if test x"$system_utmpx_path" = x"no" ; then
  729. AC_DEFINE(DISABLE_UTMPX)
  730. fi
  731. else
  732. AC_DEFINE_UNQUOTED(CONF_UTMPX_FILE, "$conf_utmpx_location", utmpx file location)
  733. fi
  734. dnl wtmpx detection
  735. AC_MSG_CHECKING([if your system defines WTMPX_FILE])
  736. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  737. #include <sys/types.h>
  738. #ifdef HAVE_UTMP_H
  739. # include <utmp.h>
  740. #endif
  741. #ifdef HAVE_UTMPX_H
  742. # include <utmpx.h>
  743. #endif
  744. #ifdef HAVE_PATHS_H
  745. # include <paths.h>
  746. #endif
  747. ]],
  748. [[ char *wtmpx = WTMPX_FILE; ]])],
  749. [ AC_MSG_RESULT(yes) ],
  750. [ AC_MSG_RESULT(no)
  751. system_wtmpx_path=no ]
  752. )
  753. if test -z "$conf_wtmpx_location"; then
  754. if test x"$system_wtmpx_path" = x"no" ; then
  755. AC_DEFINE(DISABLE_WTMPX)
  756. fi
  757. else
  758. AC_DEFINE_UNQUOTED(CONF_WTMPX_FILE, "$conf_wtmpx_location", wtmpx file location)
  759. fi
  760. # Checks for library functions.
  761. AC_PROG_GCC_TRADITIONAL
  762. AC_FUNC_MEMCMP
  763. AC_FUNC_SELECT_ARGTYPES
  764. AC_CHECK_FUNCS([getpass getspnam getusershell putenv])
  765. AC_CHECK_FUNCS([clearenv strlcpy strlcat daemon basename _getpty getaddrinfo ])
  766. AC_CHECK_FUNCS([freeaddrinfo getnameinfo fork writev getgrouplist fexecve])
  767. AC_SEARCH_LIBS(basename, gen, AC_DEFINE(HAVE_BASENAME))
  768. # Solaris needs ptmx
  769. if test -z "$no_ptmx_check" ; then
  770. if test x"$cross_compiling" = x"no" ; then
  771. if test -e /dev/ptmx ; then
  772. AC_DEFINE(USE_DEV_PTMX,1,Use /dev/ptmx)
  773. fi
  774. else
  775. AC_MSG_NOTICE([Not checking for /dev/ptmx, we're cross-compiling])
  776. fi
  777. fi
  778. if test -z "$no_ptc_check" ; then
  779. if test x"$cross_compiling" = x"no" ; then
  780. if test -e /dev/ptc ; then
  781. AC_DEFINE(HAVE_DEV_PTS_AND_PTC,1,Use /dev/ptc & /dev/pts)
  782. fi
  783. else
  784. AC_MSG_NOTICE([Not checking for /dev/ptc & /dev/pts since we're cross-compiling])
  785. fi
  786. fi
  787. AC_EXEEXT
  788. if test $BUNDLED_LIBTOM = 1 ; then
  789. (cd $srcdir; find libtomcrypt -type d) | xargs mkdir -pv
  790. LIBTOM_FILES="libtomcrypt/Makefile libtommath/Makefile"
  791. fi
  792. # flags that should be set in Makefile but not for configure tests
  793. CFLAGS="$CFLAGS $LATE_CFLAGS"
  794. AC_CONFIG_HEADERS([config.h])
  795. AC_CONFIG_FILES(Makefile $LIBTOM_FILES test/Makefile)
  796. AC_OUTPUT
  797. AC_MSG_NOTICE()
  798. if test $BUNDLED_LIBTOM = 1 ; then
  799. AC_MSG_NOTICE([Using bundled libtomcrypt and libtommath])
  800. else
  801. AC_MSG_NOTICE([Using system libtomcrypt and libtommath])
  802. fi
  803. if test "x$ac_cv_func_getpass" != xyes; then
  804. AC_MSG_NOTICE()
  805. AC_MSG_NOTICE([getpass() not available, dbclient will only have public-key authentication])
  806. fi
  807. if test "t$found_crypt_func" != there; then
  808. AC_MSG_NOTICE()
  809. AC_MSG_NOTICE([crypt() not available, dropbear server will not have password authentication])
  810. fi
  811. AC_MSG_NOTICE()
  812. AC_MSG_NOTICE([Now edit localoptions.h to choose features.])