| 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 |
|---|
| 52 | #iwevent |
|---|
| 53 | MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8 |
|---|
| 54 | MANPAGES7=wireless.7 |
|---|
| 55 | MANPAGES5=iftab.5 |
|---|
| 56 | EXTRAPROGS= macaddr iwmulticall |
|---|
| 57 | |
|---|
| 58 | # Composition of the library : |
|---|
| 59 | OBJS = iwlib.o |
|---|
| 60 | |
|---|
| 61 | # Select which library to build and to link tool with |
|---|
| 62 | ifdef BUILD_STATIC |
|---|
| 63 | IWLIB=$(STATIC) |
|---|
| 64 | IWLIB_INSTALL=install-static |
|---|
| 65 | else |
|---|
| 66 | IWLIB=$(DYNAMIC) |
|---|
| 67 | IWLIB_INSTALL=install-dynamic |
|---|
| 68 | endif |
|---|
| 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. |
|---|
| 72 | DYNAMIC_LINK= libiw.so |
|---|
| 73 | |
|---|
| 74 | # Install directories |
|---|
| 75 | INSTALL_DIR= $(PREFIX)/sbin/ |
|---|
| 76 | INSTALL_LIB= $(PREFIX)/lib/ |
|---|
| 77 | INSTALL_INC= $(PREFIX)/include/ |
|---|
| 78 | INSTALL_MAN= $(PREFIX)/man/ |
|---|
| 79 | |
|---|
| 80 | # Various commands |
|---|
| 81 | RM = rm -f |
|---|
| 82 | RM_CMD = $(RM) *.BAK *.bak *.d *.o *.so ,* *~ *.a *.orig *.rej *.out |
|---|
| 83 | LDCONFIG = ldconfig |
|---|
| 84 | |
|---|
| 85 | # Do we want to build with or without libm ? |
|---|
| 86 | ifdef BUILD_NOLIBM |
|---|
| 87 | LIBS= |
|---|
| 88 | WELIB_FLAG= -DWE_NOLIBM=y |
|---|
| 89 | else |
|---|
| 90 | LIBS= -lm |
|---|
| 91 | endif |
|---|
| 92 | |
|---|
| 93 | # Stripping or not ? |
|---|
| 94 | ifdef BUILD_STRIPPING |
|---|
| 95 | STRIPFLAGS= -Wl,-s |
|---|
| 96 | else |
|---|
| 97 | STRIPFLAGS= |
|---|
| 98 | endif |
|---|
| 99 | |
|---|
| 100 | # Do we want to build with only essential functionality ? |
|---|
| 101 | ifdef BUILD_WE_ESSENTIAL |
|---|
| 102 | WEDEF_FLAG= -DWE_ESSENTIAL=y |
|---|
| 103 | endif |
|---|
| 104 | |
|---|
| 105 | # Other flags |
|---|
| 106 | CFLAGS=$(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. |
|---|
| 109 | DEPFLAGS=-MMD |
|---|
| 110 | XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG) -DNEED_PRINTF |
|---|
| 111 | PICFLAG=-fPIC |
|---|
| 112 | |
|---|
| 113 | # Standard compilation targets |
|---|
| 114 | all:: $(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 | |
|---|
| 123 | iwconfig: iwconfig.o $(IWLIB) |
|---|
| 124 | |
|---|
| 125 | iwlist: iwlist.o $(IWLIB) |
|---|
| 126 | |
|---|
| 127 | iwpriv: iwpriv.o $(IWLIB) |
|---|
| 128 | |
|---|
| 129 | iwspy: iwspy.o $(IWLIB) |
|---|
| 130 | |
|---|
| 131 | iwgetid: iwgetid.o $(IWLIB) |
|---|
| 132 | |
|---|
| 133 | iwevent: iwevent.o $(IWLIB) |
|---|
| 134 | |
|---|
| 135 | ifrename: ifrename.o $(IWLIB) |
|---|
| 136 | |
|---|
| 137 | macaddr: macaddr.o $(IWLIB) |
|---|
| 138 | |
|---|
| 139 | # Always do symbol stripping here |
|---|
| 140 | iwmulticall: iwmulticall.o $(IWLIB) |
|---|
| 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 -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 ;-) |
|---|
| 158 | install:: $(IWLIB_INSTALL) install-bin install-hdr install-man |
|---|
| 159 | |
|---|
| 160 | # Install the dynamic library |
|---|
| 161 | install-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 |
|---|
| 169 | install-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 |
|---|
| 174 | install-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) |
|---|
| 179 | install-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 ? |
|---|
| 185 | install-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 | |
|---|
| 193 | install-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 | |
|---|
| 202 | clean:: |
|---|
| 203 | $(RM_CMD) |
|---|
| 204 | |
|---|
| 205 | realclean:: |
|---|
| 206 | $(RM_CMD) |
|---|
| 207 | $(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS) libiw* wireless.h |
|---|
| 208 | |
|---|
| 209 | uninstall:: |
|---|
| 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 |
|---|