2020-09-18 22:38:59 +03:00
|
|
|
CC = i386-elf-gcc
|
|
|
|
LD = i386-elf-gcc
|
|
|
|
OBJCOPY = i386-elf-objcopy
|
2021-03-08 02:50:23 +03:00
|
|
|
BUILDDIR = .
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2020-10-01 03:16:28 +03:00
|
|
|
CFLAGS = -flto -Os -pipe -Wall -Wextra -Werror
|
2020-09-13 15:36:18 +03:00
|
|
|
|
2020-09-25 23:36:26 +03:00
|
|
|
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-21 13:46:42 +03:00
|
|
|
-Wno-address-of-packed-member \
|
2020-09-16 18:22:05 +03:00
|
|
|
-masm=intel \
|
2021-03-08 02:50:23 +03:00
|
|
|
-mgeneral-regs-only \
|
2020-09-21 13:46:42 +03:00
|
|
|
-MMD \
|
|
|
|
-I.
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2020-09-25 23:57:57 +03:00
|
|
|
LDFLAGS = -flto -Os
|
2020-09-13 15:36:18 +03:00
|
|
|
|
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 \
|
2020-09-25 23:36:26 +03:00
|
|
|
-z max-page-size=0x1000 \
|
2020-09-13 15:36:18 +03:00
|
|
|
-static \
|
|
|
|
-Tlinker.ld
|
2020-09-06 04:35:32 +03:00
|
|
|
|
|
|
|
.PHONY: all clean
|
|
|
|
|
2021-02-22 06:34:36 +03:00
|
|
|
C_FILES := $(shell find -L ./ -type f -name '*.c' | sort)
|
|
|
|
ASM_FILES := $(shell find -L ./ -type f -name '*.asm' | sort)
|
2021-03-08 02:50:23 +03:00
|
|
|
OBJ := $(addprefix $(BUILDDIR)/, $(ASM_FILES:.asm=.o) $(C_FILES:.c=.o))
|
|
|
|
HEADER_DEPS := $(addprefix $(BUILDDIR)/, $(C_FILES:.c=.d))
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2021-03-08 02:50:23 +03:00
|
|
|
all: | builddir $(BUILDDIR)/decompressor.bin
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2021-03-08 02:50:23 +03:00
|
|
|
builddir:
|
|
|
|
for i in $(OBJ); do mkdir -p `dirname $$i`; done
|
|
|
|
|
|
|
|
$(BUILDDIR)/decompressor.bin: $(OBJ)
|
|
|
|
$(LD) $(OBJ) $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $(BUILDDIR)/decompressor.elf
|
|
|
|
$(OBJCOPY) -O binary $(BUILDDIR)/decompressor.elf $@
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2020-09-21 13:46:42 +03:00
|
|
|
-include $(HEADER_DEPS)
|
|
|
|
|
2021-03-08 02:50:23 +03:00
|
|
|
$(addprefix $(BUILDDIR)/, %.o): %.c
|
2020-09-13 15:36:18 +03:00
|
|
|
$(CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2021-03-08 02:50:23 +03:00
|
|
|
$(addprefix $(BUILDDIR)/, %.o): %.asm
|
2020-09-18 23:15:27 +03:00
|
|
|
nasm $< -f elf32 -o $@
|
|
|
|
|
2020-09-06 04:35:32 +03:00
|
|
|
clean:
|
2021-03-08 02:50:23 +03:00
|
|
|
rm -rf $(BUILDDIR)
|