OSDN Git Service

7a7dec9d2c92a34c5e8f6018b7a31ea136184d93
[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 PREFIX = /usr/local
8
9 ## Compiler to use
10 CC = gcc
11
12 ## Uncomment this to build against this kernel
13 # KERNEL_SRC = /usr/src/linux
14
15 ## Uncomment this to force a particular version of wireless extensions.
16 ## This would use private copy of Wireless Extension definition instead
17 ## of the system wide one in /usr/include/linux. Use with care.
18 ## Can be used to create multiple versions of the tools on the same system
19 ## for multiple kernels or get around broken distributions.
20 # FORCE_WEXT_VERSION = 14
21
22 ## Uncomment this to build tools using dynamic version of the library
23 # BUILD_SHARED = y
24
25 ## Uncomment this to build without using libm (less efficient)
26 ## This is mostly useful for embedded platforms
27 # BUILD_NOLIBM = y
28
29 # ***************************************************************************
30 # ***** Most users should not need to change anything beyond this point *****
31 # ***************************************************************************
32
33 # Targets to build
34 STATIC=libiw.a
35 DYNAMIC=libiw.so.25
36 PROGS= iwconfig iwlist iwpriv iwspy iwgetid iwevent
37 MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8
38 MANPAGES7=wireless.7
39
40 # Composition of the library :
41 OBJS = iwlib.o
42
43 # Select library to link tool with
44 ifdef BUILD_SHARED
45   IWLIB=$(DYNAMIC)
46 else
47   IWLIB=$(STATIC)
48 endif
49
50 # Standard name for dynamic library so that the dynamic linker can pick it.
51 # We will just create a symbolic link to the real thing.
52 DYNAMIC_LINK= libiw.so
53
54 # Install directories
55 INSTALL_DIR= $(PREFIX)/sbin/
56 INSTALL_LIB= $(PREFIX)/lib/
57 INSTALL_INC= $(PREFIX)/include/
58 INSTALL_MAN= $(PREFIX)/man/
59
60 # Use local header if the version of wireless extensions is specified
61 ifdef FORCE_WEXT_VERSION
62   WEXT_FLAG = -DWEXT_HEADER=\"wireless.$(FORCE_WEXT_VERSION).h\"
63 endif
64
65 RM = rm -f
66
67 RM_CMD = $(RM) *.BAK *.bak *.o *.so ,* *~ *.a *.orig *.rej
68
69 ifdef KERNEL_SRC
70   KERNEL_INCLUDES = -I $(KERNEL_SRC)/include
71 endif
72
73 # Do we want to build with or without libm ?
74 ifdef BUILD_NOLIBM
75   LIBS=
76   WELIB_FLAG = -DWE_NOLIBM=y
77 else
78   LIBS= -lm
79 endif
80
81 #CFLAGS=-O2 -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror
82 CFLAGS=-O2 -W -Wall -Wstrict-prototypes
83 XCFLAGS=$(CFLAGS) $(WARN) $(HEADERS) $(WEXT_FLAG) $(WELIB_FLAG) $(KERNEL_INCLUDES)
84 PICFLAG=-fPIC
85
86 all:: $(STATIC) $(DYNAMIC) $(PROGS)
87
88 %: %.o
89         $(CC) $(XCFLAGS) -o $@ $^ $(LIBS)
90 %.o: %.c
91         $(CC) $(XCFLAGS) -c $<
92 %.so: %.c
93         $(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<
94
95 iwconfig: iwconfig.o $(IWLIB)
96
97 iwlist: iwlist.o $(IWLIB)
98
99 iwpriv: iwpriv.o $(IWLIB)
100
101 iwspy: iwspy.o $(IWLIB)
102
103 iwgetid: iwgetid.o
104
105 iwevent: iwevent.o $(IWLIB)
106
107 macaddr: macaddr.o $(IWLIB)
108
109 # Compilation of the dynamic library
110 $(DYNAMIC): $(OBJS:.o=.so)
111         $(CC) -shared -o $@ -Wl,-soname,$@ -lm -lc $^
112
113 # Compilation of the static library
114 $(STATIC): $(OBJS)
115         $(RM) $@
116         ar cru $@ $^
117         ranlib $@
118
119 # So crude but so effective ;-)
120 # Less crude thanks to many contributions ;-)
121 install::
122         install -m 755 -d $(INSTALL_DIR)
123         install -m 755 $(PROGS) $(INSTALL_DIR)
124         install -m 755 -d $(INSTALL_LIB)
125         install -m 644 $(STATIC) $(INSTALL_LIB)
126         install -m 755 $(DYNAMIC) $(INSTALL_LIB)
127         ln -sfn $(DYNAMIC) $(INSTALL_LIB)/$(DYNAMIC_LINK)
128         echo "Don't forget to add $(INSTALL_LIB) to /etc/ld.so.conf, and run ldconfig."
129         install -m 755 -d $(INSTALL_INC)
130         install -m 644 iwlib.h $(INSTALL_INC)
131         install -m 755 -d $(INSTALL_MAN)/man8/
132         install -m 644 $(MANPAGES8) $(INSTALL_MAN)/man8/
133         install -m 755 -d $(INSTALL_MAN)/man7/
134         install -m 644 $(MANPAGES7) $(INSTALL_MAN)/man7/
135
136 clean::
137         $(RM_CMD) 
138
139 realclean::
140         $(RM_CMD) 
141         $(RM) $(STATIC) $(DYNAMIC) $(PROGS) macaddr
142
143 uninstall::
144         for f in $(PROGS); do \
145           $(RM) $(INSTALL_DIR)/$$f; \
146         done
147         $(RM) $(INSTALL_LIB)/$(STATIC)
148         $(RM) $(INSTALL_LIB)/$(DYNAMIC)
149         $(RM) $(INSTALL_LIB)/$(DYNAMIC_LINK)
150         $(RM) $(INSTALL_INC)/iwlib.h
151         for f in $(MANPAGES8); do \
152           $(RM) $(INSTALL_MAN)/man8/$$f; \
153         for f in $(MANPAGES7); do \
154           $(RM) $(INSTALL_MAN)/man7/$$f; \
155         done
156
157 depend::
158         makedepend -s "# DO NOT DELETE" -- $(INCLUDES) -- $(SRCS)
159 # DO NOT DELETE