1576775046.v7-2-gfed9020.move-build-system-to-meson.patch 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. Subject: Move build system to meson
  2. Origin: v7-2-gfed9020 <https://github.com/latchset/tang/commit/v7-2-gfed9020>
  3. Upstream-Author: Sergio Correia <scorreia@redhat.com>
  4. Date: Thu Dec 19 14:04:06 2019 -0300
  5. Also install asciidoc package in CI, so that it will build the
  6. man pages as well.
  7. --
  8. Some extra adjustment needed for pre-usrmerge.
  9. --- a/Makefile.am
  10. +++ /dev/null
  11. @@ -1,60 +0,0 @@
  12. -DISTCHECK_CONFIGURE_FLAGS = --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
  13. -BUILT_SOURCES=
  14. -CLEANFILES=
  15. -man1_MANS=
  16. -man8_MANS=
  17. -
  18. -AM_CFLAGS = @TANG_CFLAGS@ @jose_CFLAGS@
  19. -LDADD = @jose_LIBS@ @http_parser_LIBS@
  20. -
  21. -cachedir = $(localstatedir)/cache/$(PACKAGE_NAME)
  22. -jwkdir = $(localstatedir)/db/$(PACKAGE_NAME)
  23. -
  24. -nodist_systemdsystemunit_DATA = \
  25. - units/tangd@.service \
  26. - units/tangd.socket \
  27. - units/tangd-update.path \
  28. - units/tangd-update.service \
  29. - units/tangd-keygen.service
  30. -
  31. -dist_libexec_SCRIPTS = src/tangd-update src/tangd-keygen
  32. -dist_bin_SCRIPTS = src/tang-show-keys
  33. -libexec_PROGRAMS = src/tangd
  34. -
  35. -man_ADOC_FILES= \
  36. - doc/tang-show-keys.1.adoc \
  37. - doc/tang.8.adoc
  38. -
  39. -if HAVE_A2X
  40. -man_ROFF_FILES = $(man_ADOC_FILES:.adoc=.roff)
  41. -BUILT_SOURCES += $(man_ROFF_FILES)
  42. -CLEANFILES += $(man_ROFF_FILES) $(man_ROFF_FILES:.roff=)
  43. -
  44. -$(top_builddir)/%.roff: %.adoc
  45. - $(MKDIR_P) $$(dirname $@)
  46. - $(A2X) -f manpage $^ -D $(top_builddir)/$$(dirname $@)
  47. - $(INSTALL) -m 644 $(top_builddir)/$(@:.roff=) $(top_builddir)/$@
  48. -
  49. -man1_MANS += doc/tang-show-keys.1
  50. -man8_MANS += doc/tang.8
  51. -endif
  52. -
  53. -src_tangd_SOURCES = src/http.c src/http.h src/tangd.c
  54. -
  55. -%: %.in
  56. - $(AM_V_GEN)mkdir -p "`dirname "$@"`"
  57. - $(AM_V_GEN)$(SED) \
  58. - -e 's,@libexecdir\@,$(libexecdir),g' \
  59. - -e 's,@jwkdir\@,$(jwkdir),g' \
  60. - -e 's,@cachedir\@,$(cachedir),g' \
  61. - $(srcdir)/$@.in > $@
  62. -
  63. -AM_TESTS_ENVIRONMENT = SD_ACTIVATE="@SD_ACTIVATE@" PATH=$(srcdir)/src:$(builddir)/src:$(PATH)
  64. -TESTS = tests/adv tests/rec
  65. -
  66. -CLEANFILES += $(nodist_systemdsystemunit_DATA)
  67. -EXTRA_DIST = \
  68. - $(foreach unit,$(nodist_systemdsystemunit_DATA),$(unit).in) \
  69. - COPYING \
  70. - $(TESTS) \
  71. - $(man_ADOC_FILES)
  72. --- a/configure.ac
  73. +++ /dev/null
  74. @@ -1,87 +0,0 @@
  75. -AC_PREREQ(2.59)
  76. -AC_INIT(tang, 7)
  77. -AC_CANONICAL_SYSTEM
  78. -AC_PROG_CC_C99
  79. -AC_PROG_SED
  80. -
  81. -AM_INIT_AUTOMAKE([subdir-objects foreign no-dist-gzip dist-bzip2 parallel-tests])
  82. -AM_SILENT_RULES([yes])
  83. -AM_PROG_CC_C_O
  84. -
  85. -PKG_PROG_PKG_CONFIG([0.25])
  86. -
  87. -AC_CHECK_LIB([dl], [dlopen], [AC_SUBST([dl_LIBS], [-ldl])],
  88. - [AC_CHECK_LIB([dl], [dlopen], [AC_SUBST([dl_LIBS], [-ldl])],
  89. - [AC_MSG_ERROR([unable to find dlopen])])])
  90. -
  91. -AC_CHECK_HEADER([http_parser.h], [],
  92. - [AC_MSG_ERROR([http-parser required!])], [
  93. -#include <http_parser.h>
  94. -#ifndef HTTP_STATUS_MAP
  95. -#error HTTP_STATUS_MAP not defined!
  96. -#endif
  97. -])
  98. -
  99. -AC_CHECK_LIB([http_parser], [http_parser_execute],
  100. - [AC_SUBST(http_parser_LIBS, [-lhttp_parser])],
  101. - [AC_MSG_ERROR([http-parser required!])])
  102. -
  103. -PKG_CHECK_MODULES([jose], [jose >= 8])
  104. -PKG_CHECK_MODULES([systemd], [systemd])
  105. -
  106. -AC_ARG_WITH([systemdsystemunitdir],
  107. - [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],
  108. - [],
  109. - [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
  110. -
  111. -AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
  112. -
  113. -for ac_prog in systemd-socket-activate systemd-activate; do
  114. - AC_CHECK_PROG([SD_ACTIVATE], [$ac_prog], [$as_dir/$ac_prog], [],
  115. - [$PATH$PATH_SEPARATOR$($PKG_CONFIG --variable=systemdutildir systemd)])
  116. - test -n "$SD_ACTIVATE" && break
  117. -done
  118. -
  119. -test -n "$SD_ACTIVATE" || AC_MSG_ERROR([systemd-socket-activate required!])
  120. -
  121. -AC_MSG_CHECKING([systemd-socket-activate inetd flag])
  122. -if $SD_ACTIVATE --help | grep -q inetd; then
  123. - SD_ACTIVATE="$SD_ACTIVATE --inetd"
  124. - AC_MSG_RESULT([--inetd])
  125. -else
  126. - AC_MSG_RESULT([(default)])
  127. -fi
  128. -
  129. -AC_SUBST(SD_ACTIVATE)
  130. -
  131. -TANG_CFLAGS="\
  132. --Wall \
  133. --Wextra \
  134. --Werror \
  135. --Wstrict-aliasing \
  136. --Wchar-subscripts \
  137. --Wformat-security \
  138. --Wmissing-declarations \
  139. --Wmissing-prototypes \
  140. --Wnested-externs \
  141. --Wpointer-arith \
  142. --Wshadow \
  143. --Wsign-compare \
  144. --Wstrict-prototypes \
  145. --Wtype-limits \
  146. --Wunused-function \
  147. --Wno-missing-field-initializers \
  148. --Wno-unused-parameter \
  149. -"
  150. -AC_SUBST([TANG_CFLAGS])
  151. -
  152. -AC_CHECK_PROGS(A2X, [a2x])
  153. -
  154. -if test "x$A2X" = "x"; then
  155. - AC_MSG_WARN([asciidoc / a2x not found -- man pages will not be generated and installed])
  156. -fi
  157. -
  158. -AM_CONDITIONAL(HAVE_A2X, [test -n "$A2X"])
  159. -
  160. -AC_CONFIG_FILES([Makefile])
  161. -AC_OUTPUT
  162. --- /dev/null
  163. +++ b/doc/meson.build
  164. @@ -0,0 +1,4 @@
  165. +mans += join_paths(meson.current_source_dir(), 'tang-show-keys.1')
  166. +mans += join_paths(meson.current_source_dir(), 'tang.8')
  167. +
  168. +# vim:set ts=2 sw=2 et:
  169. --- /dev/null
  170. +++ b/meson.build
  171. @@ -0,0 +1,85 @@
  172. +project('tang', 'c',
  173. + version: '7',
  174. + license: 'GPL3+',
  175. + default_options: [
  176. + 'c_std=c99',
  177. + 'prefix=/usr',
  178. + 'sysconfdir=/etc',
  179. + 'localstatedir=/var',
  180. + 'warning_level=3',
  181. + 'werror=true'
  182. + ]
  183. +)
  184. +
  185. +libexecdir = join_paths(get_option('prefix'), get_option('libexecdir'))
  186. +sysconfdir = join_paths(get_option('prefix'), get_option('sysconfdir'))
  187. +bindir = join_paths(get_option('prefix'), get_option('bindir'))
  188. +systemunitdir = join_paths(get_option('prefix'), '../lib/systemd/system')
  189. +licensedir = join_paths(get_option('prefix'), 'share', 'licenses', meson.project_name())
  190. +cachedir = join_paths(get_option('localstatedir'), 'cache', meson.project_name())
  191. +jwkdir = join_paths(get_option('localstatedir'), 'db', meson.project_name())
  192. +
  193. +data = configuration_data()
  194. +data.set('libexecdir', libexecdir)
  195. +data.set('sysconfdir', sysconfdir)
  196. +data.set('systemunitdir', systemunitdir)
  197. +data.set('cachedir', cachedir)
  198. +data.set('jwkdir', jwkdir)
  199. +
  200. +add_project_arguments(
  201. + '-D_POSIX_C_SOURCE=200809L',
  202. + '-Wstrict-aliasing',
  203. + '-Wchar-subscripts',
  204. + '-Wformat-security',
  205. + '-Wmissing-declarations',
  206. + '-Wmissing-prototypes',
  207. + '-Wnested-externs',
  208. + '-Wpointer-arith',
  209. + '-Wshadow',
  210. + '-Wsign-compare',
  211. + '-Wstrict-prototypes',
  212. + '-Wtype-limits',
  213. + '-Wunused-function',
  214. + '-Wno-missing-field-initializers',
  215. + '-Wno-unused-parameter',
  216. + '-Wno-pedantic',
  217. + language: 'c'
  218. +)
  219. +
  220. +jose = dependency('jose', version: '>=8')
  221. +a2x = find_program('a2x', required: false)
  222. +compiler = meson.get_compiler('c')
  223. +if not compiler.has_header('http_parser.h')
  224. + error('http-parser devel files not found.')
  225. +endif
  226. +http_parser = compiler.find_library('http_parser')
  227. +
  228. +licenses = ['COPYING']
  229. +libexecbins = []
  230. +bins = []
  231. +mans = []
  232. +units = []
  233. +
  234. +subdir('doc')
  235. +subdir('src')
  236. +subdir('units')
  237. +subdir('tests')
  238. +
  239. +install_data(libexecbins, install_dir: libexecdir)
  240. +install_data(bins, install_dir: bindir)
  241. +install_data(units, install_dir: systemunitdir)
  242. +install_data(licenses, install_dir: licensedir)
  243. +
  244. +if a2x.found()
  245. + foreach m : mans
  246. + custom_target(m.split('/')[-1], input: m + '.adoc', output: m.split('/')[-1],
  247. + command: [a2x, '-f', 'manpage', '-D', meson.current_build_dir(), '@INPUT@'],
  248. + install_dir: join_paths(get_option('mandir'), 'man' + m.split('.')[-1]),
  249. + install: true
  250. + )
  251. + endforeach
  252. +else
  253. + warning('Will not build man pages due to missing a2x (asciidoc) dependency!')
  254. +endif
  255. +
  256. +# vim:set ts=2 sw=2 et:
  257. --- /dev/null
  258. +++ b/src/meson.build
  259. @@ -0,0 +1,14 @@
  260. +tangd = executable('tangd',
  261. + 'http.h',
  262. + 'http.c',
  263. + 'tangd.c',
  264. + dependencies: [jose, http_parser],
  265. + install: true,
  266. + install_dir: libexecdir
  267. +)
  268. +
  269. +bins += join_paths(meson.current_source_dir(), 'tang-show-keys')
  270. +libexecbins += join_paths(meson.current_source_dir(), 'tangd-keygen')
  271. +libexecbins += join_paths(meson.current_source_dir(), 'tangd-update')
  272. +
  273. +# vim:set ts=2 sw=2 et:
  274. --- /dev/null
  275. +++ b/tests/meson.build
  276. @@ -0,0 +1,22 @@
  277. +sd_activate = find_program(
  278. + 'systemd-socket-activate',
  279. + 'systemd-activate',
  280. + required: false
  281. +)
  282. +
  283. +if sd_activate.found()
  284. + env = environment()
  285. + env.prepend('PATH',
  286. + join_paths(meson.source_root(), 'src'),
  287. + join_paths(meson.build_root(), 'src'),
  288. + separator: ':'
  289. + )
  290. + env.set('SD_ACTIVATE', sd_activate.path() + ' --inetd')
  291. +
  292. + test('adv', find_program('adv'), env: env)
  293. + test('rec', find_program('rec'), env: env)
  294. +else
  295. + warning('Will not run the tests due to missing dependencies!')
  296. +endif
  297. +
  298. +# vim:set ts=2 sw=2 et:
  299. --- /dev/null
  300. +++ b/units/meson.build
  301. @@ -0,0 +1,31 @@
  302. +tangd_keygen_service = configure_file(
  303. + input: 'tangd-keygen.service.in',
  304. + output: 'tangd-keygen.service',
  305. + configuration: data
  306. +)
  307. +
  308. +tangd_service = configure_file(
  309. + input: 'tangd@.service.in',
  310. + output: 'tangd@.service',
  311. + configuration: data
  312. +)
  313. +
  314. +tangd_update_path = configure_file(
  315. + input: 'tangd-update.path.in',
  316. + output: 'tangd-update.path',
  317. + configuration: data
  318. +)
  319. +
  320. +tangd_update_service = configure_file(
  321. + input: 'tangd-update.service.in',
  322. + output: 'tangd-update.service',
  323. + configuration: data
  324. +)
  325. +
  326. +units += join_paths(meson.current_source_dir(), 'tangd.socket')
  327. +units += tangd_keygen_service
  328. +units += tangd_service
  329. +units += tangd_update_path
  330. +units += tangd_update_service
  331. +
  332. +# vim:set ts=2 sw=2 et:
  333. --- /dev/null
  334. +++ b/units/tangd.socket
  335. @@ -0,0 +1,14 @@
  336. +[Unit]
  337. +Description=Tang Server socket
  338. +Requires=tangd-keygen.service
  339. +Requires=tangd-update.service
  340. +Requires=tangd-update.path
  341. +After=tangd-keygen.service
  342. +After=tangd-update.service
  343. +
  344. +[Socket]
  345. +ListenStream=80
  346. +Accept=true
  347. +
  348. +[Install]
  349. +WantedBy=multi-user.target
  350. --- a/units/tangd.socket.in
  351. +++ /dev/null
  352. @@ -1,14 +0,0 @@
  353. -[Unit]
  354. -Description=Tang Server socket
  355. -Requires=tangd-keygen.service
  356. -Requires=tangd-update.service
  357. -Requires=tangd-update.path
  358. -After=tangd-keygen.service
  359. -After=tangd-update.service
  360. -
  361. -[Socket]
  362. -ListenStream=80
  363. -Accept=true
  364. -
  365. -[Install]
  366. -WantedBy=multi-user.target