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).
22 ## Uncomment this to build without using libm (less efficient).
23 ## This is mostly useful for embedded platforms without maths.
26 ## Uncomment this to strip binary from symbols. This reduce binary size.
27 ## by a few percent but make debug worse...
30 ## Uncomment this to build with only essential functionality.
31 ## This leaves out the less used features and cut in half the tools.
32 ## This is mostly useful for embedded platforms without limited feature needs.
33 # BUILD_WE_ESSENTIAL = y
35 # ***************************************************************************
36 # ***** Most users should not need to change anything beyond this point *****
37 # ***************************************************************************
39 # Version of the Wireless Tools
40 WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
42 # Version of Wireless Extensions.
43 WE_VERSION := $(shell sed -ne "/WE_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
45 # Always use local header for wireless extensions
46 WEXT_HEADER = wireless.$(WE_VERSION).h
50 DYNAMIC=libiw.so.$(WT_VERSION)
51 PROGS= iwconfig iwlist iwpriv iwspy iwgetid iwevent ifrename
52 MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8
55 EXTRAPROGS= macaddr iwmulticall
57 # Composition of the library :
60 # Select which library to build and to link tool with
63 IWLIB_INSTALL=install-static
66 IWLIB_INSTALL=install-dynamic
69 # Standard name for dynamic library so that the dynamic linker can pick it.
70 # We will just create a symbolic link to the real thing.
71 DYNAMIC_LINK= libiw.so
74 INSTALL_DIR= $(PREFIX)/sbin/
75 INSTALL_LIB= $(PREFIX)/lib/
76 INSTALL_INC= $(PREFIX)/include/
77 INSTALL_MAN= $(PREFIX)/man/
81 RM_CMD = $(RM) *.BAK *.bak *.d *.o *.so ,* *~ *.a *.orig *.rej *.out
84 # Do we want to build with or without libm ?
87 WELIB_FLAG= -DWE_NOLIBM=y
99 # Do we want to build with only essential functionality ?
100 ifdef BUILD_WE_ESSENTIAL
101 WEDEF_FLAG= -DWE_ESSENTIAL=y
105 CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
106 -Wpointer-arith -Wcast-qual -Winline -I.
107 #CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
109 XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG)
112 # Standard compilation targets
113 all:: $(IWLIB) $(PROGS)
116 $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
118 $(CC) $(XCFLAGS) -c $<
120 $(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<
122 iwconfig: iwconfig.o $(IWLIB)
124 iwlist: iwlist.o $(IWLIB)
126 iwpriv: iwpriv.o $(IWLIB)
128 iwspy: iwspy.o $(IWLIB)
130 iwgetid: iwgetid.o $(IWLIB)
132 iwevent: iwevent.o $(IWLIB)
134 ifrename: ifrename.o $(IWLIB)
136 macaddr: macaddr.o $(IWLIB)
138 # Always do symbol stripping here
139 iwmulticall: iwmulticall.o
140 $(CC) $(LDFLAGS) -Wl,-s $(XCFLAGS) -o $@ $^ $(LIBS)
142 # It's a kind of magic...
144 cp $(WEXT_HEADER) wireless.h
146 # Compilation of the dynamic library
147 $(DYNAMIC): $(OBJS:.o=.so)
148 $(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^
150 # Compilation of the static library
151 $(STATIC): $(OBJS:.o=.so)
156 # Installation : So crude but so effective ;-)
157 # Less crude thanks to many contributions ;-)
158 install:: $(IWLIB_INSTALL) install-bin install-hdr install-man
160 # Install the dynamic library
161 install-dynamic:: $(DYNAMIC)
162 install -m 755 -d $(INSTALL_LIB)
163 install -m 755 $(DYNAMIC) $(INSTALL_LIB)
164 ln -sfn $(DYNAMIC) $(INSTALL_LIB)/$(DYNAMIC_LINK)
165 @echo "*** Don't forget to add $(INSTALL_LIB) to /etc/ld.so.conf, and run ldconfig as root. ***"
166 @$(LDCONFIG) || echo "*** Could not run ldconfig ! ***"
168 # Install the static library
169 install-static:: $(STATIC)
170 install -m 755 -d $(INSTALL_LIB)
171 install -m 644 $(STATIC) $(INSTALL_LIB)
173 # All the binaries. Careful, no dependancy on install-dynamic
175 install -m 755 -d $(INSTALL_DIR)
176 install -m 755 $(PROGS) $(INSTALL_DIR)
178 # Headers to go with the wireless lib (dev)
179 install-hdr:: wireless.h
180 install -m 755 -d $(INSTALL_INC)
181 install -m 644 iwlib.h $(INSTALL_INC)
182 install -m 644 wireless.h $(INSTALL_INC)
184 # How could you live without those manapages ?
186 install -m 755 -d $(INSTALL_MAN)/man8/
187 install -m 644 $(MANPAGES8) $(INSTALL_MAN)/man8/
188 install -m 755 -d $(INSTALL_MAN)/man7/
189 install -m 644 $(MANPAGES7) $(INSTALL_MAN)/man7/
190 install -m 755 -d $(INSTALL_MAN)/man5/
191 install -m 644 $(MANPAGES5) $(INSTALL_MAN)/man5/
193 install-iwmulticall:: iwmulticall
194 install -m 755 -d $(INSTALL_DIR)
195 install -m 755 $< $(INSTALL_DIR)/iwconfig
196 ( cd $(INSTALL_DIR) ; \
197 ln -f -s iwconfig iwlist ; \
198 ln -f -s iwconfig iwspy ; \
199 ln -f -s iwconfig iwpriv ; \
200 ln -f -s iwconfig iwgetid )
207 $(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS) libiw* wireless.h
210 for f in $(PROGS); do \
211 $(RM) $(INSTALL_DIR)/$$f; \
213 $(RM) $(INSTALL_LIB)/$(STATIC)
214 $(RM) $(INSTALL_LIB)/$(DYNAMIC)
215 $(RM) $(INSTALL_LIB)/$(DYNAMIC_LINK)
216 $(RM) $(INSTALL_INC)/iwlib.h
217 $(RM) $(INSTALL_INC)/wireless.h
218 for f in $(MANPAGES8); do \
219 $(RM) $(INSTALL_MAN)/man8/$$f; \
221 for f in $(MANPAGES7); do \
222 $(RM) $(INSTALL_MAN)/man7/$$f; \
224 for f in $(MANPAGES5); do \
225 $(RM) $(INSTALL_MAN)/man5/$$f; \
228 # Include dependancies