Loading...

postfix-devel@postfix.org

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: Adding a new dict type Victor Duchovni Mon Nov 22 20:00:12 2010

On Mon, Nov 22, 2010 at 07:14:50PM -0500, Wietse Venema wrote:

> Then what do you think the files will look like, and how does the
> migration happen without me having to verify that builds on older
> platforms aren't broken in the process?

Here's a crude start at making libutil dynamic on Linux, without
making mince-meat of the Makefiles. This is missing the logic to make this
optional, ... and also changes to postfix-files, ...  and of course we'll
need rpath flags for the non-library executables, and LD_LIBRARY_PATH
when running postconf, ... in the build-tree.

This is not Linux specific, all one needs is dynamic libraries that
support SONAME, and a compiler that can build PIC objects and shared
libraries. On platforms with multiple toolchains (e.g. SunOS with
either SunCC or Gcc, we may need to offer two sets of SHLIB_MUMBLE
flags in makedefs, and the user can choose which to enable).

diff -Nru postfix0/makedefs postfix/makedefs
--- postfix0/makedefs   2010-09-13 16:42:45.000000000 -0400
+++ postfix/makedefs    2010-11-22 21:55:24.000000000 -0500
@@ -256,6 +256,12 @@
                ;;
     Linux.2*)  SYSTYPE=LINUX2
                # Postfix no longer needs DB 1.85 compatibility
+               SHLIB_LD='gcc -shared'
+               SHLIB_LDFLAGS='-h $(SONAME)'
+               SHLIB_CFLAGS='-fPIC'
+               SHLIB_EXT='so'
+               LIB_TARGET='$(SOLIB)'
+               PF_SHLIB_VERSION=2.8
                if [ -f /usr/include/db.h ]
                then
                    : we are all set
@@ -634,4 +640,10 @@
 STRCASE = $STRCASE
 EXPORT = AUXLIBS='$AUXLIBS' CCARGS='$CCARGS' OPT='$OPT' DEBUG='$DEBUG'
 WARN   = $WARN
+SHLIB_LD = $SHLIB_LD
+SHLIB_LDFLAGS  = $SHLIB_LDFLAGS
+SHLIB_CFLAGS  = $SHLIB_CFLAGS
+SHLIB_EXT = $SHLIB_EXT
+LIB_TARGET = $LIB_TARGET
+PF_SHLIB_VERSION = $PF_SHLIB_VERSION
 EOF
diff -Nru postfix0/src/util/Makefile.in postfix/src/util/Makefile.in
--- postfix0/src/util/Makefile.in       2010-09-13 16:41:58.000000000 -0400
+++ postfix/src/util/Makefile.in        2010-11-22 21:49:35.000000000 -0500
@@ -93,7 +93,10 @@
 CFLAGS = $(DEBUG) $(OPT) $(DEFS)
 FILES  = Makefile $(SRCS) $(HDRS)
 INCL   =
-LIB    = libutil.a
+LIBNAME = util
+LIB    = lib${LIBNAME}.a
+SOLIB  = lib${LIBNAME}.${SHLIB_EXT}
+SONAME = libpostfix-${LIBNAME}.${SHLIB_EXT}.${PF_SHLIB_VERSION}
 TESTPROG= dict_open dup2_pass_on_exec events exec_command fifo_open \
        fifo_rdonly_bug fifo_rdwr_bug fifo_trigger fsspace fullname \
        inet_addr_host inet_addr_local mac_parse make_dirs msg_syslog \
@@ -109,9 +112,9 @@
 LIB_DIR        = ../../lib
 INC_DIR        = ../../include
 
-.c.o:; $(CC) $(CFLAGS) -c $*.c
+.c.o:; $(CC) $(SHLIB_CFLAGS) $(CFLAGS) -c $*.c
 
-all: $(LIB)
+all: $(LIB_TARGET)
 
 $(OBJS): ../../conf/makedefs.out
 
@@ -121,14 +124,22 @@
 test:  $(TESTPROG)
 
 $(LIB):        $(OBJS)
-       $(AR) $(ARFL) $(LIB) $?
+       $(SHLIB_AR) $(ARFL) $(LIB) $?
        $(RANLIB) $(LIB)
 
+$(SOLIB):      $(OBJS)
+       $(SHLIB_LD) $(SHLIB_LDFLAGS) -o $(SONAME) $?
+       rm -f $(SOLIB); ln -s $(SONAME) $(SOLIB)
+
 $(LIB_DIR)/$(LIB): $(LIB)
        cp $(LIB) $(LIB_DIR)
        $(RANLIB) $(LIB_DIR)/$(LIB)
 
-update: $(LIB_DIR)/$(LIB) $(HDRS)
+$(LIB_DIR)/$(SOLIB): $(SOLIB)
+       cp $(SONAME) $(LIB_DIR)
+       rm -f $(LIB_DIR)/$(SOLIB); ln -s $(SONAME) $(LIB_DIR)/$(SOLIB)
+
+update: $(LIB_DIR)/$(LIB_TARGET) $(HDRS)
        -for i in $(HDRS); \
        do \
          cmp -s $$i $(INC_DIR)/$$i 2>/dev/null || cp $$i $(INC_DIR); \
@@ -150,7 +161,7 @@
        lint $(SRCS)
 
 clean:
-       rm -f *.o $(LIB) *core $(TESTPROG) junk $(MAKES) *.tmp
+       rm -f *.o $(LIB) $(SOLIB) $(SONAME) *core $(TESTPROG) junk $(MAKES) 
*.tmp
        rm -rf printfck
 
 tidy:  clean

-- 
        Viktor.