summaryrefslogtreecommitdiffhomepage
path: root/Makefile
blob: 24355b72ca9432e0fded2fdd246076c0569903d9 (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
#
# Makefile
#
# Environment: Debian
#

include common.mk

PROJECTNAME=webchat

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

INCLUDES=-I.
HEADERS=config.h storage.h webchat.h compiledsql.h connectionregistry.h
SOURCES=$(HEADERS:.h=.cpp)
OBJECTS=$(HEADERS:.h=.o)
TARGETS=webchat

build: $(TARGETS)
	$(MAKE) -C webassembly

all: build
	./webchat -c webchat.conf

install:
	mkdir -p $(DESTDIR)/usr/bin
	cp webchat $(DESTDIR)/usr/bin
	
	mkdir -p $(DESTDIR)/usr/lib/webchat/html
	cp -r html/* $(DESTDIR)/usr/lib/webchat/html/
	
	uglifyjs html/webchat.js -m -c > $(DESTDIR)/usr/lib/webchat/html/webchat.js || cp html/webchat.js $(DESTDIR)/usr/lib/webchat/html/webchat.js
	htmlmin html/index.html $(DESTDIR)/usr/lib/webchat/html/index.html
	cleancss -o $(DESTDIR)/usr/lib/webchat/html/webchat.css html/webchat.css
	
	mkdir -p $(DESTDIR)/etc
	cp webchat.conf $(DESTDIR)/etc

# link
webchat: $(OBJECTS) main.o
	$(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LIBS) -o $@

# .cpp -> .o
%.o: %.cpp
	$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@

test:
	$(MAKE) -C tests

clean:
	-rm -f *.o $(TARGETS) *.gcov
	-rm -f html/libwebchat.wasm html/libwebchat.js
	$(MAKE) -C tests clean
	$(MAKE) -C webassembly clean

deb:
	dpkg-buildpackage

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

debs: $(DISTROS)

.PHONY: clean