diff --git a/Makefile b/Makefile index 5ee33d734..80bf37959 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,13 @@ # code directories. This prevents collisions between different # compilations of the same source file with different compile options. # -BUILD_DIRECTORY_PATH = "generate/unix" -include generate/unix/Makefile.config -include generate/unix/Makefile.common +ifeq ($(OS),efi) + BUILD_DIRECTORY_PATH = "generate/efi" + include generate/efi/Makefile.config + include generate/efi/Makefile.common +else + BUILD_DIRECTORY_PATH = "generate/unix" + include generate/unix/Makefile.config + include generate/unix/Makefile.common +endif diff --git a/generate/efi/Makefile.common b/generate/efi/Makefile.common new file mode 100644 index 000000000..f9cc619d9 --- /dev/null +++ b/generate/efi/Makefile.common @@ -0,0 +1,61 @@ +# +# Common make for acpica tools and utilities +# + +# +# Main rule will only generate versions that are appropriate for the running +# OS, either 64-bit or 32-bit. +# +all: $(PROGS) +$(PROGS): FORCE + @cd $(BUILD_DIRECTORY_PATH)/$@; \ + mkdir -p obj; \ + $(MAKE) || exit "$$?"; \ + echo "$(TARGET) version of $@:"; \ + ls -al ../bin/$@.efi; \ + echo ""; + +# +# Simple clean removes all .obj files, but leaves the executables +# in the local bin directory +# +clean: FORCE + @for toolname in $(PROGS); do \ + (cd $(BUILD_DIRECTORY_PATH)/$$toolname; \ + if [ -d "obj" ] ; then \ + echo "Removing $$toolname:"; \ + pwd; \ + $(MAKE) clean; \ + rmdir obj; \ + echo ""; \ + fi; \ + ); \ + done; + +# +# Very clean removes all executables and the local bin directory +# +veryclean: FORCE + @for toolname in $(PROGS); do \ + (cd $(BUILD_DIRECTORY_PATH)/$$toolname; \ + if [ -d "obj" ] ; then \ + echo "Removing $$toolname:"; \ + pwd; \ + $(MAKE) clean; \ + rmdir obj; \ + echo ""; \ + fi; \ + ); \ + if [ -e "$(BUILD_DIRECTORY_PATH)/bin/$$toolname" ] ; then \ + rm $(BUILD_DIRECTORY_PATH)/bin/$$toolname; \ + fi; \ + done; \ + if [ -d "bin" ] ; then \ + rmdir bin; \ + fi; + +machine: FORCE + @echo "Target architecture: $(TARGET)"; + @echo "Host architecture: $(HOST)"; + +FORCE: diff --git a/generate/efi/Makefile.config b/generate/efi/Makefile.config new file mode 100644 index 000000000..db4ae695a --- /dev/null +++ b/generate/efi/Makefile.config @@ -0,0 +1,243 @@ + +# Makefile.config +# +# Common configuration and setup file to generate the ACPICA tools and +# utilities:. +# +# This file is included by the individual makefiles for each tool. +# + +# +# Note: This makefile is intended to be used from within the native +# ACPICA directory structure, from under generate/efi. It specifically +# places all object files in a generate/efi subdirectory, not within +# the various ACPICA source directories. This prevents collisions +# between different compilations of the same source file with different +# compile options, and prevents pollution of the source code. +# + +# +# Configuration +# +# TARGET Build target platform can be overridden on the make command +# line by adding the followings to the invocation: +# TARGET="..." +# Possible target (ia32, x86_64, etc.) can be used to initiate +# a possible cross build. +# OPT_CFLAGS Optimization CFLAGS can be overridden on the make command +# line by adding the followings to the invocation: +# OPT_CFLAGS="..." +# SHARED Testing build to check if symbols are not implemented. +# GCC won't complain missing of symbols as our programs are +# compiled with -shared. This can be overridden on the make +# command line by adding the followings to the invocation: +# SHARED=false +# Link failures should only be seen for the _start and +# DivU64x32. They are the only 2 GNU EFI functions we are +# using in order not to introduce architecture specific code +# into ACPICA. +# +# Notes: +# gcc should be version 4 or greater, otherwise some of the options +# used will not be recognized. +# + +.SUFFIXES : + +# +# Common defines +# +PROGS = +HOST = $(shell uname -m | sed s,i[3456789]86,ia32,) +TARGET = $(shell uname -m | sed s,i[3456789]86,ia32,) +SHARED ?= true +OBJDIR = obj +BINDIR = bin + +# +# Main ACPICA source directories +# +ACPICA_SRC = ../../../source +ACPICA_COMMON = $(ACPICA_SRC)/common +ACPICA_TOOLS = $(ACPICA_SRC)/tools +ACPICA_OSL = $(ACPICA_SRC)/os_specific/service_layers +ACPICA_CORE = $(ACPICA_SRC)/components +ACPICA_INCLUDE = $(ACPICA_SRC)/include +ACPICA_DEBUGGER = $(ACPICA_CORE)/debugger +ACPICA_DISASSEMBLER = $(ACPICA_CORE)/disassembler +ACPICA_DISPATCHER = $(ACPICA_CORE)/dispatcher +ACPICA_EVENTS = $(ACPICA_CORE)/events +ACPICA_EXECUTER = $(ACPICA_CORE)/executer +ACPICA_HARDWARE = $(ACPICA_CORE)/hardware +ACPICA_NAMESPACE = $(ACPICA_CORE)/namespace +ACPICA_PARSER = $(ACPICA_CORE)/parser +ACPICA_RESOURCES = $(ACPICA_CORE)/resources +ACPICA_TABLES = $(ACPICA_CORE)/tables +ACPICA_UTILITIES = $(ACPICA_CORE)/utilities + +# +# ACPICA tool and utility source directories +# + +# +# Common ACPICA header files +# +ACPICA_HEADERS = \ + $(wildcard $(ACPICA_INCLUDE)/*.h) \ + $(wildcard $(ACPICA_INCLUDE)/platform/*.h) + +# +# GCC configuration +# +CC = gcc +LD = ld +OBJCOPY = objcopy + +CFLAGS = \ + -std=c99\ + -U__linux__\ + -U_LINUX\ + -D_GNU_SOURCE\ + -fno-stack-protector\ + -fno-strict-aliasing\ + -fpic\ + -fshort-wchar\ + -I$(ACPICA_INCLUDE) +LDFLAGS = \ + -nostdlib\ + -znocombreloc\ + -Bsymbolic +ifeq ($(strip $(SHARED)), true) +LDFLAGS += \ + -shared +endif +LIBS = \ + $(shell $(CC) -print-libgcc-file-name) +OBJCOPYFLAGS = \ + -j .text\ + -j .sdata\ + -j .data\ + -j .dynamic\ + -j .dynsym\ + -j .rel\ + -j .rela\ + -j .reloc\ + --target=efi-app-$(TARGET) + +# +# Common compiler flags +# The _GNU_SOURCE symbol is required for many hosts. +# +OPT_CFLAGS ?= $(CWARNINGFLAGS) + +# +# Optionally disable optimizations. Optimization causes problems on +# some compilers such as gcc 4.4 +# +ifneq ($(NOOPT),TRUE) +OPT_CFLAGS += -O2 -D_FORTIFY_SOURCE=2 +endif + +# +# Common compiler warning flags. The warning flags in addition +# to -Wall are not automatically included in -Wall. +# +CWARNINGFLAGS = \ + -Wall\ + -Wbad-function-cast\ + -Wdeclaration-after-statement\ + -Werror\ + -Wformat=2\ + -Wmissing-declarations\ + -Wmissing-prototypes\ + -Wstrict-aliasing=0\ + -Wswitch-default\ + -Wpointer-arith\ + -Wempty-body\ + -Wlogical-op\ + -Wmissing-parameter-type\ + -Wold-style-declaration\ + -Wtype-limits +# +# Extra warning flags (for possible future use) +# +#CWARNINGFLAGS += \ +# -Wcast-qual\ +# -Wconversion\ +# -Wshadow\ +# -Wstrict-prototypes\ +# -Wundef\ + +CFLAGS += $(OPT_CFLAGS) + +# +# EFI environment definitions +# +EFIINC = /usr/include/efi + +ifeq ($(TARGET),ia32) + +CFLAGS += -DACPI_MACHINE_WIDTH=32 +ifeq ($(HOST),x86_64) +EFILIB = /usr/lib32 +CFLAGS += -m32 +LDFLAGS += -melf_i386 +else # HOST eq ia32 +EFILIB = /usr/lib +endif + +else # TARGET eq x86_64 + +CFLAGS += \ + -DEFI_FUNCTION_WRAPPER\ + -DACPI_MACHINE_WIDTH=64 +ifeq ($(HOST),ia32) +EFILIB = /usr/lib64 +CFLAGS += -m64 +LDFLAGS += -melf_x86_64 +else # HOST eq x86_64 +EFILIB = /usr/lib +endif + +endif + +CFLAGS += \ + -I$(EFIINC)\ + -I$(EFIINC)/$(TARGET)\ + -I$(EFIINC)/protocol +LDFLAGS += \ + -T $(EFILIB)/elf_$(TARGET)_efi.lds\ + -L$(EFILIB)\ + $(EFILIB)/crt0-efi-$(TARGET).o +LIBS += \ + -lefi\ + -lgnuefi\ + +# +# Bison/Flex configuration +# +# -y: act like yacc +# +# -i: generate case insensitive scanner +# -s: suppress default rule, abort on unknown input +# +# Optional for Bison/yacc: +# -v: verbose, produces a .output file +# -d: produces the defines header file +# +YACC= bison +YFLAGS += -y + +LEX= flex +LFLAGS += -i -s + +# +# Command definitions +# +COMPILEOBJ = $(CC) -c $(CFLAGS) -o $@ $< +LINKPROG = $(LD) $(LDFLAGS) $(OBJECTS) -o $@ $(LIBS) +OBJCOPYPROG = $(OBJCOPY) $(OBJCOPYFLAGS) $< $@ +COPYPROG = \ + @mkdir -p ../$(BINDIR); \ + cp -f $< ../$(BINDIR); \ + echo "Copied $< to $@"; diff --git a/generate/efi/Makefile.rules b/generate/efi/Makefile.rules new file mode 100644 index 000000000..914ea5a43 --- /dev/null +++ b/generate/efi/Makefile.rules @@ -0,0 +1,26 @@ +# +# Common rules for generation of ACPICA utilities +# +# BIN/PROG.efi - Copies the utility to the local bin directory +# PROG.efi - Converts the shared library into EFI executable +# PROG.so - Builds the utility into a shared library +# + + +../$(BINDIR)/$(PROG).efi : $(PROG).efi + $(COPYPROG) + +$(PROG).efi : $(PROG).so + $(OBJCOPYPROG) + +$(PROG).so : $(OBJECTS) + $(LINKPROG) + +$(OBJDIR)/%.o : %.c $(HEADERS) $(ACPICA_HEADERS) + $(COMPILEOBJ) + +clean : + rm -f ../$(BINDIR)/$(PROG).efi + rm -f $(PROG).efi + rm -f $(PROG).so + rm -f $(OBJECTS)