configure.in 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251
  1. dnl Process this file with autoconf to produce a configure script.
  2. dnl
  3. dnl Written by and Copyright (C) 2001-2020 the
  4. dnl Privoxy team. https://www.privoxy.org/
  5. dnl
  6. dnl Based on the Internet Junkbuster originally written
  7. dnl by and Copyright (C) 1997 Anonymous Coders and
  8. dnl Junkbusters Corporation. http://www.junkbusters.com
  9. dnl
  10. dnl This program is free software; you can redistribute it
  11. dnl and/or modify it under the terms of the GNU General
  12. dnl Public License as published by the Free Software
  13. dnl Foundation; either version 2 of the License, or (at
  14. dnl your option) any later version.
  15. dnl
  16. dnl This program is distributed in the hope that it will
  17. dnl be useful, but WITHOUT ANY WARRANTY; without even the
  18. dnl implied warranty of MERCHANTABILITY or FITNESS FOR A
  19. dnl PARTICULAR PURPOSE. See the GNU General Public
  20. dnl License for more details.
  21. dnl
  22. dnl The GNU General Public License should be included with
  23. dnl this file. If not, you can view it at
  24. dnl http://www.gnu.org/copyleft/gpl.html
  25. dnl or write to the Free Software Foundation, Inc., 59
  26. dnl Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  27. dnl
  28. dnl =================================================================
  29. dnl AutoConf Initialization
  30. dnl =================================================================
  31. AC_REVISION($Revision: 1.213 $)
  32. AC_INIT(jcc.c)
  33. if test ! -f config.h.in; then
  34. echo "You need to run autoheader first. "
  35. echo -n "Shall I do this for you now? (y/n) "
  36. read answer
  37. if test "$answer" != "y"; then
  38. exit 1
  39. else
  40. autoheader
  41. fi
  42. fi
  43. AC_CONFIG_HEADER([config.h])
  44. AC_CANONICAL_HOST
  45. dodk=auto
  46. DKPREFIX=none
  47. AC_ARG_WITH(docbook, dnl
  48. --with-docbook=[[yes|no|directory]]
  49. Enable docbook documentation creation
  50. (default = yes, for gnu and linux),[dnl
  51. case "$with_docbook" in
  52. yes) dodk=yes;;
  53. no) dodk=no;;
  54. *)
  55. dodk=yes
  56. DKPREFIX=$withval
  57. ;;
  58. esac
  59. ])
  60. DB2HTML=false
  61. AC_ARG_WITH(db2html, dnl
  62. --with-db2html=<path/executable>
  63. Set the location of the docbook to html converter
  64. (default = search),[dnl
  65. DB2HTML=$withval
  66. ])
  67. dnl =================================================================
  68. dnl Application version number
  69. dnl =================================================================
  70. VERSION_MAJOR=3
  71. VERSION_MINOR=0
  72. VERSION_POINT=29
  73. CODE_STATUS="stable"
  74. dnl Timestamp (date +%s) used by the mtree-spec target.
  75. dnl Should be updated before releases but forgetting it isn't critical.
  76. SOURCE_DATE_EPOCH=1605695571
  77. dnl CODE_STATUS can be "alpha", "beta", "stable" or "UNRELEASED",
  78. dnl and will be used for CGI output. Increment version number and
  79. dnl set status to "UNRELEASED" whenever CVS differs from the last
  80. dnl release and no new release is near.
  81. dnl =================================================================
  82. dnl Substitute the version numbers
  83. dnl =================================================================
  84. AC_SUBST(VERSION_MAJOR)
  85. AC_SUBST(VERSION_MINOR)
  86. AC_SUBST(VERSION_POINT)
  87. AC_SUBST(CODE_STATUS)
  88. AC_SUBST(SOURCE_DATE_EPOCH)
  89. dnl
  90. AC_DEFINE_UNQUOTED(VERSION_MAJOR,${VERSION_MAJOR})
  91. AC_DEFINE_UNQUOTED(VERSION_MINOR,${VERSION_MINOR})
  92. AC_DEFINE_UNQUOTED(VERSION_POINT,${VERSION_POINT})
  93. AC_DEFINE_UNQUOTED(VERSION,"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_POINT}")
  94. AC_DEFINE_UNQUOTED(CODE_STATUS,"${CODE_STATUS}")
  95. dnl =================================================================
  96. dnl Checks for programs needed to build.
  97. dnl =================================================================
  98. dnl Keep AC_PROG_CC from setting its own defaults:
  99. if test "X$CFLAGS" = "X"; then
  100. CFLAGS=" "
  101. fi
  102. AC_PROG_CC
  103. AC_PROG_CPP
  104. AC_PROG_INSTALL
  105. AC_PROG_LN_S
  106. AC_PROG_MAKE_SET
  107. AC_PROG_AWK
  108. AC_CHECK_PROG(GDB,gdb,yes,no)
  109. AC_PATH_PROG(BGROUPS,groups,no,$PATH:/bin:/usr/bin:/usr/local/bin)
  110. AC_PATH_PROG(ID,id,no,$PATH:/bin:/usr/bin:/usr/local/bin)
  111. AC_SUBST(ID)
  112. AC_SUBST(BGROUPS)
  113. dnl =================================================================
  114. dnl debug, gcc and gdb support
  115. dnl =================================================================
  116. AC_ARG_WITH(debug,
  117. [ --with-debug Enable debug mode],
  118. [
  119. if test "x$withval" != "xno" ; then
  120. if test $ac_cv_prog_cc_g = yes; then
  121. if test "$GCC" = yes; then
  122. if test "$GDB"; then
  123. CFLAGS="$CFLAGS -ggdb"
  124. else
  125. CFLAGS="$CFLAGS -g"
  126. fi
  127. CFLAGS="$CFLAGS -Wshadow -Wconversion"
  128. else
  129. CFLAGS="$CFLAGS -g"
  130. fi
  131. fi
  132. fi
  133. ],
  134. [
  135. if test "X$CFLAGS" = "X "; then # if CFLAGS were unset (see above)
  136. if test "$GCC" = yes; then
  137. CFLAGS="-O2"
  138. fi
  139. fi
  140. ]
  141. )
  142. dnl =================================================================
  143. dnl Check for user and group validity
  144. dnl =================================================================
  145. if test "$host_os" = haiku; then
  146. echo "Skipping user and group validity stuff.";
  147. else
  148. $ID privoxy >/dev/null 2>/dev/null
  149. if test $? -ne 0 ; then
  150. AC_MSG_WARN(There is no user 'privoxy' on this system)
  151. fi
  152. AC_MSG_CHECKING([for user])
  153. AC_ARG_WITH(user,
  154. [ --with-user=privoxy Set user under which privoxy will run],
  155. [
  156. if test "x$withval" != "xyes"; then
  157. if test $ID = no ; then
  158. AC_MSG_ERROR(There is no 'id' program on this system)
  159. else
  160. AC_MSG_RESULT($with_user)
  161. $ID $with_user 2>/dev/null >/dev/null
  162. if test $? -eq 0 ; then
  163. USER=$with_user;
  164. else
  165. AC_MSG_ERROR(There is no user '$with_user' on this system)
  166. fi
  167. fi
  168. else
  169. AC_MSG_ERROR(We need a user if you give me this parameter)
  170. fi
  171. ],
  172. [
  173. if test $ID = no ; then
  174. AC_MSG_ERROR(There is no 'id' programm on this system)
  175. else
  176. AC_MSG_RESULT(none specified)
  177. USER=$with_user
  178. fi
  179. ]
  180. )
  181. AC_SUBST(USER)
  182. AC_MSG_CHECKING([for group])
  183. AC_ARG_WITH(group,
  184. [ --with-group=privoxy Set group for privoxy],
  185. [
  186. if test "x$withval" != "xyes"; then
  187. if test $BGROUPS = no ; then
  188. AC_MSG_ERROR(There is no 'groups' program on this system)
  189. else
  190. AC_MSG_RESULT($with_group)
  191. $BGROUPS $USER >/dev/null
  192. if test $? -eq 0 ; then
  193. for i in `$BGROUPS $USER | sed 's/.*: //' 2>/dev/null`; do
  194. if test "x$i" = "x$with_group" ; then
  195. GROUP=$with_group
  196. break
  197. fi
  198. done
  199. if test "x$GROUP" != "x$with_group" ; then
  200. AC_MSG_ERROR(The given value '$withval' does not match group entry)
  201. fi
  202. else
  203. AC_MSG_ERROR(There is no group entry for user '$USER')
  204. fi
  205. fi
  206. else
  207. AC_MSG_ERROR(We need a group if you give me this parameter)
  208. fi
  209. ],
  210. [
  211. if test $BGROUPS = no ; then
  212. AC_MSG_ERROR(There is no 'groups' programm on this system)
  213. else
  214. AC_MSG_RESULT(none specified)
  215. GROUP=$with_group;
  216. fi
  217. ]
  218. )
  219. AC_SUBST(GROUP)
  220. fi
  221. dnl =================================================================
  222. dnl additional gcc flags
  223. dnl =================================================================
  224. dnl
  225. if test "$GCC"; then
  226. if test "$host" != "powerpc-unknown-amigaos"; then
  227. CFLAGS="-pipe $CFLAGS"
  228. fi
  229. fi
  230. dnl =================================================================
  231. dnl Build type
  232. dnl =================================================================
  233. dnl
  234. dnl Must do this first.
  235. dnl
  236. dnl Reason: This sets CFLAGS in order to switch the Cygwin compiler
  237. dnl into Cygwin or MinGW32 modes. Depending on the mode selected,
  238. dnl the compiler will use completely different sets of library
  239. dnl and include files.
  240. dnl
  241. dnl =================================================================
  242. AC_MINGW32
  243. AC_CYGWIN
  244. if test "$MINGW32" = "yes"; then
  245. target_type=mingw
  246. else
  247. if test "$CYGWIN" = "yes"; then
  248. target_type=cygwin
  249. else
  250. target_type=unix
  251. fi
  252. fi
  253. if test $dodk = auto; then
  254. dodk=no
  255. if test $target_type = unix; then
  256. case "$host_os" in
  257. linux* | gnu* | *bsd*)
  258. dodk=yes
  259. ;;
  260. esac
  261. fi
  262. fi
  263. dnl Decide what to do based on target_type
  264. dnl Note: PTHREAD_LIB is always set, even if pthread is disabled.
  265. dnl This is because we don't know yet whether pthread is enabled.
  266. AC_ARG_ENABLE(mingw32,
  267. [ --enable-mingw32 Use mingw32 for a Windows GUI],
  268. [if test $enableval = yes; then
  269. target_type=mingw
  270. fi])
  271. if test $target_type = mingw; then
  272. WIN_ONLY=
  273. CFLAGS="$CFLAGS -DWINVER=0x501"
  274. SPECIAL_CFLAGS="-mwindows"
  275. dnl from the cygwin FAQ: The regular setup allows you to use the -mwindows option
  276. dnl to include a set of the basic libraries user32, gdi32 and comdlg32.
  277. dnl (and also make your program a GUI program instead of a console program)
  278. PTHREAD_LIB=-lpthread
  279. echo "Using mingw32 (Win32 GUI)"
  280. else
  281. WIN_ONLY=#
  282. if test $target_type = cygwin; then
  283. SPECIAL_CFLAGS="-mno-win32"
  284. PTHREAD_LIB=
  285. echo "Using Cygnus (Win32 command line)"
  286. else
  287. SPECIAL_CFLAGS=
  288. PTHREAD_LIB=-lpthread
  289. fi
  290. fi
  291. AC_SUBST(WIN_ONLY)
  292. if test $dodk != no; then
  293. AC_CHECK_PROGS(W3M, w3m, false)
  294. if test "$W3M" = false; then
  295. AC_MSG_WARN(You need w3m to build text documentation.)
  296. fi
  297. if test $DB2HTML = false; then
  298. dnl We need to clean the variable, otherwise AC_CHECK_PROGS
  299. dnl will fail
  300. DB2HTML=""
  301. AC_CHECK_PROGS(DB2HTML,db2html docbook2html,false)
  302. fi
  303. fi
  304. AC_SUBST(W3M)
  305. AC_SUBST(DB2HTML)
  306. dnl If we use rpm, we need to check where %_topdir is
  307. AC_CHECK_PROGS(RPMBIN,rpm,false)
  308. if test $RPMBIN != false; then
  309. RPM_BASE=`rpm --eval "%{_topdir}"`
  310. if test "$RPM_BASE" = ""; then
  311. RPM_BASE=/usr/src/redhat
  312. fi
  313. fi
  314. AC_SUBST(RPM_BASE)
  315. dnl prefer openjade to jade
  316. dnl Check for jade, so we can build the documentation
  317. AC_CHECK_PROGS(JADEBIN,openjade jade,false)
  318. AC_SUBST(JADEBIN)
  319. dnl Prefer OpenSP to SP
  320. dnl ref: https://lists.privoxy.org/pipermail/privoxy-devel/2018-November/000293.html
  321. AC_CHECK_PROGS(NSGMLS,onsgmls nsgmls,false)
  322. AC_SUBST(NSGMLS)
  323. dnl Check for man2html for docs.
  324. AC_CHECK_PROGS(MAN2HTML,man2html,false)
  325. AC_SUBST(MAN2HTML)
  326. dnl Set doc status flag for conditional content inclusions
  327. DOC_STATUS=p-not-stable
  328. if test $CODE_STATUS = stable; then
  329. DOC_STATUS="p-stable"
  330. fi
  331. AC_SUBST(DOC_STATUS)
  332. dnl Checking for the docbook.dsl stylesheet file
  333. dnl It is still not portable (directory slash)
  334. JADECAT=""
  335. if test $dodk = yes; then
  336. if test $DKPREFIX = none; then
  337. for i in /usr/share/sgml/docbook/dsssl-stylesheets \
  338. /usr/share/sgml/docbkdsl /usr/share/sgml/docbook-dsssl \
  339. /usr/local/share/sgml/docbook/dsssl/modular \
  340. /usr/share/sgml/docbook/stylesheet/dsssl/modular/ \
  341. ; do
  342. dnl echo -n does not fly with /bin/sh.
  343. dnl echo -n "checking for $i/html/docbook.dsl..."
  344. AC_MSG_CHECKING([for $i])
  345. if test -f $i/html/docbook.dsl; then
  346. echo "yes"
  347. DKPREFIX=$i
  348. break
  349. else
  350. echo "no"
  351. fi
  352. done
  353. # where are the catalogs?
  354. for i in /usr/share/sgml/CATALOG.docbk30 \
  355. /usr/share/sgml/CATALOG.docbk31 \
  356. /usr/share/sgml/CATALOG.docbk31 \
  357. /usr/local/share/sgml/docbook/2.4.1/docbook.cat \
  358. /usr/local/share/sgml/docbook/3.0/docbook.cat \
  359. /usr/local/share/sgml/docbook/3.1/docbook.cat \
  360. /usr/share/sgml/docbook/dtd/3.1/docbook.cat \
  361. ; do
  362. dnl echo -n "checking for $i..."
  363. AC_MSG_CHECKING([for $i])
  364. if test -f $i; then
  365. echo "yes"
  366. JADECAT="$JADECAT -c $i"
  367. else
  368. echo "no"
  369. fi
  370. done
  371. fi
  372. fi
  373. AC_SUBST(JADECAT)
  374. AC_SUBST(DKPREFIX)
  375. AC_ARG_ENABLE(large-file-support,
  376. [ --enable-large-file-support Define _LARGE_FILES and friends.
  377. Required by some systems to support files larger then 2GB.],
  378. [if test $enableval = yes; then
  379. CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D_LARGEFILE_SOURCE=1"
  380. fi])
  381. AC_ARG_ENABLE(static-linking,
  382. [ --enable-static-linking Use static linking instead of dynamic linking (ie. LDFLAGS=-static)],
  383. [ if test $enableval = yes; then LDFLAGS="$LDFLAGS -static"; fi ])
  384. dnl Save old CFLAGS so we can restore them later, then add SPECIAL_CFLAGS
  385. old_CFLAGS_nospecial=$CFLAGS
  386. CFLAGS="$CFLAGS $SPECIAL_CFLAGS"
  387. # Hack to force AutoConf to use the CFLAGS we just set
  388. dnl Warning: This may break with a future version of Autoconf
  389. dnl Tested with autoconf 2.13
  390. ac_cpp='$CPP $CPPFLAGS $SPECIAL_CFLAGS'
  391. ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
  392. ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
  393. dnl =================================================================
  394. dnl Thread support
  395. dnl =================================================================
  396. AC_CHECK_HEADER(pthread.h, [have_pthread=yes], [have_pthread=no])
  397. AC_ARG_ENABLE(pthread,
  398. [ --disable-pthread Don't use POSIX threads (pthreads)],
  399. [if test $enableval = no; then
  400. # Disable pthreads
  401. if test $have_pthread = yes; then
  402. AC_MSG_WARN([pthreads seem to be available but you are using --disable-pthread.])
  403. AC_MSG_WARN([This is almost always a mistake and can render Privoxy unacceptable slow.])
  404. fi
  405. have_pthread=no
  406. fi])
  407. if test $have_pthread = yes; then
  408. PTHREAD_ONLY=
  409. AC_DEFINE(FEATURE_PTHREAD)
  410. echo Using POSIX threads
  411. if test "$GCC" = "yes"; then
  412. # Set a GCC specific switch:
  413. if test "$target_type" = "unix"; then
  414. ac_jgf_save_CFLAGS=$CFLAGS
  415. CFLAGS="$CFLAGS -pthread"
  416. AC_TRY_LINK([#include <pthread.h>],
  417. [void *p = pthread_create;],
  418. [
  419. # This compiler switch makes GCC on Linux thread-safe
  420. # However, it's not supported on most other OS.
  421. PTHREAD_LIB=
  422. SPECIAL_CFLAGS="-pthread"
  423. ])
  424. CFLAGS=$ac_jgf_save_CFLAGS
  425. fi
  426. fi
  427. else
  428. PTHREAD_ONLY=#
  429. echo Using native threads
  430. fi
  431. AC_SUBST(PTHREAD_ONLY)
  432. dnl =================================================================
  433. dnl On most platforms select() does not support fd numbers above
  434. dnl FD_SETSIZE, as a result Privoxy can't handle more than
  435. dnl approximately FD_SETSIZE/2 client connections.
  436. dnl On some platforms the value can be changed at compile time,
  437. dnl on others it's hardcoded and requires recompilation of the OS.
  438. dnl Only relevant if select() is actually being used.
  439. dnl =================================================================
  440. AC_ARG_WITH(fdsetsize,
  441. [ --with-fdsetsize=n Optimistically redefine FD_SETSIZE with the intend to change the number of connections Privoxy can handle. Dangerous if the platform doesn't support this. Pointless if Privoxy can use poll() instead of select().],
  442. [
  443. if test "x$withval" != "xyes"; then
  444. AC_DEFINE_UNQUOTED(FD_SETSIZE,$with_fdsetsize,[Relevant for select(). Not honoured by all OS.])
  445. echo "Redefining FD_SETSIZE to $with_fdsetsize."
  446. AC_MSG_WARN(On platforms that don't support FD_SETSIZE redefinition it may cause memory corruption.)
  447. else
  448. AC_MSG_ERROR(--with-fdsetsize used without value)
  449. fi
  450. ]
  451. )
  452. dnl =================================================================
  453. dnl Support for thread-safe versions of gethostbyaddr, gethostbyname,
  454. dnl gmtime and localtime
  455. dnl =================================================================
  456. dnl Next line needed to find the gethost*_r functions on Solaris
  457. AC_CHECK_LIB(nsl, gethostbyname)
  458. AC_CHECK_FUNC(gethostbyaddr_r, [
  459. AC_MSG_CHECKING([signature of gethostbyaddr_r])
  460. AC_TRY_COMPILE([
  461. # include <netdb.h>
  462. ], [
  463. struct hostent *h, *hp;
  464. char *a, *b;
  465. int l, bl, t, e;
  466. (void) gethostbyaddr_r(a, l, t, h, b, bl, &hp, &e)
  467. ], [
  468. AC_DEFINE(HAVE_GETHOSTBYADDR_R_8_ARGS)
  469. AC_MSG_RESULT([8 args])
  470. ], [
  471. AC_TRY_COMPILE([
  472. # include <netdb.h>
  473. ], [
  474. struct hostent *h;
  475. char *a, *b;
  476. int l, bl, t, e;
  477. (void) gethostbyaddr_r(a, l, t, h, b, bl, &e)
  478. ], [
  479. AC_DEFINE(HAVE_GETHOSTBYADDR_R_7_ARGS)
  480. AC_MSG_RESULT([7 args])
  481. ], [
  482. AC_TRY_COMPILE([
  483. # include <netdb.h>
  484. ], [
  485. struct hostent_data *d;
  486. struct hostent *h;
  487. char a,
  488. int l, t;
  489. (void) gethostbyaddr_r(a, l, t, h, d)
  490. ], [
  491. AC_DEFINE(HAVE_GETHOSTBYADDR_R_5_ARGS)
  492. AC_MSG_RESULT([5 args])
  493. ], [
  494. AC_MSG_RESULT(unrecognised)
  495. ])
  496. ])
  497. ])
  498. ], [
  499. AC_MSG_RESULT(no)
  500. ])
  501. AC_CHECK_FUNC(gethostbyname_r, [
  502. AC_MSG_CHECKING([signature of gethostbyname_r])
  503. AC_TRY_COMPILE([
  504. # include <netdb.h>
  505. ], [
  506. struct hostent *h, *r;
  507. char *n, *b;
  508. int bl, e;
  509. (void) gethostbyname_r(n, h, b, bl, &r, &e)
  510. ], [
  511. AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARGS)
  512. AC_MSG_RESULT([6 args])
  513. ], [
  514. AC_TRY_COMPILE([
  515. # include <netdb.h>
  516. ], [
  517. struct hostent *h;
  518. char *n, *b;
  519. int bl, e;
  520. (void) gethostbyname_r(n, h, b, bl, &e)
  521. ], [
  522. AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARGS)
  523. AC_MSG_RESULT([5 args])
  524. ], [
  525. AC_TRY_COMPILE([
  526. # include <netdb.h>
  527. ], [
  528. struct hostent_data *d;
  529. struct hostent *h;
  530. char *n,
  531. (void) gethostbyname_r(n, h, d)
  532. ], [
  533. AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARGS)
  534. AC_MSG_RESULT([3 args])
  535. ], [
  536. AC_MSG_RESULT(unrecognised)
  537. ])
  538. ])
  539. ])
  540. ], [
  541. AC_MSG_RESULT(no)
  542. ])
  543. AC_CHECK_FUNC(gmtime_r, [
  544. AC_MSG_CHECKING([signature of gmtime_r])
  545. AC_TRY_COMPILE([
  546. # include <time.h>
  547. ], [
  548. struct time *t;
  549. struct tm *tm;
  550. (void) gmtime_r(t, tm)
  551. ], [
  552. AC_MSG_RESULT(ok)
  553. AC_DEFINE(HAVE_GMTIME_R)
  554. ], [
  555. AC_MSG_RESULT(unrecognised)
  556. ])
  557. ], [
  558. AC_MSG_RESULT(no)
  559. ])
  560. AC_CHECK_FUNC(localtime_r, [
  561. AC_MSG_CHECKING([signature of localtime_r])
  562. AC_TRY_COMPILE([
  563. # include <time.h>
  564. ], [
  565. struct time *t;
  566. struct tm *tm;
  567. (void) localtime_r(t, tm)
  568. ], [
  569. AC_MSG_RESULT(ok)
  570. AC_DEFINE(HAVE_LOCALTIME_R)
  571. ], [
  572. AC_MSG_RESULT(unrecognised)
  573. ])
  574. ], [
  575. AC_MSG_RESULT(no)
  576. ])
  577. dnl =================================================================
  578. dnl Solaris specific
  579. dnl FIXME: Not tested on Solaris yet...
  580. dnl ISFIXED: Have tested it on Solaris, but there are other ways to
  581. dnl make these checks generic, e.g.:
  582. dnl AC_CHECK_FUNC(getsockopt, , AC_CHECK_LIB(socket, getsockopt))
  583. dnl (Moritz Barsnick <moritz@barsnick.net>)
  584. dnl =================================================================
  585. SOCKET_LIB=
  586. case "$host" in
  587. *-solaris*) SOCKET_LIB="-lsocket -lnsl"
  588. AC_DEFINE(__EXTENSIONS__)
  589. if test "$GCC" = "yes"; then
  590. # Set a GCC specific switch:
  591. # This compiler switch makes Solaris thread-safe
  592. PTHREAD_LIB=
  593. SPECIAL_CFLAGS="-pthreads"
  594. else
  595. # What do we do without GCC? Guess this:
  596. SPECIAL_CFLAGS="-D_REENTRANT"
  597. fi
  598. ;;
  599. esac
  600. AC_SUBST(SOCKET_LIB)
  601. dnl =================================================================
  602. dnl Solaris problem, and others perhaps (socklen_t is undefined)
  603. dnl =================================================================
  604. if test $target_type != mingw; then
  605. # i686-w64-mingw32-gcc gets socklen_t define from ws2tcpip.h
  606. AC_MSG_CHECKING([for socklen_t])
  607. AC_EGREP_HEADER(socklen_t, sys/socket.h, AC_MSG_RESULT([yes]),
  608. AC_MSG_RESULT([no])
  609. AC_DEFINE(socklen_t,int,
  610. [ Define to 'int' if <sys/socket.h> doesn't have it. ]))
  611. fi
  612. dnl =================================================================
  613. dnl OS/2 specific
  614. dnl =================================================================
  615. case "$host" in
  616. *-os2-emx*) SOCKET_LIB=-lsocket
  617. ;;
  618. esac
  619. AC_SUBST(SOCKET_LIB)
  620. dnl =================================================================
  621. dnl Mac OSX specific
  622. dnl =================================================================
  623. case "$host" in
  624. *-apple-darwin*) SPECIAL_CFLAGS="-Dunix"
  625. ;;
  626. esac
  627. dnl =================================================================
  628. dnl OpenBSD specific
  629. dnl =================================================================
  630. case "$host" in
  631. *-openbsd*) SPECIAL_CFLAGS="$SPECIAL_CFLAGS -Dunix"
  632. ;;
  633. esac
  634. dnl =================================================================
  635. dnl Haiku specific
  636. dnl =================================================================
  637. if test "$host_os" = haiku; then
  638. # Omit the "-pthread" flag to gcc, even when building with gcc 2.95
  639. SPECIAL_CFLAGS=
  640. # Haiku's pthreads implementation exists in its system library,
  641. # libroot, not in a separate pthreads library
  642. PTHREAD_LIB=
  643. # Networking code exists in libnetwork
  644. SOCKET_LIB=-lnetwork
  645. # Search Haiku's common-library folder to find its pcre and
  646. # pcreposix libraries
  647. LIBS="-L/boot/common/lib $LIBS"
  648. fi
  649. dnl =================================================================
  650. dnl Check for standard compiler stuff
  651. dnl =================================================================
  652. AC_EXEEXT
  653. AC_OBJEXT
  654. AC_HEADER_STDC
  655. AC_HEADER_DIRENT
  656. AC_C_CONST
  657. AC_TYPE_SIZE_T
  658. AC_TYPE_PID_T
  659. AC_HEADER_TIME
  660. AC_STRUCT_TM
  661. AC_CHECK_SIZEOF(int, 4)
  662. AC_CHECK_SIZEOF(char *, 4)
  663. AC_CHECK_SIZEOF(long, 4)
  664. AC_CHECK_SIZEOF(long long, 8)
  665. AC_CHECK_SIZEOF(size_t, 4)
  666. AC_CHECK_SIZEOF(time_t, 8)
  667. dnl Checks for header files.
  668. AC_CHECK_HEADERS([ \
  669. OS.h \
  670. arpa/inet.h \
  671. errno.h \
  672. fcntl.h \
  673. limits.h \
  674. locale.h \
  675. netdb.h \
  676. netinet/in.h \
  677. stddef.h \
  678. stdlib.h \
  679. string.h \
  680. sys/ioctl.h \
  681. sys/socket.h \
  682. sys/time.h \
  683. sys/timeb.h \
  684. sys/wait.h \
  685. unistd.h \
  686. ])
  687. dnl Checks for library functions.
  688. dnl bcopy is for PCRE
  689. AC_CHECK_FUNCS([bcopy])
  690. AC_PROG_GCC_TRADITIONAL
  691. AC_TYPE_SIGNAL
  692. AC_CHECK_FUNCS([ \
  693. access \
  694. arc4random \
  695. atexit \
  696. calloc \
  697. getcwd \
  698. gethostbyaddr \
  699. gethostbyaddr_r \
  700. gethostbyname \
  701. gethostbyname_r \
  702. gettimeofday \
  703. inet_ntoa \
  704. memchr \
  705. memmove \
  706. memset \
  707. nanosleep \
  708. poll \
  709. putenv \
  710. random \
  711. regcomp \
  712. select \
  713. setlocale \
  714. shutdown \
  715. snprintf \
  716. socket \
  717. strchr \
  718. strdup \
  719. strerror \
  720. strftime \
  721. strlcat \
  722. strlcpy \
  723. strptime \
  724. strtoul \
  725. timegm \
  726. tzset \
  727. ])
  728. dnl Checks for RFC 2553 resolver and socket functions
  729. AC_ARG_ENABLE(ipv6-support,
  730. [ --disable-ipv6-support Disable IPv6 support and other RFC-2554-related improvements],
  731. [if test $enableval = yes; then
  732. enable_ipv6_support=yes
  733. fi], enable_ipv6_support=yes)
  734. if test $enable_ipv6_support != yes; then
  735. AC_MSG_WARN([Skipping checks for IPv6 support and other RFC-2554-related improvements.
  736. Due to lock contention, this may result in slower DNS resolution for IPv4 setups, too.])
  737. elif test $target_type = mingw; then
  738. AC_CHECK_LIB(ws2_32, main)
  739. AC_MSG_CHECKING(getaddrinfo in ws2_32)
  740. AC_TRY_LINK(
  741. [
  742. #include<winsock2.h>
  743. #include<windows.h>
  744. #include<ws2tcpip.h>
  745. ],
  746. [getaddrinfo(0,0,0,0)],
  747. have_ws2_32_getaddrinfo=yes
  748. )
  749. AC_MSG_RESULT($have_ws2_32_getaddrinfo)
  750. AC_MSG_CHECKING(getnameinfo in ws2_32)
  751. AC_TRY_LINK(
  752. [
  753. #include<winsock2.h>
  754. #include<windows.h>
  755. #include<ws2tcpip.h>
  756. ],
  757. [getnameinfo(0,0,0,0,0,0,0)],
  758. have_ws2_32_getnameinfo=yes
  759. )
  760. AC_MSG_RESULT($have_ws2_32_getnameinfo)
  761. if test $have_ws2_32_getaddrinfo ; then
  762. if test $have_ws2_32_getnameinfo ; then
  763. AC_DEFINE([HAVE_RFC2553], [1],
  764. [Define if RFC 2553 resolver functions like getaddrinfo(3) and
  765. getnameinfo(3) present])
  766. fi
  767. fi
  768. else
  769. AC_CHECK_FUNC([getaddrinfo],
  770. [AC_CHECK_FUNC([getnameinfo],
  771. [AC_DEFINE([HAVE_RFC2553], [1],
  772. [Define if RFC 2553 resolver functions like getaddrinfo(3) and
  773. getnameinfo(3) present])
  774. ])
  775. ])
  776. fi
  777. dnl =================================================================
  778. dnl Checks for libraries.
  779. dnl =================================================================
  780. dnl Note: Some systems may have the library but not the system header
  781. dnl file, so we must check for both.
  782. dnl Also check for correct version
  783. AC_CHECK_LIB(pcre, pcre_compile, [
  784. AC_CHECK_HEADER(pcre.h, [
  785. AC_EGREP_HEADER(pcre_fullinfo, pcre.h, [have_pcre=yes], [AC_MSG_WARN([[pcre old version installed]]); have_pcre=no])
  786. ], [
  787. AC_CHECK_HEADER(pcre/pcre.h, [
  788. AC_EGREP_HEADER(pcre_fullinfo, pcre/pcre.h, [have_pcre=yes]; [AC_DEFINE(PCRE_H_IN_SUBDIR)], [AC_MSG_WARN([[pcre old version installed]]); have_pcre=no])
  789. ], [have_pcre=no])
  790. ])
  791. ], [have_pcre=no])
  792. AC_CHECK_LIB(pcreposix, regcomp, [
  793. AC_CHECK_HEADER(pcreposix.h, [
  794. AC_EGREP_HEADER(pcreposix_regerror, pcreposix.h, [AC_MSG_WARN([[pcreposix old version installed]]); have_pcreposix=no], [have_pcreposix=yes])
  795. ], [
  796. AC_CHECK_HEADER(pcre/pcreposix.h, [
  797. AC_EGREP_HEADER(pcreposix_regerror, pcre/pcreposix.h, [AC_MSG_WARN([[pcreposix old version installed]]); have_pcreposix=no], [have_pcreposix=yes]; [AC_DEFINE(PCREPOSIX_H_IN_SUBDIR)])
  798. ], [have_pcreposix=no])
  799. ])
  800. ], [have_pcreposix=no], -lpcre)
  801. dnl ================================================================
  802. dnl libpcrs is temporarily disabled.
  803. dnl
  804. dnl Privoxy's own pcrs version fixes some problems that
  805. dnl are present in libpcrs 0.3, the last pcrs release we
  806. dnl know of, and as libpcrs seems to be currently unmaintained
  807. dnl we can't send these fixes upstream.
  808. dnl ================================================================
  809. dnl
  810. dnl AC_CHECK_LIB(pcrs, pcrs_compile, [AC_CHECK_HEADER(pcrs.h, [have_pcrs=yes], [have_pcrs=no])], [have_pcrs=no], -lpcre)
  811. dnl =================================================================
  812. dnl Always defined
  813. dnl =================================================================
  814. AC_DEFINE(__MT__)
  815. dnl =================================================================
  816. dnl Features
  817. dnl =================================================================
  818. AC_ARG_ENABLE(toggle,
  819. [ --disable-toggle Don't support temporary disable],
  820. [if test $enableval = yes; then
  821. AC_DEFINE(FEATURE_TOGGLE)
  822. fi],AC_DEFINE(FEATURE_TOGGLE))
  823. AC_ARG_ENABLE(force,
  824. [ --disable-force Don't allow single-page disable],
  825. [if test $enableval = yes; then
  826. AC_DEFINE(FEATURE_FORCE_LOAD)
  827. fi],AC_DEFINE(FEATURE_FORCE_LOAD))
  828. AC_ARG_ENABLE(fast-redirects,
  829. [ --disable-fast-redirects Don't support fast redirects],
  830. [if test $enableval = yes; then
  831. AC_DEFINE(FEATURE_FAST_REDIRECTS)
  832. fi], AC_DEFINE(FEATURE_FAST_REDIRECTS))
  833. AC_ARG_ENABLE(stats,
  834. [ --disable-stats Don't keep statistics],
  835. [if test $enableval = yes; then
  836. AC_DEFINE(FEATURE_STATISTICS)
  837. fi],AC_DEFINE(FEATURE_STATISTICS))
  838. AC_ARG_ENABLE(extended-statistics,
  839. [ --enable-extended-statistics Gather extended statistics.],
  840. [if test $enableval = yes; then
  841. AC_DEFINE(FEATURE_EXTENDED_STATISTICS)
  842. fi])
  843. AC_ARG_ENABLE(image-blocking,
  844. [ --disable-image-blocking Don't try to figure out whether a request is
  845. for an image or HTML - assume HTML.],
  846. [if test $enableval = yes; then
  847. AC_DEFINE(FEATURE_IMAGE_BLOCKING)
  848. fi],
  849. AC_DEFINE(FEATURE_IMAGE_BLOCKING))
  850. AC_ARG_ENABLE(acl-support,
  851. [ --disable-acl-support Prevents the use of ACLs to control access to
  852. Privoxy by IP address.],
  853. [if test $enableval = yes; then
  854. AC_DEFINE(FEATURE_ACL)
  855. fi],
  856. AC_DEFINE(FEATURE_ACL))
  857. AC_ARG_ENABLE(trust-files,
  858. [ --disable-trust-files Prevents the use of trust files.],
  859. [if test $enableval = yes; then
  860. AC_DEFINE(FEATURE_TRUST)
  861. fi],
  862. AC_DEFINE(FEATURE_TRUST))
  863. AC_ARG_ENABLE(editor,
  864. [ --disable-editor Prevents the use of the web-based actions file
  865. editor and web-based temporary disable setting.],
  866. [if test $enableval = yes; then
  867. AC_DEFINE(FEATURE_CGI_EDIT_ACTIONS)
  868. fi],
  869. AC_DEFINE(FEATURE_CGI_EDIT_ACTIONS))
  870. AC_ARG_ENABLE(no-gifs,
  871. [ --enable-no-gifs Use politically correct PNG format instead of GIF
  872. for built-in images. May not work with all browsers.],
  873. [if test $enableval = yes; then
  874. AC_DEFINE(FEATURE_NO_GIFS)
  875. fi])
  876. AC_ARG_ENABLE(graceful-termination,
  877. [ --enable-graceful-termination Allow to shutdown Privoxy through the webinterface.],
  878. [if test $enableval = yes; then
  879. AC_DEFINE(FEATURE_GRACEFUL_TERMINATION)
  880. fi])
  881. AC_ARG_ENABLE(pcre-host-patterns,
  882. [ --enable-pcre-host-patterns Allow to use PCRE syntax in host patterns by prefixing the pattern with
  883. "PCRE-HOST-PATTERN:". You can use tools/url-pattern-translator.pl to
  884. convert existing action files to use PCRE host patterns.],
  885. [if test $enableval = yes; then
  886. AC_DEFINE(FEATURE_PCRE_HOST_PATTERNS)
  887. fi])
  888. AC_ARG_ENABLE(external-filters,
  889. [ --enable-external-filters Allow to filter content with scripts and programs. Experimental.],
  890. [if test $enableval = yes; then
  891. AC_DEFINE(FEATURE_EXTERNAL_FILTERS,1,[Define to 1 to allow to filter content with scripts and programs.])
  892. fi])
  893. AC_ARG_ENABLE(accept-filter,
  894. [ --enable-accept-filter Try to use accf_http(9) if supported.],
  895. [if test $enableval = yes; then
  896. AC_DEFINE(FEATURE_ACCEPT_FILTER)
  897. fi])
  898. AC_ARG_ENABLE(strptime-sanity-checks,
  899. [ --enable-strptime-sanity-checks Only trust strptime() results if an additional strftime()/strptime()
  900. conversion doesn't change the result. Can be useful if strptime() is
  901. known or suspected to be broken.],
  902. [if test $enableval = yes; then
  903. AC_DEFINE(FEATURE_STRPTIME_SANITY_CHECKS)
  904. fi])
  905. AC_ARG_ENABLE(client-tags,
  906. [ --disable-client-tags Disable support for client-specific tags],
  907. [ if test $enableval = "no"; then have_client_tags=no; fi ])
  908. if test "${have_client_tags}" = "no"; then
  909. echo "Disabling support for client-specific tags."
  910. FEATURE_CLIENT_TAGS_ONLY="#"
  911. else
  912. echo "Enabling support for client-specific tags."
  913. AC_DEFINE(FEATURE_CLIENT_TAGS,1,[Define to enable support for client-specific tags.])
  914. FEATURE_CLIENT_TAGS_ONLY=""
  915. fi
  916. AC_SUBST(FEATURE_CLIENT_TAGS_ONLY)
  917. FUZZ_ONLY="#"
  918. AC_ARG_ENABLE(fuzz,
  919. [ --enable-fuzz Enable code that makes fuzzing more convenient],
  920. [if test $enableval = yes; then
  921. FUZZ_ONLY=""
  922. AC_DEFINE(FUZZ,1,[Define to make fuzzing more convenient.])
  923. fi])
  924. AC_SUBST(FUZZ_ONLY)
  925. dnl pcre/pcrs is needed for CGI anyway, so
  926. dnl the choice is only between static and
  927. dnl dynamic:
  928. AC_ARG_ENABLE(dynamic-pcre,
  929. [ --disable-dynamic-pcre Use the built-in, static pcre, even if libpcre is available],
  930. [ if test $enableval = "no"; then have_pcre=no; fi ])
  931. dnl =================================================
  932. dnl libpcrs is temporarily disabled,
  933. dnl see comment above for the reason.
  934. dnl =================================================
  935. dnl AC_ARG_ENABLE(dynamic-pcrs,
  936. dnl [ --disable-dynamic-pcrs Use the built-in, static pcrs, even if libpcrs is available],
  937. dnl [ if test $enableval = "no"; then have_pcrs=no; fi ])
  938. dnl ====================================================
  939. dnl This check is incomplete. For mingw32 zlib is found
  940. dnl by configure, but not necessarily by the compiler.
  941. dnl ====================================================
  942. AC_ARG_ENABLE(zlib,
  943. [ --disable-zlib Don't use zlib to decompress data before filtering.],
  944. [enableval2=$enableval],
  945. [enableval2=yes])
  946. if test $enableval2 = yes; then
  947. AC_CHECK_LIB(z, zlibVersion, [have_zlib="yes"], [have_zlib="no"])
  948. if test $have_zlib = "yes"; then
  949. LIBS="$LIBS -lz"
  950. AC_DEFINE(FEATURE_ZLIB,1,[Define to 1 to use zlib to decompress data before filtering.])
  951. else
  952. AC_MSG_WARN([No zlib found.
  953. Privoxy will not be able to filter compressed content.
  954. This may become a fatal error in the future.])
  955. fi
  956. fi
  957. AC_ARG_ENABLE(compression,
  958. [ --enable-compression Allow Privoxy to compress buffered content if the client supports it. Requires zlib support.],
  959. [enableval2=$enableval],
  960. [enableval2=no])
  961. if test $enableval2 = yes; then
  962. if test $have_zlib = "yes"; then
  963. echo Enabling compression support.
  964. AC_DEFINE(FEATURE_COMPRESSION,1,[Define to 1 to use compression through the zlib library.])
  965. else
  966. AC_MSG_WARN([No zlib found. Privoxy will not be able to (re-)compressed buffered content.])
  967. fi
  968. fi
  969. # If we have libpcre and either we also have pcreposix or
  970. # we don't need pcreposix, then link pcre dynamically; else
  971. # build it and link statically
  972. #
  973. if test $have_pcre = "yes"; then
  974. echo "using libpcre"
  975. pcre_dyn=yes
  976. AC_DEFINE(FEATURE_DYNAMIC_PCRE,1,[Define to dynamically link to pcre.])
  977. STATIC_PCRE_ONLY=#
  978. LIBS="$LIBS -lpcre -lpcreposix"
  979. else
  980. AC_MSG_WARN([You are using the static PCRE code which is out of date and scheduled for removal, for details see:
  981. http://sourceforge.net/mailarchive/forum.php?thread_name=20080511195555.2dc6cfdc%40fabiankeil.de&forum_name=ijbswa-developers])
  982. pcre_dyn=no
  983. # STATIC_PCRE is a name pcre needs to statically link on Windows.
  984. # Privoxy itself no longer uses it.
  985. AC_DEFINE(STATIC_PCRE,1,[Define to statically link to internal outdated pcre on Windows.])
  986. STATIC_PCRE_ONLY=
  987. fi
  988. AC_DEFINE(FEATURE_CONNECTION_KEEP_ALIVE)
  989. if test $have_pthread = "yes" -o $target_type = "mingw"; then
  990. echo Enabling connection-sharing support.
  991. AC_DEFINE(FEATURE_CONNECTION_SHARING)
  992. fi
  993. dnl =================================================
  994. dnl libpcrs is temporarily disabled,
  995. dnl see comment above for the reason.
  996. dnl =================================================
  997. dnl # If we have libpcrs and pcre is linked dynamically
  998. dnl # then also link pcrs dynamically, else build and link
  999. dnl # pcrs statically
  1000. dnl
  1001. dnl if test $have_pcrs = "yes" -a $pcre_dyn = "yes"; then
  1002. dnl echo "using libpcrs"
  1003. dnl STATIC_PCRS_ONLY=#
  1004. dnl LIBS="$LIBS -lpcrs"
  1005. dnl else
  1006. dnl echo "using built-in static pcrs"
  1007. AC_DEFINE(STATIC_PCRS)
  1008. STATIC_PCRS_ONLY=
  1009. dnl fi
  1010. AC_SUBST(STATIC_PCRE_ONLY)
  1011. AC_SUBST(STATIC_PCRS_ONLY)
  1012. FEATURE_HTTPS_INSPECTION_ONLY=#
  1013. dnl ========================================================
  1014. dnl check for mbedTLS which is required for https inspection
  1015. dnl ========================================================
  1016. FEATURE_HTTPS_INSPECTION_ONLY_MBEDTLS=#
  1017. OPT_MBEDTLS=no
  1018. AC_ARG_WITH(mbedtls,dnl
  1019. AC_HELP_STRING([--with-mbedtls], [Enable mbedTLS detection for https inspection.])
  1020. AC_HELP_STRING([--without-mbedtls], [Disable mbedTLS detection]),
  1021. OPT_MBEDTLS=$withval)
  1022. if test X"$OPT_MBEDTLS" != Xno; then
  1023. AC_CHECK_LIB(mbedtls, mbedtls_ssl_init,
  1024. [
  1025. AC_DEFINE(FEATURE_HTTPS_INSPECTION, 1, [if SSL/TLS is enabled])
  1026. AC_DEFINE(FEATURE_HTTPS_INSPECTION_MBEDTLS, 1, [if mbedTLS is enabled])
  1027. AC_SUBST(FEATURE_HTTPS_INSPECTION_MBEDTLS, [1])
  1028. FEATURE_HTTPS_INSPECTION_MBEDTLS="yes"
  1029. ], [], -lmbedx509 -lmbedcrypto)
  1030. if test "x$FEATURE_HTTPS_INSPECTION_MBEDTLS" = "xyes"; then
  1031. AC_MSG_NOTICE([Detected mbedTLS. Enabling https inspection.])
  1032. LIBS="-lmbedtls -lmbedx509 -lmbedcrypto $LIBS"
  1033. old_CFLAGS_nospecial="-Imbedtls/include $old_CFLAGS_nospecial"
  1034. FEATURE_HTTPS_INSPECTION_ONLY=
  1035. FEATURE_HTTPS_INSPECTION_ONLY_MBEDTLS=
  1036. fi
  1037. fi
  1038. AC_SUBST(FEATURE_HTTPS_INSPECTION_ONLY_MBEDTLS)
  1039. dnl =================================================================
  1040. dnl check for OpenSSL/LibreSSL which is required for https inspection
  1041. dnl =================================================================
  1042. FEATURE_HTTPS_INSPECTION_ONLY_OPENSSL=#
  1043. OPT_OPENSSL=no
  1044. AC_ARG_WITH(openssl,dnl
  1045. AC_HELP_STRING([--with-openssl], [Enable OpenSSL/LibreSSL detection for https inspection.])
  1046. AC_HELP_STRING([--without-openssl], [Disable OpenSSL/LibreSSL detection]),
  1047. OPT_OPENSSL=$withval)
  1048. if test X"$OPT_OPENSSL" != Xno; then
  1049. if test "$PORTNAME" != "win32"; then
  1050. AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
  1051. FOUND_SSL_LIB="no"
  1052. AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [FOUND_SSL_LIB="yes"])
  1053. AC_CHECK_LIB(ssl, SSL_library_init, [FOUND_SSL_LIB="yes"])
  1054. AS_IF([test "x$FOUND_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
  1055. else
  1056. AC_SEARCH_LIBS(CRYPTO_new_ex_data, eay32 crypto, [], [AC_MSG_ERROR([library 'eay32' or 'crypto' is required for OpenSSL])])
  1057. FOUND_SSL_LIB="no"
  1058. AC_SEARCH_LIBS(OPENSSL_init_ssl, ssleay32 ssl, [FOUND_SSL_LIB="yes"])
  1059. AC_SEARCH_LIBS(SSL_library_init, ssleay32 ssl, [FOUND_SSL_LIB="yes"])
  1060. AS_IF([test "x$FOUND_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
  1061. fi
  1062. if test "x$FOUND_SSL_LIB" = xyes; then
  1063. AC_DEFINE(FEATURE_HTTPS_INSPECTION, 1, [if SSL/TLS is enabled])
  1064. AC_DEFINE(FEATURE_HTTPS_INSPECTION_OPENSSL, 1, [if OpenSSL is enabled])
  1065. AC_SUBST(FEATURE_HTTPS_INSPECTION_OPENSSL, [1])
  1066. FEATURE_HTTPS_INSPECTION="yes"
  1067. FEATURE_HTTPS_INSPECTION_OPENSSL="yes"
  1068. fi
  1069. if test "x$FEATURE_HTTPS_INSPECTION_OPENSSL" = "xyes"; then
  1070. AC_MSG_NOTICE([Detected OpenSSL. Enabling https inspection.])
  1071. AC_MSG_WARN([If you intend to redistribute Privoxy, please make sure the "special exception" from section 3 of the GPLv2 applies.])
  1072. LIBS="$LIBS -lssl -lcrypto"
  1073. old_CFLAGS_nospecial="$old_CFLAGS_nospecial"
  1074. FEATURE_HTTPS_INSPECTION_ONLY=
  1075. FEATURE_HTTPS_INSPECTION_ONLY_OPENSSL=
  1076. fi
  1077. fi
  1078. AC_SUBST(FEATURE_HTTPS_INSPECTION_ONLY_OPENSSL)
  1079. AC_SUBST(FEATURE_HTTPS_INSPECTION_ONLY)
  1080. dnl ========================================================
  1081. dnl Check for Brotli which can be used for decompression
  1082. dnl ========================================================
  1083. WITH_BROTLI=no
  1084. AC_ARG_WITH(brotli,
  1085. AC_HELP_STRING([--with-brotli], [Enable Brotli detection])
  1086. AC_HELP_STRING([--without-brotli], [Disable Brotli detection]),
  1087. WITH_BROTLI=$withval)
  1088. if test X"$WITH_BROTLI" != Xno; then
  1089. LIBS="$LIBS -lbrotlidec"
  1090. AC_CHECK_LIB(brotlidec, BrotliDecoderDecompress)
  1091. AC_CHECK_HEADERS(brotli/decode.h,
  1092. FEATURE_BROTLI=1
  1093. AC_DEFINE(FEATURE_BROTLI, 1, [If Brotli is used for decompression])
  1094. AC_SUBST(FEATURE_BROTLI, [1])
  1095. )
  1096. fi
  1097. dnl =================================================================
  1098. dnl Final cleanup and output
  1099. dnl =================================================================
  1100. dnl Remove the SPECIAL_CFLAGS stuff from CFLAGS, and add it separately
  1101. dnl in the Makefile
  1102. CFLAGS=$old_CFLAGS_nospecial
  1103. AC_SUBST(SPECIAL_CFLAGS)
  1104. AC_SUBST(PTHREAD_LIB)
  1105. AC_OUTPUT(GNUmakefile doc/source/ldp.dsl)