blob: 548591a30a9fe8ff00a5eb7b756c02f7d83a1e99 [file] [log] [blame]
Johannes Berg82afaeb2008-04-02 17:40:05 +02001MAKEFLAGS += --no-print-directory
2
Robby Workman30345662008-11-19 12:57:36 +01003PREFIX ?= /usr
John W. Linville190f50c2009-09-30 09:19:46 -04004SBINDIR ?= $(PREFIX)/sbin
Robby Workman30345662008-11-19 12:57:36 +01005MANDIR ?= $(PREFIX)/share/man
Karl Hiramoto26ae7e42009-05-13 11:16:18 +02006PKG_CONFIG ?= pkg-config
Robby Workman30345662008-11-19 12:57:36 +01007
Kel Modderman848794e2008-09-17 11:04:33 +02008MKDIR ?= mkdir -p
Johannes Bergb0f79c42008-09-16 21:09:47 +02009INSTALL ?= install
Mike Kershaw7153dbf2007-09-29 11:05:35 -040010CC ?= "gcc"
Robby Workman30345662008-11-19 12:57:36 +010011
Robert Buchholze0738db2009-01-07 15:46:13 +010012CFLAGS ?= -O2 -g
Pat Erleydfd13ee2008-12-13 01:04:05 +010013CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
Johannes Bergcad53b32007-09-28 22:11:34 +020014
Johannes Bergfebeb0c2009-07-25 17:31:08 +020015OBJS = iw.o genl.o event.o info.o phy.o \
Rostislav Lisovy3955e522015-01-12 13:49:57 +010016 interface.o ibss.o station.o survey.o util.o ocb.o \
Henning Rogge4a73ea12014-09-12 08:59:43 +020017 mesh.o mpath.o mpp.o scan.o reg.o version.o \
Johannes Berg942b5cd2010-03-25 16:52:35 -050018 reason.o status.o connect.o link.o offch.o ps.o cqm.o \
Johannes Berg60dbfa82014-10-29 17:08:35 +010019 bitrate.o wowlan.o coalesce.o roc.o p2p.o vendor.o
Johannes Berg4698bfc2009-08-24 12:53:34 +020020OBJS += sections.o
Johannes Berga1b32582012-07-06 08:50:00 +020021
22OBJS-$(HWSIM) += hwsim.o
23
Johannes Bergbb1bc462013-04-23 15:28:50 +020024OBJS += $(OBJS-y) $(OBJS-Y)
25
Mike Kershaw7153dbf2007-09-29 11:05:35 -040026ALL = iw
Johannes Berg82afaeb2008-04-02 17:40:05 +020027
Johannes Bergd0f5db82013-04-23 15:32:27 +020028ifeq ($(NO_PKG_CONFIG),)
Gilles Espinasse9c1d7582011-11-12 00:04:38 +010029NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y)
Guido Trentalancia44394672012-06-03 01:46:45 +020030ifneq ($(NL3xFOUND),Y)
31NL31FOUND := $(shell $(PKG_CONFIG) --exact-version=3.1 libnl-3.1 && echo Y)
32ifneq ($(NL31FOUND),Y)
33NL3FOUND := $(shell $(PKG_CONFIG) --atleast-version=3 libnl-3.0 && echo Y)
34ifneq ($(NL3FOUND),Y)
35NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y)
36ifneq ($(NL2FOUND),Y)
37NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y)
38endif
39endif
40endif
41endif
Pat Erleydfd13ee2008-12-13 01:04:05 +010042
43ifeq ($(NL1FOUND),Y)
44NLLIBNAME = libnl-1
45endif
46
47ifeq ($(NL2FOUND),Y)
48CFLAGS += -DCONFIG_LIBNL20
49LIBS += -lnl-genl
50NLLIBNAME = libnl-2.0
51endif
52
Bjarke Istrup Pedersen57df6fd2011-11-14 11:12:19 +010053ifeq ($(NL3xFOUND),Y)
54# libnl 3.2 might be found as 3.2 and 3.0
55NL3FOUND = N
56CFLAGS += -DCONFIG_LIBNL30
57LIBS += -lnl-genl-3
58NLLIBNAME = libnl-3.0
59endif
60
Yegor Yefremovded667b2011-07-21 15:06:17 +000061ifeq ($(NL3FOUND),Y)
62CFLAGS += -DCONFIG_LIBNL30
Johannes Bergb72de672011-11-11 09:17:13 +010063LIBS += -lnl-genl
64NLLIBNAME = libnl-3.0
Yegor Yefremovded667b2011-07-21 15:06:17 +000065endif
66
Gilles Espinasse9c1d7582011-11-12 00:04:38 +010067# nl-3.1 has a broken libnl-gnl-3.1.pc file
68# as show by pkg-config --debug --libs --cflags --exact-version=3.1 libnl-genl-3.1;echo $?
69ifeq ($(NL31FOUND),Y)
70CFLAGS += -DCONFIG_LIBNL30
71LIBS += -lnl-genl
72NLLIBNAME = libnl-3.1
73endif
74
Pavel Roskin34b6e0f2009-01-30 17:33:34 -050075ifeq ($(NLLIBNAME),)
76$(error Cannot find development files for any supported version of libnl)
77endif
78
Johannes Stezenbachc7f53382009-11-10 18:29:34 +010079LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME))
80CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME))
Johannes Bergd0f5db82013-04-23 15:32:27 +020081endif # NO_PKG_CONFIG
Pat Erleydfd13ee2008-12-13 01:04:05 +010082
Johannes Berg888e1192008-04-02 17:51:02 +020083ifeq ($(V),1)
84Q=
85NQ=true
86else
87Q=@
88NQ=echo
89endif
90
Gilles Espinasse9c1d7582011-11-12 00:04:38 +010091all: $(ALL)
Johannes Bergd711f012008-09-16 21:56:25 +020092
Johannes Bergbb1bc462013-04-23 15:28:50 +020093VERSION_OBJS := $(filter-out version.o, $(OBJS))
Johannes Berg133b0692009-04-21 00:53:00 +020094
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
100%.o: %.c iw.h nl80211.h
Johannes Berg888e1192008-04-02 17:51:02 +0200101 @$(NQ) ' CC ' $@
Johannes Bergf9c714d2008-04-03 15:38:11 +0200102 $(Q)$(CC) $(CFLAGS) -c -o $@ $<
Johannes Berg888e1192008-04-02 17:51:02 +0200103
Arik Nemtsovf21da102015-01-06 12:48:45 +0200104ifeq ($(IW_ANDROID_BUILD),)
Johannes Bergbb1bc462013-04-23 15:28:50 +0200105iw: $(OBJS)
Johannes Berg888e1192008-04-02 17:51:02 +0200106 @$(NQ) ' CC ' iw
Johannes Bergbb1bc462013-04-23 15:28:50 +0200107 $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw
Arik Nemtsovf21da102015-01-06 12:48:45 +0200108endif
Johannes Bergcad53b32007-09-28 22:11:34 +0200109
Johannes Berg82afaeb2008-04-02 17:40:05 +0200110check:
Johannes Berg888e1192008-04-02 17:51:02 +0200111 $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc"
Johannes Berg82afaeb2008-04-02 17:40:05 +0200112
Johannes Bergb0f79c42008-09-16 21:09:47 +0200113%.gz: %
114 @$(NQ) ' GZIP' $<
115 $(Q)gzip < $< > $@
116
117install: iw iw.8.gz
118 @$(NQ) ' INST iw'
John W. Linville190f50c2009-09-30 09:19:46 -0400119 $(Q)$(MKDIR) $(DESTDIR)$(SBINDIR)
Luciano Coelho6dbddf12010-03-17 17:09:20 +0200120 $(Q)$(INSTALL) -m 755 iw $(DESTDIR)$(SBINDIR)
Johannes Bergb0f79c42008-09-16 21:09:47 +0200121 @$(NQ) ' INST iw.8'
Robby Workman30345662008-11-19 12:57:36 +0100122 $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/
Luciano Coelho6dbddf12010-03-17 17:09:20 +0200123 $(Q)$(INSTALL) -m 644 iw.8.gz $(DESTDIR)$(MANDIR)/man8/
Johannes Bergb0f79c42008-09-16 21:09:47 +0200124
Johannes Bergcad53b32007-09-28 22:11:34 +0200125clean:
Johannes Berg133b0692009-04-21 00:53:00 +0200126 $(Q)rm -f iw *.o *~ *.gz version.c *-stamp