aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: a2550572dcd1739867b0840053001f7e1b6a3dca (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
# Makefile for bsd-games-extra, by B. Watson. This file is
# released under the WTFPL, so do WTF you want with it.

# You don't want to parallelize this. Use "make -j1" if you
# normally set -jN in your MAKEFLAGS.

# This is just the date, yyyymmdd
VERSION=20150209

# Slackware-specific stuff. Try MANDIR=/usr/share/man and PMAKE=bmake
# for other Linux distros.
MANDIR=/usr/man
PMAKE=pmake

# This bit of ugliness requires GNU make. I don't know BSD make
# well enough to write the equivalent for it.
INC:=$(shell pwd)/include
CFLAGS="$(OPTFLAGS) -I$(INC) -include bsdcompat.h -std=gnu99"

# Slackware64's pmake ships with broken includes.
ifeq ($(shell uname -m),x86_64)
PMAKEHACK="MAKESYSPATH=$(shell pwd)/pmake.hack"
else
PMAKEHACK=/usr/share/mk
endif

# Which games are we building?
DIRS=boggle bs cgram ching colorbars \
     dab dm grdc hack hals_end larn \
     paranoia rogue tetris

# BSD Makefiles don't create subdirs for man pages, so we have
# to do it here.
MANSECTS=5 6 8

# Some of this stuff installs with wrong permissions,
# fix_perms rule fixes it according to these 3 variables:
SCOREFILES=tetris.scores rogue.scores
SGIDBINS=tetris rogue hack
SAVEDIRS=hackdir larn

all:
	export $(PMAKEHACK) ; \
	for dir in $(DIRS); do ( cd $$dir && $(PMAKE) CFLAGS=$(CFLAGS) ); done ; \
	[ -x boggle/mkdict/mkdict ] && cd boggle && $(PMAKE) realall

clean:
	export $(PMAKEHACK) ; \
	for dir in $(DIRS); do ( cd $$dir && $(PMAKE) clean ); done

install: install_files fix_perms

install_files:
	for sect in $(MANSECTS); do \
		mkdir -p $(DESTDIR)/$(MANDIR)/man$$sect ; \
	done
	for dir in $(DIRS); do \
		( cd $$dir && \
			$(PMAKE) install \
				INSTALL="install -D" \
				MANDIR=$(MANDIR) \
				DOCDIR=/usr/doc/bsd-games-extra-$(VERSION) \
		) ; \
	done
	rm -f $(DESTDIR)/mkdict $(DESTDIR)/mkindex

fix_perms:
	for file in $(SCOREFILES); do \
		install -D -o root -g games -m664 /dev/null $(DESTDIR)/var/games/$$file ; \
	done
	for bin in $(SGIDBINS); do \
		chown root:games $(DESTDIR)/usr/games/$$bin ; \
		chmod 2755 $(DESTDIR)/usr/games/$$bin ; \
	done
	for dir in $(SAVEDIRS); do \
		mkdir -p $(DESTDIR)/var/games/$$dir ; \
		chown -R root:games $(DESTDIR)/var/games/$$dir ; \
		chmod -R ug+rw $(DESTDIR)/var/games/$$dir ; \
	done