OSDN Git Service

v26
[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 /usr, but they probably know better...
7 ifndef PREFIX
8   PREFIX = /usr/local
9 endif
10
11 ## Compiler to use
12 CC = gcc
13
14 ## Uncomment this to build against this kernel
15 # KERNEL_SRC = /usr/src/linux
16
17 ## Uncomment this to force a particular version of wireless extensions.
18 ## This would use private copy of Wireless Extension definition instead
19 ## of the system wide one in /usr/include/linux. Use with care.
20 ## Can be used to create multiple versions of the tools on the same system
21 ## for multiple kernels or get around broken distributions.
22 # FORCE_WEXT_VERSION = 16
23
24 ## Uncomment this to build tools using dynamic version of the library
25 # BUILD_SHARED = y
26
27 ## Uncomment this to build without using libm (less efficient)
28 ## This is mostly useful for embedded platforms
29 # BUILD_NOLIBM = y
30
31 # ***************************************************************************
32 # ***** Most users should not need to change anything beyond this point *****
33 # ***************************************************************************
34
35 # Targets to build
36 STATIC=libiw.a
37 DYNAMIC=libiw.so.26
38 PROGS= iwconfig iwlist iwpriv iwspy iwgetid iwevent
39 MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8
40 MANPAGES7=wireless.7
41 EXTRAPROGS= macaddr iwredir
42
43 # Composition of the library :
44 OBJS = iwlib.o
45
46 # Select library to link tool with
47 ifdef BUILD_SHARED
48   IWLIB=$(DYNAMIC)
49 else
50   IWLIB=$(STATIC)
51 endif
52
53 # Standard name for dynamic library so that the dynamic linker can pick it.
54 # We will just create a symbolic link to the real thing.
55 DYNAMIC_LINK= libiw.so
56
57 # Install directories
58 INSTALL_DIR= $(PREFIX)/sbin/
59 INSTALL_LIB= $(PREFIX)/lib/
60 INSTALL_INC= $(PREFIX)/include/
61 INSTALL_MAN= $(PREFIX)/man/
62
63 # Use local header if the version of wireless extensions is specified
64 ifdef FORCE_WEXT_VERSION
65   WEXT_FLAG = -DWEXT_HEADER=\"wireless.$(FORCE_WEXT_VERSION).h\"
66 endif
67
68 RM = rm -f
69
70 RM_CMD = $(RM) *.BAK *.bak *.o *.so ,* *~ *.a *.orig *.rej
71
72 ifdef KERNEL_SRC
73   ifeq ($(wildcard $(KERNEL_SRC)/include/linux/wireless.h),)
74     $(error Kernel source is missing or incomplete)
75   endif
76   KERNEL_INCLUDES = -I $(KERNEL_SRC)/include
77 endif
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 #CFLAGS=-O2 -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror
88 CFLAGS=-O2 -W -Wall -Wstrict-prototypes
89 XCFLAGS=$(CFLAGS) $(WARN) $(HEADERS) $(WEXT_FLAG) $(WELIB_FLAG) $(KERNEL_INCLUDES)
90 PICFLAG=-fPIC
91
92 all:: $(STATIC) $(DYNAMIC) $(PROGS)
93
94 %: %.o
95         $(CC) $(LDFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
96 %.o: %.c
97         $(CC) $(XCFLAGS) -c $<
98 %.so: %.c
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
110
111 iwevent: iwevent.o $(IWLIB)
112
113 iwredir: iwredir.o
114
115 macaddr: macaddr.o $(IWLIB)
116
117 # Compilation of the dynamic library
118 $(DYNAMIC): $(OBJS:.o=.so)
119         $(CC) -shared -o $@ -Wl,-soname,$@ $(LIBS) -lc $^
120
121 # Compilation of the static library
122 $(STATIC): $(OBJS)
123         $(RM) $@
124         ar cru $@ $^
125         ranlib $@
126
127 # So crude but so effective ;-)
128 # Less crude thanks to many contributions ;-)
129 install:: all
130         install -m 755 -d $(INSTALL_DIR)
131         install -m 755 $(PROGS) $(INSTALL_DIR)
132         install -m 755 -d $(INSTALL_LIB)
133         install -m 644 $(STATIC) $(INSTALL_LIB)
134         install -m 755 $(DYNAMIC) $(INSTALL_LIB)
135         ln -sfn $(DYNAMIC) $(INSTALL_LIB)/$(DYNAMIC_LINK)
136         echo "Don't forget to add $(INSTALL_LIB) to /etc/ld.so.conf, and run ldconfig."
137         install -m 755 -d $(INSTALL_INC)
138         install -m 644 iwlib.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
144 clean::
145         $(RM_CMD) 
146
147 realclean::
148         $(RM_CMD) 
149         $(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS)
150
151 uninstall::
152         for f in $(PROGS); do \
153           $(RM) $(INSTALL_DIR)/$$f; \
154         done
155         $(RM) $(INSTALL_LIB)/$(STATIC)
156         $(RM) $(INSTALL_LIB)/$(DYNAMIC)
157         $(RM) $(INSTALL_LIB)/$(DYNAMIC_LINK)
158         $(RM) $(INSTALL_INC)/iwlib.h
159         for f in $(MANPAGES8); do \
160           $(RM) $(INSTALL_MAN)/man8/$$f; \
161         done
162         for f in $(MANPAGES7); do \
163           $(RM) $(INSTALL_MAN)/man7/$$f; \
164         done
165
166 # Versioned install...
167 # We rename each of the tool with a suffix corresponding to the version
168 # of WE it was compiled with. We use "iwredir" for the redirection...
169
170 vinstall:: iwredir install
171         @wev=$(FORCE_WEXT_VERSION) ; \
172         if [ "$$wev" == "" ] ; then \
173           wev=`./iwredir -wev`; \
174         else :; fi ; \
175         echo "Installing tools for WE-$$wev..." ; \
176         for f in $(PROGS); do \
177           mv $(INSTALL_DIR)/$$f $(INSTALL_DIR)/$$f$$wev; \
178         done;
179         install -m 755 iwredir $(INSTALL_DIR)
180         for f in $(PROGS); do \
181           ln $(INSTALL_DIR)/iwredir $(INSTALL_DIR)/$$f; \
182         done;
183
184 vuninstall:: uninstall
185         @wev=$(FORCE_WEXT_VERSION) ; \
186         if [ "$$wev" == "" ] ; then \
187           wev=`./iwredir -wev`; \
188         else :; fi ; \
189         for f in $(PROGS); do \
190           rm $(INSTALL_DIR)/$$f$$wev; \
191         done;
192         $(RM) $(INSTALL_DIR)/iwredir;
193
194 depend::
195         makedepend -s "# DO NOT DELETE" -- $(INCLUDES) -- $(SRCS)
196 # DO NOT DELETE