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