Skip to content

Commit

Permalink
add support for building multiple filesystems and add exFAT
Browse files Browse the repository at this point in the history
  • Loading branch information
pbatard committed Jul 1, 2014
1 parent c879a69 commit 7c1dc60
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 54 deletions.
2 changes: 0 additions & 2 deletions Make.common
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ EFIINC = /usr/include/efi
GNUEFILIB = /usr/lib
EFILIB = /usr/lib
EFICRT0 = /usr/lib
# Directory where you want the driver files to be copied into with 'make install'
INSTALL_DIR = /boot/efi/EFI/refind/drivers_x64/

# You shouldn't have to edit anything below this
HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
SRCDIR = grub

VPATH = $(SRCDIR)
FS_NAME = ntfs

LOCAL_CPPFLAGS = -I$(SRCDIR)/include

Expand Down
49 changes: 49 additions & 0 deletions src/Make.gnuefi
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# Build control file for the EFI drivers, as built with GNU-EFI
#

SRCDIR = .
VPATH = $(SRCDIR)
HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
ARCH ?= $(HOSTARCH)

# Note: IA64 options are untested; taken from Debian's rEFIt package.
ifeq ($(ARCH),ia64)
# EFI specs allows only lower floating point partition to be used
ARCH_C_CFLAGS = -frename-registers -mfixed-range=f32-f127
DRIVER_ARCH = ia64
endif

ifeq ($(ARCH),ia32)
LIBEG = build32
ARCH_C_FLAGS = -m32 -malign-double
DRIVERARCH = ia32
LD_CODE = elf_i386
endif

ifeq ($(ARCH),x86_64)
LIBEG = build64
ARCH_C_FLAGS = "-DEFIAPI=__attribute__((ms_abi))" -m64
DRIVERARCH = x64
LD_CODE = elf_x86_64
endif

LOCAL_CPPFLAGS = -DDRIVERNAME=$(DRIVERNAME) $(ARCH_C_FLAGS) -I$(SRCDIR)/../include -I$(SRCDIR)/../grub -I$(SRCDIR)/../grub/include
LOCAL_LIBS = -lgrub
LOCAL_LDFLAGS = -L.
GRUB_FS_DIR = ../grub/grub-core/fs
OBJS = grubberize.o $(GRUB_FS_DIR)/fshelp.o $(GRUB_FS_DIR)/$(DRIVERNAME).o fs_driver.o
TARGET = $(DRIVERNAME)_$(DRIVERARCH).efi

all: $(TARGET)

include $(SRCDIR)/../Make.common

$(TARGET): $(SHLIB_TARGET)
@echo [OBJ] $@
@$(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
-j .rela -j .reloc --target=$(FORMAT_DRIVER) $< $@
@chmod a-x $(TARGET)

clean:
rm -f $(GRUB_FS_DIR)/*.o $(GRUB_FS_DIR)/*.d *.o *.d *.so *.efi
71 changes: 23 additions & 48 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,52 +1,27 @@
#
# Build control file for the EFI drivers, as built with GNU-EFI
# meta-Makefile for the filesystem drivers
#

DRIVERNAME = ntfs
SRCDIR = .
VPATH = $(SRCDIR)
HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
ARCH ?= $(HOSTARCH)

# Note: IA64 options are untested; taken from Debian's rEFIt package.
ifeq ($(ARCH),ia64)
# EFI specs allows only lower floating point partition to be used
ARCH_C_CFLAGS = -frename-registers -mfixed-range=f32-f127
DRIVER_ARCH = ia64
endif

ifeq ($(ARCH),ia32)
LIBEG = build32
ARCH_C_FLAGS = -m32 -malign-double
DRIVERARCH = ia32
LD_CODE = elf_i386
endif

ifeq ($(ARCH),x86_64)
LIBEG = build64
ARCH_C_FLAGS = "-DEFIAPI=__attribute__((ms_abi))" -m64
DRIVERARCH = x64
LD_CODE = elf_x86_64
endif

LOCAL_CPPFLAGS = -DDRIVERNAME=$(DRIVERNAME) $(ARCH_C_FLAGS) -I$(SRCDIR)/../include -I$(SRCDIR)/../grub -I$(SRCDIR)/../grub/include
LOCAL_LIBS = -lgrub
LOCAL_LDFLAGS = -L.
OBJS = fs_driver.o grubberize.o ../grub/grub-core/fs/fshelp.o ../grub/grub-core/fs/$(DRIVERNAME).o
TARGET = $(DRIVERNAME)_$(DRIVERARCH).efi

all: $(TARGET)

include $(SRCDIR)/../Make.common

$(TARGET): $(SHLIB_TARGET)
@echo [OBJ] $@
@$(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
-j .rela -j .reloc --target=$(FORMAT_DRIVER) $< $@
@chmod a-x $(TARGET)
INSTALL_DIR = /boot/efi/EFI/refind/drivers_x64

clean:
rm -f $(OBJS) $(OBJS:.o=.d) *.o *.so *.efi
FILESYSTEMS = ntfs xfs

all: $(FILESYSTEMS)

exfat:
@rm -f fs_driver.o
+make DRIVERNAME=exfat -f Make.gnuefi

install: all
@cp -v $(TARGET) $(INSTALL_DIR)
ntfs:
@rm -f fs_driver.o
+make DRIVERNAME=ntfs -f Make.gnuefi

xfs:
@rm -f fs_driver.o
+make DRIVERNAME=xfs -f Make.gnuefi

install:
@mkdir -p $(INSTALL_DIR)
@cp -v *.efi $(INSTALL_DIR)

clean:
+make -f Make.gnuefi clean
2 changes: 1 addition & 1 deletion src/fs_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

/* Driver version */
#define FS_DRIVER_VERSION_MAJOR 0
#define FS_DRIVER_VERSION_MINOR 4b
#define FS_DRIVER_VERSION_MINOR 5

#undef offsetof
#if defined(__GNUC__) && (__GNUC__ > 3)
Expand Down
5 changes: 3 additions & 2 deletions src/fs_guid.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ static const struct {
const CHAR16 *Name;
const EFI_GUID Guid;
} FSGuid[] = {
{ L"ntfs", { 0x3AD33E69, 0x7966, 0x4081, {0x9A, 0x66, 0x9B, 0xA8, 0xE5, 0x4E, 0x06, 0x4B } } },
{ L"xfs", { 0xB1EC46ED, 0x896B, 0x4838, {0x8B, 0x39, 0x66, 0xFF, 0x9F, 0xEE, 0x3A, 0x9A } } },
{ L"exfat", { 0xC5372182, 0x1AD1, 0x4955, { 0xBD, 0xC9, 0x4A, 0xBC, 0xC8, 0x2B, 0x20, 0x43 } } },
{ L"ntfs", { 0x3AD33E69, 0x7966, 0x4081, { 0x9A, 0x66, 0x9B, 0xA8, 0xE5, 0x4E, 0x06, 0x4B } } },
{ L"xfs", { 0xB1EC46ED, 0x896B, 0x4838, { 0x8B, 0x39, 0x66, 0xFF, 0x9F, 0xEE, 0x3A, 0x9A } } },
};

/**
Expand Down

0 comments on commit 7c1dc60

Please sign in to comment.