2020-09-06 04:35:32 +03:00
|
|
|
OPT_LEVEL = z
|
|
|
|
CFLAGS = -pipe -Wall -Wextra
|
|
|
|
|
|
|
|
INTERNAL_CFLAGS = \
|
|
|
|
-O$(OPT_LEVEL) \
|
|
|
|
-std=gnu99 \
|
|
|
|
-ffreestanding \
|
|
|
|
-flto \
|
|
|
|
-mno-80387 \
|
|
|
|
-mno-mmx \
|
|
|
|
-mno-sse \
|
|
|
|
-mno-sse2 \
|
|
|
|
-I. \
|
|
|
|
-Wno-address-of-packed-member
|
|
|
|
|
|
|
|
INTERNAL_LDFLAGS = \
|
|
|
|
-static \
|
|
|
|
-nostdlib \
|
|
|
|
-Tlinker.ld \
|
|
|
|
-no-pie
|
|
|
|
|
|
|
|
.PHONY: all clean
|
|
|
|
|
|
|
|
C_FILES := $(shell find ./ -type f -name '*.c' | sort)
|
|
|
|
BC := $(C_FILES:.c=.bc)
|
|
|
|
|
|
|
|
all: decompressor.bin
|
|
|
|
|
|
|
|
decompressor.bin: $(BC)
|
|
|
|
llvm-link $(BC) -o bundle.bc
|
|
|
|
opt --O$(OPT_LEVEL) bundle.bc -o optimised_bundle.bc
|
|
|
|
clang --target=i386-elf -O$(OPT_LEVEL) -c optimised_bundle.bc -o optimised_bundle.o
|
2020-09-09 17:04:06 +03:00
|
|
|
ld.lld optimised_bundle.o $(INTERNAL_LDFLAGS) -o decompressor.elf
|
2020-09-06 04:35:32 +03:00
|
|
|
llvm-objcopy -O binary decompressor.elf decompressor.bin
|
|
|
|
|
|
|
|
%.bc: %.c
|
|
|
|
clang --target=i386-elf $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f decompressor.bin $(BC)
|