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