components/shim/patches/01-Makefile.patch
changeset 7222 37e367b978c0
equal deleted inserted replaced
7221:0e3ebbcfc116 7222:37e367b978c0
       
     1 # Source: Internal
       
     2 # Info: Written internally so this component can be built on Solaris.
       
     3 # Status: This patch is offered at https://github.com/rhinstaller/shim/issues/54
       
     4 
       
     5 --- ORIGINAL/Makefile	2016-06-24 03:08:28.270393201 +0000
       
     6 +++ shim-0.9/Makefile	2016-08-01 20:57:34.268232472 +0000
       
     7 @@ -1,38 +1,52 @@
       
     8  VERSION		= 0.9
       
     9 -RELEASE		:=
       
    10 +RELEASE		:=""
       
    11  ifneq ($(RELEASE),"")
       
    12  	RELEASE="-$(RELEASE)"
       
    13  endif
       
    14  
       
    15  CC		= $(CROSS_COMPILE)gcc
       
    16 -LD		= $(CROSS_COMPILE)ld
       
    17 -OBJCOPY		= $(CROSS_COMPILE)objcopy
       
    18 +OS		= $(shell uname -s)
       
    19 +ifeq ($(OS),SunOS) 
       
    20 +	LD		= /usr/gnu/bin/ld
       
    21 +	OBJCOPY		= /usr/gnu/bin/objcopy
       
    22 +	ARCH		= $(shell isainfo -n)
       
    23 +	LIB_PATH	= /usr/lib/amd64
       
    24 +	EFI_PATH	:= /usr/lib/amd64/efi
       
    25 +	DEFAULT_LOADER	:= \\\\grubx64.efi
       
    26 +	# FreeBSD reports amd64 instead of x86_64
       
    27 +	ifeq ($(ARCH),amd64)
       
    28 +	  override ARCH := x86_64
       
    29 +	endif
       
    30 +	EFI_LDS		= elf_$(ARCH)_efi_sol2.lds
       
    31 +else
       
    32 +	LD		= $(CROSS_COMPILE)ld
       
    33 +	OBJCOPY		= /usr/gnu/bin/objcopy
       
    34 +	ARCH		= $(shell $(CC) -dumpmachine | cut -f1 -d- | sed s,i[3456789]86,ia32,)
       
    35 +	LIB_PATH	= /usr/lib/amd64
       
    36 +	EFI_PATH	:= /usr/lib64/gnuefi
       
    37 +	DEFAULT_LOADER	:= \\\\grub.efi
       
    38 +	EFI_LDS		= elf_$(ARCH)_efi.lds
       
    39 +endif
       
    40  
       
    41 -ARCH		= $(shell $(CC) -dumpmachine | cut -f1 -d- | sed s,i[3456789]86,ia32,)
       
    42  OBJCOPY_GTE224  = $(shell expr `$(OBJCOPY) --version |grep ^"GNU objcopy" | sed 's/^.* //g' | cut -f1-2 -d.` \>= 2.24)
       
    43  
       
    44  SUBDIRS		= Cryptlib lib
       
    45  
       
    46 -LIB_PATH	= /usr/lib64
       
    47 -
       
    48  EFI_INCLUDE	:= /usr/include/efi
       
    49  EFI_INCLUDES	= -nostdinc -ICryptlib -ICryptlib/Include -I$(EFI_INCLUDE) -I$(EFI_INCLUDE)/$(ARCH) -I$(EFI_INCLUDE)/protocol -I$(shell pwd)/include
       
    50 -EFI_PATH	:= /usr/lib64/gnuefi
       
    51  
       
    52  LIB_GCC		= $(shell $(CC) -print-libgcc-file-name)
       
    53  EFI_LIBS	= -lefi -lgnuefi --start-group Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a --end-group $(LIB_GCC) 
       
    54  
       
    55  EFI_CRT_OBJS 	= $(EFI_PATH)/crt0-efi-$(ARCH).o
       
    56 -EFI_LDS		= elf_$(ARCH)_efi.lds
       
    57  
       
    58 -DEFAULT_LOADER	:= \\\\grub.efi
       
    59  CFLAGS		= -ggdb -O0 -fno-stack-protector -fno-strict-aliasing -fpic \
       
    60  		  -fshort-wchar -Wall -Wsign-compare -Werror -fno-builtin \
       
    61  		  -Werror=sign-compare -ffreestanding \
       
    62  		  -I$(shell $(CC) -print-file-name=include) \
       
    63  		  "-DDEFAULT_LOADER=L\"$(DEFAULT_LOADER)\"" \
       
    64  		  "-DDEFAULT_LOADER_CHAR=\"$(DEFAULT_LOADER)\"" \
       
    65 -		  $(EFI_INCLUDES)
       
    66 +		  $(EFI_INCLUDES) -I/usr/include
       
    67  
       
    68  ifneq ($(origin OVERRIDE_SECURITY_POLICY), undefined)
       
    69  	CFLAGS	+= -DOVERRIDE_SECURITY_POLICY
       
    70 @@ -93,10 +107,12 @@
       
    71  		-e "s,@@COMMIT@@,$(shell if [ -d .git ] ; then git log -1 --pretty=format:%H ; elif [ -f commit ]; then cat commit ; else echo commit id not available; fi)," \
       
    72  		< version.c.in > version.c
       
    73  
       
    74 +ifneq ($(OS),SunOS)
       
    75  certdb/secmod.db: shim.crt
       
    76  	-mkdir certdb
       
    77  	pk12util -d certdb/ -i shim.p12 -W "" -K ""
       
    78  	certutil -d certdb/ -A -i shim.crt -n shim -t u
       
    79 +endif
       
    80  
       
    81  shim.o: $(SOURCES) shim_cert.h
       
    82  
       
    83 @@ -156,16 +172,32 @@
       
    84  		-j .note.gnu.build-id \
       
    85  		$(FORMAT) $^ [email protected]
       
    86  
       
    87 +ifeq ($(OS),SunOS)
       
    88 +%.efi.signed: %.efi shim.crt
       
    89 +	sbsign --cert $(word 2,$^) --key shim.key --output $@ $<
       
    90 +else
       
    91  %.efi.signed: %.efi certdb/secmod.db
       
    92  	pesign -n certdb -i $< -c "shim" -s -o $@ -f
       
    93 +endif
       
    94  
       
    95  clean:
       
    96  	$(MAKE) -C Cryptlib clean
       
    97  	$(MAKE) -C Cryptlib/OpenSSL clean
       
    98  	$(MAKE) -C lib clean
       
    99 +	ifeq ($(OS),SunOS)
       
   100 +	rm -rf $(TARGET) $(OBJS) $(MOK_OBJS) $(FALLBACK_OBJS) $(KEYS)
       
   101 +	else
       
   102  	rm -rf $(TARGET) $(OBJS) $(MOK_OBJS) $(FALLBACK_OBJS) $(KEYS) certdb
       
   103 +	endif
       
   104  	rm -f *.debug *.so *.efi *.tar.* version.c
       
   105  
       
   106 +ifeq ($(OS),SunOS)
       
   107 +install:
       
   108 +	echo $(DESTDIR)
       
   109 +	mkdir -p $(DESTDIR)/boot
       
   110 +	install -m 0755 $(TARGET) $(DESTDIR)/boot
       
   111 +endif
       
   112 +
       
   113  GITTAG = $(VERSION)
       
   114  
       
   115  test-archive: