]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
Build separate libraries for each netilnk family
authorThomas Graf <tgr@lsx.localdomain>
Thu, 15 May 2008 16:01:50 +0000 (18:01 +0200)
committerThomas Graf <tgr@lsx.localdomain>
Thu, 15 May 2008 16:01:50 +0000 (18:01 +0200)
This reduces the footprint on systems which only require a small
subset of the library.

Makefile.opts.in
lib/.gitignore
lib/Makefile

index 4accd857f658bb6d24d4ab8d4c93c07f2ffdf10b..b68e12f18b8430477d9263f0efb600dc09c9a172 100644 (file)
@@ -16,7 +16,7 @@ CPPFLAGS         := @CPPFLAGS@
 PACKAGE_NAME     := @PACKAGE_NAME@
 PACKAGE_VERSION  := @PACKAGE_VERSION@
 
-LIBNL_LIB        := @LIBNL_LIB@
+LIBNL_LIB        := @LIBNL_LIB@ -lc -L.
 
 prefix           := @prefix@
 exec_prefix      := @exec_prefix@
index f4bf2cd11bcb5966c936f0d229de0fa4c8e01ff3..2a450e8d37c0c8465eeaaa47fa8d141e2f049a08 100644 (file)
@@ -1 +1,2 @@
 libnl.so*
+libnl-*.so*
index b5b166ccacb0f621100599ac01d310bee7f02b25..cc218a49ba4b374418b8be6caeb1a11d6d9fa422 100644 (file)
@@ -6,55 +6,84 @@
 #      License as published by the Free Software Foundation version 2.1
 #      of the License.
 #
-# Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+# Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
 #
 
 ifeq ($(shell [ ! -r ../Makefile.opts ] && echo 1),)
     include ../Makefile.opts
 endif
 
-# Core
-CIN      := $(wildcard *.c)
-# NETLINK_ROUTE
-CIN      += $(wildcard route/*.c)
-# Schedulers
-CIN      += $(wildcard route/sch/*.c)
-# Classifiers
-CIN      += $(wildcard route/cls/*.c)
-# Link Info Modules
-CIN      += $(wildcard route/link/*.c)
-# NETLINK_GENERIC
-CIN      += $(wildcard genl/*.c)
-# fib lookup
-CIN      += $(wildcard fib_lookup/*.c)
-# Netfilter
-CIN      += $(wildcard netfilter/*.c)
-
-DEPS     := $(CIN:%.c=%.d)
-OBJ      := $(CIN:%.c=%.o)
-CFLAGS   += -fPIC
-OUT_SLIB := $(PACKAGE_NAME).so.$(PACKAGE_VERSION)
-LN_SLIB  := $(PACKAGE_NAME).so
+CORE_C    := $(wildcard *.c)
+CORE_OBJ  := $(CORE_C:%.c=%.o)
 
-export
+ROUTE_C   := $(wildcard route/*.c)
+ROUTE_C   += $(wildcard route/cls/*.c)
+ROUTE_C   += $(wildcard route/sch/*.c)
+ROUTE_C   += $(wildcard route/link/*.c)
+ROUTE_C   += $(wildcard fib_lookup/*.c)
+ROUTE_OBJ := $(ROUTE_C:%.c=%.o)
+
+GENL_C    := $(wildcard genl/*.c)
+GENL_OBJ  := $(GENL_C:%.c=%.o)
+
+NF_C    := $(wildcard netfilter/*.c)
+NF_OBJ    := $(NF_C:%.c=%.o)
+
+ALL_C     := $(CORE_C) $(ROUTE_C) $(GENL_C) $(NF_C)
+ALL_OBJ   := $(ALL_C:%.c=%.o)
+DEPS      := $(ALL_C:%.c=%.d)
 
-.PHONY: all clean install librtn.a $(OUT_SLIB)
+CFLAGS    += -fPIC
+
+CORE_LIB  := $(PACKAGE_NAME).so
+ROUTE_LIB := $(PACKAGE_NAME)-route.so
+GENL_LIB  := $(PACKAGE_NAME)-genl.so
+NF_LIB    := $(PACKAGE_NAME)-nf.so
+LIBS      := $(CORE_LIB) $(ROUTE_LIB) $(GENL_LIB) $(NF_LIB)
+
+export
 
+.PHONY: all clean install $(LIBS)
 
 all:
-       @echo "  MAKE $(OUT_SLIB)"; \
-       $(MAKE) $(OUT_SLIB)
+       @echo "  MAKE $(LIBS)"; \
+       $(MAKE) $(LIBS)
+
+$(CORE_LIB).$(PACKAGE_VERSION): $(CORE_OBJ)
+       @echo "  LD $@"; \
+       $(CC) -shared -Wl,-soname=$@ -o $@ $^ $(LIBNL_LIB)
+
+$(CORE_LIB): $(CORE_LIB).$(PACKAGE_VERSION)
+       @echo "  LN $@ -> $<"; \
+       $(RM) -f $@; $(LN) $< -s $@
+
+$(ROUTE_LIB).$(PACKAGE_VERSION): $(ROUTE_OBJ)
+       @echo "  LD $@"; \
+       $(CC) -shared -Wl,-soname=$@ -o $@ $^ $(LIBNL_LIB)
+
+$(ROUTE_LIB): $(ROUTE_LIB).$(PACKAGE_VERSION)
+       @echo "  LN $@ -> $<"; \
+       $(RM) -f $@; $(LN) $< -s $@
+
+$(GENL_LIB).$(PACKAGE_VERSION): $(GENL_OBJ)
+       @echo "  LD $@"; \
+       $(CC) -shared -Wl,-soname=$@ -o $@ $^ $(LIBNL_LIB)
+
+$(GENL_LIB): $(GENL_LIB).$(PACKAGE_VERSION)
+       @echo "  LN $@ -> $<"; \
+       $(RM) -f $@; $(LN) $< -s $@
+
+$(NF_LIB).$(PACKAGE_VERSION): $(NF_OBJ)
+       @echo "  LD $@"; \
+       $(CC) -shared -Wl,-soname=$@ -o $@ $^ $(LIBNL_LIB)
 
-$(OUT_SLIB): ../Makefile.opts $(OBJ)
-       @echo "  LD $(OUT_SLIB)"; \
-       $(CC) -shared -Wl,-soname=libnl.so.1.2 -o $(OUT_SLIB) $(OBJ) $(LIBNL_LIB) -lc
-       @echo "  LN $(LN1_SLIB) $(LN_SLIB)"; \
-       $(RM) -f $(LN_SLIB) ; $(LN) -s $(OUT_SLIB) $(LN_SLIB)
+$(NF_LIB): $(NF_LIB).$(PACKAGE_VERSION)
+       @echo "  LN $@ -> $<"; \
+       $(RM) -f $@; $(LN) $< -s $@
 
 clean:
        @echo "  CLEAN lib"; \
-       $(RM) -f $(OBJ) $(OUT_SLIB) $(LN_SLIB) $(LN1_SLIB); \
-       $(RM) -f $(DEPS) $(OUT_SLIB) $(LN_SLIB) $(LN1_SLIB)
+       $(RM) -f $(ALL_OBJ) $(LIBS) $(DEPS)
 
 distclean:
        @echo "  DISTCLEAN lib"; \