OSDN Git Service

2e4315907e44642588cbc622e17c00f0694f25d1
[android-x86/external-wireless-tools.git] / wireless_tools / Makefile
1 ##
2 ## Please check the configurion parameters below
3 ##
4
5 ## Installation directory. By default, go in /usr/local.
6 ## Distributions should probably use /, but they probably know better...
7 ifndef PREFIX
8   PREFIX = /usr/local
9 endif
10
11 ## Compiler to use (modify this for cross compile).
12 CC = gcc
13 ## Other tools you need to modify for cross compile (static lib only).
14 AR = ar
15 RANLIB = ranlib
16
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 # BUILD_STATIC = y
21
22 ## Uncomment this to build without using libm (less efficient).
23 ## This is mostly useful for embedded platforms without maths.
24 # BUILD_NOLIBM = y
25
26 ## Uncomment this to strip binary from symbols. This reduce binary size.
27 ## by a few percent but make debug worse...
28 # BUILD_STRIPPING = y
29
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
34
35 # ***************************************************************************
36 # ***** Most users should not need to change anything beyond this point *****
37 # ***************************************************************************
38
39 # Version of the Wireless Tools
40 WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
41
42 # Version of Wireless Extensions.
43 WE_VERSION := $(shell sed -ne "/WE_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
44
45 # Always use local header for wireless extensions
46 WEXT_HEADER = wireless.$(WE_VERSION).h
47
48 # Targets to build
49 STATIC=libiw.a
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
53 MANPAGES7=wireless.7
54 MANPAGES5=iftab.5
55 EXTRAPROGS= macaddr iwmulticall
56
57 # Composition of the library :
58 OBJS = iwlib.o
59
60 # Select which library to build and to link tool with
61 ifdef BUILD_STATIC
62   IWLIB=$(STATIC)
63   IWLIB_INSTALL=install-static
64 else
65   IWLIB=$(DYNAMIC)
66   IWLIB_INSTALL=install-dynamic
67 endif
68
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
72
73 # Install directories
74 INSTALL_DIR= $(PREFIX)/sbin/
75 INSTALL_LIB= $(PREFIX)/lib/
76 INSTALL_INC= $(PREFIX)/include/
77 INSTALL_MAN= $(PREFIX)/man/
78
79 # Various commands
80 RM = rm -f
81 RM_CMD = $(RM) *.BAK *.bak *.d *.o *.so ,* *~ *.a *.orig *.rej *.out
82 LDCONFIG = ldconfig
83
84 # Do we want to build with or without libm ?
85 ifdef BUILD_NOLIBM
86   LIBS=
87   WELIB_FLAG= -DWE_NOLIBM=y
88 else
89   LIBS= -lm
90 endif
91
92 # Stripping or not ?
93 ifdef BUILD_STRIPPING
94   STRIPFLAGS= -Wl,-s
95 else
96   STRIPFLAGS=
97 endif
98
99 # Do we want to build with only essential functionality ?
100 ifdef BUILD_WE_ESSENTIAL
101   WEDEF_FLAG= -DWE_ESSENTIAL=y
102 endif
103
104 # Other flags
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.
108 DEPFLAGS=-MMD
109 XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG)
110 PICFLAG=-fPIC
111
112 # Standard compilation targets
113 all:: $(IWLIB) $(PROGS)
114
115 %: %.o
116         $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
117 %.o: %.c wireless.h
118         $(CC) $(XCFLAGS) -c $<
119 %.so: %.c wireless.h
120         $(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<
121
122 iwconfig: iwconfig.o $(IWLIB)
123
124 iwlist: iwlist.o $(IWLIB)
125
126 iwpriv: iwpriv.o $(IWLIB)
127
128 iwspy: iwspy.o $(IWLIB)
129
130 iwgetid: iwgetid.o $(IWLIB)
131
132 iwevent: iwevent.o $(IWLIB)
133
134 ifrename: ifrename.o $(IWLIB)
135
136 macaddr: macaddr.o $(IWLIB)
137
138 # Always do symbol stripping here
139 iwmulticall: iwmulticall.o
140         $(CC) $(LDFLAGS) -Wl,-s $(XCFLAGS) -o $@ $^ $(LIBS)
141
142 # It's a kind of magic...
143 wireless.h:
144         cp $(WEXT_HEADER) wireless.h
145
146 # Compilation of the dynamic library
147 $(DYNAMIC): $(OBJS:.o=.so)
148         $(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^
149
150 # Compilation of the static library
151 $(STATIC): $(OBJS:.o=.so)
152         $(RM) $@
153         $(AR) cru $@ $^
154         $(RANLIB) $@
155
156 # Installation : So crude but so effective ;-)
157 # Less crude thanks to many contributions ;-)
158 install:: $(IWLIB_INSTALL) install-bin install-hdr install-man
159
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 ! ***"
167
168 # Install the static library
169 install-static:: $(STATIC)
170         install -m 755 -d $(INSTALL_LIB)
171         install -m 644 $(STATIC) $(INSTALL_LIB)
172
173 # All the binaries. Careful, no dependancy on install-dynamic
174 install-bin:: all
175         install -m 755 -d $(INSTALL_DIR)
176         install -m 755 $(PROGS) $(INSTALL_DIR)
177
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)
183
184 # How could you live without those manapages ?
185 install-man::
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/
192
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 )
201
202 clean::
203         $(RM_CMD) 
204
205 realclean::
206         $(RM_CMD) 
207         $(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS) libiw* wireless.h
208
209 uninstall::
210         for f in $(PROGS); do \
211           $(RM) $(INSTALL_DIR)/$$f; \
212         done
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; \
220         done
221         for f in $(MANPAGES7); do \
222           $(RM) $(INSTALL_MAN)/man7/$$f; \
223         done
224         for f in $(MANPAGES5); do \
225           $(RM) $(INSTALL_MAN)/man5/$$f; \
226         done
227
228 # Include dependancies
229 -include *.d