fixed bug #1474597 - Mac OS X 10.4 build failures

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4664 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2006-04-28 15:54:42 +00:00
parent 9ed073277d
commit 991295e17f
4 changed files with 49 additions and 17 deletions

View file

@ -35,6 +35,25 @@ defenv['ALIGN_FLAG'] = '-Wl,--file-alignment,512'
defenv['CPP_REQUIRES_STDLIB'] = 1 defenv['CPP_REQUIRES_STDLIB'] = 1
defenv['SUBSYS_CON'] = '-Wl,--subsystem,console' defenv['SUBSYS_CON'] = '-Wl,--subsystem,console'
### helper functions
# on Mac OS X, programs built with g++ 4.0, stl and -s error out:
# dyld: lazy symbol binding failed: lazy pointer not found
# dyld: lazy pointer not found
#
# to avoid this, this function checks if -s works
def TestStrip(ctx):
c = """
#include <vector>
int main() {
std::vector<int> v;
return 0;
}
"""
ctx.CheckLinkFlag('-s', run = 1, extension = '.cpp', code = c)
### debug ### debug
if defenv['DEBUG']: if defenv['DEBUG']:
@ -66,11 +85,10 @@ if not defenv['DEBUG']:
makensis_env.Append(CCFLAGS = '-O2') # optimize makensis_env.Append(CCFLAGS = '-O2') # optimize
makensis_env.Append(CCFLAGS = '-Wall') # all warnings makensis_env.Append(CCFLAGS = '-Wall') # all warnings
if not defenv['DEBUG']:
makensis_env.Append(LINKFLAGS = '-s') # strip
conf = FlagsConfigure(makensis_env) conf = FlagsConfigure(makensis_env)
conf.CheckLinkFlag('$MAP_FLAG') # generate map file conf.CheckLinkFlag('$MAP_FLAG') # generate map file
if not defenv['DEBUG']:
TestStrip(conf) # strip
conf.Finish() conf.Finish()
### plugin environment ### plugin environment
@ -93,14 +111,13 @@ plugin_env.Append(LINKFLAGS = '$MAP_FLAG') # generate map file
cp_util_env = defenv.Copy() cp_util_env = defenv.Copy()
if not defenv['DEBUG']: if not defenv['DEBUG']:
cp_util_env.Append(CCFLAGS = '-O2') # optimize cp_util_env.Append(CCFLAGS = '-O2') # optimize
cp_util_env.Append(CCFLAGS = '-Wall') # all warnings cp_util_env.Append(CCFLAGS = '-Wall') # all warnings
if not defenv['DEBUG']:
cp_util_env.Append(LINKFLAGS = '-s') # strip
conf = FlagsConfigure(cp_util_env) conf = FlagsConfigure(cp_util_env)
conf.CheckLinkFlag('$MAP_FLAG') # generate map file conf.CheckLinkFlag('$MAP_FLAG') # generate map file
if not defenv['DEBUG']:
TestStrip(conf) # strip
conf.Finish() conf.Finish()
### util environment ### util environment

View file

@ -36,19 +36,26 @@ def check_compile_flag(ctx, flag):
""" """
Checks if a linker flag is valid. Checks if a linker flag is valid.
""" """
def check_link_flag(ctx, flag): def check_link_flag(ctx, flag, run = 0, extension = '.c', code = None):
ctx.Message('Checking for linker flag %s... ' % flag) ctx.Message('Checking for linker flag %s... ' % flag)
old_flags = ctx.env['LINKFLAGS'] old_flags = ctx.env['LINKFLAGS']
ctx.env.Append(LINKFLAGS = flag) ctx.env.Append(LINKFLAGS = flag)
test = """ if code:
int main() { test = code
return 0; else:
} test = """
""" int main() {
return 0;
}
"""
result = ctx.TryLink(test, extension)
if run:
result = result and ctx.TryRun(test, extension)[0]
result = ctx.TryLink(test, '.c')
ctx.Result(result) ctx.Result(result)
if not result: if not result:

View file

@ -61,6 +61,7 @@ typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
WORD Length; WORD Length;
WCHAR NameString[1]; WCHAR NameString[1];
} IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U; } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
# pragma pack()
#endif #endif
#pragma pack(4) #pragma pack(4)

View file

@ -14,6 +14,13 @@
# include <iconv.h> # include <iconv.h>
#endif #endif
#ifdef __APPLE__
namespace Apple { // defines struct section
# include <mach-o/dyld.h> // for _NSGetExecutablePath
};
# include <sys/param.h> // for MAXPATHLEN
#endif
#include <cassert> // for assert #include <cassert> // for assert
#include <algorithm> #include <algorithm>
#include <stdexcept> #include <stdexcept>
@ -636,8 +643,8 @@ string get_executable_path(const char* argv0) {
return string(temp_buf); return string(temp_buf);
#elif __APPLE__ #elif __APPLE__
char temp_buf[MAXPATHLEN+1]; char temp_buf[MAXPATHLEN+1];
unsigned long buf_len = MAXPATHLEN; unsigned int buf_len = MAXPATHLEN;
int rc = _NSGetExecutablePath(temp_buf, &buf_len); int rc = Apple::_NSGetExecutablePath(temp_buf, &buf_len);
assert(rc == 0); assert(rc == 0);
return string(temp_buf); return string(temp_buf);
#else /* Linux/BSD/POSIX/etc */ #else /* Linux/BSD/POSIX/etc */