summaryrefslogtreecommitdiffhomepage
path: root/Makefile
blob: 0dacc8ed2a2efab702e8bfdffbbd0d219e81d570 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
include common.mk

PROJECTNAME=weblog

DISTROS=debian11
TGZNAME=$(PROJECTNAME)-$(VERSION).tar.xz

LDLIBS=\
-lfcgi \
-lreichwein \
-lfmt \
-lboost_context \
-lboost_coroutine \
-lboost_program_options \
-lboost_system \
-lboost_thread \
-lboost_filesystem \
-lboost_regex \
-lpthread \
-ldl

SRC=\
    weblog.cpp config.cpp main.cpp

default: $(PROJECTNAME)

all: default
	webapp-runner ::1:9019 ./$(PROJECTNAME) -c $(PROJECTNAME).conf

$(PROJECTNAME): $(SRC:.cpp=.o)
	$(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LIBS) -o $@

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

%.o: %.cpp %.d
	$(CXX) $(CXXFLAGS) -c $< -o $@

# dependencies

ADD_DEP=Makefile

install:
	mkdir -p $(DESTDIR)/usr/bin
	cp $(PROJECTNAME) $(DESTDIR)/usr/bin/
	
	mkdir -p $(DESTDIR)/etc
	cp weblog.conf $(DESTDIR)/etc

deb:
	dpkg-buildpackage

debs: $(DISTROS)

deb-src: clean
	dh_clean
	dh_auto_clean
	dpkg-source -b -I.git -Iresult .

$(DISTROS): deb-src
	sudo pbuilder build --basetgz /var/cache/pbuilder/$@.tgz --buildresult result/$@ ../$(PROJECTNAME)_$(VERSION).dsc
	debsign result/$@/$(PROJECTNAME)_$(VERSION)_amd64.changes

DISTFILES=$(shell git ls-files 2>/dev/null)

dist: clean
	rm -rf $(PROJECTNAME)-$(VERSION)
	mkdir $(PROJECTNAME)-$(VERSION)
	cp --parents -r $(DISTFILES) $(PROJECTNAME)-$(VERSION)
	tar cfJ ../$(PROJECTNAME)-$(VERSION).tar.xz $(PROJECTNAME)-$(VERSION)
	rm -rf $(PROJECTNAME)-$(VERSION)
	ls -l ../$(PROJECTNAME)-$(VERSION).tar.xz

upload: dist
	scp ../$(TGZNAME) antcom.de:/var/www/reichwein.it-download/
	scp -r result antcom.de:
	scp -r remote-install.sh antcom.de:
	ssh antcom.de ./remote-install.sh $(PROJECTNAME) $(VERSION)
	ssh antcom.de rm -rf remote-install.sh result

# misc ---------------------------------------------------
clean:
	-rm -f *.o *.d $(PROJECTNAME)

.PHONY: clean install all

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