Browse Source

spring cleaning before resyncing with upstream

Layout build machinery closer to LibreSSL to make code sharing easier.
Split the big Makefile.am into src/compat.
OPENBSD_5_7
Brent Cook 9 years ago
parent
commit
733037e6fc
10 changed files with 272 additions and 228 deletions
  1. +3
    -217
      Makefile.am
  2. +146
    -0
      compat/Makefile.am
  3. +2
    -2
      compat/adjfreq_freebsd.c
  4. +2
    -2
      compat/adjfreq_linux.c
  5. +2
    -2
      compat/adjfreq_netbsd.c
  6. +2
    -2
      compat/adjfreq_solaris.c
  7. +3
    -1
      configure.ac
  8. +108
    -0
      src/Makefile.am
  9. +0
    -0
      src/fake-sensors.c
  10. +4
    -2
      update.sh

+ 3
- 217
Makefile.am View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2014 Brent Cook
# Copyright (c) 2014-2015 Brent Cook
# Parts based on Makefile.in from Portable OpenNTPD:
# Copyright (c) 2004-2008 Darren Tucker.
#
@ -15,235 +15,21 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
AM_CPPFLAGS = -I$(top_srcdir)/include
SUBDIRS = include
SUBDIRS = include compat src
ACLOCAL_AMFLAGS = -I m4
ACLOCAL_AMFLAGS = -Im4
EXTRA_DIST = VERSION ntpd.conf
CLEANFILES = parse.c
sbin_PROGRAMS = ntpd
noinst_LTLIBRARIES = libcompat.la libcompatnoopt.la
dist_man_MANS = ntpctl.8 ntpd.8 ntpd.conf.5
ntpd_CFLAGS = $(CFLAGS) $(USER_CFLAGS)
ntpd_CFLAGS += -DSYSCONFDIR=\"$(sysconfdir)\"
ntpd_CFLAGS += -DLOCALSTATEDIR=\"$(localstatedir)\"
ntpd_LDADD = $(PLATFORM_LDADD) $(PROG_LDADD) libcompat.la libcompatnoopt.la
ntpd_SOURCES = client.c
ntpd_SOURCES += config.c
ntpd_SOURCES += control.c
ntpd_SOURCES += log.c
ntpd_SOURCES += log.h
ntpd_SOURCES += ntp.c
ntpd_SOURCES += ntp.h
ntpd_SOURCES += ntp_dns.c
ntpd_SOURCES += ntp_msg.c
ntpd_SOURCES += ntpd.c
ntpd_SOURCES += ntpd.h
ntpd_SOURCES += parse.y
if HAVE_SENSORS
ntpd_SOURCES += sensors.c
else
ntpd_SOURCES += compat/fake-sensors.c
endif
ntpd_SOURCES += server.c
ntpd_SOURCES += util.c
install-exec-hook:
@ln -f "$(DESTDIR)$(sbindir)/ntpd" "$(DESTDIR)$(sbindir)/ntpctl"
@if [ ! -d "$(DESTDIR)$(sysconfdir)" ]; then \
$(INSTALL) -m 755 -d "$(DESTDIR)$(sysconfdir)"; \
fi
@if [ ! -d "$(DESTDIR)$(localstatedir)/run" ]; then \
$(INSTALL) -m 755 -d "$(DESTDIR)$(localstatedir)/run"; \
fi
@if [ ! -d "$(DESTDIR)$(localstatedir)/db" ]; then \
$(INSTALL) -m 755 -d "$(DESTDIR)$(localstatedir)/db"; \
fi
@if [ ! -f "$(DESTDIR)$(sysconfdir)/ntpd.conf" ]; then \
$(INSTALL) -m 644 "$(srcdir)/ntpd.conf" "$(DESTDIR)$(sysconfdir)/ntpd.conf"; \
else \
echo; \
echo " $(DESTDIR)$(sysconfdir)/ntpd.conf already exists, install will not overwrite"; \
fi
@if [ ! -d "$(PRIVSEP_PATH)" ]; then \
echo; \
echo " Please created a privilege separation directory for ntpd." ; \
echo " For OS X, see INSTALL for instructions." ; \
echo " On Linux / BSD systems, this will probably work:"; \
echo ; \
echo " mkdir -p \"$(PRIVSEP_PATH)\"" ; \
echo " chown 0 \"$(PRIVSEP_PATH)\"" ; \
echo " chgrp 0 \"$(PRIVSEP_PATH)\"" ; \
echo " chmod 0755 \"$(PRIVSEP_PATH)\"" ; \
fi
@if egrep "^$(PRIVSEP_USER):" /etc/group >/dev/null; then \
: ; \
else \
echo; \
echo " Please create a dedicated group for ntpd." ; \
echo " For OS X, see INSTALL for instructions." ; \
echo " On Linux / BSD systems, this will probably work:"; \
echo ; \
echo " groupadd $(PRIVSEP_USER)" ; \
fi
@if egrep "^$(PRIVSEP_USER):" /etc/passwd >/dev/null; then \
: ; \
else \
echo; \
echo " Please create a dedicated user for ntpd and ensure it" ; \
echo " cannot be used to log in." ; \
echo " For OS X, see INSTALL for instructions." ; \
echo " On Linux / BSD systems, this will probably work:" ; \
echo ; \
echo " useradd -g $(PRIVSEP_USER) -s /sbin/nologin -d $(PRIVSEP_PATH) -c 'OpenNTP daemon' $(PRIVSEP_USER)" ; \
fi
@if [ -d $(PRIVSEP_PATH) ]; then \
if [ `ls -A $(PRIVSEP_PATH)|wc -l` != "0" ]; then \
echo; \
echo " WARNING: the privilege separation path is specified as $(PRIVSEP_PATH), " ; \
echo " but this directory contains files!" ; \
echo ; \
echo " Please ensure that $(PRIVSEP_PATH) is empty. If you installed a previous " ; \
echo " OpenNTPD version and created a user with a home directory at /var/empty/ntpd, " ; \
echo " please adjust that user to use /var/empty instead and delete /var/empty/ntpd." ; \
fi; \
fi
@echo
uninstall-local:
@if cmp -s "$(DESTDIR)$(sysconfdir)/ntpd.conf" "$(srcdir)/ntpd.conf"; then \
rm -f "$(DESTDIR)$(sysconfdir)/ntpd.conf"; \
fi
@rm -f "$(DESTDIR)$(sbindir)/ntpctl"
# compatibility functions that need to be built without optimizations
libcompatnoopt_la_CFLAGS = -O0
libcompatnoopt_la_SOURCES =
if !HAVE_EXPLICIT_BZERO
libcompatnoopt_la_SOURCES += compat/explicit_bzero.c
endif
# other compatibility functions
libcompat_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS)
libcompat_la_SOURCES =
libcompat_la_LIBADD = $(PLATFORM_LDADD)
if !HAVE_ADJFREQ
if HOST_FREEBSD
libcompat_la_SOURCES += compat/adjfreq_freebsd.c
endif
if HOST_LINUX
libcompat_la_SOURCES += compat/adjfreq_linux.c
endif
if HOST_NETBSD
libcompat_la_SOURCES += compat/adjfreq_netbsd.c
endif
if HOST_DARWIN
libcompat_la_SOURCES += compat/adjfreq_osx.c
endif
if HOST_SOLARIS
libcompat_la_SOURCES += compat/adjfreq_solaris.c
endif
endif
if !HAVE_ASPRINTF
libcompat_la_SOURCES += compat/bsd-asprintf.c
endif
if !HAVE_CLOCK_GETRES
libcompat_la_SOURCES += compat/clock_getres.c
endif
if !HAVE_CLOCK_GETTIME
if HOST_DARWIN
libcompat_la_SOURCES += compat/clock_gettime_osx.c
endif
endif
if !HAVE_IMSG
libcompat_la_SOURCES += compat/imsg.c
libcompat_la_SOURCES += compat/imsg-buffer.c
endif
if !HAVE_MD5
libcompat_la_SOURCES += compat/md5.c
endif
libcompat_la_SOURCES += compat/progname.c
if !HAVE_REALLOCARRAY
libcompat_la_SOURCES += compat/reallocarray.c
endif
if !HAVE_SETPROCTITLE
libcompat_la_SOURCES += compat/setproctitle.c
endif
if !HAVE_STRLCAT
libcompat_la_SOURCES += compat/strlcat.c
endif
if !HAVE_STRLCPY
libcompat_la_SOURCES += compat/strlcpy.c
endif
if !HAVE_STRTONUM
libcompat_la_SOURCES += compat/strtonum.c
endif
if !HAVE_SETRESGID
libcompat_la_SOURCES += compat/bsd-setresgid.c
endif
if !HAVE_SETRESUID
libcompat_la_SOURCES += compat/bsd-setresuid.c
endif
if !HAVE_ARC4RANDOM
libcompat_la_SOURCES += compat/arc4random.c
if !HAVE_GETENTROPY
if HOST_FREEBSD
libcompat_la_SOURCES += compat/getentropy_freebsd.c
endif
if HOST_LINUX
libcompat_la_SOURCES += compat/getentropy_linux.c
if !HAVE_SHA512
libcompat_la_SOURCES += compat/sha2.c
endif
endif
if HOST_NETBSD
libcompat_la_SOURCES += compat/getentropy_netbsd.c
endif
if HOST_DARWIN
libcompat_la_SOURCES += compat/getentropy_osx.c
if !HAVE_SHA512
libcompat_la_SOURCES += compat/sha2.c
endif
endif
if HOST_SOLARIS
libcompat_la_SOURCES += compat/getentropy_solaris.c
if !HAVE_SHA512
libcompat_la_SOURCES += compat/sha2.c
endif
endif
endif
endif
if !HAVE_ARC4RANDOM_UNIFORM
libcompat_la_SOURCES += compat/arc4random_uniform.c
endif
noinst_HEADERS = compat/arc4random.h
noinst_HEADERS += compat/arc4random_freebsd.h
noinst_HEADERS += compat/arc4random_linux.h
noinst_HEADERS += compat/arc4random_netbsd.h
noinst_HEADERS += compat/arc4random_osx.h
noinst_HEADERS += compat/arc4random_solaris.h
noinst_HEADERS += compat/arc4random_win.h
noinst_HEADERS += compat/chacha_private.h

