aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 53b69fbdcfe21ad93800bde1902001cbd50f68d7 (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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
.POSIX:

.PHONY: all \
	clean \
	distclean \
	install \
	install-abook \
	install-bash \
	install-bash-completion \
	install-bin \
	install-bin-man \
	install-curl \
	install-dillo \
	install-dunst \
	install-emacs \
	install-ex \
	install-finger \
	install-games \
	install-games-man \
	install-git \
	install-gnupg \
	install-gtk \
	install-i3 \
	install-ksh \
	install-less \
	install-login-shell \
	install-mail \
	install-man \
	install-mpd \
	install-mpv \
	install-mutt \
	install-mysql \
	install-ncmcpp \
	install-newsboat \
	install-perlcritic \
	install-perltidy \
	install-plenv \
	install-psql \
	install-pyenv \
	install-readline \
	install-sh \
	install-subversion \
	install-systemd \
	install-terminfo \
	install-tidy \
	install-tmux \
	install-urxvt \
	install-vim \
	install-vim-after \
	install-vim-after-ftplugin \
	install-vim-after-indent \
	install-vim-after-plugin \
	install-vim-after-syntax \
	install-vim-bundle \
	install-vim-compiler \
	install-vim-config \
	install-vim-filetype \
	install-vim-ftplugin \
	install-vim-gui \
	install-vim-gui-config \
	install-vim-indent \
	install-vim-plugin \
	install-vim-syntax \
	install-vint \
	install-wget \
	install-x \
	install-zsh \
	check \
	check-bash \
	check-bin \
	check-games \
	check-git-template-hooks \
	check-ksh \
	check-login-shell \
	check-man \
	check-sh \
	check-urxvt \
	check-xinit \
	check-zsh \
	lint \
	lint-bash \
	lint-bin \
	lint-games \
	lint-git-template-hooks \
	lint-ksh \
	lint-sh \
	lint-urxvt \
	lint-vim \
	lint-xinit

.SUFFIXES:
.SUFFIXES: .awk .bash .m4 .mi5 .pl .sed .sh

XDG_CACHE_HOME = $(HOME)/.cache
XDG_CONFIG_HOME = $(HOME)/.config
XDG_DATA_HOME = $(HOME)/.local/share

NAME = 'Tom Ryder'
EMAIL = tom@sanctum.geek.nz
GPG_KEYID = FA09C06E1B670CD0B2F5DE60C14286EA77BB8872
SENDMAIL = /usr/bin/msmtp

BINS = bin/ap \
	bin/apf \
	bin/ax \
	bin/bcq \
	bin/bel \
	bin/bl \
	bin/bp \
	bin/br \
	bin/brnl \
	bin/ca \
	bin/cf \
	bin/cfr \
	bin/chc \
	bin/chn \
	bin/clog \
	bin/clrd \
	bin/clwr \
	bin/csmw \
	bin/dam \
	bin/d2u \
	bin/ddup \
	bin/defang \
	bin/dfv \
	bin/dmp \
	bin/dub \
	bin/edda \
	bin/eds \
	bin/exm \
	bin/fgscr \
	bin/finc \
	bin/fnl \
	bin/fnp \
	bin/gms \
	bin/grc \
	bin/grec \
	bin/gred \
	bin/gscr \
	bin/gwp \
	bin/hms \
	bin/htdec \
	bin/htenc \
	bin/htref \
	bin/hurl \
	bin/igex \
	bin/isgr \
	bin/ix \
	bin/jfc \
	bin/jfcd \
	bin/jfp \
	bin/loc \
	bin/mi5 \
	bin/max \
	bin/maybe \
	bin/mean \
	bin/med \
	bin/mex \
	bin/mftl \
	bin/mim \
	bin/min \
	bin/mkcp \
	bin/mked \
	bin/mkmv \
	bin/mktd \
	bin/mkvi \
	bin/mode \
	bin/motd \
	bin/msc \
	bin/murl \
	bin/mw \
	bin/nlbr \
	bin/oii \
	bin/onl \
	bin/osc \
	bin/pa \
	bin/paz \
	bin/ped \
	bin/phpcsff \
	bin/pit \
	bin/plmu \
	bin/p \
	bin/pp \
	bin/pph \
	bin/pst \
	bin/pvi \
	bin/pwg \
	bin/qat \
	bin/quo \
	bin/rep \
	bin/rfcf \
	bin/rfcr \
	bin/rfct \
	bin/rgl \
	bin/rnda \
	bin/rndf \
	bin/rndi \
	bin/rndl \
	bin/rnds \
	bin/sd2u \
	bin/sec \
	bin/shb \
	bin/slow \
	bin/sls \
	bin/slsf \
	bin/sqs \
	bin/sra \
	bin/sshi \
	bin/sta \
	bin/stbl \
	bin/stex \
	bin/stws \
	bin/su2d \
	bin/sue \
	bin/supp \
	bin/swr \
	bin/td \
	bin/tl \
	bin/tlcs \
	bin/tm \
	bin/tot \
	bin/trs \
	bin/try \
	bin/u2d \
	bin/umake \
	bin/unf \
	bin/urlc \
	bin/urlh \
	bin/urlmt \
	bin/uts \
	bin/vest \
	bin/vex \
	bin/vic \
	bin/wro \
	bin/xgo \
	bin/xgoc \
	bin/xrbg \
	bin/xrq

BINS_M4 = bin/chn.m4 \
	bin/dfv.m4 \
	bin/edda.m4 \
	bin/mim.m4 \
	bin/oii.m4 \
	bin/phpcsff.m4 \
	bin/pst.m4 \
	bin/swr.m4 \
	bin/tlcs.m4 \
	bin/try.m4 \
	bin/urlc.m4

BINS_SH = bin/chn.sh \
	bin/dfv.sh \
	bin/edda.sh \
	bin/mim.sh \
	bin/oii.sh \
	bin/phpcsff.sh \
	bin/pst.sh \
	bin/swr.sh \
	bin/tlcs.sh \
	bin/try.sh \
	bin/urlc.sh

GAMES = games/aaf \
	games/acq \
	games/aesth \
	games/chkl \
	games/dr \
	games/drakon \
	games/kvlt \
	games/philsay \
	games/pks \
	games/rndn \
	games/rot13 \
	games/uuu \
	games/squ \
	games/strik \
	games/xyzzy \
	games/zs

GIT_TEMPLATE_HOOKS = git/template/hooks/post-update \
	git/template/hooks/pre-commit \
	git/template/hooks/prepare-commit-msg

all: $(BINS) \
	$(GIT_TEMPLATE_HOOKS) \
	git/config \
	gnupg/profile.d/gnupg.sh \
	less/less

clean distclean:
	rm -f -- \
		$(BINS) \
		$(BINS_M4) \
		$(BINS_SH) \
		$(GAMES) \
		$(GIT_TEMPLATE_HOOKS) \
		dillo/dillorc \
		dillo/dillorc.m4 \
		git/config \
		git/config.m4 \
		gnupg/profile.d/gnupg.sh \
		include/mktd.m4 \
		less/less \
		mutt/filters/markdown-to-html \
		urxvt/ext/select \
		vim/dist/*

.awk:
	sh bin/shb.sh awk -f < $< > $@
	chmod +x ./$@

.bash:
	sh bin/shb.sh bash < $< > $@
	chmod +x ./$@

.pl:
	sh bin/shb.sh perl < $< > $@
	chmod +x ./$@

.sed:
	sh bin/shb.sh sed -f < $< > $@
	chmod +x ./$@

.sh:
	sh bin/shb.sh sh < $< > $@
	chmod +x ./$@

.mi5.m4:
	awk -f bin/mi5.awk < $< > $@

.m4.sh:
	m4 < $< > $@

bin/chn.sh: bin/chn.m4 include/mktd.m4
bin/dfv.sh: bin/dfv.m4 include/mktd.m4
bin/edda.sh: bin/edda.m4 include/mktd.m4
bin/mim.sh: bin/mim.m4 include/mktd.m4
bin/oii.sh: bin/oii.m4 include/mktd.m4
bin/phpcsff.sh: bin/phpcsff.m4 include/mktd.m4
bin/pst.sh: bin/pst.m4 include/mktd.m4
bin/swr.sh: bin/swr.m4 include/mktd.m4
bin/tlcs.sh: bin/tlcs.m4 include/mktd.m4
bin/try.sh: bin/try.m4 include/mktd.m4
bin/urlc.sh: bin/urlc.m4 include/mktd.m4

dillo/dillorc: dillo/dillorc.m4
	m4 \
		-D HOME=$(HOME) \
		dillo/dillorc.m4 > $@

git/config: git/config.m4
	m4 \
		-D NAME=$(NAME) \
		-D EMAIL=$(EMAIL) \
		-D GPG_KEYID=$(GPG_KEYID) \
		-D SENDMAIL=$(SENDMAIL) \
		-D XDG_CONFIG_HOME=$(XDG_CONFIG_HOME) \
		git/config.m4 > $@

less/less: less/lesskey
	lesskey --output $@ less/lesskey

gnupg/profile.d/gnupg.sh: gnupg/profile.d/gnupg.sh.m4
	m4 \
		-D GPG_KEYID=$(GPG_KEYID) \
		gnupg/profile.d/gnupg.sh.m4 > $@

MAILDIR = $(HOME)/Mail

install: install-bin \
	install-curl \
	install-ex \
	install-git \
	install-gnupg \
	install-less \
	install-login-shell \
	install-man \
	install-readline \
	install-vim

install-conf:
	sh install/conf.sh

install-abook:
	mkdir -p -- $(HOME)/.abook
	cp -p -- abook/abookrc $(HOME)/.abook

install-bash: check-bash install-sh bin/han 
	mkdir -p -- $(HOME)/.bashrc.d $(HOME)/.local/bin
	cp -p -- bash/bashrc $(HOME)/.bashrc
	cp -p -- bash/bashrc.d/* $(HOME)/.bashrc.d
	cp -p -- bash/bash_profile $(HOME)/.bash_profile
	cp -p -- bash/bash_logout $(HOME)/.bash_logout
	cp -p -- bin/han $(HOME)/.local/bin

install-bash-completion: install-bash
	mkdir -p -- $(HOME)/.bash_completion.d $(XDG_CONFIG_HOME)
	cp -p -- bash/bash_completion $(XDG_CONFIG_HOME)
	cp -p -- bash/bash_completion.d/* $(HOME)/.bash_completion.d

install-bin: $(BINS) install-bin-man
	mkdir -p -- $(HOME)/.local/bin
	find bin -type f -perm -u=x \
		-exec cp -p -- {} $(HOME)/.local/bin \;

install-bin-man:
	mkdir -p -- $(XDG_DATA_HOME)/man/man1 $(XDG_DATA_HOME)/man/man8
	cp -p -- man/man1/*.1df $(XDG_DATA_HOME)/man/man1
	cp -p -- man/man8/*.8df $(XDG_DATA_HOME)/man/man8

install-curl:
	cp -p -- curl/curlrc $(HOME)/.curlrc

install-dillo: dillo/dillorc install-x
	mkdir -p -- $(HOME)/.dillo
	cp -p -- dillo/dillorc $(HOME)/.dillo/dillorc

install-dunst: install-x
	mkdir -p -- $(XDG_CONFIG_HOME)/dunst
	cp -p -- dunst/dunstrc $(XDG_CONFIG_HOME)/dunst

install-emacs: emacs/bin/emacsm install-sh
	mkdir -p -- $(HOME)/.local/bin
	cp -p -- emacs/emacs $(HOME)/.emacs
	cp -p -- emacs/bin/emacsm $(HOME)/.local/bin
	cp -p -- emacs/profile.d/emacs.sh $(HOME)/.profile.d

install-ex:
	cp -p -- ex/exrc $(HOME)/.exrc

install-finger:
	cp -p -- finger/plan $(HOME)/.plan
	cp -p -- finger/project $(HOME)/.project
	cp -p -- finger/pgpkey $(HOME)/.pgpkey

install-games: $(GAMES) install-games-man
	mkdir -p -- $(HOME)/.local/games
	find games -type f -perm -u=x \
		-exec cp -p -- {} $(HOME)/.local/games \;

install-games-man:
	mkdir -p -- $(XDG_DATA_HOME)/man/man6
	cp -p -- man/man6/*.6df $(XDG_DATA_HOME)/man/man6

install-git: git/config $(GIT_TEMPLATE_HOOKS)
	mkdir -p -- $(XDG_CONFIG_HOME)/git
	cp -p -- git/config $(XDG_CONFIG_HOME)/git/config
	find git/template \
		-type d -exec sh -c 'mkdir -p -- \
			$(XDG_CONFIG_HOME)/git/template"$${1#git/template}"' \
		_ {} \; \
		-o ! -name '*.*' -exec sh -c 'cp -p -- "$$1" \
			$(XDG_CONFIG_HOME)/git/template"$${1#git/template}"' \
		_ {} \;

install-gnupg: gnupg/profile.d/gnupg.sh install-sh
	cp -p -- gnupg/profile.d/* $(HOME)/.profile.d

install-gtk:
	mkdir -p -- $(XDG_CONFIG_HOME)/gtk-3.0
	cp -p -- gtk/gtkrc-2.0 $(HOME)/.gtkrc-2.0
	cp -p -- gtk/gtk-3.0/settings.ini $(XDG_CONFIG_HOME)/gtk-3.0

install-i3: install-x
	mkdir -p -- $(XDG_CONFIG_HOME)/i3
	cp -p -- i3/* $(XDG_CONFIG_HOME)/i3

install-keychain: install-sh
	cp -p -- keychain/profile.d/* $(HOME)/.profile.d
	cp -p -- keychain/shrc.d/* $(HOME)/.shrc.d

install-less: less/less
	mkdir -p -- $(HOME)/.profile.d
	cp -- less/profile.d/* $(HOME)/.profile.d
	mkdir -p -- $(XDG_CONFIG_HOME)/less
	cp -p -- less/less $(XDG_CONFIG_HOME)/less/key

install-mail:
	cp -p -- mail/signature $(HOME)/.signature

install-man:
	mkdir -p -- $(XDG_DATA_HOME)/man/man7
	cp -p -- man/man7/dotfiles.7df $(XDG_DATA_HOME)/man/man7

install-mpd: install-sh
	mkdir -p -- $(HOME)/.mpd/playlists
	cp -p -- mpd/profile.d/* $(HOME)/.profile.d
	cp -p -- mpd/mpdconf $(HOME)/.mpdconf

install-mpv:
	mkdir -p -- $(XDG_CONFIG_HOME)/mpv
	cp -p -- mpv/* $(XDG_CONFIG_HOME)/mpv

install-mutt: install-gnupg install-mail mutt/filters/markdown-to-html
	mkdir -p -- \
		$(XDG_CONFIG_HOME)/mutt \
		$(XDG_CONFIG_HOME)/mutt/muttrc.d \
		$(XDG_CACHE_HOME)/mutt/headers \
		$(XDG_DATA_HOME)/mutt/autocrypt \
		$(HOME)/.local/libexec/mutt/filters
	cp -p -- mutt/muttrc \
		$(XDG_CONFIG_HOME)/mutt
	cp -p -- mutt/muttrc.d/src \
		$(XDG_CONFIG_HOME)/mutt/muttrc.d
	touch -- $(XDG_CONFIG_HOME)/mutt/aliases
	cp -p -- mutt/filters/markdown-to-html \
		$(HOME)/.local/libexec/mutt/filters

install-ncmcpp: install-mpd
	mkdir -p -- $(HOME)/.ncmpcpp
	cp -p -- ncmpcpp/config $(HOME)/.ncmpcpp

install-newsboat: install-systemd
	mkdir -p -- $(XDG_CONFIG_HOME)/newsboat $(XDG_DATA_HOME)/newsboat
	cp -p -- newsboat/config $(XDG_CONFIG_HOME)/newsboat
	-command -v systemctl >/dev/null 2>&1 \
		&& mkdir -p -- $(XDG_CONFIG_HOME)/systemd/user \
		&& cp -p -- newsboat/systemd/user/* $(XDG_CONFIG_HOME)/systemd/user \
		&& systemctl --user daemon-reload \
		&& systemctl --user start reload-newsboat.timer \
		&& systemctl --user enable reload-newsboat.timer

install-mysql:
	cp -p -- mysql/my.cnf $(HOME)/.my.cnf

install-ksh: check-ksh install-sh
	mkdir -p -- $(HOME)/.kshrc.d
	cp -p -- ksh/shrc.d/* $(HOME)/.shrc.d
	cp -p -- ksh/kshrc $(HOME)/.kshrc
	cp -p -- ksh/kshrc.d/* $(HOME)/.kshrc.d

install-login-shell: check-login-shell
	sh install/login-shell.sh

install-perlcritic: install-sh
	cp -p -- perlcritic/profile.d/* $(HOME)/.profile.d
	mkdir -p -- $(XDG_CONFIG_HOME)/perlcritic
	cp -p -- perlcritic/perlcriticrc $(XDG_CONFIG_HOME)/perlcritic/perlcriticrc

install-perltidy: install-sh
	cp -p -- perltidy/profile.d/* $(HOME)/.profile.d
	mkdir -p -- $(XDG_CONFIG_HOME)/perltidy
	cp -p -- perltidy/perltidyrc $(XDG_CONFIG_HOME)/perltidy/perltidyrc

install-plenv: install-sh
	cp -p -- plenv/profile.d/* $(HOME)/.profile.d
	cp -p -- plenv/shrc.d/* $(HOME)/.shrc.d

install-psql:
	cp -p -- psql/psqlrc $(HOME)/.psqlrc

install-pyenv: install-sh
	cp -p -- pyenv/profile.d/* $(HOME)/.profile.d
	cp -p -- pyenv/shrc.d/* $(HOME)/.shrc.d

install-readline:
	cp -p -- readline/inputrc $(HOME)/.inputrc

install-sh: check-sh
	mkdir -p -- $(HOME)/.profile.d $(HOME)/.shrc.d
	cp -p -- sh/profile $(HOME)/.profile
	cp -p -- sh/profile.d/* $(HOME)/.profile.d
	cp -p -- sh/shinit $(HOME)/.shinit
	cp -p -- sh/shrc $(HOME)/.shrc
	cp -p -- sh/shrc.d/* $(HOME)/.shrc.d

install-subversion:
	mkdir -p -- $(HOME)/.subversion
	cp -p -- subversion/config $(HOME)/.subversion

install-systemd:
	-command -v systemctl >/dev/null 2>&1 \
		&& mkdir -p -- $(XDG_CONFIG_HOME)/systemd/user \
		&& cp -p -- systemd/user/* $(XDG_CONFIG_HOME)/systemd/user \
		&& systemctl --user daemon-reload \

# Need to install these in appropriate order to meet dependencies; could trust
# the system glob, but a fixed list is just more straightforward
install-terminfo:
	tic terminfo/putty.ti
	tic terminfo/putty-256color.ti
	tic terminfo/rxvt.ti
	tic terminfo/rxvt-256color.ti
	tic terminfo/rxvt-unicode.ti
	tic terminfo/rxvt-unicode-256color.ti
	tic terminfo/screen.ti
	tic terminfo/screen-256color.ti

install-tidy: install-sh
	cp -p -- tidy/profile.d/* $(HOME)/.profile.d
	mkdir -p -- $(XDG_CONFIG_HOME)/tidy
	cp -p -- tidy/tidyrc $(XDG_CONFIG_HOME)/tidy/tidyrc

install-tmux: tmux/tmux.conf install-terminfo
	cp -p -- tmux/tmux.conf $(HOME)/.tmux.conf

install-urxvt: urxvt/ext/select
	mkdir -p -- $(HOME)/.urxvt/ext
	find urxvt/ext -type f ! -name '*.pl' \
		-exec cp -p -- {} $(HOME)/.urxvt/ext \;

VIM = vim
VIMDIR = $(HOME)/.vim
VIMRC = $(VIMDIR)/vimrc

install-vim: install-vim-after \
	install-vim-autoload \
	install-vim-bundle \
	install-vim-compiler \
	install-vim-config \
	install-vim-filetype \
	install-vim-ftplugin \
	install-vim-indent \
	install-vim-plugin \
	install-vim-syntax

install-vim-after: install-vim-after-ftplugin \
	install-vim-after-indent \
	install-vim-after-plugin \
	install-vim-after-syntax

install-vim-after-ftplugin: install-vim-compiler
	mkdir -p -- $(VIMDIR)/after/ftplugin
	cp -p -- vim/after/ftplugin/*.vim $(VIMDIR)/after/ftplugin

install-vim-after-indent: install-vim-autoload
	mkdir -p -- $(VIMDIR)/after/indent
	cp -p -- vim/after/indent/*.vim $(VIMDIR)/after/indent

install-vim-after-plugin: install-vim-autoload
	mkdir -p -- $(VIMDIR)/after/plugin
	cp -p -- vim/after/plugin/*.vim $(VIMDIR)/after/plugin

install-vim-after-syntax:
	mkdir -p -- $(VIMDIR)/after/syntax
	cp -p -- vim/after/syntax/*.vim $(VIMDIR)/after/syntax

install-vim-autoload:
	mkdir -p -- $(VIMDIR)/autoload
	cd vim && find autoload \
		-type d -exec sh -c \
		'mkdir -p -- $(VIMDIR)/"$$1"' _ {} \; \
		-o \
		-type f -exec sh -c \
		'cp -p -- "$$1" $(VIMDIR)/"$$1"' _ {} \;

install-vim-bundle: install-vim-config
	cd vim/bundle && find */* \
		-type d -exec sh -c \
		'mkdir -p -- $(VIMDIR)/"$${1#*/}"' _ {} \;
	cd vim/bundle && find */*/* \
		-type f -exec sh -c \
		'cp -p -- "$$1" $(VIMDIR)/"$${1#*/}"' _ {} \;
	$(VIM) -e -u NONE -c 'helptags $(VIMDIR)/doc' -c quit

