]> code.delx.au - refind/blob - Make.common
Btrfs driver & check for valid loader before adding to menu.
[refind] / Make.common
1 #
2 # Make.common
3 # Common make rules for building with gnu-efi
4 #
5
6 #EFIINC = /usr/include/efi
7 #GNUEFILIB = /usr/lib64
8 #EFILIB = /usr/lib64
9 #EFICRT0 = /usr/lib64
10
11 # Comment out above and uncomment below if using locally-compiled GNU-EFI....
12 EFIINC = /usr/local/include/efi
13 GNUEFILIB = /usr/local/lib
14 EFILIB = /usr/local/lib
15 EFICRT0 = /usr/local/lib
16
17 HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
18 ARCH := $(HOSTARCH)
19 OS = $(shell uname -s)
20 CPPFLAGS = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol -I../include -I../refind -I../libeg -DCONFIG_$(ARCH) -D__MAKEWITH_GNUEFI
21
22 OPTIMFLAGS = -O2 -fno-strict-aliasing
23 DEBUGFLAGS = -Wall
24 #CFLAGS = $(ARCH3264) $(OPTIMFLAGS) -fpic -fshort-wchar $(DEBUGFLAGS)
25 CFLAGS = $(ARCH3264) $(OPTIMFLAGS) -fno-stack-protector -fpic -fshort-wchar -mno-red-zone $(DEBUGFLAGS)
26 ASFLAGS = $(ARCH3264)
27 LDFLAGS = -nostdlib -znocombreloc -zdefs
28
29 prefix = /usr/bin/
30 CC = $(prefix)gcc
31 AS = $(prefix)as
32 LD = $(prefix)ld
33 AR = $(prefix)ar
34 RANLIB = $(prefix)ranlib
35 OBJCOPY = $(prefix)objcopy
36
37 ifeq ($(ARCH),ia64)
38 # EFI specs allows only lower floating point partition to be used
39 CFLAGS += -frename-registers -mfixed-range=f32-f127
40 endif
41
42 ifeq ($(ARCH),x86_64)
43 CFLAGS += -DEFI_FUNCTION_WRAPPER
44 CPPFLAGS += -DEFIX64
45
46 ifeq ($(HOSTARCH),ia32)
47 ARCH3264 = -m64
48
49 GNUEFILIB := $(GNUEFILIB)64
50 EFILIB := $(EFILIB)64
51 EFICRT0 := $(EFICRT0)64
52 endif
53 endif
54
55 ifeq ($(ARCH),ia32)
56 CPPFLAGS += -DEFI32 -malign-double
57
58 ifeq ($(HOSTARCH),x86_64)
59 ARCH3264 = -m32
60
61 GNUEFILIB := $(GNUEFILIB)32
62 EFILIB := $(EFILIB)32
63 EFICRT0 := $(EFICRT0)32
64 endif
65 endif
66
67
68 CRTOBJS = $(EFICRT0)/crt0-efi-$(ARCH).o
69
70 ifneq (,$(findstring FreeBSD,$(OS)))
71 ifeq ($(ARCH),x86_64)
72 LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_fbsd_efi.lds
73 else
74 LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_efi.lds
75 endif
76 else
77 LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_efi.lds
78 endif
79
80 LDFLAGS += -T $(LDSCRIPT) -shared -Bsymbolic -L$(EFILIB) -L$(GNUEFILIB) $(CRTOBJS)
81 LIBS = -lefi -lgnuefi $(shell $(CC) $(ARCH3264) -print-libgcc-file-name)
82 FORMAT = efi-app-$(ARCH)
83 FORMAT_DRIVER = efi-bsdrv-$(ARCH)
84
85
86 # general rules
87
88 %.o: %.c
89 $(CC) $(LOCAL_CPPFLAGS) $(CPPFLAGS) $(LOCAL_CFLAGS) $(CFLAGS) -c $< -o $@
90
91 # rules for EFI applications
92
93 ifneq (,$(filter %.efi,$(TARGET)))
94
95 SHLIB_TARGET = $(subst .efi,.so,$(TARGET))
96
97 $(SHLIB_TARGET): $(OBJS)
98 $(LD) $(LOCAL_LDFLAGS) $(LDFLAGS) $(OBJS) -o $@ $(LOCAL_LIBS) $(LIBS)
99
100 #$(TARGET): $(SHLIB_TARGET)
101 # $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
102 # -j .rela -j .reloc --target=$(FORMAT) $< $@
103
104 endif
105
106 # rules for libraries
107
108 ifneq (,$(filter %.a,$(TARGET)))
109
110 $(TARGET): $(OBJS)
111 $(AR) cq $@ $(OBJS)
112
113 endif
114
115 # utility rules
116
117 clean:
118 rm -f $(TARGET) *~ *.so $(OBJS) *.efi *.obj refind_*.txt refind_*.dll *.lib
119
120 # EOF