📄 config.pl
字号:
#!/usr/bin/perl
#*____________________________________________________________________________*\
#*
#
# Copyright (c) 1997-2003 John Roy, Holger Zimmermann. All rights reserved.
#
# These sources, libraries and applications are
# FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
# as long as the following conditions are adhered to.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
# OF THE POSSIBILITY OF SUCH DAMAGE.
#
#*____________________________________________________________________________*|
#*
#* $Source: /cvsroot/pi3web/Pi3Web_200/Source/Scripts/config.pl,v $
#* $Date: 2003/05/13 18:42:17 $
#*
# Description:
# Generate all makefiles for a build
#;
# Options:-
# --c-compiler=CC specify the C compiler to use
# --cpp-compiler=CC specify the C++ compiler to use
# --production release build
#
# Options are not case sensitive
#
#*____________________________________________________________________________*/
#/*___________________________________________________________________________*\
# Global declarations:
#\*___________________________________________________________________________*/
$_=$0; s/config\.pl//i; $scriptdir=$_;
$configfile=$scriptdir.'/config.mak';
$sysspecfile=$scriptdir.'../Platform/sysspec.hh';
$c_compiler='gcc';
$cpp_compiler='g++';
$development_build=1;
$_=`uname -s`.`uname -r`; s/\s//g; $os=$_;
$machine=`uname -m`;
$config_os='';
$config_os_flavor='';
$config_machine='';
$cpp_flag_no_bool=0;
$config_83headers=0;
$config_archive='ar -r __substme';
$config_libpath='-L__substme';
$config_objextn='.o';
$config_linklib='-l__substme';
$config_fulllib='lib__substme.a';
$config_fulldll='lib__substme.so';
$config_fullexe='__substme';
$ld='ld';
#
# commands for the native shells
#
$cmd_seperator=';';
$cmd_cp='cp ';
$cmd_rm='rm -f ';
$cmd_perl='perl ';
#
# Check arguments
#
foreach $arg (@ARGV)
{
$_ = $arg;
if ( $arg =~ /--c-compiler=*/i )
{ s/--c-compiler=(.*)\n?/$1/; $c_compiler=$_; }
elsif ( $arg =~ /--cpp-compiler=*/i )
{ s/--cpp-compiler=(.*)\n?/$1/; $cpp_compiler=$_; }
elsif ( $arg =~ /--production/i )
{ $development_build=0; }
else
{ print "Unknown argument $arg\n"; exit 1; };
};
$config_ld=$cpp_compiler.' -o __substme';
$config_ld_shared=$cpp_compiler.' -o lib__substme.so';
$cflag_define='-D';
$cppflag_define='-D';
$c_flags='';
$cpp_flags='';
#
# Check operating system
#
if ( $os =~ /[L|l]inux*/ )
{
$config_os='CONFIG_OS_LINUX';
$extra_libs='-ldl';
$config_ld_shared=$cpp_compiler.' -shared -o lib__substme.so';
$config_os_flavor='POSIX';
}
elsif ( $os =~ /SunOS5.*/ )
{
$config_os='CONFIG_OS_SOLARIS';
$extra_libs='-lnsl -lsocket -ldl -lthread';
$multi_threaded=1;
$config_ld_shared=$ld.' -G -o lib__substme.so';
$config_os_flavor='POSIX';
}
elsif ( $os =~ /Windows_NT*/ || $os =~ /Windows_95*/ )
{
$config_os='CONFIG_OS_WIN32';
$extra_libs=' WSOCK32.LIB';
$multi_threaded=1;
$config_ld_shared='LINK /DEBUG /NOLOGO /DLL /OUT:"__substme.dll" /IMPLIB:"__substme.lib" /DEF:"__substme.def"';
$config_archive='LIB /OUT:__substme.lib ';
$cflag_define='/D';
$cppflag_define='/D';
$config_objextn='.obj';
$config_linklib='__substme.lib';
$config_fulllib='__substme.lib';
$config_fulldll='__substme.dll';
$config_ld='LINK /OUT:__substme.exe';
$config_libpath='/LIBPATH:__substme';
$config_fulllib='__substme.lib';
$config_fulldll='__substme.dll';
$config_fullexe='__substme.exe';
$cmd_seperator='&&';
$cmd_cp='COPY ';
$cmd_rm='DELTREE /Y ';
$config_os_flavor='WIN32';
}
else
{ print "Unsupported operating system $os\n"; exit -1; };
#
# Check machine
#
if ( $machine =~ /[i3-6|x]86*/ )
{ $config_machine=CONFIG_MACHINE_I386; }
elsif( $machine =~ /sun4*/ )
{ $config_machine=CONFIG_MACHINE_SPARC; }
else
{ print "Unsupported processor: $machine\n"; exit 1; };
#
# standard C and C++ flags
$cflag_includedir='-I';
$cppflag_includedir='-I';
$cflag_debug='-g';
$cppflag_debug='-g';
$c_compiler="cl.exe";
$cpp_compiler="cl.exe";
#
# Infer compile flags from compiler.
if ( $c_compiler =~ /gcc/ )
{
$cflag_mt=" -DREENTRANT";
$cflag_debug=$cflag_debug.' -ansi -pedantic -Wall';
}
elsif ( $c_compiler =~ /cl\.exe/i )
{
$cflag_includedir='/I';
$cflag_debug=' /Zi /Gm /Od /MTd';
$c_flags=$c_flags.' /nologo ';
}
else
{
$cflag_mt=' -mt';
};
#
# Infer cpp compile flags from compiler.
if ( $cpp_compiler =~ /g\+\+/ )
{
$cppflag_mt=" -DREENTRANT";
$cppflag_debug=$cppflag_debug.' -ansi -pedantic -Wall';
$cpp_flags=$cpp_flags.' -fhandle-exceptions';
$config_ld=$cpp_compiler.' -rdynamic -o __substme';
}
elsif ( $cpp_compiler =~ /cl\.exe/i )
{
$cflag_includedir='/I';
$cppflag_includedir='/I';
$cppflag_debug=' /Zi /Gm /Od /MTd ';
$cppflag_mt=" /MTd";
# $cppflag_debug=$cppflag_debug.' -ansi -pedantic -Wall';
$cpp_flags=$cpp_flags.' /nologo /w';
$cpp_flag_no_bool=1;
$config_83headers=1;
}
else
{
$cppflag_mt=' -mt -pic';
$cpp_flag_no_bool=1;
};
#
# Debug or optimisation flags
#
if ( ! $development_build )
{
$c_flags=$cflags." -DNDEBUG";
$cpp_flags=$cpp_flags." -DNDEBUG";
}
else
{
$c_flags=$c_flags.' '.$cflag_debug;
$cpp_flags=$cpp_flags.' '.$cppflag_debug;
};
#
# Multithreading and position independant code flags
#
if ( $multi_threaded )
{
$c_flags=$c_flags.$cflag_mt;
$cpp_flags=$cpp_flags.$cppflag_mt;
};
#
# Other compiler flags
#
if ( $cpp_flag_no_bool )
{
$cpp_flags=$cpp_flags.' '.$cppflag_define."CONFIG_NO_BOOL";
};
if ( $config_83headers )
{
$c_flags=$c_flags.' '.$cflag_define."CONFIG_83HEADERS";
$cpp_flags=$cpp_flags.' '.$cppflag_define."CONFIG_83HEADERS";
};
#
# Generate platform/sysspec.h
# LATER, don't attempt to generate if the directory doesn't exist
#
open SF, ">".$sysspecfile or die "Couldn't open file $sysspecfile\n";
print SF "/*\n";
print SF ' *** DO NOT MODIFY: AUTOMATICALLY GENERATED FILE ***'."\n";
print SF ' */'."\n";
print SF "\n";
print SF '#ifndef SYSSPEC_H_'."\n";
print SF '#define SYSSPEC_H_'."\n";
print SF "\n";
print SF '#define '.$config_os."\n";
print SF '#define '.$config_machine."\n";
print SF "\n";
print SF '#endif /* SYSSPEC_H_ */'."\n";
print SF "\n";
print SF "\n";
#
# Generate configfile
#
open CF, ">".$configfile or die "Couldn't open file $configfile\n";
print CF '#';
print CF "\n".'# Configuration values for makefiles';
print CF "\n".'# Machine : '.$machine;
print CF "\n".'# OS : '.$os;
print CF "\n".'#';
print CF "\n";
print CF "\n".'CONFIG_CC='.$c_compiler;
print CF "\n".'CONFIG_CXX='.$cpp_compiler;
print CF "\n".'CONFIG_CFLAGS='.$c_flags;
print CF "\n".'CONFIG_CXXFLAGS='.$cpp_flags;
print CF "\n".'CONFIG_OS_FLAVOR='.$config_os_flavor;
print CF "\n".'CONFIG_LD='.$config_ld;
print CF "\n".'CONFIG_LD_SHARED='.$config_ld_shared;
print CF "\n".'CONFIG_EXTRALIBS='.$extra_libs;
print CF "\n".'CONFIG_ARCHIVE='.$config_archive;
print CF "\n".'CONFIG_OBJEXTN='.$config_objextn;
print CF "\n".'CONFIG_LIBPATH='.$config_libpath;
print CF "\n".'CONFIG_FULLLIB='.$config_fulllib;
print CF "\n".'CONFIG_LINKLIB='.$config_linklib;
$_=$config_fulllib; s/(.*)__substme(.*)/$1/;
print CF "\n".'CONFIG_LIBPREFIX='.$_;
$_=$config_fulllib; s/(.*)__substme(.*)/$2/;
print CF "\n".'CONFIG_LIBSUFFIX='.$_;
$_=$config_fulldll; s/(.*)__substme(.*)/$1/;
print CF "\n".'CONFIG_DLLPREFIX='.$_;
$_=$config_fulldll; s/(.*)__substme(.*)/$2/;
print CF "\n".'CONFIG_DLLSUFFIX='.$_;
$_=$config_fullexe; s/(.*)__substme(.*)/$1/;
print CF "\n".'CONFIG_EXEPREFIX='.$_;
$_=$config_fullexe; s/(.*)__substme(.*)/$2/;
print CF "\n".'CONFIG_EXESUFFIX='.$_;
print CF "\n";
print CF "\n".'CMD_SEPERATOR='.$cmd_seperator;
print CF "\n".'CMD_CP='.$cmd_cp;
print CF "\n".'CMD_RM='.$cmd_rm;
print CF "\n".'CMD_PERL='.$cmd_perl;
print CF "\n";
print CF "\n";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -