1 | ## ----------------------------------------------------------------------- |
---|
2 | ## |
---|
3 | ## Copyright 2011 Intel Corporation; author: Matt Fleming |
---|
4 | ## |
---|
5 | ## This program is free software; you can redistribute it and/or modify |
---|
6 | ## it under the terms of the GNU General Public License as published by |
---|
7 | ## the Free Software Foundation, Inc., 53 Temple Place Ste 330, |
---|
8 | ## Boston MA 02111-1307, USA; either version 2 of the License, or |
---|
9 | ## (at your option) any later version; incorporated herein by reference. |
---|
10 | ## |
---|
11 | ## ----------------------------------------------------------------------- |
---|
12 | |
---|
13 | VPATH = $(SRC) |
---|
14 | include $(MAKEDIR)/lib.mk |
---|
15 | include $(MAKEDIR)/efi.mk |
---|
16 | |
---|
17 | # Upstream gnu-efi has old-style function definitions. |
---|
18 | CFLAGS += -Wno-strict-prototypes |
---|
19 | |
---|
20 | CORE_CSRC := $(wildcard $(core)/*.c $(core)/*/*.c $(core)/*/*/*.c) |
---|
21 | CORE_COBJ := $(subst $(core),$(OBJ)/../core/,$(patsubst %.c,%.o,$(CORE_CSRC))) |
---|
22 | |
---|
23 | # We don't want to include any of the networking stack or the thread |
---|
24 | # code since it will be implemented completely differently for EFI. |
---|
25 | FILTERED_OBJS:= $(subst $(core),$(OBJ)/../core/,$(patsubst %.c,%.o, \ |
---|
26 | $(wildcard $(core)/legacynet/*.c) \ |
---|
27 | $(wildcard $(core)/fs/pxe/*.c) \ |
---|
28 | $(wildcard $(core)/thread/*.c))) |
---|
29 | |
---|
30 | # Don't include unit tests |
---|
31 | FILTERED_OBJS += $(subst $(core),$(OBJ)/../core/, \ |
---|
32 | $(patsubst %.c,%.o,$(shell find $(core) -path "*/tests/*.c" -print))) |
---|
33 | |
---|
34 | # Don't include console objects |
---|
35 | CORE_OBJS = $(filter-out %hello.o %rawcon.o %plaincon.o %strcasecmp.o %bios.o \ |
---|
36 | %diskio_bios.o %ldlinux-c.o %isolinux-c.o %pxelinux-c.o \ |
---|
37 | %localboot.o %pxeboot.o \ |
---|
38 | $(FILTERED_OBJS),$(CORE_COBJ) $(CORE_SOBJ)) |
---|
39 | |
---|
40 | CORE_OBJS += $(addprefix $(OBJ)/../core/, \ |
---|
41 | fs/pxe/pxe.o fs/pxe/tftp.o fs/pxe/urlparse.o fs/pxe/dhcp_option.o \ |
---|
42 | fs/pxe/ftp.o fs/pxe/ftp_readdir.o fs/pxe/http.o fs/pxe/http_readdir.o) |
---|
43 | |
---|
44 | LIB_OBJS = $(addprefix $(objdir)/com32/lib/,$(CORELIBOBJS)) \ |
---|
45 | $(LIBEFI) |
---|
46 | |
---|
47 | CSRC = $(wildcard $(SRC)/*.c) |
---|
48 | OBJS = $(subst $(SRC)/,,$(filter-out %wrapper.o, $(patsubst %.c,%.o,$(CSRC)))) |
---|
49 | |
---|
50 | OBJS += $(objdir)/core/codepage.o $(ARCH)/linux.o |
---|
51 | |
---|
52 | # The DATE is set on the make command line when building binaries for |
---|
53 | # official release. Otherwise, substitute a hex string that is pretty much |
---|
54 | # guaranteed to be unique to be unique from build to build. |
---|
55 | ifndef HEXDATE |
---|
56 | HEXDATE := $(shell $(PERL) $(SRC)/../now.pl $(SRCS)) |
---|
57 | endif |
---|
58 | ifndef DATE |
---|
59 | DATE := $(shell sh $(SRC)/../gen-id.sh $(VERSION) $(HEXDATE)) |
---|
60 | endif |
---|
61 | CFLAGS += -DDATE_STR='"$(DATE)"' |
---|
62 | |
---|
63 | .PHONY: subdirs |
---|
64 | subdirs: |
---|
65 | mkdir -p $(ARCH) |
---|
66 | |
---|
67 | $(OBJS): subdirs |
---|
68 | |
---|
69 | # The targets to build in this directory |
---|
70 | BTARGET = syslinux.efi |
---|
71 | |
---|
72 | syslinux.so: $(OBJS) $(CORE_OBJS) $(LIB_OBJS) |
---|
73 | $(LD) $(LDFLAGS) --strip-debug -o $@ $^ -lgnuefi -lefi |
---|
74 | |
---|
75 | # We need to rename the .hash section because the EFI firmware |
---|
76 | # linker really doesn't like it. |
---|
77 | # $(OBJCOPY) --rename-section .gnu.hash=.sdata,load,data,alloc $^ $@ |
---|
78 | #syslinux.so: syslinux1.so |
---|
79 | # cp $^ $@ |
---|
80 | |
---|
81 | wrapper: wrapper.c |
---|
82 | $(CC) $^ -o $@ |
---|
83 | |
---|
84 | # |
---|
85 | # Build the wrapper app and wrap our .so to produce a .efi |
---|
86 | syslinux.efi: syslinux.so wrapper |
---|
87 | $(OBJ)/wrapper syslinux.so $@ |
---|
88 | |
---|
89 | all: $(BTARGET) |
---|
90 | |
---|
91 | codepage.o: ../codepage/cp865.cp |
---|
92 | cp $(objdir)/../codepage/cp865.cp codepage.cp |
---|
93 | $(CC) $(SFLAGS) -c -o $@ $(core)/codepage.S |
---|
94 | |
---|
95 | install: |
---|
96 | install -m 755 $(BTARGET) $(INSTALLROOT)$(AUXDIR) |
---|
97 | |
---|
98 | strip: |
---|
99 | |
---|
100 | tidy dist: |
---|
101 | rm -f *.so *.o wrapper |
---|
102 | find . \( -name \*.o -o -name \*.a -o -name .\*.d -o -name \*.tmp \) -print0 | \ |
---|
103 | xargs -0r rm -f |
---|
104 | $(topdir)/efi/clean-gnu-efi.sh $(EFI_SUBARCH) $(objdir) |
---|
105 | |
---|
106 | clean: tidy |
---|
107 | |
---|
108 | spotless: clean |
---|
109 | rm -f $(BTARGET) |
---|