Mike Kershaw | 7153dbf | 2007-09-29 11:05:35 -0400 | [diff] [blame] | 1 | -include .config |
Johannes Berg | cad53b3 | 2007-09-28 22:11:34 +0200 | [diff] [blame] | 2 | |
Johannes Berg | 82afaeb | 2008-04-02 17:40:05 +0200 | [diff] [blame] | 3 | MAKEFLAGS += --no-print-directory |
| 4 | |
Robby Workman | 3034566 | 2008-11-19 12:57:36 +0100 | [diff] [blame] | 5 | PREFIX ?= /usr |
| 6 | BINDIR ?= $(PREFIX)/bin |
| 7 | MANDIR ?= $(PREFIX)/share/man |
| 8 | |
Kel Modderman | 848794e | 2008-09-17 11:04:33 +0200 | [diff] [blame] | 9 | MKDIR ?= mkdir -p |
Johannes Berg | b0f79c4 | 2008-09-16 21:09:47 +0200 | [diff] [blame] | 10 | INSTALL ?= install |
Mike Kershaw | 7153dbf | 2007-09-29 11:05:35 -0400 | [diff] [blame] | 11 | CC ?= "gcc" |
Robby Workman | 3034566 | 2008-11-19 12:57:36 +0100 | [diff] [blame] | 12 | |
Robert Buchholz | e0738db | 2009-01-07 15:46:13 +0100 | [diff] [blame] | 13 | CFLAGS ?= -O2 -g |
Pat Erley | dfd13ee | 2008-12-13 01:04:05 +0100 | [diff] [blame] | 14 | 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] | 15 | |
Johannes Berg | d4f63ce | 2009-01-29 14:45:41 +0100 | [diff] [blame] | 16 | OBJS = iw.o genl.o info.o phy.o interface.o station.o util.o mesh.o mpath.o reg.o |
Mike Kershaw | 7153dbf | 2007-09-29 11:05:35 -0400 | [diff] [blame] | 17 | ALL = iw |
Johannes Berg | 82afaeb | 2008-04-02 17:40:05 +0200 | [diff] [blame] | 18 | |
Pat Erley | dfd13ee | 2008-12-13 01:04:05 +0100 | [diff] [blame] | 19 | NL1FOUND := $(shell pkg-config --atleast-version=1 libnl-1 && echo Y) |
| 20 | NL2FOUND := $(shell pkg-config --atleast-version=2 libnl-2.0 && echo Y) |
| 21 | |
| 22 | ifeq ($(NL1FOUND),Y) |
| 23 | NLLIBNAME = libnl-1 |
| 24 | endif |
| 25 | |
| 26 | ifeq ($(NL2FOUND),Y) |
| 27 | CFLAGS += -DCONFIG_LIBNL20 |
| 28 | LIBS += -lnl-genl |
| 29 | NLLIBNAME = libnl-2.0 |
| 30 | endif |
| 31 | |
Pavel Roskin | 34b6e0f | 2009-01-30 17:33:34 -0500 | [diff] [blame^] | 32 | ifeq ($(NLLIBNAME),) |
| 33 | $(error Cannot find development files for any supported version of libnl) |
| 34 | endif |
| 35 | |
Johannes Berg | 98be897 | 2008-12-13 01:09:03 +0100 | [diff] [blame] | 36 | LIBS += $(shell pkg-config --libs $(NLLIBNAME)) |
| 37 | CFLAGS += $(shell pkg-config --cflags $(NLLIBNAME)) |
Pat Erley | dfd13ee | 2008-12-13 01:04:05 +0100 | [diff] [blame] | 38 | |
Johannes Berg | 888e119 | 2008-04-02 17:51:02 +0200 | [diff] [blame] | 39 | ifeq ($(V),1) |
| 40 | Q= |
| 41 | NQ=true |
| 42 | else |
| 43 | Q=@ |
| 44 | NQ=echo |
| 45 | endif |
| 46 | |
Benjamin Berg | a0f7f1c | 2008-09-16 23:01:07 +0200 | [diff] [blame] | 47 | all: version_check $(ALL) |
| 48 | |
| 49 | version_check: |
Pat Erley | dfd13ee | 2008-12-13 01:04:05 +0100 | [diff] [blame] | 50 | ifeq ($(NL2FOUND),Y) |
| 51 | else |
| 52 | ifeq ($(NL1FOUND),Y) |
| 53 | else |
| 54 | $(error No libnl found) |
| 55 | endif |
| 56 | endif |
Mike Kershaw | 7153dbf | 2007-09-29 11:05:35 -0400 | [diff] [blame] | 57 | |
Johannes Berg | 7e10ba7 | 2008-09-16 21:58:46 +0200 | [diff] [blame] | 58 | version.h: version.sh |
Johannes Berg | d711f01 | 2008-09-16 21:56:25 +0200 | [diff] [blame] | 59 | @$(NQ) ' GEN version.h' |
Johannes Berg | 7e10ba7 | 2008-09-16 21:58:46 +0200 | [diff] [blame] | 60 | $(Q)./version.sh |
Johannes Berg | d711f01 | 2008-09-16 21:56:25 +0200 | [diff] [blame] | 61 | |
Johannes Berg | 4a00a48 | 2009-01-27 22:09:57 +0100 | [diff] [blame] | 62 | %.o: %.c iw.h version.h nl80211.h |
Johannes Berg | 888e119 | 2008-04-02 17:51:02 +0200 | [diff] [blame] | 63 | @$(NQ) ' CC ' $@ |
Johannes Berg | f9c714d | 2008-04-03 15:38:11 +0200 | [diff] [blame] | 64 | $(Q)$(CC) $(CFLAGS) -c -o $@ $< |
Johannes Berg | 888e119 | 2008-04-02 17:51:02 +0200 | [diff] [blame] | 65 | |
Mike Kershaw | 7153dbf | 2007-09-29 11:05:35 -0400 | [diff] [blame] | 66 | iw: $(OBJS) |
Johannes Berg | 888e119 | 2008-04-02 17:51:02 +0200 | [diff] [blame] | 67 | @$(NQ) ' CC ' iw |
Mike Auty | 9b2e7e6 | 2008-12-12 22:47:16 +0100 | [diff] [blame] | 68 | $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw |
Johannes Berg | cad53b3 | 2007-09-28 22:11:34 +0200 | [diff] [blame] | 69 | |
Johannes Berg | 82afaeb | 2008-04-02 17:40:05 +0200 | [diff] [blame] | 70 | check: |
Johannes Berg | 888e119 | 2008-04-02 17:51:02 +0200 | [diff] [blame] | 71 | $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc" |
Johannes Berg | 82afaeb | 2008-04-02 17:40:05 +0200 | [diff] [blame] | 72 | |
Johannes Berg | b0f79c4 | 2008-09-16 21:09:47 +0200 | [diff] [blame] | 73 | %.gz: % |
| 74 | @$(NQ) ' GZIP' $< |
| 75 | $(Q)gzip < $< > $@ |
| 76 | |
| 77 | install: iw iw.8.gz |
| 78 | @$(NQ) ' INST iw' |
Robby Workman | 3034566 | 2008-11-19 12:57:36 +0100 | [diff] [blame] | 79 | $(Q)$(MKDIR) $(DESTDIR)$(BINDIR) |
| 80 | $(Q)$(INSTALL) -m 755 -t $(DESTDIR)$(BINDIR) iw |
Johannes Berg | b0f79c4 | 2008-09-16 21:09:47 +0200 | [diff] [blame] | 81 | @$(NQ) ' INST iw.8' |
Robby Workman | 3034566 | 2008-11-19 12:57:36 +0100 | [diff] [blame] | 82 | $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/ |
| 83 | $(Q)$(INSTALL) -m 644 -t $(DESTDIR)$(MANDIR)/man8/ iw.8.gz |
Johannes Berg | b0f79c4 | 2008-09-16 21:09:47 +0200 | [diff] [blame] | 84 | |
Johannes Berg | cad53b3 | 2007-09-28 22:11:34 +0200 | [diff] [blame] | 85 | clean: |
Johannes Berg | 5729ffd | 2008-09-17 11:09:39 +0200 | [diff] [blame] | 86 | $(Q)rm -f iw *.o *~ *.gz version.h *-stamp |