all: $(ALL)
-%.o: %.c iw.h
+version.h: git-version.sh
+ @$(NQ) ' GEN version.h'
+ $(Q)./git-version.sh
+
+%.o: %.c iw.h version.h
@$(NQ) ' CC ' $@
$(Q)$(CC) $(CFLAGS) -c -o $@ $<
--- /dev/null
+#!/bin/sh
+
+(
+if head=`git rev-parse --verify HEAD 2>/dev/null`; then
+ git update-index --refresh --unmerged > /dev/null
+ printf "#define IW_GIT_VERSION \"-g%.8s" "$head"
+ if git diff-index --name-only HEAD | read dummy ; then
+ printf -- "-dirty"
+ fi
+ echo '"'
+else
+ echo '#define IW_GIT_VERSION ""'
+fi
+) > version.h
#include <linux/nl80211.h>
#include "iw.h"
+#include "version.h"
int debug = 0;
fprintf(stderr, "Usage:\t%s [options] command\n", argv0);
fprintf(stderr, "Options:\n");
- fprintf(stderr, "\t--debug\tenable netlink debugging\n");
+ fprintf(stderr, "\t--debug\t\tenable netlink debugging\n");
+ fprintf(stderr, "\t--version\tshow version\n");
fprintf(stderr, "Commands:\n");
for (cmd = &__start___cmd; cmd < &__stop___cmd; cmd++) {
switch (cmd->idby) {
}
}
+static void version(void)
+{
+ printf("iw version " VERSION IW_GIT_VERSION "\n");
+}
+
static int phy_lookup(char *name)
{
char buf[200];
argv++;
}
+ if (argc > 0 && strcmp(*argv, "--version") == 0) {
+ version();
+ return 0;
+ }
+
if (argc == 0 || strcmp(*argv, "help") == 0) {
usage(argv0);
goto out;