2 ## Please check the configurion parameters below
5 ## Installation directory. By default, go in /usr/local.
6 ## Distributions should probably use /, but they probably know better...
11 ## Compiler to use (modify this for cross compile).
13 ## Other tools you need to modify for cross compile (static lib only).
17 ## Uncomment this to build tools using static version of the library.
18 ## Mostly useful for embedded platforms without ldd, or to create
19 ## a local version (non-root).
20 ## Standard distros should comment that option to save space and to
21 ## build libiw.so used by third parties...
24 ## Uncomment this to build without using libm (less efficient).
25 ## This is mostly useful for embedded platforms without maths.
28 ## Uncomment this to strip binary from symbols. This reduce binary size.
29 ## by a few percent but make debug worse...
32 ## Uncomment this to build with only essential functionality.
33 ## This leaves out the less used features and cut in half the tools.
34 ## This is mostly useful for embedded platforms without limited feature needs.
35 # BUILD_WE_ESSENTIAL = y
37 # ***************************************************************************
38 # ***** Most users should not need to change anything beyond this point *****
39 # ***************************************************************************
41 # Version of the Wireless Tools
42 WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
44 # Version of Wireless Extensions.
45 WE_VERSION := $(shell sed -ne "/WE_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
47 # Always use local header for wireless extensions
48 WEXT_HEADER = wireless.$(WE_VERSION).h
52 DYNAMIC=libiw.so.$(WT_VERSION)
53 PROGS= iwconfig iwlist iwpriv iwspy iwgetid iwevent ifrename
54 MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8
57 EXTRAPROGS= macaddr iwmulticall
59 # Composition of the library :
62 # Select which library to build and to link tool with
65 IWLIB_INSTALL=install-static
68 IWLIB_INSTALL=install-dynamic
71 # Standard name for dynamic library so that the dynamic linker can pick it.
72 # We will just create a symbolic link to the real thing.
73 DYNAMIC_LINK= libiw.so
76 INSTALL_DIR= $(PREFIX)/sbin
77 INSTALL_LIB= $(PREFIX)/lib
78 INSTALL_INC= $(PREFIX)/include
79 INSTALL_MAN= $(PREFIX)/man
83 RM_CMD = $(RM) *.BAK *.bak *.d *.o *.so ,* *~ *.a *.orig *.rej *.out
86 # Do we want to build with or without libm ?
89 WELIB_FLAG= -DWE_NOLIBM=y
101 # Do we want to build with only essential functionality ?
102 ifdef BUILD_WE_ESSENTIAL
103 WEDEF_FLAG= -DWE_ESSENTIAL=y
107 CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
108 -Wpointer-arith -Wcast-qual -Winline -I.
109 #CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
111 XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG)
114 # Standard compilation targets
115 all:: $(IWLIB) $(PROGS)
118 $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
120 $(CC) $(XCFLAGS) -c $<
122 $(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<
124 iwconfig: iwconfig.o $(IWLIB)
126 iwlist: iwlist.o $(IWLIB)
128 iwpriv: iwpriv.o $(IWLIB)
130 iwspy: iwspy.o $(IWLIB)
132 iwgetid: iwgetid.o $(IWLIB)
134 iwevent: iwevent.o $(IWLIB)
136 ifrename: ifrename.o $(IWLIB)
138 macaddr: macaddr.o $(IWLIB)
140 # Always do symbol stripping here
141 iwmulticall: iwmulticall.o
142 $(CC) $(LDFLAGS) -Wl,-s $(XCFLAGS) -o $@ $^ $(LIBS)
144 # It's a kind of magic...
146 cp $(WEXT_HEADER) wireless.h
148 # Compilation of the dynamic library
149 $(DYNAMIC): $(OBJS:.o=.so)
150 $(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^
152 # Compilation of the static library
153 $(STATIC): $(OBJS:.o=.so)
158 # Installation : So crude but so effective ;-)
159 # Less crude thanks to many contributions ;-)
160 install:: $(IWLIB_INSTALL) install-bin install-hdr install-man
162 # Install the dynamic library
163 install-dynamic:: $(DYNAMIC)
164 install -m 755 -d $(INSTALL_LIB)
165 install -m 755 $(DYNAMIC) $(INSTALL_LIB)
166 ln -sfn $(DYNAMIC) $(INSTALL_LIB)/$(DYNAMIC_LINK)
167 @echo "*** Don't forget to add $(INSTALL_LIB) to /etc/ld.so.conf, and run ldconfig as root. ***"
168 @$(LDCONFIG) || echo "*** Could not run ldconfig ! ***"
170 # Install the static library
171 install-static:: $(STATIC)
172 install -m 755 -d $(INSTALL_LIB)
173 install -m 644 $(STATIC) $(INSTALL_LIB)
175 # All the binaries. Careful, no dependancy on install-dynamic
177 install -m 755 -d $(INSTALL_DIR)
178 install -m 755 $(PROGS) $(INSTALL_DIR)
180 # Headers to go with the wireless lib (dev)
181 install-hdr:: wireless.h
182 install -m 755 -d $(INSTALL_INC)
183 install -m 644 iwlib.h $(INSTALL_INC)
184 install -m 644 wireless.h $(INSTALL_INC)
186 # How could you live without those manapages ?
188 for lang in . cs fr.*; do \
189 install -m 755 -d $(INSTALL_MAN)/$$lang/man8/; \
190 install -m 644 $$lang/$(MANPAGES8) $(INSTALL_MAN)/$$lang/man8/; \
191 install -m 755 -d $(INSTALL_MAN)/$$lang/man7/; \
192 install -m 644 $$lang/$(MANPAGES7) $(INSTALL_MAN)/$$lang/man7/; \
193 install -m 755 -d $(INSTALL_MAN)/$$lang/man5/; \
194 install -m 644 $$lang/$(MANPAGES5) $(INSTALL_MAN)/$$lang/man5/; \
197 install-iwmulticall:: iwmulticall
198 install -m 755 -d $(INSTALL_DIR)
199 install -m 755 $< $(INSTALL_DIR)/iwconfig
200 ( cd $(INSTALL_DIR) ; \
201 ln -f -s iwconfig iwlist ; \
202 ln -f -s iwconfig iwspy ; \
203 ln -f -s iwconfig iwpriv ; \
204 ln -f -s iwconfig iwgetid )
211 $(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS) libiw* wireless.h
214 for f in $(PROGS); do \
215 $(RM) $(INSTALL_DIR)/$$f; \
217 $(RM) $(INSTALL_LIB)/$(STATIC)
218 $(RM) $(INSTALL_LIB)/$(DYNAMIC)
219 $(RM) $(INSTALL_LIB)/$(DYNAMIC_LINK)
220 $(RM) $(INSTALL_INC)/iwlib.h
221 $(RM) $(INSTALL_INC)/wireless.h
222 for lang in . cs fr.*; do \
223 for f in $(MANPAGES8); do \
224 $(RM) $(INSTALL_MAN)/$$lang/man8/$$f; \
226 for f in $(MANPAGES7); do \
227 $(RM) $(INSTALL_MAN)/$$lang/man7/$$f; \
229 for f in $(MANPAGES5); do \
230 $(RM) $(INSTALL_MAN)/$$lang/man5/$$f; \
234 # Include dependancies