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 # ***************************************************************************
27 # ***** Most users should not need to change anything beyond this point *****
28 # ***************************************************************************
30 # Version of the Wireless Tools
31 WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
33 # Version of Wireless Extensions.
34 WE_VERSION := $(shell sed -ne "/WE_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
36 # Always use local header for wireless extensions
37 WEXT_HEADER = wireless.$(WE_VERSION).h
41 DYNAMIC=libiw.so.$(WT_VERSION)
42 PROGS= iwconfig iwlist iwpriv iwspy iwgetid iwevent ifrename
43 MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8
48 # Composition of the library :
51 # Select which library to build and to link tool with
54 IWLIB_INSTALL=install-static
57 IWLIB_INSTALL=install-dynamic
60 # Standard name for dynamic library so that the dynamic linker can pick it.
61 # We will just create a symbolic link to the real thing.
62 DYNAMIC_LINK= libiw.so
65 INSTALL_DIR= $(PREFIX)/sbin/
66 INSTALL_LIB= $(PREFIX)/lib/
67 INSTALL_INC= $(PREFIX)/include/
68 INSTALL_MAN= $(PREFIX)/man/
72 RM_CMD = $(RM) *.BAK *.bak *.d *.o *.so ,* *~ *.a *.orig *.rej *.out
75 # Do we want to build with or without libm ?
78 WELIB_FLAG = -DWE_NOLIBM=y
84 CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
85 -Wpointer-arith -Wcast-qual -Winline -I.
86 #CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
88 XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG)
91 # Standard compilation targets
92 all:: $(IWLIB) $(PROGS)
95 $(CC) $(LDFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
97 $(CC) $(XCFLAGS) -c $<
99 $(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<
101 iwconfig: iwconfig.o $(IWLIB)
103 iwlist: iwlist.o $(IWLIB)
105 iwpriv: iwpriv.o $(IWLIB)
107 iwspy: iwspy.o $(IWLIB)
109 iwgetid: iwgetid.o $(IWLIB)
111 iwevent: iwevent.o $(IWLIB)
113 ifrename: ifrename.o $(IWLIB)
115 macaddr: macaddr.o $(IWLIB)
117 # It's a kind of magic...
119 cp $(WEXT_HEADER) wireless.h
121 # Compilation of the dynamic library
122 $(DYNAMIC): $(OBJS:.o=.so)
123 $(CC) -shared -o $@ -Wl,-soname,$@ $(LIBS) -lc $^
125 # Compilation of the static library
131 # So crude but so effective ;-)
132 # Less crude thanks to many contributions ;-)
133 install:: all $(IWLIB_INSTALL)
134 install -m 755 -d $(INSTALL_DIR)
135 install -m 755 $(PROGS) $(INSTALL_DIR)
136 install -m 755 -d $(INSTALL_INC)
137 install -m 644 iwlib.h $(INSTALL_INC)
138 install -m 644 wireless.h $(INSTALL_INC)
139 install -m 755 -d $(INSTALL_MAN)/man8/
140 install -m 644 $(MANPAGES8) $(INSTALL_MAN)/man8/
141 install -m 755 -d $(INSTALL_MAN)/man7/
142 install -m 644 $(MANPAGES7) $(INSTALL_MAN)/man7/
143 install -m 755 -d $(INSTALL_MAN)/man5/
144 install -m 644 $(MANPAGES5) $(INSTALL_MAN)/man5/
146 # Install the dynamic library
147 install-dynamic:: $(DYNAMIC)
148 install -m 755 -d $(INSTALL_LIB)
149 install -m 755 $(DYNAMIC) $(INSTALL_LIB)
150 ln -sfn $(DYNAMIC) $(INSTALL_LIB)/$(DYNAMIC_LINK)
151 @echo "*** Don't forget to add $(INSTALL_LIB) to /etc/ld.so.conf, and run ldconfig as root. ***"
152 @$(LDCONFIG) || echo "*** Could not run ldconfig ! ***"
154 # Install the static library
155 install-static:: $(STATIC)
156 install -m 755 -d $(INSTALL_LIB)
157 install -m 644 $(STATIC) $(INSTALL_LIB)
164 $(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS) libiw* wireless.h
167 for f in $(PROGS); do \
168 $(RM) $(INSTALL_DIR)/$$f; \
170 $(RM) $(INSTALL_LIB)/$(STATIC)
171 $(RM) $(INSTALL_LIB)/$(DYNAMIC)
172 $(RM) $(INSTALL_LIB)/$(DYNAMIC_LINK)
173 $(RM) $(INSTALL_INC)/iwlib.h
174 $(RM) $(INSTALL_INC)/wireless.h
175 for f in $(MANPAGES8); do \
176 $(RM) $(INSTALL_MAN)/man8/$$f; \
178 for f in $(MANPAGES7); do \
179 $(RM) $(INSTALL_MAN)/man7/$$f; \
181 for f in $(MANPAGES5); do \
182 $(RM) $(INSTALL_MAN)/man5/$$f; \
185 # Include dependancies