Attempt to make a working build system for linux.

This commit is contained in:
Curle 2019-07-21 00:27:20 +01:00
parent a3135a1c56
commit 10e2112faf
2 changed files with 72 additions and 0 deletions

42
build.sh Normal file
View File

@ -0,0 +1,42 @@
set +v
CurrentDir = $PWD
GCC-NAME = x86_64-w64-mingw
EFI-FOLDER = gnu-efi
Linker="$EFI-FOLDER/gnuefi/elf_x86_64_efi.lds"
cd ./x64
rm objects.list
HeaderFiles=-I$CurrentDir/inc/ \
-I$CurrentDir/gnu-efi/inc \
-I$CurrentDir/gnu-efi/inc/x86_64 \
-I$CurrentDir/gnu-efi/inc/protocol \
-I$CurrentDir/gnu-efi/lib
set -v
for f in $CurrentDir/src/*.c; do
echo "$GCC-NAME-gcc" -ffreestanding -fpic -fshort-wchar -fno-stack-protector -fno-stack-check -fno-strict-aliasing -fno-merge-all-constants -m64 -mno-redzone -DGNU_USE_MS_ABI -maccumulate-outgoing-args --std=c11 $HeaderFiles -Og -g3 -Wall -Wextra -Wdouble-promotion -fmessage-length=0 -c -MMD -MP -Wa,-adhln="${f%.*}.out" -MF"${f%.*}.d" -MT"${f%.*}.o" -o "${f%.*}.o" "$f"
"$GCC-NAME-gcc" -ffreestanding -fpic -fshort-wchar -fno-stack-protector -fno-stack-check -fno-strict-aliasing -fno-merge-all-constants -m64 -mno-redzone -DGNU_USE_MS_ABI -maccumulate-outgoing-args --std=c11 $HeaderFiles -Og -g3 -Wall -Wextra -Wdouble-promotion -fmessage-length=0 -c -MMD -MP -Wa,-adhln="${f%.*}.out" -MF"${f%.*}.d" -MT"${f%.*}.o" -o "${f%.*}.o" "$f"
done
set +v
while read f; do
echo "${f%.*}.o" | tee -a objects.list
done < $CurrentDir/c_files.txt
for f in $CurrentDir/src/*.o; do
echo "$f" | tee -a objects.list
done
set -v
"$GCC-NAME-ld" -T$Linker -nostdlib --warn-common --no-undefined -znocombreloc -s -shared -Bsymbolic -Map=output.map -o "program.so" @"objects.list"
set +v
rm image/efi/boot/BOOTx64.efi
objcopy -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .rel* -j .reloc --target=efi-app-x86_64 "program.so" "image/efi/boot/BOOTx64.efi"

30
c_files.txt Normal file
View File

@ -0,0 +1,30 @@
gnu-efi/lib/misc.c
gnu-efi/lib/print.c
gnu-efi/lib/smbios.c
gnu-efi/lib/sread.c
gnu-efi/lib/str.c
gnu-efi/lib/boxdraw.c
gnu-efi/lib/cmdline.c
gnu-efi/lib/console.c
gnu-efi/lib/crc.c
gnu-efi/lib/data.c
gnu-efi/lib/debug.c
gnu-efi/lib/dpath.c
gnu-efi/lib/error.c
gnu-efi/lib/event.c
gnu-efi/lib/exit.c
gnu-efi/lib/guid.c
gnu-efi/lib/hand.c
gnu-efi/lib/hw.c
gnu-efi/lib/init.c
gnu-efi/lib/lock.c
gnu-efi/lib/x86_64/callwrap.c
gnu-efi/lib/x86_64/efi_stub.S
gnu-efi/lib/x86_64/initplat.c
gnu-efi/lib/x86_64/math.c
gnu-efi/lib/x86_64/setjmp.S
gnu-efi/lib/runtime/efirtlib.c
gnu-efi/lib/runtime/rtdata.c
gnu-efi/lib/runtime/rtlock.c
gnu-efi/lib/runtime/rtstr.c
gnu-efi/lib/runtime/vm.c