]>
Commit | Line | Data |
---|---|---|
7153dbf3 | 1 | -include .config |
cad53b3f | 2 | |
82afaeb7 JB |
3 | MAKEFLAGS += --no-print-directory |
4 | ||
30345664 RW |
5 | PREFIX ?= /usr |
6 | BINDIR ?= $(PREFIX)/bin | |
7 | MANDIR ?= $(PREFIX)/share/man | |
26ae7e4e | 8 | PKG_CONFIG ?= pkg-config |
30345664 | 9 | |
848794ec | 10 | MKDIR ?= mkdir -p |
b0f79c45 | 11 | INSTALL ?= install |
7153dbf3 | 12 | CC ?= "gcc" |
30345664 | 13 | |
e0738dbb | 14 | CFLAGS ?= -O2 -g |
dfd13ee5 | 15 | CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration |
cad53b3f | 16 | |
febeb0c0 JB |
17 | OBJS = iw.o genl.o event.o info.o phy.o \ |
18 | interface.o ibss.o station.o util.o \ | |
19 | mesh.o mpath.o scan.o reg.o version.o \ | |
20 | reason.o status.o connect.o link.o | |
7153dbf3 | 21 | ALL = iw |
82afaeb7 | 22 | |
26ae7e4e KH |
23 | NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y) |
24 | NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y) | |
dfd13ee5 PE |
25 | |
26 | ifeq ($(NL1FOUND),Y) | |
27 | NLLIBNAME = libnl-1 | |
28 | endif | |
29 | ||
30 | ifeq ($(NL2FOUND),Y) | |
31 | CFLAGS += -DCONFIG_LIBNL20 | |
32 | LIBS += -lnl-genl | |
33 | NLLIBNAME = libnl-2.0 | |
34 | endif | |
35 | ||
34b6e0f5 PR |
36 | ifeq ($(NLLIBNAME),) |
37 | $(error Cannot find development files for any supported version of libnl) | |
38 | endif | |
39 | ||
98be8972 JB |
40 | LIBS += $(shell pkg-config --libs $(NLLIBNAME)) |
41 | CFLAGS += $(shell pkg-config --cflags $(NLLIBNAME)) | |
dfd13ee5 | 42 | |
888e1192 JB |
43 | ifeq ($(V),1) |
44 | Q= | |
45 | NQ=true | |
46 | else | |
47 | Q=@ | |
48 | NQ=echo | |
49 | endif | |
50 | ||
a0f7f1c5 BB |
51 | all: version_check $(ALL) |
52 | ||
53 | version_check: | |
dfd13ee5 PE |
54 | ifeq ($(NL2FOUND),Y) |
55 | else | |
56 | ifeq ($(NL1FOUND),Y) | |
57 | else | |
58 | $(error No libnl found) | |
59 | endif | |
60 | endif | |
7153dbf3 | 61 | |
d711f013 | 62 | |
133b069f JB |
63 | VERSION_OBJS := $(filter-out version.o, $(OBJS)) |
64 | ||
65 | version.c: version.sh $(patsubst %.o,%.c,$(VERSION_OBJS)) nl80211.h iw.h Makefile \ | |
66 | $(wildcard .git/index .git/refs/tags) | |
67 | @$(NQ) ' GEN ' $@ | |
68 | $(Q)./version.sh $@ | |
69 | ||
70 | %.o: %.c iw.h nl80211.h | |
888e1192 | 71 | @$(NQ) ' CC ' $@ |
f9c714d7 | 72 | $(Q)$(CC) $(CFLAGS) -c -o $@ $< |
888e1192 | 73 | |
7153dbf3 | 74 | iw: $(OBJS) |
888e1192 | 75 | @$(NQ) ' CC ' iw |
9b2e7e6e | 76 | $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw |
cad53b3f | 77 | |
82afaeb7 | 78 | check: |
888e1192 | 79 | $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc" |
82afaeb7 | 80 | |
b0f79c45 JB |
81 | %.gz: % |
82 | @$(NQ) ' GZIP' $< | |
83 | $(Q)gzip < $< > $@ | |
84 | ||
85 | install: iw iw.8.gz | |
86 | @$(NQ) ' INST iw' | |
30345664 RW |
87 | $(Q)$(MKDIR) $(DESTDIR)$(BINDIR) |
88 | $(Q)$(INSTALL) -m 755 -t $(DESTDIR)$(BINDIR) iw | |
b0f79c45 | 89 | @$(NQ) ' INST iw.8' |
30345664 RW |
90 | $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/ |
91 | $(Q)$(INSTALL) -m 644 -t $(DESTDIR)$(MANDIR)/man8/ iw.8.gz | |
b0f79c45 | 92 | |
cad53b3f | 93 | clean: |
133b069f | 94 | $(Q)rm -f iw *.o *~ *.gz version.c *-stamp |