OSDN Git Service

Update to v30-pre9
[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 ## Standard distros should comment that option to save space and to
21 ## build libiw.so used by third parties...
22 BUILD_STATIC = y
23
24 ## Uncomment this to build without using libm (less efficient).
25 ## This is mostly useful for embedded platforms without maths.
26 # BUILD_NOLIBM = y
27
28 ## Uncomment this to strip binary from symbols. This reduce binary size.
29 ## by a few percent but make debug worse...
30 # BUILD_STRIPPING = y
31
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
36
37 # ***************************************************************************
38 # ***** Most users should not need to change anything beyond this point *****
39 # ***************************************************************************
40
41 # Version of the Wireless Tools
42 WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
43
44 # Version of Wireless Extensions.
45 WE_VERSION := $(shell sed -ne "/WE_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
46
47 # Always use local header for wireless extensions
48 WEXT_HEADER = wireless.$(WE_VERSION).h
49
50 # Targets to build
51 STATIC=libiw.a
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
55 MANPAGES7=wireless.7
56 MANPAGES5=iftab.5
57 EXTRAPROGS= macaddr iwmulticall
58
59 # Composition of the library :
60 OBJS = iwlib.o
61
62 # Select which library to build and to link tool with
63 ifdef BUILD_STATIC
64   IWLIB=$(STATIC)
65   IWLIB_INSTALL=install-static
66 else
67   IWLIB=$(DYNAMIC)
68   IWLIB_INSTALL=install-dynamic
69 endif
70
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
74
75 # Install directories
76 INSTALL_DIR= $(PREFIX)/sbin
77 INSTALL_LIB= $(PREFIX)/lib
78 INSTALL_INC= $(PREFIX)/include
79 INSTALL_MAN= $(PREFIX)/man
80
81 # Various commands
82 RM = rm -f
83 RM_CMD = $(RM) *.BAK *.bak *.d *.o *.so ,* *~ *.a *.orig *.rej *.out
84 LDCONFIG = ldconfig
85
86 # Do we want to build with or without libm ?
87 ifdef BUILD_NOLIBM
88   LIBS=
89   WELIB_FLAG= -DWE_NOLIBM=y
90 else
91   LIBS= -lm
92 endif
93
94 # Stripping or not ?
95 ifdef BUILD_STRIPPING
96   STRIPFLAGS= -Wl,-s
97 else
98   STRIPFLAGS=
99 endif
100
101 # Do we want to build with only essential functionality ?
102 ifdef BUILD_WE_ESSENTIAL
103   WEDEF_FLAG= -DWE_ESSENTIAL=y
104 endif
105
106 # Other flags
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.
110 DEPFLAGS=-MMD
111 XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG)
112 PICFLAG=-fPIC
113
114 # Standard compilation targets
115 all:: $(IWLIB) $(PROGS)
116
117 %: %.o
118         $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
119 %.o: %.c wireless.h
120         $(CC) $(XCFLAGS) -c $<
121 %.so: %.c wireless.h
122         $(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<
123
124 iwconfig: iwconfig.o $(IWLIB)
125
126 iwlist: iwlist.o $(IWLIB)
127
128 iwpriv: iwpriv.o $(IWLIB)
129
130 iwspy: iwspy.o $(IWLIB)
131
132 iwgetid: iwgetid.o $(IWLIB)
133
134 iwevent: iwevent.o $(IWLIB)
135
136 ifrename: ifrename.o $(IWLIB)
137
138 macaddr: macaddr.o $(IWLIB)
139
140 # Always do symbol stripping here
141 iwmulticall: iwmulticall.o
142         $(CC) $(LDFLAGS) -Wl,-s $(XCFLAGS) -o $@ $^ $(LIBS)
143
144 # It's a kind of magic...
145 wireless.h:
146         cp $(WEXT_HEADER) wireless.h
147
148 # Compilation of the dynamic library
149 $(DYNAMIC): $(OBJS:.o=.so)
150         $(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^
151
152 # Compilation of the static library
153 $(STATIC): $(OBJS:.o=.so)
154         $(RM) $@
155         $(AR) cru $@ $^
156         $(RANLIB) $@
157
158 # Installation : So crude but so effective ;-)
159 # Less crude thanks to many contributions ;-)
160 install:: $(IWLIB_INSTALL) install-bin install-hdr install-man
161
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 ! ***"
169
170 # Install the static library
171 install-static:: $(STATIC)
172         install -m 755 -d $(INSTALL_LIB)
173         install -m 644 $(STATIC) $(INSTALL_LIB)
174
175 # All the binaries. Careful, no dependancy on install-dynamic
176 install-bin:: all
177         install -m 755 -d $(INSTALL_DIR)
178         install -m 755 $(PROGS) $(INSTALL_DIR)
179
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)
185
186 # How could you live without those manapages ?
187 install-man::
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/; \
195         done
196
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 )
205
206 clean::
207         $(RM_CMD) 
208
209 realclean::
210         $(RM_CMD) 
211         $(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS) libiw* wireless.h
212
213 uninstall::
214         for f in $(PROGS); do \
215           $(RM) $(INSTALL_DIR)/$$f; \
216         done
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; \
225             done; \
226             for f in $(MANPAGES7); do \
227                 $(RM) $(INSTALL_MAN)/$$lang/man7/$$f; \
228             done; \
229             for f in $(MANPAGES5); do \
230                 $(RM) $(INSTALL_MAN)/$$lang/man5/$$f; \
231             done; \
232         done
233
234 # Include dependancies
235 -include *.d