summaryrefslogtreecommitdiffhomepage
path: root/Makefile
blob: 1da35245f27d71c2b6f0dbf600ef35cc486083b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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=\
    file.cpp \
    mime.cpp \
    stringutil.cpp \
    tempfile.cpp \
    url.cpp

SRC=$(PROGSRC)
HEADERS=$(PROGSRC:.cpp=.h)

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 $@ $^

%.d: %.cpp
	$(CXX) $(CXXFLAGS) -MM -MP -MF $@ -c $<

%.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 $(SONAME1) $(SONAME2) $(SONAME3)

.PHONY: clean all install

-include $(wildcard $(SRC:.cpp=.d))