blob: 89ebd7f81e8d863dae82551276c643398d318c73 [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
6BINDIR ?= $(PREFIX)/bin
7MANDIR ?= $(PREFIX)/share/man
8
Kel Modderman848794e2008-09-17 11:04:33 +02009MKDIR ?= mkdir -p
Johannes Bergb0f79c42008-09-16 21:09:47 +020010INSTALL ?= install
Mike Kershaw7153dbf2007-09-29 11:05:35 -040011CC ?= "gcc"
Robby Workman30345662008-11-19 12:57:36 +010012
Robert Buchholze0738db2009-01-07 15:46:13 +010013CFLAGS ?= -O2 -g
Pat Erleydfd13ee2008-12-13 01:04:05 +010014CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
Johannes Bergcad53b32007-09-28 22:11:34 +020015
Johannes Bergd4f63ce2009-01-29 14:45:41 +010016OBJS = iw.o genl.o info.o phy.o interface.o station.o util.o mesh.o mpath.o reg.o
Mike Kershaw7153dbf2007-09-29 11:05:35 -040017ALL = iw
Johannes Berg82afaeb2008-04-02 17:40:05 +020018
Pat Erleydfd13ee2008-12-13 01:04:05 +010019NL1FOUND := $(shell pkg-config --atleast-version=1 libnl-1 && echo Y)
20NL2FOUND := $(shell pkg-config --atleast-version=2 libnl-2.0 && echo Y)
21
22ifeq ($(NL1FOUND),Y)
23NLLIBNAME = libnl-1
24endif
25
26ifeq ($(NL2FOUND),Y)
27CFLAGS += -DCONFIG_LIBNL20
28LIBS += -lnl-genl
29NLLIBNAME = libnl-2.0
30endif
31
Pavel Roskin34b6e0f2009-01-30 17:33:34 -050032ifeq ($(NLLIBNAME),)
33$(error Cannot find development files for any supported version of libnl)
34endif
35
Johannes Berg98be8972008-12-13 01:09:03 +010036LIBS += $(shell pkg-config --libs $(NLLIBNAME))
37CFLAGS += $(shell pkg-config --cflags $(NLLIBNAME))
Pat Erleydfd13ee2008-12-13 01:04:05 +010038
Johannes Berg888e1192008-04-02 17:51:02 +020039ifeq ($(V),1)
40Q=
41NQ=true
42else
43Q=@
44NQ=echo
45endif
46
Benjamin Berga0f7f1c2008-09-16 23:01:07 +020047all: version_check $(ALL)
48
49version_check:
Pat Erleydfd13ee2008-12-13 01:04:05 +010050ifeq ($(NL2FOUND),Y)
51else
52ifeq ($(NL1FOUND),Y)
53else
54 $(error No libnl found)
55endif
56endif
Mike Kershaw7153dbf2007-09-29 11:05:35 -040057
Johannes Berg7e10ba72008-09-16 21:58:46 +020058version.h: version.sh
Johannes Bergd711f012008-09-16 21:56:25 +020059 @$(NQ) ' GEN version.h'
Johannes Berg7e10ba72008-09-16 21:58:46 +020060 $(Q)./version.sh
Johannes Bergd711f012008-09-16 21:56:25 +020061
Johannes Berg4a00a482009-01-27 22:09:57 +010062%.o: %.c iw.h version.h nl80211.h
Johannes Berg888e1192008-04-02 17:51:02 +020063 @$(NQ) ' CC ' $@
Johannes Bergf9c714d2008-04-03 15:38:11 +020064 $(Q)$(CC) $(CFLAGS) -c -o $@ $<
Johannes Berg888e1192008-04-02 17:51:02 +020065
Mike Kershaw7153dbf2007-09-29 11:05:35 -040066iw: $(OBJS)
Johannes Berg888e1192008-04-02 17:51:02 +020067 @$(NQ) ' CC ' iw
Mike Auty9b2e7e62008-12-12 22:47:16 +010068 $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw
Johannes Bergcad53b32007-09-28 22:11:34 +020069
Johannes Berg82afaeb2008-04-02 17:40:05 +020070check:
Johannes Berg888e1192008-04-02 17:51:02 +020071 $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc"
Johannes Berg82afaeb2008-04-02 17:40:05 +020072
Johannes Bergb0f79c42008-09-16 21:09:47 +020073%.gz: %
74 @$(NQ) ' GZIP' $<
75 $(Q)gzip < $< > $@
76
77install: iw iw.8.gz
78 @$(NQ) ' INST iw'
Robby Workman30345662008-11-19 12:57:36 +010079 $(Q)$(MKDIR) $(DESTDIR)$(BINDIR)
80 $(Q)$(INSTALL) -m 755 -t $(DESTDIR)$(BINDIR) iw
Johannes Bergb0f79c42008-09-16 21:09:47 +020081 @$(NQ) ' INST iw.8'
Robby Workman30345662008-11-19 12:57:36 +010082 $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/
83 $(Q)$(INSTALL) -m 644 -t $(DESTDIR)$(MANDIR)/man8/ iw.8.gz
Johannes Bergb0f79c42008-09-16 21:09:47 +020084
Johannes Bergcad53b32007-09-28 22:11:34 +020085clean:
Johannes Berg5729ffd2008-09-17 11:09:39 +020086 $(Q)rm -f iw *.o *~ *.gz version.h *-stamp