AC_DEFINE([USE_HWCLOCK_CMOS], [1], [Define to 1 if want to use CMOS clock.])
])
+AC_ARG_ENABLE([hwclock_gplv3],
+ AS_HELP_STRING([--disable-hwclock-gplv3], [do not use datetime parsing GPLv3 code]),
+ [], [enable_hwclock_gplv3=yes]
+)
+AM_CONDITIONAL([USE_HWCLOCK_GPLv3_DATETIME], [test "x$enable_hwclock_gplv3" = xyes])
+AS_IF([test "x$enable_hwclock_gplv3" = xyes ], [
+ AC_DEFINE([USE_HWCLOCK_GPLv3_DATETIME], [1], [use datetime parsing GPLv3 code to hwclock])
+])
+
UL_BUILD_INIT([mkfs], [yes])
AM_CONDITIONAL([BUILD_MKFS], [test "x$build_mkfs" = xyes])
PATHFILES += sys-utils/hwclock.8
hwclock_SOURCES = \
sys-utils/hwclock.c \
- sys-utils/hwclock.h \
+ sys-utils/hwclock.h
+if USE_HWCLOCK_GPLv3_DATETIME
+hwclock_SOURCES += \
sys-utils/hwclock-parse-date.y
+endif
hwclock_LDADD = $(LDADD) libcommon.la -lm
hwclock_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/sys-utils
if USE_HWCLOCK_CMOS
*
* Since 7a3000f7ba548cf7d74ac77cc63fe8de228a669e (v2.30) hwclock is linked
* with parse_date.y from gnullib. This gnulib code is distributed with GPLv3.
+ * Use --disable-hwclock-gplv3 to exclude this code.
*
*
* clock.c was written by Charles Hedrick, hedrick@cs.rutgers.edu, Apr 1992
};
struct timeval startup_time;
struct adjtime adjtime = { 0 };
- struct timespec when = { 0 };
/*
* The time we started up, in seconds into the epoch, including
* fractions.
if (ctl.set || ctl.predict) {
if (!ctl.date_opt) {
- warnx(_("--date is required for --set or --predict"));
- exit(EXIT_FAILURE);
+ warnx(_("--date is required for --set or --predict"));
+ exit(EXIT_FAILURE);
}
+#ifdef USE_HWCLOCK_GPLv3_DATETIME
+ /* date(1) compatible GPLv3 parser */
+ struct timespec when = { 0 };
+
if (parse_date(&when, ctl.date_opt, NULL))
set_time = when.tv_sec;
+#else
+ /* minimalistic GPLv2 based parser */
+ usec_t usec;
+
+ if (parse_timestamp(ctl.date_opt, &usec) == 0)
+ set_time = (time_t) (usec / 1000000);
+#endif
else {
warnx(_("invalid date '%s'"), ctl.date_opt);
exit(EXIT_FAILURE);