Ship reproducible prebuilt bootloader and make 'make all' only build limine-install

This commit is contained in:
mintsuki 2020-09-13 15:20:53 +02:00
parent 5663169aa6
commit dd6f38f632
5 changed files with 15 additions and 12 deletions

View File

@ -6,10 +6,14 @@ CC = cc
OBJCOPY = objcopy OBJCOPY = objcopy
CFLAGS = -O2 -pipe -Wall -Wextra CFLAGS = -O2 -pipe -Wall -Wextra
.PHONY: all install clean echfs-test ext2-test test.img .PHONY: all limine install clean echfs-test ext2-test test.img
all: limine-install all: limine-install
limine:
$(MAKE) -C src all
cp src/limine.bin ./
install: all install: all
install -s limine-install $(DESTDIR)$(PREFIX)/bin/ install -s limine-install $(DESTDIR)$(PREFIX)/bin/
@ -17,11 +21,8 @@ clean:
rm -f limine-install rm -f limine-install
$(MAKE) -C src clean $(MAKE) -C src clean
src/limine.bin: limine-install: limine.bin limine-install.c
$(MAKE) -C src all $(OBJCOPY) -I binary -O default limine.bin limine.o
limine-install: src/limine.bin limine-install.c
$(OBJCOPY) -I binary -O default src/limine.bin limine.o
$(CC) $(CFLAGS) limine.o limine-install.c -o limine-install $(CC) $(CFLAGS) limine.o limine-install.c -o limine-install
test.img: test.img:

View File

@ -4,7 +4,7 @@
#include <stddef.h> #include <stddef.h>
#include <inttypes.h> #include <inttypes.h>
extern char _binary_src_limine_bin_start[]; extern char _binary_limine_bin_start[];
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
if (argc < 2) { if (argc < 2) {
@ -34,11 +34,11 @@ int main(int argc, char *argv[]) {
// Write the bootsector from the bootloader to the device // Write the bootsector from the bootloader to the device
fseek(device, 0, SEEK_SET); fseek(device, 0, SEEK_SET);
fwrite(&_binary_src_limine_bin_start[0], 1, 512, device); fwrite(&_binary_limine_bin_start[0], 1, 512, device);
// Write the rest of stage 2 to the device // Write the rest of stage 2 to the device
fseek(device, stage2_sect * 512, SEEK_SET); fseek(device, stage2_sect * 512, SEEK_SET);
fwrite(&_binary_src_limine_bin_start[512], 63, 512, device); fwrite(&_binary_limine_bin_start[512], 63, 512, device);
// Hardcode in the bootsector the location of stage 2 // Hardcode in the bootsector the location of stage 2
fseek(device, 0x1b0, SEEK_SET); fseek(device, 0x1b0, SEEK_SET);

BIN
limine.bin Normal file

Binary file not shown.

View File

@ -1,5 +1,6 @@
CC = ../toolchain/bin/i386-elf-gcc CC = ../toolchain/bin/i386-elf-gcc
LD = ../toolchain/bin/i386-elf-gcc LD = ../toolchain/bin/i386-elf-gcc
OBJCOPY = ../toolchain/bin/i386-elf-objcopy
CFLAGS = -flto -Os -pipe -Wall -Wextra CFLAGS = -flto -Os -pipe -Wall -Wextra
@ -35,8 +36,8 @@ all: limine.bin
limine.bin: $(OBJ) limine.bin: $(OBJ)
$(LD) $(OBJ) $(LDFLAGS) $(INTERNAL_LDFLAGS) -o stage2.elf $(LD) $(OBJ) $(LDFLAGS) $(INTERNAL_LDFLAGS) -o stage2.elf
objcopy -O binary stage2.elf stage2.bin $(OBJCOPY) -O binary stage2.elf stage2.bin
gzip -9 < stage2.bin > stage2.bin.gz gzip -n -9 < stage2.bin > stage2.bin.gz
$(MAKE) -C decompressor $(MAKE) -C decompressor
cd bootsect && nasm bootsect.asm -fbin -o ../limine.bin cd bootsect && nasm bootsect.asm -fbin -o ../limine.bin

View File

@ -1,5 +1,6 @@
CC = ../../toolchain/bin/i386-elf-gcc CC = ../../toolchain/bin/i386-elf-gcc
LD = ../../toolchain/bin/i386-elf-gcc LD = ../../toolchain/bin/i386-elf-gcc
OBJCOPY = ../../toolchain/bin/i386-elf-objcopy
CFLAGS = -flto -Os -pipe -Wall -Wextra CFLAGS = -flto -Os -pipe -Wall -Wextra
@ -34,7 +35,7 @@ all: decompressor.bin
decompressor.bin: $(OBJ) decompressor.bin: $(OBJ)
$(LD) $(OBJ) $(LDFLAGS) $(INTERNAL_LDFLAGS) -o decompressor.elf $(LD) $(OBJ) $(LDFLAGS) $(INTERNAL_LDFLAGS) -o decompressor.elf
objcopy -O binary decompressor.elf decompressor.bin $(OBJCOPY) -O binary decompressor.elf decompressor.bin
%.o: %.c %.o: %.c
$(CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@