From 534f4be7e63e4fa101e91cdeeb7fdd8c8ff76662 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 19 Dec 2011 15:55:45 +0000 Subject: [PATCH] compile debian package version into all 3 components at build time --- daemon/Makefile | 14 ++++++-------- daemon/control.c | 3 +-- daemon/main.c | 3 +-- iptables-extension/Makefile | 5 ++++- iptables-extension/libxt_MEDIAPROXY.c | 5 +++-- kernel-module/Makefile | 1 + kernel-module/xt_MEDIAPROXY.c | 2 +- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/daemon/Makefile b/daemon/Makefile index f94b51bbd..e07287a69 100644 --- a/daemon/Makefile +++ b/daemon/Makefile @@ -6,6 +6,7 @@ CC= gcc CFLAGS= -g -Wall `pkg-config --cflags glib-2.0` `pcre-config --cflags` -fno-strict-aliasing CFLAGS+= -I/lib/modules/`uname -r`/build/include/ -I../kernel-module/ CFLAGS+= -D_GNU_SOURCE +CFLAGS+= -DMEDIAPROXY_VERSION="\"$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}')\"" ifeq ($(REDIS),yes) CFLAGS+= -I$(LIBREDISDIR) @@ -53,22 +54,19 @@ tests: dep: .depend clean: - rm -f $(OBJS) mediaproxy-ng aux-test poller-test aux-test.o poller-test.o .depend build_time.h core + rm -f $(OBJS) mediaproxy-ng aux-test poller-test aux-test.o poller-test.o .depend core $(MAKE) -C $(LIBREDISDIR) clean -.depend: $(SRCS) Makefile build_time.h +.depend: $(SRCS) Makefile $(CC) $(CFLAGS) -M $(SRCS) | sed -e 's/:/ .depend:/' > .depend -build_time.h: $(SRCS) Makefile - echo "#define BUILD_TIME \"$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}')\"" > build_time.h - -mediaproxy-ng: $(OBJS) .depend build_time.h +mediaproxy-ng: $(OBJS) .depend $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) -aux-test: aux.o aux-test.o .depend build_time.h +aux-test: aux.o aux-test.o .depend $(CC) $(CFLAGS) -o $@ aux-test.o aux.o $(LDFLAGS) -poller-test: poller.o poller-test.o aux.o .depend build_time.h +poller-test: poller.o poller-test.o aux.o .depend $(CC) $(CFLAGS) -o $@ poller-test.o poller.o aux.o $(LDFLAGS) diff --git a/daemon/control.c b/daemon/control.c index 9d408fd27..614862c24 100644 --- a/daemon/control.c +++ b/daemon/control.c @@ -10,7 +10,6 @@ #include "aux.h" #include "streambuf.h" #include "log.h" -#include "build_time.h" #include "call.h" @@ -88,7 +87,7 @@ static int control_stream_parse(struct control_stream *s, char *line) { else if (!strcmp(out[14], "status")) calls_status(c->callmaster, s); else if (!strcmp(out[14], "build") | !strcmp(out[14], "version")) - streambuf_printf(s->outbuf, "Build: %s\n", BUILD_TIME); + streambuf_printf(s->outbuf, "Version: %s\n", MEDIAPROXY_VERSION); else if (!strcmp(out[14], "controls")) control_list(c, s); else if (!strcmp(out[14], "quit") || !strcmp(out[14], "exit")) diff --git a/daemon/main.c b/daemon/main.c index d125fbbfa..62e96d152 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -17,7 +17,6 @@ #ifndef NO_REDIS #include "redis.h" #endif -#include "build_time.h" @@ -185,7 +184,7 @@ static void options(int *argc, char ***argv) { die("Bad command line: %s\n", er->message); if (version) - die("Build time: %s\n", BUILD_TIME); + die("%s\n", MEDIAPROXY_VERSION); if (!ipv4s) die("Missing option --ip\n"); diff --git a/iptables-extension/Makefile b/iptables-extension/Makefile index 05ef9a25d..7400ec4bf 100644 --- a/iptables-extension/Makefile +++ b/iptables-extension/Makefile @@ -1,9 +1,12 @@ +CFLAGS = -O2 -Wall -shared -fPIC +CFLAGS += -DMEDIAPROXY_VERSION="\"$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}')\"" + .PHONY: all clean all: libxt_MEDIAPROXY.so libxt_MEDIAPROXY.so: libxt_MEDIAPROXY.c - gcc -O2 -Wall -shared -fPIC -o libxt_MEDIAPROXY.so libxt_MEDIAPROXY.c + gcc $(CFLAGS) -o libxt_MEDIAPROXY.so libxt_MEDIAPROXY.c clean: rm -f libxt_MEDIAPROXY.so diff --git a/iptables-extension/libxt_MEDIAPROXY.c b/iptables-extension/libxt_MEDIAPROXY.c index f0f7179cb..e40eae69a 100644 --- a/iptables-extension/libxt_MEDIAPROXY.c +++ b/iptables-extension/libxt_MEDIAPROXY.c @@ -12,9 +12,10 @@ static void help(void) { printf( - "MEDIAPROXY target options:\n" + "MEDIAPROXY (version %s) target options:\n" " --id \n" - " Unique ID for this instance\n" + " Unique ID for this instance\n", + MEDIAPROXY_VERSION ); } diff --git a/kernel-module/Makefile b/kernel-module/Makefile index fed302a02..9a757e163 100644 --- a/kernel-module/Makefile +++ b/kernel-module/Makefile @@ -1,6 +1,7 @@ PWD := $(shell pwd) KSRC ?= /lib/modules/$(shell uname -r)/build KBUILD := $(KSRC) +EXTRA_CFLAGS += -DMEDIAPROXY_VERSION="\"$(shell dpkg-parsechangelog -l$(M)/../debian/changelog | awk '/^Version: / {print $$2}')\"" obj-m += xt_MEDIAPROXY.o diff --git a/kernel-module/xt_MEDIAPROXY.c b/kernel-module/xt_MEDIAPROXY.c index 2c511bcb4..78f5a614f 100644 --- a/kernel-module/xt_MEDIAPROXY.c +++ b/kernel-module/xt_MEDIAPROXY.c @@ -1370,7 +1370,7 @@ static struct xt_target xt_mediaproxy_regs[] = { static int __init init(void) { int ret; - printk(KERN_NOTICE "Registering xt_MEDIAPROXY module\n"); + printk(KERN_NOTICE "Registering xt_MEDIAPROXY module - version %s\n", MEDIAPROXY_VERSION); rwlock_init(&table_lock);