OSDN Git Service

Fix no pic
[uclinux-h8/uClinux-dist.git] / user / 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 *.so.? *.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) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG)
110 PICFLAG=-fPIC
111
112 # Standard compilation targets
113 all:: $(IWLIB) $(PROGS)
114
115 %: %.o
116         $(CC) $(LDFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) $(LDLIBS$(LDLIBS_$@))
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 $(LDFLAGS) -o $@ -Wl,-soname,$@ $(LIBS) -lc $^ $(LDLIBS$(LDLIBS_$@))
149
150 romfs:
151         $(ROMFSINST) -e CONFIG_USER_WIRELESS_TOOLS_IWCONFIG /bin/iwconfig
152         $(ROMFSINST) -e CONFIG_USER_WIRELESS_TOOLS_IWLIST   /bin/iwlist
153         $(ROMFSINST) -e CONFIG_USER_WIRELESS_TOOLS_IWPRIV   /bin/iwpriv
154         $(ROMFSINST) -e CONFIG_USER_WIRELESS_TOOLS_IWSPY    /bin/iwspy
155         $(ROMFSINST) -e CONFIG_USER_WIRELESS_TOOLS_IWGETID  /bin/iwgetid
156         $(ROMFSINST) -e CONFIG_USER_WIRELESS_TOOLS_IWEVENT  /bin/iwevent
157
158 # Compilation of the static library
159 $(STATIC): $(OBJS:.o=.so)
160         $(RM) $@
161         $(AR) cru $@ $^
162         $(RANLIB) $@
163
164 # Installation : So crude but so effective ;-)
165 # Less crude thanks to many contributions ;-)
166 install:: $(IWLIB_INSTALL) install-bin install-hdr install-man
167
168 # Install the dynamic library
169 install-dynamic:: $(DYNAMIC)
170         install -m 755 -d $(INSTALL_LIB)
171         install -m 755 $(DYNAMIC) $(INSTALL_LIB)
172         ln -sfn $(DYNAMIC) $(INSTALL_LIB)/$(DYNAMIC_LINK)
173         @echo "*** Don't forget to add $(INSTALL_LIB) to /etc/ld.so.conf, and run ldconfig as root. ***"
174         @$(LDCONFIG) || echo "*** Could not run ldconfig ! ***"
175
176 # Install the static library
177 install-static:: $(STATIC)
178         install -m 755 -d $(INSTALL_LIB)
179         install -m 644 $(STATIC) $(INSTALL_LIB)
180
181 # All the binaries. Careful, no dependancy on install-dynamic
182 install-bin:: all
183         install -m 755 -d $(INSTALL_DIR)
184         install -m 755 $(PROGS) $(INSTALL_DIR)
185
186 # Headers to go with the wireless lib (dev)
187 install-hdr:: wireless.h
188         install -m 755 -d $(INSTALL_INC)
189         install -m 644 iwlib.h $(INSTALL_INC)
190         install -m 644 wireless.h $(INSTALL_INC)
191
192 # How could you live without those manapages ?
193 install-man::
194         install -m 755 -d $(INSTALL_MAN)/man8/
195         install -m 644 $(MANPAGES8) $(INSTALL_MAN)/man8/
196         install -m 755 -d $(INSTALL_MAN)/man7/
197         install -m 644 $(MANPAGES7) $(INSTALL_MAN)/man7/
198         install -m 755 -d $(INSTALL_MAN)/man5/
199         install -m 644 $(MANPAGES5) $(INSTALL_MAN)/man5/
200
201 install-iwmulticall:: iwmulticall
202         install -m 755 -d $(INSTALL_DIR)
203         install -m 755 $< $(INSTALL_DIR)/iwconfig
204         ( cd $(INSTALL_DIR) ; \
205           ln -f -s iwconfig iwlist ; \
206           ln -f -s iwconfig iwspy ; \
207           ln -f -s iwconfig iwpriv ; \
208           ln -f -s iwconfig iwgetid )
209
210 clean::
211         $(RM_CMD) 
212         $(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS) libiw* wireless.h
213
214 uninstall::
215         for f in $(PROGS); do \
216           $(RM) $(INSTALL_DIR)/$$f; \
217         done
218         $(RM) $(INSTALL_LIB)/$(STATIC)
219         $(RM) $(INSTALL_LIB)/$(DYNAMIC)
220         $(RM) $(INSTALL_LIB)/$(DYNAMIC_LINK)
221         $(RM) $(INSTALL_INC)/iwlib.h
222         $(RM) $(INSTALL_INC)/wireless.h
223         for f in $(MANPAGES8); do \
224           $(RM) $(INSTALL_MAN)/man8/$$f; \
225         done
226         for f in $(MANPAGES7); do \
227           $(RM) $(INSTALL_MAN)/man7/$$f; \
228         done
229         for f in $(MANPAGES5); do \
230           $(RM) $(INSTALL_MAN)/man5/$$f; \
231         done
232
233 # Include dependancies
234 -include *.d