]>
Commit | Line | Data |
---|---|---|
82afaeb7 JB |
1 | MAKEFLAGS += --no-print-directory |
2 | ||
30345664 | 3 | PREFIX ?= /usr |
190f50c0 | 4 | SBINDIR ?= $(PREFIX)/sbin |
30345664 | 5 | MANDIR ?= $(PREFIX)/share/man |
26ae7e4e | 6 | PKG_CONFIG ?= pkg-config |
30345664 | 7 | |
848794ec | 8 | MKDIR ?= mkdir -p |
b0f79c45 | 9 | INSTALL ?= install |
7153dbf3 | 10 | CC ?= "gcc" |
30345664 | 11 | |
6439859e JB |
12 | cc-option = $(shell set -e ; $(CC) $(1) -c -x c /dev/null -o /dev/null >/dev/null 2>&1 && echo '$(1)') |
13 | ||
14 | CFLAGS_EVAL := $(call cc-option,-Wstringop-overflow=4) | |
15 | ||
e0738dbb | 16 | CFLAGS ?= -O2 -g |
7d8fcdc8 JB |
17 | CFLAGS += -Wall -Wextra -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common |
18 | CFLAGS += -Werror-implicit-function-declaration -Wsign-compare -Wno-unused-parameter | |
19 | CFLAGS += -Wdeclaration-after-statement | |
73231dd0 | 20 | CFLAGS += -D__SANE_USERSPACE_TYPES__ |
7d8fcdc8 | 21 | CFLAGS += $(CFLAGS_EVAL) |
44686ac3 | 22 | CFLAGS += $(EXTRA_CFLAGS) |
cad53b3f | 23 | |
35a458a5 JB |
24 | _OBJS := $(sort $(patsubst %.c,%.o,$(wildcard *.c))) |
25 | VERSION_OBJS := $(filter-out version.o, $(_OBJS)) | |
26 | OBJS := $(VERSION_OBJS) version.o | |
bb1bc463 | 27 | |
7153dbf3 | 28 | ALL = iw |
82afaeb7 | 29 | |
d0f5db86 | 30 | ifeq ($(NO_PKG_CONFIG),) |
9c1d7581 | 31 | NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y) |
4439467e GT |
32 | ifneq ($(NL3xFOUND),Y) |
33 | NL31FOUND := $(shell $(PKG_CONFIG) --exact-version=3.1 libnl-3.1 && echo Y) | |
34 | ifneq ($(NL31FOUND),Y) | |
35 | NL3FOUND := $(shell $(PKG_CONFIG) --atleast-version=3 libnl-3.0 && echo Y) | |
36 | ifneq ($(NL3FOUND),Y) | |
37 | NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y) | |
38 | ifneq ($(NL2FOUND),Y) | |
39 | NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y) | |
40 | endif | |
41 | endif | |
42 | endif | |
43 | endif | |
dfd13ee5 PE |
44 | |
45 | ifeq ($(NL1FOUND),Y) | |
46 | NLLIBNAME = libnl-1 | |
47 | endif | |
48 | ||
49 | ifeq ($(NL2FOUND),Y) | |
1325244b JB |
50 | override CFLAGS += -DCONFIG_LIBNL20 |
51 | override LIBS += -lnl-genl | |
dfd13ee5 PE |
52 | NLLIBNAME = libnl-2.0 |
53 | endif | |
54 | ||
57df6fdf BIP |
55 | ifeq ($(NL3xFOUND),Y) |
56 | # libnl 3.2 might be found as 3.2 and 3.0 | |
57 | NL3FOUND = N | |
1325244b JB |
58 | override CFLAGS += -DCONFIG_LIBNL30 |
59 | override LIBS += -lnl-genl-3 | |
57df6fdf BIP |
60 | NLLIBNAME = libnl-3.0 |
61 | endif | |
62 | ||
ded667b0 | 63 | ifeq ($(NL3FOUND),Y) |
1325244b JB |
64 | override CFLAGS += -DCONFIG_LIBNL30 |
65 | override LIBS += -lnl-genl | |
b72de677 | 66 | NLLIBNAME = libnl-3.0 |
ded667b0 YY |
67 | endif |
68 | ||
9c1d7581 GE |
69 | # nl-3.1 has a broken libnl-gnl-3.1.pc file |
70 | # as show by pkg-config --debug --libs --cflags --exact-version=3.1 libnl-genl-3.1;echo $? | |
71 | ifeq ($(NL31FOUND),Y) | |
1325244b JB |
72 | override CFLAGS += -DCONFIG_LIBNL30 |
73 | override LIBS += -lnl-genl | |
9c1d7581 GE |
74 | NLLIBNAME = libnl-3.1 |
75 | endif | |
76 | ||
34b6e0f5 PR |
77 | ifeq ($(NLLIBNAME),) |
78 | $(error Cannot find development files for any supported version of libnl) | |
79 | endif | |
80 | ||
1325244b JB |
81 | override LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME)) |
82 | override CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME)) | |
d0f5db86 | 83 | endif # NO_PKG_CONFIG |
dfd13ee5 | 84 | |
888e1192 JB |
85 | ifeq ($(V),1) |
86 | Q= | |
87 | NQ=true | |
88 | else | |
89 | Q=@ | |
90 | NQ=echo | |
91 | endif | |
92 | ||
9c1d7581 | 93 | all: $(ALL) |
d711f013 | 94 | |
133b069f JB |
95 | version.c: version.sh $(patsubst %.o,%.c,$(VERSION_OBJS)) nl80211.h iw.h Makefile \ |
96 | $(wildcard .git/index .git/refs/tags) | |
97 | @$(NQ) ' GEN ' $@ | |
98 | $(Q)./version.sh $@ | |
99 | ||
dc1f3fe8 JB |
100 | nl80211-commands.inc: nl80211.h |
101 | @$(NQ) ' GEN ' $@ | |
102 | $(Q)sed 's%^\tNL80211_CMD_%%;t n;d;:n s%^\([^=]*\),.*%\t[NL80211_CMD_\1] = \"\L\1\",%;t;d' nl80211.h | grep -v "reserved" > $@ | |
103 | ||
104 | %.o: %.c iw.h nl80211.h nl80211-commands.inc | |
888e1192 | 105 | @$(NQ) ' CC ' $@ |
02bc7751 | 106 | $(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< |
888e1192 | 107 | |
f21da10f | 108 | ifeq ($(IW_ANDROID_BUILD),) |
bb1bc463 | 109 | iw: $(OBJS) |
888e1192 | 110 | @$(NQ) ' CC ' iw |
bb1bc463 | 111 | $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw |
f21da10f | 112 | endif |
cad53b3f | 113 | |
82afaeb7 | 114 | check: |
888e1192 | 115 | $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc" |
82afaeb7 | 116 | |
b0f79c45 JB |
117 | %.gz: % |
118 | @$(NQ) ' GZIP' $< | |
119 | $(Q)gzip < $< > $@ | |
120 | ||
121 | install: iw iw.8.gz | |
122 | @$(NQ) ' INST iw' | |
190f50c0 | 123 | $(Q)$(MKDIR) $(DESTDIR)$(SBINDIR) |
6dbddf13 | 124 | $(Q)$(INSTALL) -m 755 iw $(DESTDIR)$(SBINDIR) |
b0f79c45 | 125 | @$(NQ) ' INST iw.8' |
30345664 | 126 | $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/ |
6dbddf13 | 127 | $(Q)$(INSTALL) -m 644 iw.8.gz $(DESTDIR)$(MANDIR)/man8/ |
b0f79c45 | 128 | |
cad53b3f | 129 | clean: |
dc1f3fe8 | 130 | $(Q)rm -f iw *.o *~ *.gz version.c *-stamp nl80211-commands.inc |