2018-10-04 05:02:33 +00:00
|
|
|
|
2018-10-01 17:01:00 +00:00
|
|
|
AS := nasm
|
|
|
|
CC := clang
|
2018-10-04 05:02:33 +00:00
|
|
|
LD := lld
|
2018-11-15 11:34:22 +00:00
|
|
|
DAS := llvm-objdump-6.0
|
2018-01-31 19:10:24 +00:00
|
|
|
|
2018-10-04 05:02:33 +00:00
|
|
|
ifneq '$(AS_ENV)' ''
|
|
|
|
AS := $(AS_ENV)
|
|
|
|
endif
|
|
|
|
$(info Using AS=$(AS))
|
|
|
|
|
|
|
|
ifneq '$(CC_ENV)' ''
|
|
|
|
CC := $(CC_ENV)
|
|
|
|
endif
|
|
|
|
$(info Using CC=$(CC))
|
|
|
|
|
|
|
|
ifneq '$(LD_ENV)' ''
|
|
|
|
LD := $(LD_ENV)
|
|
|
|
endif
|
|
|
|
$(info Using LD=$(LD))
|
|
|
|
|
|
|
|
ifneq '$(DAS_ENV)' ''
|
|
|
|
DAS := $(DAS_ENV)
|
|
|
|
endif
|
|
|
|
$(info Using DAS=$(DAS))
|
|
|
|
|
2018-10-01 17:01:00 +00:00
|
|
|
INC_COMMON := inc
|
|
|
|
MK := mk
|
|
|
|
OUT := out
|
2018-02-06 21:25:47 +00:00
|
|
|
|
2018-10-09 19:13:31 +00:00
|
|
|
C_FLAGS_ARCH_X86_64 := -mcmodel=kernel \
|
|
|
|
-target x86_64-pc-none-elf \
|
|
|
|
-mno-red-zone \
|
|
|
|
-mno-mmx \
|
|
|
|
-mno-sse \
|
|
|
|
-mno-sse2 \
|
|
|
|
-mno-sse3 \
|
|
|
|
-mno-3dnow
|
2018-02-06 21:25:47 +00:00
|
|
|
|
2018-10-02 06:43:30 +00:00
|
|
|
# generic freestanding cflags used for target
|
|
|
|
# each submodule can append to this flag
|
2018-10-09 19:13:31 +00:00
|
|
|
C_FLAGS = -x c \
|
|
|
|
-g \
|
2018-03-24 00:58:24 +00:00
|
|
|
-c \
|
|
|
|
-O2 \
|
2018-10-09 19:13:31 +00:00
|
|
|
-std=c17 \
|
|
|
|
-Wall \
|
|
|
|
-Wextra \
|
|
|
|
-Wpedantic \
|
2018-03-24 00:58:24 +00:00
|
|
|
-Werror \
|
|
|
|
-ffreestanding \
|
|
|
|
-fno-pic \
|
2018-02-18 04:00:54 +00:00
|
|
|
-fno-stack-protector \
|
2018-10-09 19:13:31 +00:00
|
|
|
$(C_FLAGS_ARCH_X86_64) \
|
2018-10-02 06:43:30 +00:00
|
|
|
-I$(INC_COMMON) \
|
|
|
|
$(C_FLAGS_$(MOD))
|
2018-01-31 19:10:24 +00:00
|
|
|
|
2018-10-02 06:43:30 +00:00
|
|
|
# generic asm flags used for target
|
|
|
|
# each submodule can append to this flag
|
2018-02-14 07:31:50 +00:00
|
|
|
AS_FLAGS = -w+all \
|
|
|
|
-w+error \
|
|
|
|
-f elf64 \
|
|
|
|
-F dwarf \
|
|
|
|
-g \
|
2018-10-01 17:01:00 +00:00
|
|
|
-I$(INC_COMMON) \
|
2018-10-02 06:43:30 +00:00
|
|
|
$(AS_FLAGS_$(MOD))
|
2018-02-12 03:26:03 +00:00
|
|
|
|
2018-10-02 06:43:30 +00:00
|
|
|
# generic pre-processing flags used for target
|
2018-02-12 03:26:03 +00:00
|
|
|
PREP_FLAGS = -E \
|
2018-03-24 00:58:24 +00:00
|
|
|
-xc\
|
2018-02-12 03:26:03 +00:00
|
|
|
-P \
|
2018-10-02 06:43:30 +00:00
|
|
|
-I$(INC_COMMON) \
|
|
|
|
$(C_FLAGS_$(MOD))
|
2018-02-12 03:26:03 +00:00
|
|
|
|
2018-10-02 06:43:30 +00:00
|
|
|
# generic generate dependency flags used for target
|
|
|
|
# each submodule can append to this flag
|
2018-02-12 03:26:03 +00:00
|
|
|
GDEP_FLAGS = $(PREP_FLAGS) \
|
|
|
|
-MMD \
|
|
|
|
-MT $@
|
|
|
|
|
2018-02-14 07:31:50 +00:00
|
|
|
MKDIR = mkdir -p $(dir $@)
|
2018-02-18 06:14:25 +00:00
|
|
|
COMP = $(CC) $(C_FLAGS) -o $@ $<
|
|
|
|
COMPAS = $(AS) $(AS_FLAGS) -o $@ $<
|
2018-02-12 03:26:03 +00:00
|
|
|
PREP = $(CC) $(PREP_FLAGS) $< > $@
|
2018-02-14 07:31:50 +00:00
|
|
|
GDEP = $(CC) $(GDEP_FLAGS) -MF $(addsuffix .d, $@) $< > /dev/null
|
2018-01-31 19:10:24 +00:00
|
|
|
|
2018-10-01 17:01:00 +00:00
|
|
|
include Rules.top
|