blob: 3393d15f4276bdda42f2785aad42109824c5f7c8 [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
Bjarke Istrup Pedersen57df6fd2011-11-14 11:12:19 +010041ifeq ($(NL3xFOUND),Y)
42# libnl 3.2 might be found as 3.2 and 3.0
43NL3FOUND = N
44CFLAGS += -DCONFIG_LIBNL30
45LIBS += -lnl-genl-3
46NLLIBNAME = libnl-3.0
47endif
48
Yegor Yefremovded667b2011-07-21 15:06:17 +000049ifeq ($(NL3FOUND),Y)
50CFLAGS += -DCONFIG_LIBNL30
Johannes Bergb72de672011-11-11 09:17:13 +010051LIBS += -lnl-genl
52NLLIBNAME = libnl-3.0
Yegor Yefremovded667b2011-07-21 15:06:17 +000053endif
54
Gilles Espinasse9c1d7582011-11-12 00:04:38 +010055# nl-3.1 has a broken libnl-gnl-3.1.pc file
56# as show by pkg-config --debug --libs --cflags --exact-version=3.1 libnl-genl-3.1;echo $?
57ifeq ($(NL31FOUND),Y)
58CFLAGS += -DCONFIG_LIBNL30
59LIBS += -lnl-genl
60NLLIBNAME = libnl-3.1
61endif
62
Pavel Roskin34b6e0f2009-01-30 17:33:34 -050063ifeq ($(NLLIBNAME),)
64$(error Cannot find development files for any supported version of libnl)
65endif
66
Johannes Stezenbachc7f53382009-11-10 18:29:34 +010067LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME))
68CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME))
Gilles Espinasse9c1d7582011-11-12 00:04:38 +010069NLVERSION :=$(shell $(PKG_CONFIG) --print-provides $(NLLIBNAME))
Pat Erleydfd13ee2008-12-13 01:04:05 +010070
Johannes Berg888e1192008-04-02 17:51:02 +020071ifeq ($(V),1)
72Q=
73NQ=true
74else
75Q=@
76NQ=echo
77endif
78
Gilles Espinasse9c1d7582011-11-12 00:04:38 +010079all: $(ALL)
Johannes Bergd711f012008-09-16 21:56:25 +020080
Johannes Berg133b0692009-04-21 00:53:00 +020081VERSION_OBJS := $(filter-out version.o, $(OBJS))
82
83version.c: version.sh $(patsubst %.o,%.c,$(VERSION_OBJS)) nl80211.h iw.h Makefile \
84 $(wildcard .git/index .git/refs/tags)
85 @$(NQ) ' GEN ' $@
86 $(Q)./version.sh $@
87
88%.o: %.c iw.h nl80211.h
Johannes Berg888e1192008-04-02 17:51:02 +020089 @$(NQ) ' CC ' $@
Johannes Bergf9c714d2008-04-03 15:38:11 +020090 $(Q)$(CC) $(CFLAGS) -c -o $@ $<
Johannes Berg888e1192008-04-02 17:51:02 +020091
Mike Kershaw7153dbf2007-09-29 11:05:35 -040092iw: $(OBJS)
Johannes Berg888e1192008-04-02 17:51:02 +020093 @$(NQ) ' CC ' iw
Mike Auty9b2e7e62008-12-12 22:47:16 +010094 $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw
Johannes Bergcad53b32007-09-28 22:11:34 +020095
Johannes Berg82afaeb2008-04-02 17:40:05 +020096check:
Johannes Berg888e1192008-04-02 17:51:02 +020097 $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc"
Johannes Berg82afaeb2008-04-02 17:40:05 +020098
Johannes Bergb0f79c42008-09-16 21:09:47 +020099%.gz: %
100 @$(NQ) ' GZIP' $<
101 $(Q)gzip < $< > $@
102
103install: iw iw.8.gz
104 @$(NQ) ' INST iw'
John W. Linville190f50c2009-09-30 09:19:46 -0400105 $(Q)$(MKDIR) $(DESTDIR)$(SBINDIR)
Luciano Coelho6dbddf12010-03-17 17:09:20 +0200106 $(Q)$(INSTALL) -m 755 iw $(DESTDIR)$(SBINDIR)
Johannes Bergb0f79c42008-09-16 21:09:47 +0200107 @$(NQ) ' INST iw.8'
Robby Workman30345662008-11-19 12:57:36 +0100108 $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/
Luciano Coelho6dbddf12010-03-17 17:09:20 +0200109 $(Q)$(INSTALL) -m 644 iw.8.gz $(DESTDIR)$(MANDIR)/man8/
Johannes Bergb0f79c42008-09-16 21:09:47 +0200110
Johannes Bergcad53b32007-09-28 22:11:34 +0200111clean:
Johannes Berg133b0692009-04-21 00:53:00 +0200112 $(Q)rm -f iw *.o *~ *.gz version.c *-stamp