Build everything using -fPIC

Signed-off-by: David Cantrell <dcantrell@redhat.com>
This commit is contained in:
David Cantrell 2020-03-05 14:33:28 -05:00
parent 67cb0dcb06
commit 4bae71fff2
2 changed files with 13 additions and 18 deletions

View File

@ -1,6 +1,6 @@
diff -up mandoc-1.14.5/Makefile.orig mandoc-1.14.5/Makefile
--- mandoc-1.14.5/Makefile.orig 2019-03-10 05:56:43.000000000 -0400
+++ mandoc-1.14.5/Makefile 2020-03-05 12:37:41.995031115 -0500
+++ mandoc-1.14.5/Makefile 2020-03-05 14:16:20.816988115 -0500
@@ -17,6 +17,10 @@
VERSION = 1.14.5
@ -21,24 +21,16 @@ diff -up mandoc-1.14.5/Makefile.orig mandoc-1.14.5/Makefile
install: base-install $(INSTALL_TARGETS)
@@ -388,11 +392,15 @@ include Makefile.depend
# === TARGETS CONTAINING SHELL COMMANDS ================================
+LIBMANDOC_PIC_OBJS = $(COMPAT_OBJS:.o=.pic.o) $(LIBMANDOC_OBJS:.o=.pic.o)
+%.pic.o: %.c
+ $(CC) -c $(CFLAGS) $(CPPFLAGS) -fPIC $< -o $@
+
distclean: clean
@@ -392,7 +396,7 @@ distclean: clean
rm -f Makefile.local config.h config.h.old config.log config.log.old
clean:
- rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
+ rm -f libmandoc.a libmandoc.so.$(SOVERSION) $(LIBMANDOC_OBJS) $(LIBMANDOC_PIC_OBJS) $(COMPAT_OBJS)
+ rm -f libmandoc.a libmandoc.so.$(SOVERSION) $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
rm -f mandoc $(MAIN_OBJS)
rm -f man.cgi $(CGI_OBJS)
rm -f mandocd catman catman.o $(MANDOCD_OBJS)
@@ -431,11 +439,14 @@ base-install: mandoc demandoc soelim
@@ -431,11 +435,14 @@ base-install: mandoc demandoc soelim
$(INSTALL_MAN) makewhatis.8 \
$(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
@ -54,7 +46,7 @@ diff -up mandoc-1.14.5/Makefile.orig mandoc-1.14.5/Makefile
$(INSTALL_LIB) eqn.h man.h mandoc.h mandoc_aux.h mandoc_parse.h \
mdoc.h roff.h tbl.h $(DESTDIR)$(INCLUDEDIR)
$(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
@@ -485,6 +496,8 @@ uninstall:
@@ -485,6 +492,8 @@ uninstall:
rm -f $(DESTDIR)$(MANDIR)/man8/mandocd.8
rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
rm -f $(DESTDIR)$(LIBDIR)/libmandoc.a
@ -63,12 +55,12 @@ diff -up mandoc-1.14.5/Makefile.orig mandoc-1.14.5/Makefile
rm -f $(DESTDIR)$(MANDIR)/man3/mandoc.3
rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_escape.3
rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_malloc.3
@@ -514,6 +527,15 @@ Makefile.local config.h: configure $(TES
@@ -514,6 +523,15 @@ Makefile.local config.h: configure $(TES
libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
ar rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
+libmandoc.so.$(SOVERSION): $(LIBMANDOC_PIC_OBJS)
+ $(CC) -shared -Wl,-soname=libmandoc.so.$(SOMAJOR) -o $@ $(LIBMANDOC_PIC_OBJS)
+libmandoc.so.$(SOVERSION): $(LIBMANDOC_OBJS)
+ $(CC) -shared -Wl,-soname=libmandoc.so.$(SOMAJOR) -o $@ $(LIBMANDOC_OBJS)
+
+libmandoc.so.$(SOMAJOR): libmandoc.so.$(SOVERSION)
+ ln -sf libmandoc.so.$(SOVERSION) libmandoc.so.$(SOMAJOR)

View File

@ -1,6 +1,6 @@
Name: mandoc
Version: 1.14.5
Release: 6%{?dist}
Release: 7%{?dist}
Summary: A suite of tools for compiling mdoc and man
License: ISC
@ -79,7 +79,7 @@ echo 'INSTALL_DATA="${INSTALL} -m 0644"' >> configure.local
echo 'INSTALL_LIBMANDOC=1' >> configure.local
echo 'CFLAGS="%{optflags}"' >> configure.local
echo 'CFLAGS="%{optflags} -fPIC"' >> configure.local
./configure
make %{?_smp_mflags}
@ -237,6 +237,9 @@ fi
%{_mandir}/man3/tbl.3*
%changelog
* Thu Mar 05 2020 David Cantrell <dcantrell@redhat.com> - 1.14.5-7
- Build everything using -fPIC
* Thu Mar 05 2020 David Cantrell <dcantrell@redhat.com> - 1.14.5-6
- Include libmandoc.a in libmandoc-devel