OSDN Git Service

v28
[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 # ***************************************************************************
31 # ***** Most users should not need to change anything beyond this point *****
32 # ***************************************************************************
33
34 # Version of the Wireless Tools
35 WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
36
37 # Version of Wireless Extensions.
38 WE_VERSION := $(shell sed -ne "/WE_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
39
40 # Always use local header for wireless extensions
41 WEXT_HEADER = wireless.$(WE_VERSION).h
42
43 # Targets to build
44 STATIC=libiw.a
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
48 MANPAGES7=wireless.7
49 MANPAGES5=iftab.5
50 EXTRAPROGS= macaddr iwmulticall
51
52 # Composition of the library :
53 OBJS = iwlib.o
54
55 # Select which library to build and to link tool with
56 ifdef BUILD_STATIC
57   IWLIB=$(STATIC)
58   IWLIB_INSTALL=install-static
59 else
60   IWLIB=$(DYNAMIC)
61   IWLIB_INSTALL=install-dynamic
62 endif
63
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
67
68 # Install directories
69 INSTALL_DIR= $(PREFIX)/sbin/
70 INSTALL_LIB= $(PREFIX)/lib/
71 INSTALL_INC= $(PREFIX)/include/
72 INSTALL_MAN= $(PREFIX)/man/
73
74 # Various commands
75 RM = rm -f
76 RM_CMD = $(RM) *.BAK *.bak *.d *.o *.so ,* *~ *.a *.orig *.rej *.out
77 LDCONFIG = ldconfig
78
79 # Do we want to build with or without libm ?
80 ifdef BUILD_NOLIBM
81   LIBS=
82   WELIB_FLAG= -DWE_NOLIBM=y
83 else
84   LIBS= -lm
85 endif
86
87 # Stripping or not ?
88 ifdef BUILD_STRIPPING
89   STRIPFLAGS= -Wl,-s
90 else
91   STRIPFLAGS=
92 endif
93
94 # Other flags
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.
98 DEPFLAGS=-MMD
99 XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG)
100 PICFLAG=-fPIC
101
102 # Standard compilation targets
103 all:: $(IWLIB) $(PROGS)
104
105 %: %.o
106         $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
107 %.o: %.c wireless.h
108         $(CC) $(XCFLAGS) -c $<
109 %.so: %.c wireless.h
110         $(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<
111
112 iwconfig: iwconfig.o $(IWLIB)
113
114 iwlist: iwlist.o $(IWLIB)
115
116 iwpriv: iwpriv.o $(IWLIB)
117
118 iwspy: iwspy.o $(IWLIB)
119
120 iwgetid: iwgetid.o $(IWLIB)
121
122 iwevent: iwevent.o $(IWLIB)
123
124 ifrename: ifrename.o $(IWLIB)
125
126 macaddr: macaddr.o $(IWLIB)
127
128 # Always do symbol stripping here
129 iwmulticall: iwmulticall.o
130         $(CC) $(LDFLAGS) -Wl,-s $(XCFLAGS) -o $@ $^ $(LIBS)
131
132 # It's a kind of magic...
133 wireless.h:
134         cp $(WEXT_HEADER) wireless.h
135
136 # Compilation of the dynamic library
137 $(DYNAMIC): $(OBJS:.o=.so)
138         $(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^
139
140 # Compilation of the static library
141 $(STATIC): $(OBJS:.o=.so)
142         $(RM) $@
143         $(AR) cru $@ $^
144         $(RANLIB) $@
145
146 # Installation : So crude but so effective ;-)
147 # Less crude thanks to many contributions ;-)
148 install:: $(IWLIB_INSTALL) install-bin install-hdr install-man
149
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 ! ***"
157
158 # Install the static library
159 install-static:: $(STATIC)
160         install -m 755 -d $(INSTALL_LIB)
161         install -m 644 $(STATIC) $(INSTALL_LIB)
162
163 # All the binaries. Careful, no dependancy on install-dynamic
164 install-bin:: all
165         install -m 755 -d $(INSTALL_DIR)
166         install -m 755 $(PROGS) $(INSTALL_DIR)
167
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)
173
174 # How could you live without those manapages ?
175 install-man::
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/
182
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 )
191
192 clean::
193         $(RM_CMD) 
194
195 realclean::
196         $(RM_CMD) 
197         $(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS) libiw* wireless.h
198
199 uninstall::
200         for f in $(PROGS); do \
201           $(RM) $(INSTALL_DIR)/$$f; \
202         done
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; \
210         done
211         for f in $(MANPAGES7); do \
212           $(RM) $(INSTALL_MAN)/man7/$$f; \
213         done
214         for f in $(MANPAGES5); do \
215           $(RM) $(INSTALL_MAN)/man5/$$f; \
216         done
217
218 # Include dependancies
219 -include *.d