虎(牛)龍未酉2.1

記録帳|+n年後のジブンが思い出せますように……

【記録】rogueのインストール (Rogue 5.4.5p)

roguemacOS Catalinaにインストールしようと思った

 

ローグをメンテナンスしてくださっている下記に準拠。

http://yozvox.web.fc2.com/526F677565.html

 

rogue 5.4p

rogue clone III p

Angband

 

が当面のターゲット。だがしかし、コンパイル済みバイナリは動かないので、gccコンパイルできるようになるのぢゃ。 

 

1)gccのインストール

ターミナルで「gcc」と打つと、自動的にインストーラが起動するので、従った

 

2)homebrewのインストール

macOS用パッケージマネージャー — Homebrew

の言う通りに「/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"」とターミナルに打ち込んだ

 

3)ncursesのインストール

brew install ncurses

 

4)Makefileを書き換える

+CPPFLAGS = -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include
+
+LDFLAGS = -L/usr/local/opt/ncurses/lib 

  

Macでrougueをビルドする|Scratch book

 

5)まだエラーが出とる

gcc -g -O2 -L/usr/local/opt/ncurses/lib vers.o extern.o armor.o chase.o command.o daemon.o daemons.o fight.o init.o io.o list.o mach_dep.o main.o mdport.o misc.o monsters.o move.o new_level.o options.o pack.o passages.o potions.o rings.o rip.o rooms.o save.o scrolls.o state.o sticks.o things.o weapons.o wizard.o xcrypt.o -lcurses -o rogue5
Undefined symbols for architecture x86_64:
"_add_pass", referenced from:
_command in command.o
"_create_obj", referenced from:
_command in command.o
"_passwd", referenced from:
_command in command.o
"_pr_list", referenced from:
_command in command.o
"_show_map", referenced from:
_command in command.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [rogue5] Error 1

 

 

 6)C言語の作法を学ぶ……

$ chmod +x configure

$ ./configure

 

Makefileの書き換え

+CPPFLAGS = -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include
+
+LDFLAGS = -L/usr/local/opt/ncurses/lib 

$ make clean

$ make install

やっぱりエラーが出る。

gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c main.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c mdport.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c misc.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c monsters.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c move.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c new_level.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c options.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c pack.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c passages.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c potions.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c rings.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c rip.c
rip.c:251:44: warning: format specifies type 'int' but the argument has type 'time_t' (aka 'long') [-Wformat]
sprintf(logmessage, "%d %d %.20s %d ", time(NULL), amount, whoami,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
%ld
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
__builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
^~~~~~~~~~~
1 warning generated.
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c rooms.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c save.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c scrolls.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c state.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c sticks.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c things.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c weapons.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c wizard.c
gcc -g -O2 -DHAVE_CONFIG_H -I/usr/local/opt/ncurses/include -c xcrypt.c
gcc -g -O2 -L/usr/local/opt/ncurses/lib vers.o extern.o armor.o chase.o command.o daemon.o daemons.o fight.o init.o io.o list.o mach_dep.o main.o mdport.o misc.o monsters.o move.o new_level.o options.o pack.o passages.o potions.o rings.o rip.o rooms.o save.o scrolls.o state.o sticks.o things.o weapons.o wizard.o xcrypt.o -lcurses -o rogue5
Undefined symbols for architecture x86_64:
"_wizard", referenced from:
_rs_save_file in state.o
_rs_restore_file in state.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [rogue5] Error 1

 

理由はわからんけど、wizardという変数を認識できない様子。

external wizardがあるんだけど(たぶん)。

 

7)コメントアウト

本質的な解決じゃないと思うんだけど

state.cの2行をコメントアウトした。

// rs_write_int(savef, wizard);

// rs_read_int(savef, &wizard);

 

 makeは通って、

$ make install

で /usr/local/bin に rogue5という実行ファイルがコピーされた

 

8)こんどは^H問題

走ろうと思って[ctrl]+[h]を押すと

'^?'ハァ?

みたいに拒否られる。

 

$ stty -a
speed 9600 baud; 24 rows; 80 columns;
lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl
-echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
-extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel iutf8
-ignbrk brkint -inpck -ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
-dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
stop = ^S; susp = ^Z; time = 0; werase = ^W;

 

$ stty erase ^H

で eraseに^Hを割り当てたら大丈夫になった。

 

理屈がよくわかってないけど、遊べてる。

 

9)その後のアップデート

wizardという変数を認識できない様子の件。

extern.cというグローバル変数を定義している(らしい)ソースコードのうち

 

< #ifdef MASTER
< int wizard = FALSE; /* True if allows wizard commands */
< #endif

-----

> #ifdef MASTER
> int wizard = FALSE; /* True if allows wizard commands */
> #else
> int wizard = TRUE;
> #endif

とした。コンパイルは通った。MASTERモードじゃないときに

wizard変数がなくなっているからのようなんだけど。

 

ついでに

.bashrcに

function myrogue5() {
    pushd ~/Documents/200400_playrogue/rogue545p/;
    stty erase ^H
    rogue5 -10 $@;
    stty erase ^?
    popd;
}
alias rogue5=myrogue5

 と書いて、スコアファイルなどを特定のフォルダに置き、

^Hを使えるようにし、デフォルトオプションを与えておいた。

 

10)ついに解決ぢゃ!

 

Makefileの書き換え

CPPFLAGS = -DHAVE_CONFIG_H -DMASTER -I/usr/local/opt/ncurses/include

LDFLAGS = -L/usr/local/opt/ncurses/lib 

 wizardモード付きでコンパイルするのが基本であった

と理解すればよさそうである。

 

多分本当に解決!!!

 

f:id:masatora_bd5:20200418144735p:plain