Changeset View
Changeset View
Standalone View
Standalone View
ext/python/Tools/freeze/winmakemakefile.py
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | def makemakefile(outfp, vars, files, target): | ||||
try: | try: | ||||
sys.stdout = outfp | sys.stdout = outfp | ||||
realwork(vars, files, target) | realwork(vars, files, target) | ||||
finally: | finally: | ||||
sys.stdout = save | sys.stdout = save | ||||
def realwork(vars, moddefns, target): | def realwork(vars, moddefns, target): | ||||
version_suffix = "%r%r" % sys.version_info[:2] | version_suffix = "%r%r" % sys.version_info[:2] | ||||
print "# Makefile for Microsoft Visual C++ generated by freeze.py script" | print("# Makefile for Microsoft Visual C++ generated by freeze.py script") | ||||
print() | |||||
print 'target = %s' % target | print('target = %s' % target) | ||||
print 'pythonhome = %s' % vars['prefix'] | print('pythonhome = %s' % vars['prefix']) | ||||
print() | |||||
print 'DEBUG=0 # Set to 1 to use the _d versions of Python.' | print('DEBUG=0 # Set to 1 to use the _d versions of Python.') | ||||
print '!IF $(DEBUG)' | print('!IF $(DEBUG)') | ||||
print 'debug_suffix=_d' | print('debug_suffix=_d') | ||||
print 'c_debug=/Zi /Od /DDEBUG /D_DEBUG' | print('c_debug=/Zi /Od /DDEBUG /D_DEBUG') | ||||
print 'l_debug=/DEBUG' | print('l_debug=/DEBUG') | ||||
print 'temp_dir=Build\\Debug' | print('temp_dir=Build\\Debug') | ||||
print '!ELSE' | print('!ELSE') | ||||
print 'debug_suffix=' | print('debug_suffix=') | ||||
print 'c_debug=/Ox' | print('c_debug=/Ox') | ||||
print 'l_debug=' | print('l_debug=') | ||||
print 'temp_dir=Build\\Release' | print('temp_dir=Build\\Release') | ||||
print '!ENDIF' | print('!ENDIF') | ||||
print() | |||||
print '# The following line assumes you have built Python using the standard instructions' | print('# The following line assumes you have built Python using the standard instructions') | ||||
print '# Otherwise fix the following line to point to the library.' | print('# Otherwise fix the following line to point to the library.') | ||||
print 'pythonlib = "$(pythonhome)/pcbuild/python%s$(debug_suffix).lib"' % version_suffix | print('pythonlib = "$(pythonhome)/pcbuild/python%s$(debug_suffix).lib"' % version_suffix) | ||||
print() | |||||
# We only ever write one "entry point" symbol - either | # We only ever write one "entry point" symbol - either | ||||
# "main" or "WinMain". Therefore, there is no need to | # "main" or "WinMain". Therefore, there is no need to | ||||
# pass a subsystem switch to the linker as it works it | # pass a subsystem switch to the linker as it works it | ||||
# out all by itself. However, the subsystem _does_ determine | # out all by itself. However, the subsystem _does_ determine | ||||
# the file extension and additional linker flags. | # the file extension and additional linker flags. | ||||
target_link_flags = "" | target_link_flags = "" | ||||
target_ext = ".exe" | target_ext = ".exe" | ||||
if subsystem_details[vars['subsystem']][2]: | if subsystem_details[vars['subsystem']][2]: | ||||
target_link_flags = "-dll" | target_link_flags = "-dll" | ||||
target_ext = ".dll" | target_ext = ".dll" | ||||
print "# As the target uses Python%s.dll, we must use this compiler option!" % version_suffix | print("# As the target uses Python%s.dll, we must use this compiler option!" % version_suffix) | ||||
print "cdl = /MD" | print("cdl = /MD") | ||||
print() | |||||
print "all: $(target)$(debug_suffix)%s" % (target_ext) | print("all: $(target)$(debug_suffix)%s" % (target_ext)) | ||||
print() | |||||
print '$(temp_dir):' | print('$(temp_dir):') | ||||
print ' if not exist $(temp_dir)\. mkdir $(temp_dir)' | print(' if not exist $(temp_dir)\. mkdir $(temp_dir)') | ||||
print() | |||||
objects = [] | objects = [] | ||||
libs = ["shell32.lib", "comdlg32.lib", "wsock32.lib", "user32.lib", "oleaut32.lib"] | libs = ["shell32.lib", "comdlg32.lib", "wsock32.lib", "user32.lib", "oleaut32.lib"] | ||||
for moddefn in moddefns: | for moddefn in moddefns: | ||||
print "# Module", moddefn.name | print("# Module", moddefn.name) | ||||
for file in moddefn.sourceFiles: | for file in moddefn.sourceFiles: | ||||
base = os.path.basename(file) | base = os.path.basename(file) | ||||
base, ext = os.path.splitext(base) | base, ext = os.path.splitext(base) | ||||
objects.append(base + ".obj") | objects.append(base + ".obj") | ||||
print '$(temp_dir)\%s.obj: "%s"' % (base, file) | print('$(temp_dir)\%s.obj: "%s"' % (base, file)) | ||||
print "\t@$(CC) -c -nologo /Fo$* $(cdl) $(c_debug) /D BUILD_FREEZE", | print("\t@$(CC) -c -nologo /Fo$* $(cdl) $(c_debug) /D BUILD_FREEZE", end=' ') | ||||
print '"-I$(pythonhome)/Include" "-I$(pythonhome)/PC" \\' | print('"-I$(pythonhome)/Include" "-I$(pythonhome)/PC" \\') | ||||
print "\t\t$(cflags) $(cdebug) $(cinclude) \\" | print("\t\t$(cflags) $(cdebug) $(cinclude) \\") | ||||
extra = moddefn.GetCompilerOptions() | extra = moddefn.GetCompilerOptions() | ||||
if extra: | if extra: | ||||
print "\t\t%s \\" % (' '.join(extra),) | print("\t\t%s \\" % (' '.join(extra),)) | ||||
print '\t\t"%s"' % file | print('\t\t"%s"' % file) | ||||
print() | |||||
# Add .lib files this module needs | # Add .lib files this module needs | ||||
for modlib in moddefn.GetLinkerLibs(): | for modlib in moddefn.GetLinkerLibs(): | ||||
if modlib not in libs: | if modlib not in libs: | ||||
libs.append(modlib) | libs.append(modlib) | ||||
print "ADDN_LINK_FILES=", | print("ADDN_LINK_FILES=", end=' ') | ||||
for addn in vars['addn_link']: print '"%s"' % (addn), | for addn in vars['addn_link']: print('"%s"' % (addn), end=' ') | ||||
print ; print | print() ; print() | ||||
print "OBJS=", | print("OBJS=", end=' ') | ||||
for obj in objects: print '"$(temp_dir)\%s"' % (obj), | for obj in objects: print('"$(temp_dir)\%s"' % (obj), end=' ') | ||||
print ; print | print() ; print() | ||||
print "LIBS=", | print("LIBS=", end=' ') | ||||
for lib in libs: print '"%s"' % (lib), | for lib in libs: print('"%s"' % (lib), end=' ') | ||||
print ; print | print() ; print() | ||||
print "$(target)$(debug_suffix)%s: $(temp_dir) $(OBJS)" % (target_ext) | print("$(target)$(debug_suffix)%s: $(temp_dir) $(OBJS)" % (target_ext)) | ||||
print "\tlink -out:$(target)$(debug_suffix)%s %s" % (target_ext, target_link_flags), | print("\tlink -out:$(target)$(debug_suffix)%s %s" % (target_ext, target_link_flags), end=' ') | ||||
print "\t$(OBJS) \\" | print("\t$(OBJS) \\") | ||||
print "\t$(LIBS) \\" | print("\t$(LIBS) \\") | ||||
print "\t$(ADDN_LINK_FILES) \\" | print("\t$(ADDN_LINK_FILES) \\") | ||||
print "\t$(pythonlib) $(lcustom) $(l_debug)\\" | print("\t$(pythonlib) $(lcustom) $(l_debug)\\") | ||||
print "\t$(resources)" | print("\t$(resources)") | ||||
print() | |||||
print "clean:" | print("clean:") | ||||
print "\t-rm -f *.obj" | print("\t-rm -f *.obj") | ||||
print "\t-rm -f $(target).exe" | print("\t-rm -f $(target).exe") |