configure 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. #! /bin/sh
  2. #
  3. # configure
  4. #
  5. # Configuration script for POCO.
  6. #
  7. # Invoke configure --help for help.
  8. #
  9. showhelp()
  10. {
  11. cat << ENDHELP
  12. usage: configure {options}
  13. Configure the POCO C++ Libraries.
  14. Options:
  15. --help
  16. Display this help screen.
  17. --config=<config_name>
  18. Use the given build configuration.
  19. Available configurations are:
  20. $(ls -C "$base"/build/config/)
  21. --prefix=<install_prefix>
  22. Use the given install directory for make install.
  23. Default is /usr/local.
  24. --no-prefix
  25. Do not use /usr/local as default install directory and do not
  26. define POCO_PREFIX.
  27. --stdcxx-base=<apache_stdcxx_install_prefix>
  28. If (and only if) the $base/build/config selected with --config
  29. uses the Apache stdcxx library, then apache_stdcxx_install_prefix
  30. specifies the base directory where stdcxx is installed.
  31. --no-tests
  32. Do not build testsuites.
  33. --no-samples
  34. Do not build samples.
  35. --minimal
  36. Build only Foundation, XML, JSON, Util and Net.
  37. --typical (default)
  38. Build only Foundation, XML, JSON, Util, Net, Crypto, NetSSL, Data/SQLite and Zip.
  39. --everything
  40. Build everything.
  41. --no-wstring
  42. Compile with -DPOCO_NO_WSTRING.
  43. Useful if your C++ compiler does not support std::wstring
  44. (such as uClibc-based systems).
  45. --no-fpenvironment
  46. Compile with -DPOCO_NO_FPENVIRONMENT.
  47. Useful if your C++ compiler has incomplete floating-point support
  48. (such as uClibc-based systems).
  49. --no-sharedmemory
  50. Compile with -DPOCO_NO_SHAREDMEMORY.
  51. For systems that don't support shared memory API's,
  52. like uClibc-based Linux systems.
  53. --no-sharedlibs
  54. Compile with -DPOCO_NO_SHAREDLIBS.
  55. For systems that don't support shared library loading.
  56. --no-ipv6
  57. Compile with -DPOCO_NET_NO_IPv6.
  58. For systems that don't support IPv6.
  59. --no-soo
  60. Compile with -DPOCO_NO_SOO.
  61. Disables small object optimization.
  62. --no-sqlparser
  63. Compile with -DPOCO_DATA_NO_SQL_PARSER
  64. Disables compilation of the SQLParser.
  65. --sqlite-fts=<path>
  66. Compile with -DPOCO_DATA_SQLITE_FTS.
  67. Compile SQLite with Full Text Search support.
  68. --sqlite-thread-safe=<value>
  69. Compile with -DSQLITE_THREADSAFE=<value>.
  70. Valid values are:
  71. - 0 single-thread, no thread safety
  72. - 1 serial access, highest thread safety
  73. - 2 multi-threaded, without session sharing support
  74. --omit=<component>{,<component>}
  75. Do not build the specified component(s).
  76. Example: --omit=Data/MySQL,Data/ODBC,Zip
  77. --include-path=<path>
  78. Add search path for header files.
  79. --library-path=<path>
  80. Add search path for library files.
  81. --odbc-lib=<path>
  82. Specify the directory where ODBC library is located.
  83. --odbc-include=<path>
  84. Specify the directory where ODBC header files are located.
  85. --mysql-lib=<path>
  86. Specify the directory where MySQL library is located.
  87. --mysql-include=<path>
  88. Specify the directory where MySQL header files are located.
  89. --pgsql-lib=<path>
  90. Specify the directory where PostgreSQL library is located.
  91. --pgsql-include=<path>
  92. Specify the directory where PostgreSQL header files are located.
  93. --cflags=<flags>
  94. Pass additional flags to compiler.
  95. Example: --cflags=-wall
  96. --ldflags=<flags>
  97. Pass additional flags to linker.
  98. Example: --ldflags=-latomic
  99. --poquito
  100. Omit a few features for smaller codesize when linking
  101. statically for embedded targets.
  102. --unbundled
  103. Use system-provided zlib, pcre, expat and sqlite instead of
  104. bundled ones.
  105. --static
  106. Build static libraries. Overrides default mode, which
  107. depends upon target. Can be specified together
  108. with --shared to build both.
  109. --shared
  110. Build shared libraries. Overrides default mode, which
  111. depends upon target. Can be specified together
  112. with --static to build both.
  113. ENDHELP
  114. }
  115. # save cwd
  116. build=$(pwd)
  117. # get directory where we are located
  118. cd "$(dirname "$0")" || exit
  119. base=$(pwd)
  120. cd "$build" || exit
  121. tests=1
  122. samples=1
  123. noprefix=0
  124. flags=""
  125. ldflags=""
  126. includepath=""
  127. librarypath=""
  128. odbclib=""
  129. odbcinclude=""
  130. unbundled=""
  131. static=""
  132. shared=""
  133. nosqlparser=
  134. omitMinimal="Crypto NetSSL_OpenSSL Zip Data Data/SQLite Data/ODBC Data/MySQL Data/PostgreSQL MongoDB Redis PDF DNSSD DNSSD/Avahi DNSSD/Bonjour CppParser PageCompiler"
  135. omitTypical="Data/ODBC Data/MySQL Data/PostgreSQL MongoDB Redis PDF DNSSD DNSSD/Avahi DNSSD/Bonjour CppParser"
  136. omit=$omitTypical
  137. # parse arguments
  138. while [ $# -ge 1 ]; do
  139. case "$1" in
  140. --config=*)
  141. config="$(echo "${1}" | awk '{print substr($0,10)}')" ;;
  142. --prefix=*)
  143. prefix="$(echo "${1}" | awk '{print substr($0,10)}')" ;;
  144. --no-prefix)
  145. noprefix=1 ;;
  146. --stdcxx-base=*)
  147. stdcxx_base="$(echo "${1}" | awk '{print substr($0,15)}')" ;;
  148. --omit=*)
  149. omit="$(echo "${1}" | awk '{print substr($0,8)}' | tr ',;' ' ')" ;;
  150. --include-path=*)
  151. includepath="$(echo "${1}" | awk '{print substr($0,16)}' | tr ',;' ' ')" ;;
  152. --library-path=*)
  153. librarypath="$(echo "${1}" | awk '{print substr($0,16)}' | tr ',;' ' ')" ;;
  154. --odbc-lib=*)
  155. odbclib="$(echo "${1}" | awk '{print substr($0,12)}')" ;;
  156. --odbc-include=*)
  157. odbcinclude="$(echo "${1}" | awk '{print substr($0,16)}')" ;;
  158. --mysql-lib=*)
  159. mysqllib="$(echo "${1}" | awk '{print substr($0,13)}')" ;;
  160. --mysql-include=*)
  161. mysqlinclude="$(echo "${1}" | awk '{print substr($0,17)}')" ;;
  162. --pgsql-lib=*)
  163. pgsqllib="$(echo "${1}" | awk '{print substr($0,13)}')" ;;
  164. --pgsql-include=*)
  165. pgsqlinclude="$(echo "${1}" | awk '{print substr($0,17)}')" ;;
  166. --cflags=*)
  167. flags="$flags $(echo "${1}" | awk '{print substr($0,10)}')" ;;
  168. --ldflags=*)
  169. ldflags="$ldflags $(echo "${1}" | awk '{print substr($0,11)}')" ;;
  170. --no-samples)
  171. samples="" ;;
  172. --no-tests)
  173. tests="" ;;
  174. --no-wstring)
  175. flags="$flags -DPOCO_NO_WSTRING" ;;
  176. --no-fpenvironment)
  177. flags="$flags -DPOCO_NO_FPENVIRONMENT" ;;
  178. --no-sharedmemory)
  179. flags="$flags -DPOCO_NO_SHAREDMEMORY" ;;
  180. --no-sharedlibs)
  181. flags="$flags -DPOCO_NO_SHAREDLIBS" ;;
  182. --no-ipv6)
  183. flags="$flags -DPOCO_NET_NO_IPv6" ;;
  184. --no-soo)
  185. flags="$flags -DPOCO_NO_SOO" ;;
  186. --no-sqlparser)
  187. flags="$flags -DPOCO_DATA_NO_SQL_PARSER"
  188. nosqlparser=1
  189. ;;
  190. --sqlite-thread-safe=*)
  191. flags="$flags -DSQLITE_THREADSAFE=$(echo "${1}" | awk '{print substr($0,22)}')" ;;
  192. --sqlite-fts)
  193. flags="$flags -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_FTS3_PARENTHESIS" ;;
  194. --poquito)
  195. flags="$flags -DPOCO_NO_FILECHANNEL -DPOCO_NO_SPLITTERCHANNEL -DPOCO_NO_SYSLOGCHANNEL -DPOCO_UTIL_NO_INIFILECONFIGURATION -DPOCO_UTIL_NO_JSONCONFIGURATION -DPOCO_UTIL_NO_XMLCONFIGURATION" ;;
  196. --unbundled)
  197. flags="$flags -DPOCO_UNBUNDLED"
  198. unbundled=1
  199. ;;
  200. --minimal)
  201. omit=$omitMinimal ;;
  202. --typical)
  203. omit=$omitTypical ;;
  204. --everything)
  205. omit="" ;;
  206. --static)
  207. static=1 ;;
  208. --shared)
  209. shared=1 ;;
  210. --help)
  211. showhelp
  212. exit 0
  213. ;;
  214. *)
  215. showhelp
  216. exit 1
  217. ;;
  218. esac
  219. shift
  220. done
  221. # autodetect build environment
  222. # ...special cases for CYGWIN or MinGW
  223. if [ "$config" = "" ] ; then
  224. config=$(uname)
  225. case "$config" in
  226. CYGWIN*)
  227. config=CYGWIN ;;
  228. MINGW*)
  229. config=MinGW ;;
  230. esac
  231. fi
  232. if [ ! -f "$base/build/config/$config" ] ; then
  233. echo "Unknown configuration: $config"
  234. echo "Please use the --config option to specify another build configuration"
  235. echo "The following configurations are available:"
  236. ls "$base"/build/config
  237. exit 1
  238. fi
  239. if [ -z "$prefix" ] ; then
  240. if [ $noprefix -eq 0 ] ; then
  241. prefix=/usr/local
  242. fi
  243. fi
  244. # check for patches
  245. if [ -d "$base"/patches/"$config" ] ; then
  246. echo "NOTE: There are patches for your configuration available. Please apply them before compiling."
  247. fi
  248. # copy Makefile to build dir
  249. if [ "$base" != "$build" ] ; then
  250. cp "$base"/Makefile "$build"
  251. fi
  252. if [ -n "$static" ] && [ -n "$shared" ] ; then
  253. linkmode=BOTH
  254. elif [ -n "$static" ] ; then
  255. linkmode=STATIC
  256. elif [ -n "$shared" ] ; then
  257. linkmode=SHARED
  258. else
  259. linkmode=""
  260. fi
  261. # create config.make
  262. echo '# config.make generated by configure script' > "$build"/config.make
  263. {
  264. echo "POCO_CONFIG = $config"
  265. echo "POCO_BASE = $base"
  266. echo "POCO_BUILD = $build"
  267. echo "POCO_FLAGS = $flags"
  268. echo "POCO_LDFLAGS = $ldflags"
  269. } >> "$build"/config.make
  270. if [ -n "$prefix" ] ; then
  271. echo "POCO_PREFIX = $prefix" >>"$build"/config.make
  272. fi
  273. echo "OMIT = $omit" >>"$build"/config.make
  274. if [ -n "$stdcxx_base" ] ; then
  275. echo "STDCXX_BASE = $stdcxx_base" >>"$build"/config.make
  276. fi
  277. if [ -n "$includepath" ] ; then
  278. echo "POCO_ADD_INCLUDE = $includepath" >>"$build"/config.make
  279. fi
  280. if [ -n "$librarypath" ] ; then
  281. echo "POCO_ADD_LIBRARY = $librarypath" >>"$build"/config.make
  282. fi
  283. if [ -n "$odbclib" ] ; then
  284. echo "POCO_ODBC_LIB = $odbclib" >>"$build"/config.make
  285. fi
  286. if [ -n "$odbcinclude" ] ; then
  287. echo "POCO_ODBC_INCLUDE = $odbcinclude" >>"$build"/config.make
  288. fi
  289. if [ -n "$mysqllib" ] ; then
  290. echo "POCO_MYSQL_LIB = $mysqllib" >>"$build"/config.make
  291. fi
  292. if [ -n "$mysqlinclude" ] ; then
  293. echo "POCO_MYSQL_INCLUDE = $mysqlinclude" >>"$build"/config.make
  294. fi
  295. if [ -n "$pgsqllib" ] ; then
  296. echo "POCO_PGSQL_LIB = $pgsqllib" >>"$build"/config.make
  297. fi
  298. if [ -n "$pgsqlinclude" ] ; then
  299. echo "POCO_PGSQL_INCLUDE = $pgsqlinclude" >>"$build"/config.make
  300. fi
  301. if [ -n "$unbundled" ] ; then
  302. echo "POCO_UNBUNDLED = 1" >>"$build"/config.make
  303. fi
  304. if [ -n "$linkmode" ] ; then
  305. echo "LINKMODE = $linkmode" >>"$build"/config.make
  306. fi
  307. if [ -n "$nosqlparser" ] ; then
  308. echo "POCO_DATA_NO_SQL_PARSER = $nosqlparser" >>"$build"/config.make
  309. fi
  310. cat <<__EOF__ >>"$build"/config.make
  311. export POCO_CONFIG
  312. export POCO_BASE
  313. export POCO_BUILD
  314. export POCO_FLAGS
  315. export POCO_LDFLAGS
  316. __EOF__
  317. if [ -n "$prefix" ] ; then
  318. echo "export POCO_PREFIX" >>"$build"/config.make
  319. fi
  320. if [ -n "$stdcxx_base" ] ; then
  321. echo "export STDCXX_BASE" >>"$build"/config.make
  322. fi
  323. if [ -n "$includepath" ] ; then
  324. echo "export POCO_ADD_INCLUDE" >>"$build"/config.make
  325. fi
  326. if [ -n "$librarypath" ] ; then
  327. echo "export POCO_ADD_LIBRARY" >>"$build"/config.make
  328. fi
  329. if [ -n "$odbclib" ] ; then
  330. echo "export POCO_ODBC_LIB" >>"$build"/config.make
  331. fi
  332. if [ -n "$odbcinclude" ] ; then
  333. echo "export POCO_ODBC_INCLUDE" >>"$build"/config.make
  334. fi
  335. if [ -n "$mysqllib" ] ; then
  336. echo "export POCO_MYSQL_LIB" >>"$build"/config.make
  337. fi
  338. if [ -n "$mysqlinclude" ] ; then
  339. echo "export POCO_MYSQL_INCLUDE" >>"$build"/config.make
  340. fi
  341. if [ -n "$pgsqllib" ] ; then
  342. echo "export POCO_PGSQL_LIB" >>"$build"/config.make
  343. fi
  344. if [ -n "$pgsqlinclude" ] ; then
  345. echo "export POCO_PGSQL_INCLUDE" >>"$build"/config.make
  346. fi
  347. if [ -n "$unbundled" ] ; then
  348. echo "export POCO_UNBUNDLED" >>"$build"/config.make
  349. fi
  350. if [ -n "$linkmode" ] ; then
  351. echo "export LINKMODE" >>"$build"/config.make
  352. fi
  353. if [ -n "$nosqlparser" ] ; then
  354. echo "export POCO_DATA_NO_SQL_PARSER" >>"$build"/config.make
  355. fi
  356. # create config.build
  357. echo '# config.build generated by configure script' >"$build"/config.build
  358. cat <<__EOF__ >>"$build"/config.build
  359. TESTS = $tests
  360. SAMPLES = $samples
  361. __EOF__
  362. echo "Configured for $config"
  363. echo "======================"
  364. echo
  365. cat "$build"/config.make
  366. echo
  367. cat "$build"/config.build
  368. echo
  369. echo "======================"