2020-09-18 22:38:59 +03:00
|
|
|
CC = i386-elf-gcc
|
|
|
|
LD = i386-elf-gcc
|
|
|
|
OBJCOPY = i386-elf-objcopy
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2020-09-13 15:36:18 +03:00
|
|
|
CFLAGS = -flto -Os -pipe -Wall -Wextra
|
|
|
|
|
|
|
|
INTERNAL_CFLAGS = \
|
2020-09-18 23:15:27 +03:00
|
|
|
-std=gnu11 \
|
2020-09-06 04:35:32 +03:00
|
|
|
-ffreestanding \
|
2020-09-13 15:36:18 +03:00
|
|
|
-fno-stack-protector \
|
|
|
|
-fno-pic \
|
2020-09-14 20:32:11 +03:00
|
|
|
-fomit-frame-pointer \
|
2020-09-16 18:22:05 +03:00
|
|
|
-masm=intel \
|
2020-09-06 04:35:32 +03:00
|
|
|
-mno-80387 \
|
|
|
|
-mno-mmx \
|
2020-09-14 20:32:11 +03:00
|
|
|
-mno-3dnow \
|
2020-09-06 04:35:32 +03:00
|
|
|
-mno-sse \
|
|
|
|
-mno-sse2 \
|
|
|
|
-I. \
|
|
|
|
-Wno-address-of-packed-member
|
|
|
|
|
2020-09-13 15:36:18 +03:00
|
|
|
LDFLAGS = -flto -Os
|
|
|
|
|
2020-09-06 04:35:32 +03:00
|
|
|
INTERNAL_LDFLAGS = \
|
2020-09-13 15:36:18 +03:00
|
|
|
-lgcc \
|
|
|
|
-static-libgcc \
|
2020-09-06 04:35:32 +03:00
|
|
|
-nostdlib \
|
2020-09-13 15:36:18 +03:00
|
|
|
-no-pie \
|
|
|
|
-static \
|
|
|
|
-Tlinker.ld
|
2020-09-06 04:35:32 +03:00
|
|
|
|
|
|
|
.PHONY: all clean
|
|
|
|
|
|
|
|
C_FILES := $(shell find ./ -type f -name '*.c' | sort)
|
2020-09-18 23:15:27 +03:00
|
|
|
ASM_FILES := $(shell find ./ -type f -name '*.asm' | sort)
|
|
|
|
OBJ := $(ASM_FILES:.asm=.o) $(C_FILES:.c=.o)
|
2020-09-06 04:35:32 +03:00
|
|
|
|
|
|
|
all: decompressor.bin
|
|
|
|
|
2020-09-13 15:36:18 +03:00
|
|
|
decompressor.bin: $(OBJ)
|
|
|
|
$(LD) $(OBJ) $(LDFLAGS) $(INTERNAL_LDFLAGS) -o decompressor.elf
|
2020-09-13 16:20:53 +03:00
|
|
|
$(OBJCOPY) -O binary decompressor.elf decompressor.bin
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2020-09-13 15:36:18 +03:00
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2020-09-18 23:15:27 +03:00
|
|
|
%.o: %.asm
|
|
|
|
nasm $< -f elf32 -o $@
|
|
|
|
|
2020-09-06 04:35:32 +03:00
|
|
|
clean:
|
2020-09-13 15:36:18 +03:00
|
|
|
rm -f decompressor.bin decompressor.elf $(OBJ)
|