*~
*.o
.config
-version.h
+version.c
iw.8.gz
*-stamp
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)
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 $@ $<
$(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
#include "nl80211.h"
#include "iw.h"
-#include "version.h"
#ifndef CONFIG_LIBNL20
/* libnl 2.0 compatibility code */
static void version(void)
{
- printf("iw version " IW_VERSION "\n");
+ printf("iw version %s\n", iw_version);
}
static int phy_lookup(char *name)
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);
#!/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
# 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"