OSDN Git Service

v27
[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 # ***************************************************************************
27 # ***** Most users should not need to change anything beyond this point *****
28 # ***************************************************************************
29
30 # Version of the Wireless Tools
31 WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
32
33 # Version of Wireless Extensions.
34 WE_VERSION := $(shell sed -ne "/WE_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
35
36 # Always use local header for wireless extensions
37 WEXT_HEADER = wireless.$(WE_VERSION).h
38
39 # Targets to build
40 STATIC=libiw.a
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
44 MANPAGES7=wireless.7
45 MANPAGES5=iftab.5
46 EXTRAPROGS= macaddr
47
48 # Composition of the library :
49 OBJS = iwlib.o
50
51 # Select which library to build and to link tool with
52 ifdef BUILD_STATIC
53   IWLIB=$(STATIC)
54   IWLIB_INSTALL=install-static
55 else
56   IWLIB=$(DYNAMIC)
57   IWLIB_INSTALL=install-dynamic
58 endif
59
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
63
64 # Install directories
65 INSTALL_DIR= $(PREFIX)/sbin/
66 INSTALL_LIB= $(PREFIX)/lib/
67 INSTALL_INC= $(PREFIX)/include/
68 INSTALL_MAN= $(PREFIX)/man/
69
70 # Various commands
71 RM = rm -f
72 RM_CMD = $(RM) *.BAK *.bak *.d *.o *.so ,* *~ *.a *.orig *.rej *.out
73 LDCONFIG = ldconfig
74
75 # Do we want to build with or without libm ?
76 ifdef BUILD_NOLIBM
77   LIBS=
78   WELIB_FLAG = -DWE_NOLIBM=y
79 else
80   LIBS= -lm
81 endif
82
83 # Other flags
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.
87 DEPFLAGS=-MMD
88 XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG)
89 PICFLAG=-fPIC
90
91 # Standard compilation targets
92 all:: $(IWLIB) $(PROGS)
93
94 %: %.o
95         $(CC) $(LDFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
96 %.o: %.c wireless.h
97         $(CC) $(XCFLAGS) -c $<
98 %.so: %.c wireless.h
99         $(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<
100
101 iwconfig: iwconfig.o $(IWLIB)
102
103 iwlist: iwlist.o $(IWLIB)
104
105 iwpriv: iwpriv.o $(IWLIB)
106
107 iwspy: iwspy.o $(IWLIB)
108
109 iwgetid: iwgetid.o $(IWLIB)
110
111 iwevent: iwevent.o $(IWLIB)
112
113 ifrename: ifrename.o $(IWLIB)
114
115 macaddr: macaddr.o $(IWLIB)
116
117 # It's a kind of magic...
118 wireless.h:
119         cp $(WEXT_HEADER) wireless.h
120
121 # Compilation of the dynamic library
122 $(DYNAMIC): $(OBJS:.o=.so)
123         $(CC) -shared -o $@ -Wl,-soname,$@ $(LIBS) -lc $^
124
125 # Compilation of the static library
126 $(STATIC): $(OBJS)
127         $(RM) $@
128         $(AR) cru $@ $^
129         $(RANLIB) $@
130
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/
145
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 ! ***"
153
154 # Install the static library
155 install-static:: $(STATIC)
156         install -m 755 -d $(INSTALL_LIB)
157         install -m 644 $(STATIC) $(INSTALL_LIB)
158
159 clean::
160         $(RM_CMD) 
161
162 realclean::
163         $(RM_CMD) 
164         $(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS) libiw* wireless.h
165
166 uninstall::
167         for f in $(PROGS); do \
168           $(RM) $(INSTALL_DIR)/$$f; \
169         done
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; \
177         done
178         for f in $(MANPAGES7); do \
179           $(RM) $(INSTALL_MAN)/man7/$$f; \
180         done
181         for f in $(MANPAGES5); do \
182           $(RM) $(INSTALL_MAN)/man5/$$f; \
183         done
184
185 # Include dependancies
186 -include *.d