rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
if Target == "NT386MINGNU" or (Target == "NT386" and GCC_BACKEND and OSType == "WIN32"):
|
if Target == "NT386MINGNU" or (Target == "NT386" and GCC_BACKEND and TargetOS == "WIN32"):
|
def SetupEnvironment(): SystemDrive = os.environ.get("SystemDrive", "") if os.environ.get("OS") == "Windows_NT": HostIsNT = True else: HostIsNT = False SystemDrive = os.environ.get("SYSTEMDRIVE") if SystemDrive: SystemDrive += os.path.sep # Do this earlier so that its link isn't a problem. # Looking in the registry HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2 # would be reasonable here. if CM3IsCygwin: _SetupEnvironmentVariableAll( "PATH", ["cygwin1.dll"], os.path.join(SystemDrive, "cygwin", "bin")) # some host/target confusion here.. if Target == "NT386" and HostIsNT and Config == "NT386" and (not GCC_BACKEND) and OSType == "WIN32": VCBin = "" VCInc = "" VCLib = "" MspdbDir = "" # 4.0 e:\MSDEV # 5.0 E:\Program Files\DevStudio\SharedIDE MSDevDir = os.environ.get("MSDEVDIR") # 5.0 MSVCDir = os.environ.get("MSVCDIR") # E:\Program Files\DevStudio\VC # 7.1 Express VCToolkitInstallDir = os.environ.get("VCTOOLKITINSTALLDIR") # E:\Program Files\Microsoft Visual C++ Toolkit 2003 (not set by vcvars32) # 8.0 Express # E:\Program Files\Microsoft Visual Studio 8\VC # E:\Program Files\Microsoft Visual Studio 8\Common7\Tools DevEnvDir = os.environ.get("DevEnvDir") # E:\Program Files\Microsoft Visual Studio 8\Common7\IDE VSInstallDir = os.environ.get("VSINSTALLDIR") # E:\Program Files\Microsoft Visual Studio 8 # VS80CommonTools = os.environ.get("VS80COMNTOOLS") # E:\Program Files\Microsoft Visual Studio 8\Common7\Tools VCInstallDir = os.environ.get("VCINSTALLDIR") # E:\Program Files\Microsoft Visual Studio 8\VC # 9.0 Express # always, global #VS90COMNTOOLS=D:\msdev\90\Common7\Tools\ # after running the shortcut #VCINSTALLDIR=D:\msdev\90\VC #VSINSTALLDIR=D:\msdev\90 VSCommonTools = os.environ.get("VS90COMNTOOLS") if VSCommonTools and not VSInstallDir: VSInstallDir = RemoveLastPathElement(RemoveLastPathElement(VSCommonTools)) # The Windows SDK is carried with the express edition and tricky to find. # Best if folks just run the installed shortcut probably. # We do a pretty good job now of finding it, be need to encode # more paths to known versions. # This is not yet finished. # # Probe the partly version-specific less-polluting environment variables, # from newest to oldest. # That is, having setup alter PATH, INCLUDE, and LIB system-wide is not # a great idea, but having setup set DevEnvDir, VSINSTALLDIR, VS80COMNTOOLS, etc. # isn't so bad and we can temporarily establish the first set from the second # set. if VSInstallDir: # Visual C++ 2005/8.0, at least the Express Edition, free download # also Visual C++ 2008/9.0 Express Edition if not VCInstallDir: VCInstallDir = os.path.join(VSInstallDir, "VC") #print("VCInstallDir:" + VCInstallDir) if not DevEnvDir: DevEnvDir = os.path.join(VSInstallDir, "Common7", "IDE") #print("DevEnvDir:" + DevEnvDir) MspdbDir = DevEnvDir elif VCToolkitInstallDir: # free download Visual C++ 2003; no longer available VCInstallDir = VCToolkitInstallDir elif MSVCDir and MSDevDir: # Visual C++ 5.0 pass # do more research # VCInstallDir = MSVCDir elif MSDevDir: # Visual C++ 4.0, 5.0 pass # do more research # VCInstallDir = MSDevDir else: # This is what really happens on my machine, for 8.0. # It might be good to guide pylib.py to other versions, # however setting things up manually suffices and I have, um, # well automated. Msdev = os.path.join(SystemDrive, "msdev", "80") VCInstallDir = os.path.join(Msdev, "VC") DevEnvDir = os.path.join(Msdev, "Common7", "IDE") if VCInstallDir: VCBin = os.path.join(VCInstallDir, "bin") VCLib = os.path.join(VCInstallDir, "lib") VCInc = os.path.join(VCInstallDir, "include") if DevEnvDir: MspdbDir = DevEnvDir #elif VCBin: # MspdbDir = VCBin # Look for SDKs. # expand this as they are released/discovered # ordering is from newest to oldest PossibleSDKs = [os.path.join("Microsoft SDKs", "Windows", "v6.0A"), "Microsoft Platform SDK for Windows Server 2003 R2"] SDKs = [] for a in GetProgramFiles(): #print("checking " + a) for b in PossibleSDKs: c = os.path.join(a, b) #print("checking " + c) if isdir(c) and not (c in SDKs): SDKs.append(c) # Make sure %INCLUDE% contains errno.h and windows.h. # This doesn't work correctly for Cygwin Python, ok. if _CheckSetupEnvironmentVariableAll("INCLUDE", ["errno.h", "windows.h"], VCInc): for a in SDKs: b = os.path.join(a, "include") if isfile(os.path.join(b, "windows.h")): _SetupEnvironmentVariableAll("INCLUDE", ["errno.h", "windows.h"], VCInc + ";" + b, ";") break # Make sure %LIB% contains kernel32.lib and libcmt.lib. # We carry our own kernel32.lib so we don't look in the SDKs. # We usually use msvcrt.lib and not libcmt.lib, but Express 2003 had libcmt.lib and not msvcrt.lib # I think, and libcmt.lib is always present. _SetupEnvironmentVariableAll( "LIB", ["kernel32.lib", "libcmt.lib"], VCLib + ";" + os.path.join(InstallRoot, "lib")) # Check that cl.exe and link.exe are in path, and if not, add VCBin to it, # checking that they are in it. # # Do this before mspdb*dll because it sometimes gets it in the path. # (Why do we care?) _SetupEnvironmentVariableAll("PATH", ["cl", "link"], VCBin) # If none of mspdb*.dll are in PATH, add MpsdbDir to PATH, and check that one of them is in it. _SetupEnvironmentVariableAny( "PATH", ["mspdb80.dll", "mspdb71.dll", "mspdb70.dll", "mspdb60.dll", "mspdb50.dll", "mspdb41.dll", "mspdb40.dll", "dbi.dll"], MspdbDir) # Try to get mt.exe in %PATH% if it isn't already. # We only need this for certain toolsets. if not SearchPath("mt.exe", os.environ.get("PATH")): for a in SDKs: b = os.path.join(a, "bin") if isfile(os.path.join(b, "mt.exe")): SetEnvironmentVariable("PATH", os.environ.get("PATH") + os.pathsep + b) break # sys.exit(1) # The free Visual C++ 2003 has neither delayimp.lib nor msvcrt.lib. # Very old toolsets have no delayimp.lib. # The Quake config file checks these environment variables. Lib = os.environ.get("LIB") if not SearchPath("delayimp.lib", Lib): os.environ["USE_DELAYLOAD"] = "0" print("set USE_DELAYLOAD=0") if not SearchPath("msvcrt.lib", Lib): os.environ["USE_MSVCRT"] = "0" print("set USE_MSVCRT=0") # some host/target confusion here.. if Target == "NT386MINGNU" or (Target == "NT386" and GCC_BACKEND and OSType == "WIN32"): _ClearEnvironmentVariable("LIB") _ClearEnvironmentVariable("INCLUDE") _SetupEnvironmentVariableAll( "PATH", ["gcc", "as", "ld"], os.path.join(SystemDrive, "mingw", "bin")) # need to probe for ld that accepts response files. # For example, this version does not: # C:\dev2\cm3\scripts\python>ld -v # GNU ld version 2.15.91 20040904 # This comes with Qt I think (free Windows version) # # This version works: # C:\dev2\cm3\scripts\python>ld -v # GNU ld version 2.17.50 20060824 # Ensure msys make is ahead of mingwin make, by adding # msys to the start of the path after adding mingw to the # start of the path. Modula-3 does not generally use # make, but this might matter when building m3cg, and # is usually the right thing. _SetupEnvironmentVariableAll( "PATH", ["sh", "sed", "gawk", "make"], os.path.join(SystemDrive, "msys", "1.0", "bin")) # some host/target confusion here.. if Target == "NT386GNU" or (Target == "NT386" and GCC_BACKEND and OSType == "POSIX"): #_ClearEnvironmentVariable("LIB") #_ClearEnvironmentVariable("INCLUDE") #if HostIsNT: # _SetupEnvironmentVariableAll( # "PATH", # ["cygX11-6.dll"], # os.path.join(SystemDrive, "cygwin", "usr", "X11R6", "bin")) _SetupEnvironmentVariableAll( "PATH", ["gcc", "as", "ld"], os.path.join(SystemDrive, "cygwin", "bin"))
|
if Target == "NT386GNU" or (Target == "NT386" and GCC_BACKEND and OSType == "POSIX"):
|
if Host == "NT386GNU" or (Host == "NT386" and GCC_BACKEND and TargetOS == "POSIX"):
|
def SetupEnvironment(): SystemDrive = os.environ.get("SystemDrive", "") if os.environ.get("OS") == "Windows_NT": HostIsNT = True else: HostIsNT = False SystemDrive = os.environ.get("SYSTEMDRIVE") if SystemDrive: SystemDrive += os.path.sep # Do this earlier so that its link isn't a problem. # Looking in the registry HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2 # would be reasonable here. if CM3IsCygwin: _SetupEnvironmentVariableAll( "PATH", ["cygwin1.dll"], os.path.join(SystemDrive, "cygwin", "bin")) # some host/target confusion here.. if Target == "NT386" and HostIsNT and Config == "NT386" and (not GCC_BACKEND) and OSType == "WIN32": VCBin = "" VCInc = "" VCLib = "" MspdbDir = "" # 4.0 e:\MSDEV # 5.0 E:\Program Files\DevStudio\SharedIDE MSDevDir = os.environ.get("MSDEVDIR") # 5.0 MSVCDir = os.environ.get("MSVCDIR") # E:\Program Files\DevStudio\VC # 7.1 Express VCToolkitInstallDir = os.environ.get("VCTOOLKITINSTALLDIR") # E:\Program Files\Microsoft Visual C++ Toolkit 2003 (not set by vcvars32) # 8.0 Express # E:\Program Files\Microsoft Visual Studio 8\VC # E:\Program Files\Microsoft Visual Studio 8\Common7\Tools DevEnvDir = os.environ.get("DevEnvDir") # E:\Program Files\Microsoft Visual Studio 8\Common7\IDE VSInstallDir = os.environ.get("VSINSTALLDIR") # E:\Program Files\Microsoft Visual Studio 8 # VS80CommonTools = os.environ.get("VS80COMNTOOLS") # E:\Program Files\Microsoft Visual Studio 8\Common7\Tools VCInstallDir = os.environ.get("VCINSTALLDIR") # E:\Program Files\Microsoft Visual Studio 8\VC # 9.0 Express # always, global #VS90COMNTOOLS=D:\msdev\90\Common7\Tools\ # after running the shortcut #VCINSTALLDIR=D:\msdev\90\VC #VSINSTALLDIR=D:\msdev\90 VSCommonTools = os.environ.get("VS90COMNTOOLS") if VSCommonTools and not VSInstallDir: VSInstallDir = RemoveLastPathElement(RemoveLastPathElement(VSCommonTools)) # The Windows SDK is carried with the express edition and tricky to find. # Best if folks just run the installed shortcut probably. # We do a pretty good job now of finding it, be need to encode # more paths to known versions. # This is not yet finished. # # Probe the partly version-specific less-polluting environment variables, # from newest to oldest. # That is, having setup alter PATH, INCLUDE, and LIB system-wide is not # a great idea, but having setup set DevEnvDir, VSINSTALLDIR, VS80COMNTOOLS, etc. # isn't so bad and we can temporarily establish the first set from the second # set. if VSInstallDir: # Visual C++ 2005/8.0, at least the Express Edition, free download # also Visual C++ 2008/9.0 Express Edition if not VCInstallDir: VCInstallDir = os.path.join(VSInstallDir, "VC") #print("VCInstallDir:" + VCInstallDir) if not DevEnvDir: DevEnvDir = os.path.join(VSInstallDir, "Common7", "IDE") #print("DevEnvDir:" + DevEnvDir) MspdbDir = DevEnvDir elif VCToolkitInstallDir: # free download Visual C++ 2003; no longer available VCInstallDir = VCToolkitInstallDir elif MSVCDir and MSDevDir: # Visual C++ 5.0 pass # do more research # VCInstallDir = MSVCDir elif MSDevDir: # Visual C++ 4.0, 5.0 pass # do more research # VCInstallDir = MSDevDir else: # This is what really happens on my machine, for 8.0. # It might be good to guide pylib.py to other versions, # however setting things up manually suffices and I have, um, # well automated. Msdev = os.path.join(SystemDrive, "msdev", "80") VCInstallDir = os.path.join(Msdev, "VC") DevEnvDir = os.path.join(Msdev, "Common7", "IDE") if VCInstallDir: VCBin = os.path.join(VCInstallDir, "bin") VCLib = os.path.join(VCInstallDir, "lib") VCInc = os.path.join(VCInstallDir, "include") if DevEnvDir: MspdbDir = DevEnvDir #elif VCBin: # MspdbDir = VCBin # Look for SDKs. # expand this as they are released/discovered # ordering is from newest to oldest PossibleSDKs = [os.path.join("Microsoft SDKs", "Windows", "v6.0A"), "Microsoft Platform SDK for Windows Server 2003 R2"] SDKs = [] for a in GetProgramFiles(): #print("checking " + a) for b in PossibleSDKs: c = os.path.join(a, b) #print("checking " + c) if isdir(c) and not (c in SDKs): SDKs.append(c) # Make sure %INCLUDE% contains errno.h and windows.h. # This doesn't work correctly for Cygwin Python, ok. if _CheckSetupEnvironmentVariableAll("INCLUDE", ["errno.h", "windows.h"], VCInc): for a in SDKs: b = os.path.join(a, "include") if isfile(os.path.join(b, "windows.h")): _SetupEnvironmentVariableAll("INCLUDE", ["errno.h", "windows.h"], VCInc + ";" + b, ";") break # Make sure %LIB% contains kernel32.lib and libcmt.lib. # We carry our own kernel32.lib so we don't look in the SDKs. # We usually use msvcrt.lib and not libcmt.lib, but Express 2003 had libcmt.lib and not msvcrt.lib # I think, and libcmt.lib is always present. _SetupEnvironmentVariableAll( "LIB", ["kernel32.lib", "libcmt.lib"], VCLib + ";" + os.path.join(InstallRoot, "lib")) # Check that cl.exe and link.exe are in path, and if not, add VCBin to it, # checking that they are in it. # # Do this before mspdb*dll because it sometimes gets it in the path. # (Why do we care?) _SetupEnvironmentVariableAll("PATH", ["cl", "link"], VCBin) # If none of mspdb*.dll are in PATH, add MpsdbDir to PATH, and check that one of them is in it. _SetupEnvironmentVariableAny( "PATH", ["mspdb80.dll", "mspdb71.dll", "mspdb70.dll", "mspdb60.dll", "mspdb50.dll", "mspdb41.dll", "mspdb40.dll", "dbi.dll"], MspdbDir) # Try to get mt.exe in %PATH% if it isn't already. # We only need this for certain toolsets. if not SearchPath("mt.exe", os.environ.get("PATH")): for a in SDKs: b = os.path.join(a, "bin") if isfile(os.path.join(b, "mt.exe")): SetEnvironmentVariable("PATH", os.environ.get("PATH") + os.pathsep + b) break # sys.exit(1) # The free Visual C++ 2003 has neither delayimp.lib nor msvcrt.lib. # Very old toolsets have no delayimp.lib. # The Quake config file checks these environment variables. Lib = os.environ.get("LIB") if not SearchPath("delayimp.lib", Lib): os.environ["USE_DELAYLOAD"] = "0" print("set USE_DELAYLOAD=0") if not SearchPath("msvcrt.lib", Lib): os.environ["USE_MSVCRT"] = "0" print("set USE_MSVCRT=0") # some host/target confusion here.. if Target == "NT386MINGNU" or (Target == "NT386" and GCC_BACKEND and OSType == "WIN32"): _ClearEnvironmentVariable("LIB") _ClearEnvironmentVariable("INCLUDE") _SetupEnvironmentVariableAll( "PATH", ["gcc", "as", "ld"], os.path.join(SystemDrive, "mingw", "bin")) # need to probe for ld that accepts response files. # For example, this version does not: # C:\dev2\cm3\scripts\python>ld -v # GNU ld version 2.15.91 20040904 # This comes with Qt I think (free Windows version) # # This version works: # C:\dev2\cm3\scripts\python>ld -v # GNU ld version 2.17.50 20060824 # Ensure msys make is ahead of mingwin make, by adding # msys to the start of the path after adding mingw to the # start of the path. Modula-3 does not generally use # make, but this might matter when building m3cg, and # is usually the right thing. _SetupEnvironmentVariableAll( "PATH", ["sh", "sed", "gawk", "make"], os.path.join(SystemDrive, "msys", "1.0", "bin")) # some host/target confusion here.. if Target == "NT386GNU" or (Target == "NT386" and GCC_BACKEND and OSType == "POSIX"): #_ClearEnvironmentVariable("LIB") #_ClearEnvironmentVariable("INCLUDE") #if HostIsNT: # _SetupEnvironmentVariableAll( # "PATH", # ["cygX11-6.dll"], # os.path.join(SystemDrive, "cygwin", "usr", "X11R6", "bin")) _SetupEnvironmentVariableAll( "PATH", ["gcc", "as", "ld"], os.path.join(SystemDrive, "cygwin", "bin"))
|
if Config == "NT386":
|
if Config == "NT386" or Config == "I386_NT":
|
def FormInstallRoot(PackageSetName): AltConfig = {"NT386":"x86"}.get(Config, Config) a = os.path.join(GetStage(), "cm3-" + PackageSetName + "-" + AltConfig + "-" + CM3VERSION) if Config == "NT386": a = a + "-VC" + GetVisualCPlusPlusVersion() return a
|
if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or Target.find("ALPHA") != -1: Assemble = Assemble + " --64" else: Assemble = Assemble + " --32"
|
if Target != "PPC32_OPENBSD": if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or Target.find("ALPHA") != -1: Assemble = Assemble + " --64" else: Assemble = Assemble + " --32"
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Target Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. SunCompile = "/usr/ccs/bin/cc -g -mt -xcode=pic32 -xldscope=symbolic " GnuCompile = { # gcc -fPIC generates incorrect code on Interix "I386_INTERIX" : "gcc -g " }.get(Target) or "gcc -g -fPIC " if Target.endswith("_SOLARIS") or Target == "SOLsun": Compile = SunCompile else: Compile = GnuCompile Compile = Compile + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 ", "SOLsun" : " -xarch=v8plus ", "SPARC32_LINUX" : " -m32 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", "SPARC64_SOLARIS" : " -xarch=v9 ", }.get(Target) or " ") SunLink = " -lrt -lm -lnsl -lsocket -lpthread " Link = Compile + ({ "ARM_DARWIN" : " ", "AMD64_DARWIN" : " ", "I386_DARWIN" : " ", "I386_INTERIX" : " -lm ", "PPC_DARWIN" : " ", "PPC64_DARWIN" : " ", "SOLgnu" : SunLink, "SOLsun" : SunLink, "SPARC64_SOLARIS" : SunLink, "PA32_HPUX" : " -lrt -lm ", }.get(Target) or " -lm -lpthread ") # not in Link Compile += " -c " if Target.endswith("_SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or Target.find("ALPHA") != -1: Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "ARM_DARWIN" : " -arch armv6 ", "SOLgnu" : " -s -K PIC -xarch=v8plus ", "SOLsun" : " -s -K PIC -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -K PIC -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", }.get(Target) or "" Compile = GnuPlatformPrefix + Compile Link = GnuPlatformPrefix + Link Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at end # Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) if Target.find("INTERIX") != -1: a = " -I /dev/fs/C/dev2/cm3.2/m3-win/w32api/include" Compile = Compile + a + a + "/ddk" BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "ntdll", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] if Target == "NT386": P += ["mklib"] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Makefile.write(".SUFFIXES:\nall: cm3\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\nset -e\nset -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n") a.write("Assemble=" + Assemble + "\nCompile=" + Compile + "\nLink=" + Link + "\n") a.write("\n\n# no more editing should be needed (except on Interix, look at the bottom)\n\n") for a in [Make]: a.write("Assemble=\"" + Assemble + "\"\nCompile=\"" + Compile + "\"\nLink=\"" + Link + "\"\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): if not (a.endswith(".ms") or a.endswith(".is") or a.endswith(".s") or a.endswith(".c") or a.endswith(".h")): continue CopyFile(os.path.join(Root, dir, Config, a), BootDir) if a.endswith(".h"): continue Makefile.write("Objects += " + a + ".o\n" + a + ".o: " + a + "\n\t") if a.endswith(".c"): Command = "Compile" else: Command = "Assemble" for b in [Make, Makefile]: b.write("${" + Command + "} " + a + " -o " + a + ".o\n") Makefile.write("cm3: $(Objects)\n\t") for a in [Make, Makefile]: if Target.find("INTERIX") == -1: a.write("$(Link) -o cm3 *.o\n") else: a.write("rm -f ntdll.def ntdll.lib ntdll.dll ntdll.o ntdll.c.o a.out a.exe cm3 cm3.exe libntdll.a\n") a.write("gcc -c ntdll.c\n") a.write("/opt/gcc.3.3/i586-pc-interix3/bin/dlltool --dllname ntdll.dll --kill-at --output-lib libntdll.a --export-all-symbols ntdll.o\n") a.write("rm -f ntdll.o ntdll.c.o _m3main.c.o _m3main.o\n") a.write("gcc -g -o cm3 _m3main.c *.o -lm -L . -lntdll\n") Common = "Common" for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/" + Common + "/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/linux-32/m3makefile", "m3-libs/m3core/src/unix/linux-64/m3makefile", "m3-libs/m3core/src/unix/freebsd-common/m3makefile", "m3-libs/m3core/src/unix/freebsd-common/Uerror.i3", "m3-libs/m3core/src/unix/freebsd-common/Usysdep.i3", "m3-libs/m3core/src/unix/freebsd-common/Uucontext.i3", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/" + Common + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Common + "/Csignal.i3", "m3-libs/m3core/src/C/" + Common + "/Cstdio.i3", "m3-libs/m3core/src/C/" + Common + "/Cstring.i3", "m3-libs/m3core/src/C/" + Common + "/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile]: a.close() _MakeArchive(BootDir[2:])
|
"fix_nl": BuildAll or OSType == "WIN32",
|
def _FilterPackage(Package): PackageConditions = { "m3gdb": (M3GDB or CM3_GDB) and {"FreeBSD4": True, "LINUXLIBC6" : True, "SOLgnu" : True, "NetBSD2_i386" : True, "NT386GNU" : True, }.get(Target, False), "fix_nl": BuildAll or OSType == "WIN32", "tcl": BuildAll or HAVE_TCL, "tapi": BuildAll or OSType == "WIN32", "serial": BuildAll or HAVE_SERIAL, "X11R4": BuildAll or OSType != "WIN32", "m3cc": (GCC_BACKEND and (not OMIT_GCC) and (not "skipgcc" in sys.argv) and (not "omitgcc" in sys.argv) and (not "nogcc" in sys.argv)), } return PackageConditions.get(Package, True)
|
|
a.wrte("
|
a.write("
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = CM3VERSION + "-" + time.strftime("%Y%m%d") # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": CCompiler = "cc" CCompilerFlags = " " elif Config == "ALPHA64_VMS": CCompiler = "cc" CCompilerFlags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": CCompiler = "/usr/bin/cc" CCompilerFlags = "-g -mt -xldscope=symbolic " elif Config == "ALPHA_OSF": CCompiler = "/usr/bin/cc" CCompilerFlags = "-g -pthread" else: # gcc platforms CCompiler = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" CCompilerFlags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " CCompilerFlags = CCompilerFlags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags # TBD: add more and retest, e.g. Irix, AIX, HPUX, Android # http://www.openldap.org/lists/openldap-bugs/200006/msg00070.html # http://www.gnu.org/software/autoconf-archive/ax_pthread.html#ax_pthread if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "MINGW"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm -lpthread " elif Config == "ALPHA_OSF": Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " # -pthread? # not all of these tested esp. Cygwin, NetBSD elif StringContainsI(Target, "FreeBSD") \ or StringContainsI(Target, "NetBSD") \ or StringContainsI(Target, "OpenBSD") \ or StringContainsI(Target, "Cygwin") \ or StringContainsI(Target, "Linux"): Link = Link + " -lm -pthread " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not CCompilerFlags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assembler = "macro" # not right, come back to it later AssemblerFlags = "/alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): # see http://gcc.gnu.org/ml/gcc/2010-05/msg00155.html Assembler = "/usr/ccs/bin/as" elif StringTagged(Target, "OSF"): Assembler = "/usr/bin/as" else: Assembler = "as" # set assembler flags AssemblerFlags = " " if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX" and Target != "ARMEL_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): AssemblerFlags = AssemblerFlags + " --64" else: AssemblerFlags = AssemblerFlags + " --32" AssemblerFlags = (AssemblerFlags + ({ "ALPHA_OSF" : " -nocpp ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", "I386_SOLARIS" : " -Qy -s", "AMD64_SOLARIS" : " -Qy -s -xarch=generic64 ", "SOLgnu" : " -Qy -s -K PIC -xarch=v8plus ", "SOLsun" : " -Qy -s -K PIC -xarch=v8plus ", "SPARC32_SOLARIS" : " -Qy -s -K PIC -xarch=v8plus ", "SPARC64_SOLARIS" : " -Qy -s -K PIC -xarch=v9 ", "SPARC32_LINUX" : " -Qy -s -Av9a -32 -relax ", "SPARC64_LINUX" : " -Qy -s -Av9a -64 -no-undeclared-regs -relax ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ARMEL_LINUX" : "arm-linux-gnueabi-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: CCompiler = GnuPlatformPrefix + CCompiler if (not vms) or AssembleOnHost: Assembler = GnuPlatformPrefix + Assembler # squeeze runs of spaces and spaces at ends Compile = _SqueezeSpaces(Compile) CCompilerFlags = _SqueezeSpaces(CCompilerFlags) Link = _SqueezeSpaces(Link) Assembler = _SqueezeSpaces(Assembler) AssemblerFlags = _SqueezeSpaces(AssemblerFlags) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: if Config == "ALPHA_OSF": a.wrte("# add -DM3_OSF1_V4 for OSF1v4 or older\n") a.write("# edit up here\n\n" + "CC=" + CCompiler + "\n" + "CFLAGS=" + CCompilerFlags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assembler + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + CCompiler + "}\n" + "CFLAGS=${CFLAGS:-" + CCompilerFlags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assembler + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assembler + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assembler + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
UNameCommand = os.popen("uname").read().lower() UNameTuple = uname() UName = UNameTuple[0].lower() UNameArchP = platform.processor().lower() UNameArchM = UNameTuple[4].lower() UNameRevision = UNameTuple[2].lower()
|
def GetVersion(Key): # # Only read the file if an environment variable is "missing" (they # usually all are, ok), and only read it once. # #print("WriteVariablesIntoEnvironment:3") Value = Versions.get(Key) if Value: return Value # # CM3VERSION d5.7.1 # CM3VERSIONNUM 050701 # CM3LASTCHANGED 2009-01-21 # RegExp = re.compile("(" + "|".join(Versions.keys()) + ") (.+)$", re.IGNORECASE) ShFilePath = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "version") for Line in open(ShFilePath): Match = RegExp.match(Line) if Match: MatchKey = Match.group(1) # # We are here because one of them wasn't found, but we should be # sure only to overwrite what we don't have. # if not Versions[MatchKey]: Value = Match.group(2) Versions[MatchKey] = Value exec("%s = \"%s\"" % (MatchKey, Value), locals(), globals()) # # Make sure we found every key in the file (at least those # not defined in the environment) # MissingKey = None for Item in Versions.iteritems(): #print(Item) if Item[1] is None: MissingKey = Item[0] File = __file__ sys.stderr.write("%(File)s: %(MissingKey)s not found in %(ShFilePath)s\n" % vars()) if MissingKey: sys.exit(1) return Versions.get(Key)
|
|
if (UName.startswith("windows")
|
_Cm3Host = os.popen(CM3 + " -version 2>/dev/null | egrep \" +host: +\"").read() if _Cm3Host != "": Host = _Cm3Host.replace(" ", "").replace("host:", "").replace("\r", "").replace("\n", "") if Host == None: UNameCommand = os.popen("uname").read().lower() UNameTuple = uname() UName = UNameTuple[0].lower() UNameArchP = platform.processor().lower() UNameArchM = UNameTuple[4].lower() UNameRevision = UNameTuple[2].lower() if (UName.startswith("windows")
|
def GetVersion(Key): # # Only read the file if an environment variable is "missing" (they # usually all are, ok), and only read it once. # #print("WriteVariablesIntoEnvironment:3") Value = Versions.get(Key) if Value: return Value # # CM3VERSION d5.7.1 # CM3VERSIONNUM 050701 # CM3LASTCHANGED 2009-01-21 # RegExp = re.compile("(" + "|".join(Versions.keys()) + ") (.+)$", re.IGNORECASE) ShFilePath = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "version") for Line in open(ShFilePath): Match = RegExp.match(Line) if Match: MatchKey = Match.group(1) # # We are here because one of them wasn't found, but we should be # sure only to overwrite what we don't have. # if not Versions[MatchKey]: Value = Match.group(2) Versions[MatchKey] = Value exec("%s = \"%s\"" % (MatchKey, Value), locals(), globals()) # # Make sure we found every key in the file (at least those # not defined in the environment) # MissingKey = None for Item in Versions.iteritems(): #print(Item) if Item[1] is None: MissingKey = Item[0] File = __file__ sys.stderr.write("%(File)s: %(MissingKey)s not found in %(ShFilePath)s\n" % vars()) if MissingKey: sys.exit(1) return Versions.get(Key)
|
def contains(s, t): return s.find(t) != -1 target = Target.lower() currentVC = {"80":1, "90":1} nativeNT = contains(target, "nt386") or target.endswith("_nt") currentNT = nativeNT and currentVC.contains(GetVisualCPlusPlusVersion()) oldNT = nativeNT and not currentNT preferZip = contains(target, "nt386") or target.endswith("_nt") supportsMSI = nativeNT or contains(target, "interix") or contains(target, "cygwin") or contains(target, "mingw") or contains(target, "uwin") PackageSets = ["min", "all"] if oldNT: PackageSets = ["min"]:
|
def contains(s, t): return s.find(t) != -1
|
|
for a in ["m3cc", "cm3"]: if a in AllPackages: AllPackages.remove(a)
|
if "m3cc" in AllPackages: AllPackages.remove("m3cc")
|
def Setup(ExistingCompilerRoot, NewRoot): global InstallRoot InstallRoot = NewRoot os.environ["CM3_INSTALL"] = NewRoot if (OriginalLIB): # This is Windows-only thing. os.environ["LIB"] = os.path.join(NewRoot, "lib") + OriginalLIB os.environ["PATH"] = (os.path.join(NewRoot, "bin") + OriginalPATH) CopyCompiler(ExistingCompilerRoot, NewRoot) or FatalError() if NewRoot == InstallRoot_CompilerWithPrevious: NewLib = os.path.join(NewRoot, "lib") CreateDirectory(NewLib) for a in glob.glob(os.path.join(ExistingCompilerRoot, "lib", "*.obj")): CopyFile(a, NewLib) or FatalError() CopyConfigForDistribution(NewRoot) or sys.exit(1) reload(pylib) or FatalError() os.environ["CM3_INSTALL"] = ConvertToCygwinPath(NewRoot)
|
RealClean(Packages) or FatalError()
|
def Setup(ExistingCompilerRoot, NewRoot): global InstallRoot InstallRoot = NewRoot os.environ["CM3_INSTALL"] = NewRoot if (OriginalLIB): # This is Windows-only thing. os.environ["LIB"] = os.path.join(NewRoot, "lib") + OriginalLIB os.environ["PATH"] = (os.path.join(NewRoot, "bin") + OriginalPATH) CopyCompiler(ExistingCompilerRoot, NewRoot) or FatalError() if NewRoot == InstallRoot_CompilerWithPrevious: NewLib = os.path.join(NewRoot, "lib") CreateDirectory(NewLib) for a in glob.glob(os.path.join(ExistingCompilerRoot, "lib", "*.obj")): CopyFile(a, NewLib) or FatalError() CopyConfigForDistribution(NewRoot) or sys.exit(1) reload(pylib) or FatalError() os.environ["CM3_INSTALL"] = ConvertToCygwinPath(NewRoot)
|
|
ShipCompiler() or FatalError() RealClean(Packages) or FatalError()
|
def Setup(ExistingCompilerRoot, NewRoot): global InstallRoot InstallRoot = NewRoot os.environ["CM3_INSTALL"] = NewRoot if (OriginalLIB): # This is Windows-only thing. os.environ["LIB"] = os.path.join(NewRoot, "lib") + OriginalLIB os.environ["PATH"] = (os.path.join(NewRoot, "bin") + OriginalPATH) CopyCompiler(ExistingCompilerRoot, NewRoot) or FatalError() if NewRoot == InstallRoot_CompilerWithPrevious: NewLib = os.path.join(NewRoot, "lib") CreateDirectory(NewLib) for a in glob.glob(os.path.join(ExistingCompilerRoot, "lib", "*.obj")): CopyFile(a, NewLib) or FatalError() CopyConfigForDistribution(NewRoot) or sys.exit(1) reload(pylib) or FatalError() os.environ["CM3_INSTALL"] = ConvertToCygwinPath(NewRoot)
|
|
if not isdir(a):
|
if isdir(a):
|
def RemoveDirectoryRecursive(a): if os.name != "nt": print("rm -rf " + a) else: print("rmdir /q/s " + a) if not isdir(a): shutil.rmtree(a) return True
|
print("Name + "=" + Value + ";export " + Name)
|
print(Name + "=" + Value + ";export " + Name)
|
def SetEnvironmentVariable(Name, Value): if not os.environ.get(Name) or (os.environ[Name] != Value): os.environ[Name] = Value if os.name == "posix": print("Name + "=" + Value + ";export " + Name) else: print("set " + Name + "=" + Value)
|
def MakeDebianPackage(name, input, output, prefix):
|
def MakeDebianPackage(input, prefix):
|
def MakeDebianPackage(name, input, output, prefix):
|
for name in PackageSets: MakeDebianPackage(name, FormInstallRoot(name), GetStage() + "/cm3-" + name + ".deb", "/usr/local/cm3")
|
MakeDebianPackage(FormInstallRoot("all"), "/usr/local/cm3")
|
def Setup(ExistingCompilerRoot, NewRoot): global InstallRoot InstallRoot = NewRoot os.environ["CM3_INSTALL"] = NewRoot if (OriginalLIB): # This is Windows-only thing. os.environ["LIB"] = os.path.join(NewRoot, "lib") + OriginalLIB os.environ["PATH"] = (os.path.join(NewRoot, "bin") + OriginalPATH) CopyCompiler(ExistingCompilerRoot, NewRoot) or FatalError() if NewRoot == InstallRoot_CompilerWithPrevious: NewLib = os.path.join(NewRoot, "lib") CreateDirectory(NewLib) for a in glob.glob(os.path.join(ExistingCompilerRoot, "lib", "*.obj")): CopyFile(a, NewLib) or FatalError() CopyConfigForDistribution(NewRoot) or sys.exit(1) reload(pylib) or FatalError() os.environ["CM3_INSTALL"] = ConvertToCygwinPath(NewRoot)
|
b = re.sub("(Linux 2.4\..+$", "Linux2.4", b)
|
b = re.sub("Linux 2.4\..+$", "Linux2.4", b)
|
def FormInstallRoot(PackageSetName): AltConfig = {"NT386":"x86"}.get(Config, Config) a = os.path.join(GetStage(), "cm3-" + PackageSetName + "-" + AltConfig + "-" + CM3VERSION) if Config == "NT386" or Config == "I386_NT": a = a + "-VC" + GetVisualCPlusPlusVersion() else: b = os.popen("uname -sr").read() b = re.sub("(Linux 2.4\..+$", "Linux2.4", b) b = re.sub("Linux 2.6\..+$", "", b) b = re.sub("-+$", "", b) b = re.sub("SunOS", "Solaris", b) b = re.sub(" ", "", b) a = a + "-" + b a = a + "-" + time.strftime("%Y%m%d") return a
|
{\\*\\generator Msftedit 5.41.15.1515;}\\viewkind4\\uc1\\pard\\lang1033\\f0\\fs20""" + licenseText.replace("\n", "\\par\n")
|
{\\*\\generator Msftedit 5.41.15.1515;}\\viewkind4\\uc1\\pard\\lang1033\\f0\\fs20""" + licenseText.replace("\n", " ")
|
def HandleDir(state, dir): for a in os.listdir(dir): b = os.path.join(dir, a) if isdir(b): wix.write("""<Directory Id='d%d' Name='%s'>\n""" % (state.dirID, ConvertPathForWin32(a))) state.dirID += 1 HandleDir(state, b) # recursion! wix.write("</Directory>\n") else: wix.write("""<Component Id='c%s' Guid='%s'>\n""" % (str(state.componentID), str(uuid.uuid4()))) state.componentID += 1 if state.componentID == 1: wix.write("""<Environment Id="envPath" Action="set" Name="PATH" Part="last" Permanent="no" Separator=";" Value='[INSTALLDIR]bin'/>\n""")
|
"I386_INTERIX" : "gcc -g " "SOLgnu" : "/usr/sfw/bin/gcc -g "
|
"I386_INTERIX" : "gcc -g ", "SOLgnu" : "/usr/sfw/bin/gcc -g ",
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Target Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. SunCompile = "/usr/ccs/bin/cc -g -mt -xcode=pic32 -xldscope=symbolic " GnuCompile = { "I386_INTERIX" : "gcc -g " # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "/usr/sfw/bin/gcc -g " }.get(Target) or "gcc -g -fPIC " if Target.endswith("_SOLARIS") or Target == "SOLsun": Compile = SunCompile else: Compile = GnuCompile Compile = Compile + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "SOLsun" : " -xarch=v8plus ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", "SPARC64_SOLARIS" : " -xarch=v9 ", }.get(Target) or " ") SunLink = " -lrt -lm -lnsl -lsocket -lpthread " Link = Compile + ({ "ARM_DARWIN" : " ", "AMD64_DARWIN" : " ", "I386_DARWIN" : " ", "I386_INTERIX" : " -lm ", "PPC_DARWIN" : " ", "PPC64_DARWIN" : " ", "SOLgnu" : SunLink, "SOLsun" : SunLink, "SPARC64_SOLARIS" : SunLink, "PA32_HPUX" : " -lrt -lm ", }.get(Target) or " -lm -lpthread ") # not in Link Compile += " -c " if Target.endswith("_SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or Target.find("ALPHA") != -1: Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", }.get(Target) or "" Compile = GnuPlatformPrefix + Compile Link = GnuPlatformPrefix + Link Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at end # Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Makefile.write(".SUFFIXES:\nall: cm3\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\nset -e\nset -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n") a.write("Assemble=" + Assemble + "\nCompile=" + Compile + "\nLink=" + Link + "\n") a.write("\n\n# no more editing should be needed (except on Interix, look at the bottom)\n\n") for a in [Make]: a.write("Assemble=\"" + Assemble + "\"\nCompile=\"" + Compile + "\"\nLink=\"" + Link + "\"\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): if not (a.endswith(".ms") or a.endswith(".is") or a.endswith(".s") or a.endswith(".c") or a.endswith(".h")): continue CopyFile(os.path.join(Root, dir, Config, a), BootDir) if a.endswith(".h"): continue Makefile.write("Objects += " + a + ".o\n" + a + ".o: " + a + "\n\t") if a.endswith(".c"): Command = "Compile" else: Command = "Assemble" for b in [Make, Makefile]: b.write("${" + Command + "} " + a + " -o " + a + ".o\n") Makefile.write("cm3: $(Objects)\n\t") for a in [Make, Makefile]: if Target.find("INTERIX") == -1: a.write("$(Link) -o cm3 *.o\n") else: # Do we still need this variation? a.write("rm -f ntdll.def ntdll.lib ntdll.dll ntdll.o ntdll.c.o a.out a.exe cm3 cm3.exe libntdll.a _m3main.c.o _m3main.o\n") a.write("gcc -g -o cm3 _m3main.c *.o -lm -L . -lntdll\n") Common = "Common" for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/" + Common + "/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/linux-32/m3makefile", "m3-libs/m3core/src/unix/linux-64/m3makefile", "m3-libs/m3core/src/unix/freebsd-common/m3makefile", "m3-libs/m3core/src/unix/freebsd-common/Uerror.i3", "m3-libs/m3core/src/unix/freebsd-common/Usysdep.i3", "m3-libs/m3core/src/unix/freebsd-common/Uucontext.i3", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/" + Common + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Common + "/Csignal.i3", "m3-libs/m3core/src/C/" + Common + "/Cstdio.i3", "m3-libs/m3core/src/C/" + Common + "/Cstring.i3", "m3-libs/m3core/src/C/" + Common + "/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile]: a.close() _MakeArchive(BootDir[2:])
|
"PPC64", "SPARC", "SPARC32", "SPARC64", "MIPS32", "MIPS64", "PA32", "PA64", "SH"]: for os in ["AIX", "CE", "CYGWIN", "DARWIN", "FREEBSD", "HPUX" "INTERIX", "IRIX",
|
"PPC64", "SPARC", "SPARC32", "SPARC64", "MIPS32", "MIPS64EL", "MIPS64", "PA32", "PA64", "SH"]: for os in ["AIX", "CE", "CYGWIN", "DARWIN", "FREEBSD", "HPUX", "INTERIX", "IRIX",
|
def _GetAllTargets(): # legacy naming Targets = [ "NT386", "NT386GNU", "NT386MINGNU", "LINUXLIBC6", "SOLsun", "SOLgnu", "FreeBSD4", "NetBSD2_i386" ] # systematic naming for proc in ["ALPHA", "ALPHA32", "ALPHA64", "AMD64", "ARM", "ARMEL", "IA64", "I386", "PPC", "PPC32", "PPC64", "SPARC", "SPARC32", "SPARC64", "MIPS32", "MIPS64", "PA32", "PA64", "SH"]: for os in ["AIX", "CE", "CYGWIN", "DARWIN", "FREEBSD", "HPUX" "INTERIX", "IRIX", "LINUX", "MINGW", "NETBSD", "NT", "OPENBSD", "OSF", "SOLARIS", "VMS"]: # "BEOS", "MSDOS" (DJGPP), "OS2" (EMX), "PLAN9" Targets += [proc + "_" + os] return Targets
|
if false:
|
if False:
|
def GetVersion(Key): # # Only read the file if an environment variable is "missing" (they # usually all are, ok), and only read it once. # #print("WriteVariablesIntoEnvironment:3") Value = Versions.get(Key) if Value: return Value # # CM3VERSION d5.7.1 # CM3VERSIONNUM 050701 # CM3LASTCHANGED 2009-01-21 # RegExp = re.compile("(" + "|".join(Versions.keys()) + ") (.+)$", re.IGNORECASE) ShFilePath = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "version") for Line in open(ShFilePath): Match = RegExp.match(Line) if Match: MatchKey = Match.group(1) # # We are here because one of them wasn't found, but we should be # sure only to overwrite what we don't have. # if not Versions[MatchKey]: Value = Match.group(2) Versions[MatchKey] = Value exec("%s = \"%s\"" % (MatchKey, Value), locals(), globals()) # # Make sure we found every key in the file (at least those # not defined in the environment) # MissingKey = None for Item in Versions.iteritems(): #print(Item) if Item[1] is None: MissingKey = Item[0] File = __file__ sys.stderr.write("%(File)s: %(MissingKey)s not found in %(ShFilePath)s\n" % vars()) if MissingKey: sys.exit(1) return Versions.get(Key)
|
CCompiler = "CCompiler"
|
CCompiler = "cc"
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": CCompiler = "CCompiler" CCompilerFlags = " " elif Config == "ALPHA64_VMS": CCompiler = "CCompiler" CCompilerFlags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": CCompiler = "/usr/bin/CCompiler" CCompilerFlags = "-g -mt -xldscope=symbolic " else: # gcc platforms CCompiler = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" CCompilerFlags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " CCompilerFlags = CCompilerFlags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not CCompilerFlags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler AssemblerFlags = " " if StringTagged(Target, "VMS") and AssembleOnTarget: AssemblerMk = "macro" # not right, come back to it later AssemblerSh = "macro" # not right, come back to it later AssemblerFlags = "/alpha " # not right, come back to it later elif Target == "I386_SOLARIS" or Target == "AMD64_SOLARIS": # # see http://gcc.gnu.org/ml/gcc/2010-05/msg00155.html # see http://gcc.gnu.org/install/specific.html#ix86-x-solaris210 # a = (" if test -x /usr/sfw/bin/gas ; then echo /usr/sfw/bin/gas ; \\\n" + " elif test -x /opt/csw/gnu/as ; then echo /opt/csw/gnu/as ; \\\n" + " else echo \"unable to find GNU assembler\" ; fi") AssemblerMk = "$(shell " + a + ")" AssemblerSh = "`" + a + "`" elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): AssemblerMk = "/usr/ccs/bin/as" AssemblerSh = "/usr/ccs/bin/as" else: AssemblerMk = "as" AssemblerSh = "as" # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): AssemblerFlags = AssemblerFlags + " --64" else: AssemblerFlags = AssemblerFlags + " --32" AssemblerFlags = (AssemblerFlags + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: CCompiler = GnuPlatformPrefix + CCompiler Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: AssemblerMk = GnuPlatformPrefix + AssemblerMk AssemblerSh = GnuPlatformPrefix + AssemblerSh # # squeeze runs of spaces and spaces at ends # CCompilerFlags = re.sub(" +", " ", CCompilerFlags) CCompilerFlags = re.sub(" +$", "", CCompilerFlags) CCompilerFlags = re.sub("^ +", "", CCompilerFlags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) AssemblerFlags = re.sub(" +", " ", AssemblerFlags) AssemblerFlags = re.sub(" +$", "", AssemblerFlags) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + CCompiler + "\n" + "CFLAGS ?= " + CCompilerFlags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerMk + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + CCompiler + "}\n" + "CFLAGS=${CFLAGS:-" + CCompilerFlags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerSh + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = AssemblerMk + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + AssemblerMk + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
CCompiler = "/usr/bin/CCompiler"
|
CCompiler = "/usr/bin/cc"
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": CCompiler = "CCompiler" CCompilerFlags = " " elif Config == "ALPHA64_VMS": CCompiler = "CCompiler" CCompilerFlags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": CCompiler = "/usr/bin/CCompiler" CCompilerFlags = "-g -mt -xldscope=symbolic " else: # gcc platforms CCompiler = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" CCompilerFlags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " CCompilerFlags = CCompilerFlags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not CCompilerFlags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler AssemblerFlags = " " if StringTagged(Target, "VMS") and AssembleOnTarget: AssemblerMk = "macro" # not right, come back to it later AssemblerSh = "macro" # not right, come back to it later AssemblerFlags = "/alpha " # not right, come back to it later elif Target == "I386_SOLARIS" or Target == "AMD64_SOLARIS": # # see http://gcc.gnu.org/ml/gcc/2010-05/msg00155.html # see http://gcc.gnu.org/install/specific.html#ix86-x-solaris210 # a = (" if test -x /usr/sfw/bin/gas ; then echo /usr/sfw/bin/gas ; \\\n" + " elif test -x /opt/csw/gnu/as ; then echo /opt/csw/gnu/as ; \\\n" + " else echo \"unable to find GNU assembler\" ; fi") AssemblerMk = "$(shell " + a + ")" AssemblerSh = "`" + a + "`" elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): AssemblerMk = "/usr/ccs/bin/as" AssemblerSh = "/usr/ccs/bin/as" else: AssemblerMk = "as" AssemblerSh = "as" # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): AssemblerFlags = AssemblerFlags + " --64" else: AssemblerFlags = AssemblerFlags + " --32" AssemblerFlags = (AssemblerFlags + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: CCompiler = GnuPlatformPrefix + CCompiler Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: AssemblerMk = GnuPlatformPrefix + AssemblerMk AssemblerSh = GnuPlatformPrefix + AssemblerSh # # squeeze runs of spaces and spaces at ends # CCompilerFlags = re.sub(" +", " ", CCompilerFlags) CCompilerFlags = re.sub(" +$", "", CCompilerFlags) CCompilerFlags = re.sub("^ +", "", CCompilerFlags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) AssemblerFlags = re.sub(" +", " ", AssemblerFlags) AssemblerFlags = re.sub(" +$", "", AssemblerFlags) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + CCompiler + "\n" + "CFLAGS ?= " + CCompilerFlags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerMk + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + CCompiler + "}\n" + "CFLAGS=${CFLAGS:-" + CCompilerFlags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerSh + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = AssemblerMk + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + AssemblerMk + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
CCompilerFlags = CCompilerFlags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ")
|
CCompilerFlags = CCompilerFlags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic13 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic13 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic13 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ")
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": CCompiler = "CCompiler" CCompilerFlags = " " elif Config == "ALPHA64_VMS": CCompiler = "CCompiler" CCompilerFlags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": CCompiler = "/usr/bin/CCompiler" CCompilerFlags = "-g -mt -xldscope=symbolic " else: # gcc platforms CCompiler = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" CCompilerFlags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " CCompilerFlags = CCompilerFlags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not CCompilerFlags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler AssemblerFlags = " " if StringTagged(Target, "VMS") and AssembleOnTarget: AssemblerMk = "macro" # not right, come back to it later AssemblerSh = "macro" # not right, come back to it later AssemblerFlags = "/alpha " # not right, come back to it later elif Target == "I386_SOLARIS" or Target == "AMD64_SOLARIS": # # see http://gcc.gnu.org/ml/gcc/2010-05/msg00155.html # see http://gcc.gnu.org/install/specific.html#ix86-x-solaris210 # a = (" if test -x /usr/sfw/bin/gas ; then echo /usr/sfw/bin/gas ; \\\n" + " elif test -x /opt/csw/gnu/as ; then echo /opt/csw/gnu/as ; \\\n" + " else echo \"unable to find GNU assembler\" ; fi") AssemblerMk = "$(shell " + a + ")" AssemblerSh = "`" + a + "`" elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): AssemblerMk = "/usr/ccs/bin/as" AssemblerSh = "/usr/ccs/bin/as" else: AssemblerMk = "as" AssemblerSh = "as" # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): AssemblerFlags = AssemblerFlags + " --64" else: AssemblerFlags = AssemblerFlags + " --32" AssemblerFlags = (AssemblerFlags + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: CCompiler = GnuPlatformPrefix + CCompiler Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: AssemblerMk = GnuPlatformPrefix + AssemblerMk AssemblerSh = GnuPlatformPrefix + AssemblerSh # # squeeze runs of spaces and spaces at ends # CCompilerFlags = re.sub(" +", " ", CCompilerFlags) CCompilerFlags = re.sub(" +$", "", CCompilerFlags) CCompilerFlags = re.sub("^ +", "", CCompilerFlags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) AssemblerFlags = re.sub(" +", " ", AssemblerFlags) AssemblerFlags = re.sub(" +$", "", AssemblerFlags) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + CCompiler + "\n" + "CFLAGS ?= " + CCompilerFlags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerMk + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + CCompiler + "}\n" + "CFLAGS=${CFLAGS:-" + CCompilerFlags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerSh + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = AssemblerMk + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + AssemblerMk + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
if StringTagged(Target, "VMS") and AssembleOnTarget: AssemblerMk = "macro" AssemblerSh = "macro" AssemblerFlags = "/alpha " elif Target == "I386_SOLARIS" or Target == "AMD64_SOLARIS": a = (" if test -x /usr/sfw/bin/gas ; then echo /usr/sfw/bin/gas ; \\\n" + " elif test -x /opt/csw/gnu/as ; then echo /opt/csw/gnu/as ; \\\n" + " else echo \"unable to find GNU assembler\" ; fi") AssemblerMk = "$(shell " + a + ")" AssemblerSh = "`" + a + "`" elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): AssemblerMk = "/usr/ccs/bin/as" AssemblerSh = "/usr/ccs/bin/as" else: AssemblerMk = "as" AssemblerSh = "as"
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": CCompiler = "CCompiler" CCompilerFlags = " " elif Config == "ALPHA64_VMS": CCompiler = "CCompiler" CCompilerFlags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": CCompiler = "/usr/bin/CCompiler" CCompilerFlags = "-g -mt -xldscope=symbolic " else: # gcc platforms CCompiler = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" CCompilerFlags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " CCompilerFlags = CCompilerFlags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not CCompilerFlags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler AssemblerFlags = " " if StringTagged(Target, "VMS") and AssembleOnTarget: AssemblerMk = "macro" # not right, come back to it later AssemblerSh = "macro" # not right, come back to it later AssemblerFlags = "/alpha " # not right, come back to it later elif Target == "I386_SOLARIS" or Target == "AMD64_SOLARIS": # # see http://gcc.gnu.org/ml/gcc/2010-05/msg00155.html # see http://gcc.gnu.org/install/specific.html#ix86-x-solaris210 # a = (" if test -x /usr/sfw/bin/gas ; then echo /usr/sfw/bin/gas ; \\\n" + " elif test -x /opt/csw/gnu/as ; then echo /opt/csw/gnu/as ; \\\n" + " else echo \"unable to find GNU assembler\" ; fi") AssemblerMk = "$(shell " + a + ")" AssemblerSh = "`" + a + "`" elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): AssemblerMk = "/usr/ccs/bin/as" AssemblerSh = "/usr/ccs/bin/as" else: AssemblerMk = "as" AssemblerSh = "as" # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): AssemblerFlags = AssemblerFlags + " --64" else: AssemblerFlags = AssemblerFlags + " --32" AssemblerFlags = (AssemblerFlags + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: CCompiler = GnuPlatformPrefix + CCompiler Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: AssemblerMk = GnuPlatformPrefix + AssemblerMk AssemblerSh = GnuPlatformPrefix + AssemblerSh # # squeeze runs of spaces and spaces at ends # CCompilerFlags = re.sub(" +", " ", CCompilerFlags) CCompilerFlags = re.sub(" +$", "", CCompilerFlags) CCompilerFlags = re.sub("^ +", "", CCompilerFlags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) AssemblerFlags = re.sub(" +", " ", AssemblerFlags) AssemblerFlags = re.sub(" +$", "", AssemblerFlags) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + CCompiler + "\n" + "CFLAGS ?= " + CCompilerFlags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerMk + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + CCompiler + "}\n" + "CFLAGS=${CFLAGS:-" + CCompilerFlags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerSh + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = AssemblerMk + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + AssemblerMk + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
|
"I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ",
|
"I386_SOLARIS" : " -Qy -s", "AMD64_SOLARIS" : " -Qy -s -xarch=generic64 ", "SOLgnu" : " -Qy -s -K PIC -xarch=v8plus ", "SOLsun" : " -Qy -s -K PIC -xarch=v8plus ", "SPARC32_SOLARIS" : " -Qy -s -K PIC -xarch=v8plus ", "SPARC64_SOLARIS" : " -Qy -s -K PIC -xarch=v9 ",
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": CCompiler = "CCompiler" CCompilerFlags = " " elif Config == "ALPHA64_VMS": CCompiler = "CCompiler" CCompilerFlags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": CCompiler = "/usr/bin/CCompiler" CCompilerFlags = "-g -mt -xldscope=symbolic " else: # gcc platforms CCompiler = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" CCompilerFlags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " CCompilerFlags = CCompilerFlags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not CCompilerFlags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler AssemblerFlags = " " if StringTagged(Target, "VMS") and AssembleOnTarget: AssemblerMk = "macro" # not right, come back to it later AssemblerSh = "macro" # not right, come back to it later AssemblerFlags = "/alpha " # not right, come back to it later elif Target == "I386_SOLARIS" or Target == "AMD64_SOLARIS": # # see http://gcc.gnu.org/ml/gcc/2010-05/msg00155.html # see http://gcc.gnu.org/install/specific.html#ix86-x-solaris210 # a = (" if test -x /usr/sfw/bin/gas ; then echo /usr/sfw/bin/gas ; \\\n" + " elif test -x /opt/csw/gnu/as ; then echo /opt/csw/gnu/as ; \\\n" + " else echo \"unable to find GNU assembler\" ; fi") AssemblerMk = "$(shell " + a + ")" AssemblerSh = "`" + a + "`" elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): AssemblerMk = "/usr/ccs/bin/as" AssemblerSh = "/usr/ccs/bin/as" else: AssemblerMk = "as" AssemblerSh = "as" # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): AssemblerFlags = AssemblerFlags + " --64" else: AssemblerFlags = AssemblerFlags + " --32" AssemblerFlags = (AssemblerFlags + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: CCompiler = GnuPlatformPrefix + CCompiler Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: AssemblerMk = GnuPlatformPrefix + AssemblerMk AssemblerSh = GnuPlatformPrefix + AssemblerSh # # squeeze runs of spaces and spaces at ends # CCompilerFlags = re.sub(" +", " ", CCompilerFlags) CCompilerFlags = re.sub(" +$", "", CCompilerFlags) CCompilerFlags = re.sub("^ +", "", CCompilerFlags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) AssemblerFlags = re.sub(" +", " ", AssemblerFlags) AssemblerFlags = re.sub(" +$", "", AssemblerFlags) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + CCompiler + "\n" + "CFLAGS ?= " + CCompilerFlags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerMk + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + CCompiler + "}\n" + "CFLAGS=${CFLAGS:-" + CCompilerFlags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerSh + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = AssemblerMk + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + AssemblerMk + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
AssemblerMk = GnuPlatformPrefix + AssemblerMk AssemblerSh = GnuPlatformPrefix + AssemblerSh
|
Assembler = GnuPlatformPrefix + Assembler
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": CCompiler = "CCompiler" CCompilerFlags = " " elif Config == "ALPHA64_VMS": CCompiler = "CCompiler" CCompilerFlags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": CCompiler = "/usr/bin/CCompiler" CCompilerFlags = "-g -mt -xldscope=symbolic " else: # gcc platforms CCompiler = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" CCompilerFlags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " CCompilerFlags = CCompilerFlags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not CCompilerFlags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler AssemblerFlags = " " if StringTagged(Target, "VMS") and AssembleOnTarget: AssemblerMk = "macro" # not right, come back to it later AssemblerSh = "macro" # not right, come back to it later AssemblerFlags = "/alpha " # not right, come back to it later elif Target == "I386_SOLARIS" or Target == "AMD64_SOLARIS": # # see http://gcc.gnu.org/ml/gcc/2010-05/msg00155.html # see http://gcc.gnu.org/install/specific.html#ix86-x-solaris210 # a = (" if test -x /usr/sfw/bin/gas ; then echo /usr/sfw/bin/gas ; \\\n" + " elif test -x /opt/csw/gnu/as ; then echo /opt/csw/gnu/as ; \\\n" + " else echo \"unable to find GNU assembler\" ; fi") AssemblerMk = "$(shell " + a + ")" AssemblerSh = "`" + a + "`" elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): AssemblerMk = "/usr/ccs/bin/as" AssemblerSh = "/usr/ccs/bin/as" else: AssemblerMk = "as" AssemblerSh = "as" # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): AssemblerFlags = AssemblerFlags + " --64" else: AssemblerFlags = AssemblerFlags + " --32" AssemblerFlags = (AssemblerFlags + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: CCompiler = GnuPlatformPrefix + CCompiler Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: AssemblerMk = GnuPlatformPrefix + AssemblerMk AssemblerSh = GnuPlatformPrefix + AssemblerSh # # squeeze runs of spaces and spaces at ends # CCompilerFlags = re.sub(" +", " ", CCompilerFlags) CCompilerFlags = re.sub(" +$", "", CCompilerFlags) CCompilerFlags = re.sub("^ +", "", CCompilerFlags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) AssemblerFlags = re.sub(" +", " ", AssemblerFlags) AssemblerFlags = re.sub(" +$", "", AssemblerFlags) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + CCompiler + "\n" + "CFLAGS ?= " + CCompilerFlags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerMk + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + CCompiler + "}\n" + "CFLAGS=${CFLAGS:-" + CCompilerFlags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerSh + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = AssemblerMk + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + AssemblerMk + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
+ "Assemble=" + AssemblerMk + " " + AssemblerFlags + "\n"
|
+ "Assemble=" + Assembler + " " + AssemblerFlags + "\n"
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": CCompiler = "CCompiler" CCompilerFlags = " " elif Config == "ALPHA64_VMS": CCompiler = "CCompiler" CCompilerFlags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": CCompiler = "/usr/bin/CCompiler" CCompilerFlags = "-g -mt -xldscope=symbolic " else: # gcc platforms CCompiler = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" CCompilerFlags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " CCompilerFlags = CCompilerFlags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not CCompilerFlags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler AssemblerFlags = " " if StringTagged(Target, "VMS") and AssembleOnTarget: AssemblerMk = "macro" # not right, come back to it later AssemblerSh = "macro" # not right, come back to it later AssemblerFlags = "/alpha " # not right, come back to it later elif Target == "I386_SOLARIS" or Target == "AMD64_SOLARIS": # # see http://gcc.gnu.org/ml/gcc/2010-05/msg00155.html # see http://gcc.gnu.org/install/specific.html#ix86-x-solaris210 # a = (" if test -x /usr/sfw/bin/gas ; then echo /usr/sfw/bin/gas ; \\\n" + " elif test -x /opt/csw/gnu/as ; then echo /opt/csw/gnu/as ; \\\n" + " else echo \"unable to find GNU assembler\" ; fi") AssemblerMk = "$(shell " + a + ")" AssemblerSh = "`" + a + "`" elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): AssemblerMk = "/usr/ccs/bin/as" AssemblerSh = "/usr/ccs/bin/as" else: AssemblerMk = "as" AssemblerSh = "as" # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): AssemblerFlags = AssemblerFlags + " --64" else: AssemblerFlags = AssemblerFlags + " --32" AssemblerFlags = (AssemblerFlags + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: CCompiler = GnuPlatformPrefix + CCompiler Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: AssemblerMk = GnuPlatformPrefix + AssemblerMk AssemblerSh = GnuPlatformPrefix + AssemblerSh # # squeeze runs of spaces and spaces at ends # CCompilerFlags = re.sub(" +", " ", CCompilerFlags) CCompilerFlags = re.sub(" +$", "", CCompilerFlags) CCompilerFlags = re.sub("^ +", "", CCompilerFlags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) AssemblerFlags = re.sub(" +", " ", AssemblerFlags) AssemblerFlags = re.sub(" +$", "", AssemblerFlags) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + CCompiler + "\n" + "CFLAGS ?= " + CCompilerFlags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerMk + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + CCompiler + "}\n" + "CFLAGS=${CFLAGS:-" + CCompilerFlags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerSh + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = AssemblerMk + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + AssemblerMk + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
+ "Assemble=" + AssemblerSh + " " + AssemblerFlags + "\n"
|
+ "Assemble=" + Assembler + " " + AssemblerFlags + "\n"
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": CCompiler = "CCompiler" CCompilerFlags = " " elif Config == "ALPHA64_VMS": CCompiler = "CCompiler" CCompilerFlags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": CCompiler = "/usr/bin/CCompiler" CCompilerFlags = "-g -mt -xldscope=symbolic " else: # gcc platforms CCompiler = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" CCompilerFlags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " CCompilerFlags = CCompilerFlags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not CCompilerFlags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler AssemblerFlags = " " if StringTagged(Target, "VMS") and AssembleOnTarget: AssemblerMk = "macro" # not right, come back to it later AssemblerSh = "macro" # not right, come back to it later AssemblerFlags = "/alpha " # not right, come back to it later elif Target == "I386_SOLARIS" or Target == "AMD64_SOLARIS": # # see http://gcc.gnu.org/ml/gcc/2010-05/msg00155.html # see http://gcc.gnu.org/install/specific.html#ix86-x-solaris210 # a = (" if test -x /usr/sfw/bin/gas ; then echo /usr/sfw/bin/gas ; \\\n" + " elif test -x /opt/csw/gnu/as ; then echo /opt/csw/gnu/as ; \\\n" + " else echo \"unable to find GNU assembler\" ; fi") AssemblerMk = "$(shell " + a + ")" AssemblerSh = "`" + a + "`" elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): AssemblerMk = "/usr/ccs/bin/as" AssemblerSh = "/usr/ccs/bin/as" else: AssemblerMk = "as" AssemblerSh = "as" # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): AssemblerFlags = AssemblerFlags + " --64" else: AssemblerFlags = AssemblerFlags + " --32" AssemblerFlags = (AssemblerFlags + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: CCompiler = GnuPlatformPrefix + CCompiler Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: AssemblerMk = GnuPlatformPrefix + AssemblerMk AssemblerSh = GnuPlatformPrefix + AssemblerSh # # squeeze runs of spaces and spaces at ends # CCompilerFlags = re.sub(" +", " ", CCompilerFlags) CCompilerFlags = re.sub(" +$", "", CCompilerFlags) CCompilerFlags = re.sub("^ +", "", CCompilerFlags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) AssemblerFlags = re.sub(" +", " ", AssemblerFlags) AssemblerFlags = re.sub(" +$", "", AssemblerFlags) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + CCompiler + "\n" + "CFLAGS ?= " + CCompilerFlags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerMk + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + CCompiler + "}\n" + "CFLAGS=${CFLAGS:-" + CCompilerFlags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerSh + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = AssemblerMk + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + AssemblerMk + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
a = AssemblerMk + " " + fullpath + " -o " + BootDir + "/" + Object
|
a = Assembler + " " + fullpath + " -o " + BootDir + "/" + Object
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": CCompiler = "CCompiler" CCompilerFlags = " " elif Config == "ALPHA64_VMS": CCompiler = "CCompiler" CCompilerFlags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": CCompiler = "/usr/bin/CCompiler" CCompilerFlags = "-g -mt -xldscope=symbolic " else: # gcc platforms CCompiler = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" CCompilerFlags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " CCompilerFlags = CCompilerFlags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not CCompilerFlags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler AssemblerFlags = " " if StringTagged(Target, "VMS") and AssembleOnTarget: AssemblerMk = "macro" # not right, come back to it later AssemblerSh = "macro" # not right, come back to it later AssemblerFlags = "/alpha " # not right, come back to it later elif Target == "I386_SOLARIS" or Target == "AMD64_SOLARIS": # # see http://gcc.gnu.org/ml/gcc/2010-05/msg00155.html # see http://gcc.gnu.org/install/specific.html#ix86-x-solaris210 # a = (" if test -x /usr/sfw/bin/gas ; then echo /usr/sfw/bin/gas ; \\\n" + " elif test -x /opt/csw/gnu/as ; then echo /opt/csw/gnu/as ; \\\n" + " else echo \"unable to find GNU assembler\" ; fi") AssemblerMk = "$(shell " + a + ")" AssemblerSh = "`" + a + "`" elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): AssemblerMk = "/usr/ccs/bin/as" AssemblerSh = "/usr/ccs/bin/as" else: AssemblerMk = "as" AssemblerSh = "as" # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): AssemblerFlags = AssemblerFlags + " --64" else: AssemblerFlags = AssemblerFlags + " --32" AssemblerFlags = (AssemblerFlags + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: CCompiler = GnuPlatformPrefix + CCompiler Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: AssemblerMk = GnuPlatformPrefix + AssemblerMk AssemblerSh = GnuPlatformPrefix + AssemblerSh # # squeeze runs of spaces and spaces at ends # CCompilerFlags = re.sub(" +", " ", CCompilerFlags) CCompilerFlags = re.sub(" +$", "", CCompilerFlags) CCompilerFlags = re.sub("^ +", "", CCompilerFlags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) AssemblerFlags = re.sub(" +", " ", AssemblerFlags) AssemblerFlags = re.sub(" +$", "", AssemblerFlags) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + CCompiler + "\n" + "CFLAGS ?= " + CCompilerFlags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerMk + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + CCompiler + "}\n" + "CFLAGS=${CFLAGS:-" + CCompilerFlags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerSh + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = AssemblerMk + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + AssemblerMk + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
VmsMake.write("$ " + AssemblerMk + " " + a + "\n")
|
VmsMake.write("$ " + Assembler + " " + a + "\n")
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": CCompiler = "CCompiler" CCompilerFlags = " " elif Config == "ALPHA64_VMS": CCompiler = "CCompiler" CCompilerFlags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": CCompiler = "/usr/bin/CCompiler" CCompilerFlags = "-g -mt -xldscope=symbolic " else: # gcc platforms CCompiler = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" CCompilerFlags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " CCompilerFlags = CCompilerFlags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not CCompilerFlags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler AssemblerFlags = " " if StringTagged(Target, "VMS") and AssembleOnTarget: AssemblerMk = "macro" # not right, come back to it later AssemblerSh = "macro" # not right, come back to it later AssemblerFlags = "/alpha " # not right, come back to it later elif Target == "I386_SOLARIS" or Target == "AMD64_SOLARIS": # # see http://gcc.gnu.org/ml/gcc/2010-05/msg00155.html # see http://gcc.gnu.org/install/specific.html#ix86-x-solaris210 # a = (" if test -x /usr/sfw/bin/gas ; then echo /usr/sfw/bin/gas ; \\\n" + " elif test -x /opt/csw/gnu/as ; then echo /opt/csw/gnu/as ; \\\n" + " else echo \"unable to find GNU assembler\" ; fi") AssemblerMk = "$(shell " + a + ")" AssemblerSh = "`" + a + "`" elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): AssemblerMk = "/usr/ccs/bin/as" AssemblerSh = "/usr/ccs/bin/as" else: AssemblerMk = "as" AssemblerSh = "as" # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): AssemblerFlags = AssemblerFlags + " --64" else: AssemblerFlags = AssemblerFlags + " --32" AssemblerFlags = (AssemblerFlags + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: CCompiler = GnuPlatformPrefix + CCompiler Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: AssemblerMk = GnuPlatformPrefix + AssemblerMk AssemblerSh = GnuPlatformPrefix + AssemblerSh # # squeeze runs of spaces and spaces at ends # CCompilerFlags = re.sub(" +", " ", CCompilerFlags) CCompilerFlags = re.sub(" +$", "", CCompilerFlags) CCompilerFlags = re.sub("^ +", "", CCompilerFlags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) AssemblerFlags = re.sub(" +", " ", AssemblerFlags) AssemblerFlags = re.sub(" +$", "", AssemblerFlags) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + CCompiler + "\n" + "CFLAGS ?= " + CCompilerFlags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerMk + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + CCompiler + "}\n" + "CFLAGS=${CFLAGS:-" + CCompilerFlags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + AssemblerSh + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = AssemblerMk + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + AssemblerMk + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
cc = "/usr/ccs/bin/cc"
|
cc = "/usr/bin/cc"
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/ccs/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # not in Link Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = [ ] Makefile.write(".SUFFIXES:\nall: cm3\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\nset -e\nset -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n") a.write("CC ?= " + cc + "\n") a.write("CFLAGS ?= " + cflags + "\n") a.write("Compile=" + Compile + "\n") a.write("Assemble=" + Assemble + "\n") a.write("Link=" + Link + "\n") a.write("\n\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n") a.write("CC=${CC:-" + cc + "}\n") a.write("CFLAGS=${CFLAGS:-" + cflags + "}\n") a.write("Compile=" + Compile + "\n") a.write("Assemble=" + Assemble + "\n") a.write("Link=" + Link + "\n") a.write("\n\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) Objects += [Object] if vms: if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") continue Makefile.write("Objects += " + Object + "\n" + Object + ": " + a + "\n\t") if ext_c: Command = "Compile" else: Command = "Assemble" for b in [Make, Makefile]: b.write("$(" + Command + ") " + a + " -o " + Object + "\n") Makefile.write("cm3: $(Objects)\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
b = re.sub("-+$", "", b)
|
b = re.sub("-.+$", "", b)
|
def FormInstallRoot(PackageSetName): AltConfig = {"NT386":"x86"}.get(Config, Config) a = os.path.join(GetStage(), "cm3-" + PackageSetName + "-" + AltConfig + "-" + CM3VERSION) if Config == "NT386" or Config == "I386_NT": a = a + "-VC" + GetVisualCPlusPlusVersion() else: b = os.popen("uname -sr").read() b = re.sub("Linux 2.4\..+$", "Linux2.4", b) b = re.sub("Linux 2.6\..+$", "", b) b = re.sub("-+$", "", b) b = re.sub("SunOS", "Solaris", b) b = re.sub(" ", "", b) a = a + "-" + b a = a + "-" + time.strftime("%Y%m%d") return a
|
def _MakeArchive(a): DeleteFile(a + ".tar.gz") DeleteFile(a + ".tgz") b = "tar cfz " + a + ".tgz " + a
|
def _MakeTGZ(a): out = a + ".tgz" DeleteFile(out) b = "tar cfz " + out + " " + a print(b + "\n") os.system(b) def _MakeZip(a): out = a + ".zip" DeleteFile(out) b = "zip -r " + out + " " + a
|
def _MakeArchive(a): # OpenBSD doesn't have bzip2 in base, so use gzip instead. # bzip2 is also slower DeleteFile(a + ".tar.gz") DeleteFile(a + ".tgz") b = "tar cfz " + a + ".tgz " + a print(b + "\n") os.system(b)
|
AssembleOnHost = False CopyAssemblyToTarget = True if StringTagged(Target, "VMS"):
|
AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget if StringTagged(Target, "VMS") and AssembleOnTarget:
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") if Config == "ALPHA32_VMS": Compile = "cc " elif Config == "ALPHA64_VMS": Compile = "cc /pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": Compile = "/usr/ccs/bin/cc -g -mt -xcode=pic32 -xldscope=symbolic " else: Compile = { "I386_INTERIX" : "gcc -g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "/usr/sfw/bin/gcc -g ", # -fPIC? }.get(Config) or "gcc -g -fPIC " Compile = Compile + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "SOLsun" : " -xarch=v8plus ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = Compile + " *.mo *.io *.o " if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # not in Link if not StringTagged(Config, "VMS"): Compile += " -c " AssembleOnHost = False CopyAssemblyToTarget = True if StringTagged(Target, "VMS"): Assemble = "macro /alpha " elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32_")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: Compile = GnuPlatformPrefix + Compile Link = GnuPlatformPrefix + Link Assemble = GnuPlatformPrefix + Assemble if vms and AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at end # Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = [ ] Makefile.write(".SUFFIXES:\nall: cm3\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\nset -e\nset -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n") a.write("Assemble=" + Assemble + "\nCompile=" + Compile + "\nLink=" + Link + "\n") a.write("\n\n# no more editing should be needed\n\n") for a in [Make]: a.write("Assemble=\"" + Assemble + "\"\nCompile=\"" + Compile + "\"\nLink=\"" + Link + "\"\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".mi") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or CopyAssemblyToTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) Objects += [Object] if vms: if ext_c: VmsMake.write(Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write(Assemble + " " + a + "\n") continue Makefile.write("Objects=$(Objects) " + Object + "\n" + Object + ": " + a + "\n\t") if ext_c: Command = "Compile" else: Command = "Assemble" for b in [Make, Makefile]: b.write("$(" + Command + ") " + a + " -o " + Object + "\n") Makefile.write("cm3: $(Objects)\n\t") VmsMake.write("link /executable=cm3.exe ") for a in Objects: VmsMake.write(a + " ") VmsMake.write("\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() _MakeArchive(BootDir[2:])
|
if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32_")):
|
if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")):
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") if Config == "ALPHA32_VMS": Compile = "cc " elif Config == "ALPHA64_VMS": Compile = "cc /pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": Compile = "/usr/ccs/bin/cc -g -mt -xcode=pic32 -xldscope=symbolic " else: Compile = { "I386_INTERIX" : "gcc -g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "/usr/sfw/bin/gcc -g ", # -fPIC? }.get(Config) or "gcc -g -fPIC " Compile = Compile + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "SOLsun" : " -xarch=v8plus ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = Compile + " *.mo *.io *.o " if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # not in Link if not StringTagged(Config, "VMS"): Compile += " -c " AssembleOnHost = False CopyAssemblyToTarget = True if StringTagged(Target, "VMS"): Assemble = "macro /alpha " elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32_")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: Compile = GnuPlatformPrefix + Compile Link = GnuPlatformPrefix + Link Assemble = GnuPlatformPrefix + Assemble if vms and AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at end # Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = [ ] Makefile.write(".SUFFIXES:\nall: cm3\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\nset -e\nset -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n") a.write("Assemble=" + Assemble + "\nCompile=" + Compile + "\nLink=" + Link + "\n") a.write("\n\n# no more editing should be needed\n\n") for a in [Make]: a.write("Assemble=\"" + Assemble + "\"\nCompile=\"" + Compile + "\"\nLink=\"" + Link + "\"\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".mi") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or CopyAssemblyToTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) Objects += [Object] if vms: if ext_c: VmsMake.write(Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write(Assemble + " " + a + "\n") continue Makefile.write("Objects=$(Objects) " + Object + "\n" + Object + ": " + a + "\n\t") if ext_c: Command = "Compile" else: Command = "Assemble" for b in [Make, Makefile]: b.write("$(" + Command + ") " + a + " -o " + Object + "\n") Makefile.write("cm3: $(Objects)\n\t") VmsMake.write("link /executable=cm3.exe ") for a in Objects: VmsMake.write(a + " ") VmsMake.write("\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() _MakeArchive(BootDir[2:])
|
Assemble = GnuPlatformPrefix + Assemble if vms and AssembleOnHost:
|
if (not vms) or AssembleOnHost:
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") if Config == "ALPHA32_VMS": Compile = "cc " elif Config == "ALPHA64_VMS": Compile = "cc /pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": Compile = "/usr/ccs/bin/cc -g -mt -xcode=pic32 -xldscope=symbolic " else: Compile = { "I386_INTERIX" : "gcc -g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "/usr/sfw/bin/gcc -g ", # -fPIC? }.get(Config) or "gcc -g -fPIC " Compile = Compile + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "SOLsun" : " -xarch=v8plus ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = Compile + " *.mo *.io *.o " if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # not in Link if not StringTagged(Config, "VMS"): Compile += " -c " AssembleOnHost = False CopyAssemblyToTarget = True if StringTagged(Target, "VMS"): Assemble = "macro /alpha " elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32_")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: Compile = GnuPlatformPrefix + Compile Link = GnuPlatformPrefix + Link Assemble = GnuPlatformPrefix + Assemble if vms and AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at end # Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = [ ] Makefile.write(".SUFFIXES:\nall: cm3\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\nset -e\nset -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n") a.write("Assemble=" + Assemble + "\nCompile=" + Compile + "\nLink=" + Link + "\n") a.write("\n\n# no more editing should be needed\n\n") for a in [Make]: a.write("Assemble=\"" + Assemble + "\"\nCompile=\"" + Compile + "\"\nLink=\"" + Link + "\"\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".mi") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or CopyAssemblyToTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) Objects += [Object] if vms: if ext_c: VmsMake.write(Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write(Assemble + " " + a + "\n") continue Makefile.write("Objects=$(Objects) " + Object + "\n" + Object + ": " + a + "\n\t") if ext_c: Command = "Compile" else: Command = "Assemble" for b in [Make, Makefile]: b.write("$(" + Command + ") " + a + " -o " + Object + "\n") Makefile.write("cm3: $(Objects)\n\t") VmsMake.write("link /executable=cm3.exe ") for a in Objects: VmsMake.write(a + " ") VmsMake.write("\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() _MakeArchive(BootDir[2:])
|
ext_is = a.endswith(".mi")
|
ext_is = a.endswith(".is")
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") if Config == "ALPHA32_VMS": Compile = "cc " elif Config == "ALPHA64_VMS": Compile = "cc /pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": Compile = "/usr/ccs/bin/cc -g -mt -xcode=pic32 -xldscope=symbolic " else: Compile = { "I386_INTERIX" : "gcc -g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "/usr/sfw/bin/gcc -g ", # -fPIC? }.get(Config) or "gcc -g -fPIC " Compile = Compile + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "SOLsun" : " -xarch=v8plus ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = Compile + " *.mo *.io *.o " if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # not in Link if not StringTagged(Config, "VMS"): Compile += " -c " AssembleOnHost = False CopyAssemblyToTarget = True if StringTagged(Target, "VMS"): Assemble = "macro /alpha " elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32_")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: Compile = GnuPlatformPrefix + Compile Link = GnuPlatformPrefix + Link Assemble = GnuPlatformPrefix + Assemble if vms and AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at end # Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = [ ] Makefile.write(".SUFFIXES:\nall: cm3\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\nset -e\nset -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n") a.write("Assemble=" + Assemble + "\nCompile=" + Compile + "\nLink=" + Link + "\n") a.write("\n\n# no more editing should be needed\n\n") for a in [Make]: a.write("Assemble=\"" + Assemble + "\"\nCompile=\"" + Compile + "\"\nLink=\"" + Link + "\"\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".mi") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or CopyAssemblyToTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) Objects += [Object] if vms: if ext_c: VmsMake.write(Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write(Assemble + " " + a + "\n") continue Makefile.write("Objects=$(Objects) " + Object + "\n" + Object + ": " + a + "\n\t") if ext_c: Command = "Compile" else: Command = "Assemble" for b in [Make, Makefile]: b.write("$(" + Command + ") " + a + " -o " + Object + "\n") Makefile.write("cm3: $(Objects)\n\t") VmsMake.write("link /executable=cm3.exe ") for a in Objects: VmsMake.write(a + " ") VmsMake.write("\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() _MakeArchive(BootDir[2:])
|
if ext_h or ext_c or not vms or CopyAssemblyToTarget:
|
if ext_h or ext_c or not vms or AssembleOnTarget:
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") if Config == "ALPHA32_VMS": Compile = "cc " elif Config == "ALPHA64_VMS": Compile = "cc /pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": Compile = "/usr/ccs/bin/cc -g -mt -xcode=pic32 -xldscope=symbolic " else: Compile = { "I386_INTERIX" : "gcc -g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "/usr/sfw/bin/gcc -g ", # -fPIC? }.get(Config) or "gcc -g -fPIC " Compile = Compile + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "SOLsun" : " -xarch=v8plus ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = Compile + " *.mo *.io *.o " if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # not in Link if not StringTagged(Config, "VMS"): Compile += " -c " AssembleOnHost = False CopyAssemblyToTarget = True if StringTagged(Target, "VMS"): Assemble = "macro /alpha " elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32_")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: Compile = GnuPlatformPrefix + Compile Link = GnuPlatformPrefix + Link Assemble = GnuPlatformPrefix + Assemble if vms and AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at end # Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = [ ] Makefile.write(".SUFFIXES:\nall: cm3\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\nset -e\nset -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n") a.write("Assemble=" + Assemble + "\nCompile=" + Compile + "\nLink=" + Link + "\n") a.write("\n\n# no more editing should be needed\n\n") for a in [Make]: a.write("Assemble=\"" + Assemble + "\"\nCompile=\"" + Compile + "\"\nLink=\"" + Link + "\"\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".mi") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or CopyAssemblyToTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) Objects += [Object] if vms: if ext_c: VmsMake.write(Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write(Assemble + " " + a + "\n") continue Makefile.write("Objects=$(Objects) " + Object + "\n" + Object + ": " + a + "\n\t") if ext_c: Command = "Compile" else: Command = "Assemble" for b in [Make, Makefile]: b.write("$(" + Command + ") " + a + " -o " + Object + "\n") Makefile.write("cm3: $(Objects)\n\t") VmsMake.write("link /executable=cm3.exe ") for a in Objects: VmsMake.write(a + " ") VmsMake.write("\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() _MakeArchive(BootDir[2:])
|
VmsMake.write(Compile + " " + a + "\n")
|
VmsMake.write("$ " + Compile + " " + a + "\n")
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") if Config == "ALPHA32_VMS": Compile = "cc " elif Config == "ALPHA64_VMS": Compile = "cc /pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": Compile = "/usr/ccs/bin/cc -g -mt -xcode=pic32 -xldscope=symbolic " else: Compile = { "I386_INTERIX" : "gcc -g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "/usr/sfw/bin/gcc -g ", # -fPIC? }.get(Config) or "gcc -g -fPIC " Compile = Compile + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "SOLsun" : " -xarch=v8plus ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = Compile + " *.mo *.io *.o " if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # not in Link if not StringTagged(Config, "VMS"): Compile += " -c " AssembleOnHost = False CopyAssemblyToTarget = True if StringTagged(Target, "VMS"): Assemble = "macro /alpha " elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32_")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: Compile = GnuPlatformPrefix + Compile Link = GnuPlatformPrefix + Link Assemble = GnuPlatformPrefix + Assemble if vms and AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at end # Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = [ ] Makefile.write(".SUFFIXES:\nall: cm3\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\nset -e\nset -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n") a.write("Assemble=" + Assemble + "\nCompile=" + Compile + "\nLink=" + Link + "\n") a.write("\n\n# no more editing should be needed\n\n") for a in [Make]: a.write("Assemble=\"" + Assemble + "\"\nCompile=\"" + Compile + "\"\nLink=\"" + Link + "\"\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".mi") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or CopyAssemblyToTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) Objects += [Object] if vms: if ext_c: VmsMake.write(Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write(Assemble + " " + a + "\n") continue Makefile.write("Objects=$(Objects) " + Object + "\n" + Object + ": " + a + "\n\t") if ext_c: Command = "Compile" else: Command = "Assemble" for b in [Make, Makefile]: b.write("$(" + Command + ") " + a + " -o " + Object + "\n") Makefile.write("cm3: $(Objects)\n\t") VmsMake.write("link /executable=cm3.exe ") for a in Objects: VmsMake.write(a + " ") VmsMake.write("\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() _MakeArchive(BootDir[2:])
|
VmsMake.write(Assemble + " " + a + "\n")
|
VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n")
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") if Config == "ALPHA32_VMS": Compile = "cc " elif Config == "ALPHA64_VMS": Compile = "cc /pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": Compile = "/usr/ccs/bin/cc -g -mt -xcode=pic32 -xldscope=symbolic " else: Compile = { "I386_INTERIX" : "gcc -g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "/usr/sfw/bin/gcc -g ", # -fPIC? }.get(Config) or "gcc -g -fPIC " Compile = Compile + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "SOLsun" : " -xarch=v8plus ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = Compile + " *.mo *.io *.o " if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # not in Link if not StringTagged(Config, "VMS"): Compile += " -c " AssembleOnHost = False CopyAssemblyToTarget = True if StringTagged(Target, "VMS"): Assemble = "macro /alpha " elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32_")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: Compile = GnuPlatformPrefix + Compile Link = GnuPlatformPrefix + Link Assemble = GnuPlatformPrefix + Assemble if vms and AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at end # Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = [ ] Makefile.write(".SUFFIXES:\nall: cm3\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\nset -e\nset -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n") a.write("Assemble=" + Assemble + "\nCompile=" + Compile + "\nLink=" + Link + "\n") a.write("\n\n# no more editing should be needed\n\n") for a in [Make]: a.write("Assemble=\"" + Assemble + "\"\nCompile=\"" + Compile + "\"\nLink=\"" + Link + "\"\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".mi") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or CopyAssemblyToTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) Objects += [Object] if vms: if ext_c: VmsMake.write(Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write(Assemble + " " + a + "\n") continue Makefile.write("Objects=$(Objects) " + Object + "\n" + Object + ": " + a + "\n\t") if ext_c: Command = "Compile" else: Command = "Assemble" for b in [Make, Makefile]: b.write("$(" + Command + ") " + a + " -o " + Object + "\n") Makefile.write("cm3: $(Objects)\n\t") VmsMake.write("link /executable=cm3.exe ") for a in Objects: VmsMake.write(a + " ") VmsMake.write("\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() _MakeArchive(BootDir[2:])
|
VmsMake.write("link /executable=cm3.exe ") for a in Objects: VmsMake.write(a + " ") VmsMake.write("\n")
|
VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n")
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") if Config == "ALPHA32_VMS": Compile = "cc " elif Config == "ALPHA64_VMS": Compile = "cc /pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": Compile = "/usr/ccs/bin/cc -g -mt -xcode=pic32 -xldscope=symbolic " else: Compile = { "I386_INTERIX" : "gcc -g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "/usr/sfw/bin/gcc -g ", # -fPIC? }.get(Config) or "gcc -g -fPIC " Compile = Compile + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "SOLsun" : " -xarch=v8plus ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = Compile + " *.mo *.io *.o " if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # not in Link if not StringTagged(Config, "VMS"): Compile += " -c " AssembleOnHost = False CopyAssemblyToTarget = True if StringTagged(Target, "VMS"): Assemble = "macro /alpha " elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32_")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: Compile = GnuPlatformPrefix + Compile Link = GnuPlatformPrefix + Link Assemble = GnuPlatformPrefix + Assemble if vms and AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at end # Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = [ ] Makefile.write(".SUFFIXES:\nall: cm3\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\nset -e\nset -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n") a.write("Assemble=" + Assemble + "\nCompile=" + Compile + "\nLink=" + Link + "\n") a.write("\n\n# no more editing should be needed\n\n") for a in [Make]: a.write("Assemble=\"" + Assemble + "\"\nCompile=\"" + Compile + "\"\nLink=\"" + Link + "\"\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".mi") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or CopyAssemblyToTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) Objects += [Object] if vms: if ext_c: VmsMake.write(Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write(Assemble + " " + a + "\n") continue Makefile.write("Objects=$(Objects) " + Object + "\n" + Object + ": " + a + "\n\t") if ext_c: Command = "Compile" else: Command = "Assemble" for b in [Make, Makefile]: b.write("$(" + Command + ") " + a + " -o " + Object + "\n") Makefile.write("cm3: $(Objects)\n\t") VmsMake.write("link /executable=cm3.exe ") for a in Objects: VmsMake.write(a + " ") VmsMake.write("\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() _MakeArchive(BootDir[2:])
|
for a in [UpdateSource, Make, Makefile, VmsMake]:
|
for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]:
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") if Config == "ALPHA32_VMS": Compile = "cc " elif Config == "ALPHA64_VMS": Compile = "cc /pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": Compile = "/usr/ccs/bin/cc -g -mt -xcode=pic32 -xldscope=symbolic " else: Compile = { "I386_INTERIX" : "gcc -g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "/usr/sfw/bin/gcc -g ", # -fPIC? }.get(Config) or "gcc -g -fPIC " Compile = Compile + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "SOLsun" : " -xarch=v8plus ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = Compile + " *.mo *.io *.o " if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # not in Link if not StringTagged(Config, "VMS"): Compile += " -c " AssembleOnHost = False CopyAssemblyToTarget = True if StringTagged(Target, "VMS"): Assemble = "macro /alpha " elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32_")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: Compile = GnuPlatformPrefix + Compile Link = GnuPlatformPrefix + Link Assemble = GnuPlatformPrefix + Assemble if vms and AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at end # Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = [ ] Makefile.write(".SUFFIXES:\nall: cm3\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\nset -e\nset -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n") a.write("Assemble=" + Assemble + "\nCompile=" + Compile + "\nLink=" + Link + "\n") a.write("\n\n# no more editing should be needed\n\n") for a in [Make]: a.write("Assemble=\"" + Assemble + "\"\nCompile=\"" + Compile + "\"\nLink=\"" + Link + "\"\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".mi") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or CopyAssemblyToTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) Objects += [Object] if vms: if ext_c: VmsMake.write(Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write(Assemble + " " + a + "\n") continue Makefile.write("Objects=$(Objects) " + Object + "\n" + Object + ": " + a + "\n\t") if ext_c: Command = "Compile" else: Command = "Assemble" for b in [Make, Makefile]: b.write("$(" + Command + ") " + a + " -o " + Object + "\n") Makefile.write("cm3: $(Objects)\n\t") VmsMake.write("link /executable=cm3.exe ") for a in Objects: VmsMake.write(a + " ") VmsMake.write("\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() _MakeArchive(BootDir[2:])
|
_MakeArchive(BootDir[2:])
|
if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") if Config == "ALPHA32_VMS": Compile = "cc " elif Config == "ALPHA64_VMS": Compile = "cc /pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": Compile = "/usr/ccs/bin/cc -g -mt -xcode=pic32 -xldscope=symbolic " else: Compile = { "I386_INTERIX" : "gcc -g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "/usr/sfw/bin/gcc -g ", # -fPIC? }.get(Config) or "gcc -g -fPIC " Compile = Compile + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "SOLsun" : " -xarch=v8plus ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = Compile + " *.mo *.io *.o " if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # not in Link if not StringTagged(Config, "VMS"): Compile += " -c " AssembleOnHost = False CopyAssemblyToTarget = True if StringTagged(Target, "VMS"): Assemble = "macro /alpha " elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32_")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: Compile = GnuPlatformPrefix + Compile Link = GnuPlatformPrefix + Link Assemble = GnuPlatformPrefix + Assemble if vms and AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at end # Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = [ ] Makefile.write(".SUFFIXES:\nall: cm3\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\nset -e\nset -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n") a.write("Assemble=" + Assemble + "\nCompile=" + Compile + "\nLink=" + Link + "\n") a.write("\n\n# no more editing should be needed\n\n") for a in [Make]: a.write("Assemble=\"" + Assemble + "\"\nCompile=\"" + Compile + "\"\nLink=\"" + Link + "\"\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".mi") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or CopyAssemblyToTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) Objects += [Object] if vms: if ext_c: VmsMake.write(Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write(Assemble + " " + a + "\n") continue Makefile.write("Objects=$(Objects) " + Object + "\n" + Object + ": " + a + "\n\t") if ext_c: Command = "Compile" else: Command = "Assemble" for b in [Make, Makefile]: b.write("$(" + Command + ") " + a + " -o " + Object + "\n") Makefile.write("cm3: $(Objects)\n\t") VmsMake.write("link /executable=cm3.exe ") for a in Objects: VmsMake.write(a + " ") VmsMake.write("\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() _MakeArchive(BootDir[2:])
|
if Target == "NT386GNU": Config = "I386_CYGWIN" TargetOS = "POSIX" elif Target == "NT386MINGNU": Config = "I386_MINGW"
|
if Target == "NT386MINGNU" or Target == "NT386":
|
def GetVersion(Key): # # Only read the file if an environment variable is "missing" (they # usually all are, ok), and only read it once. # #print("WriteVariablesIntoEnvironment:3") Value = Versions.get(Key) if Value: return Value # # CM3VERSION d5.7.1 # CM3VERSIONNUM 050701 # CM3LASTCHANGED 2009-01-21 # RegExp = re.compile("(" + "|".join(Versions.keys()) + ") (.+)$", re.IGNORECASE) ShFilePath = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "version") for Line in open(ShFilePath): Match = RegExp.match(Line) if Match: MatchKey = Match.group(1) # # We are here because one of them wasn't found, but we should be # sure only to overwrite what we don't have. # if not Versions[MatchKey]: Value = Match.group(2) Versions[MatchKey] = Value exec("%s = \"%s\"" % (MatchKey, Value), locals(), globals()) # # Make sure we found every key in the file (at least those # not defined in the environment) # MissingKey = None for Item in Versions.iteritems(): #print(Item) if Item[1] is None: MissingKey = Item[0] File = __file__ sys.stderr.write("%(File)s: %(MissingKey)s not found in %(ShFilePath)s\n" % vars()) if MissingKey: sys.exit(1) return Versions.get(Key)
|
else: Config = "I386_NT" TargetOS = "WIN32" Target = Config
|
HAVE_SERIAL = True if Target == "NT386": GCC_BACKEND = False Config = Target Target = "NT386"
|
def GetVersion(Key): # # Only read the file if an environment variable is "missing" (they # usually all are, ok), and only read it once. # #print("WriteVariablesIntoEnvironment:3") Value = Versions.get(Key) if Value: return Value # # CM3VERSION d5.7.1 # CM3VERSIONNUM 050701 # CM3LASTCHANGED 2009-01-21 # RegExp = re.compile("(" + "|".join(Versions.keys()) + ") (.+)$", re.IGNORECASE) ShFilePath = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "version") for Line in open(ShFilePath): Match = RegExp.match(Line) if Match: MatchKey = Match.group(1) # # We are here because one of them wasn't found, but we should be # sure only to overwrite what we don't have. # if not Versions[MatchKey]: Value = Match.group(2) Versions[MatchKey] = Value exec("%s = \"%s\"" % (MatchKey, Value), locals(), globals()) # # Make sure we found every key in the file (at least those # not defined in the environment) # MissingKey = None for Item in Versions.iteritems(): #print(Item) if Item[1] is None: MissingKey = Item[0] File = __file__ sys.stderr.write("%(File)s: %(MissingKey)s not found in %(ShFilePath)s\n" % vars()) if MissingKey: sys.exit(1) return Versions.get(Key)
|
GCC_BACKEND = False TargetOS = "WIN32" if Target.endswith("_MINGW"): HAVE_SERIAL = True TargetOS = "WIN32"
|
def GetVersion(Key): # # Only read the file if an environment variable is "missing" (they # usually all are, ok), and only read it once. # #print("WriteVariablesIntoEnvironment:3") Value = Versions.get(Key) if Value: return Value # # CM3VERSION d5.7.1 # CM3VERSIONNUM 050701 # CM3LASTCHANGED 2009-01-21 # RegExp = re.compile("(" + "|".join(Versions.keys()) + ") (.+)$", re.IGNORECASE) ShFilePath = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "version") for Line in open(ShFilePath): Match = RegExp.match(Line) if Match: MatchKey = Match.group(1) # # We are here because one of them wasn't found, but we should be # sure only to overwrite what we don't have. # if not Versions[MatchKey]: Value = Match.group(2) Versions[MatchKey] = Value exec("%s = \"%s\"" % (MatchKey, Value), locals(), globals()) # # Make sure we found every key in the file (at least those # not defined in the environment) # MissingKey = None for Item in Versions.iteritems(): #print(Item) if Item[1] is None: MissingKey = Item[0] File = __file__ sys.stderr.write("%(File)s: %(MissingKey)s not found in %(ShFilePath)s\n" % vars()) if MissingKey: sys.exit(1) return Versions.get(Key)
|
|
cc = "cc" cflags = " "
|
CCompiler = "CCompiler" CCompilerFlags = " "
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
cc = "cc" cflags = "/pointer_size=64 "
|
CCompiler = "CCompiler" CCompilerFlags = "/pointer_size=64 "
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic "
|
CCompiler = "/usr/bin/CCompiler" CCompilerFlags = "-g -mt -xldscope=symbolic "
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
cc = {
|
CCompiler = {
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
cflags = {
|
CCompilerFlags = {
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ",
|
CCompilerFlags = CCompilerFlags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ",
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
Assemble = "macro /alpha "
|
AssemblerMk = "macro" AssemblerSh = "macro" AssemblerFlags = "/alpha " elif Target == "I386_SOLARIS" or Target == "AMD64_SOLARIS": a = (" if test -x /usr/sfw/bin/gas ; then echo /usr/sfw/bin/gas ; \\\n" + " elif test -x /opt/csw/gnu/as ; then echo /opt/csw/gnu/as ; \\\n" + " else echo \"unable to find GNU assembler\" ; fi") AssemblerMk = "$(shell " + a + ")" AssemblerSh = "`" + a + "`"
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
Assemble = "/usr/ccs/bin/as "
|
AssemblerMk = "/usr/ccs/bin/as" AssemblerSh = "/usr/ccs/bin/as"
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
Assemble = "as "
|
AssemblerMk = "as" AssemblerSh = "as"
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
Assemble = Assemble + " --64"
|
AssemblerFlags = AssemblerFlags + " --64"
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
Assemble = Assemble + " --32" Assemble = (Assemble + ({
|
AssemblerFlags = AssemblerFlags + " --32" AssemblerFlags = (AssemblerFlags + ({
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
cc = GnuPlatformPrefix + cc
|
CCompiler = GnuPlatformPrefix + CCompiler
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
Assemble = GnuPlatformPrefix + Assemble
|
AssemblerMk = GnuPlatformPrefix + AssemblerMk AssemblerSh = GnuPlatformPrefix + AssemblerSh
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags)
|
CCompilerFlags = re.sub(" +", " ", CCompilerFlags) CCompilerFlags = re.sub(" +$", "", CCompilerFlags) CCompilerFlags = re.sub("^ +", "", CCompilerFlags)
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble)
|
AssemblerFlags = re.sub(" +", " ", AssemblerFlags) AssemblerFlags = re.sub(" +$", "", AssemblerFlags)
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
+ "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n"
|
+ "CC ?= " + CCompiler + "\n" + "CFLAGS ?= " + CCompilerFlags + "\n"
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
+ "Assemble=" + Assemble + "\n"
|
+ "Assemble=" + AssemblerMk + " " + AssemblerFlags + "\n"
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
+ "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n"
|
+ "CC=${CC:-" + CCompiler + "}\n" + "CFLAGS=${CFLAGS:-" + CCompilerFlags + "}\n"
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
+ "Assemble=" + Assemble + "\n"
|
+ "Assemble=" + AssemblerSh + " " + AssemblerFlags + "\n"
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object
|
a = AssemblerMk + " " + fullpath + " -o " + BootDir + "/" + Object
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
VmsMake.write("$ " + Assemble + " " + a + "\n")
|
VmsMake.write("$ " + AssemblerMk + " " + a + "\n")
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = "1" # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": cc = "cc" cflags = " " elif Config == "ALPHA64_VMS": cc = "cc" cflags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": cc = "/usr/bin/cc" cflags = "-g -mt -xldscope=symbolic " else: # gcc platforms cc = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" cflags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " cflags = cflags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not cflags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assemble = "macro /alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Assemble = "/usr/ccs/bin/as " else: Assemble = "as " # set assembler flags if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): Assemble = Assemble + " --64" else: Assemble = Assemble + " --32" Assemble = (Assemble + ({ "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", # -s puts symbols where linker won't automatically strip them "I386_SOLARIS" : " -s ", "AMD64_SOLARIS" : " -s -xarch=amd64 ", "SOLgnu" : " -s -xarch=v8plus ", "SOLsun" : " -s -xarch=v8plus ", "SPARC32_SOLARIS" : " -s -xarch=v8plus ", "SPARC64_SOLARIS" : " -s -xarch=v9 ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: cc = GnuPlatformPrefix + cc Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assemble = GnuPlatformPrefix + Assemble # # squeeze runs of spaces and spaces at ends # cflags = re.sub(" +", " ", cflags) cflags = re.sub(" +$", "", cflags) cflags = re.sub("^ +", "", cflags) Compile = re.sub(" +", " ", Compile) Compile = re.sub(" +$", "", Compile) Compile = re.sub("^ +", "", Compile) Link = re.sub(" +", " ", Link) Link = re.sub(" +$", "", Link) Assemble = re.sub(" +", " ", Assemble) Assemble = re.sub(" +$", "", Assemble) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC ?= " + cc + "\n" + "CFLAGS ?= " + cflags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + cc + "}\n" + "CFLAGS=${CFLAGS:-" + cflags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assemble + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assemble + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assemble + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
if (Config != "NT386" and not FileExists(from_cm3)
|
if ( not FileExists(from_cm3)
|
def _CopyCompiler(From, To): CreateDirectory(To) from_cm3 = os.path.join(From, "cm3") from_cm3exe = os.path.join(From, "cm3.exe") from_cm3cg = os.path.join(From, "cm3cg") from_cm3cgexe = os.path.join(From, "cm3cg.exe") if (Config != "NT386" and not FileExists(from_cm3) and not FileExists(from_cm3exe) and not FileExists(from_cm3cg) and not FileExists(from_cm3cgexe)): FatalError("none of " + from_cm3 + ", " + from_cm3exe + ", " + from_cm3cg + ", " + from_cm3cgexe + " exist") # # check .exe first to avoid being fooled by Cygwin # if FileExists(from_cm3exe): from_cm3 = from_cm3exe elif FileExists(from_cm3): pass else: from_cm3 = None from_cm3exe = None if from_cm3: # # delete .exe first to avoid being fooled by Cygwin # DeleteFile(os.path.join(To, "cm3.exe")) DeleteFile(os.path.join(To, "cm3")) CopyFile(from_cm3, To) or FatalError("3") CopyFileIfExist(os.path.join(From, "cm3.pdb"), To) or FatalError("5") if Config != "NT386": if FileExists(from_cm3cgexe): from_cm3cg = from_cm3cgexe elif FileExists(from_cm3cg): pass else: from_cm3cg = None from_cm3cgexe = None if from_cm3cg: # # delete .exe first to avoid being fooled by Cygwin # DeleteFile(os.path.join(To, "cm3cg.exe")) DeleteFile(os.path.join(To, "cm3cg")) CopyFile(from_cm3cg, To) or FatalError("4") return True
|
if Config != "NT386":
|
if Config != "NT386" and not Target.endswith("_NT"):
|
def _CopyCompiler(From, To): CreateDirectory(To) from_cm3 = os.path.join(From, "cm3") from_cm3exe = os.path.join(From, "cm3.exe") from_cm3cg = os.path.join(From, "cm3cg") from_cm3cgexe = os.path.join(From, "cm3cg.exe") if (Config != "NT386" and not FileExists(from_cm3) and not FileExists(from_cm3exe) and not FileExists(from_cm3cg) and not FileExists(from_cm3cgexe)): FatalError("none of " + from_cm3 + ", " + from_cm3exe + ", " + from_cm3cg + ", " + from_cm3cgexe + " exist") # # check .exe first to avoid being fooled by Cygwin # if FileExists(from_cm3exe): from_cm3 = from_cm3exe elif FileExists(from_cm3): pass else: from_cm3 = None from_cm3exe = None if from_cm3: # # delete .exe first to avoid being fooled by Cygwin # DeleteFile(os.path.join(To, "cm3.exe")) DeleteFile(os.path.join(To, "cm3")) CopyFile(from_cm3, To) or FatalError("3") CopyFileIfExist(os.path.join(From, "cm3.pdb"), To) or FatalError("5") if Config != "NT386": if FileExists(from_cm3cgexe): from_cm3cg = from_cm3cgexe elif FileExists(from_cm3cg): pass else: from_cm3cg = None from_cm3cgexe = None if from_cm3cg: # # delete .exe first to avoid being fooled by Cygwin # DeleteFile(os.path.join(To, "cm3cg.exe")) DeleteFile(os.path.join(To, "cm3cg")) CopyFile(from_cm3cg, To) or FatalError("4") return True
|
SystemDrive = os.environ.get("SystemDrive", "") if os.environ.get("OS") == "Windows_NT": HostIsNT = True else: HostIsNT = False
|
def SetupEnvironment(): SystemDrive = os.environ.get("SystemDrive", "") if os.environ.get("OS") == "Windows_NT": HostIsNT = True else: HostIsNT = False SystemDrive = os.environ.get("SYSTEMDRIVE") if SystemDrive: SystemDrive += os.path.sep # Do this earlier so that its link isn't a problem. # Looking in the registry HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2 # would be reasonable here. if CM3IsCygwin: _SetupEnvironmentVariableAll( "PATH", ["cygwin1.dll"], os.path.join(SystemDrive, "cygwin", "bin")) # some host/target confusion here.. if Target == "NT386" and HostIsNT and Config == "NT386" and (not GCC_BACKEND) and TargetOS == "WIN32": VCBin = "" VCInc = "" VCLib = "" MspdbDir = "" # 4.0 e:\MSDEV # 5.0 E:\Program Files\DevStudio\SharedIDE MSDevDir = os.environ.get("MSDEVDIR") # 5.0 MSVCDir = os.environ.get("MSVCDIR") # E:\Program Files\DevStudio\VC # 7.1 Express VCToolkitInstallDir = os.environ.get("VCTOOLKITINSTALLDIR") # E:\Program Files\Microsoft Visual C++ Toolkit 2003 (not set by vcvars32) # 8.0 Express # E:\Program Files\Microsoft Visual Studio 8\VC # E:\Program Files\Microsoft Visual Studio 8\Common7\Tools DevEnvDir = os.environ.get("DevEnvDir") # E:\Program Files\Microsoft Visual Studio 8\Common7\IDE VSInstallDir = os.environ.get("VSINSTALLDIR") # E:\Program Files\Microsoft Visual Studio 8 # VS80CommonTools = os.environ.get("VS80COMNTOOLS") # E:\Program Files\Microsoft Visual Studio 8\Common7\Tools VCInstallDir = os.environ.get("VCINSTALLDIR") # E:\Program Files\Microsoft Visual Studio 8\VC # 9.0 Express # always, global #VS90COMNTOOLS=D:\msdev\90\Common7\Tools\ # after running the shortcut #VCINSTALLDIR=D:\msdev\90\VC #VSINSTALLDIR=D:\msdev\90 VSCommonTools = os.environ.get("VS90COMNTOOLS") if VSCommonTools and not VSInstallDir: VSInstallDir = RemoveLastPathElement(RemoveLastPathElement(VSCommonTools)) # The Windows SDK is carried with the express edition and tricky to find. # Best if folks just run the installed shortcut probably. # We do a pretty good job now of finding it, be need to encode # more paths to known versions. # This is not yet finished. # # Probe the partly version-specific less-polluting environment variables, # from newest to oldest. # That is, having setup alter PATH, INCLUDE, and LIB system-wide is not # a great idea, but having setup set DevEnvDir, VSINSTALLDIR, VS80COMNTOOLS, etc. # isn't so bad and we can temporarily establish the first set from the second # set. if VSInstallDir: # Visual C++ 2005/8.0, at least the Express Edition, free download # also Visual C++ 2008/9.0 Express Edition if not VCInstallDir: VCInstallDir = os.path.join(VSInstallDir, "VC") #print("VCInstallDir:" + VCInstallDir) if not DevEnvDir: DevEnvDir = os.path.join(VSInstallDir, "Common7", "IDE") #print("DevEnvDir:" + DevEnvDir) MspdbDir = DevEnvDir elif VCToolkitInstallDir: # free download Visual C++ 2003; no longer available VCInstallDir = VCToolkitInstallDir elif MSVCDir and MSDevDir: # Visual C++ 5.0 pass # do more research # VCInstallDir = MSVCDir elif MSDevDir: # Visual C++ 4.0, 5.0 pass # do more research # VCInstallDir = MSDevDir else: # This is what really happens on my machine, for 8.0. # It might be good to guide pylib.py to other versions, # however setting things up manually suffices and I have, um, # well automated. Msdev = os.path.join(SystemDrive, "msdev", "80") VCInstallDir = os.path.join(Msdev, "VC") DevEnvDir = os.path.join(Msdev, "Common7", "IDE") if VCInstallDir: VCBin = os.path.join(VCInstallDir, "bin") VCLib = os.path.join(VCInstallDir, "lib") VCInc = os.path.join(VCInstallDir, "include") if DevEnvDir: MspdbDir = DevEnvDir #elif VCBin: # MspdbDir = VCBin # Look for SDKs. # expand this as they are released/discovered # ordering is from newest to oldest PossibleSDKs = [os.path.join("Microsoft SDKs", "Windows", "v6.0A"), "Microsoft Platform SDK for Windows Server 2003 R2"] SDKs = [] for a in GetProgramFiles(): #print("checking " + a) for b in PossibleSDKs: c = os.path.join(a, b) #print("checking " + c) if isdir(c) and not (c in SDKs): SDKs.append(c) # Make sure %INCLUDE% contains errno.h and windows.h. # This doesn't work correctly for Cygwin Python, ok. if _CheckSetupEnvironmentVariableAll("INCLUDE", ["errno.h", "windows.h"], VCInc): for a in SDKs: b = os.path.join(a, "include") if isfile(os.path.join(b, "windows.h")): _SetupEnvironmentVariableAll("INCLUDE", ["errno.h", "windows.h"], VCInc + ";" + b, ";") break # Make sure %LIB% contains kernel32.lib and libcmt.lib. # We carry our own kernel32.lib so we don't look in the SDKs. # We usually use msvcrt.lib and not libcmt.lib, but Express 2003 had libcmt.lib and not msvcrt.lib # I think, and libcmt.lib is always present. _SetupEnvironmentVariableAll( "LIB", ["kernel32.lib", "libcmt.lib"], VCLib + ";" + os.path.join(InstallRoot, "lib")) # Check that cl.exe and link.exe are in path, and if not, add VCBin to it, # checking that they are in it. # # Do this before mspdb*dll because it sometimes gets it in the path. # (Why do we care?) _SetupEnvironmentVariableAll("PATH", ["cl", "link"], VCBin) # If none of mspdb*.dll are in PATH, add MpsdbDir to PATH, and check that one of them is in it. _SetupEnvironmentVariableAny( "PATH", ["mspdb80.dll", "mspdb71.dll", "mspdb70.dll", "mspdb60.dll", "mspdb50.dll", "mspdb41.dll", "mspdb40.dll", "dbi.dll"], MspdbDir) # Try to get mt.exe in %PATH% if it isn't already. # We only need this for certain toolsets. if not SearchPath("mt.exe", os.environ.get("PATH")): for a in SDKs: b = os.path.join(a, "bin") if isfile(os.path.join(b, "mt.exe")): SetEnvironmentVariable("PATH", os.environ.get("PATH") + os.pathsep + b) break # sys.exit(1) # The free Visual C++ 2003 has neither delayimp.lib nor msvcrt.lib. # Very old toolsets have no delayimp.lib. # The Quake config file checks these environment variables. Lib = os.environ.get("LIB") if not SearchPath("delayimp.lib", Lib): os.environ["USE_DELAYLOAD"] = "0" print("set USE_DELAYLOAD=0") if not SearchPath("msvcrt.lib", Lib): os.environ["USE_MSVCRT"] = "0" print("set USE_MSVCRT=0") # some host/target confusion here.. if Target == "NT386MINGNU" or (Target == "NT386" and GCC_BACKEND and TargetOS == "WIN32"): _ClearEnvironmentVariable("LIB") _ClearEnvironmentVariable("INCLUDE") _SetupEnvironmentVariableAll( "PATH", ["gcc", "as", "ld"], os.path.join(SystemDrive, "mingw", "bin")) # need to probe for ld that accepts response files. # For example, this version does not: # C:\dev2\cm3\scripts\python>ld -v # GNU ld version 2.15.91 20040904 # This comes with Qt I think (free Windows version) # # This version works: # C:\dev2\cm3\scripts\python>ld -v # GNU ld version 2.17.50 20060824 # Ensure msys make is ahead of mingwin make, by adding # msys to the start of the path after adding mingw to the # start of the path. Modula-3 does not generally use # make, but this might matter when building m3cg, and # is usually the right thing. _SetupEnvironmentVariableAll( "PATH", ["sh", "sed", "gawk", "make"], os.path.join(SystemDrive, "msys", "1.0", "bin")) # some host/target confusion here.. if Host == "NT386GNU" or (Host == "NT386" and GCC_BACKEND and TargetOS == "POSIX"): #_ClearEnvironmentVariable("LIB") #_ClearEnvironmentVariable("INCLUDE") #if HostIsNT: # _SetupEnvironmentVariableAll( # "PATH", # ["cygX11-6.dll"], # os.path.join(SystemDrive, "cygwin", "usr", "X11R6", "bin")) _SetupEnvironmentVariableAll( "PATH", ["gcc", "as", "ld"], os.path.join(SystemDrive, "cygwin", "bin"))
|
|
if Target == "NT386" and HostIsNT and Config == "NT386" and (not GCC_BACKEND) and TargetOS == "WIN32":
|
if IsNativeNTHostTarget():
|
def SetupEnvironment(): SystemDrive = os.environ.get("SystemDrive", "") if os.environ.get("OS") == "Windows_NT": HostIsNT = True else: HostIsNT = False SystemDrive = os.environ.get("SYSTEMDRIVE") if SystemDrive: SystemDrive += os.path.sep # Do this earlier so that its link isn't a problem. # Looking in the registry HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2 # would be reasonable here. if CM3IsCygwin: _SetupEnvironmentVariableAll( "PATH", ["cygwin1.dll"], os.path.join(SystemDrive, "cygwin", "bin")) # some host/target confusion here.. if Target == "NT386" and HostIsNT and Config == "NT386" and (not GCC_BACKEND) and TargetOS == "WIN32": VCBin = "" VCInc = "" VCLib = "" MspdbDir = "" # 4.0 e:\MSDEV # 5.0 E:\Program Files\DevStudio\SharedIDE MSDevDir = os.environ.get("MSDEVDIR") # 5.0 MSVCDir = os.environ.get("MSVCDIR") # E:\Program Files\DevStudio\VC # 7.1 Express VCToolkitInstallDir = os.environ.get("VCTOOLKITINSTALLDIR") # E:\Program Files\Microsoft Visual C++ Toolkit 2003 (not set by vcvars32) # 8.0 Express # E:\Program Files\Microsoft Visual Studio 8\VC # E:\Program Files\Microsoft Visual Studio 8\Common7\Tools DevEnvDir = os.environ.get("DevEnvDir") # E:\Program Files\Microsoft Visual Studio 8\Common7\IDE VSInstallDir = os.environ.get("VSINSTALLDIR") # E:\Program Files\Microsoft Visual Studio 8 # VS80CommonTools = os.environ.get("VS80COMNTOOLS") # E:\Program Files\Microsoft Visual Studio 8\Common7\Tools VCInstallDir = os.environ.get("VCINSTALLDIR") # E:\Program Files\Microsoft Visual Studio 8\VC # 9.0 Express # always, global #VS90COMNTOOLS=D:\msdev\90\Common7\Tools\ # after running the shortcut #VCINSTALLDIR=D:\msdev\90\VC #VSINSTALLDIR=D:\msdev\90 VSCommonTools = os.environ.get("VS90COMNTOOLS") if VSCommonTools and not VSInstallDir: VSInstallDir = RemoveLastPathElement(RemoveLastPathElement(VSCommonTools)) # The Windows SDK is carried with the express edition and tricky to find. # Best if folks just run the installed shortcut probably. # We do a pretty good job now of finding it, be need to encode # more paths to known versions. # This is not yet finished. # # Probe the partly version-specific less-polluting environment variables, # from newest to oldest. # That is, having setup alter PATH, INCLUDE, and LIB system-wide is not # a great idea, but having setup set DevEnvDir, VSINSTALLDIR, VS80COMNTOOLS, etc. # isn't so bad and we can temporarily establish the first set from the second # set. if VSInstallDir: # Visual C++ 2005/8.0, at least the Express Edition, free download # also Visual C++ 2008/9.0 Express Edition if not VCInstallDir: VCInstallDir = os.path.join(VSInstallDir, "VC") #print("VCInstallDir:" + VCInstallDir) if not DevEnvDir: DevEnvDir = os.path.join(VSInstallDir, "Common7", "IDE") #print("DevEnvDir:" + DevEnvDir) MspdbDir = DevEnvDir elif VCToolkitInstallDir: # free download Visual C++ 2003; no longer available VCInstallDir = VCToolkitInstallDir elif MSVCDir and MSDevDir: # Visual C++ 5.0 pass # do more research # VCInstallDir = MSVCDir elif MSDevDir: # Visual C++ 4.0, 5.0 pass # do more research # VCInstallDir = MSDevDir else: # This is what really happens on my machine, for 8.0. # It might be good to guide pylib.py to other versions, # however setting things up manually suffices and I have, um, # well automated. Msdev = os.path.join(SystemDrive, "msdev", "80") VCInstallDir = os.path.join(Msdev, "VC") DevEnvDir = os.path.join(Msdev, "Common7", "IDE") if VCInstallDir: VCBin = os.path.join(VCInstallDir, "bin") VCLib = os.path.join(VCInstallDir, "lib") VCInc = os.path.join(VCInstallDir, "include") if DevEnvDir: MspdbDir = DevEnvDir #elif VCBin: # MspdbDir = VCBin # Look for SDKs. # expand this as they are released/discovered # ordering is from newest to oldest PossibleSDKs = [os.path.join("Microsoft SDKs", "Windows", "v6.0A"), "Microsoft Platform SDK for Windows Server 2003 R2"] SDKs = [] for a in GetProgramFiles(): #print("checking " + a) for b in PossibleSDKs: c = os.path.join(a, b) #print("checking " + c) if isdir(c) and not (c in SDKs): SDKs.append(c) # Make sure %INCLUDE% contains errno.h and windows.h. # This doesn't work correctly for Cygwin Python, ok. if _CheckSetupEnvironmentVariableAll("INCLUDE", ["errno.h", "windows.h"], VCInc): for a in SDKs: b = os.path.join(a, "include") if isfile(os.path.join(b, "windows.h")): _SetupEnvironmentVariableAll("INCLUDE", ["errno.h", "windows.h"], VCInc + ";" + b, ";") break # Make sure %LIB% contains kernel32.lib and libcmt.lib. # We carry our own kernel32.lib so we don't look in the SDKs. # We usually use msvcrt.lib and not libcmt.lib, but Express 2003 had libcmt.lib and not msvcrt.lib # I think, and libcmt.lib is always present. _SetupEnvironmentVariableAll( "LIB", ["kernel32.lib", "libcmt.lib"], VCLib + ";" + os.path.join(InstallRoot, "lib")) # Check that cl.exe and link.exe are in path, and if not, add VCBin to it, # checking that they are in it. # # Do this before mspdb*dll because it sometimes gets it in the path. # (Why do we care?) _SetupEnvironmentVariableAll("PATH", ["cl", "link"], VCBin) # If none of mspdb*.dll are in PATH, add MpsdbDir to PATH, and check that one of them is in it. _SetupEnvironmentVariableAny( "PATH", ["mspdb80.dll", "mspdb71.dll", "mspdb70.dll", "mspdb60.dll", "mspdb50.dll", "mspdb41.dll", "mspdb40.dll", "dbi.dll"], MspdbDir) # Try to get mt.exe in %PATH% if it isn't already. # We only need this for certain toolsets. if not SearchPath("mt.exe", os.environ.get("PATH")): for a in SDKs: b = os.path.join(a, "bin") if isfile(os.path.join(b, "mt.exe")): SetEnvironmentVariable("PATH", os.environ.get("PATH") + os.pathsep + b) break # sys.exit(1) # The free Visual C++ 2003 has neither delayimp.lib nor msvcrt.lib. # Very old toolsets have no delayimp.lib. # The Quake config file checks these environment variables. Lib = os.environ.get("LIB") if not SearchPath("delayimp.lib", Lib): os.environ["USE_DELAYLOAD"] = "0" print("set USE_DELAYLOAD=0") if not SearchPath("msvcrt.lib", Lib): os.environ["USE_MSVCRT"] = "0" print("set USE_MSVCRT=0") # some host/target confusion here.. if Target == "NT386MINGNU" or (Target == "NT386" and GCC_BACKEND and TargetOS == "WIN32"): _ClearEnvironmentVariable("LIB") _ClearEnvironmentVariable("INCLUDE") _SetupEnvironmentVariableAll( "PATH", ["gcc", "as", "ld"], os.path.join(SystemDrive, "mingw", "bin")) # need to probe for ld that accepts response files. # For example, this version does not: # C:\dev2\cm3\scripts\python>ld -v # GNU ld version 2.15.91 20040904 # This comes with Qt I think (free Windows version) # # This version works: # C:\dev2\cm3\scripts\python>ld -v # GNU ld version 2.17.50 20060824 # Ensure msys make is ahead of mingwin make, by adding # msys to the start of the path after adding mingw to the # start of the path. Modula-3 does not generally use # make, but this might matter when building m3cg, and # is usually the right thing. _SetupEnvironmentVariableAll( "PATH", ["sh", "sed", "gawk", "make"], os.path.join(SystemDrive, "msys", "1.0", "bin")) # some host/target confusion here.. if Host == "NT386GNU" or (Host == "NT386" and GCC_BACKEND and TargetOS == "POSIX"): #_ClearEnvironmentVariable("LIB") #_ClearEnvironmentVariable("INCLUDE") #if HostIsNT: # _SetupEnvironmentVariableAll( # "PATH", # ["cygX11-6.dll"], # os.path.join(SystemDrive, "cygwin", "usr", "X11R6", "bin")) _SetupEnvironmentVariableAll( "PATH", ["gcc", "as", "ld"], os.path.join(SystemDrive, "cygwin", "bin"))
|
if Target == "NT386MINGNU" or (Target == "NT386" and GCC_BACKEND and TargetOS == "WIN32"):
|
if IsMinGWHostTarget():
|
def SetupEnvironment(): SystemDrive = os.environ.get("SystemDrive", "") if os.environ.get("OS") == "Windows_NT": HostIsNT = True else: HostIsNT = False SystemDrive = os.environ.get("SYSTEMDRIVE") if SystemDrive: SystemDrive += os.path.sep # Do this earlier so that its link isn't a problem. # Looking in the registry HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2 # would be reasonable here. if CM3IsCygwin: _SetupEnvironmentVariableAll( "PATH", ["cygwin1.dll"], os.path.join(SystemDrive, "cygwin", "bin")) # some host/target confusion here.. if Target == "NT386" and HostIsNT and Config == "NT386" and (not GCC_BACKEND) and TargetOS == "WIN32": VCBin = "" VCInc = "" VCLib = "" MspdbDir = "" # 4.0 e:\MSDEV # 5.0 E:\Program Files\DevStudio\SharedIDE MSDevDir = os.environ.get("MSDEVDIR") # 5.0 MSVCDir = os.environ.get("MSVCDIR") # E:\Program Files\DevStudio\VC # 7.1 Express VCToolkitInstallDir = os.environ.get("VCTOOLKITINSTALLDIR") # E:\Program Files\Microsoft Visual C++ Toolkit 2003 (not set by vcvars32) # 8.0 Express # E:\Program Files\Microsoft Visual Studio 8\VC # E:\Program Files\Microsoft Visual Studio 8\Common7\Tools DevEnvDir = os.environ.get("DevEnvDir") # E:\Program Files\Microsoft Visual Studio 8\Common7\IDE VSInstallDir = os.environ.get("VSINSTALLDIR") # E:\Program Files\Microsoft Visual Studio 8 # VS80CommonTools = os.environ.get("VS80COMNTOOLS") # E:\Program Files\Microsoft Visual Studio 8\Common7\Tools VCInstallDir = os.environ.get("VCINSTALLDIR") # E:\Program Files\Microsoft Visual Studio 8\VC # 9.0 Express # always, global #VS90COMNTOOLS=D:\msdev\90\Common7\Tools\ # after running the shortcut #VCINSTALLDIR=D:\msdev\90\VC #VSINSTALLDIR=D:\msdev\90 VSCommonTools = os.environ.get("VS90COMNTOOLS") if VSCommonTools and not VSInstallDir: VSInstallDir = RemoveLastPathElement(RemoveLastPathElement(VSCommonTools)) # The Windows SDK is carried with the express edition and tricky to find. # Best if folks just run the installed shortcut probably. # We do a pretty good job now of finding it, be need to encode # more paths to known versions. # This is not yet finished. # # Probe the partly version-specific less-polluting environment variables, # from newest to oldest. # That is, having setup alter PATH, INCLUDE, and LIB system-wide is not # a great idea, but having setup set DevEnvDir, VSINSTALLDIR, VS80COMNTOOLS, etc. # isn't so bad and we can temporarily establish the first set from the second # set. if VSInstallDir: # Visual C++ 2005/8.0, at least the Express Edition, free download # also Visual C++ 2008/9.0 Express Edition if not VCInstallDir: VCInstallDir = os.path.join(VSInstallDir, "VC") #print("VCInstallDir:" + VCInstallDir) if not DevEnvDir: DevEnvDir = os.path.join(VSInstallDir, "Common7", "IDE") #print("DevEnvDir:" + DevEnvDir) MspdbDir = DevEnvDir elif VCToolkitInstallDir: # free download Visual C++ 2003; no longer available VCInstallDir = VCToolkitInstallDir elif MSVCDir and MSDevDir: # Visual C++ 5.0 pass # do more research # VCInstallDir = MSVCDir elif MSDevDir: # Visual C++ 4.0, 5.0 pass # do more research # VCInstallDir = MSDevDir else: # This is what really happens on my machine, for 8.0. # It might be good to guide pylib.py to other versions, # however setting things up manually suffices and I have, um, # well automated. Msdev = os.path.join(SystemDrive, "msdev", "80") VCInstallDir = os.path.join(Msdev, "VC") DevEnvDir = os.path.join(Msdev, "Common7", "IDE") if VCInstallDir: VCBin = os.path.join(VCInstallDir, "bin") VCLib = os.path.join(VCInstallDir, "lib") VCInc = os.path.join(VCInstallDir, "include") if DevEnvDir: MspdbDir = DevEnvDir #elif VCBin: # MspdbDir = VCBin # Look for SDKs. # expand this as they are released/discovered # ordering is from newest to oldest PossibleSDKs = [os.path.join("Microsoft SDKs", "Windows", "v6.0A"), "Microsoft Platform SDK for Windows Server 2003 R2"] SDKs = [] for a in GetProgramFiles(): #print("checking " + a) for b in PossibleSDKs: c = os.path.join(a, b) #print("checking " + c) if isdir(c) and not (c in SDKs): SDKs.append(c) # Make sure %INCLUDE% contains errno.h and windows.h. # This doesn't work correctly for Cygwin Python, ok. if _CheckSetupEnvironmentVariableAll("INCLUDE", ["errno.h", "windows.h"], VCInc): for a in SDKs: b = os.path.join(a, "include") if isfile(os.path.join(b, "windows.h")): _SetupEnvironmentVariableAll("INCLUDE", ["errno.h", "windows.h"], VCInc + ";" + b, ";") break # Make sure %LIB% contains kernel32.lib and libcmt.lib. # We carry our own kernel32.lib so we don't look in the SDKs. # We usually use msvcrt.lib and not libcmt.lib, but Express 2003 had libcmt.lib and not msvcrt.lib # I think, and libcmt.lib is always present. _SetupEnvironmentVariableAll( "LIB", ["kernel32.lib", "libcmt.lib"], VCLib + ";" + os.path.join(InstallRoot, "lib")) # Check that cl.exe and link.exe are in path, and if not, add VCBin to it, # checking that they are in it. # # Do this before mspdb*dll because it sometimes gets it in the path. # (Why do we care?) _SetupEnvironmentVariableAll("PATH", ["cl", "link"], VCBin) # If none of mspdb*.dll are in PATH, add MpsdbDir to PATH, and check that one of them is in it. _SetupEnvironmentVariableAny( "PATH", ["mspdb80.dll", "mspdb71.dll", "mspdb70.dll", "mspdb60.dll", "mspdb50.dll", "mspdb41.dll", "mspdb40.dll", "dbi.dll"], MspdbDir) # Try to get mt.exe in %PATH% if it isn't already. # We only need this for certain toolsets. if not SearchPath("mt.exe", os.environ.get("PATH")): for a in SDKs: b = os.path.join(a, "bin") if isfile(os.path.join(b, "mt.exe")): SetEnvironmentVariable("PATH", os.environ.get("PATH") + os.pathsep + b) break # sys.exit(1) # The free Visual C++ 2003 has neither delayimp.lib nor msvcrt.lib. # Very old toolsets have no delayimp.lib. # The Quake config file checks these environment variables. Lib = os.environ.get("LIB") if not SearchPath("delayimp.lib", Lib): os.environ["USE_DELAYLOAD"] = "0" print("set USE_DELAYLOAD=0") if not SearchPath("msvcrt.lib", Lib): os.environ["USE_MSVCRT"] = "0" print("set USE_MSVCRT=0") # some host/target confusion here.. if Target == "NT386MINGNU" or (Target == "NT386" and GCC_BACKEND and TargetOS == "WIN32"): _ClearEnvironmentVariable("LIB") _ClearEnvironmentVariable("INCLUDE") _SetupEnvironmentVariableAll( "PATH", ["gcc", "as", "ld"], os.path.join(SystemDrive, "mingw", "bin")) # need to probe for ld that accepts response files. # For example, this version does not: # C:\dev2\cm3\scripts\python>ld -v # GNU ld version 2.15.91 20040904 # This comes with Qt I think (free Windows version) # # This version works: # C:\dev2\cm3\scripts\python>ld -v # GNU ld version 2.17.50 20060824 # Ensure msys make is ahead of mingwin make, by adding # msys to the start of the path after adding mingw to the # start of the path. Modula-3 does not generally use # make, but this might matter when building m3cg, and # is usually the right thing. _SetupEnvironmentVariableAll( "PATH", ["sh", "sed", "gawk", "make"], os.path.join(SystemDrive, "msys", "1.0", "bin")) # some host/target confusion here.. if Host == "NT386GNU" or (Host == "NT386" and GCC_BACKEND and TargetOS == "POSIX"): #_ClearEnvironmentVariable("LIB") #_ClearEnvironmentVariable("INCLUDE") #if HostIsNT: # _SetupEnvironmentVariableAll( # "PATH", # ["cygX11-6.dll"], # os.path.join(SystemDrive, "cygwin", "usr", "X11R6", "bin")) _SetupEnvironmentVariableAll( "PATH", ["gcc", "as", "ld"], os.path.join(SystemDrive, "cygwin", "bin"))
|
if Host == "NT386GNU" or (Host == "NT386" and GCC_BACKEND and TargetOS == "POSIX"):
|
if IsCygwinHostTarget():
|
def SetupEnvironment(): SystemDrive = os.environ.get("SystemDrive", "") if os.environ.get("OS") == "Windows_NT": HostIsNT = True else: HostIsNT = False SystemDrive = os.environ.get("SYSTEMDRIVE") if SystemDrive: SystemDrive += os.path.sep # Do this earlier so that its link isn't a problem. # Looking in the registry HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2 # would be reasonable here. if CM3IsCygwin: _SetupEnvironmentVariableAll( "PATH", ["cygwin1.dll"], os.path.join(SystemDrive, "cygwin", "bin")) # some host/target confusion here.. if Target == "NT386" and HostIsNT and Config == "NT386" and (not GCC_BACKEND) and TargetOS == "WIN32": VCBin = "" VCInc = "" VCLib = "" MspdbDir = "" # 4.0 e:\MSDEV # 5.0 E:\Program Files\DevStudio\SharedIDE MSDevDir = os.environ.get("MSDEVDIR") # 5.0 MSVCDir = os.environ.get("MSVCDIR") # E:\Program Files\DevStudio\VC # 7.1 Express VCToolkitInstallDir = os.environ.get("VCTOOLKITINSTALLDIR") # E:\Program Files\Microsoft Visual C++ Toolkit 2003 (not set by vcvars32) # 8.0 Express # E:\Program Files\Microsoft Visual Studio 8\VC # E:\Program Files\Microsoft Visual Studio 8\Common7\Tools DevEnvDir = os.environ.get("DevEnvDir") # E:\Program Files\Microsoft Visual Studio 8\Common7\IDE VSInstallDir = os.environ.get("VSINSTALLDIR") # E:\Program Files\Microsoft Visual Studio 8 # VS80CommonTools = os.environ.get("VS80COMNTOOLS") # E:\Program Files\Microsoft Visual Studio 8\Common7\Tools VCInstallDir = os.environ.get("VCINSTALLDIR") # E:\Program Files\Microsoft Visual Studio 8\VC # 9.0 Express # always, global #VS90COMNTOOLS=D:\msdev\90\Common7\Tools\ # after running the shortcut #VCINSTALLDIR=D:\msdev\90\VC #VSINSTALLDIR=D:\msdev\90 VSCommonTools = os.environ.get("VS90COMNTOOLS") if VSCommonTools and not VSInstallDir: VSInstallDir = RemoveLastPathElement(RemoveLastPathElement(VSCommonTools)) # The Windows SDK is carried with the express edition and tricky to find. # Best if folks just run the installed shortcut probably. # We do a pretty good job now of finding it, be need to encode # more paths to known versions. # This is not yet finished. # # Probe the partly version-specific less-polluting environment variables, # from newest to oldest. # That is, having setup alter PATH, INCLUDE, and LIB system-wide is not # a great idea, but having setup set DevEnvDir, VSINSTALLDIR, VS80COMNTOOLS, etc. # isn't so bad and we can temporarily establish the first set from the second # set. if VSInstallDir: # Visual C++ 2005/8.0, at least the Express Edition, free download # also Visual C++ 2008/9.0 Express Edition if not VCInstallDir: VCInstallDir = os.path.join(VSInstallDir, "VC") #print("VCInstallDir:" + VCInstallDir) if not DevEnvDir: DevEnvDir = os.path.join(VSInstallDir, "Common7", "IDE") #print("DevEnvDir:" + DevEnvDir) MspdbDir = DevEnvDir elif VCToolkitInstallDir: # free download Visual C++ 2003; no longer available VCInstallDir = VCToolkitInstallDir elif MSVCDir and MSDevDir: # Visual C++ 5.0 pass # do more research # VCInstallDir = MSVCDir elif MSDevDir: # Visual C++ 4.0, 5.0 pass # do more research # VCInstallDir = MSDevDir else: # This is what really happens on my machine, for 8.0. # It might be good to guide pylib.py to other versions, # however setting things up manually suffices and I have, um, # well automated. Msdev = os.path.join(SystemDrive, "msdev", "80") VCInstallDir = os.path.join(Msdev, "VC") DevEnvDir = os.path.join(Msdev, "Common7", "IDE") if VCInstallDir: VCBin = os.path.join(VCInstallDir, "bin") VCLib = os.path.join(VCInstallDir, "lib") VCInc = os.path.join(VCInstallDir, "include") if DevEnvDir: MspdbDir = DevEnvDir #elif VCBin: # MspdbDir = VCBin # Look for SDKs. # expand this as they are released/discovered # ordering is from newest to oldest PossibleSDKs = [os.path.join("Microsoft SDKs", "Windows", "v6.0A"), "Microsoft Platform SDK for Windows Server 2003 R2"] SDKs = [] for a in GetProgramFiles(): #print("checking " + a) for b in PossibleSDKs: c = os.path.join(a, b) #print("checking " + c) if isdir(c) and not (c in SDKs): SDKs.append(c) # Make sure %INCLUDE% contains errno.h and windows.h. # This doesn't work correctly for Cygwin Python, ok. if _CheckSetupEnvironmentVariableAll("INCLUDE", ["errno.h", "windows.h"], VCInc): for a in SDKs: b = os.path.join(a, "include") if isfile(os.path.join(b, "windows.h")): _SetupEnvironmentVariableAll("INCLUDE", ["errno.h", "windows.h"], VCInc + ";" + b, ";") break # Make sure %LIB% contains kernel32.lib and libcmt.lib. # We carry our own kernel32.lib so we don't look in the SDKs. # We usually use msvcrt.lib and not libcmt.lib, but Express 2003 had libcmt.lib and not msvcrt.lib # I think, and libcmt.lib is always present. _SetupEnvironmentVariableAll( "LIB", ["kernel32.lib", "libcmt.lib"], VCLib + ";" + os.path.join(InstallRoot, "lib")) # Check that cl.exe and link.exe are in path, and if not, add VCBin to it, # checking that they are in it. # # Do this before mspdb*dll because it sometimes gets it in the path. # (Why do we care?) _SetupEnvironmentVariableAll("PATH", ["cl", "link"], VCBin) # If none of mspdb*.dll are in PATH, add MpsdbDir to PATH, and check that one of them is in it. _SetupEnvironmentVariableAny( "PATH", ["mspdb80.dll", "mspdb71.dll", "mspdb70.dll", "mspdb60.dll", "mspdb50.dll", "mspdb41.dll", "mspdb40.dll", "dbi.dll"], MspdbDir) # Try to get mt.exe in %PATH% if it isn't already. # We only need this for certain toolsets. if not SearchPath("mt.exe", os.environ.get("PATH")): for a in SDKs: b = os.path.join(a, "bin") if isfile(os.path.join(b, "mt.exe")): SetEnvironmentVariable("PATH", os.environ.get("PATH") + os.pathsep + b) break # sys.exit(1) # The free Visual C++ 2003 has neither delayimp.lib nor msvcrt.lib. # Very old toolsets have no delayimp.lib. # The Quake config file checks these environment variables. Lib = os.environ.get("LIB") if not SearchPath("delayimp.lib", Lib): os.environ["USE_DELAYLOAD"] = "0" print("set USE_DELAYLOAD=0") if not SearchPath("msvcrt.lib", Lib): os.environ["USE_MSVCRT"] = "0" print("set USE_MSVCRT=0") # some host/target confusion here.. if Target == "NT386MINGNU" or (Target == "NT386" and GCC_BACKEND and TargetOS == "WIN32"): _ClearEnvironmentVariable("LIB") _ClearEnvironmentVariable("INCLUDE") _SetupEnvironmentVariableAll( "PATH", ["gcc", "as", "ld"], os.path.join(SystemDrive, "mingw", "bin")) # need to probe for ld that accepts response files. # For example, this version does not: # C:\dev2\cm3\scripts\python>ld -v # GNU ld version 2.15.91 20040904 # This comes with Qt I think (free Windows version) # # This version works: # C:\dev2\cm3\scripts\python>ld -v # GNU ld version 2.17.50 20060824 # Ensure msys make is ahead of mingwin make, by adding # msys to the start of the path after adding mingw to the # start of the path. Modula-3 does not generally use # make, but this might matter when building m3cg, and # is usually the right thing. _SetupEnvironmentVariableAll( "PATH", ["sh", "sed", "gawk", "make"], os.path.join(SystemDrive, "msys", "1.0", "bin")) # some host/target confusion here.. if Host == "NT386GNU" or (Host == "NT386" and GCC_BACKEND and TargetOS == "POSIX"): #_ClearEnvironmentVariable("LIB") #_ClearEnvironmentVariable("INCLUDE") #if HostIsNT: # _SetupEnvironmentVariableAll( # "PATH", # ["cygX11-6.dll"], # os.path.join(SystemDrive, "cygwin", "usr", "X11R6", "bin")) _SetupEnvironmentVariableAll( "PATH", ["gcc", "as", "ld"], os.path.join(SystemDrive, "cygwin", "bin"))
|
CM3_BuildLocal = CM3_BuildLocal or BuildLocal or "%(CM3)s %(CM3_FLAGS)s -build -override %(DEFS)s%(BuildArgs)s" CM3_CleanLocal = CM3_CleanLocal or CleanLocal or "%(CM3)s %(CM3_FLAGS)s -clean -build -override %(DEFS)s%(CleanArgs)s" CM3_BuildGlobal = CM3_BuildGlobal or BuildGlobal or "%(CM3)s %(CM3_FLAGS)s -build %(DEFS)s%(BuildArgs)s" CM3_CleanGlobal = CM3_CleanGlobal or CleanGlobal or "%(CM3)s %(CM3_FLAGS)s -clean %(DEFS)s%(CleanArgs)s"
|
Debug = "" CM3_BuildLocal = CM3_BuildLocal or BuildLocal or "%(CM3)s %(CM3_FLAGS)s " + Debug + " -build -override %(DEFS)s%(BuildArgs)s" CM3_CleanLocal = CM3_CleanLocal or CleanLocal or "%(CM3)s %(CM3_FLAGS)s " + Debug + " -clean -build -override %(DEFS)s%(CleanArgs)s" CM3_BuildGlobal = CM3_BuildGlobal or BuildGlobal or "%(CM3)s %(CM3_FLAGS)s " + Debug + " -build %(DEFS)s%(BuildArgs)s" CM3_CleanGlobal = CM3_CleanGlobal or CleanGlobal or "%(CM3)s %(CM3_FLAGS)s " + Debug + " -clean %(DEFS)s%(CleanArgs)s"
|
def ConvertPathForCM3(a): return _ConvertFromCygwinPath(a)
|
Link = GnuPlatformPrefix + Link
|
def Boot(): global BuildLocal BuildLocal += " -boot -keep -DM3CC_TARGET=" + Config Version = CM3VERSION + "-" + time.strftime("%Y%m%d") # This information is duplicated from the config files. # TBD: put it only in one place. # The older bootstraping method does get that right. vms = StringTagged(Config, "VMS") # pick the compiler if Config == "ALPHA32_VMS": CCompiler = "cc" CCompilerFlags = " " elif Config == "ALPHA64_VMS": CCompiler = "cc" CCompilerFlags = "/pointer_size=64 " elif StringTagged(Config, "SOLARIS") or Config == "SOLsun": CCompiler = "/usr/bin/cc" CCompilerFlags = "-g -mt -xldscope=symbolic " elif Config == "ALPHA_OSF": CCompiler = "/usr/bin/cc" CCompilerFlags = "-g " else: # gcc platforms CCompiler = { "SOLgnu" : "/usr/sfw/bin/gcc", }.get(Config) or "gcc" CCompilerFlags = { "I386_INTERIX" : "-g ", # gcc -fPIC generates incorrect code on Interix "SOLgnu" : "-g ", # -fPIC? }.get(Config) or "-g -fPIC " CCompilerFlags = CCompilerFlags + ({ "AMD64_LINUX" : " -m64 -mno-align-double ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -march=armv6 -mcpu=arm1176jzf-s ", "LINUXLIBC6" : " -m32 -mno-align-double ", "I386_LINUX" : " -m32 -mno-align-double ", "MIPS64_OPENBSD" : " -mabi=64 ", "SOLgnu" : " -m32 -mcpu=v9 ", "I386_SOLARIS" : " -xarch=pentium_pro -Kpic ", "AMD64_SOLARIS" : " -xarch=amd64 -Kpic ", "SOLsun" : " -xarch=v8plus -xcode=pic32 ", "SPARC32_SOLARIS" : " -xarch=v8plus -xcode=pic32 ", "SPARC64_SOLARIS" : " -xarch=v9 -xcode=pic32 ", "SPARC32_LINUX" : " -m32 -mcpu=v9 -munaligned-doubles ", "SPARC64_LINUX" : " -m64 -munaligned-doubles ", }.get(Config) or " ") Link = "$(CC) $(CFLAGS) *.mo *.io *.o " # link flags if StringTagged(Target, "DARWIN"): pass elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): Link = Link + " -lrt -lm -lnsl -lsocket -lpthread " elif StringTagged(Target, "HPUX"): Link = Link + " -lrt -lm " elif StringTagged(Target, "INTERIX"): Link = Link + " -lm " else: Link = Link + " -lm -lpthread " # add -c to compiler but not link (i.e. not CCompilerFlags) Compile = "$(CC) $(CFLAGS) " if not StringTagged(Config, "VMS"): Compile = Compile + " -c " AssembleOnTarget = not vms AssembleOnHost = not AssembleOnTarget # pick assembler if StringTagged(Target, "VMS") and AssembleOnTarget: Assembler = "macro" # not right, come back to it later AssemblerFlags = "/alpha " # not right, come back to it later elif StringTagged(Target, "SOLARIS") or Target.startswith("SOL"): # see http://gcc.gnu.org/ml/gcc/2010-05/msg00155.html Assembler = "/usr/ccs/bin/as" elif StringTagged(Target, "OSF"): Assembler = "/usr/bin/as" else: Assembler = "as" # set assembler flags AssemblerFlags = " " if Target != "PPC32_OPENBSD" and Target != "PPC_LINUX" and Target != "ARMEL_LINUX": # "Tag" not right for LINUX due to LINUXLIBC6 # "Tag" not right for BSD or 64 either. if Target.find("LINUX") != -1 or Target.find("BSD") != -1: if Target.find("64") != -1 or (StringTagged(Target, "ALPHA") and not StringTagged(Target, "ALPHA32")): AssemblerFlags = AssemblerFlags + " --64" else: AssemblerFlags = AssemblerFlags + " --32" AssemblerFlags = (AssemblerFlags + ({ "ALPHA_OSF" : " -nocpp ", "AMD64_DARWIN" : " -arch x86_64 ", "PPC64_DARWIN" : " -arch ppc64 ", "ARM_DARWIN" : " -arch armv6 ", "I386_SOLARIS" : " -Qy -s", "AMD64_SOLARIS" : " -Qy -s -xarch=generic64 ", "SOLgnu" : " -Qy -s -K PIC -xarch=v8plus ", "SOLsun" : " -Qy -s -K PIC -xarch=v8plus ", "SPARC32_SOLARIS" : " -Qy -s -K PIC -xarch=v8plus ", "SPARC64_SOLARIS" : " -Qy -s -K PIC -xarch=v9 ", "SPARC32_LINUX" : " -Qy -s -Av9a -32 -relax ", "SPARC64_LINUX" : " -Qy -s -Av9a -64 -no-undeclared-regs -relax ", }.get(Target) or "")) GnuPlatformPrefix = { "ARM_DARWIN" : "arm-apple-darwin8-", "ARMEL_LINUX" : "arm-linux-gnueabi-", "ALPHA32_VMS" : "alpha-dec-vms-", "ALPHA64_VMS" : "alpha64-dec-vms-", }.get(Target) or "" if not vms: CCompiler = GnuPlatformPrefix + CCompiler Link = GnuPlatformPrefix + Link if (not vms) or AssembleOnHost: Assembler = GnuPlatformPrefix + Assembler # squeeze runs of spaces and spaces at ends Compile = _SqueezeSpaces(Compile) CCompilerFlags = _SqueezeSpaces(CCompilerFlags) Link = _SqueezeSpaces(Link) Assembler = _SqueezeSpaces(Assembler) AssemblerFlags = _SqueezeSpaces(AssemblerFlags) BootDir = "./cm3-boot-" + Target + "-" + Version P = [ "m3cc", "import-libs", "m3core", "libm3", "sysutils", "m3middle", "m3quake", "m3objfile", "m3linker", "m3back", "m3front", "cm3" ] #DoPackage(["", "realclean"] + P) or sys.exit(1) DoPackage(["", "buildlocal"] + P) or sys.exit(1) try: shutil.rmtree(BootDir) except: pass try: os.mkdir(BootDir) except: pass # # This would probably be a good use of XSL (xml style sheets) # Make = open(os.path.join(BootDir, "make.sh"), "wb") VmsMake = open(os.path.join(BootDir, "vmsmake.com"), "wb") VmsLink = open(os.path.join(BootDir, "vmslink.opt"), "wb") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") UpdateSource = open(os.path.join(BootDir, "updatesource.sh"), "wb") Objects = { } Makefile.write(".SUFFIXES:\n" + ".SUFFIXES: .c .is .ms .s .o .obj .io .mo\n\n" + "all: cm3\n\n" + "clean:\n" + "\trm -rf *.io *.mo *.o *.obj\n\n") for a in [UpdateSource, Make]: a.write("#!/bin/sh\n\n" + "set -e\n" + "set -x\n\n") for a in [Makefile]: a.write("# edit up here\n\n" + "CC=" + CCompiler + "\n" + "CFLAGS=" + CCompilerFlags + "\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assembler + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for a in [Make]: a.write("# edit up here\n\n" + "CC=${CC:-" + CCompiler + "}\n" + "CFLAGS=${CFLAGS:-" + CCompilerFlags + "}\n" + "Compile=" + Compile + "\n" + "Assemble=" + Assembler + " " + AssemblerFlags + "\n" + "Link=" + Link + "\n" + "\n# no more editing should be needed\n\n") for q in P: dir = GetPackagePath(q) for a in os.listdir(os.path.join(Root, dir, Config)): ext_c = a.endswith(".c") ext_h = a.endswith(".h") ext_s = a.endswith(".s") ext_ms = a.endswith(".ms") ext_is = a.endswith(".is") if not (ext_c or ext_h or ext_s or ext_ms or ext_is): continue fullpath = os.path.join(Root, dir, Config, a) if ext_h or ext_c or not vms or AssembleOnTarget: CopyFile(fullpath, BootDir) if ext_h: continue Object = GetObjectName(a) if Objects.get(Object): continue Objects[Object] = 1 if ext_c: VmsMake.write("$ " + Compile + " " + a + "\n") else: if AssembleOnHost: # must have cross assembler a = Assembler + " " + fullpath + " -o " + BootDir + "/" + Object print(a) os.system(a) else: VmsMake.write("$ " + Assembler + " " + a + "\n") VmsLink.write(Object + "/SELECTIVE_SEARCH\n") Makefile.write(".c.o:\n" + "\t$(Compile) -o $@ $<\n\n" + ".c.obj:\n" + "\t$(Compile) -o $@ $<\n\n" + ".is.io:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".s.o:\n" + "\t$(Assemble) -o $@ $<\n\n" + ".ms.mo:\n" + "\t$(Assemble) -o $@ $<\n\n") Makefile.write("cm3:") Objects = Objects.keys() Objects.sort() k = 4 for a in Objects: k = k + 1 + len(a) if k > 76: # line wrap Makefile.write(" \\\n") k = 1 + len(a) Makefile.write(" " + a) Makefile.write("\n\t") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.o\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.obj\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.mo\n") VmsMake.write("$ set file/attr=(rfm=var,rat=none) *.io\n") VmsMake.write("$ link /executable=cm3.exe vmslink/options\n") for a in [Make, Makefile]: a.write("$(Link) -o cm3\n") for a in [ # # Add to this list as needed. # Adding more than necessary is ok -- assume the target system has no changes, # so we can replace whatever is there. # "m3-libs/libm3/src/os/POSIX/OSConfigPosix.m3", "m3-libs/libm3/src/random/m3makefile", "m3-libs/m3core/src/m3makefile", "m3-libs/m3core/src/Uwaitpid.quake", "m3-libs/m3core/src/thread.quake", "m3-libs/m3core/src/C/m3makefile", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/m3makefile", "m3-libs/m3core/src/Csupport/m3makefile", "m3-libs/m3core/src/float/m3makefile", "m3-libs/m3core/src/runtime/m3makefile", "m3-libs/m3core/src/runtime/common/m3makefile", "m3-libs/m3core/src/runtime/common/Compiler.tmpl", "m3-libs/m3core/src/runtime/common/m3text.h", "m3-libs/m3core/src/runtime/common/RTError.h", "m3-libs/m3core/src/runtime/common/RTMachine.i3", "m3-libs/m3core/src/runtime/common/RTProcess.h", "m3-libs/m3core/src/runtime/common/RTSignalC.c", "m3-libs/m3core/src/runtime/common/RTSignalC.h", "m3-libs/m3core/src/runtime/common/RTSignalC.i3", "m3-libs/m3core/src/runtime/common/RTSignal.i3", "m3-libs/m3core/src/runtime/common/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/m3makefile", "m3-libs/m3core/src/runtime/" + Target + "/RTMachine.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTSignal.m3", "m3-libs/m3core/src/runtime/" + Target + "/RTThread.m3", "m3-libs/m3core/src/text/TextLiteral.i3", "m3-libs/m3core/src/thread/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/m3makefile", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.i3", "m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c", "m3-libs/m3core/src/time/POSIX/m3makefile", "m3-libs/m3core/src/unix/m3makefile", "m3-libs/m3core/src/unix/Common/m3makefile", "m3-libs/m3core/src/unix/Common/m3unix.h", "m3-libs/m3core/src/unix/Common/Udir.i3", "m3-libs/m3core/src/unix/Common/UdirC.c", "m3-libs/m3core/src/unix/Common/Usignal.i3", "m3-libs/m3core/src/unix/Common/Ustat.i3", "m3-libs/m3core/src/unix/Common/UstatC.c", "m3-libs/m3core/src/unix/Common/UtimeC.c", "m3-libs/m3core/src/unix/Common/Uucontext.i3", "m3-sys/cminstall/src/config-no-install/SOLgnu", "m3-sys/cminstall/src/config-no-install/SOLsun", "m3-sys/cminstall/src/config-no-install/Solaris.common", "m3-sys/cminstall/src/config-no-install/Unix.common", "m3-sys/cminstall/src/config-no-install/cm3cfg.common", "m3-sys/cminstall/src/config-no-install/" + Target, "m3-sys/m3cc/src/m3makefile", "m3-sys/m3cc/src/gcc/m3cg/parse.c", "m3-sys/m3middle/src/Target.i3", "m3-sys/m3middle/src/Target.m3", "scripts/python/pylib.py", "m3-libs/m3core/src/C/" + Target + "/Csetjmp.i3", "m3-libs/m3core/src/C/" + Target + "/m3makefile", "m3-libs/m3core/src/C/Common/Csetjmp.i3", "m3-libs/m3core/src/C/Common/Csignal.i3", "m3-libs/m3core/src/C/Common/Cstdio.i3", "m3-libs/m3core/src/C/Common/Cstring.i3", "m3-libs/m3core/src/C/Common/m3makefile", ]: source = os.path.join(Root, a) if FileExists(source): name = GetLastPathElement(a) reldir = RemoveLastPathElement(a) destdir = os.path.join(BootDir, reldir) dest = os.path.join(destdir, name) try: os.makedirs(destdir) except: pass CopyFile(source, dest) for b in [UpdateSource, Make]: b.write("mkdir -p /dev2/cm3/" + reldir + "\n") b.write("cp " + a + " /dev2/cm3/" + a + "\n") for a in [UpdateSource, Make, Makefile, VmsMake, VmsLink]: a.close() # write entirely new custom makefile for NT # We always have object files so just compile and link in one fell swoop. if StringTagged(Config, "NT") or Config == "NT386": DeleteFile("updatesource.sh") DeleteFile("make.sh") Makefile = open(os.path.join(BootDir, "Makefile"), "wb") Makefile.write("cm3.exe: *.io *.mo *.c\r\n" + " cl -Zi -MD *.c -link *.mo *.io -out:cm3.exe user32.lib kernel32.lib wsock32.lib comctl32.lib gdi32.lib advapi32.lib netapi32.lib\r\n") Makefile.close() if vms or StringTagged(Config, "NT") or Config == "NT386": _MakeZip(BootDir[2:]) else: _MakeTGZ(BootDir[2:])
|
|
arch = os.popen("arch -s").read().lower() if arch == "sparc64":
|
arch = os.popen("arch -s").read() if arch == "sparc64\n":
|
def GetVersion(Key): # # Only read the file if an environment variable is "missing" (they # usually all are, ok), and only read it once. # #print("WriteVariablesIntoEnvironment:3") Value = Versions.get(Key) if Value: return Value # # CM3VERSION d5.7.1 # CM3VERSIONNUM 050701 # CM3LASTCHANGED 2009-01-21 # RegExp = re.compile("(" + "|".join(Versions.keys()) + ") (.+)$", re.IGNORECASE) ShFilePath = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "version") for Line in open(ShFilePath): Match = RegExp.match(Line) if Match: MatchKey = Match.group(1) # # We are here because one of them wasn't found, but we should be # sure only to overwrite what we don't have. # if not Versions[MatchKey]: Value = Match.group(2) Versions[MatchKey] = Value exec("%s = \"%s\"" % (MatchKey, Value), locals(), globals()) # # Make sure we found every key in the file (at least those # not defined in the environment) # MissingKey = None for Item in Versions.iteritems(): #print(Item) if Item[1] is None: MissingKey = Item[0] File = __file__ sys.stderr.write("%(File)s: %(MissingKey)s not found in %(ShFilePath)s\n" % vars()) if MissingKey: sys.exit(1) return Versions.get(Key)
|
elif arch == "powerpc":
|
elif arch == "powerpc\n":
|
def GetVersion(Key): # # Only read the file if an environment variable is "missing" (they # usually all are, ok), and only read it once. # #print("WriteVariablesIntoEnvironment:3") Value = Versions.get(Key) if Value: return Value # # CM3VERSION d5.7.1 # CM3VERSIONNUM 050701 # CM3LASTCHANGED 2009-01-21 # RegExp = re.compile("(" + "|".join(Versions.keys()) + ") (.+)$", re.IGNORECASE) ShFilePath = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "version") for Line in open(ShFilePath): Match = RegExp.match(Line) if Match: MatchKey = Match.group(1) # # We are here because one of them wasn't found, but we should be # sure only to overwrite what we don't have. # if not Versions[MatchKey]: Value = Match.group(2) Versions[MatchKey] = Value exec("%s = \"%s\"" % (MatchKey, Value), locals(), globals()) # # Make sure we found every key in the file (at least those # not defined in the environment) # MissingKey = None for Item in Versions.iteritems(): #print(Item) if Item[1] is None: MissingKey = Item[0] File = __file__ sys.stderr.write("%(File)s: %(MissingKey)s not found in %(ShFilePath)s\n" % vars()) if MissingKey: sys.exit(1) return Versions.get(Key)
|
elif arch == "i386":
|
elif arch == "i386\n":
|
def GetVersion(Key): # # Only read the file if an environment variable is "missing" (they # usually all are, ok), and only read it once. # #print("WriteVariablesIntoEnvironment:3") Value = Versions.get(Key) if Value: return Value # # CM3VERSION d5.7.1 # CM3VERSIONNUM 050701 # CM3LASTCHANGED 2009-01-21 # RegExp = re.compile("(" + "|".join(Versions.keys()) + ") (.+)$", re.IGNORECASE) ShFilePath = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "version") for Line in open(ShFilePath): Match = RegExp.match(Line) if Match: MatchKey = Match.group(1) # # We are here because one of them wasn't found, but we should be # sure only to overwrite what we don't have. # if not Versions[MatchKey]: Value = Match.group(2) Versions[MatchKey] = Value exec("%s = \"%s\"" % (MatchKey, Value), locals(), globals()) # # Make sure we found every key in the file (at least those # not defined in the environment) # MissingKey = None for Item in Versions.iteritems(): #print(Item) if Item[1] is None: MissingKey = Item[0] File = __file__ sys.stderr.write("%(File)s: %(MissingKey)s not found in %(ShFilePath)s\n" % vars()) if MissingKey: sys.exit(1) return Versions.get(Key)
|
"cm3", "mklib", "m3cc", "m3core", "libm3",
|
"cm3", "mklib", "m3core", "libm3",
|
def _CleanupEnvironment(): # pylib.py figures these out correctly and in particular # their forms have to change if we upgrade from NT386 # to I386_CYGWIN or vice versa; reloading pylib.py # handles that for a in ["M3CONFIG", "CM3_INSTALL", "CM3_ROOT"]: if os.environ.get(a): del(os.environ[a])
|
def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr) self.questItemIds = range(1632, 1635) + range(1636,1642) + [1622, 1623] def onEvent (self,event,st) : htmltext = event player = st.getPlayer() if event == "30527_1" : if player.getClassId().getId() != 0x35 : if player.getClassId().getId() == 0x38 : htmltext = "30527-02a.htm" else: htmltext = "30527-02.htm" else: if player.getLevel()<18 : htmltext = "30527-03.htm" else: if st.getQuestItemsCount(PASS_FINAL) != 0 : htmltext = "30527-04.htm" else: htmltext = "30527-05.htm" return htmltext elif event == "30527_2" : htmltext = "30527-11.htm" st.takeItems(TOTEM_SPIRIT_CLAW,1) st.giveItems(TATARUS_LETTER,1) elif event == "1" : st.set("id","0") st.set("cond","1") st.setState(State.STARTED) st.playSound("ItemSound.quest_accept") htmltext = "30527-06.htm" st.giveItems(SILVERYS_RING,1) elif event == "a" : htmltext = "30527-08a.htm" st.takeItems(SILVERYS_RING,st.getQuestItemsCount(SILVERYS_RING)) st.takeItems(RATMAN_TOOTH,st.getQuestItemsCount(RATMAN_TOOTH)) st.takeItems(BIG_RATMAN_TOOTH,st.getQuestItemsCount(BIG_RATMAN_TOOTH)) st.playSound("ItemSound.quest_accept") st.giveItems(PASS_1ST,1) st.set("cond","3") elif event == "b" : htmltext = "30527-08b.htm" st.set("cond","8") st.takeItems(SILVERYS_RING,st.getQuestItemsCount(SILVERYS_RING)) st.takeItems(RATMAN_TOOTH,st.getQuestItemsCount(RATMAN_TOOTH)) st.takeItems(BIG_RATMAN_TOOTH,st.getQuestItemsCount(BIG_RATMAN_TOOTH)) st.playSound("ItemSound.quest_accept") elif event == "30317_1" : htmltext = "30317-02.htm" elif event == "30317_2" : htmltext = "30317-05.htm" elif event == "30317_3" : htmltext = "30317-03.htm" elif event == "30317_4" : htmltext = "30317-04.htm" st.giveItems(KLUTOS_LETTER,1) st.set("cond","4") elif event == "30317_5" : htmltext = "30317-06.htm" elif event == "30317_6" : htmltext = "30317-07.htm" st.giveItems(KLUTOS_LETTER,1) st.set("cond","4") elif event == "30317_7" : if st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(PASS_2ND) and st.getQuestItemsCount(SECRET_BOX2) : htmltext = "30317-10.htm" st.takeItems(PASS_1ST,1) st.takeItems(PASS_2ND,1) st.takeItems(SECRET_BOX2,1) st.giveItems(PASS_FINAL,1) isFinished = st.getGlobalQuestVar("1ClassQuestFinished") if isFinished == "" : st.giveItems(57,81900) st.addExpAndSp(160267,11726) st.set("cond","0") st.exitQuest(False) st.saveGlobalQuestVar("1ClassQuestFinished","1") st.playSound("ItemSound.quest_finish") else : htmltext = "30317-08.htm" elif event == "30317_8" : htmltext = "30317-11.htm" elif event == "30317_9" : if st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(PASS_2ND) and st.getQuestItemsCount(SECRET_BOX2) : htmltext = "30317-12.htm" st.takeItems(PASS_1ST,1) st.takeItems(PASS_2ND,1) st.takeItems(SECRET_BOX2,1) st.giveItems(PASS_FINAL,1) st.giveItems(57,81900) st.addExpAndSp(228064,15075) st.set("cond","0") st.exitQuest(False) st.playSound("ItemSound.quest_finish") else : htmltext = "30317-08.htm" elif event == "30298_1" : htmltext = "30298-02.htm" elif event == "30298_2" : htmltext = "30298-03.htm" st.takeItems(KLUTOS_LETTER,1) st.giveItems(FOOTPRINT,1) st.set("cond","5") elif event == "30298_3" : htmltext = "30298-06.htm" st.takeItems(SECRET_BOX1,1) st.takeItems(FOOTPRINT,1) st.giveItems(SECRET_BOX2,1) st.giveItems(PASS_2ND,1) st.set("cond","7") elif event == "32052_07" : htmltext = "32052-07.htm" st.set("cond","9") st.playSound("ItemSound.quest_accept") elif event == "31963_5" : htmltext = "31963-05.htm" st.giveItems(PASS_FINAL,1) st.set("cond","0") st.exitQuest(False) st.playSound("ItemSound.quest_finish") elif event == "31963_6" : htmltext = "31963-06.htm" st.set("cond","10") st.playSound("ItemSound.quest_accept") elif event == "31963_8" : htmltext = "31963-08.htm" st.set("cond","11") st.playSound("ItemSound.quest_accept") elif event == "32052_13" : htmltext = "32052-13.htm" st.giveItems(PASS_FINAL,1) st.set("cond","0") st.exitQuest(False) st.playSound("ItemSound.quest_finish") elif event == "30531_5" : htmltext = "30531-05.htm" st.giveItems(PASS_FINAL,1) st.set("cond","0") st.exitQuest(False) st.playSound("ItemSound.quest_finish") elif event == "31956_1" : htmltext = "31956-03.htm" st.giveItems(PASS_FINAL,1) st.set("cond","0") st.exitQuest(False) st.playSound("ItemSound.quest_finish") return htmltext def onTalk (self,npc,player): htmltext = "<html><body>ثeSȡAαšC</body></html>" st = player.getQuestState(qn) if not st : return htmltext npcId = npc.getNpcId() id = st.getState() cond = st.getInt("cond") if npcId != 30527 and id != State.STARTED : return htmltext if npcId == 30527 and st.getInt("cond") == 0 : htmltext = "30527-01.htm" elif npcId == 30527 and st.getInt("cond") and st.getQuestItemsCount(SILVERYS_RING) == 1 and (st.getQuestItemsCount(RATMAN_TOOTH)+st.getQuestItemsCount(BIG_RATMAN_TOOTH)) < 12 : htmltext = "30527-07.htm" elif npcId == 30527 and st.getInt("cond") and st.getQuestItemsCount(SILVERYS_RING) == 1 and st.getQuestItemsCount(RATMAN_TOOTH) >= 10 and st.getQuestItemsCount(BIG_RATMAN_TOOTH) >= 2 : htmltext = "30527-08.htm" st.takeItems(SILVERYS_RING,st.getQuestItemsCount(SILVERYS_RING)) st.takeItems(RATMAN_TOOTH,st.getQuestItemsCount(RATMAN_TOOTH)) st.takeItems(BIG_RATMAN_TOOTH,st.getQuestItemsCount(BIG_RATMAN_TOOTH)) st.giveItems(PASS_1ST,1) st.set("cond","3") elif npcId == 30527 and st.getInt("cond") and st.getQuestItemsCount(PASS_1ST) == 1 : htmltext = "30527-09.htm" elif npcId == 30317 and st.getInt("cond") and st.getQuestItemsCount(KLUTOS_LETTER) == 0 and st.getQuestItemsCount(FOOTPRINT) == 0 and st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(PASS_2ND) == 0 and st.getQuestItemsCount(SECRET_BOX2) == 0 : htmltext = "30317-01.htm" elif npcId == 30317 and st.getInt("cond") and st.getQuestItemsCount(PASS_1ST) and (st.getQuestItemsCount(KLUTOS_LETTER) or st.getQuestItemsCount(FOOTPRINT)) : htmltext = "30317-08.htm" elif npcId == 30317 and st.getInt("cond") and st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(PASS_2ND) and st.getQuestItemsCount(SECRET_BOX2) : htmltext = "30317-09.htm" elif npcId == 30298 and st.getInt("cond") and st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(KLUTOS_LETTER) : htmltext = "30298-01.htm" elif npcId == 30298 and st.getInt("cond") and st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(FOOTPRINT) and st.getQuestItemsCount(SECRET_BOX1) == 0 : htmltext = "30298-04.htm" elif npcId == 30298 and st.getInt("cond") and st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(FOOTPRINT) and st.getQuestItemsCount(SECRET_BOX1) : htmltext = "30298-05.htm" elif npcId == 30298 and st.getInt("cond") and st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(PASS_2ND) and st.getQuestItemsCount(SECRET_BOX2) : htmltext = "30298-07.htm" elif npcId == 30527 and cond == 8 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "30527-09b.htm" elif npcId == 32052 and cond == 8 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "32052-01.htm" elif npcId == 32052 and cond == 9 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "32052-08.htm" elif npcId == 31963 and cond == 9 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "31963-01.htm" elif npcId == 31963 and cond == 10 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "31963-07.htm" elif npcId == 30531 and cond == 10 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "30531-01.htm" elif npcId == 31963 and cond == 11 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "31963-09.htm" elif npcId == 32052 and cond == 11 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "32052-09.htm" elif npcId == 31956 and cond == 12 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "31956-01.htm" return htmltext def onKill(self,npc,player,isPet): st = player.getQuestState(qn) if not st : return if st.getState() != State.STARTED : return npcId = npc.getNpcId() if npcId == 20389 : st.set("id","0") if st.getInt("cond") and st.getQuestItemsCount(SILVERYS_RING) == 1 and st.getQuestItemsCount(RATMAN_TOOTH) < 10 : if st.getRandom(10) < 7 : if st.getQuestItemsCount(RATMAN_TOOTH) == 9 and st.getQuestItemsCount(BIG_RATMAN_TOOTH) == 2 : st.giveItems(RATMAN_TOOTH,1) st.playSound("ItemSound.quest_middle") st.set("cond","2") else: st.giveItems(RATMAN_TOOTH,1) st.playSound("ItemSound.quest_itemget") elif npcId == 20390 : st.set("id","0") if st.getInt("cond") and st.getQuestItemsCount(SILVERYS_RING) == 1 and st.getQuestItemsCount(BIG_RATMAN_TOOTH) < 2 : if st.getRandom(10) < 5 : if st.getQuestItemsCount(BIG_RATMAN_TOOTH) == 1 and st.getQuestItemsCount(RATMAN_TOOTH) == 10 : st.giveItems(BIG_RATMAN_TOOTH,1) st.playSound("ItemSound.quest_middle") st.set("cond","2") else: st.giveItems(BIG_RATMAN_TOOTH,1) st.playSound("ItemSound.quest_itemget") elif npcId == 20017 : st.set("id","0") if st.getInt("cond") and st.getQuestItemsCount(FOOTPRINT) == 1 and st.getQuestItemsCount(SECRET_BOX1) < 1 : if st.getRandom(10) < 2 : st.giveItems(SECRET_BOX1,1) st.playSound("ItemSound.quest_middle") st.set("cond","6") return QUEST = Quest(418,qn,"uK")
|
def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr) self.questItemIds = range(1632, 1635) + range(1636,1642) + [1622, 1623] def onEvent (self,event,st): htmltext = event player = st.getPlayer() if event == "30527_1" : if player.getClassId().getId() != 0x35 : if player.getClassId().getId() == 0x38 : htmltext = "30527-02a.htm" else: htmltext = "30527-02.htm" else: if player.getLevel() < 18 : htmltext = "30527-03.htm" else: if st.getQuestItemsCount(PASS_FINAL) != 0 : htmltext = "30527-04.htm" else: htmltext = "30527-05.htm" return htmltext elif event == "30527_2" : htmltext = "30527-11.htm" st.takeItems(TOTEM_SPIRIT_CLAW,1) st.giveItems(TATARUS_LETTER,1) elif event == "1" : htmltext = "30527-06.htm" st.set("id","0") st.set("cond","1") st.setState(State.STARTED) st.playSound("ItemSound.quest_accept") st.giveItems(SILVERYS_RING,1) elif event == "a" : htmltext = "30527-08a.htm" st.takeItems(SILVERYS_RING,st.getQuestItemsCount(SILVERYS_RING)) st.takeItems(RATMAN_TOOTH,st.getQuestItemsCount(RATMAN_TOOTH)) st.takeItems(BIG_RATMAN_TOOTH,st.getQuestItemsCount(BIG_RATMAN_TOOTH)) st.giveItems(PASS_1ST,1) st.set("cond","3") st.playSound("ItemSound.quest_accept") elif event == "b" : htmltext = "30527-08b.htm" st.set("cond","8") st.takeItems(SILVERYS_RING,st.getQuestItemsCount(SILVERYS_RING)) st.takeItems(RATMAN_TOOTH,st.getQuestItemsCount(RATMAN_TOOTH)) st.takeItems(BIG_RATMAN_TOOTH,st.getQuestItemsCount(BIG_RATMAN_TOOTH)) st.playSound("ItemSound.quest_accept") elif event == "30317_1" : htmltext = "30317-02.htm" elif event == "30317_2" : htmltext = "30317-05.htm" elif event == "30317_3" : htmltext = "30317-03.htm" elif event == "30317_4" : htmltext = "30317-04.htm" st.giveItems(KLUTOS_LETTER,1) st.set("cond","4") st.playSound("ItemSound.quest_accept") elif event == "30317_5" : htmltext = "30317-06.htm" elif event == "30317_6" : htmltext = "30317-07.htm" st.giveItems(KLUTOS_LETTER,1) st.set("cond","4") st.playSound("ItemSound.quest_accept") elif event == "30317_7" : if st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(PASS_2ND) and st.getQuestItemsCount(SECRET_BOX2) : htmltext = "30317-10.htm" st.takeItems(PASS_1ST,1) st.takeItems(PASS_2ND,1) st.takeItems(SECRET_BOX2,1) st.giveItems(PASS_FINAL,1) isFinished = st.getGlobalQuestVar("1ClassQuestFinished") if isFinished == "" : st.giveItems(57,81900) st.addExpAndSp(160267,11726) st.set("cond","0") st.exitQuest(False) st.saveGlobalQuestVar("1ClassQuestFinished","1") st.playSound("ItemSound.quest_finish") else : htmltext = "30317-08.htm" elif event == "30317_8" : htmltext = "30317-11.htm" elif event == "30317_9" : if st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(PASS_2ND) and st.getQuestItemsCount(SECRET_BOX2) : htmltext = "30317-12.htm" st.takeItems(PASS_1ST,1) st.takeItems(PASS_2ND,1) st.takeItems(SECRET_BOX2,1) st.giveItems(PASS_FINAL,1) st.giveItems(57,81900) st.addExpAndSp(228064,15075) st.set("cond","0") st.exitQuest(False) st.playSound("ItemSound.quest_finish") else : htmltext = "30317-08.htm" elif event == "30298_1" : htmltext = "30298-02.htm" elif event == "30298_2" : htmltext = "30298-03.htm" st.takeItems(KLUTOS_LETTER,1) st.giveItems(FOOTPRINT,1) st.set("cond","5") st.playSound("ItemSound.quest_accept") elif event == "30298_3" : htmltext = "30298-06.htm" st.takeItems(SECRET_BOX1,1) st.takeItems(FOOTPRINT,1) st.giveItems(SECRET_BOX2,1) st.giveItems(PASS_2ND,1) st.set("cond","7") st.playSound("ItemSound.quest_accept") elif event == "32052_07" : htmltext = "32052-07.htm" st.set("cond","9") st.playSound("ItemSound.quest_accept") elif event == "31963_5" : htmltext = "31963-05.htm" st.giveItems(PASS_FINAL,1) st.set("cond","0") st.exitQuest(False) st.playSound("ItemSound.quest_finish") elif event == "31963_6" : htmltext = "31963-06.htm" st.set("cond","10") st.playSound("ItemSound.quest_accept") elif event == "31963_8" : htmltext = "31963-08.htm" st.set("cond","11") st.playSound("ItemSound.quest_accept") elif event == "32052_13" : htmltext = "32052-13.htm" st.giveItems(PASS_FINAL,1) st.set("cond","0") st.exitQuest(False) st.playSound("ItemSound.quest_finish") elif event == "30531_5" : htmltext = "30531-05.htm" st.giveItems(PASS_FINAL,1) st.set("cond","0") st.exitQuest(False) st.playSound("ItemSound.quest_finish") elif event == "31956_1" : htmltext = "31956-03.htm" st.giveItems(PASS_FINAL,1) st.set("cond","0") st.exitQuest(False) st.playSound("ItemSound.quest_finish") return htmltext def onTalk (self,npc,player): htmltext = "<html><body>ثeSȡAαšC</body></html>" st = player.getQuestState(qn) if not st : return htmltext npcId = npc.getNpcId() id = st.getState() cond = st.getInt("cond") if npcId != 30527 and id != State.STARTED : return htmltext if npcId == 30527 : if cond == 0 : htmltext = "30527-01.htm" elif cond == 1 and st.getQuestItemsCount(SILVERYS_RING) == 1 and (st.getQuestItemsCount(RATMAN_TOOTH)+st.getQuestItemsCount(BIG_RATMAN_TOOTH)) < 12 : htmltext = "30527-07.htm" elif cond == 2 and st.getQuestItemsCount(SILVERYS_RING) == 1 and st.getQuestItemsCount(RATMAN_TOOTH) >= 10 and st.getQuestItemsCount(BIG_RATMAN_TOOTH) >= 2 : htmltext = "30527-08.htm" elif cond == 3 and st.getQuestItemsCount(PASS_1ST) == 1 : htmltext = "30527-09.htm" elif cond == 8 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "30527-09b.htm" elif npcId == 30317 : if cond == 3 and st.getQuestItemsCount(KLUTOS_LETTER) == 0 and st.getQuestItemsCount(FOOTPRINT) == 0 and st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(PASS_2ND) == 0 and st.getQuestItemsCount(SECRET_BOX2) == 0 : htmltext = "30317-01.htm" elif cond == 4 and st.getQuestItemsCount(PASS_1ST) and (st.getQuestItemsCount(KLUTOS_LETTER) or st.getQuestItemsCount(FOOTPRINT)) : htmltext = "30317-08.htm" elif cond == 7 and st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(PASS_2ND) and st.getQuestItemsCount(SECRET_BOX2) : htmltext = "30317-09.htm" elif npcId == 30298 : if cond == 4 and st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(KLUTOS_LETTER) : htmltext = "30298-01.htm" elif cond == 5 and st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(FOOTPRINT) and st.getQuestItemsCount(SECRET_BOX1) == 0 : htmltext = "30298-04.htm" elif cond == 6 and st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(FOOTPRINT) and st.getQuestItemsCount(SECRET_BOX1) : htmltext = "30298-05.htm" elif cond == 7 and st.getQuestItemsCount(PASS_1ST) and st.getQuestItemsCount(PASS_2ND) and st.getQuestItemsCount(SECRET_BOX2) : htmltext = "30298-07.htm" elif npcId == 30531 : if cond == 10 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "30531-01.htm" elif npcId == 31963 : if cond == 9 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "31963-01.htm" elif cond == 10 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "31963-07.htm" elif cond == 11 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "31963-09.htm" elif npcId == 31956 : if cond == 12 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "31956-01.htm" elif npcId == 32052 : if cond == 8 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "32052-01.htm" elif cond == 9 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "32052-08.htm" elif cond == 11 and st.getQuestItemsCount(PASS_1ST) == 0 : htmltext = "32052-09.htm" return htmltext def onKill(self,npc,player,isPet): st = player.getQuestState(qn) if not st : return if st.getState() != State.STARTED : return npcId = npc.getNpcId() if npcId == 20389 : st.set("id","0") if st.getInt("cond") and st.getQuestItemsCount(SILVERYS_RING) == 1 and st.getQuestItemsCount(RATMAN_TOOTH) < 10 : if st.getRandom(10) < 7 : if st.getQuestItemsCount(RATMAN_TOOTH) == 9 and st.getQuestItemsCount(BIG_RATMAN_TOOTH) == 2 : st.giveItems(RATMAN_TOOTH,1) st.playSound("ItemSound.quest_middle") st.set("cond","2") else: st.giveItems(RATMAN_TOOTH,1) st.playSound("ItemSound.quest_itemget") elif npcId == 20390 : st.set("id","0") if st.getInt("cond") and st.getQuestItemsCount(SILVERYS_RING) == 1 and st.getQuestItemsCount(BIG_RATMAN_TOOTH) < 2 : if st.getRandom(10) < 5 : if st.getQuestItemsCount(BIG_RATMAN_TOOTH) == 1 and st.getQuestItemsCount(RATMAN_TOOTH) == 10 : st.giveItems(BIG_RATMAN_TOOTH,1) st.playSound("ItemSound.quest_middle") st.set("cond","2") else: st.giveItems(BIG_RATMAN_TOOTH,1) st.playSound("ItemSound.quest_itemget") elif npcId == 20017 : st.set("id","0") if st.getInt("cond") and st.getQuestItemsCount(FOOTPRINT) == 1 and st.getQuestItemsCount(SECRET_BOX1) < 1 : if st.getRandom(10) < 2 : st.giveItems(SECRET_BOX1,1) st.playSound("ItemSound.quest_middle") st.set("cond","6") return QUEST = Quest(418,qn,"uK")
|
def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr) self.questItemIds = range(1632, 1635) + range(1636,1642) + [1622, 1623]
|
htmltext = "<html><body>You are either not on a quest that involves this NPC, or you don't meet this NPC's minimum quest requirements.</body></html>"
|
htmltext = Quest.getNoQuestMsg(player)
|
def onTalk (self, npc, player) : htmltext = "<html><body>You are either not on a quest that involves this NPC, or you don't meet this NPC's minimum quest requirements.</body></html>" st = player.getQuestState(qn) if not st : return htmltext
|
self.controller.scheduler.pause()
|
self.controller.scheduler.stop()
|
def close_dome (self):
|
def theor_beta_prod(alpha, n, x): norm = float((alpha + 1) ** n) for i in xrange(1, n): norm /= i return norm * x ** alpha * log(1.0 / x) ** (n - 1) for alpha in [0.2, 1, 2, 4]: for n in [2, 3, 5]: d = BetaDistr(alpha + 1, 1) for i in xrange(n - 1): d *= BetaDistr(alpha + 1, 1) figure() demo_distr(d, theoretical = partial(theor_beta_prod, alpha, n)) def theor_quot_power(alpha, x): return (x > 0) * (x <= 1) * (alpha + 1.0) / 2 * x**alpha + (x > 1) * (alpha + 1.0) / 2 * x**(-alpha-2) for alpha in [0.1, 1, 10]:
|
def theor_quot_power2(a, b, m_plus_1, x): m = m_plus_1 - 1 Ay = m_plus_1**2*x**m / ((b1*b2)**m_plus_1) for a1, b1, a2, b2, m in [(1.1, 4, 1, 3, 1)]: assert a1 >= 0 and a2 >= 0 assert b1 > b2 > a1 > a2 assert b1*b2 > b1*a2 > b2*a1 > a1*a2 m += 1 d1 = FunDistr(lambda x: (m+1)*x / (b1**m_plus_1 - a1**m_plus_1), breakPoints=[a1, b1])
|
def theor_beta_prod(alpha, n, x): norm = float((alpha + 1) ** n) for i in xrange(1, n): norm /= i return norm * x ** alpha * log(1.0 / x) ** (n - 1)
|
demo_distr(BetaDistr(alpha + 1, 1) / BetaDistr(alpha + 1, 1), theoretical = partial(theor_quot_power, alpha))
|
print d1.summary() d1.plot()
|
def theor_quot_power(alpha, x): return (x > 0) * (x <= 1) * (alpha + 1.0) / 2 * x**alpha + (x > 1) * (alpha + 1.0) / 2 * x**(-alpha-2)
|
headers += ('lum_V')
|
headers += ('lum_V',)
|
def weightvecs(m1, x1, m2, x2) : return [(x1[0]*m1 + x2[0]*m2)/(m1+m2), (x1[1]*m1 + x2[1]*m2)/(m1+m2), (x1[2]*m1 + x2[2]*m2)/(m1+m2)]
|
def profile(nbins=4, min_radius=0.0534932, bin_type='log', group='All', family='all', center='pot', projection='sph', fit_radius=0., debug_flag = 1) :
|
def profile(nbins=4, min_radius=0.0534932, bin_type='log', group='All', family='all', center='pot', projection='sph', WRITE_TO = 'profile.DAT', fit_radius=0., debug_flag = 1) :
|
def profile(nbins=4, min_radius=0.0534932, bin_type='log', group='All', family='all', center='pot', projection='sph', fit_radius=0., debug_flag = 1) : """Perform the Tipsy profile() function. This version implements: linear and logarithmic binning spherical projections base data fields star data fields currently developing: gas data fields mean mass weighted gas density mass weighted gas temperature mass weighted gas pressure mass weighted gas entropy """ if debug_flag == 1 : import load_meanmwt load_meanmwt.safeload() # min_radius default should be 0., changed for comparison against tipsy # parameters should be reordered at completion of function print '\n' # these should be moved to tipsyf # fn to take the dot product of two vectors in R3 def dotprod(a, b) : return a[0]*b[0] + a[1]*b[1] + a[2]*b[2] # fn to take the cross product of two vectors in R3 def crossprod(a, b) : return [a[1]*b[2] - a[2]*b[1], a[2]*b[0] - a[0]*b[2], a[0]*b[1] - a[1]*b[0]] # fn to multiply a vector v by a scalar c def scalevec(c, v) : return [c * v[0], c * v[1], c * v[2]] # fn to add two vectors def addvec(a, b) : return [a[0] + b[0], a[1] + b[1], a[2] + b[2]] # fn to subtract vector b from vector a def subvec(a, b) : return [a[0] - b[0], a[1] - b[1], a[2] - b[2]] # fn to find the length of a vector def vlength(a) : import math return math.sqrt(pow(a[0], 2) + pow(a[1], 2) + pow(a[2], 2)) # fn to combine two vectors, weighting by their corresponding mass scalars def weightvecs(m1, x1, m2, x2) : return [(x1[0]*m1 + x2[0]*m2)/(m1+m2), (x1[1]*m1 + x2[1]*m2)/(m1+m2), (x1[2]*m1 + x2[2]*m2)/(m1+m2)] # constants (fake since it's Python) WRITE_TO = '../profile.DAT' # output path (should probably parameterize, worry about this later, trivial change) LOG_MIN = 0.01 # alternate min_radius to use if bin_type == 'log' and min_radius == 0 # scrub input # check if simulation loaded, store group list groups = charm.getGroups() if groups == None : raise StandardError('Simulation not loaded') # case is inconsistent between groups and families, work for either if group == 'all' : group = 'All' if family == 'All' : family = 'all' # deal with group or center group does not exist if group not in groups : raise StandardError('Group does not exist!') if (center not in groups) and (center != 'pot') : raise StandardError('Center group does not exist!') # set up families iterator and throw family related exceptions families = charm.getFamilies() if families == None : raise StandardError('Simulation loaded but no families present.') isbaryon = 0 if family == 'baryon' : isbaryon = 1 if 'dark' in families: families.remove('dark') if len(families) == 0 : raise StandardError('No baryon particles present in simulation.') if (family != 'all') and (family != 'baryon') : if family not in families : raise StandardError('Family not present in simulation.') else : families = [family] if len(families) == 0 : raise StandardError('List of families to process has zero length.') # create groups containing one family each, store names in famgroups list famgroups = [] for each in families : famgroup = group + 'FAM' + each charm.createGroup_Family(famgroup, group, each) famgroups += [famgroup] # validate other inputs if bin_type == 'linear' : bin_type = 'lin' elif bin_type == 'logarithmic' : bin_type = 'log' elif bin_type not in ['lin', 'log'] : raise StandardError('Value of bin_type must be lin or log.') if (int(nbins) != nbins) or (nbins < 1) : raise StandardError('Value of nbins must be a positive integer.') if not min_radius >= 0 : raise StandardError('Value of min_radius cannot be negative.') if min_radius == 0 and bin_type == 'log' : min_radius = LOG_MIN print 'Parameter min_radius set to ' + str(LOG_MIN) + ' to accomodate logarithmic binning.' if not fit_radius >= 0 : raise StandardError('Value of fit_radius cannot be negative.') # begin calculating parameters # find center point if center == 'pot' : center = charm.findAttributeMin(group, 'potential') else: center = charm.getCenterOfMass(center) # get center_vel and center_angular_mom # families must be parsed individually then combined vmdata = charm.reduceParticle(famgroups[0], vmmap, vmreduce, None) if vmdata == None : raise StandardError('MapReduce returned NoneType object.') center_vel = vmdata[0][2] center_angular_mom = vmdata[0][3] # if there are additional families, parse each then combine results weighting by mass if len(famgroups) > 1 : old_mass = vmdata[0][1] for i in range(len(famgroups)-1) : vmdata = charm.reduceParticle(famgroups[i+1], vmmap, vmreduce, None) new_mass = vmdata[0][1] center_vel = weightvecs(old_mass, center_vel, new_mass, vmdata[0][2]) center_angular_mom = weightvecs(old_mass, center_angular_mom, new_mass, vmdata[0][3]) old_mass += new_mass # for an elliptical projection, use Katz to get shape & then find vel, mom # when restoring this, find out what happened to center_ell? if projection == 'ell' : # shape = tipsyf.find_shape(group, family, center, fit_radius) # if len(shape) < 6 : # print 'Katz algorithm failed to find shape for elliptical projection!' # return # else : # ba, ca, phi, theta, psi, ell_matrix = shape # print 'b/a = ' + str(ba) + ' c/a = ' + str(ca) # center_vel, center_angular_mom = tipsyf.find_vel(group, family, center, fit_radius, ell_matrix, ba, ca) print 'projection == ell for some reason' else : ba, ca, phi, theta, psi, center_ell, ell_matrix = (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) # find max_radius # maxradmap iterates over all particles and compares each radius to the previous max found p_param = (center) max_radius = 0. if family == 'all' : max_radius = charm.reduceParticle(group, maxradmap, maxradreduce, p_param)[0][1] else : for i in range(len(famgroups)) : fam_radius = charm.reduceParticle(famgroups[i], maxradmap, maxradreduce, p_param)[0][1] max_radius = max(max_radius, fam_radius) # TIPSY uses an approximation for max_radius which can't be adequately emulated here. # for the run99 data file, the value of max_radius is known; set it manually. # remove when done debugging. if debug_flag == 1 : max_radius = 8.18829 # determine bin_size # if min_radius > 0, then bin 0 should have the specified radius. # other than this exception, all bins have constant size in either lin or log space as specified if min_radius > max_radius and nbins > 1 : raise StandardException('Value for min_radius encompasses all particles; cannot bin data.') # min_radius > 0 case creates a scenario where nbins = 1 would create a /0 error, must handle here. if nbins == 1 : bin_size = max_radius # bin_type and min_radius are superfluous to nbins = 1 case bin_type = 'lin' min_radius = 0. # find size in lin space elif bin_type == 'lin' : if min_radius > 0. : bin_size = (max_radius - min_radius) / float(nbins - 1) else : bin_size = (max_radius - min_radius) / float(nbins) # find size in log space else : min_radius = math.log10(min_radius) bin_size = (math.log10(max_radius) - min_radius) / float(nbins - 1) # calculate bin boundary radii bounds = [0.] * (nbins + 1) # the first boundary radius is affected by min_radius, handle if bin_type == 'lin' and min_radius == 0.: bounds[1] = bin_size else : bounds[1] = min_radius # each following bound should be bound[previous] + bin_size for i in range(2, nbins + 1) : bounds[i] = bounds[i - 1] + bin_size # if logarithmic binning, convert values into linear space if bin_type == 'log' : for i in range(1, nbins + 1) : bounds[i] = pow(10., bounds[i]) # constants # msolunit = 1.e12 # mass scale # kpcunit = 1. # distance scale # fhydrogen = 0.76 # fraction of gas as hydrogen # KPCCM = 3.085678e21 # kiloparsec in centimeters # GCGS = 6.67e-8 # G in cgs # MSOLG = 1.99e33 # solar mass in grams # GYRSEC = 3.155693e16 # gigayear in seconds age = [ .01, .02, .05, .1, .2, .5, 1., 2., 5., 10., 20.] lum = [.0635, .0719, .0454, .153, .293, .436, .636, .898, 1.39, 2.54, 5.05] vv_dat = [ -.01, -.02, -.01, 0., -.01, -.01, -.01, 0., 0., .01, .01] bv_dat = [ -.02, -.33, 0., .19, .04, .1, .18, .31, .42, .75, .84] uv_dat = [ .16, -.12, .84, .97, .83, 1.08, 1.24, 1.39, 1.51, 2.22, 2.50] uuv_dat = [ -.32, -.21, 1.68, 1.67, 1.75, 2.62, 3.50, 4.70, 6.30, 8.86, 9.97] n = 11 lumv_fit = [None] * n vv_fit = [None] * n bv_fit = [None] * n uv_fit = [None] * n uuv_fit = [None] * n spline.splinit( age, lum, lumv_fit, n, 0., 0. ) spline.splinit( age, vv_dat, vv_fit, n, 0., 0. ) spline.splinit( age, bv_dat, bv_fit, n, 0., 0. ) spline.splinit( age, uv_dat, uv_fit, n, 0., 0. ) spline.splinit( age, uuv_dat, uuv_fit, n, 0., 0. ) # time_unit = math.sqrt(pow(kpcunit*KPCCM, 3.) / (GCGS*msolunit*MSOLG)) / GYRSEC sim_time = charm.getTime() # do calculations which must see individual particles. # the set of attributes on a particle varies by family, so each family must be processed seperately params = [None, isbaryon, bounds, projection, nbins, bin_type, bin_size, min_radius, max_radius, center, center_vel, ba, ca, config.msolunit, config.gasconst, sim_time, config.time_unit, age, lum, lumv_fit, vv_dat, vv_fit, bv_dat, bv_fit] fam_data = [None] * len(famgroups) for i in range(len(famgroups)) : params[0] = families[i] fam_data[i] = charm.reduceParticle(famgroups[i], basemap, basereduce, tuple(params)) if debug_flag == 1 : print '\nThe current family is: ' + families[i] for line in fam_data[i] : print line if len(fam_data) < 1 or fam_data == None : raise StandardException('MapReduce for fam_data has length zero or is NoneType.') # sum results into one list. # Note that if a bin has no particles, it will be missing from the reduce result. data[] should have no missing rows. # values are: bin, number, mass, vel_radial, vel_radial_sigma, vel_tang_sigma, angular_mom[x,y,z], lum, density, temp, pressure, entropy, gas_mass data = [None] * nbins for i in range(nbins) : data[i] = [i, 0, 0., 0., 0., 0., [0., 0., 0.], 0., 0., 0., 0., 0., 0.] for fam in fam_data : for row in fam : bin = row[0] # merge fields 0 thru 5 for i in range(1, 6) : data[bin][i] += row[i] # merge field 6 (angular momentum vector) for i in range(3) : data[bin][6][i] += row[6][i] # merge fields 7 thru 12 for i in range(7, 13) : data[bin][i] += row[i] if not len(data) == nbins : raise StandardError('nbins != length of result after basemap') # calculate remaining "base" values that did not need to be handled in the map mass_r = 0. for i in range(nbins) : # get max radius, min radius, and mean radius r_max = bounds[i + 1] r_min = bounds[i] r_mean = (r_max + r_min) / 2. # number of particles in bin number = data[i][1] # if the bin is empty then some calculations e.g. 1/mass will explode; catch these. if number != 0 : # find volume by projection pi = 3.141592653589793 if projection == 'ell' : volume = 4. * ba * ca / 3. * pi * (pow((r_max),3) - pow((r_min),3)) elif projection == 'cyl' : volume = pi * (pow((r_max),2) - pow((r_min),2)) else : volume = (4. / 3.) * pi * (pow(r_max,3) - pow(r_min,3)) # unpack values. deal with non-sum calculations, largely n / mass mass = data[i][2] mass_r += mass vel_radial = data[i][3] / mass vel_radial_sigma = data[i][4] / mass if vel_radial_sigma > pow(vel_radial, 2) : vel_radial_sigma = math.sqrt(vel_radial_sigma - pow(vel_radial, 2)) else : vel_radial_sigma = 0. if mass > 0. : vel_tang_sigma = math.sqrt(data[i][5] / mass) ang_mom = scalevec(1./mass, data[i][6]) ang = vlength(ang_mom) if ang > 0.0 : ang_theta = 180.0 * math.acos(ang_mom[2] / ang) / pi else : ang_theta = 0.0 ang_phi = 180.0 * math.atan2(ang_mom[1], ang_mom[0]) / pi rho = mass / volume vel_circ = ang / r_mean c_vel = math.sqrt(mass_r / r_max) # star stuff lum_den = data[i][7] / volume # gas stuff if 'gas' in families : density = data[i][8] / data[i][12] temp = data[i][9] / data[i][12] pressure = data[i][10] / data[i][12] entropy = data[i][11] / data[i][12] else : density = 0. temp = 0. pressure = 0. entropy = -config.HUGE data[i] = [r_max, number, rho, mass_r, c_vel, vel_radial, vel_radial_sigma, vel_circ, vel_tang_sigma, ang, ang_theta, ang_phi, density, temp, pressure, entropy, lum_den] else : data[i] = [r_max, 0, 0., mass_r, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.] # build header row # may need to update the exact text used for clarity or for consistency with TIPSY headers = ('radius', 'number', 'rho', 'mass_r', 'c_vel', 'vel_radial', 'vel_radial_sigma', 'vel_circ', 'vel_tang_sigma', 'ang', 'ang_theta', 'ang_phi') gasheaders = ('mmwg_density', 'mwg_temp', 'mwg_pres', 'mwg_entr') starheaders = ('lum_V') if debug_flag == 1 : print '\nFinal data' for line in data : print line # write output to file f = open(WRITE_TO, 'w') # write headers according to families present # ADD ME # write data according to families present for i in range(nbins) : f.write('%g %d %g %g %g %g %g %g %g %g %g %g' % tuple(data[i][0:12])) if 'gas' in families : f.write(' %g %g %g %g' % tuple(data[i][12:16])) if 'star' in families : f.write(' %g' % tuple(data[i][16:17])) f.write('\n') f.close() # clean up created groups # *** requires adding a charm.deleteGroup() method *** # for each in famgroups : # charm.deleteGroup(each)
|
WRITE_TO = '../profile.DAT'
|
def weightvecs(m1, x1, m2, x2) : return [(x1[0]*m1 + x2[0]*m2)/(m1+m2), (x1[1]*m1 + x2[1]*m2)/(m1+m2), (x1[2]*m1 + x2[2]*m2)/(m1+m2)]
|
|
num = len(p.list)
|
num = 0
|
basereduce = """def localparticle(p): # sum values used for calculation of base fields to get per-bin results bin = p.list[0][0] num = len(p.list) mass = 0. vel_radial = 0. vel_radial_sigma = 0. vel_tang_sigma = 0. ang_mom = [0., 0., 0.] radius = 0. lum = 0. density = 0. temp = 0. pressure = 0. entropy = 0. gas_mass = 0. for i in range(num) : mass += p.list[i][2] vel_radial += p.list[i][3] vel_radial_sigma += p.list[i][4] vel_tang_sigma += p.list[i][5] ang_mom[0] += p.list[i][6][0] ang_mom[1] += p.list[i][6][1] ang_mom[2] += p.list[i][6][2] lum += p.list[i][7] density += p.list[i][8] temp += p.list[i][9] pressure += p.list[i][10] entropy += p.list[i][11] gas_mass += p.list[i][12] return (bin, num, mass, vel_radial, vel_radial_sigma, vel_tang_sigma, ang_mom, lum, density, temp, pressure, entropy, gas_mass)
|
for i in range(num) :
|
for i in range(len(p.list)) : num += p.list[i][1]
|
basereduce = """def localparticle(p): # sum values used for calculation of base fields to get per-bin results bin = p.list[0][0] num = len(p.list) mass = 0. vel_radial = 0. vel_radial_sigma = 0. vel_tang_sigma = 0. ang_mom = [0., 0., 0.] radius = 0. lum = 0. density = 0. temp = 0. pressure = 0. entropy = 0. gas_mass = 0. for i in range(num) : mass += p.list[i][2] vel_radial += p.list[i][3] vel_radial_sigma += p.list[i][4] vel_tang_sigma += p.list[i][5] ang_mom[0] += p.list[i][6][0] ang_mom[1] += p.list[i][6][1] ang_mom[2] += p.list[i][6][2] lum += p.list[i][7] density += p.list[i][8] temp += p.list[i][9] pressure += p.list[i][10] entropy += p.list[i][11] gas_mass += p.list[i][12] return (bin, num, mass, vel_radial, vel_radial_sigma, vel_tang_sigma, ang_mom, lum, density, temp, pressure, entropy, gas_mass)
|
print paragraphs
|
def format_description(self, description, width=None): # textwrap doesn't allow for a way to preserve double newlines # to separate paragraphs, so we do it here. paragraphs = description.split('\n\n') print paragraphs rets = []
|
|
self.debug('parse_args called')
|
self.debug('called parse_args')
|
def parse(self, argv): """ Parse the given arguments and act on them.
|
print(argc)
|
def parse_params(): global VERBOSE, QUIET, SHENIDAM, FFMPEG, SHENIDAM_PARAMS, TRANSCODE_BASE, OUTPUT_PATTERN, BASE_FN, AUDIO_EXPORT_PARAMS, AUDIO_REMIX_PARAMS, SHENIDAM_PARAMS, TEMP_DIR, AUDIO_ONLY; argv = sys.argv argc = len(argv) i = 1 print(argc) while i < argc: arg = argv[i].strip() i+=1 if arg == "-v" or arg == "--verbose": VERBOSE = True if arg == "-a" or arg == "--audio-only": AUDIO_ONLY = True elif arg == "-q" or arg == "--quiet": QUIET = True elif arg == "-se" or arg == "--shenidam-executable": if i >= argc: return 1 SHENIDAM = argv[i].strip() i+=1; elif arg == "-fe" or arg == "--ffmpeg-executable": if i >= argc: return 1; FFMPEG = argv[i].strip() i+=1 elif arg == "-tb" or arg == "--transcode-base": TRANSCODE_BASE = True elif arg == "-sp" or arg == "--shenidam-params": if i >= argc: return 1; SHENIDAM_PARAMS = argv[i].strip() i+=1 elif arg == "-ntb" or arg == "--no-transcode-base": TRANSCODE_BASE = False elif arg == "-o" or arg == "--output": if i >= argc: return 1; OUTPUT_PATTERN = argv[i].strip() i+=1 elif arg == "-b" or arg == "--base": if i >= argc: return 1; BASE_FN = argv[i].strip() i+=1 elif arg == "-aep" or arg == "--audio-export-params": if i >= argc: return 1; AUDIO_EXPORT_PARAMS = argv[i].strip() i+=1 elif arg == "-arp" or arg == "--audio-remix-params": if i >= argc: return 1; AUDIO_REMIX_PARAMS = argv[i].strip() i+=1 elif arg == "-sp" or arg == "--shenidam-params": if i >= argc: return 1; SHENIDAM_PARAMS = argv[i].strip() i+=1 elif arg == "-td" or arg == "--temporary-directory": if i >= argc: return 1; TEMP_DIR = argv[i].strip() i+=1 else: i-=1; break; print(i) if i == argc: return 1; for j in range(i,argc): INPUT_TRACKS.append(argv[j].strip()) return 0;
|
|
print(i)
|
def parse_params(): global VERBOSE, QUIET, SHENIDAM, FFMPEG, SHENIDAM_PARAMS, TRANSCODE_BASE, OUTPUT_PATTERN, BASE_FN, AUDIO_EXPORT_PARAMS, AUDIO_REMIX_PARAMS, SHENIDAM_PARAMS, TEMP_DIR, AUDIO_ONLY; argv = sys.argv argc = len(argv) i = 1 print(argc) while i < argc: arg = argv[i].strip() i+=1 if arg == "-v" or arg == "--verbose": VERBOSE = True if arg == "-a" or arg == "--audio-only": AUDIO_ONLY = True elif arg == "-q" or arg == "--quiet": QUIET = True elif arg == "-se" or arg == "--shenidam-executable": if i >= argc: return 1 SHENIDAM = argv[i].strip() i+=1; elif arg == "-fe" or arg == "--ffmpeg-executable": if i >= argc: return 1; FFMPEG = argv[i].strip() i+=1 elif arg == "-tb" or arg == "--transcode-base": TRANSCODE_BASE = True elif arg == "-sp" or arg == "--shenidam-params": if i >= argc: return 1; SHENIDAM_PARAMS = argv[i].strip() i+=1 elif arg == "-ntb" or arg == "--no-transcode-base": TRANSCODE_BASE = False elif arg == "-o" or arg == "--output": if i >= argc: return 1; OUTPUT_PATTERN = argv[i].strip() i+=1 elif arg == "-b" or arg == "--base": if i >= argc: return 1; BASE_FN = argv[i].strip() i+=1 elif arg == "-aep" or arg == "--audio-export-params": if i >= argc: return 1; AUDIO_EXPORT_PARAMS = argv[i].strip() i+=1 elif arg == "-arp" or arg == "--audio-remix-params": if i >= argc: return 1; AUDIO_REMIX_PARAMS = argv[i].strip() i+=1 elif arg == "-sp" or arg == "--shenidam-params": if i >= argc: return 1; SHENIDAM_PARAMS = argv[i].strip() i+=1 elif arg == "-td" or arg == "--temporary-directory": if i >= argc: return 1; TEMP_DIR = argv[i].strip() i+=1 else: i-=1; break; print(i) if i == argc: return 1; for j in range(i,argc): INPUT_TRACKS.append(argv[j].strip()) return 0;
|
|
rospy.loginfo("Waiting for %s_controller init...", component_name)
|
rospy.loginfo("Initialize <<%s>>", component_name) rospy.loginfo("Waiting for <<%s>> to be initialized...", component_name)
|
def Init(self,component_name): rospy.loginfo("Waiting for %s_controller init...", component_name) service_name = component_name + "_controller/Init" try: rospy.wait_for_service(service_name,rospy.get_param('server_timeout',1)) except rospy.ROSException, e: print "Service not available: %s"%e return False try: init = rospy.ServiceProxy(service_name,Trigger) print init() except rospy.ServiceException, e: print "Service call failed: %s"%e return False return True
|
print init()
|
init()
|
def Init(self,component_name): rospy.loginfo("Waiting for %s_controller init...", component_name) service_name = component_name + "_controller/Init" try: rospy.wait_for_service(service_name,rospy.get_param('server_timeout',1)) except rospy.ROSException, e: print "Service not available: %s"%e return False try: init = rospy.ServiceProxy(service_name,Trigger) print init() except rospy.ServiceException, e: print "Service call failed: %s"%e return False return True
|
time.sleep(1)
|
def __init__(self): self.ns_global_prefix = "/script_server" self.move_action_server = actionlib.SimpleActionServer(self.ns_global_prefix, MoveAction, self.execute_cb) time.sleep(1)
|
|
server_result.return_value = self.sss.move(server_goal.component_name.data,server_goal.parameter_name.data)
|
handle01 = self.sss.move(server_goal.component_name,server_goal.parameter_name)
|
def execute_cb(self, server_goal): server_result = MoveActionResult().result server_result.return_value = self.sss.move(server_goal.component_name.data,server_goal.parameter_name.data) if server_result.return_value == 0: print "success" self.move_action_server.set_succeeded(server_result) else: print "error" self.move_action_server.set_aborted(server_result)
|
print "success"
|
rospy.logdebug("action result success")
|
def execute_cb(self, server_goal): server_result = MoveActionResult().result server_result.return_value = self.sss.move(server_goal.component_name.data,server_goal.parameter_name.data) if server_result.return_value == 0: print "success" self.move_action_server.set_succeeded(server_result) else: print "error" self.move_action_server.set_aborted(server_result)
|
print "error"
|
rospy.logerror("action result error")
|
def execute_cb(self, server_goal): server_result = MoveActionResult().result server_result.return_value = self.sss.move(server_goal.component_name.data,server_goal.parameter_name.data) if server_result.return_value == 0: print "success" self.move_action_server.set_succeeded(server_result) else: print "error" self.move_action_server.set_aborted(server_result)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.