This code (except for some of the argument parsing changes) is not used yet. mdgrep.pl generates mdgrep.h; like the lex and yacc files we ship mdgrep.h pre-generated; there is no need for perl on end-user/end-compiler systems. (In fact mdgrep.h is so simple mdgrep.pl is probably overkill.) mdgrep.h creates an array reflecting the compiler options in effect The changes to makedefs break the Mac OS9 compile; if necessary the fix is simple and documented (but I think that port is permanently dead). With that port out of the way, makedefs can be allowed to take real options; none of the current options have been changed. Instead, a second sub-main routine has been added to handle options starting with two hyphens and all the new options start with two hyphens: --input specifies the input file (- is stdin) --output specifies the output file (- is stdout) --grep causes the input file to be filtered into the output file --grep-showvars dumps the info from the array in mdgrep.h --grep-trace turns on tracing of the grep filtering Docs for the filtering language are in the source.
95 lines
2.6 KiB
Perl
95 lines
2.6 KiB
Perl
#!perl
|
|
# NetHack 3.5 makedefs.c $Date$ $Revision$
|
|
# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2008
|
|
# NetHack may be freely redistributed. See license for details.
|
|
|
|
# Operating Systems:
|
|
@os = qw/WIN32 MSDOS VMS UNIX TOS AMIGA MAC WINNT __BEOS__ WIN_CE OS2
|
|
WIN_CE_SMARTPHONE WIN_CE_POCKETPC WIN_CE_PS2xx
|
|
WIN32_PLATFORM_HPCPRO WIN32_PLATFORM_WFSP/;
|
|
|
|
# Window Systems:
|
|
@win = qw/TTY_GRAPHICS MAC_GRAPHICS AMII_GRAPHICS MSWIN_GRAPHICS X11_GRAPHICS
|
|
QT_GRAPHICS GNOME_GRAPHICS GEM_GRAPHICS/;
|
|
|
|
# Game Features:
|
|
@feature = qw/ZEROCOMP USE_TILES ASCIIGRAPH CLIPPING TEXTCOLOR
|
|
COMPRESS ZLIB_COMP RANDOM SECURE USER_SOUNDS WIZARD
|
|
SAFERHANGUP MFLOPPY NOCWD_ASSUMPTIONS
|
|
VAR_PLAYGROUND DLB SHELL SUSPEND NOSAVEONHANGUP HANGUPHANDLING
|
|
BSD_JOB_CONTROL MAIL POSIX_JOB_CONTROL
|
|
UNICODE_DRAWING UNICODE_WIDEWINPORT UNICODE_PLAYERTEXT
|
|
/;
|
|
|
|
# Miscellaneous
|
|
@misc = qw/BETA/;
|
|
|
|
# JUNK:
|
|
# MICRO BSD __GNUC__ NHSTDC TERMLIB __linux__ LINUX WIN32CON NO_TERMS
|
|
# ULTRIX_PROTO TERMINFO _DCC DISPMAP OPT_DISPMAP TARGET_API_MAC_CARBON
|
|
# NOTTYGRAPHICS SYSV ULTRIX MAKEDEFS LEV_LEX_C __STDC__
|
|
# BITCOUNT TILE_X COLORS_IN_USE CHDIR KR1ED
|
|
# apollo __APPLE__ AIX_31 PC9800 __MACH__ _GNU_SOURCE __EMX__ DGUX
|
|
# __MWERKS__ __MRC__ __BORLANDC__ LINT THINK_C __SC__ AZTEC_C __FreeBSD__
|
|
# USE_PROTOTYPES __DJGPP__ macintosh POSIX_TYPES SUNOS4 _MSC_VER __OpenBSD__
|
|
# GCC_WARN VOIDYYPUT FLEX_SCANNER FLEXHACK_SCANNER WIERD_LEX
|
|
# NeXT __osf__ SVR4 _AIX32 _BULL_SOURCE AUX __sgi GNUDOS
|
|
# TIMED_DELAY DEF_MAILREADER DEF_PAGER NO_SIGNAL PC_LOCKING LATTICE __GO32__
|
|
# msleep NO_FILE_LINKS bsdi HPUX AMIFLUSH SYSFLAGS
|
|
# OVERLAY USE_TRAMPOLI USE_OVLx SPEC_LEV DGN_COMP
|
|
# SCREEN_BIOS SCREEN_DJGPPFAST SCREEN_VGA SCREEN_8514
|
|
# EXEPATH NOTSTDC SELECTSAVED NOTPARMDECL
|
|
|
|
# constants
|
|
@const_true = qw/1 TRUE/;
|
|
@const_false = qw/0 FALSE/;
|
|
|
|
sub start_file {
|
|
($rev) = ('$Revision$') =~ m/: (.*) .$/;
|
|
open(OUT, ">mdgrep.h") || die "open mkgrep.h: $!";
|
|
print OUT <<E_O_M;
|
|
/*
|
|
* This file generated by mdgrep.pl version $rev.
|
|
* DO NOT EDIT! Your changes will be lost.
|
|
*/
|
|
E_O_M
|
|
}
|
|
|
|
sub end_file {
|
|
print OUT "/* End of file */\n";
|
|
close OUT;
|
|
}
|
|
|
|
sub gen_magic {
|
|
local($v, @x) = @_;
|
|
foreach (@x){
|
|
$magic{$_} = $v;
|
|
}
|
|
}
|
|
|
|
sub gen_file {
|
|
print OUT "static struct grep_var grep_vars[]={\n";
|
|
foreach(@_){
|
|
if(defined $magic{$_}){
|
|
print OUT <<E_O_M;
|
|
{"$_", $magic{$_}},
|
|
E_O_M
|
|
next;
|
|
}
|
|
print OUT <<E_O_M;
|
|
#if defined($_)
|
|
{"$_", 1},
|
|
#else
|
|
{"$_", 0},
|
|
#endif
|
|
E_O_M
|
|
}
|
|
print OUT "\t{0,0}\n};\n";
|
|
}
|
|
|
|
&start_file;
|
|
&gen_magic(0, @const_false);
|
|
&gen_magic(1, @const_true);
|
|
&gen_file(sort(@os,@win,@feature,@misc,@const_false,@const_true));
|
|
&end_file;
|