+ 146
- 0
compat/Makefile.am View File

@ -0,0 +1,146 @@
#
# Copyright (c) 2014 Brent Cook
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src
noinst_LTLIBRARIES = libcompat.la libcompatnoopt.la
# compatibility functions that need to be built without optimizations
libcompatnoopt_la_CFLAGS = -O0
libcompatnoopt_la_SOURCES =
if !HAVE_EXPLICIT_BZERO
libcompatnoopt_la_SOURCES += explicit_bzero.c
endif
# other compatibility functions
libcompat_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS)
libcompat_la_SOURCES =
libcompat_la_LIBADD = $(PLATFORM_LDADD)
if !HAVE_ADJFREQ
if HOST_FREEBSD
libcompat_la_SOURCES += adjfreq_freebsd.c
endif
if HOST_LINUX
libcompat_la_SOURCES += adjfreq_linux.c
endif
if HOST_NETBSD
libcompat_la_SOURCES += adjfreq_netbsd.c
endif
if HOST_DARWIN
libcompat_la_SOURCES += adjfreq_osx.c
endif
if HOST_SOLARIS
libcompat_la_SOURCES += adjfreq_solaris.c
endif
endif
if !HAVE_ASPRINTF
libcompat_la_SOURCES += bsd-asprintf.c
endif
if !HAVE_CLOCK_GETRES
libcompat_la_SOURCES += clock_getres.c
endif
if !HAVE_CLOCK_GETTIME
if HOST_DARWIN
libcompat_la_SOURCES += clock_gettime_osx.c
endif
endif
if !HAVE_IMSG
libcompat_la_SOURCES += imsg.c
libcompat_la_SOURCES += imsg-buffer.c
endif
if !HAVE_MD5
libcompat_la_SOURCES += md5.c
endif
libcompat_la_SOURCES += progname.c
if !HAVE_REALLOCARRAY
libcompat_la_SOURCES += reallocarray.c
endif
if !HAVE_SETPROCTITLE
libcompat_la_SOURCES += setproctitle.c
endif
if !HAVE_STRLCAT
libcompat_la_SOURCES += strlcat.c
endif
if !HAVE_STRLCPY
libcompat_la_SOURCES += strlcpy.c
endif
if !HAVE_STRTONUM
libcompat_la_SOURCES += strtonum.c
endif
if !HAVE_SETRESGID
libcompat_la_SOURCES += bsd-setresgid.c
endif
if !HAVE_SETRESUID
libcompat_la_SOURCES += bsd-setresuid.c
endif
if !HAVE_ARC4RANDOM
libcompat_la_SOURCES += arc4random.c
if !HAVE_GETENTROPY
if HOST_FREEBSD
libcompat_la_SOURCES += getentropy_freebsd.c
endif
if HOST_LINUX
libcompat_la_SOURCES += getentropy_linux.c
if !HAVE_SHA512
libcompat_la_SOURCES += sha2.c
endif
endif
if HOST_NETBSD
libcompat_la_SOURCES += getentropy_netbsd.c
endif
if HOST_DARWIN
libcompat_la_SOURCES += getentropy_osx.c
if !HAVE_SHA512
libcompat_la_SOURCES += sha2.c
endif
endif
if HOST_SOLARIS
libcompat_la_SOURCES += getentropy_solaris.c
if !HAVE_SHA512
libcompat_la_SOURCES += sha2.c
endif
endif
endif
endif
if !HAVE_ARC4RANDOM_UNIFORM
libcompat_la_SOURCES += arc4random_uniform.c
endif
noinst_HEADERS = arc4random.h
noinst_HEADERS += arc4random_freebsd.h
noinst_HEADERS += arc4random_linux.h
noinst_HEADERS += arc4random_netbsd.h
noinst_HEADERS += arc4random_osx.h
noinst_HEADERS += arc4random_solaris.h
noinst_HEADERS += arc4random_win.h
noinst_HEADERS += chacha_private.h

