OSDN Git Service

v22
[android-x86/external-wireless-tools.git] / wireless_tools / Makefile
index b7f7550..236acbb 100644 (file)
@@ -3,16 +3,27 @@
 #
 
 # Targets to build
+STATIC=libiw.a
+DYNAMIC=libiw.so.22
 PROGS= iwconfig iwlist iwpriv iwspy iwgetid
 
+# Composition of the library :
+OBJS = iwlib.o
+
+# Define if tools should be built using static or dynamic version of the lib
+IWLIBS=$(OBJS)
+#IWLIBS=-liw
+
 # Installation directory. By default, go in local.
 # Distributions should probably use /usr/sbin, but they probably know better...
 INSTALL_DIR= /usr/local/sbin
+INSTALL_LIB= /usr/local/lib
+INSTALL_INC= /usr/local/include
 
 # This is our header selection. Try to hide the mess and the misery :-(
 # Please choose *only one* of the define...
 
-# Kernel headers 2.4.X + Glibc 2.2 - Mandrake 8.0 */
+# Kernel headers 2.4.X + Glibc 2.2 - Mandrake 8.0, Debian 2.3, RH 7.1
 #HEADERS= -DGLIBC22_HEADERS
 
 # Kernel headers 2.0.X + Glibc 2.0 - Debian 2.0, RH 5
@@ -42,38 +53,51 @@ RM_CMD = $(RM) *.BAK *.bak *.o ,* *~ *.a
 
 CFLAGS=-O2 -Wall $(HEADERS) $(WE_HEADER)
 
-LIBS=-lm
+LIBS=$(IWLIBS) -lm
 
-all:: $(PROGS)
+all:: $(STATIC) $(DYNAMIC) $(PROGS)
 
 .c.o:
        $(CC) $(CFLAGS) -c $<
 
-iwconfig: iwconfig.o iwcommon.o
-       $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
+iwconfig: iwconfig.o $(OBJS)
+       $(CC) $(CFLAGS) -o $@ $< $(LIBS)
 
-iwlist: iwlist.o iwcommon.o
-       $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
+iwlist: iwlist.o $(OBJS)
+       $(CC) $(CFLAGS) -o $@ $< $(LIBS)
 
-iwpriv: iwpriv.o iwcommon.o
-       $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
+iwpriv: iwpriv.o $(OBJS)
+       $(CC) $(CFLAGS) -o $@ $< $(LIBS)
 
-iwspy: iwspy.o iwcommon.o
-       $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
+iwspy: iwspy.o $(OBJS)
+       $(CC) $(CFLAGS) -o $@ $< $(LIBS)
 
 iwgetid: iwgetid.o
        $(CC) $(CFLAGS) -o $@ $^
 
+# Compilation of the dynamic library
+libiw.so.22: $(OBJS)
+       $(CC) -O2 -shared -o $@ -Wl,-soname,$@ -lm -lc $^
+
+# Compilation of the static library
+libiw.a: $(OBJS)
+       $(RM) $@
+       ar cru $@ $^
+       ranlib $@
+
 # So crude but so effective ;-)
 install::
        cp $(PROGS) $(INSTALL_DIR)
+       cp $(STATIC) $(DYNAMIC) $(INSTALL_LIB)
+       echo "Don't forget to fix you /etc/ld.so.conf and run ldconfig."
+       cp iwlib.h $(INSTALL_INC)
 
 clean::
        $(RM_CMD) 
 
 realclean::
        $(RM_CMD) 
-       $(RM) $(PROGS)
+       $(RM) $(STATIC) $(DYNAMIC) $(PROGS)
 
 depend::
        makedepend -s "# DO NOT DELETE" -- $(INCLUDES) -- $(SRCS)