]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
generate version.c instead of version.o
authorJohannes Berg <johannes@sipsolutions.net>
Mon, 20 Apr 2009 22:53:00 +0000 (00:53 +0200)
committerJohannes Berg <johannes@sipsolutions.net>
Mon, 20 Apr 2009 22:53:00 +0000 (00:53 +0200)
.gitignore
Makefile
iw.c
iw.h
version.sh

index f941d581c6a4f3072ba906aca05a5b4a8367ba8b..16bb88b0a6a2bb18301ce30c9372c871894bb3bc 100644 (file)
@@ -2,6 +2,6 @@ iw
 *~
 *.o
 .config
-version.h
+version.c
 iw.8.gz
 *-stamp
index 6ec41717290324a29722280ef2dbb6719e92ebc6..5fa09bfb41840b9edb430711d5e050312c503ce7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ CC ?= "gcc"
 CFLAGS ?= -O2 -g
 CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
 
-OBJS = iw.o genl.o info.o phy.o interface.o ibss.o station.o util.o mesh.o mpath.o scan.o reg.o
+OBJS = iw.o genl.o info.o phy.o interface.o ibss.o station.o util.o mesh.o mpath.o scan.o reg.o version.o
 ALL = iw
 
 NL1FOUND := $(shell pkg-config --atleast-version=1 libnl-1 && echo Y)
@@ -55,11 +55,15 @@ else
 endif
 endif
 
-version.h: version.sh *.c nl80211.h iw.h Makefile
-       @$(NQ) ' GEN  version.h'
-       $(Q)./version.sh
 
-%.o: %.c iw.h version.h nl80211.h
+VERSION_OBJS := $(filter-out version.o, $(OBJS))
+
+version.c: version.sh $(patsubst %.o,%.c,$(VERSION_OBJS)) nl80211.h iw.h Makefile \
+               $(wildcard .git/index .git/refs/tags)
+       @$(NQ) ' GEN ' $@
+       $(Q)./version.sh $@
+
+%.o: %.c iw.h nl80211.h
        @$(NQ) ' CC  ' $@
        $(Q)$(CC) $(CFLAGS) -c -o $@ $<
 
@@ -83,4 +87,4 @@ install: iw iw.8.gz
        $(Q)$(INSTALL) -m 644 -t $(DESTDIR)$(MANDIR)/man8/ iw.8.gz
 
 clean:
-       $(Q)rm -f iw *.o *~ *.gz version.h *-stamp
+       $(Q)rm -f iw *.o *~ *.gz version.c *-stamp
diff --git a/iw.c b/iw.c
index 8d587312a5c74fe2c9444383abe8e55d34f80555..56c5694e81bb0457834525410f154c578362720e 100644 (file)
--- a/iw.c
+++ b/iw.c
@@ -21,7 +21,6 @@
 
 #include "nl80211.h"
 #include "iw.h"
-#include "version.h"
 
 #ifndef CONFIG_LIBNL20
 /* libnl 2.0 compatibility code */
@@ -136,7 +135,7 @@ static void usage(const char *argv0)
 
 static void version(void)
 {
-       printf("iw version " IW_VERSION "\n");
+       printf("iw version %s\n", iw_version);
 }
 
 static int phy_lookup(char *name)
diff --git a/iw.h b/iw.h
index 76848fec32523e4d5b088765e11cec93b739661e..d0781255f27253459bdffb34d3e307e531299e0f 100644 (file)
--- a/iw.h
+++ b/iw.h
@@ -68,6 +68,7 @@ struct cmd {
 extern struct cmd __start___cmd;
 extern struct cmd __stop___cmd;
 
+extern const char iw_version[];
 
 int handle_cmd(struct nl80211_state *state, enum id_input idby,
               int argc, char **argv);
index e292408245f045ffd4334a2603036d4977a755fe..fb1dd9a4ebab3e65d67f346a67c12e4af98e349d 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 VERSION="0.9.12"
-OUT="version.h"
+OUT="$1"
 
 if head=`git rev-parse --verify HEAD 2>/dev/null`; then
        git update-index --refresh --unmerged > /dev/null
@@ -10,13 +10,14 @@ if head=`git rev-parse --verify HEAD 2>/dev/null`; then
        # on git builds check that the version number above
        # is correct...
        [ "${descr%%-*}" = "v$VERSION" ] || exit 2
-       
-       echo -n '#define IW_VERSION "' > "$OUT"
-       echo -n "${descr#v}" >> "$OUT"
+
+       echo -n 'const char iw_version[] = "' > "$OUT"
+       v="${descr#v}"
        if git diff-index --name-only HEAD | read dummy ; then
-               echo -n "-dirty" >> "$OUT"
+               v="$v"-dirty
        fi
-       echo '"' >> "$OUT"
 else
-echo "#define IW_VERSION \"$VERSION\"" > "$OUT"
+       v="$VERSION"
 fi
+
+echo "const char iw_version[] = \"$v\";" > "$OUT"