aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 295badac91d434fb6df601ab193a5b2443a3e990 (plain) (blame)
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
VER=0.9.6
PREFIX=/usr/share
DLURL="https://humungus.tedunangst.com/r/honk/d/honk-$(VER).tgz"
MANDIR="$(DESTDIR)$(PREFIX)/man/man"
DOCS="honk-$(VER)/docs"
SYSTEMD=1

getsrc:
	@if ! test -e honk-$(VER).tgz; then \
		$(MAKE) clean; \
		printf "Getting source for honk version $(VER)...\n"; \
		curl --progress-bar -fOJL $(DLURL); \
	fi
	@tar xzf honk-$(VER).tgz; \

rsstitle: rsstitle.patch
	$(MAKE) getsrc;
	cd honk-$(VER)/ && patch -Nbp1 < ../rsstitle.patch;

i18n: i18n.patch i18n.go
	$(MAKE) getsrc;
	cp i18n.go honk-$(VER)/;
	cp i18n_views/* honk-$(VER)/views/;
	cd honk-$(VER) && patch -Nbp1 < ../i18n.patch;
	
altnavbar: altnavbar.patch
	$(MAKE) getsrc;
	cp i18n_views/local.css honk-$(VER)/views;
	cd honk-$(VER) && patch -Nbp1 < ../altnavbar.patch;

i18naltnavbar: altnavbar_i18n.patch
	$(MAKE) getsrc;
	$(MAKE) i18n;
	cp i18n_views/local.css honk-$(VER)/views;
	cd honk-$(VER) && patch -Nbp1 < ../altnavbar_i18n.patch;

build: honk-$(VER)/
	cd honk-$(VER) && go build -mod=`ls -d vendor 2> /dev/null` -o honk;
	
install: honk.service honkinit honk-$(VER)/
	$(MAKE) build;
	install -Dm755 "honk-$(VER)/honk" -t "$(DESTDIR)/usr/bin/";
	install -Dm644 honk-$(VER)/views/* -t "$(DESTDIR)$(PREFIX)/honk/views/";
	install -Dm644 $(DOCS)/* -t "$(DESTDIR)$(PREFIX)/honk/docs/";
	gzip -k -f $(DOCS)/*.{1,3,5,7,8};
	install -Dm644 $(DOCS)/honk.1.gz -t $(MANDIR)1/;
	install -Dm644 $(DOCS)/honk.3.gz -t $(MANDIR)3/;
	install -Dm644 $(DOCS)/honk.5.gz -t $(MANDIR)5/;
	install -Dm644 $(DOCS)/honk.8.gz -t $(MANDIR)8/;
	install -Dm644 $(DOCS)/activitypub.7.gz $(MANDIR)7/honk_activitypub.7.gz;
	install -Dm644 $(DOCS)/hfcs.1.gz $(MANDIR)1/honk_hfcs.1.gz;
	install -Dm644 $(DOCS)/intro.1.gz $(MANDIR)1/honk_intro.1.gz;
	install -Dm644 $(DOCS)/vim.3.gz $(MANDIR)3/honk_vim.3.gz;	
	install -Dm644 "honk-$(VER)"/LICENSE -t "$(DESTDIR)$(PREFIX)/licenses/honk/";
	@if test -n $(SYSTEMD); #if systemd
	    install -Dm644 honk.service -t "$(DESTDIR)/usr/lib/systemd/system/";\
	    systemctl daemon-reload;\
	fi;
	mandb -q > /dev/null;
	if ! getent passwd honk >/dev/null; then \
        useradd -r -d $(DESTDIR)$(PREFIX)/honk honk; \
    fi
	chown honk:honk -R "$(DESTDIR)$(PREFIX)/honk";
	@if ! test -e $(PREFIX)/honk/honk.db; then \
       sh honkinit;\
    fi
	@printf "\nDone\n";

uninstall: $(DESTDIR)$(PREFIX)/honk;
	@if test -n $(SYSTEMD); #if systemd
	    systemctl stop honk;
	fi;
	userdel honk;
	rm -rf $(DESTDIR)$(PREFIX)/honk;
	rm -f $(DESTDIR)/usr/lib/systemd/system/honk.service;
	rm -f $(DESTDIR)/usr/bin/honk;
	find $(DESTDIR)$(PREFIX)/man/ -name "honk*.gz" -exec rm -f {} \;;

clean:
	rm -rf honk honk-$(VER)*;