@@ -510,6 +510,7 @@ class found(Exception): pass
510510 dblibs = [dblib ]
511511 raise found
512512 except found :
513+ dblibs = [dblib ]
513514 # A default source build puts Berkeley DB in something like
514515 # /usr/local/Berkeley.3.3 and the lib dir under that isn't
515516 # normally on ld.so's search path, unless the sysadmin has hacked
@@ -524,33 +525,42 @@ class found(Exception): pass
524525 runtime_library_dirs = [dblib_dir ],
525526 include_dirs = db_incs ,
526527 define_macros = [('HAVE_DB_185_H' ,1 )],
527- libraries = [ dblib ] ))
528+ libraries = dblibs ))
528529 else :
529530 exts .append (Extension ('bsddb' , ['bsddbmodule.c' ],
530531 library_dirs = [dblib_dir ],
531532 runtime_library_dirs = [dblib_dir ],
532533 include_dirs = db_incs ,
533- libraries = [ dblib ] ))
534+ libraries = dblibs ))
534535 else :
535536 db_incs = None
536537 dblibs = []
537538 dblib_dir = None
538539
539540 # The standard Unix dbm module:
540- if platform not in ['cygwin' , 'mac' ]:
541- if (self .compiler .find_library_file (lib_dirs , 'ndbm' )):
541+ if platform not in ['cygwin' ]:
542+ if (self .compiler .find_library_file (lib_dirs , 'ndbm' )
543+ and find_file ("ndbm.h" , inc_dirs , []) is not None ):
542544 exts .append ( Extension ('dbm' , ['dbmmodule.c' ],
545+ define_macros = [('HAVE_NDBM_H' ,None )],
543546 libraries = ['ndbm' ] ) )
544- elif self .compiler .find_library_file (lib_dirs , 'gdbm' ):
547+ elif (platform in ['darwin' ]
548+ and find_file ("ndbm.h" , inc_dirs , []) is not None ):
549+ # Darwin has ndbm in libc
545550 exts .append ( Extension ('dbm' , ['dbmmodule.c' ],
551+ define_macros = [('HAVE_NDBM_H' ,None )]) )
552+ elif (self .compiler .find_library_file (lib_dirs , 'gdbm' )
553+ and find_file ("gdbm/ndbm.h" , inc_dirs , []) is not None ):
554+ exts .append ( Extension ('dbm' , ['dbmmodule.c' ],
555+ define_macros = [('HAVE_GDBM_NDBM_H' ,None )],
546556 libraries = ['gdbm' ] ) )
547557 elif db_incs is not None :
548558 exts .append ( Extension ('dbm' , ['dbmmodule.c' ],
549- library_dirs = dblib_dir ,
559+ library_dirs = [ dblib_dir ] ,
550560 include_dirs = db_incs ,
561+ define_macros = [('HAVE_BERKDB_H' ,None ),
562+ ('DB_DBM_HSEARCH' ,None )],
551563 libraries = dblibs ))
552- else :
553- exts .append ( Extension ('dbm' , ['dbmmodule.c' ]) )
554564
555565 # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
556566 if (self .compiler .find_library_file (lib_dirs , 'gdbm' )):
@@ -712,32 +722,34 @@ class found(Exception): pass
712722 exts .append ( Extension ('sunaudiodev' , ['sunaudiodev.c' ]) )
713723
714724 if platform == 'darwin' :
715- # Mac OS X specific modules. These are ported over from MacPython
716- # and still experimental. Some (such as gestalt or icglue) are
717- # already generally useful, some (the GUI ones) really need to
718- # be used from a framework.
725+ # Mac OS X specific modules. Modules linked against the Carbon
726+ # framework are only built for framework-enabled Pythons. As
727+ # of MacOSX 10.1 importing the Carbon framework from a non-windowing
728+ # application (MacOSX server, not logged in on the console) may
729+ # result in Python crashing.
719730 #
720731 # I would like to trigger on WITH_NEXT_FRAMEWORK but that isn't
721732 # available here. This Makefile variable is also what the install
722733 # procedure triggers on.
723- frameworkdir = sysconfig .get_config_var ('PYTHONFRAMEWORKDIR' )
724- exts .append ( Extension ('gestalt' , ['gestaltmodule.c' ],
725- extra_link_args = ['-framework' , 'Carbon' ]) )
726- exts .append ( Extension ('MacOS' , ['macosmodule.c' ],
727- extra_link_args = ['-framework' , 'Carbon' ]) )
728- exts .append ( Extension ('icglue' , ['icgluemodule.c' ],
729- extra_link_args = ['-framework' , 'Carbon' ]) )
730- exts .append ( Extension ('macfs' ,
731- ['macfsmodule.c' ,
732- '../Python/getapplbycreator.c' ],
733- extra_link_args = ['-framework' , 'Carbon' ]) )
734734 exts .append ( Extension ('_CF' , ['cf/_CFmodule.c' , 'cf/pycfbridge.c' ],
735735 extra_link_args = ['-framework' , 'CoreFoundation' ]) )
736- exts .append ( Extension ('_Res' , ['res/_Resmodule.c' ],
737- extra_link_args = ['-framework' , 'Carbon' ]) )
738- exts .append ( Extension ('_Snd' , ['snd/_Sndmodule.c' ],
739- extra_link_args = ['-framework' , 'Carbon' ]) )
740- if frameworkdir :
736+
737+ framework = sysconfig .get_config_var ('PYTHONFRAMEWORK' )
738+ if framework :
739+ exts .append ( Extension ('gestalt' , ['gestaltmodule.c' ],
740+ extra_link_args = ['-framework' , 'Carbon' ]) )
741+ exts .append ( Extension ('MacOS' , ['macosmodule.c' ],
742+ extra_link_args = ['-framework' , 'Carbon' ]) )
743+ exts .append ( Extension ('icglue' , ['icgluemodule.c' ],
744+ extra_link_args = ['-framework' , 'Carbon' ]) )
745+ exts .append ( Extension ('macfs' ,
746+ ['macfsmodule.c' ,
747+ '../Python/getapplbycreator.c' ],
748+ extra_link_args = ['-framework' , 'Carbon' ]) )
749+ exts .append ( Extension ('_Res' , ['res/_Resmodule.c' ],
750+ extra_link_args = ['-framework' , 'Carbon' ]) )
751+ exts .append ( Extension ('_Snd' , ['snd/_Sndmodule.c' ],
752+ extra_link_args = ['-framework' , 'Carbon' ]) )
741753 exts .append ( Extension ('Nav' , ['Nav.c' ],
742754 extra_link_args = ['-framework' , 'Carbon' ]) )
743755 exts .append ( Extension ('_AE' , ['ae/_AEmodule.c' ],
@@ -789,7 +801,7 @@ class found(Exception): pass
789801 waste_incs = find_file ("WASTE.h" , [],
790802 ['../' * n + 'waste/C_C++ Headers' for n in (0 ,1 ,2 ,3 ,4 )])
791803 waste_libs = find_library_file (self .compiler , "WASTE" , [],
792- [ "../" * n + "waste/Static Libraries" for n in (0 ,1 ,2 ,3 ,4 )])
804+ [ "../" * n + "waste/Static Libraries" for n in (0 ,1 ,2 ,3 ,4 )])
793805 if waste_incs != None and waste_libs != None :
794806 (srcdir ,) = sysconfig .get_config_vars ('srcdir' )
795807 exts .append ( Extension ('waste' ,
0 commit comments