summaryrefslogtreecommitdiffstats
path: root/GNU_efi_HelloWorld/example_Makefile
diff options
context:
space:
mode:
authorRegina König2022-09-07 23:24:55 +0200
committerRegina König2022-09-07 23:24:55 +0200
commit09e1b4fb40878ef29b8ca36b93172fcd89c70883 (patch)
treef731cd63f8a6511d1b1bbad6ed4eb01111e77995 /GNU_efi_HelloWorld/example_Makefile
parenthiuhi (diff)
parentRename dir and experiment with cmdline options (diff)
downloadmemtest86-09e1b4fb40878ef29b8ca36b93172fcd89c70883.tar.gz
memtest86-09e1b4fb40878ef29b8ca36b93172fcd89c70883.tar.xz
memtest86-09e1b4fb40878ef29b8ca36b93172fcd89c70883.zip
Merge branch 'master' of git.openslx.org:openslx-ng/memtest86HEADmaster
Diffstat (limited to 'GNU_efi_HelloWorld/example_Makefile')
-rw-r--r--GNU_efi_HelloWorld/example_Makefile96
1 files changed, 96 insertions, 0 deletions
diff --git a/GNU_efi_HelloWorld/example_Makefile b/GNU_efi_HelloWorld/example_Makefile
new file mode 100644
index 0000000..f62df60
--- /dev/null
+++ b/GNU_efi_HelloWorld/example_Makefile
@@ -0,0 +1,96 @@
+# /phoenix/kernel/boot/Makefile
+#
+# This file is a part of Phoenix operating system.
+# Copyright (c) 2011-2012, Artyom Lebedev <artyom.lebedev@gmail.com>
+# All rights reserved.
+# See COPYING file for copyright details.
+
+include $(PHOENIX_ROOT)/make/makevar.mak
+
+LOADER_BINARY = phoenix.efi
+
+COMPILE_DIR = build
+OBJ_DIR = $(COMPILE_DIR)/$(PHOENIX_TARGET)
+
+SUBDIRS = gnuefi lib lib/runtime lib/x86_64 loader \
+ $(PHOENIX_ROOT)/lib/common $(PHOENIX_ROOT)/lib/elf
+
+EFI_IMAGE = $(OBJ_DIR)/$(LOADER_BINARY)
+EFI_DEBUG_IMAGE = $(OBJ_DIR)/debug.$(LOADER_BINARY)
+ELF_IMAGE = $(OBJ_DIR)/elf_image.so
+
+SRCS = $(foreach dir,$(SUBDIRS),$(wildcard $(dir)/*.S $(dir)/*.c $(dir)/*.cpp))
+
+$(foreach dir,$(SUBDIRS),$(eval vpath %.S $(dir)) $(eval vpath %.c $(dir)) $(eval vpath %.cpp $(dir)))
+
+OBJS = $(foreach src,$(SRCS), \
+ $(OBJ_DIR)/$(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(patsubst %.S,%.o,$(notdir $(src))))))
+DEPS = $(OBJS:.o=.d)
+
+CFLAGS = $(GLOBAL_C_FLAGS) $(C_STANDARD) -Wno-pointer-sign
+
+CPP_FLAGS = $(GLOBAL_CXX_FLAGS) $(CXX_STANDARD) $(CXX_RESTRICTIONS) \
+ -fno-exceptions -fno-rtti
+
+COMMON_FLAGS = $(GLOBAL_FLAGS) -fpic -Wall -Werror -fshort-wchar \
+ -fno-strict-aliasing -fno-merge-constants -DEFI_FUNCTION_WRAPPER \
+ -mno-red-zone -DCONFIG_x86_64 -DBOOT_LOADER -DEFI_APP \
+ -DKERNEL_ADDRESS=$(KERNEL_ADDRESS)
+
+SECTIONS = .text .sdata .data .dynamic .dynsym .rel .rela .reloc
+DEBUG_SECTIONS = .debug_info .debug_abbrev .debug_loc .debug_aranges \
+ .debug_line .debug_macinfo .debug_str
+
+ifeq ($(PHOENIX_TARGET),RELEASE)
+COMMON_FLAGS += -O2
+else ifeq ($(PHOENIX_TARGET),DEBUG)
+COMMON_FLAGS += -ggdb3 -O0 -DDEBUG -DEFI_DEBUG=1
+else
+$(error Target not supported: $(PHOENIX_TARGET))
+endif
+
+INCLUDE_DIRS = inc inc/protocol inc/x86_64 lib \
+ $(PHOENIX_ROOT)/kernel/sys $(PHOENIX_ROOT)/kernel/sys/arch/$(PHOENIX_ARCH) \
+ $(PHOENIX_ROOT)/include $(PHOENIX_ROOT)/lib/elf
+
+IFLAGS = $(foreach incdir,$(INCLUDE_DIRS),-I$(incdir))
+
+LD_SCRIPT = gnuefi/elf_x86_64_efi.lds
+
+LDFLAGS = -nostdlib -T $(LD_SCRIPT) -shared -Bsymbolic --unresolved-symbols=report-all
+
+.PHONY: all clean
+
+all: $(EFI_IMAGE) $(EFI_DEBUG_IMAGE)
+
+# include dependencies if exist
+-include $(DEPS)
+
+$(EFI_IMAGE): $(ELF_IMAGE)
+ $(OBJCOPY) $(foreach sec,$(SECTIONS),-j $(sec)) --target=efi-app-x86_64 $< $@
+
+$(EFI_DEBUG_IMAGE): $(ELF_IMAGE)
+ $(OBJCOPY) $(foreach sec,$(SECTIONS) $(DEBUG_SECTIONS),-j $(sec)) --target=efi-app-x86_64 $< $@
+
+$(ELF_IMAGE): $(OBJ_DIR) $(OBJS)
+ $(LD) $(LDFLAGS) $(OBJS) -o $@
+
+$(OBJ_DIR)/%.o: %.S
+ $(CC) -DCONFIG_x86_64 -c -o $@ $<
+
+$(OBJ_DIR)/%.o: %.c
+ $(CC) $(IFLAGS) $(COMMON_FLAGS) $(CFLAGS) -c -o $@ $<
+ $(CC) -MM -MT '$@' $(IFLAGS) $(COMMON_FLAGS) $(CFLAGS) -c -o $(@:.o=.d) $<
+
+$(OBJ_DIR)/%.o: %.cpp
+ $(CC) $(IFLAGS) $(COMMON_FLAGS) $(CPP_FLAGS) -c -o $@ $<
+ $(CC) -MM -MT '$@' $(IFLAGS) $(COMMON_FLAGS) $(CPP_FLAGS) -c -o $(@:.o=.d) $<
+
+$(COMPILE_DIR):
+ if [ ! -d $@ ]; then mkdir $@; fi
+
+$(OBJ_DIR): $(COMPILE_DIR)
+ if [ ! -d $@ ]; then mkdir $@; fi
+
+clean:
+ $(RM) -rf $(COMPILE_DIR)