• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1-include .config
2
3MAKEFLAGS += --no-print-directory
4
5PREFIX ?= /usr
6BINDIR ?= $(PREFIX)/bin
7MANDIR ?= $(PREFIX)/share/man
8
9MKDIR ?= mkdir -p
10INSTALL ?= install
11CC ?= "gcc"
12PKG_CONFIG ?= pkg-config
13
14CFLAGS ?= -O2 -g
15CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
16
17OBJS = iwcap.o
18ALL = iwcap
19
20NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y)
21NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y)
22
23ifeq ($(NL1FOUND),Y)
24NLLIBNAME = libnl-1
25endif
26
27ifeq ($(NL2FOUND),Y)
28CFLAGS += -DCONFIG_LIBNL20
29LIBS += -lnl-genl
30NLLIBNAME = libnl-2.0
31endif
32
33ifeq ($(NLLIBNAME),)
34$(error Cannot find development files for any supported version of libnl)
35endif
36
37LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME))
38CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME))
39
40ifeq ($(V),1)
41Q=
42NQ=true
43else
44Q=@
45NQ=echo
46endif
47
48all: version_check $(ALL)
49
50version_check:
51ifeq ($(NL2FOUND),Y)
52else
53ifeq ($(NL1FOUND),Y)
54else
55	$(error No libnl found)
56endif
57endif
58
59
60%.o: %.c nl80211.h
61	@$(NQ) ' CC  ' $@
62	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
63
64iwcap:	$(OBJS)
65	@$(NQ) ' CC  ' iwcap
66	$(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iwcap
67
68check:
69	$(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc"
70
71%.gz: %
72	@$(NQ) ' GZIP' $<
73	$(Q)gzip < $< > $@
74
75install: iwcap
76	@$(NQ) ' INST iwcap'
77	$(Q)$(MKDIR) $(DESTDIR)$(BINDIR)
78	$(Q)$(INSTALL) -m 755 -t $(DESTDIR)$(BINDIR) iwcap
79
80clean:
81	$(Q)rm -f iwcap *.o *~ *.gz version.c *-stamp
82