Johannes Berg | 82afaeb | 2008-04-02 17:40:05 +0200 | [diff] [blame] | 1 | MAKEFLAGS += --no-print-directory |
| 2 | |
Robby Workman | 3034566 | 2008-11-19 12:57:36 +0100 | [diff] [blame] | 3 | PREFIX ?= /usr |
John W. Linville | 190f50c | 2009-09-30 09:19:46 -0400 | [diff] [blame] | 4 | SBINDIR ?= $(PREFIX)/sbin |
Robby Workman | 3034566 | 2008-11-19 12:57:36 +0100 | [diff] [blame] | 5 | MANDIR ?= $(PREFIX)/share/man |
Karl Hiramoto | 26ae7e4 | 2009-05-13 11:16:18 +0200 | [diff] [blame] | 6 | PKG_CONFIG ?= pkg-config |
Robby Workman | 3034566 | 2008-11-19 12:57:36 +0100 | [diff] [blame] | 7 | |
Kel Modderman | 848794e | 2008-09-17 11:04:33 +0200 | [diff] [blame] | 8 | MKDIR ?= mkdir -p |
Johannes Berg | b0f79c4 | 2008-09-16 21:09:47 +0200 | [diff] [blame] | 9 | INSTALL ?= install |
Mike Kershaw | 7153dbf | 2007-09-29 11:05:35 -0400 | [diff] [blame] | 10 | CC ?= "gcc" |
Robby Workman | 3034566 | 2008-11-19 12:57:36 +0100 | [diff] [blame] | 11 | |
Robert Buchholz | e0738db | 2009-01-07 15:46:13 +0100 | [diff] [blame] | 12 | CFLAGS ?= -O2 -g |
Pat Erley | dfd13ee | 2008-12-13 01:04:05 +0100 | [diff] [blame] | 13 | CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration |
Johannes Berg | cad53b3 | 2007-09-28 22:11:34 +0200 | [diff] [blame] | 14 | |
Johannes Berg | febeb0c | 2009-07-25 17:31:08 +0200 | [diff] [blame] | 15 | OBJS = iw.o genl.o event.o info.o phy.o \ |
Rostislav Lisovy | 3955e52 | 2015-01-12 13:49:57 +0100 | [diff] [blame] | 16 | interface.o ibss.o station.o survey.o util.o ocb.o \ |
Henning Rogge | 4a73ea1 | 2014-09-12 08:59:43 +0200 | [diff] [blame] | 17 | mesh.o mpath.o mpp.o scan.o reg.o version.o \ |
Johannes Berg | 942b5cd | 2010-03-25 16:52:35 -0500 | [diff] [blame] | 18 | reason.o status.o connect.o link.o offch.o ps.o cqm.o \ |
Johannes Berg | 60dbfa8 | 2014-10-29 17:08:35 +0100 | [diff] [blame] | 19 | bitrate.o wowlan.o coalesce.o roc.o p2p.o vendor.o |
Johannes Berg | 4698bfc | 2009-08-24 12:53:34 +0200 | [diff] [blame] | 20 | OBJS += sections.o |
Johannes Berg | a1b3258 | 2012-07-06 08:50:00 +0200 | [diff] [blame] | 21 | |
| 22 | OBJS-$(HWSIM) += hwsim.o |
| 23 | |
Johannes Berg | bb1bc46 | 2013-04-23 15:28:50 +0200 | [diff] [blame] | 24 | OBJS += $(OBJS-y) $(OBJS-Y) |
| 25 | |
Mike Kershaw | 7153dbf | 2007-09-29 11:05:35 -0400 | [diff] [blame] | 26 | ALL = iw |
Johannes Berg | 82afaeb | 2008-04-02 17:40:05 +0200 | [diff] [blame] | 27 | |
Johannes Berg | d0f5db8 | 2013-04-23 15:32:27 +0200 | [diff] [blame] | 28 | ifeq ($(NO_PKG_CONFIG),) |
Gilles Espinasse | 9c1d758 | 2011-11-12 00:04:38 +0100 | [diff] [blame] | 29 | NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y) |
Guido Trentalancia | 4439467 | 2012-06-03 01:46:45 +0200 | [diff] [blame] | 30 | ifneq ($(NL3xFOUND),Y) |
| 31 | NL31FOUND := $(shell $(PKG_CONFIG) --exact-version=3.1 libnl-3.1 && echo Y) |
| 32 | ifneq ($(NL31FOUND),Y) |
| 33 | NL3FOUND := $(shell $(PKG_CONFIG) --atleast-version=3 libnl-3.0 && echo Y) |
| 34 | ifneq ($(NL3FOUND),Y) |
| 35 | NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y) |
| 36 | ifneq ($(NL2FOUND),Y) |
| 37 | NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y) |
| 38 | endif |
| 39 | endif |
| 40 | endif |
| 41 | endif |
Pat Erley | dfd13ee | 2008-12-13 01:04:05 +0100 | [diff] [blame] | 42 | |
| 43 | ifeq ($(NL1FOUND),Y) |
| 44 | NLLIBNAME = libnl-1 |
| 45 | endif |
| 46 | |
| 47 | ifeq ($(NL2FOUND),Y) |
| 48 | CFLAGS += -DCONFIG_LIBNL20 |
| 49 | LIBS += -lnl-genl |
| 50 | NLLIBNAME = libnl-2.0 |
| 51 | endif |
| 52 | |
Bjarke Istrup Pedersen | 57df6fd | 2011-11-14 11:12:19 +0100 | [diff] [blame] | 53 | ifeq ($(NL3xFOUND),Y) |
| 54 | # libnl 3.2 might be found as 3.2 and 3.0 |
| 55 | NL3FOUND = N |
| 56 | CFLAGS += -DCONFIG_LIBNL30 |
| 57 | LIBS += -lnl-genl-3 |
| 58 | NLLIBNAME = libnl-3.0 |
| 59 | endif |
| 60 | |
Yegor Yefremov | ded667b | 2011-07-21 15:06:17 +0000 | [diff] [blame] | 61 | ifeq ($(NL3FOUND),Y) |
| 62 | CFLAGS += -DCONFIG_LIBNL30 |
Johannes Berg | b72de67 | 2011-11-11 09:17:13 +0100 | [diff] [blame] | 63 | LIBS += -lnl-genl |
| 64 | NLLIBNAME = libnl-3.0 |
Yegor Yefremov | ded667b | 2011-07-21 15:06:17 +0000 | [diff] [blame] | 65 | endif |
| 66 | |
Gilles Espinasse | 9c1d758 | 2011-11-12 00:04:38 +0100 | [diff] [blame] | 67 | # 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 $? |
| 69 | ifeq ($(NL31FOUND),Y) |
| 70 | CFLAGS += -DCONFIG_LIBNL30 |
| 71 | LIBS += -lnl-genl |
| 72 | NLLIBNAME = libnl-3.1 |
| 73 | endif |
| 74 | |
Pavel Roskin | 34b6e0f | 2009-01-30 17:33:34 -0500 | [diff] [blame] | 75 | ifeq ($(NLLIBNAME),) |
| 76 | $(error Cannot find development files for any supported version of libnl) |
| 77 | endif |
| 78 | |
Johannes Stezenbach | c7f5338 | 2009-11-10 18:29:34 +0100 | [diff] [blame] | 79 | LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME)) |
| 80 | CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME)) |
Johannes Berg | d0f5db8 | 2013-04-23 15:32:27 +0200 | [diff] [blame] | 81 | endif # NO_PKG_CONFIG |
Pat Erley | dfd13ee | 2008-12-13 01:04:05 +0100 | [diff] [blame] | 82 | |
Johannes Berg | 888e119 | 2008-04-02 17:51:02 +0200 | [diff] [blame] | 83 | ifeq ($(V),1) |
| 84 | Q= |
| 85 | NQ=true |
| 86 | else |
| 87 | Q=@ |
| 88 | NQ=echo |
| 89 | endif |
| 90 | |
Gilles Espinasse | 9c1d758 | 2011-11-12 00:04:38 +0100 | [diff] [blame] | 91 | all: $(ALL) |
Johannes Berg | d711f01 | 2008-09-16 21:56:25 +0200 | [diff] [blame] | 92 | |
Johannes Berg | bb1bc46 | 2013-04-23 15:28:50 +0200 | [diff] [blame] | 93 | VERSION_OBJS := $(filter-out version.o, $(OBJS)) |
Johannes Berg | 133b069 | 2009-04-21 00:53:00 +0200 | [diff] [blame] | 94 | |
| 95 | version.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 Berg | 888e119 | 2008-04-02 17:51:02 +0200 | [diff] [blame] | 101 | @$(NQ) ' CC ' $@ |
Johannes Berg | f9c714d | 2008-04-03 15:38:11 +0200 | [diff] [blame] | 102 | $(Q)$(CC) $(CFLAGS) -c -o $@ $< |
Johannes Berg | 888e119 | 2008-04-02 17:51:02 +0200 | [diff] [blame] | 103 | |
Arik Nemtsov | f21da10 | 2015-01-06 12:48:45 +0200 | [diff] [blame] | 104 | ifeq ($(IW_ANDROID_BUILD),) |
Johannes Berg | bb1bc46 | 2013-04-23 15:28:50 +0200 | [diff] [blame] | 105 | iw: $(OBJS) |
Johannes Berg | 888e119 | 2008-04-02 17:51:02 +0200 | [diff] [blame] | 106 | @$(NQ) ' CC ' iw |
Johannes Berg | bb1bc46 | 2013-04-23 15:28:50 +0200 | [diff] [blame] | 107 | $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw |
Arik Nemtsov | f21da10 | 2015-01-06 12:48:45 +0200 | [diff] [blame] | 108 | endif |
Johannes Berg | cad53b3 | 2007-09-28 22:11:34 +0200 | [diff] [blame] | 109 | |
Johannes Berg | 82afaeb | 2008-04-02 17:40:05 +0200 | [diff] [blame] | 110 | check: |
Johannes Berg | 888e119 | 2008-04-02 17:51:02 +0200 | [diff] [blame] | 111 | $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc" |
Johannes Berg | 82afaeb | 2008-04-02 17:40:05 +0200 | [diff] [blame] | 112 | |
Johannes Berg | b0f79c4 | 2008-09-16 21:09:47 +0200 | [diff] [blame] | 113 | %.gz: % |
| 114 | @$(NQ) ' GZIP' $< |
| 115 | $(Q)gzip < $< > $@ |
| 116 | |
| 117 | install: iw iw.8.gz |
| 118 | @$(NQ) ' INST iw' |
John W. Linville | 190f50c | 2009-09-30 09:19:46 -0400 | [diff] [blame] | 119 | $(Q)$(MKDIR) $(DESTDIR)$(SBINDIR) |
Luciano Coelho | 6dbddf1 | 2010-03-17 17:09:20 +0200 | [diff] [blame] | 120 | $(Q)$(INSTALL) -m 755 iw $(DESTDIR)$(SBINDIR) |
Johannes Berg | b0f79c4 | 2008-09-16 21:09:47 +0200 | [diff] [blame] | 121 | @$(NQ) ' INST iw.8' |
Robby Workman | 3034566 | 2008-11-19 12:57:36 +0100 | [diff] [blame] | 122 | $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/ |
Luciano Coelho | 6dbddf1 | 2010-03-17 17:09:20 +0200 | [diff] [blame] | 123 | $(Q)$(INSTALL) -m 644 iw.8.gz $(DESTDIR)$(MANDIR)/man8/ |
Johannes Berg | b0f79c4 | 2008-09-16 21:09:47 +0200 | [diff] [blame] | 124 | |
Johannes Berg | cad53b3 | 2007-09-28 22:11:34 +0200 | [diff] [blame] | 125 | clean: |
Johannes Berg | 133b069 | 2009-04-21 00:53:00 +0200 | [diff] [blame] | 126 | $(Q)rm -f iw *.o *~ *.gz version.c *-stamp |