X-Git-Url: http://git.tuebingen.mpg.de/?p=lopsub.git;a=blobdiff_plain;f=Makefile;h=200a7c0d411b5e8cc90c354576d36759a9c63028;hp=7e44330b4ee335e75327c4c5318bbd234a5b112f;hb=d6f28609ba3b250079ac0c55422dafdabb6c0c71;hpb=0cfd2b26c29859490b67351266b90702f7aac0ff diff --git a/Makefile b/Makefile index 7e44330..200a7c0 100644 --- a/Makefile +++ b/Makefile @@ -18,14 +18,27 @@ AR := ar GROFF := groff CP := cp INSTALL := install -GZIP := gzip -f9 +GZIP := gzip -fn9 ZCAT := zcat -DATE := $(shell date '+%B %Y') +DATE_FMT := +%B %Y +# To get a reproducible build, we use $(SOURCE_DATE_EPOCH) instead of the +# current time if this variable is set. +ifdef SOURCE_DATE_EPOCH + DATE := $(shell LC_ALL=C date -u -d '@$(SOURCE_DATE_EPOCH)' \ + '$(DATE_FMT)' 2>/dev/null || LC_ALL=C date -u '$(DATE_FMT)') +else + DATE := $(shell date '$(DATE_FMT)') +endif GIT_VERSION := $(shell ./version-gen.sh) +PLAIN_VERSION := $(firstword $(subst -, , $(GIT_VERSION))) +MAJOR_VERSION := $(firstword $(subst ., , $(PLAIN_VERSION))) +SONAME := liblopsub.so.$(MAJOR_VERSION) +REALNAME := liblopsub.so.$(PLAIN_VERSION) +LINKERNAME:=liblopsub.so m4_man_pages := lopsub-suite.5.gz lopsub.7.gz -all := $(m4_man_pages) liblopsub.a lopsubgen lopsubgen.1.gz \ +all := $(m4_man_pages) $(REALNAME) lopsubgen lopsubgen.1.gz \ lopsubex lopsubex.1.gz all: $(all) @@ -64,39 +77,36 @@ lopsubgen.lsg.c lopsubgen.lsg.h: lopsubgen.suite lopsubgen-stage1 \ lsg1_objs := lopsubgen.o lsg1.o version.o lsg_objs := lopsubgen.o lsg.o lopsubgen.lsg.o lopsub.o version.o liblopsub_objs := config_file.o lopsub.o version.o -lopsubex_objs := lopsubex.o lopsubex.lsg.o version.o +lopsubex_objs := lopsubex.o lopsubex.lsg.o $(liblopsub_objs) $(lsg_objs) $(liblopsub_objs) $(lopsubex_objs): %.o: %.c lopsubgen.o config_file.o: - $(CC) -g -c -o $@ ${@:.o=.c} + $(CC) -g -c -fPIC -o $@ ${@:.o=.c} lsg1.o: lsg.c lsg.h - $(CC) -g -DSTAGE1 -Wall -g -c $< -o $@ + $(CC) -g -DSTAGE1 -Wall -c $< -o $@ %.o: %.c - $(CC) -Wall -I. -g -c -o $@ $< + $(CC) -Wall -I. -g -c -fPIC -o $@ $< # linking lopsubgen-stage1: $(lsg1_objs) $(CC) -Wall -g $(lsg1_objs) -o $@ lopsubgen: $(lsg_objs) $(CC) -Wall -g -o $@ $(lsg_objs) -liblopsub.a: $(liblopsub_objs) - $(AR) -rcs $@ $^ -lopsubex: $(lopsubex_objs) liblopsub.a - $(CC) -Wall -g -o $@ $^ +$(REALNAME): $(liblopsub_objs) + $(CC) --shared -Wl,-soname,liblopsub.so.$(MAJOR_VERSION) -o $@ $^ +lopsubex: $(lopsubex_objs) $(REALNAME) + $(CC) -Wall -g -o $@ $(lopsubex_objs) # web html := $(addprefix web/, $(addsuffix .html, \ - index lopsub-api lopsubgen.1 lopsubex.1 $(m4_man_pages))) -$(html): $(addprefix web/, $(addsuffix .html, header footer)) - + index lopsub-api lopsubgen.1 lopsubex.1 $(m4_man_pages:.gz=))) www: $(html) - -web/lopsub-api.html: lopsub.h.m4 +web/lopsub-api.html: lopsub.h.m4 web/header.html web/footer.html $(M4) -DOUTPUT_MODE=HTML web/header.html $(gendoc) \ $< web/footer.html > $@ web/index.html: web/lopsub.7.html $(LN) -s $(notdir $<) $@ -web/%.html: %.gz +web/%.html: %.gz web/header.html $(CP) web/header.html $@ $(ZCAT) $< | $(GROFF) -m man -Thtml | sed -e '1,/^/d' >> $@ @@ -104,7 +114,9 @@ install: $(all) $(INSTALL) -d $(DESTDIR)$(PREFIX)/lib $(DESTDIR)$(PREFIX)/include \ $(DESTDIR)$(PREFIX)/share/man/man1 $(DESTDIR)$(PREFIX)/share/man/man5 \ $(DESTDIR)$(PREFIX)/share/man/man7 $(DESTDIR)$(PREFIX)/bin - $(INSTALL) -m 644 liblopsub.a $(DESTDIR)$(PREFIX)/lib + $(INSTALL) -m 644 $(REALNAME) $(DESTDIR)$(PREFIX)/lib + $(LN) -s $(REALNAME) $(DESTDIR)$(PREFIX)/lib/$(SONAME) + $(LN) -s $(SONAME) $(DESTDIR)$(PREFIX)/lib/$(LINKERNAME) $(INSTALL) -m 755 lopsubgen $(DESTDIR)$(PREFIX)/bin $(INSTALL) -m 644 lopsub.h $(DESTDIR)$(PREFIX)/include $(INSTALL) -m 644 lopsub-internal.h $(DESTDIR)$(PREFIX)/include