]> the.earth.li Git - onak.git/commitdiff
Move to CMake over autoconf
authorJonathan McDowell <noodles@earth.li>
Sun, 14 Apr 2019 16:51:11 +0000 (17:51 +0100)
committerJonathan McDowell <noodles@earth.li>
Sun, 14 Apr 2019 16:51:11 +0000 (17:51 +0100)
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.

24 files changed:
CMakeLists.txt [new file with mode: 0644]
Makefile.in [deleted file]
armor.c
build-config.h.in [new file with mode: 0644]
configure.ac [deleted file]
debian/control
debian/onak.install
debian/rules
gpgwww.c
keyd.c
keydb_hkp.c
keydctl.c
keyid.c
lookup.c
m4/ax_lib_nettle.m4 [deleted file]
md5.c
onak-conf.c
onak-mail.pl.in
onak.c
onak.ini.in
sha1.c
sha1x.c
sigcheck.c
wotsap.c

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d9ce358
--- /dev/null
@@ -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 (file)
index ceb9367..0000000
+++ /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 595c4452480b6b1e0df5769f9b90efcbb59a192f..44be9394d72ab5201341f8b426933c09880bea66 100644 (file)
--- a/armor.c
+++ b/armor.c
 
 #include <stdlib.h>
 
+#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 (file)
index 0000000..15abe12
--- /dev/null
@@ -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 (file)
index 0e67c09..0000000
+++ /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 <db.h>\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.h>], 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=<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
index a8669367434ca65bd286ee1df18fd949b7b3ba3e..1950719ff262dbaea0b0ae5b2d0d5d52950d44d9 100644 (file)
@@ -2,7 +2,13 @@ Source: onak
 Section: net
 Priority: optional
 Maintainer: Jonathan McDowell <noodles@earth.li>
-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
index 9935e4c977a28814b5499f2cc4b403169fe37760..a092913482d9c762876195e38d0af83405c2da62 100644 (file)
@@ -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
index 13bdadca02f7254cca2ab1d9684f9dece99cfbf1..baa74cb624dfd47228c08e304abe8bfcdd0bf79e 100755 (executable)
@@ -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
index ae634e9c0f7f8ca6dfd0e202e8e7fe161152de39..02b4e79972bafa66c1206f130f39df5f2ae2638a 100644 (file)
--- a/gpgwww.c
+++ b/gpgwww.c
@@ -21,6 +21,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#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 68f72370b5e04390ccbbc1515f242a1e7e124b49..9994dea303b812588fe00ff9d18cec5424ce8668 100644 (file)
--- a/keyd.c
+++ b/keyd.c
@@ -32,7 +32,7 @@
 #include <time.h>
 #include <unistd.h>
 
-#include "config.h"
+#include "build-config.h"
 
 #ifdef HAVE_SYSTEMD
 #include <systemd/sd-daemon.h>
@@ -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
index b4540e15ab915d5cf01542a72cb87964106c4040..3ec46a4f2cf7b9e9bb40ca1e806961727fa40370 100644 (file)
@@ -23,6 +23,8 @@
 #include <string.h>
 #include <curl/curl.h>
 
+#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 */
index a2b312ca985d9f274f4858ebccba6dc239e8b96c..8712f6361d00978817f42f717989e3f545ebb18d 100644 (file)
--- a/keydctl.c
+++ b/keydctl.c
 #include <sys/socket.h>
 #include <sys/un.h>
 
+#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 d5244943f8e0c4480294900ad02c8577dc0b1fa2..9ac97b15e1f75c0ba8886e18035afc2c1b79e08d 100644 (file)
--- a/keyid.c
+++ b/keyid.c
@@ -20,7 +20,7 @@
 #include <sys/types.h>
 #include <arpa/inet.h>
 
-#include "config.h"
+#include "build-config.h"
 #include "keyid.h"
 #include "keystructs.h"
 #include "onak.h"
index c9f94a9e8579c51c187659cecb08f36a742a86a3..91371b43b1b72e3c046407739d4c3a313c5742e2 100644 (file)
--- a/lookup.c
+++ b/lookup.c
@@ -23,6 +23,8 @@
 #include <string.h>
 #include <unistd.h>
 
+#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 (file)
index cff46d0..0000000
+++ /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_<algo> 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 <autoconf.archive@coelho.net>
-#
-#   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 cbc5f0310e42bca7f371c4b66acfb1fee0cf1f17..45353e77734824b4da75eaa7bfcd72bb7d3d00dd 100644 (file)
--- a/md5.c
+++ b/md5.c
@@ -20,7 +20,7 @@
 
 /* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.  */
 
-#include "config.h"
+#include "build-config.h"
 
 #include <sys/types.h>
 
index 5a4400315551694d19eadc6c104223dcada44526..c30260fd6318cbb2d47d5792fe34a8adbf9f0943 100644 (file)
  * You should have received a copy of the GNU General Public License along with
  * this program.  If not, see <https://www.gnu.org/licenses/>.
  */
-
-#include "config.h"
-
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <strings.h>
 
+#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,
 
index 8231a127e22abd762e5ff495445b63a1d90f25d3..2083042e86d716ba7bc19fb7c93b599489c4d787 100644 (file)
@@ -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 (<CONFIG>) {
@@ -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 085a876c54c9dac6ceb1d4f22bbb8ec2fcff8f91..63f19d769679ccd9287c59e9e048aac7fc471230 100644 (file)
--- a/onak.c
+++ b/onak.c
@@ -27,6 +27,8 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
+#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,
index 465b4e5362a592843fe6a0f5592ba00b1578bf03..4dbf8305d516cf73fbf7a7447ac02efa96148c56 100644 (file)
@@ -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 <pgp-keyserver-admin@the.earth.li>
-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 859440efa23e02431b8f7319e793ced1014c5a59..8ee7a62059b14a34e1a66a08c5dd4a0eb008b697 100644 (file)
--- a/sha1.c
+++ b/sha1.c
@@ -17,7 +17,7 @@
 
 #define SHA1HANDSOFF
 
-#include "config.h"
+#include "build-config.h"
 
 #include <string.h>
 
diff --git a/sha1x.c b/sha1x.c
index 1242440dae3f9c96e9862df4653229479ece32b7..f1a51839f3c5401f6f717516a5ffe65eec9951ab 100644 (file)
--- a/sha1x.c
+++ b/sha1x.c
  *
  * Placed into the public domain.
  */
-
-#include "config.h"
-
 #include <stdbool.h>
 #include <stdint.h>
 #include <string.h>
 
+#include "build-config.h"
+
 #ifdef HAVE_NETTLE
 #include <nettle/sha.h>
 #else
index 7732229abf75579516ea56cae281f7526bede028..2401665b498bbfaf78c4662a55dcb0bf407bcb91 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <stdint.h>
 
-#include "config.h"
+#include "build-config.h"
 #include "decodekey.h"
 #include "keyid.h"
 #include "keystructs.h"
index 3aefc42012a4059324bfbad3ad7e080fc548ea81..37653f7c3d74fe8ad295129ec88a6da2a30ed528 100644 (file)
--- a/wotsap.c
+++ b/wotsap.c
 #include <string.h>
 #include <arpa/inet.h>
 
+#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)
 {