5 kx ##
5 kx ## Please check the configurion parameters below
5 kx ##
5 kx
5 kx ## Installation directory. By default, go in /usr/local.
5 kx ## Distributions should probably use /, but they probably know better...
5 kx ifndef PREFIX
5 kx PREFIX = /usr/local
5 kx endif
5 kx
5 kx ## Compiler to use (modify this for cross compile).
5 kx #CC = gcc
5 kx ## Other tools you need to modify for cross compile (static lib only).
5 kx #AR = ar
5 kx #RANLIB = ranlib
5 kx
5 kx ## Uncomment this to build tools using static version of the library.
5 kx ## Mostly useful for embedded platforms without ldd, or to create
5 kx ## a local version (non-root).
5 kx ## Standard distros should comment that option to save space and to
5 kx ## build libiw.so used by third parties...
5 kx BUILD_STATIC = y
5 kx
5 kx ## Uncomment this to build without using libm (less efficient).
5 kx ## This is mostly useful for embedded platforms without maths.
5 kx # BUILD_NOLIBM = y
5 kx
5 kx ## Uncomment this to strip binary from symbols. This reduce binary size.
5 kx ## by a few percent but make debug worse...
5 kx # BUILD_STRIPPING = y
5 kx
5 kx ## Uncomment this to build with only essential functionality.
5 kx ## This leaves out the less used features and cut in half the tools.
5 kx ## This is mostly useful for embedded platforms without limited feature needs.
5 kx # BUILD_WE_ESSENTIAL = y
5 kx
5 kx # ***************************************************************************
5 kx # ***** Most users should not need to change anything beyond this point *****
5 kx # ***************************************************************************
5 kx
5 kx # Version of the Wireless Tools
5 kx WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
5 kx
5 kx # Version of Wireless Extensions.
5 kx WE_VERSION := $(shell sed -ne "/WE_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
5 kx
5 kx # Always use local header for wireless extensions
5 kx WEXT_HEADER = wireless.$(WE_VERSION).h
5 kx
5 kx # Targets to build
5 kx STATIC=libiw.a
5 kx DYNAMIC=libiw.so.$(WT_VERSION)
5 kx PROGS= iwconfig iwlist iwpriv iwspy iwgetid iwevent ifrename
5 kx MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8
5 kx MANPAGES7=wireless.7
5 kx MANPAGES5=iftab.5
5 kx EXTRAPROGS= macaddr iwmulticall
5 kx
5 kx # Composition of the library :
5 kx OBJS = iwlib.o
5 kx
5 kx # Select which library to build and to link tool with
5 kx ifdef BUILD_STATIC
5 kx IWLIB=$(STATIC)
5 kx IWLIB_INSTALL=install-static
5 kx else
5 kx IWLIB=$(DYNAMIC)
5 kx IWLIB_INSTALL=install-dynamic
5 kx endif
5 kx
5 kx # Standard name for dynamic library so that the dynamic linker can pick it.
5 kx # We will just create a symbolic link to the real thing.
5 kx DYNAMIC_LINK= libiw.so
5 kx
5 kx # Install directories
5 kx INSTALL_DIR= $(PREFIX)/sbin
5 kx INSTALL_LIB= $(PREFIX)/lib
5 kx INSTALL_INC= $(PREFIX)/include
5 kx INSTALL_MAN= $(PREFIX)/man
5 kx
5 kx # Various commands
5 kx RM = rm -f
5 kx RM_CMD = $(RM) *.BAK *.bak *.d *.o *.so ,* *~ *.a *.orig *.rej *.out
5 kx LDCONFIG = ldconfig
5 kx
5 kx # Do we want to build with or without libm ?
5 kx ifdef BUILD_NOLIBM
5 kx LIBS=
5 kx WELIB_FLAG= -DWE_NOLIBM=y
5 kx else
5 kx LIBS= -lm
5 kx endif
5 kx
5 kx # Stripping or not ?
5 kx ifdef BUILD_STRIPPING
5 kx STRIPFLAGS= -Wl,-s
5 kx else
5 kx STRIPFLAGS=
5 kx endif
5 kx
5 kx # Do we want to build with only essential functionality ?
5 kx ifdef BUILD_WE_ESSENTIAL
5 kx WEDEF_FLAG= -DWE_ESSENTIAL=y
5 kx endif
5 kx
5 kx # Other flags
5 kx CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
5 kx -Wpointer-arith -Wcast-qual -Wimplicit-fallthrough=0 -I.
5 kx #CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
5 kx DEPFLAGS=-MMD
5 kx XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG)
5 kx PICFLAG=-fPIC
5 kx
5 kx # Standard compilation targets
5 kx all:: $(IWLIB) $(PROGS)
5 kx
5 kx %: %.o
5 kx $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
5 kx %.o: %.c wireless.h
5 kx $(CC) $(XCFLAGS) -c $<
5 kx %.so: %.c wireless.h
5 kx $(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<
5 kx
5 kx iwconfig: iwconfig.o $(IWLIB)
5 kx
5 kx iwlist: iwlist.o $(IWLIB)
5 kx
5 kx iwpriv: iwpriv.o $(IWLIB)
5 kx
5 kx iwspy: iwspy.o $(IWLIB)
5 kx
5 kx iwgetid: iwgetid.o $(IWLIB)
5 kx
5 kx iwevent: iwevent.o $(IWLIB)
5 kx
5 kx ifrename: ifrename.o $(IWLIB)
5 kx
5 kx macaddr: macaddr.o $(IWLIB)
5 kx
5 kx # Always do symbol stripping here
5 kx iwmulticall: iwmulticall.o
5 kx $(CC) $(LDFLAGS) -Wl,-s $(XCFLAGS) -o $@ $^ $(LIBS)
5 kx
5 kx # It's a kind of magic...
5 kx wireless.h:
5 kx cp $(WEXT_HEADER) wireless.h
5 kx
5 kx # Compilation of the dynamic library
5 kx $(DYNAMIC): $(OBJS:.o=.so)
5 kx $(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^
5 kx
5 kx # Compilation of the static library
5 kx $(STATIC): $(OBJS:.o=.so)
5 kx $(RM) $@
5 kx $(AR) cru $@ $^
5 kx $(RANLIB) $@
5 kx
5 kx # Installation : So crude but so effective ;-)
5 kx # Less crude thanks to many contributions ;-)
5 kx install:: $(IWLIB_INSTALL) install-bin install-hdr install-man
5 kx
5 kx # Install the dynamic library
5 kx install-dynamic:: $(DYNAMIC)
5 kx install -m 755 -d $(INSTALL_LIB)
5 kx install -m 755 $(DYNAMIC) $(INSTALL_LIB)
5 kx ln -sfn $(DYNAMIC) $(INSTALL_LIB)/$(DYNAMIC_LINK)
5 kx @echo "*** Don't forget to add $(INSTALL_LIB) to /etc/ld.so.conf, and run ldconfig as root. ***"
5 kx # @$(LDCONFIG) || echo "*** Could not run ldconfig ! ***"
5 kx
5 kx # Install the static library
5 kx install-static:: $(STATIC)
5 kx install -m 755 -d $(INSTALL_LIB)
5 kx install -m 644 $(STATIC) $(INSTALL_LIB)
5 kx
5 kx # All the binaries. Careful, no dependancy on install-dynamic
5 kx install-bin:: all
5 kx install -m 755 -d $(INSTALL_DIR)
5 kx install -m 755 $(PROGS) $(INSTALL_DIR)
5 kx
5 kx # Headers to go with the wireless lib (dev)
5 kx install-hdr:: wireless.h
5 kx install -m 755 -d $(INSTALL_INC)
5 kx install -m 644 iwlib.h $(INSTALL_INC)
5 kx install -m 644 wireless.h $(INSTALL_INC)
5 kx
5 kx # How could you live without those manapages ?
5 kx install-man::
5 kx for lang in . cs fr.*; do \
5 kx install -m 755 -d $(INSTALL_MAN)/$$lang/man8/; \
5 kx install -m 644 $$lang/$(MANPAGES8) $(INSTALL_MAN)/$$lang/man8/; \
5 kx install -m 755 -d $(INSTALL_MAN)/$$lang/man7/; \
5 kx install -m 644 $$lang/$(MANPAGES7) $(INSTALL_MAN)/$$lang/man7/; \
5 kx install -m 755 -d $(INSTALL_MAN)/$$lang/man5/; \
5 kx install -m 644 $$lang/$(MANPAGES5) $(INSTALL_MAN)/$$lang/man5/; \
5 kx done
5 kx
5 kx install-iwmulticall:: iwmulticall
5 kx install -m 755 -d $(INSTALL_DIR)
5 kx install -m 755 $< $(INSTALL_DIR)/iwconfig
5 kx ( cd $(INSTALL_DIR) ; \
5 kx ln -f -s iwconfig iwlist ; \
5 kx ln -f -s iwconfig iwspy ; \
5 kx ln -f -s iwconfig iwpriv ; \
5 kx ln -f -s iwconfig iwgetid )
5 kx
5 kx clean::
5 kx $(RM_CMD)
5 kx
5 kx realclean::
5 kx $(RM_CMD)
5 kx $(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS) libiw* wireless.h
5 kx
5 kx uninstall::
5 kx for f in $(PROGS); do \
5 kx $(RM) $(INSTALL_DIR)/$$f; \
5 kx done
5 kx $(RM) $(INSTALL_LIB)/$(STATIC)
5 kx $(RM) $(INSTALL_LIB)/$(DYNAMIC)
5 kx $(RM) $(INSTALL_LIB)/$(DYNAMIC_LINK)
5 kx $(RM) $(INSTALL_INC)/iwlib.h
5 kx $(RM) $(INSTALL_INC)/wireless.h
5 kx for lang in . cs fr.*; do \
5 kx for f in $(MANPAGES8); do \
5 kx $(RM) $(INSTALL_MAN)/$$lang/man8/$$f; \
5 kx done; \
5 kx for f in $(MANPAGES7); do \
5 kx $(RM) $(INSTALL_MAN)/$$lang/man7/$$f; \
5 kx done; \
5 kx for f in $(MANPAGES5); do \
5 kx $(RM) $(INSTALL_MAN)/$$lang/man5/$$f; \
5 kx done; \
5 kx done
5 kx
5 kx # Include dependancies
5 kx -include *.d