diff --git a/ports/bochs/port.script b/ports/bochs/port.script new file mode 100644 index 0000000..488c656 --- /dev/null +++ b/ports/bochs/port.script @@ -0,0 +1,31 @@ +#import "util/get_source.script" get_source; + +str targetName #option; +str toolchainPrefix #option; +int processorCount #option; + +void Start() { + str rootDirectory = PathGetDefaultPrefix() + "/root"; + str version = "2.6.9"; + if processorCount == 0 processorCount = SystemGetProcessorCount(); + get_source.Get("https://netix.dl.sourceforge.net/project/bochs/bochs/%version%/bochs-%version%.tar.gz", "bochs-%version%", + "ee5b677fd9b1b9f484b5aeb4614f43df21993088c0c0571187f93acb0866e98c"); + assert FileCopy("ports/bochs/config.cc", "bin/source/config.cc"); + assert FileCopy("ports/bochs/config.h.in", "bin/source/config.h.in"); + assert FileCopy("ports/bochs/configure.in", "bin/source/configure.in"); + assert FileCopy("ports/bochs/main.cc", "bin/source/main.cc"); + assert FileCopy("ports/bochs/Makefile.in", "bin/source/Makefile.in"); + assert FileCopy("ports/bochs/plugin.cc", "bin/source/plugin.cc"); + assert FileCopy("ports/bochs/plugin.h", "bin/source/plugin.h"); + assert FileCopy("ports/bochs/essence.cc", "bin/source/gui/essence.cc"); + assert FileCopy("ports/bochs/gui_Makefile.in", "bin/source/gui/Makefile.in"); + assert SystemShellExecuteWithWorkingDirectory("bin/source", "autoconf"); + assert SystemShellExecuteWithWorkingDirectory("bin/source", + "./configure --with-essence CC=%toolchainPrefix%-gcc CXX=%toolchainPrefix%-g++ " + + "CFLAGS=\" -O2 -D_GNU_SOURCE \" CXXFLAGS=\" -O2 -D_GNU_SOURCE \" " + + "--host=%toolchainPrefix% --prefix=\"/Applications/POSIX\" --exec-prefix=\"/Applications/POSIX\" " + + "--enable-cpu-level=6 --enable-x86-64 --enable-all-optimizations"); + assert SystemShellExecuteWithWorkingDirectory("bin/source", "make -j %processorCount%"); + assert SystemShellExecuteWithWorkingDirectory("bin/source", "make DESTDIR=%rootDirectory% install"); + PathDeleteRecursively("bin/source"); +} diff --git a/ports/bochs/port.sh b/ports/bochs/port.sh deleted file mode 100755 index 6fddced..0000000 --- a/ports/bochs/port.sh +++ /dev/null @@ -1,27 +0,0 @@ -set -e - -SYSROOT=`realpath root` -VERSION=2.6.9 - -bin/script util/get_source.script checksum=ee5b677fd9b1b9f484b5aeb4614f43df21993088c0c0571187f93acb0866e98c directoryName=bochs-$VERSION url=https://netix.dl.sourceforge.net/project/bochs/bochs/$VERSION/bochs-$VERSION.tar.gz -cd bin/source - -cp ../../ports/bochs/config.cc . -cp ../../ports/bochs/config.h.in . -cp ../../ports/bochs/configure.in . -cp ../../ports/bochs/main.cc . -cp ../../ports/bochs/Makefile.in . -cp ../../ports/bochs/plugin.cc . -cp ../../ports/bochs/plugin.h . -cp ../../ports/bochs/essence.cc gui -cp ../../ports/bochs/gui_Makefile.in gui/Makefile.in - -autoconf -./configure --with-essence CC=x86_64-essence-gcc CXX=x86_64-essence-g++ CFLAGS=" -O2 -D _GNU_SOURCE " CXXFLAGS=" -O2 -D _GNU_SOURCE " --host=x86_64-essence --prefix=/Applications/POSIX --exec-prefix=/Applications/POSIX --enable-cpu-level=6 --enable-x86-64 --enable-all-optimizations -# ./configure --with-essence CC=x86_64-essence-gcc CXX=x86_64-essence-g++ CFLAGS=" -g -D _GNU_SOURCE " CXXFLAGS=" -g -D _GNU_SOURCE " --host=x86_64-essence --prefix=/Applications/POSIX --exec-prefix=/Applications/POSIX --enable-cpu-level=6 --enable-x86-64 -make -j 4 -make DESTDIR=$SYSROOT install -echo Built Bochs without error. - -cd ../.. -rm -r bin/source diff --git a/ports/busybox/port.script b/ports/busybox/port.script new file mode 100644 index 0000000..9c51449 --- /dev/null +++ b/ports/busybox/port.script @@ -0,0 +1,25 @@ +#import "util/get_source.script" get_source; + +str targetName #option; +str toolchainPrefix #option; +int processorCount #option; + +void Start() { + str rootDirectory = PathGetDefaultPrefix() + "/root"; + str version = "1.33.1"; + if processorCount == 0 processorCount = SystemGetProcessorCount(); + + if StringTrim(SystemShellEvaluate("uname")) == "Darwin" { + SystemSetEnvironmentVariable("PATH", "/usr/local/opt/gnu-sed/libexec/gnubin:" + SystemGetEnvironmentVariable("PATH")); + } + + get_source.Get("https://www.busybox.net/downloads/busybox-%version%.tar.bz2", "busybox-%version%", + "12cec6bd2b16d8a9446dd16130f2b92982f1819f6e1c5f5887b6db03f5660d28"); + assert FileCopy("ports/busybox/config", "bin/source/.config"); + assert SystemShellExecuteWithWorkingDirectory("bin/source", "sed -i \"51 i CONFIG_SYSROOT=\\\"%rootDirectory%\\\"\" .config"); + assert SystemShellExecuteWithWorkingDirectory("bin/source", "make -j %processorCount%"); + assert FileCopy("bin/source/busybox", "%rootDirectory%/Applications/POSIX/bin/busybox"); + assert FileCopy("bin/source/LICENSE", "bin/BusyBox License.txt"); + + PathDeleteRecursively("bin/source"); +} diff --git a/ports/busybox/port.sh b/ports/busybox/port.sh deleted file mode 100755 index 851fe39..0000000 --- a/ports/busybox/port.sh +++ /dev/null @@ -1,17 +0,0 @@ -set -e - -SYSROOT=`realpath root` -VERSION=1.33.1 - -uname -a | grep Darwin && PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH" - -bin/script util/get_source.script checksum=12cec6bd2b16d8a9446dd16130f2b92982f1819f6e1c5f5887b6db03f5660d28 directoryName=busybox-$VERSION url=https://www.busybox.net/downloads/busybox-$VERSION.tar.bz2 -cd bin/source -cp ../../ports/busybox/config .config -sed -i "51 i CONFIG_SYSROOT=\"$SYSROOT\"" .config - -make -j `nproc` -cp busybox $SYSROOT/Applications/POSIX/bin -cp LICENSE ../BusyBox\ License.txt -cd ../.. -rm -r bin/source diff --git a/ports/gcc/port.script b/ports/gcc/port.script index 513ad18..a226eed 100644 --- a/ports/gcc/port.script +++ b/ports/gcc/port.script @@ -22,6 +22,9 @@ bool ConsoleGetYes() { } void Start() { + assert targetName != ""; + assert toolchainPrefix != ""; + if buildCross { // Print instructions. PrintStdErr("To build Essence, you need a cross compiler. This will be built for you automatically.\n"); @@ -44,8 +47,6 @@ void Start() { if gmpVersion == "" gmpVersion = "6.2.1"; if mpfrVersion == "" mpfrVersion = "4.1.0"; if mpcVersion == "" mpcVersion = "1.2.1"; - if targetName == "" targetName = "x86_64"; - if toolchainPrefix == "" toolchainPrefix = "x86_64-essence"; // Get the number of processors to compile with. if processorCount == 0 { diff --git a/util/build.c b/util/build.c index 1db36b9..9d09c54 100644 --- a/util/build.c +++ b/util/build.c @@ -1139,7 +1139,7 @@ void DoCommand(const char *l) { LoadOptions(); Compile(COMPILE_FOR_EMULATOR, atoi(GetOptionString("Emulator.PrimaryDriveMB")), NULL); } else if (0 == strcmp(l, "build-cross")) { - CallSystem("bin/script ports/gcc/port.script buildCross=true"); + CallSystem("bin/script ports/gcc/port.script buildCross=true targetName=" TARGET_NAME " toolchainPrefix=" TOOLCHAIN_PREFIX); printf("Please restart the build system.\n"); exit(0); } else if (0 == strcmp(l, "build-utilities") || 0 == strcmp(l, "u")) { @@ -1319,7 +1319,7 @@ void DoCommand(const char *l) { fprintf(stderr, "build-optional-ports: Calling \"ports/%s/port.sh\"...\n", entry->d_name); CallSystemF("ports/%s/port.sh", entry->d_name); fprintf(stderr, "build-optional-ports: Calling \"bin/script ports/%s/port.script\"...\n", entry->d_name); - CallSystemF("bin/script ports/%s/port.script", entry->d_name); + CallSystemF("bin/script ports/%s/port.script targetName=" TARGET_NAME " toolchainPrefix=" TOOLCHAIN_PREFIX, entry->d_name); } closedir(directory); @@ -1477,7 +1477,7 @@ void DoCommand(const char *l) { int status; if (f) status = CallSystemF("ports/%s/port.sh", l2); - else status = CallSystemF("bin/script ports/%s/port.script", l2); + else status = CallSystemF("bin/script ports/%s/port.script targetName=" TARGET_NAME " toolchainPrefix=" TOOLCHAIN_PREFIX, l2); if (!alreadyNamedPort) { free(l2); @@ -1544,9 +1544,9 @@ void DoCommand(const char *l) { AddCompilerToPath(); #else if (automatedBuild) { - CallSystem("bin/script ports/gcc/port.script buildCross=true skipYesChecks=true"); + CallSystem("bin/script ports/gcc/port.script buildCross=true skipYesChecks=true targetName=" TARGET_NAME " toolchainPrefix=" TOOLCHAIN_PREFIX); } else { - CallSystem("bin/script ports/gcc/port.script buildCross=true"); + CallSystem("bin/script ports/gcc/port.script buildCross=true targetName=" TARGET_NAME " toolchainPrefix=" TOOLCHAIN_PREFIX); } exit(0);