-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·208 lines (199 loc) · 4.38 KB
/
build
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
#!/bin/bash
#
# build - compile and optionally install asciigames components
#
build_2048() {
make
[ "${INSTALL}" ] && sudo PREFIX=${PREFIX} make install
}
build_nethack() {
#
# Repo: https://github.com/doctorfree/asciigames
#
# Fork of Repo: https://github.com/NetHack/NetHack
# with bug fixes and enhancements from UnNetHack at
# https://github.com/UnNetHack/UnNetHack
#
# Initial build for NetHack
# [ -f src/nethack ] || {
# sys/unix/setup.sh sys/unix/hints/linux-asciiville
# make fetch-lua
# make
# cd doc
# make
# cd ..
# }
# chmod +x src/nethack
#
# Revised build with UnNetHack changes
[ -f src/nethack ] || {
cd sys/autoconf
./bootstrap.sh
cd ../..
chmod 755 configure
./configure --prefix=${PREFIX}/games \
--with-owner=games \
--with-group=games \
--enable-wizmode=doctorwhen
make
}
[ "${INSTALL}" ] && sudo PREFIX=${PREFIX} make install
}
build_ninvaders() {
[ -f cmake_build/ninvaders ] || {
cmake -B cmake_build
cmake --build cmake_build -j2
}
}
build_tetris() {
[ -f tetris ] || {
./configure.sh --prefix=${PREFIX}/games --enable-xlib=no --enable-curses=yes
make
make gameserver
}
[ "${INSTALL}" ] && sudo make install
}
usage() {
printf "\nUsage: ./build [-i] [-p prefix] [-u] project [project2 ...]"
printf "\nWhere:"
printf "\n\t-i indicates install"
printf "\n\t-p prefix specifies installation prefix (default ${PREFIX})"
printf "\n\t-u displays this usage message and exits\n"
printf "\nNo arguments: build nethack, configure with prefix=${PREFIX}, build\n"
exit 1
}
arch=
centos=
debian=
fedora=
[ -f /etc/os-release ] && . /etc/os-release
[ "${ID_LIKE}" == "debian" ] && debian=1
[ "${ID}" == "arch" ] || [ "${ID_LIKE}" == "arch" ] && arch=1
[ "${ID}" == "centos" ] && centos=1
[ "${ID}" == "fedora" ] && fedora=1
[ "${debian}" ] || [ -f /etc/debian_version ] && debian=1
if [ "${debian}" ]
then
PKGS="build-essential libncurses-dev cmake"
if [ "$1" == "-r" ]
then
sudo apt remove ${PKGS}
else
sudo apt install ${PKGS} pandoc zip
fi
else
if [ "${arch}" ]
then
PKGS="base-devel cmake ncurses"
if [ "$1" == "-r" ]
then
sudo pacman -Rs ${PKGS}
else
sudo pacman -S --needed ${PKGS} pandoc zip
fi
else
have_dnf=`type -p dnf`
if [ "${have_dnf}" ]
then
PINS=dnf
else
PINS=yum
fi
sudo ${PINS} makecache
if [ "${fedora}" ]
then
PKGS="cmake ncurses-devel"
if [ "$1" == "-r" ]
then
sudo ${PINS} -y remove ${PKGS}
sudo ${PINS} -y groupremove "Development Tools" "Development Libraries"
else
sudo ${PINS} -y groupinstall "Development Tools" "Development Libraries"
sudo ${PINS} -y install ${PKGS} pandoc zip
fi
else
if [ "${centos}" ]
then
PKGS="cmake ncurses-devel"
if [ "$1" == "-r" ]
then
sudo ${PINS} -y remove ${PKGS}
sudo ${PINS} -y groupremove "Development Tools"
else
sudo ${PINS} -y groupinstall "Development Tools"
sudo ${PINS} -y install ${PKGS} pandoc zip
fi
else
echo "Unrecognized operating system"
fi
fi
fi
fi
PROJ=nethack
INSTALL=
platform=`uname -s`
if [ "${platform}" == "Darwin" ]
then
PREFIX=/usr/local
else
PREFIX=/usr
fi
while getopts "ip:u" flag; do
case $flag in
i)
INSTALL=1
;;
p)
PREFIX="$OPTARG"
;;
u)
usage
;;
esac
done
shift $(( OPTIND - 1 ))
for project in $*
do
case "${project}" in
2048)
PROJ=2048
[ -d ${PROJ} ] && {
cd ${PROJ}
build_2048
cd ..
}
;;
nethack)
PROJ=nethack
[ -d ${PROJ} ] && {
cd ${PROJ}
build_nethack
cd ..
}
;;
ninvaders)
PROJ=ninvaders
[ -d ${PROJ} ] && {
cd ${PROJ}
build_ninvaders
cd ..
}
;;
tetris|vitetris)
PROJ=tetris
[ -d ${PROJ} ] && {
cd ${PROJ}
build_tetris
cd ..
}
;;
*)
echo "Unsupported project build: ${project}"
continue
;;
esac
[ -d ${PROJ} ] || {
echo "$PROJ does not exist or is not a directory."
echo "Run: git clone https://github.com/doctorfree/asciigames"
}
done