]> mj.ucw.cz Git - libucw.git/commitdiff
Added a clean way for building of static PIC libraries
authorMartin Mares <mj@ucw.cz>
Fri, 1 Oct 2010 18:57:25 +0000 (20:57 +0200)
committerMartin Mares <mj@ucw.cz>
Fri, 1 Oct 2010 18:57:25 +0000 (20:57 +0200)
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.

charset/Makefile
images/Makefile
images/libimages.pc
shxml/Makefile
shxml/libshxml.pc
ucw/Makefile
ucw/default.cfg
ucw/libucw.pc

index 33998db53b0a9e91a5b2b69d17da8ad1435e1e85..23d40f8c8e896cf52b7e166ab30e5d294eb08862 100644 (file)
@@ -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
index e5793da9d6db3a80c9ddd2d5919f602d43c4ea51..98a53636c214894920a4c69e5eecf3106d75802d 100644 (file)
@@ -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
index 10f6e4f100118dba9d0546960e70e2c3b78f6e32..e8ca58f13473cce1de1da2f86e6ace9f2c7ee74e 100644 (file)
@@ -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@
index 630ce6c33745767192d44c43c0102294435152c7..ecdba488bce95a998f1ee9f6316960f947aef97e 100644 (file)
@@ -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
index 877b7a436f61f04268e22bef18e909f7d4ca5be7..44983e21b81e2f30ec60dec9c474b6be22065835 100644 (file)
@@ -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@
index bfb039a5c316bd5a5f1d044e8bf2acedf073b842..f741b1870786764f5ddfc459a46101201595e615 100644 (file)
@@ -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
index 6b919c6bd4ae23a46c69484f52bd2886eb1dfe1d..5d070687a4270dbf5f3daa8eb92089c5c5cf8594 100644 (file)
@@ -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");
index c4784eb297e12d0c8337dffced4541c441597e93..f55aafbc5930afa526b3b5d12f1687e7bba8423c 100644 (file)
@@ -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}