diff --git a/CMakeLists.txt b/CMakeLists.txt index 1777b63e..7c0c1f2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,23 +10,23 @@ project(Luna LANGUAGES C CXX ASM ASM_NASM VERSION 0.1.0) set(LUNA_ROOT ${CMAKE_CURRENT_LIST_DIR}) set(LUNA_BASE ${CMAKE_CURRENT_LIST_DIR}/base) -set(ARCH $ENV{ARCH}) +set(LUNA_ARCH $ENV{LUNA_ARCH}) -if(NOT DEFINED ARCH) -set(ARCH "x86_64") +if(NOT DEFINED LUNA_ARCH) +set(LUNA_ARCH "x86_64") endif() -set(CMAKE_C_COMPILER ${ARCH}-luna-gcc) -set(CMAKE_CXX_COMPILER ${ARCH}-luna-g++) -set(CMAKE_ASM_COMPILER ${ARCH}-luna-gcc) +set(CMAKE_C_COMPILER ${LUNA_ARCH}-luna-gcc) +set(CMAKE_CXX_COMPILER ${LUNA_ARCH}-luna-g++) +set(CMAKE_ASM_COMPILER ${LUNA_ARCH}-luna-gcc) set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64) -set(CMAKE_ASM_NASM_LINK_EXECUTABLE "${ARCH}-luna-ld -o ") +set(CMAKE_ASM_NASM_LINK_EXECUTABLE "${LUNA_ARCH}-luna-ld -o ") -set(CMAKE_FIND_ROOT_PATH ${LUNA_ROOT}/toolchain/${ARCH}-luna) +set(CMAKE_FIND_ROOT_PATH ${LUNA_ROOT}/toolchain/${LUNA_ARCH}-luna) -message(STATUS "Configuring Luna for ${ARCH}") +message(STATUS "Configuring Luna for ${LUNA_ARCH}") add_subdirectory(luna) add_subdirectory(libc) diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index 7e67fbbd..fe25dd0a 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -26,7 +26,7 @@ set(SOURCES src/ELF.cpp ) -if("${ARCH}" MATCHES "x86_64") +if("${LUNA_ARCH}" MATCHES "x86_64") set(SOURCES ${SOURCES} src/arch/x86_64/IO.cpp @@ -43,7 +43,7 @@ endif() add_executable(moon ${SOURCES}) -if("${ARCH}" MATCHES "x86_64") +if("${LUNA_ARCH}" MATCHES "x86_64") set(ASM_SOURCES src/arch/x86_64/CPU.asm src/arch/x86_64/Entry.asm @@ -66,7 +66,7 @@ target_compile_options(moon PRIVATE -fno-rtti -ffreestanding -fno-exceptions) target_compile_options(moon PRIVATE -fno-asynchronous-unwind-tables -fno-omit-frame-pointer) target_compile_options(moon PRIVATE -nostdlib -mcmodel=kernel) -if("${ARCH}" MATCHES "x86_64") +if("${LUNA_ARCH}" MATCHES "x86_64") target_compile_options(moon PRIVATE -mno-red-zone) target_compile_options(moon PRIVATE -mno-80387 -mno-mmx -mno-sse -mno-sse2) target_link_options(moon PRIVATE -mno-red-zone) diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index 3a80c95c..efba8728 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -13,14 +13,14 @@ set(SOURCES src/sys/mman.cpp ) -if(${ARCH} STREQUAL "x86_64") +if(${LUNA_ARCH} STREQUAL "x86_64") set(SOURCES ${SOURCES} src/arch/x86_64/syscall.S ) endif() -add_library(crt0 STATIC src/arch/${ARCH}/crt0.S) +add_library(crt0 STATIC src/arch/${LUNA_ARCH}/crt0.S) add_custom_command( TARGET crt0 COMMAND "${CMAKE_COMMAND}" -E copy $ ${LUNA_BASE}/usr/lib/crt0.o diff --git a/luna/CMakeLists.txt b/luna/CMakeLists.txt index f9b6ec72..1b01daf5 100644 --- a/luna/CMakeLists.txt +++ b/luna/CMakeLists.txt @@ -46,7 +46,7 @@ target_compile_options(luna PRIVATE -fno-asynchronous-unwind-tables -fno-omit-fr target_include_directories(luna PUBLIC include/) target_include_directories(luna PUBLIC ${LUNA_BASE}/usr/include) -if("${ARCH}" MATCHES "x86_64") +if("${LUNA_ARCH}" MATCHES "x86_64") target_compile_options(luna-freestanding PRIVATE -mno-red-zone) target_compile_options(luna-freestanding PRIVATE -mno-80387 -mno-mmx -mno-sse -mno-sse2) target_compile_definitions(luna-freestanding PUBLIC ARCH_X86_64) diff --git a/tools/build-debug.sh b/tools/build-debug.sh index e571ff01..d6e05cf6 100755 --- a/tools/build-debug.sh +++ b/tools/build-debug.sh @@ -11,8 +11,8 @@ tools/full-clean.sh tools/install-headers.sh -cmake -S . -B $BUILD_DIR -DMOON_DEBUG_SYMBOLS=ON -DLUNA_DEBUG_SYMBOLS=ON -G "$CMAKE_GEN" -cmake --build $BUILD_DIR -cmake --install $BUILD_DIR +cmake -S . -B $LUNA_BUILD_DIR -DMOON_DEBUG_SYMBOLS=ON -DLUNA_DEBUG_SYMBOLS=ON -G "$LUNA_CMAKE_GENERATOR_NAME" +cmake --build $LUNA_BUILD_DIR +cmake --install $LUNA_BUILD_DIR mkbootimg luna.json Luna.iso diff --git a/tools/build-iso.sh b/tools/build-iso.sh index ee0177dc..406cdb78 100755 --- a/tools/build-iso.sh +++ b/tools/build-iso.sh @@ -9,9 +9,9 @@ tools/setup.sh tools/install-headers.sh -mkdir -p $BUILD_DIR -cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN" -cmake --build $BUILD_DIR -cmake --install $BUILD_DIR +mkdir -p $LUNA_BUILD_DIR +cmake -S . -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME" +cmake --build $LUNA_BUILD_DIR +cmake --install $LUNA_BUILD_DIR mkbootimg luna.json Luna.iso diff --git a/tools/build.sh b/tools/build.sh index f854d8e5..2214c0f4 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -9,6 +9,6 @@ tools/setup.sh tools/install-headers.sh -mkdir -p $BUILD_DIR -cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN" -cmake --build $BUILD_DIR +mkdir -p $LUNA_BUILD_DIR +cmake -S . -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME" +cmake --build $LUNA_BUILD_DIR diff --git a/tools/clean.sh b/tools/clean.sh index 6d9139c6..e147bd45 100755 --- a/tools/clean.sh +++ b/tools/clean.sh @@ -3,6 +3,6 @@ set -e source $(dirname $0)/env.sh -cd $BUILD_DIR +cd $LUNA_BUILD_DIR -$BUILD clean \ No newline at end of file +$LUNA_BUILD clean diff --git a/tools/debug.sh b/tools/debug.sh index 9623df96..210476fd 100755 --- a/tools/debug.sh +++ b/tools/debug.sh @@ -3,4 +3,4 @@ set -e source $(dirname $0)/env.sh -qemu-system-$ARCH -cdrom Luna.iso -smp 1 -m 256M -serial stdio -d int,cpu_reset -s $@ \ No newline at end of file +qemu-system-$LUNA_ARCH -cdrom Luna.iso -smp 1 -m 256M -serial stdio -d int,cpu_reset -s $@ diff --git a/tools/env.sh b/tools/env.sh index 7d4cd8d8..f31e842e 100755 --- a/tools/env.sh +++ b/tools/env.sh @@ -4,16 +4,16 @@ export LUNA_BASE=${LUNA_BASE:-$LUNA_ROOT/base} [ -f "$LUNA_ROOT/env-local.sh" ] && source $LUNA_ROOT/env-local.sh -export ARCH=${ARCH:-x86_64} -export PATH=$LUNA_ROOT/toolchain/$ARCH-luna/bin:$LUNA_ROOT/toolchain/dist:$PATH +export LUNA_ARCH=${LUNA_ARCH:-x86_64} +export PATH=$LUNA_ROOT/toolchain/$LUNA_ARCH-luna/bin:$LUNA_ROOT/toolchain/dist:$PATH if [ "$USE_MAKE" = "1" ] then -export BUILD=make -export CMAKE_GEN="Unix Makefiles" +export LUNA_BUILD=make +export LUNA_CMAKE_GENERATOR_NAME="Unix Makefiles" else -export BUILD=ninja -export CMAKE_GEN="Ninja" +export LUNA_BUILD=ninja +export LUNA_CMAKE_GENERATOR_NAME="Ninja" fi -export BUILD_DIR=$LUNA_ROOT/build/$BUILD-$ARCH +export LUNA_BUILD_DIR=$LUNA_ROOT/build/$LUNA_BUILD-$LUNA_ARCH diff --git a/tools/fast-run.sh b/tools/fast-run.sh index 49f43dd9..74401249 100755 --- a/tools/fast-run.sh +++ b/tools/fast-run.sh @@ -5,4 +5,4 @@ source $(dirname $0)/env.sh cd $LUNA_ROOT -qemu-system-$ARCH -cdrom Luna.iso -smp 1 -m 256M -serial stdio -enable-kvm $@ \ No newline at end of file +qemu-system-$LUNA_ARCH -cdrom Luna.iso -smp 1 -m 256M -serial stdio -enable-kvm $@ diff --git a/tools/full-clean.sh b/tools/full-clean.sh index e4e03188..1f39ad03 100755 --- a/tools/full-clean.sh +++ b/tools/full-clean.sh @@ -3,5 +3,5 @@ set -e source $(dirname $0)/env.sh -rm -rf $BUILD_DIR -mkdir -p $BUILD_DIR \ No newline at end of file +rm -rf $LUNA_BUILD_DIR +mkdir -p $LUNA_BUILD_DIR diff --git a/tools/gdb.sh b/tools/gdb.sh index bae0b3ab..cae9795d 100755 --- a/tools/gdb.sh +++ b/tools/gdb.sh @@ -3,6 +3,6 @@ set -e source $(dirname $0)/env.sh -cd $BUILD_DIR +cd $LUNA_BUILD_DIR -gdb -x $LUNA_ROOT/.gdbconf \ No newline at end of file +gdb -x $LUNA_ROOT/.gdbconf diff --git a/tools/install.sh b/tools/install.sh index 73a507f6..19e997d1 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -5,4 +5,4 @@ source $(dirname $0)/env.sh cd $LUNA_ROOT -cmake --install $BUILD_DIR \ No newline at end of file +cmake --install $LUNA_BUILD_DIR diff --git a/tools/rebuild-iso.sh b/tools/rebuild-iso.sh index 012df09c..f79a1bc8 100755 --- a/tools/rebuild-iso.sh +++ b/tools/rebuild-iso.sh @@ -11,8 +11,8 @@ tools/full-clean.sh tools/install-headers.sh -cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN" -cmake --build $BUILD_DIR -cmake --install $BUILD_DIR +cmake -S . -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME" +cmake --build $LUNA_BUILD_DIR +cmake --install $LUNA_BUILD_DIR mkbootimg luna.json Luna.iso diff --git a/tools/rebuild.sh b/tools/rebuild.sh index 524b7ba1..f3d64d78 100755 --- a/tools/rebuild.sh +++ b/tools/rebuild.sh @@ -11,5 +11,5 @@ tools/full-clean.sh tools/install-headers.sh -cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN" -cmake --build $BUILD_DIR +cmake -S . -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME" +cmake --build $LUNA_BUILD_DIR diff --git a/tools/setup-binutils.sh b/tools/setup-binutils.sh index 9877adc9..d1a389fc 100755 --- a/tools/setup-binutils.sh +++ b/tools/setup-binutils.sh @@ -13,7 +13,7 @@ if [ ! -f toolchain/tarballs/binutils-$LUNA_BINUTILS_VERSION_REQUIRED.tar.xz ]; wget -Otoolchain/tarballs/binutils-$LUNA_BINUTILS_VERSION_REQUIRED.tar.xz https://ftp.gnu.org/gnu/binutils/binutils-$LUNA_BINUTILS_VERSION_REQUIRED.tar.xz fi -rm -rf toolchain/build/binutils-$ARCH +rm -rf toolchain/build/binutils-$LUNA_ARCH rm -rf toolchain/build/binutils-$LUNA_BINUTILS_VERSION_REQUIRED echo Extracting Binutils... @@ -30,9 +30,9 @@ cd - echo Configuring Binutils... -mkdir -p toolchain/build/binutils-$ARCH +mkdir -p toolchain/build/binutils-$LUNA_ARCH -cd toolchain/build/binutils-$ARCH +cd toolchain/build/binutils-$LUNA_ARCH unset CC unset CXX diff --git a/tools/setup-env.sh b/tools/setup-env.sh index d0c9957a..10776d86 100755 --- a/tools/setup-env.sh +++ b/tools/setup-env.sh @@ -4,6 +4,6 @@ source $(dirname $0)/env.sh export LUNA_GCC_VERSION_REQUIRED=12.2.0 export LUNA_BINUTILS_VERSION_REQUIRED=2.39 -export BUILD_PREFIX=$LUNA_ROOT/toolchain/$ARCH-luna -export BUILD_TARGET=$ARCH-luna +export BUILD_PREFIX=$LUNA_ROOT/toolchain/$LUNA_ARCH-luna +export BUILD_TARGET=$LUNA_ARCH-luna export BUILD_SYSROOT=$LUNA_ROOT/base diff --git a/tools/setup-gcc.sh b/tools/setup-gcc.sh index eabde2d8..3c8fda9e 100755 --- a/tools/setup-gcc.sh +++ b/tools/setup-gcc.sh @@ -4,7 +4,7 @@ source $(dirname $0)/setup-env.sh cd $LUNA_ROOT -if [ ! -x $(command -v $ARCH-luna-as) ] +if [ ! -x $(command -v $LUNA_ARCH-luna-as) ] then echo Binutils should be cross-built before GCC. exit 1 @@ -21,7 +21,7 @@ if [ ! -f toolchain/tarballs/gcc-$LUNA_GCC_VERSION_REQUIRED.tar.xz ]; then wget -Otoolchain/tarballs/gcc-$LUNA_GCC_VERSION_REQUIRED.tar.xz https://ftp.gnu.org/gnu/gcc/gcc-$LUNA_GCC_VERSION_REQUIRED/gcc-$LUNA_GCC_VERSION_REQUIRED.tar.xz fi -rm -rf toolchain/build/gcc-$ARCH +rm -rf toolchain/build/gcc-$LUNA_ARCH rm -rf toolchain/build/gcc-$LUNA_GCC_VERSION_REQUIRED echo Extracting GCC... @@ -38,9 +38,9 @@ cd - echo Configuring GCC... -mkdir -p toolchain/build/gcc-$ARCH +mkdir -p toolchain/build/gcc-$LUNA_ARCH -cd toolchain/build/gcc-$ARCH +cd toolchain/build/gcc-$LUNA_ARCH unset CC unset CXX diff --git a/tools/test-binutils.sh b/tools/test-binutils.sh index c0d99acb..90ba52c1 100755 --- a/tools/test-binutils.sh +++ b/tools/test-binutils.sh @@ -2,9 +2,9 @@ set -e source $(dirname $0)/setup-env.sh -if [ -x "$(command -v $ARCH-luna-ar)" ] +if [ -x "$(command -v $LUNA_ARCH-luna-ar)" ] then - if [ "$($ARCH-luna-ar --version | head -n 1 | awk '{ print $5 }')" == "$LUNA_BINUTILS_VERSION_REQUIRED" ] + if [ "$($LUNA_ARCH-luna-ar --version | head -n 1 | awk '{ print $5 }')" == "$LUNA_BINUTILS_VERSION_REQUIRED" ] then exit 0 else diff --git a/tools/test-gcc.sh b/tools/test-gcc.sh index 2a6211ab..2537a5ca 100755 --- a/tools/test-gcc.sh +++ b/tools/test-gcc.sh @@ -2,9 +2,9 @@ set -e source $(dirname $0)/setup-env.sh -if [ -x "$(command -v $ARCH-luna-gcc)" ] +if [ -x "$(command -v $LUNA_ARCH-luna-gcc)" ] then - if [ "$($ARCH-luna-gcc --version | head -n 1 | awk '{ print $3 }')" == "$LUNA_GCC_VERSION_REQUIRED" ] + if [ "$($LUNA_ARCH-luna-gcc --version | head -n 1 | awk '{ print $3 }')" == "$LUNA_GCC_VERSION_REQUIRED" ] then exit 0 else