summaryrefslogtreecommitdiff
path: root/Makefile
blob: dcbbe6c26a59460a45663a6efe847a7e7465a3a7 (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
# Nethack osso build dir
# ======================
# Ralf Engels <ralf-engels@gmx.de>
# Josep Torra <jtorra@uoc.edu>
# Copyright: GPL


NETHACK_VERSION_SHORT = 343
NETHACK_VERSION = 3.4.3

DBUS_VERSION_MAJOR = $(shell pkg-config dbus-1 --modversion | awk '{split($$1,t,/\./) ; print t[1]}')
DBUS_VERSION_MINOR = $(shell pkg-config dbus-1 --modversion | awk '{split($$1,t,/\./) ; print t[2]}')

HILDON_VERSION_MAJOR=$(shell pkg-config hildon-1 --modversion | awk '{split($$1,t,/\./) ; print t[1]}')
HILDON_VERSION_MINOR=$(shell pkg-config hildon-1 --modversion | awk '{split($$1,t,/\./) ; print t[2]}')

MAEMO_VERSION = 1
ifneq ($(DBUS_VERSION_MINOR), 23)
	MAEMO_VERSION = 2
endif

MAEMO_FLAGS = -DHILDON -DMAEMO${MAEMO_VERSION}

ifeq ($(HILDON_VERSION_MAJOR), 1)
	MAEMO_FLAGS += -DHILDON1
    MAEMO_VERSION = 4
endif

all: nethack-${NETHACK_VERSION}/src/nethack

# -- unpack the directory
nethack-${NETHACK_VERSION}: nethack-${NETHACK_VERSION_SHORT}-src.tgz
	tar -xzf $<
	touch $@

# -- copy the makefile
nethack-${NETHACK_VERSION}/Makefile: nethack-${NETHACK_VERSION}
	cd $</sys/unix; \
	source setup.sh

# -- copy the gtk2 files
nethack-${NETHACK_VERSION}/win/gtk2: patches/gtk2 
	cp -r $< $@

nethack-${NETHACK_VERSION}/src/winGtk2.h: patches/winGtk2.h
	cp $< $@

# -- apply patches
nethack-${NETHACK_VERSION}/patched: nethack-${NETHACK_VERSION}/Makefile \
	patches/3.4.3-default-options.patch \
	patches/3.4.3-bison.patch \
	patches/3.4.3-X-support.patch \
	patches/3.4.3-gtk2.patch \
	patches/3.4.3-maemo${MAEMO_VERSION}.patch \
	patches/cflags.patch
	patch -p0 -d ${dir $<} <${word 2,$^}
	patch -p0              <${word 3,$^}
	patch -p0 -d ${dir $<} <${word 4,$^}
	patch -p0 -d ${dir $<} <${word 5,$^}
	patch -p0 -d ${dir $<} <${word 6,$^}
	patch -p0 -d ${dir $<} <${word 7,$^}
	touch $@

# -- build the executable
nethack-${NETHACK_VERSION}/src/nethack: nethack-${NETHACK_VERSION}/patched nethack-${NETHACK_VERSION}/win/gtk2 nethack-${NETHACK_VERSION}/src/winGtk2.h
	cd nethack-${NETHACK_VERSION}; \
	make MAEMO_FLAGS="${MAEMO_FLAGS}" CFLAGS_DEB="$(CFLAGS_DEB)"

# -- install
install: nethack-${NETHACK_VERSION}/src/nethack 
	cd nethack-${NETHACK_VERSION}; \
	make install
	mkdir -p $(PREFIX)/share/applications/hildon
	mkdir -p $(PREFIX)/share/icons/hicolor/26x26/hildon
	mkdir -p $(PREFIX)/share/icons/hicolor/40x40/hildon
	mkdir -p $(PREFIX)/share/icons/hicolor/scalable/hildon
	cp data/nethack.desktop-maemo$(MAEMO_VERSION) $(PREFIX)/share/applications/hildon/nethack.desktop
	cp data/pkg_nethack.26.png $(PREFIX)/share/icons/hicolor/26x26/hildon/pkg_nethack.png
	cp data/pkg_nethack.40.png $(PREFIX)/share/icons/hicolor/40x40/hildon/pkg_nethack.png
	cp data/pkg_nethack.64.png $(PREFIX)/share/icons/hicolor/scalable/hildon/pkg_nethack.png
	mkdir -p $(PREFIX)/bin
	cp patches/nethack.sh-maemo$(MAEMO_VERSION) $(PREFIX)/bin/nethack.sh
	cp patches/dot.nethackrc $(PREFIX)/games/lib/nethackdir/.
	cp data/mapbg.xpm $(PREFIX)/games/lib/nethackdir/.
	cp data/gtk2hackrc $(PREFIX)/games/lib/nethackdir/.
	cp data/tiles32.png $(PREFIX)/games/lib/nethackdir/.
	cp data/ClassicBW.png $(PREFIX)/games/lib/nethackdir/.
	cp data/ClassicWB.png $(PREFIX)/games/lib/nethackdir/.
	cp data/ClassicColor.png $(PREFIX)/games/lib/nethackdir/.
	if [ "$(MAEMO_VERSION)" = "1" ]; then \
		cp data/nethack.service $(PREFIX)/share/applications/hildon/. ; \
		mkdir -p $(PREFIX)/etc/osso-backup/applications ; \
		cp data/nethack.conf $(PREFIX)/etc/osso-backup/applications/. ; \
	fi

clean:
	rm -rf nethack-${NETHACK_VERSION} 

.phony: nethack nethack-patches clean