📄 makefile
字号:
#### Please check the configurion parameters below#### Installation directory. By default, go in /usr/local## Distributions should probably use /, but they probably know better...ifndef PREFIX PREFIX = /usr/localendif## Compiler to use (modify this for cross compile)CC = gcc## Other tools you need to modify for cross compile (static lib only)AR = arRANLIB = ranlib## 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## Uncomment this to build without using libm (less efficient)## This is mostly useful for embedded platforms without maths.# BUILD_NOLIBM = y## Uncomment this to strip binary from symbols. This reduce binary size## by a few percent but make debug worse...# BUILD_STRIPPING = y# ***************************************************************************# ***** Most users should not need to change anything beyond this point *****# ***************************************************************************# Version of the Wireless ToolsWT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )# Version of Wireless Extensions.WE_VERSION := $(shell sed -ne "/WE_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )# Always use local header for wireless extensionsWEXT_HEADER = wireless.$(WE_VERSION).h# Targets to buildSTATIC=libiw.aDYNAMIC=libiw.so.$(WT_VERSION)PROGS= iwconfig iwlist iwpriv iwspy iwgetid iwevent ifrenameMANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8MANPAGES7=wireless.7MANPAGES5=iftab.5EXTRAPROGS= macaddr iwmulticall# Composition of the library :OBJS = iwlib.o# Select which library to build and to link tool withifdef BUILD_STATIC IWLIB=$(STATIC) IWLIB_INSTALL=install-staticelse IWLIB=$(DYNAMIC) IWLIB_INSTALL=install-dynamicendif# 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 directoriesINSTALL_DIR= $(PREFIX)/sbin/INSTALL_LIB= $(PREFIX)/lib/INSTALL_INC= $(PREFIX)/include/INSTALL_MAN= $(PREFIX)/man/# Various commandsRM = rm -fRM_CMD = $(RM) *.BAK *.bak *.d *.o *.so ,* *~ *.a *.orig *.rej *.outLDCONFIG = ldconfig# Do we want to build with or without libm ?ifdef BUILD_NOLIBM LIBS= WELIB_FLAG= -DWE_NOLIBM=yelse LIBS= -lmendif# Stripping or not ?ifdef BUILD_STRIPPING STRIPFLAGS= -Wl,-selse STRIPFLAGS=endif# Other flagsCFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \ -Wpointer-arith -Wcast-qual -Winline -I.#CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.DEPFLAGS=-MMDXCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG)PICFLAG=-fPIC# Standard compilation targetsall:: $(IWLIB) $(PROGS)%: %.o $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)%.o: %.c wireless.h $(CC) $(XCFLAGS) -c $<%.so: %.c wireless.h $(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<iwconfig: iwconfig.o $(IWLIB)iwlist: iwlist.o $(IWLIB)iwpriv: iwpriv.o $(IWLIB)iwspy: iwspy.o $(IWLIB)iwgetid: iwgetid.o $(IWLIB)iwevent: iwevent.o $(IWLIB)ifrename: ifrename.o $(IWLIB)macaddr: macaddr.o $(IWLIB)# Always do symbol stripping hereiwmulticall: 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$(DYNAMIC): $(OBJS:.o=.so) $(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^# Compilation of the static library$(STATIC): $(OBJS:.o=.so) $(RM) $@ $(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 libraryinstall-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 libraryinstall-static:: $(STATIC) install -m 755 -d $(INSTALL_LIB) install -m 644 $(STATIC) $(INSTALL_LIB)# All the binaries. Careful, no dependancy on install-dynamicinstall-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) $(EXTRAPROGS) libiw* wireless.huninstall:: 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -