source: src/router/wireless-tools/Makefile @ 18286

Last change on this file since 18286 was 18286, checked in by BrainSlayer, 16 months ago

smaller

File size: 6.1 KB
Line 
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...
7ifndef PREFIX
8  PREFIX = /usr/local
9endif
10
11## Compiler to use (modify this for cross compile).
12CC = gcc
13## Other tools you need to modify for cross compile (static lib only).
14AR = ar
15RANLIB = 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.
24BUILD_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
40WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
41
42# Version of Wireless Extensions.
43WE_VERSION := $(shell sed -ne "/WE_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
44
45# Always use local header for wireless extensions
46WEXT_HEADER = wireless.$(WE_VERSION).h
47
48# Targets to build
49STATIC=libiw.a
50DYNAMIC=libiw.so.$(WT_VERSION)
51PROGS= iwconfig iwlist iwpriv
52#iwevent
53MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8
54MANPAGES7=wireless.7
55MANPAGES5=iftab.5
56EXTRAPROGS= macaddr iwmulticall
57
58# Composition of the library :
59OBJS = iwlib.o
60
61# Select which library to build and to link tool with
62ifdef BUILD_STATIC
63  IWLIB=$(STATIC)
64  IWLIB_INSTALL=install-static
65else
66  IWLIB=$(DYNAMIC)
67  IWLIB_INSTALL=install-dynamic
68endif
69
70# Standard name for dynamic library so that the dynamic linker can pick it.
71# We will just create a symbolic link to the real thing.
72DYNAMIC_LINK= libiw.so
73
74# Install directories
75INSTALL_DIR= $(PREFIX)/sbin/
76INSTALL_LIB= $(PREFIX)/lib/
77INSTALL_INC= $(PREFIX)/include/
78INSTALL_MAN= $(PREFIX)/man/
79
80# Various commands
81RM = rm -f
82RM_CMD = $(RM) *.BAK *.bak *.d *.o *.so ,* *~ *.a *.orig *.rej *.out
83LDCONFIG = ldconfig
84
85# Do we want to build with or without libm ?
86ifdef BUILD_NOLIBM
87  LIBS=
88  WELIB_FLAG= -DWE_NOLIBM=y
89else
90  LIBS= -lm
91endif
92
93# Stripping or not ?
94ifdef BUILD_STRIPPING
95  STRIPFLAGS= -Wl,-s
96else
97  STRIPFLAGS=
98endif
99
100# Do we want to build with only essential functionality ?
101ifdef BUILD_WE_ESSENTIAL
102  WEDEF_FLAG= -DWE_ESSENTIAL=y
103endif
104
105# Other flags
106CFLAGS=$(COPTS) -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -DNEED_PRINTF \
107        -Wpointer-arith -Wcast-qual -Winline -I.
108#CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
109DEPFLAGS=-MMD
110XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG) -DNEED_PRINTF
111PICFLAG=-fPIC
112
113# Standard compilation targets
114all:: $(IWLIB) $(PROGS)
115
116%: %.o
117        $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
118%.o: %.c wireless.h
119        $(CC) $(XCFLAGS) -c $<
120%.so: %.c wireless.h
121        $(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<
122
123iwconfig: iwconfig.o $(IWLIB)
124
125iwlist: iwlist.o $(IWLIB)
126
127iwpriv: iwpriv.o $(IWLIB)
128
129iwspy: iwspy.o $(IWLIB)
130
131iwgetid: iwgetid.o $(IWLIB)
132
133iwevent: iwevent.o $(IWLIB)
134
135ifrename: ifrename.o $(IWLIB)
136
137macaddr: macaddr.o $(IWLIB)
138
139# Always do symbol stripping here
140iwmulticall: iwmulticall.o $(IWLIB)
141
142# It's a kind of magic...
143wireless.h:
144        cp $(WEXT_HEADER) wireless.h
145
146# Compilation of the dynamic library
147$(DYNAMIC): $(OBJS:.o=.so)
148        $(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^
149
150# Compilation of the static library
151$(STATIC): $(OBJS:.o=.so)
152        $(RM) $@
153        $(AR) cru $@ $^
154        $(RANLIB) $@
155
156# Installation : So crude but so effective ;-)
157# Less crude thanks to many contributions ;-)
158install:: $(IWLIB_INSTALL) install-bin install-hdr install-man
159
160# Install the dynamic library
161install-dynamic:: $(DYNAMIC)
162        install -m 755 -d $(INSTALL_LIB)
163        install -m 755 $(DYNAMIC) $(INSTALL_LIB)
164        ln -sfn $(DYNAMIC) $(INSTALL_LIB)/$(DYNAMIC_LINK)
165        @echo "*** Don't forget to add $(INSTALL_LIB) to /etc/ld.so.conf, and run ldconfig as root. ***"
166        @$(LDCONFIG) || echo "*** Could not run ldconfig ! ***"
167
168# Install the static library
169install-static:: $(STATIC)
170        install -m 755 -d $(INSTALL_LIB)
171        install -m 644 $(STATIC) $(INSTALL_LIB)
172
173# All the binaries. Careful, no dependancy on install-dynamic
174install-bin:: all
175        install -m 755 -d $(INSTALL_DIR)
176        install -m 755 $(PROGS) $(INSTALL_DIR)
177
178# Headers to go with the wireless lib (dev)
179install-hdr:: wireless.h
180        install -m 755 -d $(INSTALL_INC)
181        install -m 644 iwlib.h $(INSTALL_INC)
182        install -m 644 wireless.h $(INSTALL_INC)
183
184# How could you live without those manapages ?
185install-man::
186        install -m 755 -d $(INSTALL_MAN)/man8/
187        install -m 644 $(MANPAGES8) $(INSTALL_MAN)/man8/
188        install -m 755 -d $(INSTALL_MAN)/man7/
189        install -m 644 $(MANPAGES7) $(INSTALL_MAN)/man7/
190        install -m 755 -d $(INSTALL_MAN)/man5/
191        install -m 644 $(MANPAGES5) $(INSTALL_MAN)/man5/
192
193install-iwmulticall:: iwmulticall
194        install -m 755 -d $(INSTALL_DIR)
195        install -m 755 $< $(INSTALL_DIR)/iwconfig
196        ( cd $(INSTALL_DIR) ; \
197          ln -f -s iwconfig iwlist ; \
198          ln -f -s iwconfig iwspy ; \
199          ln -f -s iwconfig iwpriv ; \
200          ln -f -s iwconfig iwgetid )
201
202clean::
203        $(RM_CMD)
204
205realclean::
206        $(RM_CMD)
207        $(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS) libiw* wireless.h
208
209uninstall::
210        for f in $(PROGS); do \
211          $(RM) $(INSTALL_DIR)/$$f; \
212        done
213        $(RM) $(INSTALL_LIB)/$(STATIC)
214        $(RM) $(INSTALL_LIB)/$(DYNAMIC)
215        $(RM) $(INSTALL_LIB)/$(DYNAMIC_LINK)
216        $(RM) $(INSTALL_INC)/iwlib.h
217        $(RM) $(INSTALL_INC)/wireless.h
218        for f in $(MANPAGES8); do \
219          $(RM) $(INSTALL_MAN)/man8/$$f; \
220        done
221        for f in $(MANPAGES7); do \
222          $(RM) $(INSTALL_MAN)/man7/$$f; \
223        done
224        for f in $(MANPAGES5); do \
225          $(RM) $(INSTALL_MAN)/man5/$$f; \
226        done
227
228# Include dependancies
229-include *.d
Note: See TracBrowser for help on using the repository browser.