From 2aad357c18245a2220a2f00cd7273aa733a7efb6 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 2 Apr 2023 04:48:56 +0300 Subject: [PATCH] BuildSystem: building for 32-bit works now --- CMakeLists.txt | 17 +++++++++++++++-- kernel/CMakeLists.txt | 24 +++++++++++++++--------- kernel/font/prefs.psf.o | Bin 5912 -> 0 bytes 3 files changed, 30 insertions(+), 11 deletions(-) delete mode 100644 kernel/font/prefs.psf.o diff --git a/CMakeLists.txt b/CMakeLists.txt index c04eaa65a8..46598c6e48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,22 @@ cmake_minimum_required(VERSION 3.26) -project(banan-os CXX ASM) - set(BANAN_ARCH x86_64) +if(DEFINED ENV{BANAN_ARCH}) + set(BANAN_ARCH $ENV{BANAN_ARCH}) +endif() + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED True) +set(CMAKE_CXX_COMPILER ${BANAN_ARCH}-elf-g++) +set(CMAKE_CXX_COMPILER_WORKS True) + +if("${BANAN_ARCH}" STREQUAL "i386") + set(CMAKE_CXX_COMPILER i686-elf-g++) +endif() + +project(banan-os CXX) + set(BANAN_SYSROOT ${CMAKE_BINARY_DIR}/sysroot) set(BANAN_INCLUDE ${BANAN_SYSROOT}/usr/include) set(BANAN_BOOT ${BANAN_SYSROOT}/boot) diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index b0761ec484..c09448a5f1 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -2,11 +2,12 @@ cmake_minimum_required(VERSION 3.26) project(kernel CXX ASM) -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED True) -set(CMAKE_CXX_COMPILER ${BANAN_ARCH}-elf-g++) -set(CMAKE_CXX_COMPILER_WORKS True) - +if("${BANAN_ARCH}" STREQUAL "x86_64") + set(ELF_FORMAT elf64-x86-64) +elseif("${BANAN_ARCH}" STREQUAL "i386") + set(ELF_FORMAT elf32-i386) +endif() + set(KERNEL_SOURCES font/prefs.psf.o kernel/ACPI.cpp @@ -62,7 +63,7 @@ if("${BANAN_ARCH}" STREQUAL "x86_64") arch/x86_64/SpinLock.S arch/x86_64/Thread.S ) -elseif("${BANAN_ARCH}" EQUAL "i386") +elseif("${BANAN_ARCH}" STREQUAL "i386") set(KERNEL_SOURCES ${KERNEL_SOURCES} arch/i386/boot.S @@ -73,7 +74,7 @@ elseif("${BANAN_ARCH}" EQUAL "i386") arch/i386/Thread.S ) else() - message(FATAL_ERROR "unsupported architecure") + message(FATAL_ERROR "unsupported architecure ${BANAN_ARCH}") endif() set(BAN_SOURCES @@ -99,7 +100,7 @@ add_executable(kernel ${KERNEL_SOURCES}) target_include_directories(kernel PUBLIC include ../BAN/include ../libc/include) target_compile_definitions(kernel PUBLIC __is_kernel) -target_compile_definitions(kernel PUBLIC __arch=x86_64) +target_compile_definitions(kernel PUBLIC __arch=${BANAN_ARCH}) target_compile_options(kernel PUBLIC -O2 -g) target_compile_options(kernel PUBLIC -Wno-literal-suffix) @@ -138,4 +139,9 @@ add_custom_command( COMMAND cp ${CRTEND} . ) -set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_COMPILER} -o ${CMAKE_CURRENT_BINARY_DIR}/crti.o ${CMAKE_CURRENT_BINARY_DIR}/crtbegin.o ${CMAKE_CURRENT_BINARY_DIR}/crtend.o ${CMAKE_CURRENT_BINARY_DIR}/crtn.o") +add_custom_command( + OUTPUT font/prefs.psf.o + COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && objcopy -O ${ELF_FORMAT} -B i386 -I binary font/prefs.psf ${CMAKE_CURRENT_BINARY_DIR}/font/prefs.psf.o +) + +set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_COMPILER} -o ${CMAKE_CURRENT_BINARY_DIR}/crti.o ${CMAKE_CURRENT_BINARY_DIR}/crtbegin.o ${CMAKE_CURRENT_BINARY_DIR}/crtend.o ${CMAKE_CURRENT_BINARY_DIR}/crtn.o -lgcc ") diff --git a/kernel/font/prefs.psf.o b/kernel/font/prefs.psf.o deleted file mode 100644 index d7df195a25c506568a5efd0418692eba4a03821a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5912 zcmbW5dvsLA8Ni1Hx7xFZMuoaI6mEbE)lggn!-6XyKKjsFQK_v~a}(hL?IolnO@pk9 ze|h|~(sMkA<3G}tJ}lL~YzsmgiEgWgM{P?}6C-_vKCFdWL)yl@{e3fY@7~=L|LNrX z=FT_YH{U$&H#0Z8>xP?eOih`hqBKRVQdKFcRcdf%wY)|b*QoQTo&RWvEGR}J}MrI@EHN#3b; zKgj0%V~?&*r>nAe?6Gua4)Up7d&}zyeO8iE_Mub|h?hxICS9a{dLyZECb4i!s~V+{2aw{HMY7%nXPzu>X zK^%%>NepYgF2q?7R055zX=o^(eECH2y^o$OHrQ8e*0cPOX^{_te9tiB?a?x>qop!> zmQJT=MOjRp5@tcZl25*N{eDgBYF^_wip{Dznh!N830JT0L8D}S$|p~fN$`-e`CeR+ ztdC;Zn3pR?kDM-~)9J`QGpi5`R2cGXqp$S!^-U!7c@G))k$r{sX3mj6R0+M5OSI4M za&6MD!oClwva($vJv`Zjk-6+dJ9w#*&8lsT9{(9;7q5r(H!?CZ+-K+CkPph`iVVou zPY?k`@F$Ec;Yd2-+jtufMCtp%xY1Yq_RYPUy>{QOmz6#5Orm`vo~0+A9}l=jQ?QaTfDsR05YI)A1!)lSIj z=#=*tC+$FVVw3GO{(6REzj1*x-bN#lqoNHjYC^3>CVpyUg}bD^+{Z~dALQc$#B{fM z>%c(BavVKw}{3m7cpOj^NYGlS+Ba72=kl2;iZ1OuwY=F^2QGdzvL;6d~ z(qB@R^+?KMZx4`y_*3ePSCrr{M(0~E?_zL(Hu|&ViS@OA`f?$76Z_N+DIF9gA=a5_X~K3NLPw_vwdVeNr^2liQKVxxPl8q4QN zRWc>>eNoavKFH>hO?or=#LX=8G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