X-Git-Url: http://git.osdn.net/view?p=android-x86%2Fexternal-wireless-tools.git;a=blobdiff_plain;f=wireless_tools%2FMakefile;h=bc4fbd6309a18b55e935d4c47f3783416223c25d;hp=236acbbf6ed52564cbd5dd6c35a5e91697f93a5d;hb=9ec0f62f146639f364238cbb7821ca47222e3bb9;hpb=fb1188c580d9ff90cc4d80d2bedb03e86b463057 diff --git a/wireless_tools/Makefile b/wireless_tools/Makefile index 236acbb..bc4fbd6 100644 --- a/wireless_tools/Makefile +++ b/wireless_tools/Makefile @@ -1,104 +1,219 @@ -# -# Basic and crude Makefile... -# +## +## Please check the configurion parameters below +## -# Targets to build -STATIC=libiw.a -DYNAMIC=libiw.so.22 -PROGS= iwconfig iwlist iwpriv iwspy iwgetid +## Installation directory. By default, go in /usr/local +## Distributions should probably use /, but they probably know better... +ifndef PREFIX + PREFIX = /usr/local +endif -# Composition of the library : -OBJS = iwlib.o +## Compiler to use (modify this for cross compile) +CC = gcc +## Other tools you need to modify for cross compile (static lib only) +AR = ar +RANLIB = ranlib -# Define if tools should be built using static or dynamic version of the lib -IWLIBS=$(OBJS) -#IWLIBS=-liw +## Uncomment this to build tools using static version of the library +## Mostly useful for embedded platforms without ldd, or to create +## a local version (non-root). +# BUILD_STATIC = y -# Installation directory. By default, go in local. -# Distributions should probably use /usr/sbin, but they probably know better... -INSTALL_DIR= /usr/local/sbin -INSTALL_LIB= /usr/local/lib -INSTALL_INC= /usr/local/include +## Uncomment this to build without using libm (less efficient) +## This is mostly useful for embedded platforms without maths. +# BUILD_NOLIBM = y -# This is our header selection. Try to hide the mess and the misery :-( -# Please choose *only one* of the define... +## Uncomment this to strip binary from symbols. This reduce binary size +## by a few percent but make debug worse... +# BUILD_STRIPPING = y -# Kernel headers 2.4.X + Glibc 2.2 - Mandrake 8.0, Debian 2.3, RH 7.1 -#HEADERS= -DGLIBC22_HEADERS +# *************************************************************************** +# ***** Most users should not need to change anything beyond this point ***** +# *************************************************************************** -# Kernel headers 2.0.X + Glibc 2.0 - Debian 2.0, RH 5 -# Kernel headers 2.2.X + Glibc 2.1 - Debian 2.2, RH 6.1 -# Kernel headers 2.4.X + Glibc 2.1 - Debian 2.2 upgraded, RH 7.0 -HEADERS= -DGLIBC_HEADERS +# Version of the Wireless Tools +WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h ) -# Kernel headers 2.2.X + Glibc 2.0 - Debian 2.1 -#HEADERS= -DKLUDGE_HEADERS +# Version of Wireless Extensions. +WE_VERSION := $(shell sed -ne "/WE_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h ) -# Kernel headers 2.0.X + libc5 - old systems -#HEADERS= -DLIBC5_HEADERS +# Always use local header for wireless extensions +WEXT_HEADER = wireless.$(WE_VERSION).h -# Use private copy of Wireless Extension definition instead of the -# system wide one in /usr/include/linux. Use with care. -# Can be used to create multiple versions of the tools on the same system -# for multiple kernels or get around broken distributions. -#WE_HEADER= -DPRIVATE_WE_HEADER -WE_HEADER= +# Targets to build +STATIC=libiw.a +DYNAMIC=libiw.so.$(WT_VERSION) +PROGS= iwconfig iwlist iwpriv iwspy iwgetid iwevent ifrename +MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8 +MANPAGES7=wireless.7 +MANPAGES5=iftab.5 +EXTRAPROGS= macaddr iwmulticall -# ------------ End of config -------------- +# Composition of the library : +OBJS = iwlib.o -CC = gcc +# Select which library to build and to link tool with +ifdef BUILD_STATIC + IWLIB=$(STATIC) + IWLIB_INSTALL=install-static +else + IWLIB=$(DYNAMIC) + IWLIB_INSTALL=install-dynamic +endif + +# Standard name for dynamic library so that the dynamic linker can pick it. +# We will just create a symbolic link to the real thing. +DYNAMIC_LINK= libiw.so + +# Install directories +INSTALL_DIR= $(PREFIX)/sbin/ +INSTALL_LIB= $(PREFIX)/lib/ +INSTALL_INC= $(PREFIX)/include/ +INSTALL_MAN= $(PREFIX)/man/ + +# Various commands RM = rm -f +RM_CMD = $(RM) *.BAK *.bak *.d *.o *.so ,* *~ *.a *.orig *.rej *.out +LDCONFIG = ldconfig + +# Do we want to build with or without libm ? +ifdef BUILD_NOLIBM + LIBS= + WELIB_FLAG= -DWE_NOLIBM=y +else + LIBS= -lm +endif + +# Stripping or not ? +ifdef BUILD_STRIPPING + STRIPFLAGS= -Wl,-s +else + STRIPFLAGS= +endif + +# Other flags +CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \ + -Wpointer-arith -Wcast-qual -Winline -I. +#CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I. +DEPFLAGS=-MMD +XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) +PICFLAG=-fPIC -RM_CMD = $(RM) *.BAK *.bak *.o ,* *~ *.a +# Standard compilation targets +all:: $(IWLIB) $(PROGS) -CFLAGS=-O2 -Wall $(HEADERS) $(WE_HEADER) +%: %.o + $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) +%.o: %.c wireless.h + $(CC) $(XCFLAGS) -c $< +%.so: %.c wireless.h + $(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $< -LIBS=$(IWLIBS) -lm +iwconfig: iwconfig.o $(IWLIB) -all:: $(STATIC) $(DYNAMIC) $(PROGS) +iwlist: iwlist.o $(IWLIB) -.c.o: - $(CC) $(CFLAGS) -c $< +iwpriv: iwpriv.o $(IWLIB) -iwconfig: iwconfig.o $(OBJS) - $(CC) $(CFLAGS) -o $@ $< $(LIBS) +iwspy: iwspy.o $(IWLIB) -iwlist: iwlist.o $(OBJS) - $(CC) $(CFLAGS) -o $@ $< $(LIBS) +iwgetid: iwgetid.o $(IWLIB) -iwpriv: iwpriv.o $(OBJS) - $(CC) $(CFLAGS) -o $@ $< $(LIBS) +iwevent: iwevent.o $(IWLIB) -iwspy: iwspy.o $(OBJS) - $(CC) $(CFLAGS) -o $@ $< $(LIBS) +ifrename: ifrename.o $(IWLIB) -iwgetid: iwgetid.o - $(CC) $(CFLAGS) -o $@ $^ +macaddr: macaddr.o $(IWLIB) + +# Always do symbol stripping here +iwmulticall: iwmulticall.o + $(CC) $(LDFLAGS) -Wl,-s $(XCFLAGS) -o $@ $^ $(LIBS) + +# It's a kind of magic... +wireless.h: + cp $(WEXT_HEADER) wireless.h # Compilation of the dynamic library -libiw.so.22: $(OBJS) - $(CC) -O2 -shared -o $@ -Wl,-soname,$@ -lm -lc $^ +$(DYNAMIC): $(OBJS:.o=.so) + $(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^ # Compilation of the static library -libiw.a: $(OBJS) +$(STATIC): $(OBJS:.o=.so) $(RM) $@ - ar cru $@ $^ - ranlib $@ - -# So crude but so effective ;-) -install:: - cp $(PROGS) $(INSTALL_DIR) - cp $(STATIC) $(DYNAMIC) $(INSTALL_LIB) - echo "Don't forget to fix you /etc/ld.so.conf and run ldconfig." - cp iwlib.h $(INSTALL_INC) + $(AR) cru $@ $^ + $(RANLIB) $@ + +# Installation : So crude but so effective ;-) +# Less crude thanks to many contributions ;-) +install:: $(IWLIB_INSTALL) install-bin install-hdr install-man + +# Install the dynamic library +install-dynamic:: $(DYNAMIC) + install -m 755 -d $(INSTALL_LIB) + install -m 755 $(DYNAMIC) $(INSTALL_LIB) + ln -sfn $(DYNAMIC) $(INSTALL_LIB)/$(DYNAMIC_LINK) + @echo "*** Don't forget to add $(INSTALL_LIB) to /etc/ld.so.conf, and run ldconfig as root. ***" + @$(LDCONFIG) || echo "*** Could not run ldconfig ! ***" + +# Install the static library +install-static:: $(STATIC) + install -m 755 -d $(INSTALL_LIB) + install -m 644 $(STATIC) $(INSTALL_LIB) + +# All the binaries. Careful, no dependancy on install-dynamic +install-bin:: all + install -m 755 -d $(INSTALL_DIR) + install -m 755 $(PROGS) $(INSTALL_DIR) + +# Headers to go with the wireless lib (dev) +install-hdr:: wireless.h + install -m 755 -d $(INSTALL_INC) + install -m 644 iwlib.h $(INSTALL_INC) + install -m 644 wireless.h $(INSTALL_INC) + +# How could you live without those manapages ? +install-man:: + install -m 755 -d $(INSTALL_MAN)/man8/ + install -m 644 $(MANPAGES8) $(INSTALL_MAN)/man8/ + install -m 755 -d $(INSTALL_MAN)/man7/ + install -m 644 $(MANPAGES7) $(INSTALL_MAN)/man7/ + install -m 755 -d $(INSTALL_MAN)/man5/ + install -m 644 $(MANPAGES5) $(INSTALL_MAN)/man5/ + +install-iwmulticall:: iwmulticall + install -m 755 -d $(INSTALL_DIR) + install -m 755 $< $(INSTALL_DIR)/iwconfig + ( cd $(INSTALL_DIR) ; \ + ln -f -s iwconfig iwlist ; \ + ln -f -s iwconfig iwspy ; \ + ln -f -s iwconfig iwpriv ; \ + ln -f -s iwconfig iwgetid ) clean:: $(RM_CMD) realclean:: $(RM_CMD) - $(RM) $(STATIC) $(DYNAMIC) $(PROGS) - -depend:: - makedepend -s "# DO NOT DELETE" -- $(INCLUDES) -- $(SRCS) -# DO NOT DELETE + $(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS) libiw* wireless.h + +uninstall:: + for f in $(PROGS); do \ + $(RM) $(INSTALL_DIR)/$$f; \ + done + $(RM) $(INSTALL_LIB)/$(STATIC) + $(RM) $(INSTALL_LIB)/$(DYNAMIC) + $(RM) $(INSTALL_LIB)/$(DYNAMIC_LINK) + $(RM) $(INSTALL_INC)/iwlib.h + $(RM) $(INSTALL_INC)/wireless.h + for f in $(MANPAGES8); do \ + $(RM) $(INSTALL_MAN)/man8/$$f; \ + done + for f in $(MANPAGES7); do \ + $(RM) $(INSTALL_MAN)/man7/$$f; \ + done + for f in $(MANPAGES5); do \ + $(RM) $(INSTALL_MAN)/man5/$$f; \ + done + +# Include dependancies +-include *.d