-
Notifications
You must be signed in to change notification settings - Fork 116
/
nethacked.rb
216 lines (189 loc) · 7.2 KB
/
nethacked.rb
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
require 'etc'
# Bugfixed and interface-patched Nethack.
#
# This formula is based on the Nethack formala, and includes the
# patches from same. The original notes from the Nethack formula
# follow:
# - @jterk
#
# Nethack the way God intended it to be played: from a terminal.
# This build script was created referencing:
# * http://nethackwiki.com/wiki/Compiling#On_Mac_OS_X
# * http://nethackwiki.com/wiki/Pkgsrc#patch-ac_.28system.h.29
# and copious hacking until things compiled.
#
# The patch applied incorporates the patch-ac above, the OS X
# instructions from the Wiki, and whatever else needed to be
# done.
# - @adamv
class Nethacked < Formula
homepage 'https://nethacked.github.io/'
url 'https://github.com/nethacked/nethacked/archive/1.0.tar.gz'
sha1 'c30af9be9846616683f669ff6d898fa765bec8cf'
fails_with_llvm :build => 2334
# Don't remove save folder
skip_clean 'libexec/save'
patch :DATA
def install
# Build everything in-order; no multi builds.
ENV.deparallelize
# Symlink makefiles
system 'sh sys/unix/setup.sh'
inreplace "include/config.h",
/^#\s*define HACKDIR.*$/,
"#define HACKDIR \"#{libexec}\""
# Enable wizard mode for the current user
wizard = Etc.getpwuid.name
inreplace "include/config.h",
/^#\s*define\s+WIZARD\s+"wizard"/,
"#define WIZARD \"#{wizard}\""
inreplace "include/config.h",
/^#\s*define\s+WIZARD_NAME\s+"wizard"/,
"#define WIZARD_NAME \"#{wizard}\""
# Make the data first, before we munge the CFLAGS
system "cd dat;make"
cd 'dat' do
%w(perm logfile).each do |f|
system "touch", f
libexec.install f
end
# Stage the data
libexec.install %w(help hh cmdhelp history opthelp wizhelp dungeon license data oracles options rumors quest.dat)
libexec.install Dir['*.lev']
end
# Make the game
ENV.append_to_cflags "-I../include"
system 'cd src;make'
bin.install 'src/nethacked'
(libexec+'save').mkpath
# These need to be group-writable in multi-user situations
system "chmod", "g+w", libexec
system "chmod", "g+w", libexec+'save'
end
end
__END__
diff --git a/include/system.h b/include/system.h
index a4efff9..cfe96f1 100644
--- a/include/system.h
+++ b/include/system.h
@@ -79,10 +79,10 @@ typedef long off_t;
# if !defined(__SC__) && !defined(LINUX)
E long NDECL(random);
# endif
-# if (!defined(SUNOS4) && !defined(bsdi) && !defined(__FreeBSD__)) || defined(RANDOM)
+# if (!defined(SUNOS4) && !defined(bsdi) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__DragonFly__) && !defined(__APPLE__)) || defined(RANDOM)
E void FDECL(srandom, (unsigned int));
# else
-# if !defined(bsdi) && !defined(__FreeBSD__)
+# if !defined(bsdi) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__DragonFly__) && !defined(__APPLE__)
E int FDECL(srandom, (unsigned int));
# endif
# endif
@@ -132,7 +132,7 @@ E void FDECL(perror, (const char *));
E void FDECL(qsort, (genericptr_t,size_t,size_t,
int(*)(const genericptr,const genericptr)));
#else
-# if defined(BSD) || defined(ULTRIX)
+# if defined(BSD) || defined(ULTRIX) && !defined(__NetBSD__)
E int qsort();
# else
# if !defined(LATTICE) && !defined(AZTEC_50)
@@ -421,7 +421,7 @@ E size_t FDECL(strlen, (const char *));
# ifdef HPUX
E unsigned int FDECL(strlen, (char *));
# else
-# if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
+# if !(defined(ULTRIX_PROTO) && defined(__GNUC__)) && !defined(__NetBSD__)
E int FDECL(strlen, (const char *));
# endif
# endif /* HPUX */
@@ -476,9 +476,9 @@ E char *sprintf();
# if !defined(SVR4) && !defined(apollo)
# if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
# if !(defined(SUNOS4) && defined(__STDC__)) /* Solaris unbundled cc (acc) */
-E int FDECL(vsprintf, (char *, const char *, va_list));
-E int FDECL(vfprintf, (FILE *, const char *, va_list));
-E int FDECL(vprintf, (const char *, va_list));
+// E int FDECL(vsprintf, (char *, const char *, va_list));
+// E int FDECL(vfprintf, (FILE *, const char *, va_list));
+// E int FDECL(vprintf, (const char *, va_list));
# endif
# endif
# endif
@@ -521,7 +521,7 @@ E struct tm *FDECL(localtime, (const time_t *));
# endif
# endif
-# if defined(ULTRIX) || (defined(BSD) && defined(POSIX_TYPES)) || defined(SYSV) || defined(MICRO) || defined(VMS) || defined(MAC) || (defined(HPUX) && defined(_POSIX_SOURCE))
+# if defined(ULTRIX) || (defined(BSD) && defined(POSIX_TYPES)) || defined(SYSV) || defined(MICRO) || defined(VMS) || defined(MAC) || (defined(HPUX) && defined(_POSIX_SOURCE)) || defined(__NetBSD__)
E time_t FDECL(time, (time_t *));
# else
E long FDECL(time, (time_t *));
diff --git a/include/unixconf.h b/include/unixconf.h
index fe1b006..3a195a6 100644
--- a/include/unixconf.h
+++ b/include/unixconf.h
@@ -19,20 +19,20 @@
*/
/* define exactly one of the following four choices */
-/* #define BSD 1 */ /* define for 4.n/Free/Open/Net BSD */
+#define BSD 1 /* define for 4.n/Free/Open/Net BSD */
/* also for relatives like SunOS 4.x, DG/UX, and */
/* older versions of Linux */
/* #define ULTRIX */ /* define for Ultrix v3.0 or higher (but not lower) */
/* Use BSD for < v3.0 */
/* "ULTRIX" not to be confused with "ultrix" */
-#define SYSV /* define for System V, Solaris 2.x, newer versions */
+/* #define SYSV */ /* define for System V, Solaris 2.x, newer versions */
/* of Linux */
/* #define HPUX */ /* Hewlett-Packard's Unix, version 6.5 or higher */
/* use SYSV for < v6.5 */
/* define any of the following that are appropriate */
-#define SVR4 /* use in addition to SYSV for System V Release 4 */
+/* #define SVR4 */ /* use in addition to SYSV for System V Release 4 */
/* including Solaris 2+ */
#define NETWORK /* if running on a networked system */
/* e.g. Suns sharing a playground through NFS */
@@ -285,8 +285,8 @@
#if defined(BSD) || defined(ULTRIX)
# if !defined(DGUX) && !defined(SUNOS4)
-#define memcpy(d, s, n) bcopy(s, d, n)
-#define memcmp(s1, s2, n) bcmp(s2, s1, n)
+// #define memcpy(d, s, n) bcopy(s, d, n)
+// #define memcmp(s1, s2, n) bcmp(s2, s1, n)
# endif
# ifdef SUNOS4
#include <memory.h>
diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src
index 29ad99a..7842af2 100644
--- a/sys/unix/Makefile.src
+++ b/sys/unix/Makefile.src
@@ -151,8 +151,8 @@ GNOMEINC=-I/usr/lib/glib/include -I/usr/lib/gnome-libs/include -I../win/gnome
# flags for debugging:
# CFLAGS = -g -I../include
-CFLAGS = -O -I../include
-LFLAGS =
+#CFLAGS = -O -I../include
+#LFLAGS =
# The Qt and Be window systems are written in C++, while the rest of
# NetHack is standard C. If using Qt, uncomment the LINK line here to get
@@ -230,8 +230,8 @@ WINOBJ = $(WINTTYOBJ)
# WINTTYLIB = -ltermcap
# WINTTYLIB = -lcurses
# WINTTYLIB = -lcurses16
-# WINTTYLIB = -lncurses
-WINTTYLIB = -ltermlib
+WINTTYLIB = -lncurses
+#WINTTYLIB = -ltermlib
#
# libraries for X11
# If USE_XPM is defined in config.h, you will also need -lXpm here.
diff --git a/win/tty/termcap.c b/win/tty/termcap.c
index 706e203..dadc9a9 100644
--- a/win/tty/termcap.c
+++ b/win/tty/termcap.c
@@ -835,7 +835,7 @@ cl_eos() /* free after Robert Viduya */
#include <curses.h>
-#ifndef LINUX
+#if !defined(LINUX) && !defined(__APPLE__)
extern char *tparm();
#endif