]> git.ipfire.org Git - thirdparty/iw.git/blob - Makefile
print nicer auth/assoc/deauth/disassoc events
[thirdparty/iw.git] / Makefile
1 -include .config
2
3 MAKEFLAGS += --no-print-directory
4
5 PREFIX ?= /usr
6 BINDIR ?= $(PREFIX)/bin
7 MANDIR ?= $(PREFIX)/share/man
8
9 MKDIR ?= mkdir -p
10 INSTALL ?= install
11 CC ?= "gcc"
12
13 CFLAGS ?= -O2 -g
14 CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
15
16 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 reason.o
17 ALL = iw
18
19 NL1FOUND := $(shell pkg-config --atleast-version=1 libnl-1 && echo Y)
20 NL2FOUND := $(shell pkg-config --atleast-version=2 libnl-2.0 && echo Y)
21
22 ifeq ($(NL1FOUND),Y)
23 NLLIBNAME = libnl-1
24 endif
25
26 ifeq ($(NL2FOUND),Y)
27 CFLAGS += -DCONFIG_LIBNL20
28 LIBS += -lnl-genl
29 NLLIBNAME = libnl-2.0
30 endif
31
32 ifeq ($(NLLIBNAME),)
33 $(error Cannot find development files for any supported version of libnl)
34 endif
35
36 LIBS += $(shell pkg-config --libs $(NLLIBNAME))
37 CFLAGS += $(shell pkg-config --cflags $(NLLIBNAME))
38
39 ifeq ($(V),1)
40 Q=
41 NQ=true
42 else
43 Q=@
44 NQ=echo
45 endif
46
47 all: version_check $(ALL)
48
49 version_check:
50 ifeq ($(NL2FOUND),Y)
51 else
52 ifeq ($(NL1FOUND),Y)
53 else
54 $(error No libnl found)
55 endif
56 endif
57
58
59 VERSION_OBJS := $(filter-out version.o, $(OBJS))
60
61 version.c: version.sh $(patsubst %.o,%.c,$(VERSION_OBJS)) nl80211.h iw.h Makefile \
62 $(wildcard .git/index .git/refs/tags)
63 @$(NQ) ' GEN ' $@
64 $(Q)./version.sh $@
65
66 %.o: %.c iw.h nl80211.h
67 @$(NQ) ' CC ' $@
68 $(Q)$(CC) $(CFLAGS) -c -o $@ $<
69
70 iw: $(OBJS)
71 @$(NQ) ' CC ' iw
72 $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw
73
74 check:
75 $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc"
76
77 %.gz: %
78 @$(NQ) ' GZIP' $<
79 $(Q)gzip < $< > $@
80
81 install: iw iw.8.gz
82 @$(NQ) ' INST iw'
83 $(Q)$(MKDIR) $(DESTDIR)$(BINDIR)
84 $(Q)$(INSTALL) -m 755 -t $(DESTDIR)$(BINDIR) iw
85 @$(NQ) ' INST iw.8'
86 $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/
87 $(Q)$(INSTALL) -m 644 -t $(DESTDIR)$(MANDIR)/man8/ iw.8.gz
88
89 clean:
90 $(Q)rm -f iw *.o *~ *.gz version.c *-stamp