]> git.ipfire.org Git - thirdparty/iw.git/blob - Makefile
Merge branch 'ibss-test'
[thirdparty/iw.git] / Makefile
1 -include .config
2
3 MAKEFLAGS += --no-print-directory
4
5 PREFIX ?= /usr
6 BINDIR ?= $(PREFIX)/bin
7 MANDIR ?= $(PREFIX)/share/man
8
9 MKDIR ?= mkdir -p
10 INSTALL ?= install
11 CC ?= "gcc"
12
13 CFLAGS ?= -O2 -g
14 CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
15
16 OBJS = iw.o genl.o info.o phy.o interface.o ibss.o station.o util.o mesh.o mpath.o scan.o reg.o
17 ALL = iw
18
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
32 ifeq ($(NLLIBNAME),)
33 $(error Cannot find development files for any supported version of libnl)
34 endif
35
36 LIBS += $(shell pkg-config --libs $(NLLIBNAME))
37 CFLAGS += $(shell pkg-config --cflags $(NLLIBNAME))
38
39 ifeq ($(V),1)
40 Q=
41 NQ=true
42 else
43 Q=@
44 NQ=echo
45 endif
46
47 all: version_check $(ALL)
48
49 version_check:
50 ifeq ($(NL2FOUND),Y)
51 else
52 ifeq ($(NL1FOUND),Y)
53 else
54 $(error No libnl found)
55 endif
56 endif
57
58 version.h: version.sh *.c nl80211.h iw.h Makefile
59 @$(NQ) ' GEN version.h'
60 $(Q)./version.sh
61
62 %.o: %.c iw.h version.h nl80211.h
63 @$(NQ) ' CC ' $@
64 $(Q)$(CC) $(CFLAGS) -c -o $@ $<
65
66 iw: $(OBJS)
67 @$(NQ) ' CC ' iw
68 $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw
69
70 check:
71 $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc"
72
73 %.gz: %
74 @$(NQ) ' GZIP' $<
75 $(Q)gzip < $< > $@
76
77 install: iw iw.8.gz
78 @$(NQ) ' INST iw'
79 $(Q)$(MKDIR) $(DESTDIR)$(BINDIR)
80 $(Q)$(INSTALL) -m 755 -t $(DESTDIR)$(BINDIR) iw
81 @$(NQ) ' INST iw.8'
82 $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/
83 $(Q)$(INSTALL) -m 644 -t $(DESTDIR)$(MANDIR)/man8/ iw.8.gz
84
85 clean:
86 $(Q)rm -f iw *.o *~ *.gz version.h *-stamp