]> git.ipfire.org Git - thirdparty/iw.git/blob - Makefile
iw: fix some scan code indentation
[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 \
14 -Werror-implicit-function-declaration -Wsign-compare
15
16 OBJS = iw.o genl.o event.o info.o phy.o \
17 interface.o ibss.o station.o survey.o util.o ocb.o \
18 mesh.o mpath.o mpp.o scan.o reg.o version.o \
19 reason.o status.o connect.o link.o offch.o ps.o cqm.o \
20 bitrate.o wowlan.o coalesce.o roc.o p2p.o vendor.o mgmt.o \
21 ap.o
22 OBJS += sections.o
23
24 OBJS-$(HWSIM) += hwsim.o
25
26 OBJS += $(OBJS-y) $(OBJS-Y)
27
28 ALL = iw
29
30 ifeq ($(NO_PKG_CONFIG),)
31 NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y)
32 ifneq ($(NL3xFOUND),Y)
33 NL31FOUND := $(shell $(PKG_CONFIG) --exact-version=3.1 libnl-3.1 && echo Y)
34 ifneq ($(NL31FOUND),Y)
35 NL3FOUND := $(shell $(PKG_CONFIG) --atleast-version=3 libnl-3.0 && echo Y)
36 ifneq ($(NL3FOUND),Y)
37 NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y)
38 ifneq ($(NL2FOUND),Y)
39 NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y)
40 endif
41 endif
42 endif
43 endif
44
45 ifeq ($(NL1FOUND),Y)
46 NLLIBNAME = libnl-1
47 endif
48
49 ifeq ($(NL2FOUND),Y)
50 CFLAGS += -DCONFIG_LIBNL20
51 LIBS += -lnl-genl
52 NLLIBNAME = libnl-2.0
53 endif
54
55 ifeq ($(NL3xFOUND),Y)
56 # libnl 3.2 might be found as 3.2 and 3.0
57 NL3FOUND = N
58 CFLAGS += -DCONFIG_LIBNL30
59 LIBS += -lnl-genl-3
60 NLLIBNAME = libnl-3.0
61 endif
62
63 ifeq ($(NL3FOUND),Y)
64 CFLAGS += -DCONFIG_LIBNL30
65 LIBS += -lnl-genl
66 NLLIBNAME = libnl-3.0
67 endif
68
69 # nl-3.1 has a broken libnl-gnl-3.1.pc file
70 # as show by pkg-config --debug --libs --cflags --exact-version=3.1 libnl-genl-3.1;echo $?
71 ifeq ($(NL31FOUND),Y)
72 CFLAGS += -DCONFIG_LIBNL30
73 LIBS += -lnl-genl
74 NLLIBNAME = libnl-3.1
75 endif
76
77 ifeq ($(NLLIBNAME),)
78 $(error Cannot find development files for any supported version of libnl)
79 endif
80
81 LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME))
82 CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME))
83 endif # NO_PKG_CONFIG
84
85 ifeq ($(V),1)
86 Q=
87 NQ=true
88 else
89 Q=@
90 NQ=echo
91 endif
92
93 all: $(ALL)
94
95 VERSION_OBJS := $(filter-out version.o, $(OBJS))
96
97 version.c: version.sh $(patsubst %.o,%.c,$(VERSION_OBJS)) nl80211.h iw.h Makefile \
98 $(wildcard .git/index .git/refs/tags)
99 @$(NQ) ' GEN ' $@
100 $(Q)./version.sh $@
101
102 %.o: %.c iw.h nl80211.h
103 @$(NQ) ' CC ' $@
104 $(Q)$(CC) $(CFLAGS) -c -o $@ $<
105
106 ifeq ($(IW_ANDROID_BUILD),)
107 iw: $(OBJS)
108 @$(NQ) ' CC ' iw
109 $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw
110 endif
111
112 check:
113 $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc"
114
115 %.gz: %
116 @$(NQ) ' GZIP' $<
117 $(Q)gzip < $< > $@
118
119 install: iw iw.8.gz
120 @$(NQ) ' INST iw'
121 $(Q)$(MKDIR) $(DESTDIR)$(SBINDIR)
122 $(Q)$(INSTALL) -m 755 iw $(DESTDIR)$(SBINDIR)
123 @$(NQ) ' INST iw.8'
124 $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/
125 $(Q)$(INSTALL) -m 644 iw.8.gz $(DESTDIR)$(MANDIR)/man8/
126
127 clean:
128 $(Q)rm -f iw *.o *~ *.gz version.c *-stamp