diff --git a/Makefile.in b/Makefile.in index 2bcf5e8..4ffd5fd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -38,14 +38,9 @@ DESTDIR= HASH_OBJ = @HASH_OBJ@ -OBJS = util.o sched.o regress.o local.o \ - sys.o main.o ntp_io.o ntp_core.o ntp_sources.o \ - sources.o sourcestats.o reference.o \ - logging.o conf.o cmdmon.o keys.o \ - nameserv.o nameserv_async.o manual.o addrfilt.o \ - cmdparse.o mkdirpp.o rtc.o pktlength.o clientlog.o \ - broadcast.o refclock.o refclock_phc.o refclock_pps.o \ - refclock_shm.o refclock_sock.o tempcomp.o $(HASH_OBJ) +OBJS = cmdparse.o conf.o local.o logging.o main.o mkdirpp.o reference.o \ + regress.o rtc.o sched.o sources.o sourcestats.o stubs.o sys.o \ + tempcomp.o util.o $(HASH_OBJ) EXTRA_OBJS=@EXTRA_OBJECTS@ diff --git a/configure b/configure index e717e31..3f898bd 100755 --- a/configure +++ b/configure @@ -105,9 +105,12 @@ For better control, use the options below. --with-ncurses-library=DIR Specify where ncurses lib directory is --without-nss Don't use NSS even if it is available --without-tomcrypt Don't use libtomcrypt even if it is available + --disable-cmdmon Disable command and monitoring support + --disable-ntp Disable NTP support + --disable-refclock Disable reference clock support + --disable-phc Disable PHC refclock driver + --disable-pps Disable PPS refclock driver --disable-ipv6 Disable IPv6 support - --disable-phc Disable PHC support - --disable-pps Disable PPS API support --disable-rtc Don't include RTC even on Linux --disable-linuxcaps Disable Linux capabilities support --disable-asyncdns Disable asynchronous name resolving @@ -181,6 +184,9 @@ EXTRA_DEFS="" SYSDEFS="" debug=0 +feat_cmdmon=1 +feat_ntp=1 +feat_refclock=1 feat_readline=1 try_readline=1 try_editline=1 @@ -262,6 +268,15 @@ do --chronyvardir=* ) SETCHRONYVARDIR=`echo $option | sed -e 's/^.*=//;'` ;; + --disable-cmdmon) + feat_cmdmon=0 + ;; + --disable-ntp) + feat_ntp=0 + ;; + --disable-refclock) + feat_refclock=0 + ;; --disable-rtc) feat_rtc=0 ;; @@ -389,6 +404,29 @@ case $SYSTEM in ;; esac +if [ $feat_cmdmon = "1" ]; then + add_def FEAT_CMDMON + EXTRA_OBJECTS="$EXTRA_OBJECTS cmdmon.o manual.o pktlength.o" +fi + +if [ $feat_ntp = "1" ]; then + add_def FEAT_NTP + EXTRA_OBJECTS="$EXTRA_OBJECTS broadcast.o nameserv_async.o ntp_core.o ntp_io.o ntp_sources.o" +else + feat_asyncdns=0 +fi + +if [ "$feat_cmdmon" = "1" ] || [ $feat_ntp = "1" ]; then + EXTRA_OBJECTS="$EXTRA_OBJECTS addrfilt.o clientlog.o keys.o nameserv.o" +else + feat_ipv6=0 +fi + +if [ $feat_refclock = "1" ]; then + add_def FEAT_REFCLOCK + EXTRA_OBJECTS="$EXTRA_OBJECTS refclock.o refclock_phc.o refclock_pps.o refclock_shm.o refclock_sock.o" +fi + if test_code '64-bit time_t' 'time.h' '' '' ' char x[sizeof(time_t) > 4 ? 1 : -1] = {0}; return x[0];' @@ -481,7 +519,7 @@ then fi timepps_h="" -if [ $feat_pps = "1" ]; then +if [ $feat_refclock = "1" ] && [ $feat_pps = "1" ]; then if test_code '' 'sys/timepps.h' '' '' ''; then timepps_h="sys/timepps.h" add_def HAVE_SYS_TIMEPPS_H @@ -522,7 +560,7 @@ then add_def FEAT_RTC fi -if [ $feat_phc = "1" ] && [ $try_phc = "1" ] && \ +if [ $feat_refclock = "1" ] && [ $feat_phc = "1" ] && [ $try_phc = "1" ] && \ test_code '' 'sys/ioctl.h linux/ptp_clock.h' '' '' \ 'ioctl(1, PTP_CLOCK_GETCAPS, 0);' then diff --git a/stubs.c b/stubs.c new file mode 100644 index 0000000..e1ae485 --- /dev/null +++ b/stubs.c @@ -0,0 +1,310 @@ +/* + chronyd/chronyc - Programs for keeping computer clocks accurate. + + ********************************************************************** + * Copyright (C) Miroslav Lichvar 2014 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + ********************************************************************** + + ======================================================================= + + Function replacements needed when optional features are disabled. + + */ + +#include "config.h" + +#include "broadcast.h" +#include "clientlog.h" +#include "cmdmon.h" +#include "keys.h" +#include "logging.h" +#include "manual.h" +#include "nameserv.h" +#include "ntp_core.h" +#include "ntp_io.h" +#include "ntp_sources.h" +#include "refclock.h" + +#ifndef FEAT_CMDMON + +void +CAM_Initialise(int family) +{ +} + +void +CAM_Finalise(void) +{ +} + +int +CAM_AddAccessRestriction(IPAddr *ip_addr, int subnet_bits, int allow, int all) +{ + return 1; +} + +void +MNL_Initialise(void) +{ +} + +void +MNL_Finalise(void) +{ +} + +#endif /* !FEAT_CMDMON */ + +#ifndef FEAT_NTP + +void +BRD_Initialise(void) +{ +} + +void +BRD_Finalise(void) +{ +} + +void +BRD_AddDestination(IPAddr *addr, unsigned short port, int interval) +{ +} + +void +NCR_Initialise(void) +{ +} + +void +NCR_Finalise(void) +{ +} + +int +NCR_AddAccessRestriction(IPAddr *ip_addr, int subnet_bits, int allow, int all) +{ + return 1; +} + +int +NCR_CheckAccessRestriction(IPAddr *ip_addr) +{ + return 0; +} + +void +NIO_Initialise(int family) +{ +} + +void +NIO_Finalise(void) +{ +} + +void +NSR_Initialise(void) +{ +} + +void +NSR_Finalise(void) +{ +} + +NSR_Status +NSR_AddSource(NTP_Remote_Address *remote_addr, NTP_Source_Type type, SourceParameters *params) +{ + return NSR_TooManySources; +} + +void +NSR_AddUnresolvedSource(char *name, int port, NTP_Source_Type type, SourceParameters *params) +{ +} + +NSR_Status +NSR_RemoveSource(NTP_Remote_Address *remote_addr) +{ + return NSR_NoSuchSource; +} + +void +NSR_RemoveAllSources(void) +{ +} + +void +NSR_SetSourceResolvingEndHandler(NSR_SourceResolvingEndHandler handler) +{ + if (handler) + (handler)(); +} + +void +NSR_ResolveSources(void) +{ +} + +void NSR_StartSources(void) +{ +} + +void NSR_AutoStartSources(void) +{ +} + +int +NSR_InitiateSampleBurst(int n_good_samples, int n_total_samples, + IPAddr *mask, IPAddr *address) +{ + return 0; +} + +int +NSR_TakeSourcesOnline(IPAddr *mask, IPAddr *address) +{ + return 0; +} + +int +NSR_TakeSourcesOffline(IPAddr *mask, IPAddr *address) +{ + return 0; +} + +int +NSR_ModifyMinpoll(IPAddr *address, int new_minpoll) +{ + return 0; +} + +int +NSR_ModifyMaxpoll(IPAddr *address, int new_maxpoll) +{ + return 0; +} + +int +NSR_ModifyMaxdelay(IPAddr *address, double new_max_delay) +{ + return 0; +} + +int +NSR_ModifyMaxdelayratio(IPAddr *address, double new_max_delay_ratio) +{ + return 0; +} + +int +NSR_ModifyMaxdelaydevratio(IPAddr *address, double new_max_delay_dev_ratio) +{ + return 0; +} + +int +NSR_ModifyMinstratum(IPAddr *address, int new_min_stratum) +{ + return 0; +} + +int +NSR_ModifyPolltarget(IPAddr *address, int new_poll_target) +{ + return 0; +} + +void +NSR_ReportSource(RPT_SourceReport *report, struct timeval *now) +{ + memset(report, 0, sizeof (*report)); +} + +void +NSR_GetActivityReport(RPT_ActivityReport *report) +{ + memset(report, 0, sizeof (*report)); +} + +#ifndef FEAT_CMDMON + +void +CLG_Initialise(void) +{ +} + +void +CLG_Finalise(void) +{ +} + +void +DNS_SetAddressFamily(int family) +{ +} + +DNS_Status +DNS_Name2IPAddress(const char *name, IPAddr *addr) +{ + return DNS_Failure; +} + +void +KEY_Initialise(void) +{ +} + +void +KEY_Finalise(void) +{ +} + +#endif /* !FEAT_CMDMON */ +#endif /* !FEAT_NTP */ + +#ifndef FEAT_REFCLOCK +void +RCL_Initialise(void) +{ +} + +void +RCL_Finalise(void) +{ +} + +int +RCL_AddRefclock(RefclockParameters *params) +{ + return 0; +} + +void +RCL_StartRefclocks(void) +{ +} + +void +RCL_ReportSource(RPT_SourceReport *report, struct timeval *now) +{ + memset(report, 0, sizeof (*report)); +} + +#endif /* !FEAT_REFCLOCK */