From c1e4315f297b92444d7aa0547108810d6ac445df Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Wed, 25 Apr 2012 08:14:19 +0200 Subject: [PATCH] change build so it works with GIT instead of SVN --- Makefile | 28 ++++++++++++++++++++++------ client.c | 6 +++--- common.h | 2 +- configure | 37 +++++++++++++++++++++++++++++++++++++ server.c | 6 +++--- 5 files changed, 66 insertions(+), 13 deletions(-) create mode 100755 configure diff --git a/Makefile b/Makefile index 8a3c634..92ce584 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ #set this if you want a debugable version CFLAGS=-Wall -g +LDFLAGS= #or alternatively this if you want a release build #CFLAGS=-O2 @@ -12,9 +13,13 @@ CFLAGS=-Wall -g #set this if you want allocation errors to end the process CFLAGS += -DALLOCPANIC=1 +#C++ flags, normally this is identical to CFLAGS +CXXFLAGS=$(CFLAGS) + #compiler and linker to use CC=gcc -LD=gcc +CXX=g++ +LD=g++ #end of options ##################### @@ -32,6 +37,9 @@ tdhcpd: server.o $(COMMON) %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< +%.o: %.cpp + $(CXX) $(CXXFLAGS) -c -o $@ $< + clean: rm -rf *~ *.o core* svnrev.h @@ -40,14 +48,22 @@ distclean: clean deps: rm -f .deps - for i in *.c ; do $(CC) -MM -MG $$i >>.deps ; done + for i in *.c; do $(CC) -MM -MG $$i >>.deps ; done + for i in *.cpp; do $(CXX) -MM -MG $$i >>.deps ; done -client.o server.o: svnrev.h -svnrev.h: $(shell ls *.c *.h|grep -v svnrev) - echo "/*Autogenerated File*/" >$@ - echo "#define SVNREV \"`svn info .|grep Revision:|cut -c 11-`\"" >>$@ +client.o server.o: gitrev.h +gitrev.h .gitrev: $(shell ls *.c *.h|grep -v gitrev) + echo "/*Autogenerated File*/" >gitrev.h + echo "#define GITDATE \"`git log -1 --date=short --pretty=format:%ad`\"" >>gitrev.h + echo "#define GITHASH \"`git log -1 --pretty=format:%H`\"" >>gitrev.h + git log -1 --date=short --pretty=format:%ad_%h | tr -d - |tr _ - >.gitrev + echo "#define GITREV \"`cat .gitrev`\"" >>gitrev.h include .deps +include .config.make + +.config.make: + ./configure #make empty deps file for non-developers .deps: diff --git a/client.c b/client.c index 47276f2..7e23471 100644 --- a/client.c +++ b/client.c @@ -43,11 +43,11 @@ struct option longopt[]= { {0,0,0,0} }; -#include "svnrev.h" +#include "gitrev.h" #define HELP \ "Usage: %s [options] device script\n" \ - "TDHCPc - Tunnel/Tiny DHCP client, revision " SVNREV "\n"\ - "(c) Konrad Rosenbaum, 2009\n"\ + "TDHCPc - Tunnel/Tiny DHCP client, revision " GITREV "\n"\ + "(c) Konrad Rosenbaum, 2009, 2012\n"\ "this program is protected under the GNU GPLv3 or at your option any newer\n"\ "\n"\ "TDHCP client parameters:\n"\ diff --git a/common.h b/common.h index c67b9b9..a521dd7 100644 --- a/common.h +++ b/common.h @@ -13,7 +13,7 @@ #ifndef TDHCP_COMMON_H #define TDHCP_COMMON_H -/*enterprise number*/ +/*enterprise number used for generating DUIDs*/ extern const unsigned long PEN; /*side ID, allocated in server.c (as 0x00) and client.c (as 0x01) respectively*/ diff --git a/configure b/configure new file mode 100755 index 0000000..01884a5 --- /dev/null +++ b/configure @@ -0,0 +1,37 @@ +#!/bin/bash + +echo $* + +bindir=/bin +mandir=/share/man +prefix=/usr/local +docdir=/share/doc/ip6calc + +TEMP=$(getopt -l prefix: -l mandir: -l bindir: -- "" "$@" 2>/dev/null ) + +eval set -- "$TEMP" +while true ; do + case "$1" in + --prefix) prefix=$2 ; shift 2 ;; + --mandir) mandir=$2 ; shift 2 ;; + --bindir) bindir=$2 ; shift 2 ;; + --docdir) docdir=$2 ; shift 2 ;; + --) break ;; + *) shift ;; + esac +done + +echo "Configuration for ip6calc:" +echo " PREFIX: $prefix" +echo " Binaries: $prefix$bindir" +echo " Man Pages: $prefix$mandir" +echo " Documentation: $prefix$docdir" + +CM=.config.make +echo '#generated file' >$CM +echo "PREFIX=$prefix" >>$CM +echo "BINDIR=$prefix$bindir" >>$CM +echo "MANDIR=$prefix$mandir" >>$CM +echo "DOCDIR=$prefix$docdir" >>$CM + +exit 0 \ No newline at end of file diff --git a/server.c b/server.c index 0e72a9b..4d6ebf3 100644 --- a/server.c +++ b/server.c @@ -45,11 +45,11 @@ struct option longopt[]= { {0,0,0,0} }; -#include "svnrev.h" +#include "gitrev.h" #define HELP \ "Usage: %s [options] device\n" \ - "TDHCPc - Tunnel/Tiny DHCP server, revision " SVNREV "\n"\ - "(c) Konrad Rosenbaum, 2009\n"\ + "TDHCPc - Tunnel/Tiny DHCP server, revision " GITREV "\n"\ + "(c) Konrad Rosenbaum, 2009, 2012\n"\ "this program is protected under the GNU GPLv3 or at your option any newer\n"\ "\n"\ "TDHCP server parameters:\n"\ -- 1.7.2.5