diff --git a/SCons/Config/gnu b/SCons/Config/gnu index 6bb5d813..2da0c7f8 100644 --- a/SCons/Config/gnu +++ b/SCons/Config/gnu @@ -255,6 +255,13 @@ if conf.CheckBigEndian(): test_env.Append(CPPDEFINES = ['__BIG_ENDIAN__']) conf.Finish() +if makensis_env['PLATFORM'] == 'hpux': + makensis_env.Append(CPPDEFINES = ['__ALLOW_UNALIGNED_DATA_ACCESS__']) + makensis_conf = makensis_env.Configure() + makensis_conf.CheckLib("unalign") + makensis_conf.CheckLib("hppa") + makensis_conf.Finish() + ### return Return('stub_env makensis_env plugin_env util_env cp_util_env test_env') diff --git a/SCons/Config/hpc++ b/SCons/Config/hpc++ new file mode 100644 index 00000000..3c0ebd1d --- /dev/null +++ b/SCons/Config/hpc++ @@ -0,0 +1,113 @@ +print "Using hpc++ tools configuration" + +Import('defenv') + +### flags + +defenv['ENTRY_FLAG'] = lambda x: '' +defenv['MAP_FLAG'] = '' +defenv['EXCEPTION_FLAG'] = '' +defenv['NODEFLIBS_FLAG'] = '' +defenv['C_FLAG'] = '' +defenv['CPP_FLAG'] = '' +defenv['CPP_REQUIRES_STDLIB'] = 0 +defenv['SUBSYS_CON'] = '' +defenv['MSVCRT_FLAG'] = '' + +### stub environment + +stub_env = defenv.Clone() + +### makensis environment + +makensis_env = defenv.Clone() + +### use "$CXX -Ae" as the "$CC" compiler to build makensis + +makensis_env['CC'] = makensis_env['CXX'] +makensis_env.Append(CFLAGS = '-Ae') + +### required to build makensis + +makensis_env.Append(LINKFLAGS = '+DD32') +makensis_env.Append(LINKFLAGS = '-mt') + +makensis_env.Append(CCFLAGS = '+DD32') +makensis_env.Append(CCFLAGS = '-mt') + +### debug for makensis + +if makensis_env['DEBUG']: + makensis_env.Append(CCFLAGS = '-g') + makensis_env.Append(LINKFLAGS = '-g') + +### strip for makensis + +if not makensis_env['DEBUG'] and makensis_env['STRIP']: + makensis_env.Append(LINKFLAGS = '-s') + +# +# aCC defines _BIG_ENDIAN, but we use __BIG_ENDIAN__ so check and define as +# needed (is there any HPUX that is NOT big endian?). +# + +def check_big_endian(ctx): + ctx.Message('Checking for if this is a big endian host... ') + test = """ + #define LITTLE_ENDIAN 0 + #define BIG_ENDIAN 1 + #define UNKNOWN 2 + int main() + { + union { + short s; + char c[sizeof(short)]; + } u; + u.s = 0x0102; + if (sizeof(short) == 2) { + if (u.c[0] == 1 && u.c[1] == 2) + return (BIG_ENDIAN); + else if (u.c[0] == 2 && u.c[1] == 1) + return (LITTLE_ENDIAN); + else + return(UNKNOWN); + } else { + return (sizeof(short)); + } + } + """ + result = not ctx.TryRun(test, '.c')[0] + ctx.Result(result) + return result + +makensis_conf = makensis_env.Configure(custom_tests = { 'CheckBigEndian' : check_big_endian }) + +if makensis_conf.CheckBigEndian(): + makensis_env.Append(CPPDEFINES = ['__BIG_ENDIAN__']) + +if makensis_env['PLATFORM'] == 'hpux': + makensis_env.Append(CPPDEFINES = ['__ALLOW_UNALIGNED_DATA_ACCESS__']) + makensis_conf.CheckLib("unalign") + makensis_conf.CheckLib("hppa") + +makensis_conf.Finish() + +### plugin environment + +plugin_env = defenv.Clone(no_import_lib = 1) + +### util environment + +util_env = defenv.Clone() + +### cross-platform util environment + +cp_util_env = util_env.Clone() + +### test environment + +test_env = defenv.Clone() + +# return + +Return('stub_env makensis_env plugin_env util_env cp_util_env test_env') diff --git a/SConstruct b/SConstruct index 75ee0620..bc488f28 100644 --- a/SConstruct +++ b/SConstruct @@ -57,11 +57,17 @@ doc = [ ####### Build Environment ### ###################################################################### +path = ARGUMENTS.get('PATH', '') toolset = ARGUMENTS.get('TOOLSET', '') -if toolset: - defenv = Environment(TOOLS = toolset.split(',') + ['zip']) +if toolset and path: + defenv = Environment(ENV = {'PATH' : path}, TOOLS = toolset.split(',') + ['zip']) else: + if path: + defenv = Environment(ENV = {'PATH' : path}) + if toolset: + defenv = Environment(TOOLS = toolset.split(',') + ['zip']) +if not toolset and not path: defenv = Environment() Export('defenv') @@ -136,6 +142,7 @@ opts.Add(ListOption('SKIPDOC', 'A list of doc files that will not be built/insta opts.Add(('SKIPTESTS', 'A comma-separated list of test files that will not be ran', 'none')) opts.Add(('IGNORETESTS', 'A comma-separated list of test files that will be ran but ignored', 'none')) # build tools +opts.Add(('PATH', 'A colon-separated list of system paths instead of the default - TEMPORARY AND MAY DEPRECATE', None)) opts.Add(('TOOLSET', 'A comma-separated list of specific tools used for building instead of the default', None)) opts.Add(BoolOption('MSTOOLKIT', 'Use Microsoft Visual C++ Toolkit', 'no')) opts.Add(BoolOption('CHMDOCS', 'Build CHM documentation, requires hhc.exe', hhc)) @@ -339,6 +346,8 @@ if 'msvc' in tools or 'mstoolkit' in tools: envs = SConscript('SCons/Config/ms') elif 'gcc' in tools: envs = SConscript('SCons/Config/gnu') +elif 'hpc++' in tools: + envs = SConscript('SCons/Config/hpc++') else: envs = SConscript('SCons/Config/default') diff --git a/Source/Plugins.cpp b/Source/Plugins.cpp index 2ea9f5ea..9c2999e5 100644 --- a/Source/Plugins.cpp +++ b/Source/Plugins.cpp @@ -69,7 +69,7 @@ size_t file_size(ifstream& file) { file.seekg(0, ios::end); ifstream::pos_type result = file.tellg(); - assert(result >= 0); + assert(result >= (ifstream::pos_type)0); file.seekg(pos); diff --git a/Source/ResourceEditor.cpp b/Source/ResourceEditor.cpp index da100940..78d5d7f8 100644 --- a/Source/ResourceEditor.cpp +++ b/Source/ResourceEditor.cpp @@ -27,6 +27,12 @@ using namespace std; #define ALIGN(dwToAlign, dwAlignOn) dwToAlign = (dwToAlign%dwAlignOn == 0) ? dwToAlign : dwToAlign - (dwToAlign%dwAlignOn) + dwAlignOn #define RALIGN(dwToAlign, dwAlignOn) ((dwToAlign%dwAlignOn == 0) ? dwToAlign : dwToAlign - (dwToAlign%dwAlignOn) + dwAlignOn) +#ifndef _WIN32 +static inline ULONG ConvertEndianness(ULONG u) { + return FIX_ENDIAN_INT32(u); +} +#endif + static inline DWORD ConvertEndianness(DWORD d) { return FIX_ENDIAN_INT32(d); } diff --git a/Source/makenssi.cpp b/Source/makenssi.cpp index 7feaacb7..9e791905 100644 --- a/Source/makenssi.cpp +++ b/Source/makenssi.cpp @@ -245,6 +245,12 @@ static int change_to_script_dir(CEXEBuild& build, string& script) int main(int argc, char **argv) { + +#ifdef __ALLOW_UNALIGNED_DATA_ACCESS__ + extern "C" void allow_unaligned_data_access(); + allow_unaligned_data_access(); +#endif + CEXEBuild build; int do_cd=1; int outputtried=0;