背景:
阅读文章

MUDOS在WINDOWS下的编译过程

[日期:2007-05-05] 来源:  作者:本说明是由Hunter@JNUMUD完成 [字体: ]

* 本说明涉及软件有Mudos V22pre11源代码,bison for Win以及Vc++5.0以上


使用软件: 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,大功告成!^_^

                                         

收藏 推荐 打印 | 录入:sbso | 阅读:
相关内容      
本文评论   [发表评论]   全部评论 (0)
内容推送
52mud提供
一起回忆泥巴游戏QQ群68186072
52mud官方微信公众平台
热门评论