Add nasm support

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
merge-requests/1/head
Jiaxun Yang 2 years ago
parent d0282646db
commit faff431342

@ -6,21 +6,24 @@ endif
# get source files, generate object names
ifeq ($(SRCS),)
SRCS = $(wildcard *.c) $(wildcard *.S)
SRCS = $(wildcard *.c) $(wildcard *.S) $(wildcard *.nasm)
endif
TMP = $(SRCS:.c=.o)
OBJS = $(TMP:.S=.o)
TMP1 = $(TMP:.S=.o)
OBJS = $(TMP1:.nasm=.o)
CFLAGS += -fshort-wchar -fno-strict-aliasing -ffreestanding -fno-stack-protector -fno-stack-check -I. -I./uefi \
-I/usr/include -I/usr/include/efi -I/usr/include/efi/protocol -I/usr/include/efi/$(ARCH) -D__$(ARCH)__
ifeq ($(ARCH),x86_64)
CFLAGS += -DHAVE_USE_MS_ABI -mno-red-zone
endif
# for libuefi.a
# for libuefi.
LIBSRCS = $(filter-out $(wildcard crt_*.c),$(wildcard *.c)) $(wildcard *.S)
TMP2 = $(LIBSRCS:.c=.o)
LIBOBJS = $(TMP2:.S=.o)
# NASM can only be nasm :-)
NASM = nasm
# detect toolchain
ifeq ($(wildcard /usr/bin/clang)$(wildcard /usr/local/bin/clang)$(wildcard /usr/lib/llvm/*/bin/clang),)
USE_GCC = 1
@ -29,6 +32,7 @@ ifneq ($(USE_GCC),)
ifeq ($(ARCH),x86_64)
CFLAGS += -maccumulate-outgoing-args
endif
NASMFLAGS += -f elf64
CFLAGS += -Wno-builtin-declaration-mismatch -fpic -fPIC
LDFLAGS += -nostdlib -shared -Bsymbolic -Luefi uefi/crt_$(ARCH).o
LIBS += -o $(TARGET).so -luefi -T uefi/elf_$(ARCH)_efi.lds
@ -49,6 +53,8 @@ EFIARCH = efi-app-$(ARCH)
endif
AR ?= ar
else
# clang toolchian uses COFF64
NASMFLAGS += -f win64
CFLAGS += --target=$(ARCH)-pc-win32-coff -Wno-builtin-requires-header -Wno-incompatible-library-redeclaration -Wno-long-long
LDFLAGS += -subsystem:efi_application -nodefaultlib -dll -entry:uefi_init uefi/*.o
LIBS = -out:$(TARGET)
@ -95,6 +101,9 @@ $(TARGET).so: $(OBJS)
%.o: %.S
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.nasm
$(NASM) $(NASMFLAGS) $< -o $@
build:
@mkdir ../build ../build/uefi 2>/dev/null || true
@cp crt_$(ARCH).o ../build/uefi/crt0.o

Loading…
Cancel
Save