Merge from vendor branch CVS:
[dragonfly.git] / sys / boot / efi / loader / Makefile
1 # $FreeBSD$
2 # $DragonFly: src/sys/boot/efi/loader/Makefile,v 1.1 2003/11/10 06:08:33 dillon Exp $
3
4 .PATH: ${.CURDIR}/../common
5
6 BASE=           loader
7 PROG=           ${BASE}.efi
8 NOMAN=
9 NEWVERSWHAT=    "EFI boot" ${MACHINE_ARCH}
10 BINDIR?=        /boot
11 STRIP=          # We must not strip loader.efi at install time.
12
13 SRCS+=          main.c conf.c dev_net.c
14
15 CFLAGS+=        -ffreestanding
16
17 .if !defined(NOFORTH)
18 # Enable BootForth
19 BOOT_FORTH=     yes
20 CFLAGS+=        -DBOOT_FORTH
21 CFLAGS+=        -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/${MACHINE_ARCH}
22 .if exists(${.OBJDIR}/../../ficl/libficl.a)
23 LIBFICL=        ${.OBJDIR}/../../ficl/libficl.a
24 .else
25 LIBFICL=        ${.CURDIR}/../../ficl/libficl.a
26 .endif
27 .endif
28
29 # where to get libstand from
30 .if exists(${.OBJDIR}/../../../../lib/libstand/libstand.a)
31 LIBSTAND=       ${.OBJDIR}/../../../../lib/libstand/libstand.a
32 .else
33 LIBSTAND=       ${.CURDIR}/../../../../lib/libstand/libstand.a
34 .endif
35
36 .if exists(${.OBJDIR}/../libefi/libefi.a)
37 LIBEFI=         ${.OBJDIR}/../libefi/libefi.a
38 .else
39 LIBEFI=         ${.CURDIR}/../libefi/libefi.a
40 .endif
41
42 # Always add MI sources 
43 .PATH: ${.CURDIR}/../../common
44 .include <${.CURDIR}/../../common/Makefile.inc>
45
46 CFLAGS+= -I-
47 CFLAGS+= -I${.CURDIR}/../include
48 CFLAGS+= -I${.CURDIR}/../include/${MACHINE_ARCH}
49 CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}
50 CFLAGS+= -I${.CURDIR}/../../.. -I.
51 CFLAGS+= -I${.CURDIR}/../libefi
52 CFLAGS+= -I${.CURDIR}/../../../../lib/libstand
53 CFLAGS+= -DLOADER
54
55 LDSCRIPT=       ${.CURDIR}/../libefi/arch/${MACHINE_ARCH}/ldscript.${MACHINE_ARCH}
56 LDFLAGS=        -nostdlib -T ${LDSCRIPT} -shared -Bsymbolic
57 OBJCOPY?=       objcopy
58
59 CLEANFILES+=    setdef0.c setdef0.o setdef1.c setdef1.o setdefs.h start.o \
60                 vers.c vers.o ${BASE}.efi ${BASE}.sym ${BASE}.list
61 CLEANFILES+=    loader.help
62 CLEANFILES+=    machine
63
64 CRT=    start.o
65
66 all: ${BASE}
67
68 vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
69         sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
70         ${CC} -c vers.c
71
72 ${BASE}:        ${BASE}.efi ${BASE}.help
73
74 ${BASE}.efi: ${BASE}.sym
75         ${OBJCOPY} -j .text \
76                 -j .hash \
77                 -j .data \
78                 -j .sdata \
79                 -j .dynamic \
80                 -j .rela \
81                 -j .reloc \
82                 -j .dynsym \
83                 -j .dynstr \
84                 --target=efi-app-${MACHINE_ARCH} \
85                 ${BASE}.sym ${BASE}.efi
86
87 ${BASE}.help:   help.common
88         cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk \
89             > ${.TARGET}
90
91 beforeinstall:
92 .if exists(${.OBJDIR}/loader.help)
93         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
94                 ${.OBJDIR}/${BASE}.help ${DESTDIR}/boot
95 .else
96         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
97                 ${.CURDIR}/${BASE}.help ${DESTDIR}/boot
98 .endif
99 .if !exists(${DESTDIR}/boot/loader.rc)
100         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
101                 ${.CURDIR}/../../forth/loader.rc ${DESTDIR}/boot
102 .endif
103         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
104                 ${.CURDIR}/../../forth/loader.4th ${DESTDIR}/boot
105         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
106                 ${.CURDIR}/../../forth/support.4th ${DESTDIR}/boot
107         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
108                 ${.CURDIR}/../../forth/loader.conf ${DESTDIR}/boot/defaults
109
110
111 # Other fragments still to be brought in from ../Makfile.booters?
112 start.o: ${.CURDIR}/../libefi/arch/${MACHINE_ARCH}/start.S
113         ${CC} -c ${CFLAGS} ${.IMPSRC}
114
115 machine:
116         ln -sf ${.CURDIR}/../../../${MACHINE_ARCH}/include machine
117
118 .include <bsd.prog.mk>
119
120 ${BASE}.sym: ${OBJS} ${LIBFICL} ${LIBEFI} ${LIBSTAND} ${CRT} vers.o
121         ${LD} ${LDFLAGS} -o ${BASE}.sym -M ${CRT} ${OBJS} vers.o \
122             ${LIBFICL} ${LIBEFI} ${LIBSTAND} > ${.OBJDIR}/${BASE}.list
123
124 beforedepend ${OBJS}: machine