install-vim-compiler:
	mkdir -p -- $(VIMDIR)/compiler
	cp -p -- vim/compiler/*.vim $(VIMDIR)/compiler

install-vim-config: install-vim-autoload
	cp -p -- vim/vimrc.stub $(HOME)/.vimrc
	cp -p -- vim/vimrc $(VIMRC)

install-vim-filetype:
	cp -p -- vim/filetype.vim vim/scripts.vim $(VIMDIR)

install-vim-ftplugin: install-vim-autoload
	mkdir -p -- $(VIMDIR)/ftplugin
	cp -p -- vim/ftplugin/*.vim $(VIMDIR)/ftplugin

GVIMRC = $(HOME)/.gvimrc

install-vim-gui: install-vim \
	install-vim-gui-config

install-vim-gui-config:
	cp -p -- vim/gvimrc $(GVIMRC)

install-vim-indent:
	mkdir -p -- $(VIMDIR)/indent
	cp -p -- vim/indent/*.vim $(VIMDIR)/indent

install-vim-plugin: install-vim-autoload
	mkdir -p -- $(VIMDIR)/plugin
	cp -p -- vim/plugin/*.vim $(VIMDIR)/plugin

install-vim-syntax:
	mkdir -p -- $(VIMDIR)/syntax
	cp -p -- vim/syntax/*.vim $(VIMDIR)/syntax

install-vint:
	cp -p -- vint/vintrc.yaml $(HOME)/.vintrc.yaml

install-wget: install-sh
	cp -p -- wget/profile.d/* $(HOME)/.profile.d
	mkdir -p -- $(XDG_CACHE_HOME)/wget $(XDG_CONFIG_HOME)/wget
	cp -p -- wget/wgetrc $(XDG_CONFIG_HOME)/wget/wgetrc

install-x: check-xinit
	mkdir -p -- \
		$(XDG_CONFIG_HOME)/sxhkd \
		$(HOME)/.xinitrc.d \
		$(HOME)/.Xresources.d
	cp -p -- X/redshift.conf $(XDG_CONFIG_HOME)
	cp -p -- X/sxhkdrc $(XDG_CONFIG_HOME)/sxhkd
	cp -p -- X/xinitrc $(HOME)/.xinitrc
	cp -p -- X/xinitrc.d/* $(HOME)/.xinitrc.d
	cp -p -- X/Xresources $(HOME)/.Xresources
	cp -p -- X/Xresources.d/* $(HOME)/.Xresources.d

install-zsh: check-zsh install-sh
	mkdir -p -- $(HOME)/.zshrc.d
	cp -p -- zsh/profile.d/* $(HOME)/.profile.d
	cp -p -- zsh/zprofile $(HOME)/.zprofile
	cp -p -- zsh/zshrc $(HOME)/.zshrc
	cp -p -- zsh/zshrc.d/* $(HOME)/.zshrc.d

check: check-bin \
	check-git-template-hooks \
	check-login-shell \
	check-man \
	check-sh

check-bash:
	sh check/bash.sh

check-bin: $(BINS)
	sh check/bin.sh

check-games: $(GAMES)
	sh check/games.sh

check-git-template-hooks: $(GIT_TEMPLATE_HOOKS)
	sh check/git-template-hooks.sh

check-man:
	sh check/man.sh

check-ksh:
	sh check/ksh.sh

check-login-shell:
	sh check/login-shell.sh

check-sh:
	sh check/sh.sh

check-urxvt: urxvt/ext/select
	sh check/urxvt.sh

check-xinit:
	sh check/xinit.sh

check-zsh:
	sh check/zsh.sh

lint: lint-bash \
	lint-bin \
	lint-games \
	lint-git-template-hooks \
	lint-ksh \
	lint-sh \
	lint-urxvt \
	lint-vim \
	lint-xinit

lint-bash: check-bash
	sh lint/bash.sh

lint-bin: check-bin
	sh lint/bin.sh

lint-games: check-games
	sh lint/games.sh

lint-git-template-hooks: check-git-template-hooks
	sh lint/git-template-hooks.sh

lint-ksh: check-ksh
	sh lint/ksh.sh

lint-sh: check-sh
	sh lint/sh.sh

lint-urxvt: check-urxvt
	sh lint/urxvt.sh

lint-vim:
	sh lint/vim.sh

lint-xinit: check-xinit
	sh lint/xinit.sh