1Fix linking libraries built with -fPIC with this library
2
3Patch borrowed from Fedora
4
5Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
6
7Upstream-Status: Pending
8
9diff -up imap-2007e/src/osdep/unix/Makefile.shared imap-2007e/src/osdep/unix/Makefile
10--- imap-2007e/src/osdep/unix/Makefile.shared	2009-07-07 19:28:02.909755512 -0500
11+++ imap-2007e/src/osdep/unix/Makefile	2009-07-07 19:29:35.870006799 -0500
12@@ -170,6 +170,10 @@ BUILD=$(MAKE) build EXTRACFLAGS='$(EXTRA
13  EXTRADRIVERS='$(EXTRADRIVERS)' EXTRAAUTHENTICATORS='$(EXTRAAUTHENTICATORS)'\
14  PASSWDTYPE=$(PASSWDTYPE) SSLTYPE=$(SSLTYPE) IP=$(IP)
15
16+# Need this for the shared library rule to work correctly
17+.SUFFIXES: .o .so
18+SOFILES=${BINARIES:.o=.so}
19+
20
21 # Here if no make argument established
22
23@@ -845,18 +849,24 @@ vu2:	# VAX Ultrix 2.3, etc.
24
25 # Build it!
26
27-build:	clean once $(ARCHIVE)
28+build:	clean once $(ARCHIVE) $(SHLIBNAME)
29
30-all:	$(ARCHIVE)
31+all:	$(ARCHIVE) $(SHLIBNAME)
32
33 $(ARCHIVE): $(BINARIES)
34 	sh -c '$(RM) $(ARCHIVE) || true'
35 	@$(CAT) ARCHIVE
36 	@$(SH) ARCHIVE
37
38-.c.o:
39-	`$(CAT) CCTYPE` -c `$(CAT) CFLAGS` $*.c
40+$(SHLIBNAME):	$(SOFILES)
41+	gcc -shared -Wl,-soname,$(SHLIBNAME) -o $(SHLIBNAME) $(SOFILES) `cat LDFLAGS`
42+	ln -s $(SHLIBNAME) lib$(SHLIBBASE).so
43
44+.c.so:	osdep.h
45+	$(CC) -fPIC -DPIC -D_REENTRANT -c `$(CAT) CFLAGS` ${@:.so=.c} -o $@
46+
47+.c.o:
48+	$(CC) -fPIC -DPIC -D_REENTRANT -c `$(CAT) CFLAGS` $*.c
49
50 # Cleanup
51
52@@ -895,8 +905,7 @@ utf8aux.o: mail.h misc.h osdep.h utf8.h
53
54
55 # OS-dependent
56-
57-osdep.o:mail.h misc.h env.h fs.h ftl.h nl.h tcp.h \
58+OSDEPS= mail.h misc.h env.h fs.h ftl.h nl.h tcp.h \
59 	osdep.h env_unix.h tcp_unix.h \
60 	osdep.c env_unix.c fs_unix.c ftl_unix.c nl_unix.c tcp_unix.c ip_unix.c\
61 	auths.c crexcl.c flockcyg.c flocklnx.c flocksim.c fsync.c \
62@@ -910,12 +919,19 @@ osdep.o:mail.h misc.h env.h fs.h ftl.h n
63 	write.c sslstdio.c \
64 	strerror.c strpbrk.c strstr.c strtok.c strtoul.c \
65 	OSCFLAGS
66+
67+osdep.o:	$(OSDEPS)
68+	$(CC) -fPIC -DPIC -D_REENTRANT `$(CAT) CFLAGS` `$(CAT) OSCFLAGS` -c osdep.c
69+	@echo ========================================================================
70 	@echo Building OS-dependent module
71 	@echo If you get No such file error messages for files x509.h, ssl.h,
72 	@echo pem.h, buffer.h, bio.h, and crypto.h, that means that OpenSSL
73 	@echo is not installed on your system.  Either install OpenSSL first
74 	@echo or build with command: make `$(CAT) OSTYPE` SSLTYPE=none
75-	`$(CAT) CCTYPE` -c `$(CAT) CFLAGS` `$(CAT) OSCFLAGS` -c osdep.c
76+	@echo ========================================================================
77+
78+osdep.so:	$(OSDEPS)
79+	$(CC) -fPIC -DPIC -D_REENTRANT `$(CAT) CFLAGS` `cat OSCFLAGS` -c osdep.c -o $@
80
81 osdep.c: osdepbas.c osdepckp.c osdeplog.c osdepssl.c
82 	$(CAT) osdepbas.c osdepckp.c osdeplog.c osdepssl.c > osdep.c
83