From a799cc2909f47d918d1ec7171a9edba28a9f5136 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Sun, 14 Apr 2019 17:51:11 +0100 Subject: [PATCH] Move to CMake over autoconf The auto* tools are hard to work with, and I'd like to split out various bits of onak into a shared library useful to other projects as well as various internal helpers (e.g. a backend DB library). To help with that move over to CMake as a more modern but still widely available build system. --- CMakeLists.txt | 185 +++++++++++++++++++++++++++++++++++++++ Makefile.in | 204 -------------------------------------------- armor.c | 3 +- build-config.h.in | 10 +++ configure.ac | 100 ---------------------- debian/control | 8 +- debian/onak.install | 4 +- debian/rules | 4 +- gpgwww.c | 3 +- keyd.c | 3 +- keydb_hkp.c | 3 +- keydctl.c | 6 +- keyid.c | 2 +- lookup.c | 3 +- m4/ax_lib_nettle.m4 | 84 ------------------ md5.c | 2 +- onak-conf.c | 11 ++- onak-mail.pl.in | 6 +- onak.c | 3 +- onak.ini.in | 10 +-- sha1.c | 2 +- sha1x.c | 5 +- sigcheck.c | 2 +- wotsap.c | 3 +- 24 files changed, 242 insertions(+), 424 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile.in create mode 100644 build-config.h.in delete mode 100644 configure.ac delete mode 100644 m4/ax_lib_nettle.m4 diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..d9ce358 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,185 @@ +cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +project(onak VERSION 0.5.0 LANGUAGES C) + +include(FindPkgConfig) +include(GNUInstallDirs) +include(TestBigEndian) +# Fall back for earlier versions of CMake which lack RUNSTATEDIR +if ("x${CMAKE_INSTALL_FULL_RUNSTATEDIR}" STREQUAL "x") + set(CMAKE_INSTALL_FULL_RUNSTATEDIR + ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run) +endif() + +# Configuration options from the user +set(DBTYPE "dynamic" CACHE STRING + "Configure the default database backend to use" ) +option(KEYD + "Enable the key daemon to handle communication with the key database" + ON) + +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +TEST_BIG_ENDIAN(WORDS_BIGENDIAN) + +# Pick up a git based version number for development builds +find_package(Git) +if (GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git") + EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} describe --tags --dirty + OUTPUT_VARIABLE GIT_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REPLACE "onak-" "" VERSION ${GIT_VERSION}) +else() + set(VERSION ${PROJECT_VERSION}) +endif() + +# Core objects +add_library(libonak STATIC armor.c charfuncs.c cleankey.c cleanup.c decodekey.c + getcgi.c hash.c keyarray.c keyid.c keyindex.c ll.c log.c marshal.c + mem.c merge.c onak-conf.c parsekey.c photoid.c sigcheck.c sendsync.c + sha1x.c wordlist.c) +set(LIBONAK_LIBRARIES "") + +# Ideally use Nettle, fall back to our own md5/sha1 routines otherwise +pkg_check_modules(NETTLE nettle) +if (NETTLE_FOUND) + set(HAVE_NETTLE true) + target_include_directories(libonak SYSTEM PUBLIC ${NETTLE_INCLUDE_DIRS}) + LIST(APPEND LIBONAK_LIBRARIES ${NETTLE_LIBRARIES}) +else() + target_sources(libonak PRIVATE md5.c sha1.c) +endif() + +# Backends + +# These have no dependencies and can always be compiled +set(BACKENDS "file" "fs" "stacked") + +# DB4 backend (add check for existence) +LIST(APPEND BACKENDS db4) +set(BACKEND_db4_LIBS db-5.3) + +# HKP backend - needs libcurl +pkg_check_modules(CURL libcurl) +if (CURL_FOUND) + LIST(APPEND BACKENDS hkp) + set(BACKEND_hkp_INC ${CURL_INCLUDE_DIRS}) + set(BACKEND_hkp_LIBS ${CURL_LIBRARIES}) +endif() + +# PostgreSQL backend - needs libpq +pkg_check_modules(POSTGRESQL libpq) +if (POSTGRESQL_FOUND) + LIST(APPEND BACKENDS pg) + set(BACKEND_pg_INC ${POSTGRESQL_INCLUDE_DIRS}) + set(BACKEND_pg_LIBS ${POSTGRESQL_LIBRARIES}) +endif() + +# keyd backend - can be disabled entirely +if (KEYD STREQUAL "ON") + LIST(APPEND BACKENDS keyd) + + add_executable(keyd keyd.c) + target_link_libraries(keyd libonak) + add_executable(keydctl keydctl.c onak-conf.c) + target_link_libraries(keydctl libonak) + target_compile_definitions(keydctl PRIVATE + CONFIGDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}") + + pkg_check_modules(SYSTEMD libsystemd) + if (SYSTEMD_FOUND) + set(HAVE_SYSTEMD true) + target_include_directories(keyd SYSTEM PUBLIC + ${SYSTEMD_INCLUDE_DIRS}) + target_link_libraries(keyd ${SYSTEMD_LIBRARIES}) + endif() + + install(TARGETS keydctl RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(TARGETS keyd RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}) + install(FILES keyd.8 keydctl.8 + DESTINATION ${CMAKE_INSTALL_MANDIR}/man8/) +endif() + + +# Now we have the DB type confirmed we can tidy up the libonak options + +if (DBTYPE STREQUAL "dynamic") + LIST(APPEND LIBONAK_LIBRARIES "dl") + foreach(BACKEND IN LISTS BACKENDS) + add_library(keydb_${BACKEND} SHARED keydb_${BACKEND}.c) + target_include_directories(keydb_${BACKEND} SYSTEM PUBLIC + ${BACKEND_${BACKEND}_INC}) + target_link_libraries(keydb_${BACKEND} libonak + ${BACKEND_${BACKEND}_LIBS}) + install(TARGETS keydb_${BACKEND} LIBRARY DESTINATION + ${CMAKE_INSTALL_LIBDIR}/onak/backends/) + endforeach(BACKEND) +else() + list (FIND BACKENDS ${DBTYPE} _index) + if (${_index} LESS 0) + message(FATAL_ERROR "${DBTYPE} is not a supported DB backend.") + endif() + + LIST(APPEND LIBONAK_LIBRARIES ${BACKEND_${DBTYPE}_LIBS}) +endif() + +# For onak-conf.o compilation +target_compile_definitions(libonak PRIVATE + CONFIGDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}" + DBINIT=keydb_${DBTYPE}_init) + +# DB Backend related options are known, so finish off libonak configuration +target_sources(libonak PRIVATE keydb_${DBTYPE}.c) +target_link_libraries(libonak ${LIBONAK_LIBRARIES}) + +# Executables start here + +# Swiss Army tool +add_executable(onak onak.c) +target_link_libraries(onak libonak) + +# CGI +add_executable(add add.c) +target_link_libraries(add libonak) +add_executable(gpgwww gpgwww.c stats.c) +target_link_libraries(gpgwww libonak) +add_executable(hashquery hashquery.c) +target_link_libraries(hashquery libonak) +add_executable(lookup lookup.c) +target_link_libraries(lookup libonak) + +# Tools that operate on the key DB +add_executable(maxpath maxpath.c stats.c) +target_link_libraries(maxpath libonak) +add_executable(sixdegrees sixdegrees.c stats.c) +target_link_libraries(sixdegrees libonak) +add_executable(wotsap wotsap.c) +target_link_libraries(wotsap libonak) + +# Stand alone tools +add_executable(splitkeys splitkeys.c) +target_link_libraries(splitkeys libonak) +add_executable(stripkey stripkey.c) +target_link_libraries(stripkey libonak) + +install(TARGETS onak splitkeys RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES onak.1 splitkeys.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/) + +# Build files that have substitutions in them +include_directories(${CMAKE_BINARY_DIR}) +configure_file("${CMAKE_SOURCE_DIR}/build-config.h.in" + "${CMAKE_BINARY_DIR}/build-config.h" @ONLY) + +configure_file("${CMAKE_SOURCE_DIR}/onak.ini.in" + "${CMAKE_BINARY_DIR}/onak.ini" @ONLY) +install(FILES ${CMAKE_BINARY_DIR}/onak.ini + DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}) + +configure_file("${CMAKE_SOURCE_DIR}/onak-mail.pl.in" + "${CMAKE_BINARY_DIR}/onak-mail.pl" @ONLY) +install(PROGRAMS ${CMAKE_BINARY_DIR}/onak-mail.pl + DESTINATION ${CMAKE_INSTALL_LIBDIR}/onak/) +install(FILES onak-mail.pl.8 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8/) + +# Basic unit tests +enable_testing() +add_test(NAME syntaxtest COMMAND perl -cw ${CMAKE_BINARY_DIR}/onak-mail.pl) +add_test(NAME sanitytests COMMAND ${CMAKE_SOURCE_DIR}/runtests) diff --git a/Makefile.in b/Makefile.in deleted file mode 100644 index ceb9367..0000000 --- a/Makefile.in +++ /dev/null @@ -1,204 +0,0 @@ -# -# Makefile for onak. -# - -CC = @CC@ -CFLAGS += @CFLAGS@ -Wall -pedantic -fPIC -# Uncomment to enable profiling. -LDFLAGS += @LDFLAGS@ -# Can be "pg" for Postgresql, "file" for flat files or "db4" for Berkeley DB. -DBTYPE = @DBTYPE@ -# -LIBS = @LIBS@ @NETTLE_LIBS@ -DB4LIBS = @DB4LIBS@ -CURLLIBS = @LIBCURL@ -#MAKEDEPEND = makedepend -f- -- -MAKEDEPEND = $(CC) -MM -prefix ?= @prefix@ -exec_prefix ?= @exec_prefix@ - -PROGS = add lookup hashquery gpgwww onak splitkeys onak-mail.pl stripkey \ - wotsap -CORE_OBJS = armor.o charfuncs.o decodekey.o getcgi.o hash.o marshal.o \ - keyid.o keyindex.o ll.o mem.o onak-conf.o parsekey.o sigcheck.o \ - log.o photoid.o wordlist.o cleanup.o merge.o sendsync.o keyarray.o \ - sha1x.o cleankey.o -ifeq (x@NETTLE_LIBS@, x) -CORE_OBJS += md5.o sha1.o -endif -SRCS = armor.c parsekey.c merge.c keyid.c md5.c sha1.c main.c getcgi.c mem.c \ - keyindex.c stats.c lookup.c add.c keydb_$(DBTYPE).c ll.c hash.c \ - gpgwww.c onak-conf.c charfuncs.c sendsync.c log.c photoid.c sigcheck.c \ - wordlist.c cleankey.c cleanup.c keyarray.c hashquery.c marshal.c \ - sha1x.c \ - $(foreach be,@BACKENDS@,keydb_$(be).c) -PROGS_LDFLAGS_EXTRA = - -ifeq (x@KEYD@, xyes) -PROGS += keyd keydctl -KEYDB_OBJ = keydb_keyd.o -SRCS += keyd.c keydb_keyd.c keydctl.c -else -KEYDB_OBJ = keydb_$(DBTYPE).o -endif - -ifeq (x@DBTYPE@, xdynamic) -LIBS += -ldl -BACKENDS = $(foreach be,@BACKENDS@,libkeydb_$(be).so) -PROGS += keyd keydctl -PROGS_LDFLAGS_EXTRA = -rdynamic -SRCS += keyd.c keydctl.c -endif - -ifeq (x@GOSSIP@, xyes) -SRCS += gossip-server.c -GOSSIP_OBJS = gossip-server.o -else -GOSSIP_OBJS = -endif - -OBJS = stats.o $(CORE_OBJS) $(KEYDB_OBJ) $(GOSSIP_OBJS) - -all: .depend $(PROGS) testparse maxpath sixdegrees splitkeys onak.ini \ - wotsap $(BACKENDS) - -test: onak $(BACKENDS) - perl -cw onak-mail.pl - @./runtests - -install: $(PROGS) onak.ini $(BACKENDS) - install -d $(DESTDIR)/@bindir@ - install -d $(DESTDIR)/@libdir@/onak/backends - install -d $(DESTDIR)/@localstatedir@/lib/onak - install -d $(DESTDIR)/@mandir@/man1 - install -d $(DESTDIR)/@mandir@/man8 - install -d $(DESTDIR)/@sysconfdir@ - install -m 755 onak-mail.pl $(DESTDIR)/@libdir@/onak - install onak splitkeys $(DESTDIR)/@bindir@ - install onak.1 splitkeys.1 $(DESTDIR)/@mandir@/man1 - install keyd.8 keydctl.8 onak-mail.pl.8 $(DESTDIR)/@mandir@/man8 -ifeq (x@DBTYPE@, xdynamic) - install $(BACKENDS) $(DESTDIR)/@libdir@/onak/backends - install -d $(DESTDIR)/@sbindir@ - install keyd $(DESTDIR)/@sbindir@ - install keydctl $(DESTDIR)/@bindir@ -endif - -keyd: keyd.o $(CORE_OBJS) $(GOSSIP_OBJS) keydb_$(DBTYPE).o - $(CC) $(LDFLAGS) $(PROGS_LDFLAGS_EXTRA) \ - -o keyd keyd.o $(CORE_OBJS) $(GOSSIP_OBJS) keydb_$(DBTYPE).o \ - $(LIBS) @SYSTEMD_LIBS@ - -keydctl: keydctl.o onak-conf.o ll.o log.o - $(CC) $(LDFLAGS) $(PROGS_LDFLAGS_EXTRA) \ - -o keydctl keydctl.o onak-conf.o ll.o log.o $(LIBS) - -libkeydb_db4.so: keydb_db4.o $(CORE_OBJS) - $(CC) $(LDFLAGS) -shared -o libkeydb_db4.so keydb_db4.o $(DB4LIBS) $(CORE_OBJS) - -libkeydb_hkp.so: keydb_hkp.o $(CORE_OBJS) - $(CC) $(LDFLAGS) -shared -o libkeydb_hkp.so keydb_hkp.o $(CURLLIBS) $(CORE_OBJS) - -libkeydb_pg.so: keydb_pg.o $(CORE_OBJS) - $(CC) $(LDFLAGS) -shared -o libkeydb_pg.so keydb_pg.o $(PQLIBS) $(CORE_OBJS) - -libkeydb_%.so: keydb_%.o $(CORE_OBJS) - $(CC) $(LDFLAGS) -shared -o $@ $< $(CORE_OBJS) - -splitkeys: splitkeys.o $(CORE_OBJS) $(KEYDB_OBJ) - $(CC) $(LDFLAGS) -o splitkeys splitkeys.o $(CORE_OBJS) $(KEYDB_OBJ) \ - $(LIBS) $(PROGS_LDFLAGS_EXTRA) - -testparse: main.o $(OBJS) - $(CC) $(LDFLAGS) -o testparse main.o $(OBJS) $(LIBS) \ - $(PROGS_LDFLAGS_EXTRA) - -maxpath: maxpath.o $(OBJS) - $(CC) $(LDFLAGS) -o maxpath maxpath.o $(OBJS) $(LIBS) \ - $(PROGS_LDFLAGS_EXTRA) - -sixdegrees: sixdegrees.o $(OBJS) - $(CC) $(LDFLAGS) -o sixdegrees sixdegrees.o $(OBJS) $(LIBS) \ - $(PROGS_LDFLAGS_EXTRA) - -wotsap: wotsap.o $(OBJS) - $(CC) $(LDFLAGS) -o wotsap wotsap.o $(OBJS) $(LIBS) \ - $(PROGS_LDFLAGS_EXTRA) - -stripkey: stripkey.o $(OBJS) - $(CC) $(LDFLAGS) -o stripkey stripkey.o $(OBJS) $(LIBS) \ - $(PROGS_LDFLAGS_EXTRA) - -gpgwww: gpgwww.o $(OBJS) - $(CC) $(LDFLAGS) -o gpgwww gpgwww.o $(OBJS) $(LIBS) \ - $(PROGS_LDFLAGS_EXTRA) - -hashquery: hashquery.o $(CORE_OBJS) $(KEYDB_OBJ) - $(CC) $(LDFLAGS) -o hashquery hashquery.o $(CORE_OBJS) \ - $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA) - -lookup: lookup.o $(CORE_OBJS) $(KEYDB_OBJ) - $(CC) $(LDFLAGS) -o lookup lookup.o $(CORE_OBJS) \ - $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA) - -add: add.o $(CORE_OBJS) $(KEYDB_OBJ) - $(CC) $(LDFLAGS) -o add add.o \ - $(CORE_OBJS) $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA) - -onak: onak.o $(CORE_OBJS) $(KEYDB_OBJ) - $(CC) $(LDFLAGS) -o onak onak.o \ - $(CORE_OBJS) $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA) - -onak-conf.o: onak-conf.c onak-conf.h - $(CC) $(CFLAGS) -DCONFIGDIR=\"@sysconfdir@\" \ - -DDBINIT=keydb_@DBTYPE@_init -c onak-conf.c - -# HACK: onak-conf.o needs to be able to see keydb_@DBTYPE@_funcs, but -# keydctl doesn't want to link against the DB stuff. To be fixed more cleanly. -keydctl.o: keydctl.c keyd.h - $(CC) $(CFLAGS) -DDBINIT=keydb_@DBTYPE@_init -c keydctl.c - -%: %.in - sed -e 's:@BINDIR@:@bindir@:g' \ - -e 's:@CONFIG@:@sysconfdir@/onak.ini:g' \ - -e 's:@CONFIGOLD@:@sysconfdir@/onak.conf:g' \ - -e 's:@LIBDIR@:@libdir@:g' \ - -e 's:@RUNDIR@:@runstatedir@:g' \ - -e 's:@SBINDIR@:@sbindir@:g' \ - -e 's:@STATEDIR@:@localstatedir@:g' \ - < $< > $@ - -clean: - $(RM) $(PROGS) $(OBJS) Makefile.bak testparse maxpath *.core core \ - gpgwww.o add.o lookup.o main.o maxpath.o onak.o sixdegrees \ - sixdegrees.o splitkeys.o stripkey.o onak.ini keyd.o \ - keydctl.o hashquery.o wotsap.o version.h \ - TAGS cscope.out cscope.files \ - $(foreach be,@BACKENDS@,keydb_$(be).o) *.so -ifeq (x@KEYD@, xyes) - $(RM) keyd.o keydb_$(DBTYPE).o -endif - -distclean: clean - $(RM) -f Makefile .depend config.log config.status config.h - $(RM) -r autom4te.cache - -doxygen-docs: *.c *.h Doxyfile - doxygen - -version.h: $(SRCS) - @echo '#include "config.h"' > version.h - @if [ -e .git ]; then \ - echo "#define ONAK_VERSION \"`git describe --tags --dirty | cut -d - -f 2-`\"" \ - >> version.h; \ - else \ - echo "#define ONAK_VERSION PACKAGE_VERSION" >> version.h; \ - fi - -.depend: $(SRCS) version.h - rm -f .depend - $(MAKEDEPEND) $(CFLAGS) $(SRCS) > .depend - -include .depend - -.PHONY: all clean diff --git a/armor.c b/armor.c index 595c445..44be939 100644 --- a/armor.c +++ b/armor.c @@ -19,10 +19,11 @@ #include +#include "build-config.h" + #include "armor.h" #include "keystructs.h" #include "parsekey.h" -#include "version.h" /** * @brief Line length we'll use for armored output diff --git a/build-config.h.in b/build-config.h.in new file mode 100644 index 0000000..15abe12 --- /dev/null +++ b/build-config.h.in @@ -0,0 +1,10 @@ +#ifndef __CONFIG_H__ +#define __CONFIG_H__ + +#define ONAK_VERSION "@VERSION@" + +#cmakedefine HAVE_NETTLE 1 +#cmakedefine HAVE_SYSTEMD 1 +#cmakedefine WORDS_BIGENDIAN 1 + +#endif /* __CONFIG_H__ */ diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 0e67c09..0000000 --- a/configure.ac +++ /dev/null @@ -1,100 +0,0 @@ -AC_PREREQ(2.50) -AC_INIT([onak],[0.5.0],[noodles-onak@earth.li]) -AC_CONFIG_SRCDIR(onak.c) -AC_CONFIG_HEADER(config.h) - -AC_PROG_CC -AC_PROG_CC_C99 - -AC_C_BIGENDIAN - -m4_include([m4/ax_lib_nettle.m4]) - -AX_LIB_NETTLE(auto) -AC_CHECK_HEADER([systemd/sd-daemon.h], [ - AC_CHECK_LIB([systemd-daemon], [sd_listen_fds], - [AC_DEFINE([HAVE_SYSTEMD], [1], [sd_listen_fds is available]) - AC_SUBST([SYSTEMD_LIBS], [-lsystemd-daemon]) - ], - AC_CHECK_LIB([systemd], [sd_listen_fds], - [AC_DEFINE([HAVE_SYSTEMD], [1], [sd_listen_fds is available]) - AC_SUBST([SYSTEMD_LIBS], [-lsystemd]) - ]) - ) -]) - -dnl We should always have these backends available. -backends="file fs keyd stacked" - -LIBCURL_CHECK_CONFIG(,,[have_libcurl="yes" backends="$backends hkp"],have_libcurl="no") - -AC_CHECK_LIB(pq, PQsetdbLogin,[have_libpq="yes" backends="$backends pg"],have_libpq="no") - -AC_CHECK_HEADER(db.h, have_db_h="yes", have_db_h="no") -AC_MSG_CHECKING(for libdb version in db.h) -printf "#include \nDB_VERSION_MAJOR DB_VERSION_MINOR\n" >conftest.c -set `eval $ac_cpp conftest.c | egrep '^ *[[0-9]] *'`; v="$1"; vv="$2" -AC_MSG_RESULT($v.$vv) -if test "$v" -ge 4; then - for db in "db-$v.$vv" "db$v.$vv" "db-$v" "db$v" "db"; do - AC_MSG_CHECKING(for db_create in lib$db) - oldLIBS="$LIBS" - LIBS="$LIBS -l$db" - db4libs="-l$db" - AC_TRY_LINK([#include ], db_create(0, 0, 0), - have_libdb="yes", have_libdb="no") - AC_MSG_RESULT($have_libdb) - LIBS="$oldLIBS" - if test "$have_libdb" != "no"; then break; fi - done -fi -if test "$have_libdb" = "yes" -a "$have_db_h" = "yes"; then - AC_DEFINE(HAVE_LIBDB4, 1, [libdb found]) - backends="$backends db4" -fi - -AC_MSG_CHECKING(available backends) -AC_MSG_RESULT($backends) - -AC_ARG_ENABLE(backend,AC_HELP_STRING([--enable-backend=],[Choose the backend database to use. Defaults to dynamic.]), [], [enable_backend="dynamic"]) - -AC_ARG_ENABLE(keyd,AC_HELP_STRING([--enable-keyd],[Use keyd as the DB backend.]), [], []) - -AC_MSG_CHECKING([which key database backend to use]) -AC_MSG_RESULT([$enable_backend]) -AC_CHECK_FILE([$srcdir/keydb_$enable_backend.c], ,AC_MSG_ERROR([non existent key database backend $enable_backend])) - -if test "x$enable_backend" = "xdb4" -then - if test "$have_libdb" = "no" -o "$have_db_h" = "no"; then - AC_MSG_ERROR(libdb not found.) - fi - LIBS="$LIBS $db4libs" -else if test "x$enable_backend" = "xpg" -then - if test "$have_libpq" = "no"; then - AC_MSG_ERROR(libpq not found.) - fi - LIBS="$LIBS -lpq" -fi -fi - -dnl If we are explicitly told which backend to use, only build that one. -if test "x$enable_backend" = "xdb4" -then - backend="$enable_backend" -fi - -dnl Fallback for autoconf before 2.70 -if test "x$runstatedir" = x; then - AC_SUBST([runstatedir], ["$localstatedir/run"]) -fi - -AC_SUBST(DBTYPE, $enable_backend) -AC_SUBST(DB4LIBS, $db4libs) -AC_SUBST(KEYD, $enable_keyd) -AC_SUBST(BACKENDS, $backends) - -AC_CONFIG_FILES(Makefile) - -AC_OUTPUT diff --git a/debian/control b/debian/control index a866936..1950719 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,13 @@ Source: onak Section: net Priority: optional Maintainer: Jonathan McDowell -Build-Depends: debhelper (>= 9), dh-autoreconf, dh-systemd, libdb-dev, nettle-dev, libcurl4-gnutls-dev | libcurl-dev, libsystemd-dev (>= 214) [linux-any] | libsystemd-daemon-dev [linux-any] +Build-Depends: cmake, + debhelper (>= 9), + dh-systemd, + libcurl4-gnutls-dev | libcurl-dev, + libdb-dev, + libsystemd-dev (>= 214) [linux-any] | libsystemd-daemon-dev [linux-any], + nettle-dev Standards-Version: 3.9.8.0 Homepage: https://www.earth.li/projectpurple/progs/onak.html Vcs-Browser: https://the.earth.li/gitweb/?p=onak.git;a=summary diff --git a/debian/onak.install b/debian/onak.install index 9935e4c..a092913 100644 --- a/debian/onak.install +++ b/debian/onak.install @@ -1,2 +1,2 @@ -onak.ini etc -add lookup gpgwww hashquery usr/lib/cgi-bin/pks +obj-*/onak.ini etc +obj-*/add obj-*/lookup obj-*/gpgwww obj-*/hashquery usr/lib/cgi-bin/pks diff --git a/debian/rules b/debian/rules index 13bdadc..baa74cb 100755 --- a/debian/rules +++ b/debian/rules @@ -1,12 +1,10 @@ #!/usr/bin/make -f export DEB_BUILD_MAINT_OPTIONS = hardening=+all -DEB_CONFIGURE_EXTRA_FLAGS += --enable-backend=dynamic --runstatedir=/run - CFLAGS += -std=gnu99 %: - dh "$@" --with autoreconf,systemd + dh "$@" --with systemd override_dh_installinit: dh_installinit --no-start diff --git a/gpgwww.c b/gpgwww.c index ae634e9..02b4e79 100644 --- a/gpgwww.c +++ b/gpgwww.c @@ -21,6 +21,8 @@ #include #include +#include "build-config.h" + #include "armor.h" #include "charfuncs.h" #include "cleanup.h" @@ -32,7 +34,6 @@ #include "onak-conf.h" #include "parsekey.h" #include "stats.h" -#include "version.h" #define OP_UNKNOWN 0 #define OP_GET 1 diff --git a/keyd.c b/keyd.c index 68f7237..9994dea 100644 --- a/keyd.c +++ b/keyd.c @@ -32,7 +32,7 @@ #include #include -#include "config.h" +#include "build-config.h" #ifdef HAVE_SYSTEMD #include @@ -48,7 +48,6 @@ #include "mem.h" #include "onak-conf.h" #include "parsekey.h" -#include "version.h" /* Maximum number of clients we're prepared to accept at once */ #define MAX_CLIENTS 16 diff --git a/keydb_hkp.c b/keydb_hkp.c index b4540e1..3ec46a4 100644 --- a/keydb_hkp.c +++ b/keydb_hkp.c @@ -23,6 +23,8 @@ #include #include +#include "build-config.h" + #include "armor.h" #include "charfuncs.h" #include "keydb.h" @@ -31,7 +33,6 @@ #include "mem.h" #include "onak-conf.h" #include "parsekey.h" -#include "version.h" struct onak_hkp_dbctx { struct onak_db_config *config; /* Our DB config info */ diff --git a/keydctl.c b/keydctl.c index a2b312c..8712f63 100644 --- a/keydctl.c +++ b/keydctl.c @@ -26,12 +26,10 @@ #include #include +#include "build-config.h" + #include "keyd.h" #include "onak-conf.h" -#include "version.h" - -/* HACK: We need to stop onak-conf.o requiring this. */ -void *DBINIT = NULL; static int keyd_fd = -1; static int verbose = 0; diff --git a/keyid.c b/keyid.c index d524494..9ac97b1 100644 --- a/keyid.c +++ b/keyid.c @@ -20,7 +20,7 @@ #include #include -#include "config.h" +#include "build-config.h" #include "keyid.h" #include "keystructs.h" #include "onak.h" diff --git a/lookup.c b/lookup.c index c9f94a9..91371b4 100644 --- a/lookup.c +++ b/lookup.c @@ -23,6 +23,8 @@ #include #include +#include "build-config.h" + #include "armor.h" #include "charfuncs.h" #include "cleankey.h" @@ -36,7 +38,6 @@ #include "onak-conf.h" #include "parsekey.h" #include "photoid.h" -#include "version.h" #define OP_UNKNOWN 0 #define OP_GET 1 diff --git a/m4/ax_lib_nettle.m4 b/m4/ax_lib_nettle.m4 deleted file mode 100644 index cff46d0..0000000 --- a/m4/ax_lib_nettle.m4 +++ /dev/null @@ -1,84 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_lib_nettle.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_LIB_NETTLE([yes|no|auto]) -# -# DESCRIPTION -# -# Searches for the 'nettle' library with the --with... option. -# -# If found, define HAVE_NETTLE and macro NETTLE_LIBS. Also defines -# NETTLE_WITH_ for the algorithms found available. Possible -# algorithms: AES ARCTWO BLOWFISH CAST128 DES DES3 SERPENT TWOFISH MD2 MD4 -# MD5 SHA1 SHA256. -# -# The argument is used if no --with...-nettle option is set. Value "yes" -# requires the configuration by default. Value "no" does not require it by -# default. Value "auto" configures the library only if available. -# -# See also AX_LIB_BEECRYPT, AX_LIB_CRYPTO, and AX_LIB_GCRYPT. -# -# LICENSE -# -# Copyright (c) 2009 Fabien Coelho -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 7 - -# AX_CHECK_NETTLE_ALGO([name],[function]) -AC_DEFUN([AX_CHECK_NETTLE_ALGO],[ - AC_CHECK_LIB([nettle], [nettle_$2], - AC_DEFINE([NETTLE_WITH_$1],[1],[Algorithm $1 in nettle library])) -]) - -# AX_LIB_NETTLE([yes|no|auto]) -AC_DEFUN([AX_LIB_NETTLE],[ - AC_MSG_CHECKING([whether nettle is enabled]) - AC_ARG_WITH([nettle],[ --with-nettle require nettle library - --without-nettle disable nettle library],[ - AC_MSG_RESULT([$withval]) - ax_with_nettle=$withval - ],[ - AC_MSG_RESULT([$1]) - ax_with_nettle=$1 - ]) - if test "$ax_with_nettle" = "yes" -o "$ax_with_nettle" = "auto" ; then - AC_CHECK_HEADERS([nettle/nettle-meta.h],[ - AC_CHECK_LIB([nettle],[nettle_base64_encode_final],[ - AC_DEFINE([HAVE_NETTLE],[1],[Nettle library is available]) - HAVE_NETTLE=1 - AC_SUBST([NETTLE_LIBS],[-lnettle]) - # ciphers - AX_CHECK_NETTLE_ALGO([AES],[aes_encrypt]) - AX_CHECK_NETTLE_ALGO([ARCTWO],[arctwo_encrypt]) - AX_CHECK_NETTLE_ALGO([BLOWFISH],[blowfish_encrypt]) - AX_CHECK_NETTLE_ALGO([CAST128],[cast128_encrypt]) - AX_CHECK_NETTLE_ALGO([DES],[des_encrypt]) - AX_CHECK_NETTLE_ALGO([DES3],[des3_encrypt]) - AX_CHECK_NETTLE_ALGO([SERPENT],[serpent_encrypt]) - AX_CHECK_NETTLE_ALGO([TWOFISH],[twofish_encrypt]) - # digests - AX_CHECK_NETTLE_ALGO([MD2],[md2_digest]) - AX_CHECK_NETTLE_ALGO([MD4],[md4_digest]) - AX_CHECK_NETTLE_ALGO([MD5],[md5_digest]) - AX_CHECK_NETTLE_ALGO([RIPEMD160],[ripemd160_digest]) - AX_CHECK_NETTLE_ALGO([SHA1],[sha1_digest]) - AX_CHECK_NETTLE_ALGO([SHA224],[sha224_digest]) - AX_CHECK_NETTLE_ALGO([SHA256],[sha256_digest]) - AX_CHECK_NETTLE_ALGO([SHA384],[sha384_digest]) - AX_CHECK_NETTLE_ALGO([SHA512],[sha512_digest]) - ]) - ]) - # complain only if explicitely required - if test "$ax_with_nettle" = "yes" -a "x$HAVE_NETTLE" = "x" ; then - AC_MSG_ERROR([cannot configure required nettle library]) - fi - fi -]) diff --git a/md5.c b/md5.c index cbc5f03..45353e7 100644 --- a/md5.c +++ b/md5.c @@ -20,7 +20,7 @@ /* Written by Ulrich Drepper , 1995. */ -#include "config.h" +#include "build-config.h" #include diff --git a/onak-conf.c b/onak-conf.c index 5a44003..c30260f 100644 --- a/onak-conf.c +++ b/onak-conf.c @@ -15,21 +15,22 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ - -#include "config.h" - #include #include #include #include #include +#include "build-config.h" + #include "cleankey.h" #include "ll.h" #include "log.h" #include "onak-conf.h" +#ifdef DBINIT extern struct onak_dbctx *DBINIT(struct onak_db_config *dbcfg, bool readonly); +#endif /* * config - Runtime configuration for onak. @@ -51,7 +52,11 @@ struct onak_config config = { .backends = NULL, .backends_dir = NULL, +#ifdef DBINIT .dbinit = DBINIT, +#else + .dbinit = NULL, +#endif .clean_policies = ONAK_CLEAN_CHECK_SIGHASH, diff --git a/onak-mail.pl.in b/onak-mail.pl.in index 8231a12..2083042 100644 --- a/onak-mail.pl.in +++ b/onak-mail.pl.in @@ -21,7 +21,7 @@ my %config; # upgrades. # sub readoldconfig { - open(CONFIG, "@CONFIGOLD@") or + open(CONFIG, "@CMAKE_INSTALL_FULL_SYSCONFDIR@/onak.conf") or die "Can't read config file: $!"; while () { @@ -57,12 +57,12 @@ sub readoldconfig { # sub readconfig { # Prefer the old style config if it exists. - if (-e "@CONFIGOLD@") { + if (-e "@CMAKE_INSTALL_FULL_SYSCONFDIR@/onak.conf") { &readoldconfig; return; } - open(CONFIG, "@CONFIG@") or + open(CONFIG, "@CMAKE_INSTALL_FULL_SYSCONFDIR@/onak.ini") or die "Can't read config file: $!"; my $section = ""; diff --git a/onak.c b/onak.c index 085a876..63f19d7 100644 --- a/onak.c +++ b/onak.c @@ -27,6 +27,8 @@ #include #include +#include "build-config.h" + #include "armor.h" #include "charfuncs.h" #include "cleankey.h" @@ -41,7 +43,6 @@ #include "onak-conf.h" #include "parsekey.h" #include "photoid.h" -#include "version.h" void find_keys(struct onak_dbctx *dbctx, char *search, uint64_t keyid, diff --git a/onak.ini.in b/onak.ini.in index 465b4e5..4dbf830 100644 --- a/onak.ini.in +++ b/onak.ini.in @@ -3,13 +3,13 @@ ; [main] backend=defaultdb4 -backends_dir=@LIBDIR@/onak/backends -logfile=@STATEDIR@/log/onak.log +backends_dir=@CMAKE_INSTALL_FULL_LIBDIR@/onak/backends +logfile=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/onak.log ; Loglevel : 0 is highest debug, default is 3, nothing is 7+ loglevel=3 ; Should we use the keyd backend? use_keyd=false -sock_dir=@RUNDIR@ +sock_dir=@CMAKE_INSTALL_FULL_RUNSTATEDIR@ ; Maximum number of keys to return in a reply to an index, verbose index or ; get. Setting it to -1 will allow any size of reply. max_reply_keys=128 @@ -23,7 +23,7 @@ check_sighash=true ; Settings related to the email interface to onak. [mail] maintainer_email=PGP Key Server Administrator -mail_dir=@STATEDIR@/spool/onak +mail_dir=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/spool/onak ; Specify the envelope sender address as the -f argument to ; sendmail. This is the address which will receive any bounces. ; If you don't use sendmail, then change this to an equivalent command. @@ -49,7 +49,7 @@ this_site=pgp-public-keys@the.earth.li [backend:defaultdb4] ; The default DB4 backend. Recommended. type=db4 -location=@STATEDIR@/lib/onak +location=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/lib/onak [backend:examplehkp] ; An example HKP backend; all operations will be done against the diff --git a/sha1.c b/sha1.c index 859440e..8ee7a62 100644 --- a/sha1.c +++ b/sha1.c @@ -17,7 +17,7 @@ #define SHA1HANDSOFF -#include "config.h" +#include "build-config.h" #include diff --git a/sha1x.c b/sha1x.c index 1242440..f1a5183 100644 --- a/sha1x.c +++ b/sha1x.c @@ -12,13 +12,12 @@ * * Placed into the public domain. */ - -#include "config.h" - #include #include #include +#include "build-config.h" + #ifdef HAVE_NETTLE #include #else diff --git a/sigcheck.c b/sigcheck.c index 7732229..2401665 100644 --- a/sigcheck.c +++ b/sigcheck.c @@ -18,7 +18,7 @@ #include -#include "config.h" +#include "build-config.h" #include "decodekey.h" #include "keyid.h" #include "keystructs.h" diff --git a/wotsap.c b/wotsap.c index 3aefc42..37653f7 100644 --- a/wotsap.c +++ b/wotsap.c @@ -28,11 +28,12 @@ #include #include +#include "build-config.h" + #include "hash.h" #include "log.h" #include "onak-conf.h" #include "stats.h" -#include "version.h" static struct ll *sortkeyll(struct ll *keys) { -- 2.39.5