]> code.delx.au - refind/blob - Make.common
Replace HTML version of CC license in icons directory with plain-text
[refind] / Make.common
1 #
2 # Make.common
3 # Common make rules for building with gnu-efi
4 #
5
6 # This program is licensed under the terms of the GNU GPL, version 3,
7 # or (at your option) any later version.
8 # You should have received a copy of the GNU General Public License
9 # along with this program. If not, see <http://www.gnu.org/licenses/>.
10
11 EFIINC = /usr/include/efi
12 GNUEFILIB = /usr/lib
13 EFILIB = /usr/lib
14 EFICRT0 = /usr/lib
15
16 # Comment out above and uncomment below if using locally-compiled GNU-EFI....
17 #EFIINC = /usr/local/include/efi
18 #GNUEFILIB = /usr/local/lib
19 #EFILIB = /usr/local/lib
20 #EFICRT0 = /usr/local/lib
21
22 HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
23 ARCH := $(HOSTARCH)
24 OS = $(shell uname -s)
25 CPPFLAGS = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol -I../include -I../refind -I../libeg -DCONFIG_$(ARCH) -D__MAKEWITH_GNUEFI
26
27 OPTIMFLAGS = -O2 -fno-strict-aliasing
28 DEBUGFLAGS = -Wall
29 #CFLAGS = $(ARCH3264) $(OPTIMFLAGS) -fpic -fshort-wchar $(DEBUGFLAGS)
30 CFLAGS = $(ARCH3264) $(OPTIMFLAGS) -fno-stack-protector -fpic -fshort-wchar $(DEBUGFLAGS)
31 ASFLAGS = $(ARCH3264)
32 LDFLAGS = -nostdlib
33 DRV_LDFLAGS =
34
35 prefix = /usr/bin/
36 CC = $(prefix)gcc
37 AS = $(prefix)as
38 LD = $(prefix)ld
39 AR = $(prefix)ar
40 RANLIB = $(prefix)ranlib
41 OBJCOPY = $(prefix)objcopy
42
43 ifeq ($(ARCH),ia64)
44 # EFI specs allows only lower floating point partition to be used
45 CFLAGS += -frename-registers -mfixed-range=f32-f127
46 endif
47
48 FORMAT = --target=efi-app-$(ARCH)
49 FORMAT_DRIVER = --target=efi-bsdrv-$(ARCH)
50
51 ifeq ($(ARCH),x86_64)
52 CFLAGS += -DEFI_FUNCTION_WRAPPER -mno-red-zone
53 CPPFLAGS += -DEFIX64
54 LDFLAGS += -znocombreloc -zdefs
55
56 ifeq ($(HOSTARCH),ia32)
57 ARCH3264 = -m64
58
59 GNUEFILIB := $(GNUEFILIB)64
60 EFILIB := $(EFILIB)64
61 EFICRT0 := $(EFICRT0)64
62 endif
63 endif
64
65 ifeq ($(ARCH),ia32)
66 CPPFLAGS += -DEFI32 -malign-double
67 LDFLAGS += -znocombreloc -zdefs
68
69 ifeq ($(HOSTARCH),x86_64)
70 ARCH3264 = -m32
71
72 GNUEFILIB := $(GNUEFILIB)32
73 EFILIB := $(EFILIB)32
74 EFICRT0 := $(EFICRT0)32
75 endif
76 endif
77
78 ifeq ($(ARCH), aarch64)
79 CFLAGS += -fno-stack-check -g -fno-merge-constants -ffreestanding -fno-stack-check
80 CPPFLAGS += -DEFIAARCH64
81 FORMAT = -O binary
82 FORMAT_DRIVER = -O binary
83 LDFLAGS += --defsym=EFI_SUBSYSTEM=0xa --warn-common --no-undefined --fatal-warnings
84 DRV_LDFLAGS += --defsym=EFI_SUBSYSTEM=0xb --warn-common --no-undefined --fatal-warnings
85 endif
86
87 CRTOBJS = $(EFICRT0)/crt0-efi-$(ARCH).o
88
89 ifneq (,$(findstring FreeBSD,$(OS)))
90 ifeq ($(ARCH),x86_64)
91 LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_fbsd_efi.lds
92 else
93 LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_efi.lds
94 endif
95 else
96 LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_efi.lds
97 endif
98
99 LDFLAGS += -T $(LDSCRIPT) -shared -Bsymbolic -L$(EFILIB) -L$(GNUEFILIB) $(CRTOBJS)
100 DRV_LDFLAGS += -T $(LDSCRIPT) -shared -Bsymbolic -L$(EFILIB) -L$(GNUEFILIB) $(CRTOBJS)
101 LIBS = -lefi -lgnuefi $(shell $(CC) $(ARCH3264) -print-libgcc-file-name)
102
103
104 # general rules
105
106 %.o: %.c
107 $(CC) $(LOCAL_CPPFLAGS) $(CPPFLAGS) $(LOCAL_CFLAGS) $(CFLAGS) -c $< -o $@
108
109 # rules for EFI applications
110
111 ifneq (,$(filter %.efi,$(TARGET)))
112
113 SHLIB_TARGET = $(subst .efi,.so,$(TARGET))
114
115 endif
116
117 # rules for libraries
118
119 ifneq (,$(filter %.a,$(TARGET)))
120
121 $(TARGET): $(OBJS)
122 $(AR) cq $@ $(OBJS)
123
124 endif
125
126 # utility rules
127
128 clean:
129 rm -f $(TARGET) *~ *.so $(OBJS) *.efi *.obj refind_*.txt refind_*.dll *.lib
130
131 # EOF