]> git.ipfire.org Git - thirdparty/iw.git/blame - Makefile
update nl80211.h
[thirdparty/iw.git] / Makefile
CommitLineData
82afaeb7
JB
1MAKEFLAGS += --no-print-directory
2
30345664 3PREFIX ?= /usr
190f50c0 4SBINDIR ?= $(PREFIX)/sbin
30345664 5MANDIR ?= $(PREFIX)/share/man
26ae7e4e 6PKG_CONFIG ?= pkg-config
30345664 7
848794ec 8MKDIR ?= mkdir -p
b0f79c45 9INSTALL ?= install
7153dbf3 10CC ?= "gcc"
30345664 11
6439859e
JB
12cc-option = $(shell set -e ; $(CC) $(1) -c -x c /dev/null -o /dev/null >/dev/null 2>&1 && echo '$(1)')
13
14CFLAGS_EVAL := $(call cc-option,-Wstringop-overflow=4)
15
e0738dbb 16CFLAGS ?= -O2 -g
7d8fcdc8
JB
17CFLAGS += -Wall -Wextra -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common
18CFLAGS += -Werror-implicit-function-declaration -Wsign-compare -Wno-unused-parameter
19CFLAGS += -Wdeclaration-after-statement
73231dd0 20CFLAGS += -D__SANE_USERSPACE_TYPES__
7d8fcdc8 21CFLAGS += $(CFLAGS_EVAL)
44686ac3 22CFLAGS += $(EXTRA_CFLAGS)
cad53b3f 23
35a458a5
JB
24_OBJS := $(sort $(patsubst %.c,%.o,$(wildcard *.c)))
25VERSION_OBJS := $(filter-out version.o, $(_OBJS))
26OBJS := $(VERSION_OBJS) version.o
bb1bc463 27
7153dbf3 28ALL = iw
82afaeb7 29
d0f5db86 30ifeq ($(NO_PKG_CONFIG),)
9c1d7581 31NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y)
4439467e
GT
32ifneq ($(NL3xFOUND),Y)
33NL31FOUND := $(shell $(PKG_CONFIG) --exact-version=3.1 libnl-3.1 && echo Y)
34ifneq ($(NL31FOUND),Y)
35NL3FOUND := $(shell $(PKG_CONFIG) --atleast-version=3 libnl-3.0 && echo Y)
36ifneq ($(NL3FOUND),Y)
37NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y)
38ifneq ($(NL2FOUND),Y)
39NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y)
40endif
41endif
42endif
43endif
dfd13ee5
PE
44
45ifeq ($(NL1FOUND),Y)
46NLLIBNAME = libnl-1
47endif
48
49ifeq ($(NL2FOUND),Y)
1325244b
JB
50override CFLAGS += -DCONFIG_LIBNL20
51override LIBS += -lnl-genl
dfd13ee5
PE
52NLLIBNAME = libnl-2.0
53endif
54
57df6fdf
BIP
55ifeq ($(NL3xFOUND),Y)
56# libnl 3.2 might be found as 3.2 and 3.0
57NL3FOUND = N
1325244b
JB
58override CFLAGS += -DCONFIG_LIBNL30
59override LIBS += -lnl-genl-3
57df6fdf
BIP
60NLLIBNAME = libnl-3.0
61endif
62
ded667b0 63ifeq ($(NL3FOUND),Y)
1325244b
JB
64override CFLAGS += -DCONFIG_LIBNL30
65override LIBS += -lnl-genl
b72de677 66NLLIBNAME = libnl-3.0
ded667b0
YY
67endif
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 $?
71ifeq ($(NL31FOUND),Y)
1325244b
JB
72override CFLAGS += -DCONFIG_LIBNL30
73override LIBS += -lnl-genl
9c1d7581
GE
74NLLIBNAME = libnl-3.1
75endif
76
34b6e0f5
PR
77ifeq ($(NLLIBNAME),)
78$(error Cannot find development files for any supported version of libnl)
79endif
80
1325244b
JB
81override LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME))
82override CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME))
d0f5db86 83endif # NO_PKG_CONFIG
dfd13ee5 84
888e1192
JB
85ifeq ($(V),1)
86Q=
87NQ=true
88else
89Q=@
90NQ=echo
91endif
92
9c1d7581 93all: $(ALL)
d711f013 94
133b069f
JB
95version.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
100nl80211-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 108ifeq ($(IW_ANDROID_BUILD),)
bb1bc463 109iw: $(OBJS)
888e1192 110 @$(NQ) ' CC ' iw
bb1bc463 111 $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw
f21da10f 112endif
cad53b3f 113
82afaeb7 114check:
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
121install: 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 129clean:
dc1f3fe8 130 $(Q)rm -f iw *.o *~ *.gz version.c *-stamp nl80211-commands.inc