| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

MUDOS完全編譯手冊

This version was saved 17 years ago View current version     Page history
Saved by PBworks
on March 29, 2007 at 1:51:25 pm
 
MUDOS完全編譯手冊.txt

 

MUDOS編譯完全手冊

by 梁宇翀(Micro Liang)@天下創作室

 

2000-10-20

 

( micro_liang@hotmail.com, micro_liang@21cn.com )

 

MudOS版本:V22Pre11

 

通常來說MudOS有以下版本:

 

Alpha 給開發者測試的版本

Beta 給玩家測試的版本

Preview 預發佈的版本

Release 發佈的版本,即正式版

 

 

一、WINDOWS/VC++6·0

 

使用軟件:VC++6·0,BISON

 

1、將源碼解壓,進入 v22p11/src 目錄

 

2、將 windows 目錄下所有 .mak 文件複製到上層目錄

 

3、使用 VC 建立(File 中的 New)一個名為 MudOS 的 Win32 Application

新 Workspace。選擇 Project 中的 Insert Project into Workspace,

加入項目 edit_source.mak。刪除 source file 中的 local_options、

make_func.tab.c 兩個文件,在步驟4之後加入文件 make_func.c。

 

4、運行 clean.bat,生成文件 make_func.c。內容如下:

 

del comptest.*

del configure.h

del efunctions.h

del efun_defs.c

del efun_protos.h

del func_spec.cpp

del grammar_tab.c

del grammar_tab.h

del grammar.c

del grammar.y

del make_func.c

del malloc.c

del mallocwrapper.c

del opc.h

del opcodes.h

del option_defs.c

del trash_me.bat

 

bison make_func.y

ren malloc.h malloc.h~

 

5、新建一個文件 cc.h,內容如下:

 

/* this file automatically generated by the Makefile */

#define COMPILER "cl"

#define OPTIMIZE "-G4"

#define CFLAGS "-DWIN32 -D_ALL_SOURCE -G4"

#define OBJDIR "obj"

 

5、修改 edit_source.c,把

fprintf(yyout, "#define UINT32 unsigned long\n");

替換為:

{

#ifndef WIN32

fprintf(yyout, "#define UINT32 unsigned long\n");

#else

;

#endif

}

 

6、編譯 edit_source 項目,生成可執行文件 .\debug\edit_source.exe。

 

7、運行 grammar.bat,生成文件 grammar.c。這個文件內容如下:

 

ren malloc.h~ malloc.h

.\debug\edit_source -configure

.\debug\edit_source -options -process grammar.y.pre -malloc -build_func_spec "cs

bison grammar.y

 

8、選擇 Project 中的 Insert Project into Workspace,加入項目 mudos.mak。

選擇 Project 中的 Settings,在 C/C++ 的 Preprocessor definitions 中

刪除 DEBUG,增加 MSDOS 參數。

 

刪除 mudos project 之 source file 中的 grammar_tab.c,增加 grammar.c

刪除 malloc.c, parser.c,增加 package/uids.c,package/mudlib_stats.c

 

將 src 中文件 grammar_tab.h 改為 grammar.h(因為 windows 的 bison

不能產生 grammar.h,所以建議從 UNIX 上取一份版本相同的 grammar_tab.h)

修改 lex.c 將 #include "grammar.tab.h" 改為 #include "grammar.h"

 

9、修改 backend.c 中的函數 call_heart_beat():

刪除以下:

#ifdef WIN32

static long Win32Thread = -1;

#endif

刪除以下:

if (Win32Thread == -1) Win32Thread = _beginthread(alarm_loop, 256, 0);

 

10、修改 crc32.h 在 compute_crc32 函數之前加入:

typedef unsigned int UINT32;

修改 crc32.c 在前面增加:

#include "crc32.h"

 

11、修改 crypt.h 中的句子

char *custom_crypt( CONST char *key, CONST char *salt, byte *rawout);

char *custom_crypt( char *key, char *salt, byte *rawout);

(即刪除所有的 CONST)

 

12、將 interface.h, efuns_main.c, compile_file.c, mudlib/interface.c

中所有名為 interface 的變量名都替換成 if_t_array。

 

13、編譯 mudos 項目,生成可執行文件 .\release\mudos.exe。

 

下載http://www.21cntx.com/MudOS.zip

http://www.nease.net/~micro/MudOS.zip

 

 

二、FreeBSD

 

1、將源碼解壓,進入 v22p11/src 目錄

 

2、將文件 system_libs 的內容改為:

-lcrypt -lm

 

3、運行文件:./build.MudOS 進行配置

 

4、運行命令:

make clean

rm -rf obj

ln -s . obj

 

5、運行編譯命令:make,生成可執行文件 ./driver

 

 

三、RedHat

 

1、將源碼解壓,進入 v22p11/src 目錄

 

2、將文件 system_libs 的內容改為:

-lcrypt -lm

 

3、將文件 file_incl.h 以下段落用 /* */ 註釋

#ifdef INCL_SYS_DIRENT_H

# include

#endif

 

4、修改文件 GNUmakefile,將

$(DRIVER_BIN): packages/packages.a mudlib/mudlib.a $(OBJ)

-mv -f $(DRIVER_BIN) $(DRIVER_BIN).old

