]> git.ipfire.org Git - thirdparty/iw.git/blob - Makefile
iw: support multiple regdom print
[thirdparty/iw.git] / Makefile
1 MAKEFLAGS += --no-print-directory
2
3 PREFIX ?= /usr
4 SBINDIR ?= $(PREFIX)/sbin
5 MANDIR ?= $(PREFIX)/share/man
6 PKG_CONFIG ?= pkg-config
7
8 MKDIR ?= mkdir -p
9 INSTALL ?= install
10 CC ?= "gcc"
11
12 CFLAGS ?= -O2 -g
13 CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
14
15 OBJS = iw.o genl.o event.o info.o phy.o \
16 interface.o ibss.o station.o survey.o util.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
20 OBJS += sections.o
21
22 OBJS-$(HWSIM) += hwsim.o
23
24 OBJS += $(OBJS-y) $(OBJS-Y)
25
26 ALL = iw
27
28 ifeq ($(NO_PKG_CONFIG),)
29 NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y)
30 ifneq ($(NL3xFOUND),Y)
31 NL31FOUND := $(shell $(PKG_CONFIG) --exact-version=3.1 libnl-3.1 && echo Y)
32 ifneq ($(NL31FOUND),Y)
33 NL3FOUND := $(shell $(PKG_CONFIG) --atleast-version=3 libnl-3.0 && echo Y)
34 ifneq ($(NL3FOUND),Y)
35 NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y)
36 ifneq ($(NL2FOUND),Y)
37 NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y)
38 endif
39 endif
40 endif
41 endif
42
43 ifeq ($(NL1FOUND),Y)
44 NLLIBNAME = libnl-1
45 endif
46
47 ifeq ($(NL2FOUND),Y)
48 CFLAGS += -DCONFIG_LIBNL20
49 LIBS += -lnl-genl
50 NLLIBNAME = libnl-2.0
51 endif
52
53 ifeq ($(NL3xFOUND),Y)
54 # libnl 3.2 might be found as 3.2 and 3.0
55 NL3FOUND = N
56 CFLAGS += -DCONFIG_LIBNL30
57 LIBS += -lnl-genl-3
58 NLLIBNAME = libnl-3.0
59 endif
60
61 ifeq ($(NL3FOUND),Y)
62 CFLAGS += -DCONFIG_LIBNL30
63 LIBS += -lnl-genl
64 NLLIBNAME = libnl-3.0
65 endif
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 $?
69 ifeq ($(NL31FOUND),Y)
70 CFLAGS += -DCONFIG_LIBNL30
71 LIBS += -lnl-genl
72 NLLIBNAME = libnl-3.1
73 endif
74
75 ifeq ($(NLLIBNAME),)
76 $(error Cannot find development files for any supported version of libnl)
77 endif
78
79 LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME))
80 CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME))
81 endif # NO_PKG_CONFIG
82
83 ifeq ($(V),1)
84 Q=
85 NQ=true
86 else
87 Q=@
88 NQ=echo
89 endif
90
91 all: $(ALL)
92
93 VERSION_OBJS := $(filter-out version.o, $(OBJS))
94
95 version.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
104 iw: $(OBJS)
105 @$(NQ) ' CC ' iw
106 $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw
107
108 check:
109 $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc"
110
111 %.gz: %
112 @$(NQ) ' GZIP' $<
113 $(Q)gzip < $< > $@
114
115 install: iw iw.8.gz
116 @$(NQ) ' INST iw'
117 $(Q)$(MKDIR) $(DESTDIR)$(SBINDIR)
118 $(Q)$(INSTALL) -m 755 iw $(DESTDIR)$(SBINDIR)
119 @$(NQ) ' INST iw.8'
120 $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/
121 $(Q)$(INSTALL) -m 644 iw.8.gz $(DESTDIR)$(MANDIR)/man8/
122
123 clean:
124 $(Q)rm -f iw *.o *~ *.gz version.c *-stamp