X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=Makefile;h=e61825ecc766b2db8ec064770c4d5662aca3542c;hb=96fa73c7564fa7eba89cd78a24f20acd68d2f55f;hp=ae013338e361c07c6891b75e09eca1a4376bb7d5;hpb=9c8d84fb70979331bd7d19b45ec3b10bf76bd46e;p=thirdparty%2Fiw.git diff --git a/Makefile b/Makefile index ae01333..e61825e 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,86 @@ --include .config - MAKEFLAGS += --no-print-directory -INSTALL ?= install PREFIX ?= /usr +SBINDIR ?= $(PREFIX)/sbin +MANDIR ?= $(PREFIX)/share/man +PKG_CONFIG ?= pkg-config + +MKDIR ?= mkdir -p +INSTALL ?= install CC ?= "gcc" -CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -CFLAGS += -I/lib/modules/`uname -r`/source/include -CFLAGS += -O2 -g -LDFLAGS += -lnl -OBJS = iw.o info.o phy.o interface.o station.o util.o mpath.o reg.o +CFLAGS ?= -O2 -g +CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common \ + -Werror-implicit-function-declaration -Wsign-compare + +OBJS = iw.o genl.o event.o info.o phy.o \ + interface.o ibss.o station.o survey.o util.o ocb.o \ + mesh.o mpath.o mpp.o scan.o reg.o version.o \ + reason.o status.o connect.o link.o offch.o ps.o cqm.o \ + bitrate.o wowlan.o coalesce.o roc.o p2p.o vendor.o +OBJS += sections.o + +OBJS-$(HWSIM) += hwsim.o + +OBJS += $(OBJS-y) $(OBJS-Y) + ALL = iw +ifeq ($(NO_PKG_CONFIG),) +NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y) +ifneq ($(NL3xFOUND),Y) +NL31FOUND := $(shell $(PKG_CONFIG) --exact-version=3.1 libnl-3.1 && echo Y) +ifneq ($(NL31FOUND),Y) +NL3FOUND := $(shell $(PKG_CONFIG) --atleast-version=3 libnl-3.0 && echo Y) +ifneq ($(NL3FOUND),Y) +NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y) +ifneq ($(NL2FOUND),Y) +NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y) +endif +endif +endif +endif + +ifeq ($(NL1FOUND),Y) +NLLIBNAME = libnl-1 +endif + +ifeq ($(NL2FOUND),Y) +CFLAGS += -DCONFIG_LIBNL20 +LIBS += -lnl-genl +NLLIBNAME = libnl-2.0 +endif + +ifeq ($(NL3xFOUND),Y) +# libnl 3.2 might be found as 3.2 and 3.0 +NL3FOUND = N +CFLAGS += -DCONFIG_LIBNL30 +LIBS += -lnl-genl-3 +NLLIBNAME = libnl-3.0 +endif + +ifeq ($(NL3FOUND),Y) +CFLAGS += -DCONFIG_LIBNL30 +LIBS += -lnl-genl +NLLIBNAME = libnl-3.0 +endif + +# nl-3.1 has a broken libnl-gnl-3.1.pc file +# as show by pkg-config --debug --libs --cflags --exact-version=3.1 libnl-genl-3.1;echo $? +ifeq ($(NL31FOUND),Y) +CFLAGS += -DCONFIG_LIBNL30 +LIBS += -lnl-genl +NLLIBNAME = libnl-3.1 +endif + +ifeq ($(NLLIBNAME),) +$(error Cannot find development files for any supported version of libnl) +endif + +LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME)) +CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME)) +endif # NO_PKG_CONFIG + ifeq ($(V),1) Q= NQ=true @@ -23,17 +91,22 @@ endif all: $(ALL) -version.h: version.sh - @$(NQ) ' GEN version.h' - $(Q)./version.sh +VERSION_OBJS := $(filter-out version.o, $(OBJS)) + +version.c: version.sh $(patsubst %.o,%.c,$(VERSION_OBJS)) nl80211.h iw.h Makefile \ + $(wildcard .git/index .git/refs/tags) + @$(NQ) ' GEN ' $@ + $(Q)./version.sh $@ -%.o: %.c iw.h version.h +%.o: %.c iw.h nl80211.h @$(NQ) ' CC ' $@ $(Q)$(CC) $(CFLAGS) -c -o $@ $< +ifeq ($(IW_ANDROID_BUILD),) iw: $(OBJS) @$(NQ) ' CC ' iw - $(Q)$(CC) $(LDFLAGS) $(OBJS) -o iw + $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw +endif check: $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc" @@ -44,9 +117,11 @@ check: install: iw iw.8.gz @$(NQ) ' INST iw' - $(Q)$(INSTALL) -o root -g root -t $(PREFIX)/bin iw + $(Q)$(MKDIR) $(DESTDIR)$(SBINDIR) + $(Q)$(INSTALL) -m 755 iw $(DESTDIR)$(SBINDIR) @$(NQ) ' INST iw.8' - $(Q)$(INSTALL) -o root -g root -t $(PREFIX)/share/man/man8/ iw.8.gz + $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/ + $(Q)$(INSTALL) -m 644 iw.8.gz $(DESTDIR)$(MANDIR)/man8/ clean: - $(Q)rm -f iw *.o *~ *.gz version.h + $(Q)rm -f iw *.o *~ *.gz version.c *-stamp