2023-02-19 12:07:21 +03:00
|
|
|
override MAKEFLAGS += -rR
|
|
|
|
|
2023-03-14 19:20:46 +03:00
|
|
|
include $(TOOLCHAIN_FILE)
|
2023-03-16 05:38:53 +03:00
|
|
|
export CC_FOR_TARGET
|
|
|
|
export LD_FOR_TARGET
|
|
|
|
export OBJDUMP_FOR_TARGET
|
|
|
|
export OBJCOPY_FOR_TARGET
|
|
|
|
export READELF_FOR_TARGET
|
2022-06-15 08:16:41 +03:00
|
|
|
|
2022-01-02 14:45:15 +03:00
|
|
|
BUILDDIR ?=
|
2021-03-08 05:05:39 +03:00
|
|
|
|
2021-12-08 19:41:19 +03:00
|
|
|
override SPACE := $(subst ,, )
|
2021-11-28 21:00:49 +03:00
|
|
|
|
2021-11-28 21:14:34 +03:00
|
|
|
MKESCAPE = $(subst $(SPACE),\ ,$(1))
|
2021-11-28 21:00:49 +03:00
|
|
|
SHESCAPE = $(subst ','\'',$(1))
|
|
|
|
OBJESCAPE = $(subst .a ,.a' ',$(subst .o ,.o' ',$(call SHESCAPE,$(1))))
|
|
|
|
|
2022-08-15 18:41:04 +03:00
|
|
|
ifeq ($(call MKESCAPE,$(BUILDDIR)),)
|
|
|
|
$(error BUILDDIR not specified)
|
2021-03-08 05:05:39 +03:00
|
|
|
endif
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2023-03-16 04:28:50 +03:00
|
|
|
override CFLAGS_FOR_TARGET += \
|
2022-08-15 17:37:31 +03:00
|
|
|
-Os \
|
2023-04-11 18:15:41 +03:00
|
|
|
-Wall \
|
|
|
|
-Wextra \
|
|
|
|
-Wshadow \
|
|
|
|
-Wvla \
|
|
|
|
$(WERROR_FLAG) \
|
2022-08-29 00:24:47 +03:00
|
|
|
-std=gnu11 \
|
|
|
|
-nostdinc \
|
2022-08-15 18:41:04 +03:00
|
|
|
-ffreestanding \
|
|
|
|
-fno-stack-protector \
|
|
|
|
-fno-stack-check \
|
2022-08-29 00:24:47 +03:00
|
|
|
-fomit-frame-pointer \
|
2022-08-15 18:41:04 +03:00
|
|
|
-fno-strict-aliasing \
|
|
|
|
-fno-lto \
|
2023-04-11 16:57:02 +03:00
|
|
|
-fno-PIE \
|
|
|
|
-fno-PIC \
|
2022-08-29 01:27:26 +03:00
|
|
|
-m32 \
|
|
|
|
-march=i686 \
|
2023-04-11 18:15:41 +03:00
|
|
|
-mno-80387
|
2023-02-25 03:38:26 +03:00
|
|
|
|
2023-03-16 04:28:50 +03:00
|
|
|
override CPPFLAGS_FOR_TARGET := \
|
2022-08-15 18:41:04 +03:00
|
|
|
-I../freestanding-headers \
|
2023-05-03 20:36:47 +03:00
|
|
|
-I./tinf \
|
2023-02-25 03:38:26 +03:00
|
|
|
-I. \
|
2023-03-16 04:28:50 +03:00
|
|
|
$(CPPFLAGS_FOR_TARGET) \
|
2023-03-23 03:02:58 +03:00
|
|
|
-MMD \
|
|
|
|
-MP
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2023-03-16 04:28:50 +03:00
|
|
|
override LDFLAGS_FOR_TARGET += \
|
2022-08-29 00:24:47 +03:00
|
|
|
-m elf_i386 \
|
2022-08-15 18:41:04 +03:00
|
|
|
-nostdlib \
|
|
|
|
-z max-page-size=0x1000 \
|
|
|
|
-static \
|
2022-08-29 00:24:47 +03:00
|
|
|
-T linker.ld
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2023-03-16 04:28:50 +03:00
|
|
|
ifeq ($(LD_FOR_TARGET_HAS_NO_PIE),yes)
|
|
|
|
override LDFLAGS_FOR_TARGET += -no-pie
|
2022-08-26 11:23:35 +03:00
|
|
|
endif
|
|
|
|
|
2022-08-27 06:09:42 +03:00
|
|
|
override C_FILES := $(shell find . -type f -name '*.c')
|
|
|
|
override ASM_FILES := $(shell find . -type f -name '*.asm')
|
2022-05-19 21:12:48 +03:00
|
|
|
override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(ASM_FILES:.asm=.o) $(C_FILES:.c=.o))
|
2021-12-08 19:41:19 +03:00
|
|
|
override HEADER_DEPS := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c=.d))
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2021-12-08 19:41:19 +03:00
|
|
|
.PHONY: all
|
|
|
|
all: $(call MKESCAPE,$(BUILDDIR))/decompressor.bin
|
2021-03-08 02:50:23 +03:00
|
|
|
|
2023-05-03 20:36:47 +03:00
|
|
|
$(call MKESCAPE,$(BUILDDIR))/decompressor.bin: $(OBJ) ../libgcc-binaries/libgcc-i686.a
|
2023-03-16 04:28:50 +03:00
|
|
|
$(LD_FOR_TARGET) '$(call OBJESCAPE,$^)' $(LDFLAGS_FOR_TARGET) -o '$(call SHESCAPE,$(BUILDDIR))/decompressor.elf'
|
|
|
|
$(OBJCOPY_FOR_TARGET) -O binary '$(call SHESCAPE,$(BUILDDIR))/decompressor.elf' '$(call SHESCAPE,$@)'
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2020-09-21 13:46:42 +03:00
|
|
|
-include $(HEADER_DEPS)
|
|
|
|
|
2023-05-03 20:36:47 +03:00
|
|
|
$(call MKESCAPE,$(BUILDDIR))/%.o: %.c
|
2022-08-08 23:00:25 +03:00
|
|
|
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
|
2023-03-16 04:28:50 +03:00
|
|
|
$(CC_FOR_TARGET) $(CFLAGS_FOR_TARGET) $(CPPFLAGS_FOR_TARGET) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)'
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2022-05-19 21:12:48 +03:00
|
|
|
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm
|
2022-08-08 23:00:25 +03:00
|
|
|
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
|
2023-04-18 13:41:01 +03:00
|
|
|
nasm '$(call SHESCAPE,$<)' -Wall $(WERROR_FLAG) -f elf32 -o '$(call SHESCAPE,$@)'
|