rulimine/decompressor/Makefile

57 lines
1.0 KiB
Makefile
Raw Permalink Normal View History

CC = i386-elf-gcc
LD = i386-elf-gcc
OBJCOPY = i386-elf-objcopy
CFLAGS = -flto -Os -pipe -Wall -Wextra -Werror
2020-09-13 15:36:18 +03:00
INTERNAL_CFLAGS = \
-std=gnu11 \
-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 \
-masm=intel \
-mno-80387 \
-mno-mmx \
2020-09-14 20:32:11 +03:00
-mno-3dnow \
-mno-sse \
-mno-sse2 \
2020-09-21 13:46:42 +03:00
-MMD \
-I.
LDFLAGS = -flto -Os
2020-09-13 15:36:18 +03:00
INTERNAL_LDFLAGS = \
2020-09-13 15:36:18 +03:00
-lgcc \
-static-libgcc \
-nostdlib \
2020-09-13 15:36:18 +03:00
-no-pie \
-z max-page-size=0x1000 \
2020-09-13 15:36:18 +03:00
-static \
-Tlinker.ld
.PHONY: all clean
C_FILES := $(shell find ./ -type f -name '*.c' | sort)
ASM_FILES := $(shell find ./ -type f -name '*.asm' | sort)
OBJ := $(ASM_FILES:.asm=.o) $(C_FILES:.c=.o)
2020-09-21 13:46:42 +03:00
HEADER_DEPS := $(C_FILES:.c=.d)
all: decompressor.bin
2020-09-13 15:36:18 +03:00
decompressor.bin: $(OBJ)
$(LD) $(OBJ) $(LDFLAGS) $(INTERNAL_LDFLAGS) -o decompressor.elf
$(OBJCOPY) -O binary decompressor.elf decompressor.bin
2020-09-21 13:46:42 +03:00
-include $(HEADER_DEPS)
2020-09-13 15:36:18 +03:00
%.o: %.c
$(CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
%.o: %.asm
nasm $< -f elf32 -o $@
clean:
2020-10-04 01:01:05 +03:00
rm -f decompressor.bin decompressor.elf $(OBJ) $(HEADER_DEPS)