summaryrefslogtreecommitdiffhomepage
path: root/Makefile
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-01-03 17:22:08 +0100
committerRoland Reichwein <mail@reichwein.it>2023-01-03 17:22:08 +0100
commita82d947a594b01af54e056473799ebab619e2bd2 (patch)
treed68a3896a32cd882a3866c4c88dcd6dba85d9c83 /Makefile
parentd00dc2c69164d8a8850d317f2868c6f131b7f679 (diff)
Switch to shared library
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile35
1 files changed, 33 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index fe17e98..1da3524 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,16 @@
include common.mk
+VERSION=$(shell dpkg-parsechangelog --show-field Version)
+DISTROS=base debian11 ubuntu2204 ubuntu2210
+
PROJECTNAME=libreichwein
+DESTDIR=/
+
+SONAME1=libreichwein.so
+SONAME2=libreichwein.so.0
+SONAME3=libreichwein.so.0.0.0
+
CXXFLAGS+= -fvisibility=hidden -fPIC
PROGSRC=\
@@ -14,13 +23,23 @@ PROGSRC=\
SRC=$(PROGSRC)
HEADERS=$(PROGSRC:.cpp=.h)
-all: $(PROJECTNAME).a
+all: staticlib sharedlib
+
+staticlib: $(PROJECTNAME).a
+
+sharedlib: $(SONAME3)
+
+$(SONAME3): $(PROGSRC:.cpp=.o)
+ $(CXX) $(CXXFLAGS) -shared -Wl,-soname,$(SONAME2) -o $@ $^
install:
mkdir -p $(DESTDIR)/usr/lib
cp $(PROJECTNAME).a $(DESTDIR)/usr/lib/
mkdir -p $(DESTDIR)/usr/include/libreichwein
cp $(HEADERS) $(DESTDIR)/usr/include/libreichwein/
+ install $(SONAME3) $(DESTDIR)/usr/lib/$(SONAME3)
+ ln -sf $(SONAME3) $(DESTDIR)/usr/lib/$(SONAME2)
+ ln -sf $(SONAME2) $(DESTDIR)/usr/lib/$(SONAME1)
$(PROJECTNAME).a: $(SRC:.cpp=.o)
ar rcs $@ $^
@@ -31,13 +50,25 @@ $(PROJECTNAME).a: $(SRC:.cpp=.o)
%.o: %.cpp %.d
$(CXX) $(CXXFLAGS) -c $< -o $@
+deb:
+ dpkg-buildpackage -rfakeroot
+
+deb-src:
+ dh_clean
+ dh_auto_clean
+ dpkg-source -b -I.git -Iresult -Ifastcgi -Icgi-bin .
+
+$(DISTROS): deb-src
+ sudo pbuilder build --basetgz /var/cache/pbuilder/$@.tgz --buildresult result/$@ ../libreichwein_$(VERSION).dsc
+ -debsign result/$@/libreichwein_$(VERSION)_amd64.changes
+
# dependencies
ADD_DEP=Makefile
# misc ---------------------------------------------------
clean:
- -rm -f *.o *.a *.d
+ -rm -f *.o *.a *.d $(SONAME1) $(SONAME2) $(SONAME3)
.PHONY: clean all install