+ 2
- 2
compat/adjfreq_freebsd.c View File

@ -19,8 +19,8 @@
#include <unistd.h>
#include "ntp.h"
#include "ntpd.h"
#include <ntp.h>
#include <ntpd.h>
/*
* adjfreq (old)freq = nanosec. per seconds shifted left 32 bits


+ 2
- 2
compat/adjfreq_linux.c View File

@ -19,8 +19,8 @@
#include <unistd.h>
#include "ntp.h"
#include "ntpd.h"
#include <ntp.h>
#include <ntpd.h>
/*
* adjfreq (old)freq = nanosec. per seconds shifted left 32 bits


+ 2
- 2
compat/adjfreq_netbsd.c View File

@ -20,8 +20,8 @@
#include <unistd.h>
#include "ntp.h"
#include "ntpd.h"
#include <ntp.h>
#include <ntpd.h>
/*
* adjfreq (old)freq = nanosec. per seconds shifted left 32 bits


+ 2
- 2
compat/adjfreq_solaris.c View File

@ -19,8 +19,8 @@
#include <unistd.h>
#include "ntp.h"
#include "ntpd.h"
#include <ntp.h>
#include <ntpd.h>
/*
* adjfreq (old)freq = nanosec. per seconds shifted left 32 bits


+ 3
- 1
configure.ac View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2014 Brent Cook
# Copyright (c) 2014-2015 Brent Cook
# Parts based on configure.ac from Portable OpenNTPD:
# Copyright (c) 2004-2008 Darren Tucker
# which itself was based on configure.ac from OpenSSH:
@ -222,6 +222,8 @@ AC_SUBST(PRIVSEP_PATH)
AC_CONFIG_FILES([
Makefile
include/Makefile
compat/Makefile
src/Makefile
])
AC_OUTPUT

+ 108
- 0
src/Makefile.am View File

@ -0,0 +1,108 @@
#
# Copyright (c) 2014 Brent Cook
# Parts based on Makefile.in from Portable OpenNTPD:
# Copyright (c) 2004-2008 Darren Tucker.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
AM_CPPFLAGS = -I$(top_srcdir)/include
ACLOCAL_AMFLAGS = -Im4
CLEANFILES = parse.c
sbin_PROGRAMS = ntpd
dist_man_MANS = ntpctl.8 ntpd.8 ntpd.conf.5
ntpd_CFLAGS = $(CFLAGS) $(USER_CFLAGS)
ntpd_CFLAGS += -DSYSCONFDIR=\"$(sysconfdir)\"
ntpd_CFLAGS += -DLOCALSTATEDIR=\"$(localstatedir)\"
ntpd_LDADD = $(PLATFORM_LDADD) $(PROG_LDADD)
ntpd_LDADD += $(top_builddir)/compat/libcompat.la
ntpd_LDADD += $(top_builddir)/compat/libcompatnoopt.la
ntpd_SOURCES = client.c
ntpd_SOURCES += config.c
ntpd_SOURCES += control.c
ntpd_SOURCES += log.c
ntpd_SOURCES += log.h
ntpd_SOURCES += ntp.c
ntpd_SOURCES += ntp.h
ntpd_SOURCES += ntp_dns.c
ntpd_SOURCES += ntp_msg.c
ntpd_SOURCES += ntpd.c
ntpd_SOURCES += ntpd.h
ntpd_SOURCES += parse.y
if HAVE_SENSORS
ntpd_SOURCES += sensors.c
else
ntpd_SOURCES += fake-sensors.c
endif
ntpd_SOURCES += server.c
ntpd_SOURCES += util.c
install-exec-hook:
@ln -f "$(DESTDIR)$(sbindir)/ntpd" "$(DESTDIR)$(sbindir)/ntpctl"
@if [ ! -d "$(DESTDIR)$(sysconfdir)" ]; then \
$(INSTALL) -m 755 -d "$(DESTDIR)$(sysconfdir)"; \
fi
@if [ ! -d "$(DESTDIR)$(localstatedir)/run" ]; then \
$(INSTALL) -m 755 -d "$(DESTDIR)$(localstatedir)/run"; \
fi
@if [ ! -d "$(DESTDIR)$(localstatedir)/db" ]; then \
$(INSTALL) -m 755 -d "$(DESTDIR)$(localstatedir)/db"; \
fi
@if [ ! -d "$(PRIVSEP_PATH)" ]; then \
echo; \
echo " Please created a privilege separation directory for ntpd." ; \
echo " For OS X, see INSTALL for instructions." ; \
echo " On Linux / BSD systems, this will probably work:"; \
echo ; \
echo " mkdir -p \"$(PRIVSEP_PATH)\"" ; \
echo " chown 0 \"$(PRIVSEP_PATH)\"" ; \
echo " chgrp 0 \"$(PRIVSEP_PATH)\"" ; \
echo " chmod 0755 \"$(PRIVSEP_PATH)\"" ; \
fi
@if egrep "^$(PRIVSEP_USER):" /etc/group >/dev/null; then \
: ; \
else \
echo; \
echo " Please create a dedicated group for ntpd." ; \
echo " For OS X, see INSTALL for instructions." ; \
echo " On Linux / BSD systems, this will probably work:"; \
echo ; \
echo " groupadd $(PRIVSEP_USER)" ; \
fi
@if egrep "^$(PRIVSEP_USER):" /etc/passwd >/dev/null; then \
: ; \
else \
echo; \
echo " Please create a dedicated user for ntpd and ensure it" ; \
echo " cannot be used to log in." ; \
echo " For OS X, see INSTALL for instructions." ; \
echo " On Linux / BSD systems, this will probably work:" ; \
echo ; \
echo " useradd -g $(PRIVSEP_USER) -s /sbin/nologin -d $(PRIVSEP_PATH) -c 'OpenNTP daemon' $(PRIVSEP_USER)" ; \
fi
@if [ -d $(PRIVSEP_PATH) ]; then \
if [ `ls -A $(PRIVSEP_PATH)|wc -l` != "0" ]; then \
echo; \
echo " WARNING: the privilege separation path is specified as $(PRIVSEP_PATH), " ; \
echo " but this directory contains files!" ; \
echo ; \
echo " Please ensure that $(PRIVSEP_PATH) is empty. If you installed a previous " ; \
echo " OpenNTPD version and created a user with a home directory at /var/empty/ntpd, " ; \
echo " please adjust that user to use /var/empty instead and delete /var/empty/ntpd." ; \
fi; \
fi
@echo

compat/fake-sensors.c → src/fake-sensors.c View File


+ 4
- 2
update.sh View File

@ -55,10 +55,12 @@ for i in client.c config.c control.c log.c log.h ntp.c ntp.h ntp_dns.c ntp_msg.c
ntpctl.8 ntpd.8 ntpd.conf.5 ; do
file=`basename $i`
echo Copying $file
$CP $ntpd_src/$i .
$CP $ntpd_src/$i src
done
for i in patches/*.patch; do
(cd src
for i in ../patches/*.patch; do
echo Patching $i
$PATCH -p4 < $i
done
)

Loading…
Cancel
Save