blob: 6cad858f3b8b1cd6a1941c3a1059bc8b127a741e [file] [log] [blame]
Mike Kershaw7153dbf2007-09-29 11:05:35 -04001-include .config
Johannes Bergcad53b32007-09-28 22:11:34 +02002
Johannes Berg82afaeb2008-04-02 17:40:05 +02003MAKEFLAGS += --no-print-directory
4
Robby Workman30345662008-11-19 12:57:36 +01005PREFIX ?= /usr
John W. Linville190f50c2009-09-30 09:19:46 -04006SBINDIR ?= $(PREFIX)/sbin
Robby Workman30345662008-11-19 12:57:36 +01007MANDIR ?= $(PREFIX)/share/man
Karl Hiramoto26ae7e42009-05-13 11:16:18 +02008PKG_CONFIG ?= pkg-config
Robby Workman30345662008-11-19 12:57:36 +01009
Kel Modderman848794e2008-09-17 11:04:33 +020010MKDIR ?= mkdir -p
Johannes Bergb0f79c42008-09-16 21:09:47 +020011INSTALL ?= install
Mike Kershaw7153dbf2007-09-29 11:05:35 -040012CC ?= "gcc"
Robby Workman30345662008-11-19 12:57:36 +010013
Robert Buchholze0738db2009-01-07 15:46:13 +010014CFLAGS ?= -O2 -g
Pat Erleydfd13ee2008-12-13 01:04:05 +010015CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
Johannes Bergcad53b32007-09-28 22:11:34 +020016
Johannes Bergfebeb0c2009-07-25 17:31:08 +020017OBJS = iw.o genl.o event.o info.o phy.o \
Holger Schurig9ceb6852009-11-11 11:36:34 +010018 interface.o ibss.o station.o survey.o util.o \
Johannes Bergfebeb0c2009-07-25 17:31:08 +020019 mesh.o mpath.o scan.o reg.o version.o \
Johannes Berg942b5cd2010-03-25 16:52:35 -050020 reason.o status.o connect.o link.o offch.o ps.o cqm.o \
Johannes Berg11596792011-07-15 23:13:59 +020021 bitrate.o wowlan.o roc.o
Johannes Berg4698bfc2009-08-24 12:53:34 +020022OBJS += sections.o
Mike Kershaw7153dbf2007-09-29 11:05:35 -040023ALL = iw
Johannes Berg82afaeb2008-04-02 17:40:05 +020024
Karl Hiramoto26ae7e42009-05-13 11:16:18 +020025NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y)
26NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y)
Yegor Yefremovded667b2011-07-21 15:06:17 +000027NL3FOUND := $(shell $(PKG_CONFIG) --atleast-version=3 libnl-3.0 && echo Y)
Gilles Espinasse9c1d7582011-11-12 00:04:38 +010028NL31FOUND := $(shell $(PKG_CONFIG) --exact-version=3.1 libnl-3.1 && echo Y)
29NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y)
Pat Erleydfd13ee2008-12-13 01:04:05 +010030
31ifeq ($(NL1FOUND),Y)
32NLLIBNAME = libnl-1
33endif
34
35ifeq ($(NL2FOUND),Y)
36CFLAGS += -DCONFIG_LIBNL20
37LIBS += -lnl-genl
38NLLIBNAME = libnl-2.0
39endif
40
Yegor Yefremovded667b2011-07-21 15:06:17 +000041ifeq ($(NL3FOUND),Y)
42CFLAGS += -DCONFIG_LIBNL30
Johannes Bergb72de672011-11-11 09:17:13 +010043LIBS += -lnl-genl
44NLLIBNAME = libnl-3.0
Yegor Yefremovded667b2011-07-21 15:06:17 +000045endif
46
Gilles Espinasse9c1d7582011-11-12 00:04:38 +010047# nl-3.1 has a broken libnl-gnl-3.1.pc file
48# as show by pkg-config --debug --libs --cflags --exact-version=3.1 libnl-genl-3.1;echo $?
49ifeq ($(NL31FOUND),Y)
50CFLAGS += -DCONFIG_LIBNL30
51LIBS += -lnl-genl
52NLLIBNAME = libnl-3.1
53endif
54
55ifeq ($(NL3xFOUND),Y)
56CFLAGS += -DCONFIG_LIBNL30
57LIBS += -lnl-genl-3
58NLLIBNAME = libnl-3.0
59endif
60
Pavel Roskin34b6e0f2009-01-30 17:33:34 -050061ifeq ($(NLLIBNAME),)
62$(error Cannot find development files for any supported version of libnl)
63endif
64
Johannes Stezenbachc7f53382009-11-10 18:29:34 +010065LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME))
66CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME))
Gilles Espinasse9c1d7582011-11-12 00:04:38 +010067NLVERSION :=$(shell $(PKG_CONFIG) --print-provides $(NLLIBNAME))
Pat Erleydfd13ee2008-12-13 01:04:05 +010068
Johannes Berg888e1192008-04-02 17:51:02 +020069ifeq ($(V),1)
70Q=
71NQ=true
72else
73Q=@
74NQ=echo
75endif
76
Gilles Espinasse9c1d7582011-11-12 00:04:38 +010077all: $(ALL)
Johannes Bergd711f012008-09-16 21:56:25 +020078
Johannes Berg133b0692009-04-21 00:53:00 +020079VERSION_OBJS := $(filter-out version.o, $(OBJS))
80
81version.c: version.sh $(patsubst %.o,%.c,$(VERSION_OBJS)) nl80211.h iw.h Makefile \
82 $(wildcard .git/index .git/refs/tags)
83 @$(NQ) ' GEN ' $@
84 $(Q)./version.sh $@
85
86%.o: %.c iw.h nl80211.h
Johannes Berg888e1192008-04-02 17:51:02 +020087 @$(NQ) ' CC ' $@
Johannes Bergf9c714d2008-04-03 15:38:11 +020088 $(Q)$(CC) $(CFLAGS) -c -o $@ $<
Johannes Berg888e1192008-04-02 17:51:02 +020089
Mike Kershaw7153dbf2007-09-29 11:05:35 -040090iw: $(OBJS)
Johannes Berg888e1192008-04-02 17:51:02 +020091 @$(NQ) ' CC ' iw
Mike Auty9b2e7e62008-12-12 22:47:16 +010092 $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw
Johannes Bergcad53b32007-09-28 22:11:34 +020093
Johannes Berg82afaeb2008-04-02 17:40:05 +020094check:
Johannes Berg888e1192008-04-02 17:51:02 +020095 $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc"
Johannes Berg82afaeb2008-04-02 17:40:05 +020096
Johannes Bergb0f79c42008-09-16 21:09:47 +020097%.gz: %
98 @$(NQ) ' GZIP' $<
99 $(Q)gzip < $< > $@
100
101install: iw iw.8.gz
102 @$(NQ) ' INST iw'
John W. Linville190f50c2009-09-30 09:19:46 -0400103 $(Q)$(MKDIR) $(DESTDIR)$(SBINDIR)
Luciano Coelho6dbddf12010-03-17 17:09:20 +0200104 $(Q)$(INSTALL) -m 755 iw $(DESTDIR)$(SBINDIR)
Johannes Bergb0f79c42008-09-16 21:09:47 +0200105 @$(NQ) ' INST iw.8'
Robby Workman30345662008-11-19 12:57:36 +0100106 $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/
Luciano Coelho6dbddf12010-03-17 17:09:20 +0200107 $(Q)$(INSTALL) -m 644 iw.8.gz $(DESTDIR)$(MANDIR)/man8/
Johannes Bergb0f79c42008-09-16 21:09:47 +0200108
Johannes Bergcad53b32007-09-28 22:11:34 +0200109clean:
Johannes Berg133b0692009-04-21 00:53:00 +0200110 $(Q)rm -f iw *.o *~ *.gz version.c *-stamp