1MAKEFLAGS += --no-print-directory 2 3PREFIX ?= /usr 4SBINDIR ?= $(PREFIX)/sbin 5MANDIR ?= $(PREFIX)/share/man 6PKG_CONFIG ?= pkg-config 7 8MKDIR ?= mkdir -p 9INSTALL ?= install 10CC ?= "gcc" 11 12CFLAGS ?= -O2 -g 13CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration 14 15OBJS = iw.o genl.o event.o info.o phy.o \ 16 interface.o ibss.o station.o survey.o util.o ocb.o \ 17 mesh.o mpath.o mpp.o scan.o reg.o version.o \ 18 reason.o status.o connect.o link.o offch.o ps.o cqm.o \ 19 bitrate.o wowlan.o coalesce.o roc.o p2p.o vendor.o 20OBJS += sections.o 21 22OBJS-$(HWSIM) += hwsim.o 23 24OBJS += $(OBJS-y) $(OBJS-Y) 25 26ALL = iw 27 28ifeq ($(NO_PKG_CONFIG),) 29NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y) 30ifneq ($(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 42 43ifeq ($(NL1FOUND),Y) 44NLLIBNAME = libnl-1 45endif 46 47ifeq ($(NL2FOUND),Y) 48CFLAGS += -DCONFIG_LIBNL20 49LIBS += -lnl-genl 50NLLIBNAME = libnl-2.0 51endif 52 53ifeq ($(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 61ifeq ($(NL3FOUND),Y) 62CFLAGS += -DCONFIG_LIBNL30 63LIBS += -lnl-genl 64NLLIBNAME = libnl-3.0 65endif 66 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 $? 69ifeq ($(NL31FOUND),Y) 70CFLAGS += -DCONFIG_LIBNL30 71LIBS += -lnl-genl 72NLLIBNAME = libnl-3.1 73endif 74 75ifeq ($(NLLIBNAME),) 76$(error Cannot find development files for any supported version of libnl) 77endif 78 79LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME)) 80CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME)) 81endif # NO_PKG_CONFIG 82 83ifeq ($(V),1) 84Q= 85NQ=true 86else 87Q=@ 88NQ=echo 89endif 90 91all: $(ALL) 92 93VERSION_OBJS := $(filter-out version.o, $(OBJS)) 94 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 101 @$(NQ) ' CC ' $@ 102 $(Q)$(CC) $(CFLAGS) -c -o $@ $< 103 104ifeq ($(IW_ANDROID_BUILD),) 105iw: $(OBJS) 106 @$(NQ) ' CC ' iw 107 $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw 108endif 109 110check: 111 $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc" 112 113%.gz: % 114 @$(NQ) ' GZIP' $< 115 $(Q)gzip < $< > $@ 116 117install: iw iw.8.gz 118 @$(NQ) ' INST iw' 119 $(Q)$(MKDIR) $(DESTDIR)$(SBINDIR) 120 $(Q)$(INSTALL) -m 755 iw $(DESTDIR)$(SBINDIR) 121 @$(NQ) ' INST iw.8' 122 $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/ 123 $(Q)$(INSTALL) -m 644 iw.8.gz $(DESTDIR)$(MANDIR)/man8/ 124 125clean: 126 $(Q)rm -f iw *.o *~ *.gz version.c *-stamp 127