--- GNUmakefile.in +++ GNUmakefile.in @@ -43,7 +43,10 @@ # - the name of the game. # libfactory = @libfactory@ - +libfactory_so = $(libfactory:.a=.so) +libfactory_sover = $(libfactory_so).@factory_version@ +libcfmem_so = libcfmem.so +libcfmem_sover = libcfmem.so.$(version) # # - programs. # @@ -51,7 +54,7 @@ CXX = @CXX@ # seems configure sometimes finds non-BSD install, so we better # hardcode path to our install-sh -INSTALL = $(srcdir)/bin/install-sh -c +INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM=@INSTALL_PROGRAM@ RANLIB = @RANLIB@ @@ -200,8 +203,8 @@ # factory object files and dependencies factoryobj1 := $(factorysrc:%.cc=%.o) factoryobj := $(factoryobj1:%.y=%.o) -factorygobj := $(factorysrc:%.cc=%.og) -factorypobj := $(factorysrc:%.cc=%.op) +factoryobj1 := $(factorysrc:%.cc=%.o_pic) +factoryobj_pic := $(factoryobj1:%.y=%.o_pic) factorydep := $(factorysrc:%.cc=%.d) factorydep := $(factorydep:%.y=%.d) @@ -295,6 +298,8 @@ # memory manager object files and dependencies memmanobj := $(memmansrc:.cc=.o) memmanobj := $(memmanobj:.c=.o) +memmanobj_pic := $(memmansrc:.cc=.o_pic) +memmanobj_pic := $(memmanobj_pic:.c=.o_pic) memmandep := $(memmansrc:.cc=.d) memmandep := $(memmandep:.c=.d) @@ -426,16 +431,14 @@ # # how to create library objets -%.o: %.cc config.h +%.o: %.cc config.h factoryconf.h $(CXX) -c $< $(LIBCXXFLAGS) -o $@ -%.o: %.c config.h +%.o: %.c config.h factoryconf.h $(CC) -c $< $(LIBCFLAGS) -o $@ -# the debug version: -%.og: %.cc config.h - $(CXX) -g -c $< $(LIBCGGFLAGS) -o $@ -# the profiling version: -%.op: %.cc config.h - $(CXX) -O -pg -c $< $(LIBCGGFLAGS) -o $@ +%.o_pic: %.cc config.h factoryconf.h + $(CXX) -c $< $(LIBCXXFLAGS) -fPIC -o $@ +%.o_pic: %.c config.h factoryconf.h + $(CC) -c $< $(LIBCFLAGS) -fPIC -o $@ # how to create dependency files. To avoid broken dependency files # (which in turn break this GNUmakefile) we first generate them in @@ -463,9 +466,9 @@ # all: $(alltargets) -cf: factoryconf.h factory.h $(libfactory) libsingcf_g.a +cf: factoryconf.h factory.h $(libfactory) $(libfactory_sover) -mem: libcfmem.a +mem: libcfmem.a $(libcfmem_sover) # # - explicit targets. @@ -474,18 +477,16 @@ $(AR) $(ARFLAGS) $@ $^ $(RANLIB) $@ -libsingcf_g.a: $(factorygobj) - $(AR) $(ARFLAGS) $@ $^ - $(RANLIB) $@ - -libsingcf_p.a: $(factorypobj) - $(AR) $(ARFLAGS) $@ $^ - $(RANLIB) $@ +$(libfactory_sover): $(factoryobj_pic) + $(CXX) -shared -Wl,-soname,$(libfactory_so).3 $(LDFLAGS) -o $@ $^ $(LIBS) libcfmem.a: $(memmanobj) $(AR) $(ARFLAGS) $@ $^ $(RANLIB) $@ +$(libcfmem_sover): $(memmanobj_pic) + $(CXX) -shared -Wl,-soname,$(libcfmem_so).3 $(LDFLAGS) -o $@ $^ $(LIBS) + ftmpl_inst.o: ftmpl_inst.cc factoryconf.h factory.h \ $(addprefix templates/,$(templatesrc)) \ $(addprefix templates/,$(templateincl)) @@ -605,45 +606,41 @@ # install: $(installtargets) -install_all: install libsingcf_p.a - -$(INSTALL_DATA) libsingcf_p.a $(libdir)/libsingcf_p.a - install-nolns: install installcf: cf - $(MKINSTALLDIRS) $(libdir) - $(MKINSTALLDIRS) $(includedir) - $(MKINSTALLDIRS) $(templatedir) - $(INSTALL_DATA) $(libfactory) $(libdir)/$(libfactory) - -$(INSTALL_DATA) libsingcf_g.a $(libdir)/libsingcf_g.a - $(INSTALL_DATA) factory.h $(includedir)/factory.h - $(INSTALL_DATA) cf_gmp.h $(includedir)/cf_gmp.h - $(INSTALL_DATA) factoryconf.h $(includedir)/factoryconf.h - $(INSTALL_DATA) $(srcdir)/ftmpl_inst.cc $(templatedir)/ftmpl_inst.cc + $(INSTALL_DATA) -D $(libfactory) $(DESTDIR)$(libdir)/$(libfactory) + $(INSTALL_PROGRAM) -D $(libfactory_sover) $(DESTDIR)$(libdir)/$(libfactory_sover) + $(LN_S) $(libfactory_sover) $(DESTDIR)$(libdir)/$(libfactory_so).3 + $(LN_S) $(libfactory_sover) $(DESTDIR)$(libdir)/$(libfactory_so) + $(INSTALL_DATA) -D factory.h $(DESTDIR)$(includedir)/factory.h + $(INSTALL_DATA) cf_gmp.h $(DESTDIR)$(includedir)/cf_gmp.h + $(INSTALL_DATA) factoryconf.h $(DESTDIR)$(includedir)/factoryconf.h + $(INSTALL_DATA) -D $(srcdir)/ftmpl_inst.cc $(DESTDIR)$(templatedir)/ftmpl_inst.cc for file in $(templatesrc) $(templateincl); do \ - $(INSTALL_DATA) $(srcdir)/templates/$$file $(templatedir)/$$file; \ + $(INSTALL_DATA) $(srcdir)/templates/$$file $(DESTDIR)$(templatedir)/$$file; \ done # we run `ranlib' another time for SUN machines - $(RANLIB) $(libdir)/$(libfactory) + $(RANLIB) $(DESTDIR)$(libdir)/$(libfactory) installmem: mem - $(MKINSTALLDIRS) $(libdir) - $(INSTALL_DATA) libcfmem.a $(libdir)/libcfmem.a + $(INSTALL_DATA) -D libcfmem.a $(DESTDIR)$(libdir)/libcfmem.a + $(INSTALL_PROGRAM) $(libcfmem_sover) $(DESTDIR)$(libdir)/$(libcfmem_sover) + $(LN_S) $(libcfmem_sover) $(DESTDIR)$(libdir)/$(libcfmem_so).3 + $(LN_S) $(libcfmem_sover) $(DESTDIR)$(libdir)/$(libcfmem_so) # once again: another run for SUN - $(RANLIB) $(libdir)/libcfmem.a + $(RANLIB) $(DESTDIR)$(libdir)/libcfmem.a # to a pity, this cannot be done automatically ... installgftables: @echo "Copying GF(q) tables ..." @if test -d gftables; then \ - $(MKINSTALLDIRS) $(gftabledir); \ for file in gftables/gftable.*.*; do \ - $(INSTALL_DATA) $$file $(gftabledir); \ + $(INSTALL_DATA) -D $$file $(DESTDIR)$(gftabledir); \ done \ elif test -d "$(srcdir)"/gftables; then \ - $(MKINSTALLDIRS) $(gftabledir); \ for file in "$(srcdir)"/gftables/gftable.*.*; do \ - $(INSTALL_DATA) $$file $(gftabledir); \ + $(INSTALL_DATA) -D $$file $(DESTDIR)$(gftabledir); \ done \ else \ echo "Run 'make gftables' before installing them"; \