summaryrefslogtreecommitdiffhomepage
path: root/Makefile
blob: e4a8c3f11fddb87b686436785296a24b502a8140 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#
# Makefile
#
# Environment: Debian
#

DISTROS=base debian11 ubuntu2204
VERSION=$(shell dpkg-parsechangelog --show-field Version)

CXX=clang++-13

ifeq ($(shell which $(CXX)),)
CXX=clang++-10
endif

ifeq ($(shell which $(CXX)),)
CXX=clang++
endif

ifeq ($(shell which $(CXX)),)
CXX=g++-9
endif

ifeq ($(shell which $(CXX)),)
CXX=g++
endif

LIBS=-lfcgi -lboost_filesystem
INCLUDES=-I.
HEADERS=file.h config.h
SOURCES=$(HEADERS:.h=.cpp)
OBJECTS=$(HEADERS:.h=.o)
TARGETS=whiteboard.fcgi

ifeq ($(CXXFLAGS),)
CXXFLAGS=-g -O2
endif

CXXFLAGS+=-Wall -fPIE -Wpedantic -gdwarf-4
LDFLAGS+=-pie

ifeq ($(CXX),g++-9)
CXXFLAGS+=-std=c++17
else
CXXFLAGS+=-std=c++20
endif

ifeq ($(CXX),clang++-10)
LIBS+= \
-fuse-ld=lld-10 \
-lstdc++
#-lc++ \
#-lc++abi
#-lc++fs
#-lstdc++fs
else
LIBS+= \
-lstdc++ \
-lstdc++fs
endif

build: $(TARGETS)

all: build
	./start.sh

install:
	mkdir -p $(DESTDIR)/usr/lib/whiteboard
	cp whiteboard.fcgi $(DESTDIR)/usr/lib/whiteboard/
	
	mkdir -p $(DESTDIR)/usr/lib/whiteboard/html
	cp -r html/* $(DESTDIR)/usr/lib/whiteboard/html/
	
	#uglifyjs html/whiteboard.js -m -c > $(DESTDIR)/usr/lib/whiteboard/html/whiteboard.js
	htmlmin html/index.html $(DESTDIR)/usr/lib/whiteboard/html/index.html
	cleancss -o $(DESTDIR)/usr/lib/whiteboard/html/whiteboard.css html/whiteboard.css
	
	mkdir -p $(DESTDIR)/etc
	cp whiteboard.conf $(DESTDIR)/etc
	
	mkdir -p $(DESTDIR)/usr/bin
	cp whiteboard-cleanup $(DESTDIR)/usr/bin/
	
	mkdir -p $(DESTDIR)/etc/cron.d
	cp whiteboard.cron $(DESTDIR)/etc/cron.d/whiteboard

whiteboard.fcgi: $(OBJECTS)

# link
%.fcgi: %.o
	$(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LIBS) -o $@

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

clean:
	-rm -f *.o *.fcgi

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/$@ ../whiteboard_$(VERSION).dsc
	debsign result/$@/whiteboard_$(VERSION)_amd64.changes

debs: $(DISTROS)

.PHONY: clean