diff --git a/Makefile b/Makefile index ac27f32..2e32eb3 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,14 @@ # PROG= nsh +.PHONY: release dist + +.include "nsh-version.mk" + +.if ${NSH_RELEASE} != Yes +DEBUG?=-O0 -g +.endif + .if make(install) DESTDIR?=/usr/local BINDIR?=/bin @@ -11,6 +19,7 @@ MANDIR?=/man/man #CFLAGS=-O -DDHCPLEASES=\"/flash/dhcpd.leases\" -Wmissing-prototypes -Wformat -Wall -Wpointer-arith -Wbad-function-cast #-W CFLAGS?=-O CFLAGS+=-Wmissing-prototypes -Wformat -Wall -Wbad-function-cast -I/usr/local/include #-W -Wpointer-arith +CPPFLAGS+=-DNSH_VERSION=${NSH_VERSION} SRCS=arp.c compile.c main.c genget.c commands.c stats.c kroute.c SRCS+=ctl.c show.c if.c version.c route.c conf.c complete.c ieee80211.c @@ -25,4 +34,22 @@ MAN=nsh.8 compile.c: compile.sh sh ${.CURDIR}/compile.sh +release: clean + sed -i -e "s/_RELEASE=No/_RELEASE=Yes/" ${.CURDIR}/nsh-version.mk + ${MAKE} -C ${.CURDIR} dist + sed -i -e "s/_RELEASE=Yes/_RELEASE=No/" ${.CURDIR}/nsh-version.mk + +dist: clean + mkdir /tmp/nsh-${NSH_VERSION} + (cd ${.CURDIR} && pax -rw * /tmp/nsh-${NSH_VERSION}) + find /tmp/nsh-${NSH_VERSION} -name obj -type d -delete + rm /tmp/nsh-${NSH_VERSION}/nsh-dist.txt + tar -C /tmp -zcf ${.CURDIR}/nsh-${NSH_VERSION}.tar.gz nsh-${NSH_VERSION} + rm -rf /tmp/nsh-${NSH_VERSION} + tar -ztf ${.CURDIR}/nsh-${NSH_VERSION}.tar.gz | \ + sed -e 's/^nsh-${NSH_VERSION}//' | \ + sort > ${.CURDIR}/nsh-dist.txt.new + diff -u ${.CURDIR}/nsh-dist.txt ${.CURDIR}/nsh-dist.txt.new + rm ${.CURDIR}/nsh-dist.txt.new + .include diff --git a/externs.h b/externs.h index cc6533d..75755d4 100644 --- a/externs.h +++ b/externs.h @@ -2,6 +2,15 @@ * nsh externs, prototypes and macros */ +#ifndef NSH_VERSION +#error "NSH_VERSION is undefined" +#endif + +#define NSH_STRINGIFY_VERSION(x) #x +#define NSH_STRINGVAL_VERSION(x) NSH_STRINGIFY_VERSION(x) + +#define NSH_VERSION_STR NSH_STRINGVAL_VERSION(NSH_VERSION) + #define NO_ARG(x) (strcasecmp(x, "no") == 0) /* absolute "no" */ #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) /* sys/param.h */ diff --git a/main.c b/main.c index afe1459..5b1c31e 100644 --- a/main.c +++ b/main.c @@ -35,7 +35,7 @@ void usage(void); jmp_buf toplevel; -char *vers = "1.1"; +char *vers = NSH_VERSION_STR; int bridge = 0; /* bridge mode for interface() */ int verbose = 0; /* verbose mode */ int priv = 0, cli_rtable = 0; diff --git a/nsh-dist.txt b/nsh-dist.txt new file mode 100644 index 0000000..c6ecde6 --- /dev/null +++ b/nsh-dist.txt @@ -0,0 +1,65 @@ + +/COPYRIGHT +/MANUAL +/Makefile +/README +/TODO +/arp.c +/bridge.c +/bridge.h +/carp.c +/commands.c +/commands.h +/compile.sh +/complete.c +/conf.c +/ctl.c +/ctl.h +/editing.h +/externs.h +/genget.c +/ieee80211.c +/if.c +/ip.h +/kroute.c +/main.c +/media.c +/more.c +/nameserver.c +/ndp.c +/nopt.c +/nsh-scripts +/nsh-scripts/bin +/nsh-scripts/bin/enable-sshd.nshrc +/nsh-scripts/bin/initial-config.nshrc +/nsh-scripts/bin/mg-env-settings +/nsh-scripts/bin/nsh +/nsh-scripts/bin/nsh-openbsd-integration.sh +/nsh-scripts/bin/write-config.nshrc +/nsh-version.mk +/nsh.8 +/nwrapper.c +/passwd.c +/pflow.c +/pfsync.c +/ppp.c +/route.c +/save-ro.sh +/save-rw.sh +/show.c +/sqlite3.c +/stats.c +/stringlist.c +/stringlist.h +/sysctl.c +/sysctl.h +/test +/test/basic-show-run.nshrc +/test/broken-commands.nshrc +/trunk.c +/tunnel.c +/umb.c +/utils.c +/version.c +/wg.c +/who.c diff --git a/nsh-version.mk b/nsh-version.mk new file mode 100644 index 0000000..e4340eb --- /dev/null +++ b/nsh-version.mk @@ -0,0 +1,12 @@ +# NSH_RELEASE is only set to "Yes" in a release tarball +NSH_RELEASE=No + +# Version number of the next upcoming release. +# Should be cranked immediately after publishing a release. +NSH_VERSION_NUMBER=1.2 + +.if ${NSH_RELEASE} == Yes +NSH_VERSION=${NSH_VERSION_NUMBER} +.else +NSH_VERSION=${NSH_VERSION_NUMBER}-current +.endif