From: Martin Mares Date: Fri, 1 Oct 2010 18:57:25 +0000 (+0200) Subject: Added a clean way for building of static PIC libraries X-Git-Tag: v5.0~141 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=64e1c5f18620ca22d7584f8cef7c54539adf2b27;p=libucw.git Added a clean way for building of static PIC libraries Defining CONFIG_STATIC_PIC adds a dependency on *-pic.a to every pkg-config file. In addition to that, the .pc files now contain a "picsuffix" variable which can be overridden by the user to enable the PIC mode. --- diff --git a/charset/Makefile b/charset/Makefile index 33998db5..23d40f8c 100644 --- a/charset/Makefile +++ b/charset/Makefile @@ -10,6 +10,10 @@ $(o)/charset/libcharset-pic.a: $(addsuffix .oo,$(addprefix $(o)/charset/,$(LIBCH $(o)/charset/libcharset.so: $(addsuffix .oo,$(addprefix $(o)/charset/,$(LIBCHARSET_MODS))) $(o)/charset/libcharset.pc: $(LIBUCW) +ifdef CONFIG_STATIC_PIC +$(o)/charset/libcharset.pc: $(o)/charset/libcharset-pic.a +endif + API_LIBS+=libcharset API_INCLUDES+=$(o)/charset/.include-stamp $(o)/charset/.include-stamp: $(addprefix $(s)/charset/,$(LIBCHARSET_INCLUDES)) @@ -28,5 +32,8 @@ install-libcharset: install -m 644 $(addprefix run/include/charset/,$(LIBCHARSET_INCLUDES)) $(DESTDIR)$(INSTALL_INCLUDE_DIR)/charset install -m 644 run/lib/libcharset.$(LS) $(DESTDIR)$(INSTALL_LIB_DIR) install -m 644 run/lib/pkgconfig/libcharset.pc $(DESTDIR)$(INSTALL_PKGCONFIG_DIR) +ifdef CONFIG_STATIC_PIC + install -m 644 run/lib/libcharset-pic.$(LS) $(DESTDIR)$(INSTALL_LIB_DIR) +endif .PHONY: install-libcharset diff --git a/images/Makefile b/images/Makefile index e5793da9..98a53636 100644 --- a/images/Makefile +++ b/images/Makefile @@ -15,6 +15,10 @@ else LIBIMAGES_DEPS=$(LIBUCW) endif +ifdef CONFIG_STATIC_PIC +LIBIMAGES_DEPS+=$(o)/images/libimages-pic.a +endif + ifdef CONFIG_IMAGES_DUP LIBIMAGES_PROGS+=$(o)/images/image-dup-test LIBIMAGES_MODS+=dup-init dup-cmp @@ -61,6 +65,7 @@ PROGS+=$(LIBIMAGES_PROGS) CONFIGS+=$(LIBIMAGES_CONFIGS) $(o)/images/libimages.a: $(addsuffix .o,$(addprefix $(o)/images/,$(LIBIMAGES_MODS))) +$(o)/images/libimages-pic.a: $(addsuffix .oo,$(addprefix $(o)/images/,$(LIBIMAGES_MODS))) $(o)/images/libimages.so: $(addsuffix .oo,$(addprefix $(o)/images/,$(LIBIMAGES_MODS))) $(o)/images/libimages.pc: $(LIBIMAGES_DEPS) @@ -91,5 +96,8 @@ install-libimages: install -m 644 run/lib/libimages.$(LS) $(DESTDIR)$(INSTALL_LIB_DIR) install -m 644 run/lib/pkgconfig/libimages.pc $(DESTDIR)$(INSTALL_PKGCONFIG_DIR) install -m 644 $(addprefix run/$(CONFIG_DIR)/,$(LIBIMAGES_CONFIGS)) $(DESTDIR)$(INSTALL_CONFIG_DIR) +ifdef CONFIG_STATIC_PIC + install -m 644 run/lib/libimages-pic.$(LS) $(DESTDIR)$(INSTALL_LIB_DIR) +endif .PHONY: install-libimages diff --git a/images/libimages.pc b/images/libimages.pc index 10f6e4f1..e8ca58f1 100644 --- a/images/libimages.pc +++ b/images/libimages.pc @@ -3,9 +3,12 @@ libdir=@LIBDIR@ incdir=. +# Override if you want to use the -pic version +picsuffix= + Name: libimages Description: Sherlock image library Version: @UCW_VERSION@ Cflags: -I${incdir} -Libs: -L${libdir} -limages -lm -lpthread @LIBIMAGES_LIBS@ +Libs: -L${libdir} -limages${picsuffix} -lm -lpthread @LIBIMAGES_LIBS@ Requires: @DEPS@ diff --git a/shxml/Makefile b/shxml/Makefile index 630ce6c3..ecdba488 100644 --- a/shxml/Makefile +++ b/shxml/Makefile @@ -10,9 +10,14 @@ LIBSHXML_INCLUDES=xml.h dtd.h LIBSHXML_MOD_PATHS=$(addprefix $(o)/shxml/,$(LIBSHXML_MODS)) $(o)/shxml/libshxml.a: $(addsuffix .o,$(LIBSHXML_MOD_PATHS)) +$(o)/shxml/libshxml-pic.a: $(addsuffix .oo,$(LIBSHXML_MOD_PATHS)) $(o)/shxml/libshxml.so: $(addsuffix .oo,$(LIBSHXML_MOD_PATHS)) $(o)/shxml/libshxml.pc: $(LIBCHARSET) +ifdef CONFIG_STATIC_PIC +$(o)/shxml/libshxml.pc: $(o)/shxml/libshxml-pic.a +endif + $(o)/shxml/common.o: $(o)/shxml/unicat.h $(o)/shxml/common.oo: $(o)/shxml/unicat.h $(o)/shxml/source.o: $(o)/shxml/unicat.h @@ -42,5 +47,8 @@ install-sh-xml: install -m 644 $(addprefix run/include/shxml/,$(LIBSHXML_INCLUDES)) $(DESTDIR)$(INSTALL_INCLUDE_DIR)/shxml install -m 644 run/lib/pkgconfig/libshxml.pc $(DESTDIR)$(INSTALL_PKGCONFIG_DIR) install -m 644 run/lib/libshxml.$(LS) $(DESTDIR)$(INSTALL_LIB_DIR) +ifdef CONFIG_STATIC_PIC + install -m 644 run/lib/libshxml-pic.$(LS) $(DESTDIR)$(INSTALL_LIB_DIR) +endif .PHONY: install-sh-xml diff --git a/shxml/libshxml.pc b/shxml/libshxml.pc index 877b7a43..44983e21 100644 --- a/shxml/libshxml.pc +++ b/shxml/libshxml.pc @@ -3,9 +3,12 @@ libdir=@LIBDIR@ incdir=. +# Override if you want to use the -pic version +picsuffix= + Name: libshxml Description: XML parser for Sherlock project Version: @UCW_VERSION@ Cflags: -I${incdir} -Libs: -L${libdir} -lshxml +Libs: -L${libdir} -lshxml${picsuffix} Requires: @DEPS@ diff --git a/ucw/Makefile b/ucw/Makefile index bfb039a5..f741b187 100644 --- a/ucw/Makefile +++ b/ucw/Makefile @@ -85,6 +85,10 @@ $(o)/ucw/libucw.a: $(addsuffix .o,$(LIBUCW_MOD_PATHS)) $(o)/ucw/libucw-pic.a: $(addsuffix .oo,$(LIBUCW_MOD_PATHS)) $(o)/ucw/libucw.so: $(addsuffix .oo,$(LIBUCW_MOD_PATHS)) +ifdef CONFIG_STATIC_PIC +$(o)/ucw/libucw.pc: $(o)/ucw/libucw-pic.a +endif + $(o)/ucw/hashfunc.o $(o)/ucw/hashfunc.oo: CFLAGS += -funroll-loops $(o)/ucw/lizard.o: CFLAGS += $(COPT2) -funroll-loops @@ -170,6 +174,9 @@ install-libucw: install -m 644 $(addprefix run/include/ucw/,$(LIBUCW_MAIN_INCLUDES) autoconf.h config.h) $(DESTDIR)$(INSTALL_INCLUDE_DIR)/ucw/ install -m 644 run/lib/pkgconfig/libucw.pc $(DESTDIR)$(INSTALL_PKGCONFIG_DIR) install -m 644 run/lib/libucw.$(LS) $(DESTDIR)$(INSTALL_LIB_DIR) +ifdef CONFIG_STATIC_PIC + install -m 644 run/lib/libucw-pic.$(LS) $(DESTDIR)$(INSTALL_LIB_DIR) +endif install -m 644 run/$(CONFIG_DIR)/libucw $(DESTDIR)$(INSTALL_CONFIG_DIR) .PHONY: install-libucw diff --git a/ucw/default.cfg b/ucw/default.cfg index 6b919c6b..5d070687 100644 --- a/ucw/default.cfg +++ b/ucw/default.cfg @@ -17,6 +17,10 @@ Set("CONFIG_LARGE_FILES"); # Use shared libraries UnSet("CONFIG_SHARED"); +# In addition to normal static libraries, generate also static libraries +# with PIC code (libucw-pic.a and friends). +UnSet("CONFIG_STATIC_PIC"); + # If your system can't reset getopt with 'optind = 0', you need to compile our internal copy # of GNU libc's getopt. This should not be necessary on GNU libc. UnSet("CONFIG_OWN_GETOPT"); diff --git a/ucw/libucw.pc b/ucw/libucw.pc index c4784eb2..f55aafbc 100644 --- a/ucw/libucw.pc +++ b/ucw/libucw.pc @@ -15,6 +15,9 @@ regex=-lpcre regex= #endif +# Override if you want to use the -pic version +picsuffix= + perl_modules_dir=@INSTALL_PERL_DIR@ perl_module_flags=-I${perl_modules_dir} build_system=@INSTALL_SHARE_DIR@/ucw/build @@ -23,4 +26,4 @@ Name: libucw Description: A library of utility functions and data structures Version: @UCW_VERSION@ Cflags: -I${incdir} -Libs: -L${libdir} -lucw ${threads} ${regex} +Libs: -L${libdir} -lucw${picsuffix} ${threads} ${regex}