# Public domain sub TEST_dyld { BeginTestHeaders(); DetectHeaderC('HAVE_MACH_O_DYLD_H', ''); TryCompile 'HAVE_DYLD', << 'EOF'; #ifdef __APPLE__ # include # ifdef __MAC_OS_X_VERSION_MIN_REQUIRED # if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 # error "deprecated in Leopard and later" # endif # endif #endif #ifdef HAVE_MACH_O_DYLD_H #include #endif int main(int argc, char *argv[]) { NSObjectFileImage img; NSObjectFileImageReturnCode rv; rv = NSCreateObjectFileImageFromFile("foo", &img); return (rv == NSObjectFileImageSuccess); } EOF MkIfTrue('${HAVE_DYLD}'); MkPrintSN('checking for NSLINKMODULE_OPTION_RETURN_ON_ERROR'); TryCompile 'HAVE_DYLD_RETURN_ON_ERROR', << 'EOF'; #ifdef HAVE_MACH_O_DYLD_H #include #endif int main(int argc, char *argv[]) { NSObjectFileImage img; NSObjectFileImageReturnCode rv; void *handle; rv = NSCreateObjectFileImageFromFile("foo", &img); handle = (void *)NSLinkModule(img, "foo", NSLINKMODULE_OPTION_RETURN_ON_ERROR| NSLINKMODULE_OPTION_NONE); if (handle == NULL) { NSLinkEditErrors errs; int n; const char *f, *s = NULL; NSLinkEditError(&errs, &n, &f, &s); } return (0); } EOF MkElse; MkDisableFailed('dyld'); MkEndif; EndTestHeaders(); } sub DISABLE_dyld { MkDefine('HAVE_DYLD', 'no') unless $TestFailed; MkDefine('HAVE_MACH_O_DYLD_H', 'no'); MkDefine('HAVE_DYLD_RETURN_ON_ERROR', 'no'); MkSaveUndef('HAVE_DYLD', 'HAVE_MACH_O_DYLD_H', 'HAVE_DYLD_RETURN_ON_ERROR'); } BEGIN { my $n = 'dyld'; $DESCR{$n} = 'dyld interface'; $TESTS{$n} = \&TEST_dyld; $DISABLE{$n} = \&DISABLE_dyld; $DEPS{$n} = 'cc'; } ;1