2022-07-05 10:14:48 +03:00
|
|
|
include $(CROSS_FILE)
|
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))))
|
|
|
|
|
|
|
|
ifeq ($(call MKESCAPE,$(BUILDDIR)), )
|
2021-12-08 19:41:19 +03:00
|
|
|
$(error BUILDDIR not specified)
|
2021-03-08 05:05:39 +03:00
|
|
|
endif
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2021-12-08 19:41:19 +03:00
|
|
|
override INTERNAL_CFLAGS := \
|
2022-01-17 00:41:37 +03:00
|
|
|
$(WERROR) \
|
2021-04-03 01:48:38 +03:00
|
|
|
-m32 \
|
2021-11-10 15:18:08 +03:00
|
|
|
-march=i686 \
|
2021-10-11 22:35:23 +03:00
|
|
|
-mtune=generic \
|
2021-07-31 22:28:06 +03:00
|
|
|
-mabi=sysv \
|
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 \
|
2022-03-02 17:55:15 +03:00
|
|
|
-fno-stack-check \
|
2022-01-25 11:16:26 +03:00
|
|
|
-fno-strict-aliasing \
|
2022-01-20 07:17:45 +03:00
|
|
|
-fno-lto \
|
2021-04-03 01:48:38 +03:00
|
|
|
-fno-pie \
|
2022-08-09 16:22:15 +03:00
|
|
|
-fno-pic \
|
2020-09-14 20:32:11 +03:00
|
|
|
-fomit-frame-pointer \
|
2022-01-20 07:17:45 +03:00
|
|
|
-nostdinc \
|
2020-09-21 13:46:42 +03:00
|
|
|
-Wno-address-of-packed-member \
|
2022-02-18 03:09:51 +03:00
|
|
|
-Wshadow \
|
|
|
|
-Wvla \
|
2021-05-22 11:26:56 +03:00
|
|
|
-mno-80387 \
|
|
|
|
-mno-mmx \
|
|
|
|
-mno-sse \
|
|
|
|
-mno-sse2 \
|
2020-09-21 13:46:42 +03:00
|
|
|
-MMD \
|
2022-06-30 08:48:42 +03:00
|
|
|
-I../freestanding-headers \
|
2021-10-22 21:08:11 +03:00
|
|
|
-I. \
|
2021-11-28 21:00:49 +03:00
|
|
|
-I'$(call SHESCAPE,$(BUILDDIR))/tinf'
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2021-12-08 19:41:19 +03:00
|
|
|
override INTERNAL_LDFLAGS := \
|
2021-05-31 01:32:43 +03:00
|
|
|
-melf_i386 \
|
2020-09-06 04:35:32 +03:00
|
|
|
-nostdlib \
|
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
|
|
|
|
2022-01-22 05:10:25 +03:00
|
|
|
override C_FILES := $(shell find ./ -type f -name '*.c')
|
2022-05-19 21:12:48 +03:00
|
|
|
override ASM_FILES := $(shell find ./ -type f -name '*.asm')
|
|
|
|
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
|
|
|
|
2022-06-21 09:47:48 +03:00
|
|
|
$(call MKESCAPE,$(BUILDDIR))/decompressor.bin: $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o
|
2022-07-05 10:14:48 +03:00
|
|
|
$(CROSS_LD) '$(call OBJESCAPE,$^)' $(CROSS_LDFLAGS) $(INTERNAL_LDFLAGS) -o '$(call SHESCAPE,$(BUILDDIR))/decompressor.elf'
|
|
|
|
$(CROSS_OBJCOPY) -O binary '$(call SHESCAPE,$(BUILDDIR))/decompressor.elf' '$(call SHESCAPE,$@)'
|
2020-09-06 04:35:32 +03:00
|
|
|
|
2021-11-28 21:00:49 +03:00
|
|
|
$(call MKESCAPE,$(BUILDDIR))/tinf-copied: ../tinf/*
|
|
|
|
rm -rf '$(call SHESCAPE,$(BUILDDIR))/tinf'
|
2022-08-08 23:00:25 +03:00
|
|
|
$(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))'
|
2021-11-28 21:00:49 +03:00
|
|
|
cp -r ../tinf '$(call SHESCAPE,$(BUILDDIR))/'
|
|
|
|
touch '$(call SHESCAPE,$(BUILDDIR))/tinf-copied'
|
2021-10-22 21:08:11 +03:00
|
|
|
|
2022-01-18 00:13:19 +03:00
|
|
|
$(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o: $(call MKESCAPE,$(BUILDDIR))/tinf-copied
|
2022-08-08 23:00:25 +03:00
|
|
|
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
|
2022-07-05 10:14:48 +03:00
|
|
|
$(CROSS_CC) $(CROSS_CFLAGS) -Os $(INTERNAL_CFLAGS) -c '$(call SHESCAPE,$(@:.o=.c))' -o '$(call SHESCAPE,$@)'
|
2022-01-18 00:13:19 +03:00
|
|
|
|
|
|
|
$(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o: $(call MKESCAPE,$(BUILDDIR))/tinf-copied
|
2022-08-08 23:00:25 +03:00
|
|
|
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
|
2022-07-05 10:14:48 +03:00
|
|
|
$(CROSS_CC) $(CROSS_CFLAGS) -Os $(INTERNAL_CFLAGS) -c '$(call SHESCAPE,$(@:.o=.c))' -o '$(call SHESCAPE,$@)'
|
2021-10-22 21:08:11 +03:00
|
|
|
|
2020-09-21 13:46:42 +03:00
|
|
|
-include $(HEADER_DEPS)
|
|
|
|
|
2021-11-28 21:00:49 +03:00
|
|
|
$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/tinf-copied
|
2022-08-08 23:00:25 +03:00
|
|
|
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
|
2022-07-05 10:14:48 +03:00
|
|
|
$(CROSS_CC) $(CROSS_CFLAGS) -Os $(INTERNAL_CFLAGS) -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,$@)')"
|
2022-05-19 21:12:48 +03:00
|
|
|
nasm '$(call SHESCAPE,$<)' -f elf32 -o '$(call SHESCAPE,$@)'
|