Skip to content

Commit

Permalink
build-sys: make version number to update at each commit
Browse files Browse the repository at this point in the history
This make version number to be based on git tag.  In same go get rid of
SNAPSHOT.h in favour of config.h that most of developers expect to see, and
make these build system generated headers to be included automatically via
-include compiler option so that each file is guaranteed to get them as a
first include.

Signed-off-by: Sami Kerola <[email protected]>
  • Loading branch information
kerolasa committed Oct 3, 2018
1 parent 0213779 commit fb14ff3
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 33 deletions.
4 changes: 1 addition & 3 deletions arping.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
* YOSHIFUJI Hideaki <[email protected]>
*/

#include "SNAPSHOT.h"

#include <stdlib.h>
#include <time.h>
#include <signal.h>
Expand Down Expand Up @@ -1041,7 +1039,7 @@ main(int argc, char **argv)
source = optarg;
break;
case 'V':
printf("arping utility, iputils-%s\n", SNAPSHOT);
printf(IPUTILS_VERSION("arping"));
exit(0);
case 'h':
case '?':
Expand Down
2 changes: 2 additions & 0 deletions git-version.h.meson
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define PACKAGE_VERSION "@VCS_TAG@"
#define IPUTILS_VERSION(_prog) "%s from %s %s\n", _prog, PACKAGE_NAME, PACKAGE_VERSION
33 changes: 22 additions & 11 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ project('iputils', 'c',
'c_std=c99',
'warning_level=2',
],
version : '20170717') # version hardcoded
version : 's20161105') # keep in sync with: git describe | awk -F- '{print $1}'

cc = meson.get_compiler('c')

add_project_arguments(
'-include', 'config.h',
'-include', 'git-version.h',
language : 'c'
)

conf = configuration_data()
conf.set_quoted('SNAPSHOT', meson.project_version())
conf.set_quoted('PACKAGE_NAME', meson.project_name())

if cc.compiles('''
#include <sys/types.h>
Expand Down Expand Up @@ -145,53 +151,58 @@ if build_ninfod == true
endif
endif

git_version_h = vcs_tag(
input : 'git-version.h.meson',
output : 'git-version.h'
)

config_h = configure_file(
output : 'SNAPSHOT.h',
output : 'config.h',
configuration : conf)

############################################################
if build_ping == true
executable('ping', ['ping.c', 'ping_common.c', 'ping6_common.c'],
executable('ping', ['ping.c', 'ping_common.c', 'ping6_common.c', git_version_h],
dependencies : [m_dep, cap_dep, idn_dep, crypto_dep, resolv_dep],
install: true)
endif

if build_tracepath == true
executable('tracepath', 'tracepath.c',
executable('tracepath', ['tracepath.c', git_version_h],
dependencies : idn_dep,
install: true)
endif

if build_traceroute6 == true
executable('traceroute6', 'traceroute6.c',
executable('traceroute6', ['traceroute6.c', git_version_h],
dependencies : [cap_dep, idn_dep],
install: true)
endif

if build_clockdiff == true
executable('clockdiff', 'clockdiff.c',
executable('clockdiff', ['clockdiff.c', git_version_h],
dependencies : [cap_dep],
install: true)
endif

if build_rinfod == true
executable('rdisc', 'rdisc.c',
executable('rdisc', ['rdisc.c', git_version_h],
install: true)
endif

if build_arping == true
executable('arping', 'arping.c',
executable('arping', ['arping.c', git_version_h],
dependencies : [rt_dep, cap_dep, idn_dep],
install: true)
endif

if build_tftpd == true
executable('tftpd', ['tftpd.c', 'tftpsubs.c'],
executable('tftpd', ['tftpd.c', 'tftpsubs.c', git_version_h],
install: true)
endif

if build_rarpd == true
executable('rarpd', 'rarpd.c',
executable('rarpd', ['rarpd.c', git_version_h],
install: true)
endif

Expand Down
2 changes: 1 addition & 1 deletion ninfod/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ninfod_sources = files('''
ninfod_name.c
'''.split())
gcrypt_dep = cc.find_library('gcrypt')
executable('ninfod', ninfod_sources,
executable('ninfod', [ninfod_sources, git_version_h],
dependencies : [cap_dep, gcrypt_dep, rt_dep, threads],
include_directories : inc,
install: true,
Expand Down
2 changes: 0 additions & 2 deletions ninfod/ni_ifaddrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
* SUCH DAMAGE.
*/

#include "SNAPSHOT.h"

#include <string.h>
#include <time.h>
#include <malloc.h>
Expand Down
2 changes: 0 additions & 2 deletions ninfod/ninfod.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
* YOSHIFUJI Hideaki <[email protected]>
*/

#include "SNAPSHOT.h"

#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
Expand Down
2 changes: 0 additions & 2 deletions ninfod/ninfod_addrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
* YOSHIFUJI Hideaki <[email protected]>
*/

#include "SNAPSHOT.h"

#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
Expand Down
2 changes: 0 additions & 2 deletions ninfod/ninfod_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
* YOSHIFUJI Hideaki <[email protected]>
*/

#include "SNAPSHOT.h"

#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
Expand Down
2 changes: 0 additions & 2 deletions ninfod/ninfod_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
* YOSHIFUJI Hideaki <[email protected]>
*/

#include "SNAPSHOT.h"

#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
Expand Down
2 changes: 1 addition & 1 deletion ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ main(int argc, char **argv)
options |= F_VERBOSE;
break;
case 'V':
printf("ping utility, iputils-%s\n", SNAPSHOT);
printf(IPUTILS_VERSION("ping"));
exit(0);
case 'w':
deadline = atoi(optarg);
Expand Down
1 change: 0 additions & 1 deletion ping.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
#include <linux/errqueue.h>

#include "in6_flowlabel.h"
#include "SNAPSHOT.h"

#ifndef SCOPE_DELIMITER
#define SCOPE_DELIMITER '%'
Expand Down
4 changes: 1 addition & 3 deletions rdisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
#include <string.h>
#include <syslog.h>

#include "SNAPSHOT.h"

struct interface
{
struct in_addr address; /* Used to identify the interface */
Expand Down Expand Up @@ -337,7 +335,7 @@ int main(int argc, char **argv)
forever = 1;
break;
case 'V':
printf("rdisc utility, iputils-%s\n", SNAPSHOT);
printf(IPUTILS_VERSION("rdisc"));
exit(0);
#ifdef RDISC_SERVER
case 'T':
Expand Down
4 changes: 1 addition & 3 deletions traceroute6.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,6 @@
#include <string.h>
#include <unistd.h>

#include "SNAPSHOT.h"

#ifndef SOL_IPV6
#define SOL_IPV6 IPPROTO_IPV6
#endif
Expand Down Expand Up @@ -428,7 +426,7 @@ int main(int argc, char *argv[])
}
break;
case 'V':
printf("traceroute6 utility, iputils-%s\n", SNAPSHOT);
printf(IPUTILS_VERSION("traceroute6"));
exit(0);
default:
usage();
Expand Down

0 comments on commit fb14ff3

Please sign in to comment.