C++ Library containing a lot of needful things: Stack Trace, Command Line Parser, Resource Handling, Configuration Files, Unix Command Execution, Directories, Regular Expressions, Tokenizer, Function Trace, Standard Extensions.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ax_init_standard_project.m4 43KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238
  1. ## @id $Id: ax_init_standard_project.m4 204 2016-09-29 18:29:53Z marc $
  2. ## 1 2 3 4 5 6 7 8
  3. ## 45678901234567890123456789012345678901234567890123456789012345678901234567890
  4. # m4_esyscmd_s does not exist on centos 5 and 6
  5. m4_define([mrw_esyscmd_s], [m4_normalize(m4_esyscmd([$1]))])
  6. # define least version number from subversion's revision number:
  7. # it is taken modulo 256 due to a bug on Apple's MaxOSX
  8. m4_define(x_least, m4_ifdef([x_least_fix], [x_least_fix],
  9. m4_ifdef([x_least_diff],
  10. mrw_esyscmd_s([
  11. VCS_REVISION="ERROR-UNDEFINED-REVISION-to-be-built-in-subdirectory-of-checkout"
  12. for path in . .. ../.. ../../..; do
  13. if test -d ${path}/.svn; then
  14. (cd $path; svn upgrade 1>&2 > /dev/null || true)
  15. VCS_REVISION=$(LANG= svn info $path | sed -n 's/Last Changed Rev: //p')
  16. if test -n "${VCS_REVISION}"; then break; fi
  17. elif test -d ${path}/.git; then
  18. VCS_REVISION=$(cd ${path} > /dev/null 2/dev/null; git rev-list --all --count)
  19. if test -n "${VCS_REVISION}"; then break; fi
  20. fi
  21. done
  22. echo $ECHO_N $(($VCS_REVISION))
  23. ]), mrw_esyscmd_s([
  24. VCS_REVISION="ERROR-UNDEFINED-REVISION-to-be-built-in-subdirectory-of-checkout"
  25. for path in . .. ../.. ../../..; do
  26. if test -d ${path}/.svn; then
  27. (cd $path; svn upgrade 1>&2 > /dev/null || true)
  28. VCS_REVISION=$(LANG= svn info $path | sed -n 's/Last Changed Rev: //p')
  29. if test -n "${VCS_REVISION}"; then break; fi
  30. elif test -d ${path}/.git; then
  31. VCS_REVISION=$(cd ${path} > /dev/null 2/dev/null; git rev-list --all --count)
  32. if test -n "${VCS_REVISION}"; then break; fi
  33. fi
  34. done
  35. # Mac does not support LEAST > 255
  36. echo $ECHO_N $(($VCS_REVISION%256))]))))
  37. # define version number from subversion's revision number:
  38. # it is taken modulo 256 due to a bug on Apple's MacOSX
  39. # add to x_minor if revision number is > 256
  40. m4_define(x_minor_diff, m4_ifdef([x_least_fix], 0, mrw_esyscmd_s([
  41. VCS_REVISION="ERROR-UNDEFINED-REVISION-to-be-built-in-subdirectory-of-checkout"
  42. for path in . .. ../.. ../../..; do
  43. if test -d ${path}/.svn; then
  44. (cd $path; svn upgrade 1>&2 > /dev/null || true)
  45. VCS_REVISION=$(LANG= svn info $path | sed -n 's/Last Changed Rev: //p')
  46. if test -n "${VCS_REVISION}"; then break; fi
  47. elif test -d ${path}/.git; then
  48. VCS_REVISION=$(cd ${path} > /dev/null 2/dev/null; git rev-list --all --count)
  49. if test -n "${VCS_REVISION}"; then break; fi
  50. fi;
  51. done
  52. # Mac does not support LEAST > 255
  53. echo $ECHO_N $(($VCS_REVISION/256))])))
  54. # setup version number
  55. m4_define(x_version, [x_major.m4_ifdef([x_least_diff], x_minor, m4_eval(x_minor+x_minor_diff)).m4_eval(m4_ifdef([x_least_diff], [x_least-x_least_diff], [x_least]))])
  56. ## bugreport mail address is taken from <user@host> in first line of AUTHORS
  57. m4_define(x_bugreport, mrw_esyscmd_s([
  58. head -1 AUTHORS | \
  59. sed -n 's,.*<\([-_.a-z0-9A-Z]*@[-_.a-z0-9A-Z]*\)>.*,\1,gp'
  60. ]))
  61. m4_include(ax_check_qt.m4)
  62. AC_ALIAS([AC_DEFINE_DIR], [AX_DEFINE_DIR])
  63. AC_DEFUN([AX_DEFINE_DIR], [
  64. prefix_NONE=
  65. exec_prefix_NONE=
  66. test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
  67. test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
  68. dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn
  69. dnl refers to ${prefix}. Thus we have to use `eval' twice.
  70. eval ax_define_dir="\"[$]$2\""
  71. eval ax_define_dir="\"$ax_define_dir\""
  72. AC_SUBST($1, "$ax_define_dir")
  73. AC_DEFINE_UNQUOTED($1, "$ax_define_dir", [$3])
  74. test "$prefix_NONE" && prefix=NONE
  75. test "$exec_prefix_NONE" && exec_prefix=NONE
  76. ])
  77. # add target dependencies to an existing makefile.in
  78. # - parameters:
  79. # $1 = existing target
  80. # $2 = new dependency for that target
  81. # $3 = filename of makefile.in
  82. AC_DEFUN([AX_ADD_MAKEFILE_TARGET_DEP], [
  83. sh_add_makefile_target_dep() {
  84. sed -i -e ':a;/^'${1}':.*\\$/{N;s/\\\n//;ta};s/^'"${1}"':.*$/& '"${2}"'/' "${srcdir}/${3}"
  85. if ! egrep -q "${1}:.* ${2}" "${srcdir}/${3}"; then
  86. echo "${1}: ${2}" >> "${srcdir}/${3}"
  87. fi
  88. }
  89. sh_add_makefile_target_dep "$1" "$2" "$3"
  90. if test "$1" != ".PHONY"; then
  91. sh_add_makefile_target_dep ".PHONY" "$2" "$3"
  92. fi
  93. ])
  94. # Same as AC_SUBST, but adds -Dname="value" option to CPPFLAGS and a
  95. # notz only a @name@ replacement, but also a @name_ENCODED@ one to be
  96. # used in code.
  97. # - parameters:
  98. # $1 = variable name
  99. AC_DEFUN([AX_SUBST], [
  100. [$1]_ENCODED=$(echo "${$1}" | awk 1 ORS='\\n' | sed 's,\\n$,,')
  101. [$1]_ENCODED=${[$1]_ENCODED//\"/\\\"}
  102. [$1]_ENCODED=${[$1]_ENCODED//\'/\'\"\'\"\'}
  103. [$1]_ENCODED=${[$1]_ENCODED//#/\\#}
  104. AM_CPPFLAGS+=" '-D$1=\"${[$1]_ENCODED}\"'"
  105. AC_SUBST([$1])
  106. AC_SUBST([$1]_ENCODED)
  107. AC_SUBST(AM_CPPFLAGS)
  108. ])
  109. # must be called on the right position in configure.ac
  110. #
  111. # configure.ac must start with:
  112. #
  113. # m4_define(x_package_name, YOUR_PACKAGE_NAME) # project's name
  114. # m4_define(x_major, MAJOR_NUMBER) # project's major version
  115. # m4_define(x_minor, MINOR_NUMBER) # project's minor version
  116. # m4_include(ax_init_standard_project.m4)
  117. # AC_INIT(x_package_name, x_version, x_bugreport, x_package_name)
  118. # AM_INIT_AUTOMAKE([1.9 tar-pax parallel-tests color-tests])
  119. # AX_INIT_STANDARD_PROJECT
  120. #
  121. # you change nothing but: YOUR_PACKAGE_NAME, MAJOR_NUMBER, MINOR_NUMBER
  122. #
  123. # configures the basic environment
  124. AC_DEFUN([AX_INIT_STANDARD_PROJECT], [
  125. PREFIX=$(test "$prefix" = NONE && prefix=$ac_default_prefix; eval echo "${prefix}")
  126. AX_SUBST(PREFIX)
  127. SYSCONFDIR=$(test "$prefix" = NONE && prefix=$ac_default_prefix; eval echo "${sysconfdir}")
  128. AX_SUBST(SYSCONFDIR)
  129. PKGSYSCONFDIR=$(test "$prefix" = NONE && prefix=$ac_default_prefix; eval echo "${SYSCONFDIR}/${PACKAGE_NAME}")
  130. AX_SUBST(PKGSYSCONFDIR)
  131. DATADIR=$(test "$prefix" = NONE && prefix=$ac_default_prefix; eval echo "${datadir}")
  132. AX_SUBST(DATADIR)
  133. PKGDATADIR=$(test "$prefix" = NONE && prefix=$ac_default_prefix; eval echo "${DATADIR}/${PACKAGE_NAME}")
  134. AX_SUBST(PKGDATADIR)
  135. LOCALSTATEDIR=$(test "$prefix" = NONE && prefix=$ac_default_prefix; eval echo "${localstatedir}")
  136. AX_SUBST(LOCALSTATEDIR)
  137. AC_MSG_CHECKING([target platfrom])
  138. UNIX=1
  139. MINGW=
  140. MACOSX=
  141. for h in ${target} ${target_os} ${host} ${host_os} \
  142. ${build} ${build_os} $(uname -s 2> /dev/null); do
  143. p="$h is generic Unix"
  144. case "$h" in
  145. (*mingw*)
  146. UNIX=; MINGW=1; p="MinGW"; break;;
  147. (*Darwin*|*darwin*|*rhapsody*|*macosx*)
  148. UNIX=; MACOSX=1; p="MacOSX"; break;;
  149. esac
  150. done
  151. AC_MSG_RESULT($p)
  152. AM_CONDITIONAL(UNIX, test "$UNIX" = "1")
  153. AM_CONDITIONAL(MINGW, test "$MINGW" = "1")
  154. AM_CONDITIONAL(MACOSX, test "$MACOSX" = "1")
  155. AX_SUBST(UNIX)
  156. AX_SUBST(MINGW)
  157. AX_SUBST(MACOSX)
  158. AM_CPPFLAGS+=" '-DMAKE_STRING(X)=\#X' '-DNAMESPACE=${PACKAGE_TARNAME//[^a-zA-Z0-9]/_}'"
  159. AX_SUBST(NUMBERS)
  160. AX_SUBST(HOME)
  161. if test -f README.md; then
  162. README_FILE=README.md
  163. README=$(tail -n +3 README.md)
  164. DESCRIPTION=$(head -1 README.md | sed 's,^#\+ *,,;s, *#\+$,,')
  165. else
  166. README_FILE=README
  167. README=$(tail -n +3 README)
  168. DESCRIPTION=$(head -1 README)
  169. fi
  170. README_ESCAPED=$(echo "$README" | sed ':a;N;$!ba;s/\n/\\n/g;s,",\\",g')
  171. if which pandoc 2>&1 > /dev/null; then
  172. README_HTML=$(echo "$README" | pandoc -f markdown_github -t html | sed ':a;N;$!ba;s,\\\(.\),\\\\<span>\1</span>,g;s/\n/\\n/g;s,",\\",g;s, ,\&nbsp;\&nbsp;,g')
  173. else
  174. README_HTML="${README}"
  175. fi
  176. AX_SUBST(README_FILE)
  177. AX_SUBST(README)
  178. _AM_SUBST_NOTMAKE([README])
  179. AX_SUBST(README_ESCAPED)
  180. _AM_SUBST_NOTMAKE([README_ESCAPED])
  181. AX_SUBST(README_HTML)
  182. _AM_SUBST_NOTMAKE([README_HTML])
  183. AX_SUBST(DESCRIPTION)
  184. _AM_SUBST_NOTMAKE([DESCRIPTION])
  185. LICENSE=$(echo $(head -1 COPYING))
  186. AX_SUBST(LICENSE)
  187. COPYING=$(<COPYING)
  188. AX_SUBST(COPYING)
  189. _AM_SUBST_NOTMAKE([COPYING])
  190. CHANGELOG=$(<ChangeLog)
  191. AC_SUBST(CHANGELOG)
  192. _AM_SUBST_NOTMAKE([CHANGELOG])
  193. DEB_CHANGELOG=$(sed '/^[[^\t]]/{h;N;d};s,\t, ,g;/^ \* /{s,,,;H;g;s,^, * ,;s,\n\([[^ ]]*\) *, \1\n ,}' ChangeLog)
  194. if test -z "$DEB_CHANGELOG"; then
  195. DEB_CHANGELOG=" * see file ChangeLog and project management web site"
  196. fi
  197. AC_SUBST(DEB_CHANGELOG)
  198. _AM_SUBST_NOTMAKE([DEB_CHANGELOG])
  199. AUTHOR=$(head -1 AUTHORS)
  200. AUTHOR_NAME=$(echo $AUTHOR | sed 's, *[[<(]].*$,,')
  201. AUTHOR_URL=$(echo $AUTHOR | sed 's,.*(\(http[[^)]]*\)).*,\1,')
  202. AUTHOR_MAIL=$(echo $AUTHOR | sed 's,.*<\(.*@.*\)>.*,\1,')
  203. PACKAGER=$(gpg -K --display-charset utf-8 --lock-never 2>/dev/null | sed -n 's,uid *\(\[[ultimate\]] *\)\?,,p' | head -1)
  204. if test -z "${PACKAGER}"; then
  205. PACKAGER="$AUTHOR"
  206. fi
  207. AX_SUBST(AUTHOR)
  208. _AM_SUBST_NOTMAKE([AUTHOR])
  209. AX_SUBST(AUTHOR_NAME)
  210. AX_SUBST(AUTHOR_URL)
  211. AX_SUBST(AUTHOR_MAIL)
  212. AX_SUBST(PACKAGER)
  213. PROJECT_URL="${PROJECT_URL:-${AUTHOR_URL}}"
  214. for path in . .. ../.. ../../..; do
  215. if test -d ${path}/.svn; then
  216. PROJECT_URL="$(LANG= svn info | sed -n 's,^Repository Root: ,,p')"
  217. break
  218. elif test -d ${path}/.git; then
  219. PROJECT_URL="$(git remote get-url origin)"
  220. break
  221. fi
  222. done
  223. SOURCE_DOWNLOAD="${SOURCE_DOWNLOAD:-${PROJECT_URL}}"
  224. AX_SUBST(PROJECT_URL)
  225. AX_SUBST(SOURCE_DOWNLOAD)
  226. VENDOR=$((lsb_release -is 2>/dev/null || echo unknown) | tr ' ' '_')
  227. AX_SUBST(VENDOR)
  228. DISTRO=$(lsb_release -sc 2>/dev/null || uname -s 2>/dev/null)
  229. if test "${DISTRO}" = "n/a"; then
  230. DISTRO="${VENDOR}_$(lsb_release -sr 2>/dev/null | tr ' ' '_')"
  231. fi
  232. AX_SUBST(DISTRO)
  233. ARCH=$((@<:@@<:@ $(uname -sm) =~ 64 @:>@@:>@ && echo amd64) || (@<:@@<:@ $(uname -sm) =~ 'i?86' @:>@@:>@ && echo i386 || uname -sm))
  234. AX_SUBST(ARCH)
  235. DISTRIBUTOR=$(lsb_release -si 2>/dev/null || uname -s 2>/dev/null)
  236. case "${DISTRIBUTOR// /-}" in
  237. (Ubuntu) UBUNTU=1; AX_SUBST(UBUNTU);;
  238. (Debian) DEBIAN=1; AX_SUBST(DEBIAN);;
  239. (SUSE-LINUX) SUSE=1; AX_SUBST(SUSE);;
  240. (Fedora) FEDORA=1; AX_SUBST(FEDORA);;
  241. (Centos) CENTOS=1; AX_SUBST(CENTOS);;
  242. esac
  243. AX_SUBST(DISTRIBUTOR)
  244. BUILD_NUMBER=${BUILD_NUMBER:-1}
  245. AX_SUBST(BUILD_NUMBER)
  246. BUILD_DATE=$(LANG= date +"%a, %d %b %Y %H:%M:%S %z")
  247. AX_SUBST(BUILD_DATE)
  248. if test -f "${PACKAGE_NAME}.desktop.in"; then
  249. PACKAGE_DESKTOP="${PACKAGE_NAME}.desktop"
  250. fi
  251. AX_SUBST(PACKAGE_DESKTOP)
  252. if test -f "${PACKAGE_NAME}-logo.png"; then
  253. PACKAGE_LOGO="${PACKAGE_NAME}-logo.png"
  254. fi
  255. AX_SUBST(PACKAGE_LOGO)
  256. if test -f "${PACKAGE_NAME}-icon.svg"; then
  257. PACKAGE_ICON="${PACKAGE_NAME}-icon.svg"
  258. elif test -f "${PACKAGE_NAME}-icon.png"; then
  259. PACKAGE_ICON="${PACKAGE_NAME}-icon.png"
  260. elif test -f "${PACKAGE_NAME}.svg"; then
  261. PACKAGE_ICON="${PACKAGE_NAME}.svg"
  262. elif test -f "${PACKAGE_NAME}.png"; then
  263. PACKAGE_ICON="${PACKAGE_NAME}.png"
  264. fi
  265. AX_SUBST(PACKAGE_ICON)
  266. AC_ARG_ENABLE(pedantic,
  267. [AS_HELP_STRING([--enable-pedantic],
  268. [enable all warnings and checks, abort on warnings])],
  269. [have_pedantic="$enableval"; test "$enableval" = "yes" && \
  270. AM_CXXFLAGS="${AM_CXXFLAGS:-} -pedantic-errors -Wall -W -Wfloat-equal -Wundef -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Wconversion -Wsign-compare -Wmissing-format-attribute -Wno-multichar -Wpacked -Wredundant-decls -Werror -Wshadow -Wcast-qual -Wno-ctor-dtor-privacy"])
  271. dnl problem in libs: -Wshadow -Wcast-qual
  272. dnl auto.hpp: -Wno-ctor-dtor-privacy (removed)
  273. AM_CONDITIONAL(PEDANTIC, test "$enableval" = "yes")
  274. if test "$have_pedantic" == "yes"; then
  275. AC_MSG_NOTICE([Pedantic compile mode enabled!
  276. - all warnings for GNU g++ are enabled
  277. - all warnings result in an error
  278. - doxygen warnings are treated as error too]); fi
  279. AC_ARG_ENABLE(debug,
  280. [AS_HELP_STRING([--enable-debug],
  281. [compile for debugger])],
  282. [have_debug="$enableval"], [have_debug="no"])
  283. AM_CONDITIONAL(DEBUG, test "$enableval" = "yes")
  284. if test "$have_debug" == "yes"; then
  285. AC_MSG_NOTICE([Debug compile mode enabled]);
  286. AM_CPPFLAGS="${AM_CPPFLAGS} -DDEBUG"
  287. AM_CXXFLAGS="${AM_CXXFLAGS:-} -ggdb3 -O0"
  288. AM_LDFLAGS="${AM_LDFLAGS} -ggdb3 -O0"
  289. else
  290. AM_CPPFLAGS="${AM_CPPFLAGS} -DQT_NO_DEBUG_OUTPUT -DQT_NO_DEBUG"
  291. fi
  292. AC_ARG_WITH(gcov,
  293. [AS_HELP_STRING([--with-gcov=FILE],
  294. [enable gcov, set gcov file (defaults to gcov)])],
  295. [GCOV="$enableval"], [GCOV="no"])
  296. AM_CONDITIONAL(COVERAGE, test "$GCOV" != "no")
  297. if test "$GCOV" != "no"; then
  298. if test "$GCOV" == "yes"; then
  299. GCOV=gcov
  300. fi
  301. AC_CHECK_PROG(has_gcov, [$GCOV], [yes], [no])
  302. if test "$has_gcov" != "yes"; then
  303. AC_MSG_ERROR([gcov: program $GCOV not found])
  304. fi
  305. AC_MSG_NOTICE([Coverage tests enabled, using ${GCOV}]);
  306. AM_CXXFLAGS="${AM_CXXFLAGS:-} -O0 --coverage -fprofile-arcs -ftest-coverage"
  307. AM_LDFLAGS="${AM_LDFLAGS} -O0 --coverage -fprofile-arcs"
  308. AX_SUBST(GCOV)
  309. fi
  310. if test -f ${PACKAGE_NAME}.desktop.in; then
  311. AC_CONFIG_FILES([${PACKAGE_NAME}.desktop])
  312. fi
  313. AC_CONFIG_FILES([makefile])
  314. AX_ADD_MAKEFILE_TARGET_DEP([clean-am], [clean-standard-project-targets], [makefile.in])
  315. AX_ADD_MAKEFILE_TARGET_DEP([distclean-am], [distclean-standard-project-targets], [makefile.in])
  316. AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-standard-project-targets], [makefile.in])
  317. test -f makefile.in && cat >> makefile.in <<EOF
  318. #### Begin: Appended by $0
  319. EXTRA_DIST += bootstrap.sh ax_init_standard_project.m4 ax_cxx_compile_stdcxx.m4 \
  320. ax_check_qt.m4 resolve-debbuilddeps.sh resolve-rpmbuilddeps.sh \
  321. build-resource-file.sh mac-create-app-bundle.sh
  322. clean-standard-project-targets:
  323. -rm -rf \${PACKAGE_NAME}-\${PACKAGE_VERSION}
  324. -rm \${PACKAGE_TARNAME}-\${PACKAGE_VERSION}.tar.gz
  325. distclean-standard-project-targets:
  326. -rm -r autom4te.cache
  327. -rm aclocal.m4 config.guess config.sub configure depcomp compile install-sh ltmain.sh makefile missing mkinstalldirs test-driver
  328. maintainer-clean-standard-project-targets:
  329. -rm makefile.in
  330. #### End: $0
  331. EOF
  332. ])
  333. # use this in configure.ac to support C++
  334. AC_DEFUN([AX_USE_CXX], [
  335. m4_include(ax_cxx_compile_stdcxx.m4)
  336. AC_LANG(C++)
  337. AX_CXX_COMPILE_STDCXX([17], [noext], [optional])
  338. AC_PROG_CXX
  339. AC_PROG_CPP
  340. AC_CONFIG_FILES([src/makefile])
  341. AM_CPPFLAGS+=' -I ${top_srcdir}/src -I ${top_builddir}/src -I ${srcdir} -I ${builddir}'
  342. AM_LDFLAGS+=' -L ${top_srcdir}/src -L ${top_builddir}/src'
  343. # Get rid of those stupid -g -O2 options!
  344. CXXFLAGS="${CXXFLAGS//-g -O2/}"
  345. CFLAGS="${CFLAGS//-g -O2/}"
  346. # pass compile flags to make distcheck
  347. AM_DISTCHECK_CONFIGURE_FLAGS="CXXFLAGS='${CXXFLAGS}' CPPFLAGS='${CPPFLAGS}' CFLAGS='${CFLAGS}' LDFLAGS='${LDFLAGS}'"
  348. AC_SUBST(AM_DISTCHECK_CONFIGURE_FLAGS)
  349. AC_SUBST(AM_CXXFLAGS)
  350. AC_SUBST(AM_CPPFLAGS)
  351. AC_SUBST(AM_LDFLAGS)
  352. AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-cxx-targets], [src/makefile.in])
  353. test -f src/makefile.in && cat >> src/makefile.in <<EOF
  354. #### Begin: Appended by $0
  355. %.app: %
  356. -rm -r [\$][@]
  357. \$(MAKE) DESTDIR=[\$][\$](pwd)/tmp install
  358. QTDIR="\${QTDIR}" \
  359. QT_PLUGINS="\${QT_PLUGINS}" \
  360. QT_PLUGIN_PATH="\${QT_PLUGIN_PATH}" \
  361. \${top_builddir}/mac-create-app-bundle.sh \
  362. [\$][@] [\$][<] [\$][\$](pwd)/tmp[\$]{prefix}
  363. -rm -rf tmp
  364. maintainer-clean-cxx-targets:
  365. -rm makefile.in
  366. #### End: $0
  367. EOF
  368. ])
  369. # require specific C++ version
  370. AC_DEFUN([AX_USE_CXX_11], [
  371. AX_USE_CXX
  372. AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
  373. ])
  374. AC_DEFUN([AX_USE_CXX_14], [
  375. AX_USE_CXX
  376. AX_CXX_COMPILE_STDCXX([14], [noext], [mandatory])
  377. ])
  378. AC_DEFUN([AX_USE_CXX_17], [
  379. AX_USE_CXX
  380. AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])
  381. ])
  382. # use this in configure.ac to support old school C
  383. AC_DEFUN([AX_USE_C], [
  384. AC_LANG(C)
  385. AC_PROG_CC
  386. AC_PROG_CPP
  387. AC_CONFIG_FILES([src/makefile])
  388. AM_CPPFLAGS+=' -I ${top_srcdir}/src -I ${top_builddir}/src -I ${srcdir} -I ${builddir}'
  389. AM_LDFLAGS+=' -L ${top_srcdir}/src -L ${top_builddir}/src'
  390. # Get rid of those stupid -g -O2 options!
  391. CXXFLAGS="${CXXFLAGS//-g -O2/}"
  392. CFLAGS="${CFLAGS//-g -O2/}"
  393. # pass compile flags to make distcheck
  394. AM_DISTCHECK_CONFIGURE_FLAGS="CFLAGS='${CFLAGS}' CPPFLAGS='${CPPFLAGS}' CFLAGS='${CFLAGS}' LDFLAGS='${LDFLAGS}'"
  395. AC_SUBST(AM_DISTCHECK_CONFIGURE_FLAGS)
  396. AC_SUBST(AM_CFLAGS)
  397. AC_SUBST(AM_CPPFLAGS)
  398. AC_SUBST(AM_LDFLAGS)
  399. AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-c-targets], [src/makefile.in])
  400. test -f src/makefile.in && cat >> src/makefile.in <<EOF
  401. #### Begin: Appended by $0
  402. %.app: %
  403. -rm -r [\$][@]
  404. \$(MAKE) DESTDIR=[\$][\$](pwd)/[\$][@]/tmp install
  405. \${top_builddir}/mac-create-app-bundle.sh \
  406. [\$][@] [\$][<] [\$][\$](pwd)/[\$][@]/tmp\${prefix}
  407. maintainer-clean-c-targets:
  408. -rm makefile.in
  409. #### End: $0
  410. EOF
  411. ])
  412. # use this in configure.ac to support tests without CppUnit
  413. AC_DEFUN([AX_BUILD_TEST], [
  414. AC_CONFIG_FILES([test/makefile])
  415. AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-test-targets], [test/makefile.in])
  416. test -f test/makefile.in && cat >> test/makefile.in <<EOF
  417. #### Begin: Appended by $0
  418. maintainer-clean-test-targets:
  419. -rm makefile.in
  420. #### End: $0
  421. EOF
  422. ])
  423. # use this in configure.ac to support CppUnit for C++ unit tests
  424. AC_DEFUN([AX_USE_CPPUNIT], [
  425. PKG_CHECK_MODULES(CPPUNIT, cppunit, [have_cppunit="yes"], [have_cppunit="no"])
  426. # infos and warnings
  427. if test "$have_cppunit" = "no"; then
  428. AC_MSG_WARN([Missing cppunit development library!
  429. - you cannot check the project using "make check"
  430. - everything else works perfectly]); fi
  431. AX_BUILD_TEST
  432. ])
  433. # use this in configure.ac to support C++ examples
  434. AC_DEFUN([AX_BUILD_EXAMPLES], [
  435. AC_CONFIG_FILES([examples/makefile])
  436. AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-example-targets], [examples/makefile.in])
  437. test -f examples/makefile.in && cat >> examples/makefile.in <<EOF
  438. #### Begin: Appended by $0
  439. maintainer-clean-example-targets:
  440. -rm makefile.in
  441. #### End: $0
  442. EOF
  443. ])
  444. # use this in configure.ac to support NodeJS
  445. AC_DEFUN([AX_USE_NODEJS], [
  446. AC_PATH_PROG(ANDROID, [android], [0],
  447. [${PATH}${PATH_SEPARATOR}${ANDROID_HOME}/tools])
  448. AC_CONFIG_FILES([nodejs/package.json])
  449. AC_CONFIG_FILES([nodejs/makefile])
  450. if test -z "${DEB_SECTION}"; then
  451. AX_DEB_SECTION([web])
  452. fi
  453. if test -z "${RPM_GROUP}"; then
  454. AX_RPM_GROUP([Applications/Internet])
  455. fi
  456. AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-nodejs-targets], [nodejs/makefile.in])
  457. test -f nodejs/makefile.in && cat >> nodejs/makefile.in <<EOF
  458. #### Begin: Appended by $0
  459. maintainer-clean-nodejs-targets:
  460. -rm makefile.in
  461. #### End: $0
  462. EOF
  463. ])
  464. # use this in configure.ac to support Cordova
  465. AC_DEFUN([AX_USE_CORDOVA], [
  466. AC_PATH_PROG(ANDROID, [android], [0],
  467. [${PATH}${PATH_SEPARATOR}${ANDROID_HOME}/tools])
  468. AC_PATH_PROG(CORDOVA, [cordova], [0],
  469. [${PATH}${PATH_SEPARATOR}$(pwd)/node_modules/cordova/bin])
  470. if test ${CORDOVA} = 0; then
  471. AC_MSG_WARN([cordova is missing, on ubuntu install cordova-cli from repository ppa:cordova-ubuntu/ppa])
  472. fi
  473. if test ${ANDROID} = 0; then
  474. AC_MSG_WARN([android sdk is missing, set variable ANDROID_HOME after installation])
  475. fi
  476. AM_CONDITIONAL(HAVE_CORDOVA, [test ${CORDOVA} != 0 -a ${ANDROID} != 0])
  477. AX_SUBST(CORDOVA)
  478. AC_CONFIG_FILES([cordova/makefile])
  479. AC_CONFIG_FILES([cordova/config.xml])
  480. EOF
  481. AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-cordova-targets], [cordova/makefile.in])
  482. test -f cordova/makefile.in && cat >> cordova/makefile.in <<EOF
  483. #### Begin: Appended by $0
  484. maintainer-clean-cordova-targets:
  485. -rm makefile.in
  486. #### End: $0
  487. EOF
  488. ])
  489. # use this in configure.ac to support HTML data for webservers
  490. AC_DEFUN([AX_BUILD_HTML], [
  491. AC_CONFIG_FILES([html/makefile])
  492. if test -z "${DEB_SECTION}"; then
  493. AX_DEB_SECTION([web])
  494. fi
  495. if test -z "${RPM_GROUP}"; then
  496. AX_RPM_GROUP([Applications/Internet])
  497. fi
  498. AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-html-targets], [html/makefile.in])
  499. test -f html/makefile.in && cat >> html/makefile.in <<EOF
  500. #### Begin: Appended by $0
  501. maintainer-clean-html-targets:
  502. -rm makefile.in
  503. #### End: $0
  504. EOF
  505. ])
  506. # use this in configure.ac to support HTML data for webservers
  507. AC_DEFUN([AX_BUILD_HTML_NPM], [
  508. AC_CONFIG_FILES([html/package.json])
  509. AX_BUILD_HTML
  510. ])
  511. # use this in configure.ac to support C++ libraries
  512. AC_DEFUN([AX_USE_LIBTOOL], [
  513. # libtool versioning
  514. LIB_MAJOR=m4_eval(x_major+x_minor+x_minor_diff)
  515. LIB_MINOR=x_least
  516. LIB_LEAST=m4_eval(x_minor+x_minor_diff)
  517. LIB_VERSION="${LIB_MAJOR}:${LIB_MINOR}:${LIB_LEAST}"
  518. AM_LDFLAGS="-version-info ${LIB_VERSION}"
  519. AC_SUBST(AM_LDFLAGS)
  520. AC_SUBST(LIB_VERSION)
  521. AC_PROG_LIBTOOL
  522. AC_CONFIG_FILES([src/${PACKAGE_NAME}.pc])
  523. if test -z "${DEB_SECTION}"; then
  524. AX_DEB_SECTION([devel])
  525. fi
  526. if test -z "${RPM_GROUP}"; then
  527. AX_RPM_GROUP([Development/Libraries])
  528. fi
  529. AX_ADD_MAKEFILE_TARGET_DEP([install-data-am], [install-data-libtool-pkg], [src/makefile.in])
  530. AX_ADD_MAKEFILE_TARGET_DEP([uninstall-am], [uninstall-data-am], [src/makefile.in])
  531. AX_ADD_MAKEFILE_TARGET_DEP([uninstall-data-am], [uninstall-data-libtool-pkg], [src/makefile.in])
  532. test -f src/makefile.in && cat >> src/makefile.in <<EOF
  533. #### Begin: Appended by $0
  534. install-data-libtool-pkg:
  535. test -d \$(DESTDIR)\${libdir}/pkgconfig || mkdir -p \$(DESTDIR)\${libdir}/pkgconfig
  536. chmod -R u+w \$(DESTDIR)\${libdir}/pkgconfig
  537. cp \${PACKAGE_NAME}.pc \$(DESTDIR)\${libdir}/pkgconfig/
  538. uninstall-data-libtool-pkg:
  539. -chmod -R u+w \$(DESTDIR)\${libdir}/pkgconfig
  540. -rm -f \$(DESTDIR)\${libdir}/pkgconfig/\${PACKAGE_NAME}.pc
  541. #### End: $0
  542. EOF
  543. ])
  544. # use this in configure.ac to support debian packages
  545. # - $1: optional debian package section
  546. AC_DEFUN([AX_USE_DEBIAN_PACKAGING], [
  547. if test -n "$1"; then
  548. AX_DEB_SECTION([$1])
  549. fi
  550. if test -f README.md; then
  551. README_DEB=$(tail -n +3 README.md | sed -e 's/^ *$/./g' -e 's/^/ /g')
  552. else
  553. README_DEB=$(tail -n +3 README | sed -e 's/^ *$/./g' -e 's/^/ /g')
  554. fi
  555. AC_SUBST(README_DEB)
  556. _AM_SUBST_NOTMAKE([README_DEB])
  557. AC_CONFIG_FILES([debian/changelog debian/control])
  558. AX_ADD_MAKEFILE_TARGET_DEP([clean-am], [clean-debian-targets], [makefile.in])
  559. AX_ADD_MAKEFILE_TARGET_DEP([distclean-am], [distclean-debian-targets], [makefile.in])
  560. test -f makefile.in && cat >> makefile.in <<EOF
  561. #### Begin: Appended by $0
  562. EXTRA_DIST += debian
  563. clean-debian-targets:
  564. -rm -rf \${PACKAGE_NAME}_\${PACKAGE_VERSION}~\${DISTRO}.\${BUILD_NUMBER}.{dsc,tar.gz} \${PACKAGE_NAME}_\${PACKAGE_VERSION}~\${DISTRO}.\${BUILD_NUMBER}*.changes \$\$(sed -n 's,Package: \(.*\),\1_${PACKAGE_VERSION}~${DISTRO}.${BUILD_NUMBER}*.deb,p;' debian/control)
  565. deb: distdir
  566. cd \${PACKAGE_NAME}-\${PACKAGE_VERSION} && ( export CFLAGS="\${CFLAGS}"; export CPPFLAGS="\${CPPFLAGS}"; export CXXFLAGS="\${CXXFLAGS}"; export LDFLAGS="\${LDFLAGS}"; export DEB_CFLAGS_APPEND="\${CFLAGS}"; export DEB_CPPFLAGS_APPEND="\${CPPFLAGS}"; export DEB_CXXFLAGS_APPEND="\${CXXFLAGS}"; export DEB_LDFLAGS_APPEND="\${LDFLAGS}"; dpkg-buildpackage )
  567. gpg --verify \${PACKAGE_NAME}_\${PACKAGE_VERSION}~\${DISTRO}.\${BUILD_NUMBER}.dsc
  568. distclean-debian-targets:
  569. -rm debian/changelog debian/control
  570. #### End: $0
  571. EOF
  572. ])
  573. # use this in configure.ac to support RPM packages
  574. # - $1: optional rpm package group
  575. AC_DEFUN([AX_USE_RPM_PACKAGING], [
  576. if test -n "$1"; then
  577. AX_RPM_GROUP([$1])
  578. fi
  579. AC_CONFIG_FILES([${PACKAGE_NAME}.spec])
  580. #AX_ADD_MAKEFILE_TARGET_DEP([clean-am], [clean-rpm-targets], [makefile.in])
  581. AX_ADD_MAKEFILE_TARGET_DEP([clean-am], [clean-rpm-targets], [makefile.in])
  582. AX_ADD_MAKEFILE_TARGET_DEP([distclean-am], [distclean-rpm-targets], [makefile.in])
  583. test -f makefile.in && cat >> makefile.in <<EOF
  584. #### Begin: Appended by $0
  585. EXTRA_DIST += \${PACKAGE_NAME}.spec.in
  586. rpm: dist
  587. rpmbuild -ba --define "_topdir \$\$(pwd)" --define "_sourcedir \$\$(pwd)" \${PACKAGE_NAME}.spec
  588. ./rpmsign.exp "\${PACKAGER}" "\{PASSWORD}" RPMS/*/*.rpm SRPMS/*.rpm
  589. clean-rpm-targets:
  590. -rm -rf BUILD BUILDROOT RPMS SPECS SRPMS
  591. distclean-rpm-targets:
  592. -rm \${PACKAGE_NAME}.spec
  593. #### End: $0
  594. EOF
  595. ])
  596. # use this in configure.ac to support scripts, e.g. bash scripts
  597. AC_DEFUN([AX_USE_ETC], [
  598. AC_CONFIG_FILES([etc/makefile])
  599. ])
  600. # use this in configure.ac to support scripts, e.g. bash scripts
  601. AC_DEFUN([AX_USE_SCRIPTS], [
  602. AC_CONFIG_FILES([scripts/makefile])
  603. ])
  604. # use this in configure.ac to support Doxygen documentation generation
  605. AC_DEFUN([AX_USE_DOXYGEN], [
  606. AC_CHECK_PROG(have_doxygen, doxygen, yes, no)
  607. AC_CHECK_PROG(have_dot, dot, yes, no)
  608. AC_CHECK_PROG(have_mscgen, mscgen, yes, no)
  609. PDF_DOC=${PACKAGE_NAME}-${PACKAGE_VERSION}.pdf
  610. AC_SUBST(PDF_DOC)
  611. if test "$have_doxygen" = "no"; then
  612. AC_MSG_WARN([Missing program doxygen!
  613. - you cannot rebuild the documentation
  614. - there are precompiled derived files in the distribution]); fi
  615. if test "$have_dot" = "no"; then
  616. AC_MSG_WARN([Missing program dot!
  617. - when you rebild documentation, there are no generated images
  618. - there are precompiled derived files in the distribution]); fi
  619. if test "$have_mscgen" = "no"; then
  620. AC_MSG_WARN([Missing program mscgen!
  621. - when you rebild documentation, there are no message state charts
  622. - there are precompiled derived files in the distribution]); fi
  623. AC_CONFIG_FILES([doc/makefile doc/doxyfile doc/header.html doc/footer.html])
  624. AX_ADD_MAKEFILE_TARGET_DEP([clean-am], [clean-documentation], [doc/makefile.in])
  625. AX_ADD_MAKEFILE_TARGET_DEP([distclean-am], [distclean-documentation], [doc/makefile.in])
  626. AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-documentation], [doc/makefile.in])
  627. AX_ADD_MAKEFILE_TARGET_DEP([install-data-am], [install-data-documentation], [doc/makefile.in])
  628. AX_ADD_MAKEFILE_TARGET_DEP([uninstall-am], [uninstall-documentation], [doc/makefile.in])
  629. AX_ADD_MAKEFILE_TARGET_DEP([all], [doc], [doc/makefile.in])
  630. AX_ADD_MAKEFILE_TARGET_DEP([.PHONY], [pdf gen-uml-images], [doc/makefile.in])
  631. test -f doc/makefile.in && cat >> doc/makefile.in <<EOF
  632. #### Begin: Appended by $0
  633. doc: doxyfile
  634. doxygen doxyfile
  635. @PEDANTIC_TRUE@ test \! -s doxygen.errors
  636. clean-documentation:
  637. -rm doxygen.errors @PDF_DOC@
  638. distclean-documentation:
  639. -rm -r html
  640. -rm @PACKAGE_NAME@.doxytag
  641. maintainer-clean-documentation:
  642. -rm makefile.in
  643. install-data-documentation:
  644. test -d \$(DESTDIR)\${docdir} || mkdir -p \$(DESTDIR)\${docdir}
  645. chmod -R u+w \$(DESTDIR)\${docdir}
  646. cp -r html \$(DESTDIR)\${docdir}/
  647. uninstall-documentation:
  648. -chmod -R u+w \$(DESTDIR)\${docdir}
  649. -rm -rf \$(DESTDIR)\${docdir}/html
  650. #### End: $0
  651. EOF
  652. ])
  653. # use this in configure.ac to support Doxygen documentation generation
  654. AC_DEFUN([AX_USE_PERLDOC], [
  655. PERL_SOURCES="m4_default([$1], [perl])"
  656. AX_SUBST(PERL_SOURCES)
  657. if test -z "$PERL_SOURCES"; then
  658. AC_MSG_ERROR([You must specify the path to perl files
  659. - use [AX]_[USE]_PERLDOC([[pathes to perldoc]])]); fi
  660. AC_CHECK_PROG(have_perldoc, pods2html, yes, no)
  661. if test "$have_doxygen" = "no"; then
  662. AC_MSG_WARN([Missing program pods2html!
  663. - you cannot rebuild the documentation
  664. - there are precompiled derived files in the distribution
  665. - if you need to generate documentation, install libpod-tree-perl]); fi
  666. AC_CONFIG_FILES([doc/makefile])
  667. AX_ADD_MAKEFILE_TARGET_DEP([distclean-am], [distclean-perldoc], [doc/makefile.in])
  668. AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-perldoc], [doc/makefile.in])
  669. AX_ADD_MAKEFILE_TARGET_DEP([install-data-am], [install-data-perldoc], [doc/makefile.in])
  670. AX_ADD_MAKEFILE_TARGET_DEP([uninstall-am], [uninstall-perldoc], [doc/makefile.in])
  671. AX_ADD_MAKEFILE_TARGET_DEP([all], [doc], [doc/makefile.in])
  672. AX_ADD_MAKEFILE_TARGET_DEP([.PHONY], [doc], [doc/makefile.in])
  673. test -f doc/makefile.in && cat >> doc/makefile.in <<EOF
  674. #### Begin: Appended by $0
  675. doc: perldoc/index.html
  676. perldoc/index.html: \${PERL_SOURCES:%=perldoc/%}
  677. echo "<html><head><title>Perl Documentation</title></head><body><h1>Perl Documentation</h1><ul>" > perldoc/index.html
  678. for p in \${PERL_SOURCES:%=perldoc/%}; do \
  679. echo '<li><a href="'"\$\${p#perldoc/}"'/index.html">'"\$\${p#perldoc/}"'</a></li>' >> perldoc/index.html; \
  680. done
  681. echo "</ul></body></html>" >> perldoc/index.html
  682. perldoc/%:
  683. pods2html --notoc --empty --index index @top_srcdir@/\${@:perldoc/%=%} \$[@]
  684. distclean-perldoc:
  685. -rm -r perldoc
  686. maintainer-clean-perldoc:
  687. -rm makefile.in
  688. install-data-perldoc:
  689. test -d \$(DESTDIR)\${docdir} || mkdir -p \$(DESTDIR)\${docdir}
  690. chmod -R u+w \$(DESTDIR)\${docdir}
  691. cp -r perldoc \$(DESTDIR)\${docdir}/
  692. uninstall-perldoc:
  693. -chmod -R u+w \$(DESTDIR)\${docdir}
  694. -rm -rf \$(DESTDIR)\${docdir}/perldoc
  695. #### End: $0
  696. EOF
  697. ])
  698. # require a specific package, with fallback: test for a header
  699. # - parameter:
  700. # $1 = unique id (no special characters)
  701. # $2 = module name (optional, if different from id)
  702. # $3 = a header file to find (optional)
  703. # $4 = alternative module names (space separated, optional)
  704. # $5 = optional flags:
  705. # manualflags if CXXFLAGS, CPPFLAGS, LIBS should remain unchanged
  706. # $6 = optional parameters, allowed are (evaluated in this order):
  707. # - DEV_RPM_DIST_PKG=<name>
  708. # special name for the RPM development package
  709. # - DEV_DEB_DIST_PKG=<name>
  710. # special name for the debian development package
  711. # - DEV_DIST_PKG=<name>
  712. # if the name of the development package is different
  713. #
  714. # uses PKG_CHECK_MODULES to test for a module
  715. # then, if given, looks for the header file
  716. # if header file is not found, searches in alternative modules
  717. # sets all flags, so that the module can be used everywhere
  718. # fails if not found
  719. AC_DEFUN([AX_PKG_REQUIRE], [
  720. PKG_PROG_PKG_CONFIG
  721. optional_flags="$5"
  722. $1_found=no
  723. secondpar="m4_default([$2], [$1])"
  724. PKG_CHECK_MODULES([$1], [m4_default([$2], [$1])], [
  725. $1_found=$secondpar
  726. PKG_REQUIREMENTS+=" $secondpar"
  727. ], [
  728. if test -n "$4"; then
  729. AC_MSG_WARN([Recommended package $secondpar for feature $1 not installed, trying $4])
  730. for pkg in $4; do
  731. PKG_CHECK_MODULES([$1], [$pkg], [
  732. PKG_REQUIREMENTS+=" $pkg"
  733. $1_found=$pkg
  734. break;
  735. ], [
  736. AC_MSG_WARN([Recommended package $pkg for feature $1 not installed])
  737. ])
  738. done
  739. fi
  740. ])
  741. AC_SUBST(CPPFLAGS)
  742. AC_SUBST(CXXFLAGS)
  743. AC_SUBST(PKG_REQUIREMENTS)
  744. if test -n "$3"; then
  745. if test "${$1_found}" = "no"; then
  746. tmp_package="yes"
  747. else
  748. tmp_package=${$1_found}
  749. fi
  750. $1_found=no
  751. old_CPPFLAGS=${CPPFLAGS}
  752. CPPFLAGS=" ${$1_CFLAGS} ${CPPFLAGS}"
  753. AC_CHECK_HEADER([$3], [
  754. $1_found=${tmp_package}
  755. ], [
  756. for x in ${$1_CFLAGS}; do
  757. AC_MSG_NOTICE([search for $3 in ${x[#]-I}])
  758. for f in $(find ${x[#]-I} -name "$3" 2> /dev/null); do
  759. if test -f "$f"; then
  760. $1_found=${tmp_package}
  761. $1_CFLAGS+=" -I${f%/*}"
  762. AC_MSG_NOTICE([added path ${f%/*}])
  763. break;
  764. fi
  765. done
  766. if test "${$1_found}" != "no"; then
  767. break;
  768. fi
  769. done
  770. if test "${$1_found}" = "no"; then
  771. tmp_includedir=$(${PKG_CONFIG} --variable=includedir $tmp_package)
  772. for x in ${tmp_includedir}; do
  773. AC_MSG_NOTICE([search for $3 in $x])
  774. for f in $(find ${x} -name "$3" 2> /dev/null); do
  775. if test -f "$f"; then
  776. $1_found=${tmp_package}
  777. $1_CFLAGS+=" -I${f%/*}"
  778. AC_MSG_NOTICE([added path ${f%/*}])
  779. break;
  780. fi
  781. done
  782. if test "${$1_found}" != "no"; then
  783. break;
  784. fi
  785. done
  786. fi
  787. ])
  788. CPPFLAGS=${old_CPPFLAGS}
  789. fi
  790. if test "${$1_found}" = "no"; then
  791. if test -n "$3"; then
  792. if test -n "$4"; then
  793. AC_MSG_ERROR([Feature $1 not found, need header $3 in modules $secondpar or $4])
  794. else
  795. AC_MSG_ERROR([Feature $1 not found, need header $3 in module $secondpar])
  796. fi
  797. else
  798. AC_MSG_ERROR([Feature $1 not found please install module $secondpar])
  799. fi
  800. fi
  801. [$1]_CPPFLAGS="${$1_CFLAGS}"
  802. [$1]_CXXFLAGS="${$1_CFLAGS}"
  803. AC_SUBST([$1]_CPPFLAGS)
  804. AC_SUBST([$1]_CXXFLAGS)
  805. if test "${optional_flags/manualflags/}" = "${optional_flags}"; then
  806. CPPFLAGS+=" ${$1_CPPFLAGS}"
  807. CXXFLAGS+=" ${$1_CXXFLAGS}"
  808. LIBS+=" ${$1_LIBS}"
  809. AC_MSG_NOTICE([Adding flags for $1])
  810. else
  811. AC_MSG_NOTICE([To enable $1, add $1_CPPFLAGS, $1_CXXFLAGS and $1_LIBS])
  812. fi
  813. DEV_DEB_DIST_PKG=
  814. DEV_RPM_DIST_PKG=
  815. DEV_DIST_PKG=
  816. pkg=m4_default([$2], [$1])
  817. $6
  818. deb_pkg=${DEV_DEB_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-dev}
  819. rpm_pkg=${DEV_RPM_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-devel}
  820. if test -n "$4"; then
  821. for f in $pkg $4; do
  822. if test -n "$(apt-cache policy -q ${f}-dev 2> /dev/null)"; then
  823. deb_pkg=${f}-dev
  824. break
  825. fi
  826. done
  827. for f in $pkg $4; do
  828. if (test -x /usr/bin/zypper && zypper search -x "${f}-devel" 1>&2 > /dev/null) || \
  829. (test -x /usr/bin/dnf && dnf list -q "${f}-devel" 1>&2 > /dev/null) || \
  830. (test -x /usr/bin/yum && yum list -q "${f}-devel" 1>&2 > /dev/null) || \
  831. (test -x /usr/sbin/urpmq && urpmq "${f}-devel" 1>&2 > /dev/null); then
  832. rpm_pkg=${f}-devel
  833. break
  834. fi
  835. done
  836. fi
  837. AX_DEB_BUILD_DEPEND([$deb_pkg])
  838. AX_RPM_BUILD_DEPEND([$rpm_pkg])
  839. ])
  840. # check if a specific package exists
  841. # - parameter:
  842. # $1 = unique id (no special characters)
  843. # $2 = module name (optional, if different from id)
  844. # $3 = optional flags:
  845. # manualflags if CXXFLAGS, CPPFLAGS, LIBS should remain unchanged
  846. # $4 = optional parameters, allowed are (evaluated in this order):
  847. # - DEV_RPM_DIST_PKG=<name>
  848. # special name for the RPM development package
  849. # - DEV_DEB_DIST_PKG=<name>
  850. # special name for the debian development package
  851. # - DEV_DIST_PKG=<name>
  852. # if the name of the development package is different
  853. #
  854. # uses PKG_CHECK_MODULES to test for a module
  855. # sets automake conditional HAVE_$1 to 0 (not found) or 1 (found)
  856. # sets all flags, so that the module can be used everywhere
  857. AC_DEFUN([AX_PKG_CHECK], [
  858. optional_flags="$3"
  859. PKG_PROG_PKG_CONFIG
  860. PKG_CHECK_MODULES([$1], [m4_default([$2], [$1])], [
  861. HAVE_$1=1
  862. [$1]_CPPFLAGS="${$1_CFLAGS}"
  863. [$1]_CXXFLAGS="${$1_CFLAGS}"
  864. AC_SUBST([$1]_CPPFLAGS)
  865. AC_SUBST([$1]_CXXFLAGS)
  866. if test "${optional_flags/manualflags/}" = "${optional_flags}"; then
  867. CPPFLAGS+=" ${$1_CPPFLAGS}"
  868. CXXFLAGS+=" ${$1_CXXFLAGS}"
  869. LIBS+=" ${$1_LIBS}"
  870. AC_MSG_NOTICE([Adding flags for $1])
  871. else
  872. AC_MSG_NOTICE([To enable $1, add $1_CPPFLAGS, $1_CXXFLAGS and $1_LIBS])
  873. fi
  874. if test -z "$PKG_REQUIREMENTS"; then
  875. PKG_REQUIREMENTS="m4_default([$2], [$1])"
  876. else
  877. PKG_REQUIREMENTS="${PKG_REQUIREMENTS}, m4_default([$2], [$1])"
  878. fi
  879. ], [
  880. HAVE_$1=0
  881. ])
  882. AM_CONDITIONAL(HAVE_$1, test $HAVE_[$1] -eq 1)
  883. AC_SUBST(HAVE_$1)
  884. AC_SUBST(CPPFLAGS)
  885. AC_SUBST(CXXFLAGS)
  886. AC_SUBST(PKG_REQUIREMENTS)
  887. DEV_DEB_DIST_PKG=
  888. DEV_RPM_DIST_PKG=
  889. DEV_DIST_PKG=
  890. pkg=m4_default([$2], [$1])
  891. $4
  892. dep_pkg=${DEV_DEB_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-dev}
  893. rpm_pkg=${DEV_RPM_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-devel}
  894. if test -n "$(apt-cache policy -q ${deb_pkg} 2> /dev/null)"; then
  895. AX_DEB_BUILD_DEPEND([$deb_pkg])
  896. fi
  897. if (test -x /usr/bin/zypper && zypper search -x "$rpm_pkg" 1>&2 > /dev/null) || \
  898. (test -x /usr/bin/dnf && dnf list -q "$rpm_pkg" 1>&2 > /dev/null) || \
  899. (test -x /usr/bin/yum && yum list -q "$rpm_pkg" 1>&2 > /dev/null) || \
  900. (test -x /usr/sbin/urpmq && urpmq "$rpm_pkg" 1>&2 > /dev/null); then
  901. AX_RPM_BUILD_DEPEND([$rpm_pkg])
  902. fi
  903. ])
  904. # make sure, a specific header exists
  905. # - parameter:
  906. # $1 = header name
  907. # $2 = pathes to search for
  908. AC_DEFUN([AX_REQUIRE_HEADER], [
  909. AC_CHECK_HEADER($1, [], [
  910. found=0
  911. if test -n "$2"; then
  912. for d in $2; do
  913. if test -f "${d}/$1"; then
  914. AC_MSG_NOTICE([found file ${d}/$1])
  915. CPPFLAGS+=" -I${d}"
  916. found=1
  917. break;
  918. else
  919. AC_MSG_NOTICE([not found file ${d}/$1])
  920. fi
  921. done
  922. fi
  923. if test $found -eq 0; then
  924. AC_MSG_ERROR([Header $1 not found])
  925. fi
  926. ], [])
  927. ], [])
  928. ])
  929. # Check within a list of CPP-Flags for the first that is usable and
  930. # configure it
  931. # - parameter:
  932. # $1 = white-space separated list of alternative flags
  933. # $2 = module name (optional, if different from id)
  934. AC_DEFUN([AX_CHECK_VALID_CPP_FLAG], [
  935. AC_MSG_CHECKING([m4_default([$2], [for valid flag in "$1"])])
  936. save_cppflags="$CPPFLAGS"
  937. newflag="no"
  938. for test_flag in $1; do
  939. CPPFLAGS+=" ${test_flag}"
  940. AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
  941. newflag="$test_flag"
  942. CPPFLAGS="$save_cppflags"
  943. CPPFLAGS+=" ${test_flag}"
  944. break;
  945. ])
  946. CPPFLAGS="$save_cppflags"
  947. done
  948. AC_SUBST(CPPFLAGS)
  949. AC_MSG_RESULT([$newflag in $CPPFLAGS])
  950. ])
  951. # Check within a list of CXX-Flags for the first that is usable and
  952. # configure it
  953. # - parameter:
  954. # $1 = white-space separated list of alternative flags
  955. # $2 = module name (optional, if different from id)
  956. AC_DEFUN([AX_CHECK_VALID_CXX_FLAG], [
  957. AC_MSG_CHECKING([m4_default([$2], [for valid flag in "$1"])])
  958. save_cxxflags="$CXXFLAGS"
  959. newflag="no"
  960. for test_flag in $1; do
  961. CXXFLAGS+=" ${test_flag}"
  962. AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
  963. newflag="$test_flag"
  964. CXXFLAGS="$save_cxxflags"
  965. CXXFLAGS+=" ${test_flag}"
  966. break;
  967. ])
  968. CXXFLAGS="$save_cxxflags"
  969. done
  970. AC_SUBST(CXXFLAGS)
  971. AC_MSG_RESULT([$newflag in $CXXFLAGS])
  972. ])
  973. # Check within a list of C-Flags for the first that is usable and
  974. # configure it
  975. # - parameter:
  976. # $1 = white-space separated list of alternative flags
  977. # $2 = module name (optional, if different from id)
  978. AC_DEFUN([AX_CHECK_VALID_C_FLAG], [
  979. AC_MSG_CHECKING([m4_default([$2], [for valid flag in "$1"])])
  980. save_cflags="$CFLAGS"
  981. newflag="no"
  982. for test_flag in $1; do
  983. CFLAGS+=" ${test_flag}"
  984. AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
  985. newflag="$test_flag"
  986. CFLAGS="$save_cflags"
  987. CFLAGS+=" ${test_flag}"
  988. break;
  989. ])
  990. CFLAGS="$save_cflags"
  991. done
  992. AC_SUBST(CFLAGS)
  993. AC_MSG_RESULT([$newflag in $CFLAGS])
  994. ])
  995. # Check within a list of LD-Flags for the first that is usable and
  996. # configure it
  997. # - parameter:
  998. # $1 = white-space separated list of alternative flags
  999. # $2 = module name (optional, if different from id)
  1000. AC_DEFUN([AX_CHECK_VALID_LD_FLAG], [
  1001. AC_MSG_CHECKING([m4_default([$2], [for valid flag in "$1"])])
  1002. save_ldflags="$LDFLAGS"
  1003. newflag="no"
  1004. for test_flag in $1; do
  1005. LDFLAGS+=" ${test_flag}"
  1006. AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
  1007. newflag="$test_flag"
  1008. LDFLAGS="$save_ldflags"
  1009. LDFLAGS+=" ${test_flag}"
  1010. break;
  1011. ])
  1012. LDFLAGS="$save_ldflags"
  1013. done
  1014. AC_SUBST(LDFLAGS)
  1015. AC_MSG_RESULT([$newflag in $LDFLAGS])
  1016. ])
  1017. # Check if a package exists in the current distribution, if yes, require it
  1018. # in debian/control.in append @DEB_DEPEND_IFEXISTS@ to Build-Depends
  1019. # if you pass a list, it will require the first matching, if any matches
  1020. # - parameter:
  1021. # $1 = space separated list of package names
  1022. AC_DEFUN([AX_DEB_DEPEND_IFEXISTS], [
  1023. for pkg in $1; do
  1024. if test -n "$(apt-cache policy -q ${pkg} 2> /dev/null)"; then
  1025. DEB_DEPEND_IFEXISTS="${DEB_DEPEND_IFEXISTS}, ${pkg}"
  1026. break
  1027. fi
  1028. done
  1029. ])
  1030. # require package in debian/control.in append @DEB_BUILD_DEPEND@ to Build-Depends
  1031. # - parameter:
  1032. # $1 = package name
  1033. AC_DEFUN([AX_DEB_BUILD_DEPEND], [
  1034. DEB_BUILD_DEPEND="${DEB_BUILD_DEPEND}, $1"
  1035. ])
  1036. # require package in debian/control.in append @DEB_DEPEND@ to Depends
  1037. # - parameter:
  1038. # $1 = package name
  1039. AC_DEFUN([AX_DEB_DEPEND], [
  1040. DEB_DEPEND="${DEB_DEPEND}, $1"
  1041. ])
  1042. # require package in debian/control.in append @DEB_DEPEND@ to Depends
  1043. # - parameter:
  1044. # $1 = package name
  1045. AC_DEFUN([AX_DEB_SECTION], [
  1046. DEB_SECTION="$1"
  1047. ])
  1048. # call after setting debian dependencies
  1049. AC_DEFUN([AX_DEB_RESOLVE], [
  1050. AC_SUBST(DEB_BUILD_DEPEND)
  1051. AC_SUBST(DEB_DEPEND)
  1052. AC_SUBST(DEB_SECTION)
  1053. AC_SUBST(DEB_DEPEND_IFEXISTS)
  1054. ])
  1055. # Check if a package exists in the current distribution, if yes, require it
  1056. # in .spec.in append @RPM_DEPEND_IFEXISTS@ to Build-Depends
  1057. # if you pass a list, it will require the first matching, if any matches
  1058. # - parameter:
  1059. # $1 = space separated package names
  1060. AC_DEFUN([AX_RPM_DEPEND_IFEXISTS], [
  1061. for pkg in $1; do
  1062. if (test -x /usr/bin/zypper && zypper search -x "$pkg" 1>&2 > /dev/null) || \
  1063. (test -x /usr/bin/dnf && dnf list -q "$pkg" 1>&2 > /dev/null) || \
  1064. (test -x /usr/bin/yum && yum list -q "$pkg" 1>&2 > /dev/null) || \
  1065. (test -x /usr/sbin/urpmq && urpmq "$pkg" 1>&2 > /dev/null); then
  1066. RPM_DEPEND_IFEXISTS="${RPM_DEPEND_IFEXISTS}, ${pkg}"
  1067. break
  1068. fi
  1069. done
  1070. ])
  1071. # require package in .spec.in append @RPM_BUILD_DEPEND@ to Build-Depends
  1072. # - parameter:
  1073. # $1 = package name
  1074. AC_DEFUN([AX_RPM_BUILD_DEPEND], [
  1075. RPM_BUILD_DEPEND="${RPM_BUILD_DEPEND}, $1"
  1076. ])
  1077. # require package in .spec.in append @RPM_DEPEND@ to Depends
  1078. # - parameter:
  1079. # $1 = package name
  1080. AC_DEFUN([AX_RPM_DEPEND], [
  1081. if test -z "${RPM_DEPEND}"; then
  1082. RPM_DEPEND="$1"
  1083. else
  1084. RPM_DEPEND="${RPM_DEPEND}, $1"
  1085. fi
  1086. ])
  1087. # require package in debian/control.in append @DEB_DEPEND@ to Depends
  1088. # - parameter:
  1089. # $1 = package name
  1090. AC_DEFUN([AX_RPM_GROUP], [
  1091. RPM_GROUP="$1"
  1092. ])
  1093. # call after setting rpmian dependencies
  1094. AC_DEFUN([AX_RPM_RESOLVE], [
  1095. AC_SUBST(RPM_BUILD_DEPEND)
  1096. AC_SUBST(RPM_DEPEND)
  1097. AC_SUBST(RPM_GROUP)
  1098. AC_SUBST(RPM_DEPEND_IFEXISTS)
  1099. ])
  1100. # Check if a package exists in the current distribution, if yes, require it
  1101. # in .spec.in append @ALL_DEPEND_IFEXISTS@ to Build-Depends
  1102. # if you pass a list, it will require the first matching, if any matches
  1103. # - parameter:
  1104. # $1 = space separated list of package names
  1105. AC_DEFUN([AX_ALL_DEPEND_IFEXISTS], [
  1106. AX_DEB_DEPEND_IFEXISTS([$1])
  1107. AX_RPM_DEPEND_IFEXISTS([$1])
  1108. ])
  1109. # Check if a package exists in the current distribution, if yes, require it
  1110. # in .spec.in append @ALL_DEPEND_IFEXISTS@ to Build-Depends
  1111. # if you pass a list, it will require the first matching, if any matches
  1112. # - parameter:
  1113. # $1 = package name
  1114. AC_DEFUN([AX_ALL_DEPEND_IFEXISTS_DEV], [
  1115. pkgs="$1"
  1116. AX_DEB_DEPEND_IFEXISTS([${pkgs// /-dev }-dev])
  1117. AX_RPM_DEPEND_IFEXISTS([${pkgs// /-devel }-devel])
  1118. ])
  1119. # require package in .spec.in append @ALL_BUILD_DEPEND@ to Build-Depends
  1120. # - parameter:
  1121. # $1 = package name
  1122. AC_DEFUN([AX_ALL_BUILD_DEPEND], [
  1123. pkg="$1"
  1124. DEB_BUILD_DEPEND="${DEB_BUILD_DEPEND}, ${pkg}"
  1125. RPM_BUILD_DEPEND="${RPM_BUILD_DEPEND}, ${pkg}"
  1126. ])
  1127. # require package in .spec.in and control.in, append to runtime depends
  1128. # - parameter:
  1129. # $1 = package name
  1130. AC_DEFUN([AX_ALL_DEPEND], [
  1131. pkg="$1"
  1132. DEB_DEPEND="${DEB_DEPEND}, ${pkg}"
  1133. RPM_DEPEND="${RPM_DEPEND}, ${pkg}"
  1134. ])
  1135. # require package in .spec.in append @ALL_BUILD_DEPEND@ to Build-Depends
  1136. # - parameter:
  1137. # $1 = package name
  1138. AC_DEFUN([AX_ALL_BUILD_DEPEND_DEV], [
  1139. pkg="$1"
  1140. DEB_BUILD_DEPEND="${DEB_BUILD_DEPEND}, ${pkg// /-dev}-dev"
  1141. RPM_BUILD_DEPEND="${RPM_BUILD_DEPEND}, ${pkg// /-devel}-devel"
  1142. ])
  1143. # require package in .spec.in append @ALL_DEPEND@ to Depends
  1144. # - parameter:
  1145. # $1 = package name
  1146. AC_DEFUN([AX_ALL_DEPEND], [
  1147. pkg="$1"
  1148. DEB_DEPEND="${DEB_DEPEND}, ${pkg}"
  1149. if test -z "${RPM_DEPEND}"; then
  1150. RPM_DEPEND="${pkg}"
  1151. else
  1152. RPM_DEPEND="${RPM_DEPEND}, ${pkg}"
  1153. fi
  1154. ])
  1155. # finish configuration - to be called instead of AC_OUTPUT
  1156. AC_DEFUN([AX_OUTPUT], [
  1157. AX_INIT_QT
  1158. AX_DEB_RESOLVE
  1159. AX_RPM_RESOLVE
  1160. AC_OUTPUT
  1161. AC_MSG_NOTICE([configured for ${PACKAGE_NAME}-${VERSION}])
  1162. ])