$(PROOF) $(CC) -lcrypt $(CFLAGS) $(OPTIMIZE) $(OBJ) -o $(DRIVER_BIN) pa`

第三行加多一個 -lcrypt

 

5、運行編譯命令:gmake,生成可執行文件 ./driver

 

MUDOS 在WINDOWS下編譯過程

2002-6-3

 

 

 

 

 

使用軟件: vc5以上,bison

 

將源碼解壓,進入~v22pre11/src目錄

 

將windows目錄下的所有.bat和.mak文件copy到上層目錄中

 

用vc新建一個MUDOS WORKSPACE,選擇Insert Project into Workspace…,將src下的edit_source.mak文件加入到workspace中,刪除」source

file」中的」local_options」文件,刪除」make_func.tab.c」文件,執行step1.bat,得到make_func.c文件,把它加入到edit_source的project中

 

 

建立一個新文件,文件名為cc.h,文件內容如下:

 

 

 

#define COMPILER "cl"

 

#define OPTIMIZE "-G4"

 

#define CFLAGS "-DWIN32 -D_ALL_SOURCE -G4"

 

#define OBJDIR "obj"

 

 

 

在edit_source的project的setting項目里的」c/c++」->」preprocessor

definitions」里去掉」DEBUG」參數,在」custom build」的」command」里添加如下命令:

 

 

 

cd E:\work\v22.pre11/src

 

.\windebug\edit_source -configure

 

.\windebug\edit_source -options -process grammar.y.pre

-malloc -build_func_spec "cl /E " -build_efuns

 

 

 

「output」里添加」grammar.y」

 

 

編輯edit_source.c,把」 fprintf(yyout, "#define

UINT32 unsigned long\n");」替換為:

 

 

 

{ //防止重複定義,WINDOWS把UINT32定義為unsigned int了

 

#ifndef WIN32

 

fprintf(yyout, "#define UINT32 unsigned long\n");

 

#else

 

;

 

#endif

 

}

 

 

 

編譯edit_source,編譯完成後會自動生成grammar.y文件

 

在dos下執行「bison grammar.y」,生成grammar.c

 

選擇」project」->」insert project into workspace」,把Mudos.mak加入到mudos

workspace中。修改mudos project,將setting->link->」object/library

module」中的所有.lib文件刪除,在」c/c++」->」preprocessor definites」中刪除」DEBUG」,增加」MSDOS」參數。

 

 

 

修改backend.c,將static void call_heart_beat();替換成如下:

 

 

 

static void call_heart_beat()

 

{

 

object_t *ob;

 

heart_beat_t *curr_hb;

 

heart_beat_flag = 0;

 

#ifdef SIGALRM

 

signal(SIGALRM, sigalrm_handler);

 

#endif

 

#ifdef HAS_UALARM

 

ualarm(HEARTBEAT_INTERVAL, 0);

 

#else

 

# ifdef WIN32

 

# else

 

alarm(SYSV_HEARTBEAT_INTERVAL); /* defined in config.h

*/

 

# edif

 

#enndif

 

debug(256, ("."));

 

current_time = get_current_time();

 

current_interactive = 0;

 

if ((num_hb_to_do = num_hb_objs))

 

{

 

num_hb_calls++;

 

heart_beat_index = 0;

 

while (!heart_beat_flag)

 

{

 

ob = (curr_hb = &heart_beats[heart_beat_index])->ob;

 

DEBUG_CHECK(!(ob->flags & O_HEART_BEAT),

 

"Heartbeat not set in object on heartbeat list!");

 

DEBUG_CHECK(ob->flags & O_SWAPPED,

 

"Heartbeat in swapped object.\n");

 

/* is it time to do a heart beat ? */

 

curr_hb->heart_beat_ticks--;

 

if (ob->prog->heart_beat != -1)

 

{

 

if (curr_hb->heart_beat_ticks < 1)

 

{

 

curr_hb->heart_beat_ticks = curr_hb->time_to_heart_beat;

 

current_heart_beat = ob;

 

command_giver = ob;

 

#ifndef NO_SHADOWS

 

while (command_giver->shadowing)

 

command_giver = command_giver->shadowing;

 

#endif

 

#ifndef NO_ADD_ACTION

 

if (!(command_giver->flags & O_ENABLE_COMMANDS))

 

command_giver = 0;

 

#endif

 

#ifdef PACKAGE_MUDLIB_STATS

 

add_heart_beats(&ob->stats, 1);

 

#endif

 

eval_cost = max_cost;

 

/* this should be looked at ... */

 

call_function(ob->prog, ob->prog->heart_beat);

 

command_giver = 0;

 

current_object = 0;

 

}

 

}

 

if (++heart_beat_index == num_hb_to_do)

 

break;

 

}

 

if (heart_beat_index < num_hb_to_do)

 

perc_hb_probes = 100 * (float) heart_beat_index

/ num_hb_to_do;

 

else

 

perc_hb_probes = 100.0;

 

heart_beat_index = num_hb_to_do = 0;

 

}

 

current_prog = 0;

 

current_heart_beat = 0;

 

look_for_objects_to_swap();

 

call_out();

 

#ifdef PACKAGE_MUDLIB_STATS

 

mudlib_stats_decay();

 

#endif

 

} /* call_heart_beat() */

 

 

 

修改crc32.h,在compute_crc32函數之前加入

 

typedef unsigned int UINT32;

 

把interface.h,efuns_main.c,compile_file.c中所有名稱為interface的變量名都替換為_interface,以避免和windows關鍵字衝突

 

去掉crypt.h中char *custom_crypt( CONST char *key, CONST

char *salt, byte *rawout);

 

的所有CONST設定,刪掉mudos project里的grammar.tab.c文件,增加grammar.c,

 

修改lex.c,把grammar.tab.h改為grammar.h(因為WINDOWS的bison無法產生grammar.h,所以建議從UNIX 上拿一份版本相同的.h回來用),刪除project中的」mallocwrapper.c」、」parser.c」,把」 package/uids.c」增加到project中。

 

 

 

最後編譯mudos,大功告成!^_^

 

 

 

 

 

 

原作者: Hunter@JNUMUD

Comments (0)

You don't have permission to comment on this page.