diff options
| -rw-r--r-- | .gitignore | 15 | ||||
| -rw-r--r-- | Makefile.am | 3 | ||||
| -rw-r--r-- | ircd/Makefile.am | 51 | ||||
| -rw-r--r-- | ircd/creation.c.SH | 57 | ||||
| -rw-r--r-- | ircd/creation.c.in | 4 | ||||
| -rw-r--r-- | ircd/meson.build | 20 | ||||
| -rw-r--r-- | ircd/version.c.SH | 28 | ||||
| -rw-r--r-- | ircd/version.c.in | 2 | ||||
| -rw-r--r-- | librb/Makefile.am | 1 | ||||
| -rw-r--r-- | librb/meson.build | 1 | ||||
| -rw-r--r-- | librb/src/Makefile.am | 1 | ||||
| -rw-r--r-- | librb/src/version.c.SH | 13 | ||||
| -rw-r--r-- | librb/src/version.c.in | 1 |
13 files changed, 114 insertions, 83 deletions
@@ -33,6 +33,7 @@ librb/configure librb/compile librb/depcomp librb/aclocal.m4 +librb/include/datecode.h librb/include/librb_config.h librb/include/librb_config.h.in librb/include/librb-config.h @@ -43,17 +44,19 @@ librb/missing librb/libratbox.pc librb/libtool librb/src/version.c -librb/src/version.c.last scripts/*.tar.bz2 scripts/*.tar.gz +include/datecode.h +include/serno.h include/setup.h include/setup.h.in -ircd/solanum +ircd/creation.c +ircd/generation.last +ircd/ircd_lexer.c ircd/ircd_parser.c ircd/ircd_parser.h -ircd/ircd_lexer.c +ircd/solanum ircd/version.c -ircd/version.c.last ssld/ssld testsuite/ircd.pid.* tools/solanum-mkpasswd @@ -61,10 +64,6 @@ tools/solanum-mkfingerprint tools/genssl tools/mkpasswd tools/viconf -include/serno.h -ircd/solanum -ircd/version.c -ircd/version.c.last /libtool Makefile.in m4/argz.m4 diff --git a/Makefile.am b/Makefile.am index b8a0cb55..89aa3fdc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -44,8 +44,9 @@ distclean-local: clean-local: rm -f include/serno.h rm -f include/datecode.h + rm -f ircd/creation.c + rm -f ircd/generation.last rm -f ircd/ircd_lexer.c rm -f ircd/ircd_parser.c rm -f ircd/ircd_parser.h rm -f ircd/version.c - rm -f ircd/version.c.last diff --git a/ircd/Makefile.am b/ircd/Makefile.am index 6b3754fe..027838e2 100644 --- a/ircd/Makefile.am +++ b/ircd/Makefile.am @@ -1,31 +1,38 @@ AUTOMAKE_OPTIONS = foreign -prefix = @prefix@ -libircddir = @libdir@ +prefix = @prefix@ +libircddir = @libdir@ -AM_CPPFLAGS = @LTDLINCL@ -I$(top_srcdir)/include -I$(top_srcdir)/librb/include -AM_LDFLAGS = -L$(top_srcdir)/librb/src -export-dynamic -avoid-version -no-undefined -AM_YFLAGS = -d +AM_CPPFLAGS = @LTDLINCL@ -I$(top_srcdir)/include -I$(top_srcdir)/librb/include +AM_LDFLAGS = -L$(top_srcdir)/librb/src -export-dynamic -avoid-version -no-undefined +AM_YFLAGS = -d -BUILT_SOURCES = ircd_parser.h version.c +BUILT_SOURCES = ircd_parser.h -version.c: version.c.SH ../CREDITS ../include/patchlevel.h ../include/serno.h ../include/datecode.h - $(SHELL) version.c.SH - $(CP) version.c version.c.last - touch version.c.SH +# Force creation.c and version.c to be rebuilt every time make is +# invoked by declaring one of their prerequisites a phony target +# +.PHONY: creation.c.in version.c.in -libircd_la_SOURCES = \ - authproc.c \ +creation.c: creation.c.SH creation.c.in + $(SHELL) $(<) creation.c.in creation.c generation.last + +version.c: version.c.SH version.c.in ../CREDITS ../include/datecode.h ../include/patchlevel.h ../include/serno.h + $(SHELL) $(<) + +libircd_la_SOURCES = \ + authproc.c \ bandbi.c \ - batch.c \ + batch.c \ cache.c \ - capability.c \ + capability.c \ channel.c \ chmode.c \ class.c \ client.c \ - client_tags.c \ - dns.c \ + client_tags.c \ + creation.c \ + dns.c \ extban.c \ getopt.c \ hash.c \ @@ -40,13 +47,13 @@ libircd_la_SOURCES = \ match.c \ modules.c \ monitor.c \ - msgbuf.c \ + msgbuf.c \ newconf.c \ operhash.c \ packet.c \ parse.c \ privilege.c \ - ratelimit.c \ + ratelimit.c \ reject.c \ response.c \ restart.c \ @@ -64,14 +71,14 @@ libircd_la_SOURCES = \ version.c \ whowas.c -libircd_la_LDFLAGS = $(EXTRA_FLAGS) -avoid-version -no-undefined -libircd_la_LIBADD = @LIBLTDL@ -L$(top_srcdir)/librb/src -lrb +libircd_la_LDFLAGS = $(EXTRA_FLAGS) -avoid-version -no-undefined +libircd_la_LIBADD = @LIBLTDL@ -L$(top_srcdir)/librb/src -lrb libircd_LTLIBRARIES = libircd.la -bin_PROGRAMS = solanum +bin_PROGRAMS = solanum solanum_SOURCES = main.c solanum_LDFLAGS = $(EXTRA_FLAGS) -dlopen self -solanum_LDADD = libircd.la -L$(top_srcdir)/librb/src -lrb +solanum_LDADD = libircd.la -L$(top_srcdir)/librb/src -lrb install-exec-hook: install-libircdLTLIBRARIES $(RM) -f version.c diff --git a/ircd/creation.c.SH b/ircd/creation.c.SH new file mode 100644 index 00000000..969edafc --- /dev/null +++ b/ircd/creation.c.SH @@ -0,0 +1,57 @@ +#!/bin/sh + +set -eu + +INPUT_FILE="$1" +OUTPUT_FILE="$2" +GENERATION_FILE="$3" + +# Use SOURCE_DATE_EPOCH if it is present and EXTERNAL_BUILD_TIMESTAMP is not +# +if test -n "${SOURCE_DATE_EPOCH:-}" +then + if test -z "${EXTERNAL_BUILD_TIMESTAMP:-}" + then + EXTERNAL_BUILD_TIMESTAMP="${SOURCE_DATE_EPOCH}" + fi +fi + +if test -n "${EXTERNAL_BUILD_TIMESTAMP:-}" +then + # If using reproducible builds, hardcode the build timestamp and set the generation counter to 1 + # + CREATION=$(LC_ALL=C date -d '@'"${EXTERNAL_BUILD_TIMESTAMP}" +'%a %b %d %Y at %T %Z') + GENERATION=1 +else + # Otherwise, use the current date as the creation date + # + CREATION=$(LC_ALL=C date +'%a %b %d %Y at %T %Z') + + # If this is not the first generation, read and increment the old one. Otherwise, use an initial generation + # counter of 0, in order to ensure that when the counter gets bumped twice (by invoking 'meson compile' and + # 'meson install'), it reads as 1 when IRCd is ultimately started. + # + if test -r "${GENERATION_FILE}" + then + GENERATION=$(cat "${GENERATION_FILE}") + if test -n "${GENERATION:-}" + then + GENERATION=$((GENERATION + 1)) + else + GENERATION=0 + fi + else + GENERATION=0 + fi +fi + +# Write the output file +# +sed \ + -e "s/@CREATION@/${CREATION}/" \ + -e "s/@GENERATION@/${GENERATION}/" \ + < "${INPUT_FILE}" > "${OUTPUT_FILE}" + +# Write the new generation counter +# +echo "${GENERATION}" > "${GENERATION_FILE}" diff --git a/ircd/creation.c.in b/ircd/creation.c.in new file mode 100644 index 00000000..2de82191 --- /dev/null +++ b/ircd/creation.c.in @@ -0,0 +1,4 @@ +// This file is automatically generated by creation.c.SH + +const char *creation = "@CREATION@"; +const char *generation = "@GENERATION@"; diff --git a/ircd/meson.build b/ircd/meson.build index 478123d8..29d4d56d 100644 --- a/ircd/meson.build +++ b/ircd/meson.build @@ -1,7 +1,9 @@ -ircd_parser = custom_target('ircd_parser', - input: 'ircd_parser.y', - output: ['ircd_parser.c', 'ircd_parser.h'], - command: [bison, '-d', '@INPUT@', '--output=@OUTPUT0@', '--defines=@OUTPUT1@'] +ircd_creation = custom_target('ircd_creation', + input: ['creation.c.SH', 'creation.c.in'], + output: ['creation.c', 'generation.last'], + command: ['sh', '@INPUT@', '@OUTPUT@'], + build_always_stale: true, + build_by_default: true, ) ircd_lexer = custom_target('ircd_lexer', @@ -10,10 +12,14 @@ ircd_lexer = custom_target('ircd_lexer', command: [flex, '-o', '@OUTPUT@', '@INPUT@'] ) +ircd_parser = custom_target('ircd_parser', + input: 'ircd_parser.y', + output: ['ircd_parser.c', 'ircd_parser.h'], + command: [bison, '-d', '@INPUT@', '--output=@OUTPUT0@', '--defines=@OUTPUT1@'] +) + credits_result = run_command('sed', 's/^$/ /;s/.*/ "&",/', meson.project_source_root() / 'CREDITS', check: true) ircd_version_conf = configuration_data() -ircd_version_conf.set('GENERATION', '0') -ircd_version_conf.set('CREATION', '__DATE__ at __TIME__') ircd_version_conf.set('CREDITS', credits_result.stdout()) ircd_version_conf.set('PACKAGE', meson.project_name()) ircd_version = configure_file( @@ -73,7 +79,7 @@ libircd_sources = files( libircd_inc = include_directories('../include') libircd = shared_library('ircd', - [libircd_sources, ircd_parser, ircd_lexer, ircd_version, serno_h], + [libircd_sources, ircd_creation, ircd_lexer, ircd_parser, ircd_version, serno_h], dependencies: [librb_dep, ltdl_dep], include_directories: libircd_inc, install: true, diff --git a/ircd/version.c.SH b/ircd/version.c.SH index c6d0d3e5..a8de713d 100644 --- a/ircd/version.c.SH +++ b/ircd/version.c.SH @@ -4,37 +4,11 @@ set -eu echo "Extracting solanum/ircd/version.c..." -if test -r version.c.last -then - generation=`sed -n 's/^const char \*generation = "\(.*\)";/\1/p' < version.c.last` - if test ! "$generation" ; then generation=0; fi -else - generation=0 -fi - -generation=`expr $generation + 1` - -if test -n "${SOURCE_DATE_EPOCH:-}" -a "${EXTERNAL_BUILD_TIMESTAMP:-}" = '' ; then - EXTERNAL_BUILD_TIMESTAMP=$SOURCE_DATE_EPOCH -fi -if test "${EXTERNAL_BUILD_TIMESTAMP:-}" = ''; then - creation=`LC_ALL=C date | \ -awk '{if (NF == 6) \ - { print $1 " " $2 " " $3 " " $6 " at " $4 " " $5 } \ -else \ - { print $1 " " $2 " " $3 " " $7 " at " $4 " " $5 " " $6 }}'` -else - creation="$EXTERNAL_BUILD_TIMESTAMP" - generation=1 -fi - # Generate CREDITS content credits=$(sed 's/^$/ /;s/.*/ "&",/' ../CREDITS) # Read template and substitute -sed -e "s/@GENERATION@/$generation/" \ - -e "s/@CREATION@/$creation/" \ - -e "/@CREDITS@/r /dev/stdin" \ +sed -e "/@CREDITS@/r /dev/stdin" \ -e "/@CREDITS@/d" \ version.c.in > version.c << EOF $credits diff --git a/ircd/version.c.in b/ircd/version.c.in index 6caee954..c7ff617a 100644 --- a/ircd/version.c.in +++ b/ircd/version.c.in @@ -25,8 +25,6 @@ #include "serno.h" #include "stdinc.h" -const char *generation = "@GENERATION@"; -const char *creation = "@CREATION@"; const char *ircd_version = PATCHLEVEL; const char *serno = SERNO; const unsigned long int datecode = DATECODE; diff --git a/librb/Makefile.am b/librb/Makefile.am index 5de88372..bf8d2a5d 100644 --- a/librb/Makefile.am +++ b/librb/Makefile.am @@ -23,4 +23,3 @@ clean-local: rm -f include/serno.h rm -f include/datecode.h rm -f src/version.c - rm -f src/version.c.last diff --git a/librb/meson.build b/librb/meson.build index 936cd13f..895fc117 100644 --- a/librb/meson.build +++ b/librb/meson.build @@ -31,7 +31,6 @@ librb_sources = files( librb_credits_result = run_command('sed', 's/^$/ /;s/.*/ "&",/', meson.current_source_dir() / 'CREDITS', check: true) librb_version_conf = configuration_data() -librb_version_conf.set('GENERATION', '0') librb_version_conf.set('CREDITS', librb_credits_result.stdout()) librb_version_c = configure_file( input: 'src/version.c.in', diff --git a/librb/src/Makefile.am b/librb/src/Makefile.am index 140596f7..26e3b741 100644 --- a/librb/src/Makefile.am +++ b/librb/src/Makefile.am @@ -7,7 +7,6 @@ BUILT_SOURCES = version.c version.c: version.c.SH ../CREDITS $(SHELL) ./version.c.SH - $(CP) version.c version.c.last version.lo: version.c ../include/serno.h ../include/datecode.h $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ diff --git a/librb/src/version.c.SH b/librb/src/version.c.SH index 19e2cf23..1c68ad29 100644 --- a/librb/src/version.c.SH +++ b/librb/src/version.c.SH @@ -4,22 +4,11 @@ set -eu echo "Extracting librb/src/version.c..." -if test -r version.c.last -then - generation=`sed -n 's/^const char \*librb_generation = "\(.*\)";/\1/p' < version.c.last` - if test ! "$generation" ; then generation=0; fi -else - generation=0 -fi - -generation=`expr $generation + 1` - # Generate CREDITS content credits=$(grep -v '^$Id' ../CREDITS | tr -d '"' | sed 's/.*/ "&",/') # Read template and substitute -sed -e "s/@GENERATION@/$generation/" \ - -e "/@CREDITS@/r /dev/stdin" \ +sed -e "/@CREDITS@/r /dev/stdin" \ -e "/@CREDITS@/d" \ version.c.in > version.c << EOF $credits diff --git a/librb/src/version.c.in b/librb/src/version.c.in index 620aaca7..16025b22 100644 --- a/librb/src/version.c.in +++ b/librb/src/version.c.in @@ -22,7 +22,6 @@ #include "../include/serno.h" -const char *librb_generation = "@GENERATION@"; const char *librb_serno = SERNO; const unsigned long int librb_datecode = DATECODE; |
