blob: 8443ee69f26fdabf603356c1895e6b036fc3a35e [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)
Pat Erleydfd13ee2008-12-13 01:04:05 +010028
29ifeq ($(NL1FOUND),Y)
30NLLIBNAME = libnl-1
31endif
32
33ifeq ($(NL2FOUND),Y)
34CFLAGS += -DCONFIG_LIBNL20
35LIBS += -lnl-genl
36NLLIBNAME = libnl-2.0
37endif
38
Yegor Yefremovded667b2011-07-21 15:06:17 +000039ifeq ($(NL3FOUND),Y)
40CFLAGS += -DCONFIG_LIBNL30
41LIBS += -lnl-genl
42NLLIBNAME = libnl-3.0
43endif
44
Pavel Roskin34b6e0f2009-01-30 17:33:34 -050045ifeq ($(NLLIBNAME),)
46$(error Cannot find development files for any supported version of libnl)
47endif
48
Johannes Stezenbachc7f53382009-11-10 18:29:34 +010049LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME))
50CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME))
Pat Erleydfd13ee2008-12-13 01:04:05 +010051
Johannes Berg888e1192008-04-02 17:51:02 +020052ifeq ($(V),1)
53Q=
54NQ=true
55else
56Q=@
57NQ=echo
58endif
59
Benjamin Berga0f7f1c2008-09-16 23:01:07 +020060all: version_check $(ALL)
61
62version_check:
Yegor Yefremovded667b2011-07-21 15:06:17 +000063ifeq ($(NL3FOUND),Y)
64else
Pat Erleydfd13ee2008-12-13 01:04:05 +010065ifeq ($(NL2FOUND),Y)
66else
67ifeq ($(NL1FOUND),Y)
68else
69 $(error No libnl found)
70endif
71endif
Yegor Yefremovded667b2011-07-21 15:06:17 +000072endif
Mike Kershaw7153dbf2007-09-29 11:05:35 -040073
Johannes Bergd711f012008-09-16 21:56:25 +020074
Johannes Berg133b0692009-04-21 00:53:00 +020075VERSION_OBJS := $(filter-out version.o, $(OBJS))
76
77version.c: version.sh $(patsubst %.o,%.c,$(VERSION_OBJS)) nl80211.h iw.h Makefile \
78 $(wildcard .git/index .git/refs/tags)
79 @$(NQ) ' GEN ' $@
80 $(Q)./version.sh $@
81
82%.o: %.c iw.h nl80211.h
Johannes Berg888e1192008-04-02 17:51:02 +020083 @$(NQ) ' CC ' $@
Johannes Bergf9c714d2008-04-03 15:38:11 +020084 $(Q)$(CC) $(CFLAGS) -c -o $@ $<
Johannes Berg888e1192008-04-02 17:51:02 +020085
Mike Kershaw7153dbf2007-09-29 11:05:35 -040086iw: $(OBJS)
Johannes Berg888e1192008-04-02 17:51:02 +020087 @$(NQ) ' CC ' iw
Mike Auty9b2e7e62008-12-12 22:47:16 +010088 $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw
Johannes Bergcad53b32007-09-28 22:11:34 +020089
Johannes Berg82afaeb2008-04-02 17:40:05 +020090check:
Johannes Berg888e1192008-04-02 17:51:02 +020091 $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc"
Johannes Berg82afaeb2008-04-02 17:40:05 +020092
Johannes Bergb0f79c42008-09-16 21:09:47 +020093%.gz: %
94 @$(NQ) ' GZIP' $<
95 $(Q)gzip < $< > $@
96
97install: iw iw.8.gz
98 @$(NQ) ' INST iw'
John W. Linville190f50c2009-09-30 09:19:46 -040099 $(Q)$(MKDIR) $(DESTDIR)$(SBINDIR)
Luciano Coelho6dbddf12010-03-17 17:09:20 +0200100 $(Q)$(INSTALL) -m 755 iw $(DESTDIR)$(SBINDIR)
Johannes Bergb0f79c42008-09-16 21:09:47 +0200101 @$(NQ) ' INST iw.8'
Robby Workman30345662008-11-19 12:57:36 +0100102 $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/
Luciano Coelho6dbddf12010-03-17 17:09:20 +0200103 $(Q)$(INSTALL) -m 644 iw.8.gz $(DESTDIR)$(MANDIR)/man8/
Johannes Bergb0f79c42008-09-16 21:09:47 +0200104
Johannes Bergcad53b32007-09-28 22:11:34 +0200105clean:
Johannes Berg133b0692009-04-21 00:53:00 +0200106 $(Q)rm -f iw *.o *~ *.gz version.c *-stamp