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 # ***************************************************************************
31 # ***** Most users should not need to change anything beyond this point *****
32 # ***************************************************************************
34 # Version of the Wireless Tools
35 WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
37 # Version of Wireless Extensions.
38 WE_VERSION := $(shell sed -ne "/WE_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
40 # Always use local header for wireless extensions
41 WEXT_HEADER = wireless.$(WE_VERSION).h
45 DYNAMIC=libiw.so.$(WT_VERSION)
46 PROGS= iwconfig iwlist iwpriv iwspy iwgetid iwevent ifrename
47 MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8
50 EXTRAPROGS= macaddr iwmulticall
52 # Composition of the library :
55 # Select which library to build and to link tool with
58 IWLIB_INSTALL=install-static
61 IWLIB_INSTALL=install-dynamic
64 # Standard name for dynamic library so that the dynamic linker can pick it.
65 # We will just create a symbolic link to the real thing.
66 DYNAMIC_LINK= libiw.so
69 INSTALL_DIR= $(PREFIX)/sbin/
70 INSTALL_LIB= $(PREFIX)/lib/
71 INSTALL_INC= $(PREFIX)/include/
72 INSTALL_MAN= $(PREFIX)/man/
76 RM_CMD = $(RM) *.BAK *.bak *.d *.o *.so ,* *~ *.a *.orig *.rej *.out
79 # Do we want to build with or without libm ?
82 WELIB_FLAG= -DWE_NOLIBM=y
95 CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
96 -Wpointer-arith -Wcast-qual -Winline -I.
97 #CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
99 XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG)
102 # Standard compilation targets
103 all:: $(IWLIB) $(PROGS)
106 $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
108 $(CC) $(XCFLAGS) -c $<
110 $(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<
112 iwconfig: iwconfig.o $(IWLIB)
114 iwlist: iwlist.o $(IWLIB)
116 iwpriv: iwpriv.o $(IWLIB)
118 iwspy: iwspy.o $(IWLIB)
120 iwgetid: iwgetid.o $(IWLIB)
122 iwevent: iwevent.o $(IWLIB)
124 ifrename: ifrename.o $(IWLIB)
126 macaddr: macaddr.o $(IWLIB)
128 # Always do symbol stripping here
129 iwmulticall: iwmulticall.o
130 $(CC) $(LDFLAGS) -Wl,-s $(XCFLAGS) -o $@ $^ $(LIBS)
132 # It's a kind of magic...
134 cp $(WEXT_HEADER) wireless.h
136 # Compilation of the dynamic library
137 $(DYNAMIC): $(OBJS:.o=.so)
138 $(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^
140 # Compilation of the static library
141 $(STATIC): $(OBJS:.o=.so)
146 # Installation : So crude but so effective ;-)
147 # Less crude thanks to many contributions ;-)
148 install:: $(IWLIB_INSTALL) install-bin install-hdr install-man
150 # Install the dynamic library
151 install-dynamic:: $(DYNAMIC)
152 install -m 755 -d $(INSTALL_LIB)
153 install -m 755 $(DYNAMIC) $(INSTALL_LIB)
154 ln -sfn $(DYNAMIC) $(INSTALL_LIB)/$(DYNAMIC_LINK)
155 @echo "*** Don't forget to add $(INSTALL_LIB) to /etc/ld.so.conf, and run ldconfig as root. ***"
156 @$(LDCONFIG) || echo "*** Could not run ldconfig ! ***"
158 # Install the static library
159 install-static:: $(STATIC)
160 install -m 755 -d $(INSTALL_LIB)
161 install -m 644 $(STATIC) $(INSTALL_LIB)
163 # All the binaries. Careful, no dependancy on install-dynamic
165 install -m 755 -d $(INSTALL_DIR)
166 install -m 755 $(PROGS) $(INSTALL_DIR)
168 # Headers to go with the wireless lib (dev)
169 install-hdr:: wireless.h
170 install -m 755 -d $(INSTALL_INC)
171 install -m 644 iwlib.h $(INSTALL_INC)
172 install -m 644 wireless.h $(INSTALL_INC)
174 # How could you live without those manapages ?
176 install -m 755 -d $(INSTALL_MAN)/man8/
177 install -m 644 $(MANPAGES8) $(INSTALL_MAN)/man8/
178 install -m 755 -d $(INSTALL_MAN)/man7/
179 install -m 644 $(MANPAGES7) $(INSTALL_MAN)/man7/
180 install -m 755 -d $(INSTALL_MAN)/man5/
181 install -m 644 $(MANPAGES5) $(INSTALL_MAN)/man5/
183 install-iwmulticall:: iwmulticall
184 install -m 755 -d $(INSTALL_DIR)
185 install -m 755 $< $(INSTALL_DIR)/iwconfig
186 ( cd $(INSTALL_DIR) ; \
187 ln -f -s iwconfig iwlist ; \
188 ln -f -s iwconfig iwspy ; \
189 ln -f -s iwconfig iwpriv ; \
190 ln -f -s iwconfig iwgetid )
197 $(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS) libiw* wireless.h
200 for f in $(PROGS); do \
201 $(RM) $(INSTALL_DIR)/$$f; \
203 $(RM) $(INSTALL_LIB)/$(STATIC)
204 $(RM) $(INSTALL_LIB)/$(DYNAMIC)
205 $(RM) $(INSTALL_LIB)/$(DYNAMIC_LINK)
206 $(RM) $(INSTALL_INC)/iwlib.h
207 $(RM) $(INSTALL_INC)/wireless.h
208 for f in $(MANPAGES8); do \
209 $(RM) $(INSTALL_MAN)/man8/$$f; \
211 for f in $(MANPAGES7); do \
212 $(RM) $(INSTALL_MAN)/man7/$$f; \
214 for f in $(MANPAGES5); do \
215 $(RM) $(INSTALL_MAN)/man5/$$f; \
218 # Include dependancies