File: Make.common

package info (click to toggle)
refit 0.14-2
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 2,840 kB
  • ctags: 3,282
  • sloc: ansic: 13,877; python: 631; objc: 319; makefile: 92; perl: 45; sh: 16
file content (112 lines) | stat: -rw-r--r-- 2,542 bytes parent folder | download
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
#
# Make.common
# Common make rules for building with gnu-efi
#

EFIINC          = /usr/include/efi
GNUEFILIB       = /usr/lib
EFILIB          = /usr/lib
EFICRT0         = /usr/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 -DCONFIG_$(ARCH)

OPTIMFLAGS      = -O2 -fno-strict-aliasing
DEBUGFLAGS      = -Wall
CFLAGS          = $(ARCH3264) $(OPTIMFLAGS) -fpic -fshort-wchar $(DEBUGFLAGS)
ASFLAGS         = $(ARCH3264)
LDFLAGS         = -nostdlib -znocombreloc

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 -mno-red-zone
  CPPFLAGS += -DEFIX64

  ifeq ($(HOSTARCH),ia32)
    ARCH3264 = -m64

    GNUEFILIB := $(GNUEFILIB)64
    EFILIB    := $(EFILIB)64
    EFICRT0   := $(EFICRT0)64
  endif
endif

ifeq ($(ARCH),ia32)
  CPPFLAGS += -DEFI32

  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)


# 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)

# EOF