DATE := $(shell date '+%B %Y')
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)
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 $@
%.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, \
$(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