rulimine/src/Makefile

53 lines
1.1 KiB
Makefile
Raw Normal View History

2020-09-13 15:36:18 +03:00
CC = ../toolchain/bin/i386-elf-gcc
LD = ../toolchain/bin/i386-elf-gcc
OBJCOPY = ../toolchain/bin/i386-elf-objcopy
2020-09-13 15:36:18 +03:00
CFLAGS = -flto -Os -pipe -Wall -Wextra
INTERNAL_CFLAGS = \
2020-08-25 00:35:06 +03:00
-std=gnu99 \
-ffreestanding \
2020-09-13 15:36:18 +03:00
-fno-stack-protector \
-fno-pic \
2020-08-25 00:35:06 +03:00
-mno-80387 \
-mno-mmx \
-mno-sse \
-mno-sse2 \
2020-04-29 17:53:05 +03:00
-I. \
-Wno-address-of-packed-member
2020-09-13 15:36:18 +03:00
LDFLAGS = -flto -Os
INTERNAL_LDFLAGS = \
2020-09-13 15:36:18 +03:00
-lgcc \
-static-libgcc \
-nostdlib \
2020-09-13 15:36:18 +03:00
-no-pie \
-static \
-Tlinker.ld
.PHONY: all clean
C_FILES := $(shell find ./ -type f -name '*.c' | grep -v bootsect | grep -v decompressor | sort)
ASM_FILES := $(shell find ./ -type f -name '*.asm' | grep -v bootsect | grep -v decompressor | sort)
2020-09-13 15:36:18 +03:00
OBJ := $(ASM_FILES:.asm=.o) $(C_FILES:.c=.o)
2020-08-29 21:02:16 +03:00
all: limine.bin
2020-09-13 15:36:18 +03:00
limine.bin: $(OBJ)
$(LD) $(OBJ) $(LDFLAGS) $(INTERNAL_LDFLAGS) -o stage2.elf
$(OBJCOPY) -O binary stage2.elf stage2.bin
gzip -n -9 < stage2.bin > stage2.bin.gz
$(MAKE) -C decompressor
2020-08-29 21:02:16 +03:00
cd bootsect && nasm bootsect.asm -fbin -o ../limine.bin
2020-09-13 15:36:18 +03:00
%.o: %.c
$(CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
%.o: %.asm
nasm $< -f elf32 -o $@
clean:
$(MAKE) -C decompressor clean
2020-09-13 15:36:18 +03:00
rm -f stage2.bin.gz stage2.bin stage2.elf limine.bin $(OBJ)