summaryrefslogtreecommitdiffstats
path: root/sys/conf/Makefile.arm
blob: 73d0e55df58865f6c6d24c943c929ab4d438beab (plain)
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
121
122
# Makefile.arm -- with config changes.
# Copyright 1990 W. Jolitz
#	from: @(#)Makefile.i386	7.1 5/10/91
# $FreeBSD$
#
# Makefile for FreeBSD
#
# This makefile is constructed from a machine description:
#	config machineid
# Most changes should be made in the machine description
#	/sys/arm/conf/``machineid''
# after which you should do
#	 config machineid
# Generic makefile changes should be made in
#	/sys/conf/Makefile.arm
# after which config should be rerun for all machines.
#

# Which version of config(8) is required.
%VERSREQ=	600004

# Temporary stuff while we're still embryonic
NO_MODULES=

STD8X16FONT?=	iso

.if !defined(S)
.if exists(./@/.)
S=	./@
.else
S=	../../..
.endif
.endif
.include "$S/conf/kern.pre.mk"

SYSTEM_LD:= ${SYSTEM_LD:$S/conf/ldscript.$M=ldscript.$M}
SYSTEM_DEP:= ${SYSTEM_DEP:$S/conf/ldscript.$M=ldscript.$M}

.if defined(ARM_BIG_ENDIAN)
CC += -mbig-endian
SYSTEM_LD += -EB
.endif


.if !defined(DEBUG) && !defined(PROFLEVEL)
CFLAGS += -mno-apcs-frame
STRIP_FLAGS = -S
.endif

DDB_ENABLED!=	grep DDB opt_ddb.h || true

SYSTEM_LD_ = ${LD} -Bdynamic -T ldscript.$M.noheader \
	  -warn-common -export-dynamic -dynamic-linker /red/herring -o \
	   ${FULLKERNEL}.noheader -X ${SYSTEM_OBJS} vers.o
SYSTEM_LD_TAIL +=;sed s/" + SIZEOF_HEADERS"// ldscript.$M\
		>ldscript.$M.noheader; \
		${SYSTEM_LD_}; \
		${OBJCOPY} -S -O binary ${FULLKERNEL}.noheader \
		${KERNEL_KO}.bin; \
		rm ${FULLKERNEL}.noheader

trampoline: ${KERNEL_KO}.tramp
${KERNEL_KO}.tramp: ${KERNEL_KO}
	echo "#define KERNNAME \"${KERNEL_KO}.tmp\"" >opt_kernname.h 
	sed s/${KERNVIRTADDR}/${KERNPHYSADDR}/ ldscript.$M > ldscript.$M.tramp
	sed s/" + SIZEOF_HEADERS"// ldscript.$M.tramp > \
	ldscript.$M.tramp.noheader
	${OBJCOPY} --strip-symbol '$$d' --strip-symbol '$$a' \
	-g --strip-symbol '$$t' ${FULLKERNEL} ${KERNEL_KO}.tmp
	${CC} -O -nostdlib -I. -Xlinker -T -Xlinker ldscript.$M.tramp \
	$S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S -o ${KERNEL_KO}.tramp
	${CC} -O -nostdlib -I. -Xlinker -T -Xlinker ldscript.$M.tramp.noheader \
	$S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S -o \
	${KERNEL_KO}.tramp.noheader 
	${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
	${KERNEL_KO}.tramp.bin 
	${OBJCOPY} ${STRIP_FLAGS} ${KERNEL_KO}.tmp 
	echo "#define KERNNAME \"${KERNEL_KO}.tmp.gz\"" \
	>opt_kernname.h 
	eval $$(stat -s ${KERNEL_KO}.tmp) && \
	echo "#define KERNSIZE $$st_size" >>opt_kernname.h
	gzip -9 ${KERNEL_KO}.tmp
	eval $$(stat -s ${KERNEL_KO}.tmp.gz) && \
	echo "#define KERNCOMPSIZE $$st_size" >>opt_kernname.h
	${CC} -O2 -DKZIP -I. -c $S/kern/inflate.c -o inflate-tramp.o
	${CC} -O -nostdlib -I. -Xlinker -T -Xlinker ldscript.$M.tramp \
	-DKZIP $S/$M/$M/elf_trampoline.c inflate-tramp.o $S/$M/$M/inckern.S \
	-o ${KERNEL_KO}.gz.tramp
	${CC} -O -nostdlib -I. -Xlinker -T -Xlinker ldscript.$M.tramp.noheader \
	-DKZIP $S/$M/$M/elf_trampoline.c inflate-tramp.o $S/$M/$M/inckern.S \
	-o ${KERNEL_KO}.tramp.noheader
	${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
	${KERNEL_KO}.gz.tramp.bin
	rm ${KERNEL_KO}.tmp.gz ${KERNEL_KO}.tramp.noheader opt_kernname.h \
	inflate-tramp.o

%BEFORE_DEPEND

%OBJS

%FILES.c

%FILES.s

%FILES.m

%CLEAN

CLEAN+=	ldscript.$M ${KERNEL_KO}.bin ldscript.$M.noheader

.if ${DDB_ENABLED} != ""
CLEAN+= ${KERNEL_KO}.tramp ${KERNEL_KO}.tramp.bin ldscript.$M.tramp \
	ldscript.$M.tramp.noheader ${KERNEL_KO}.gz.tramp \
	${KERNEL_KO}.gz.tramp.bin

.endif
ldscript.$M: $S/conf/ldscript.$M
	cat $S/conf/ldscript.$M|sed s/KERNPHYSADDR/${KERNPHYSADDR}/g| \
	  sed s/KERNVIRTADDR/${KERNVIRTADDR}/g > ldscript.$M
%RULES
	
.include "$S/conf/kern.post.mk"
OpenPOWER on IntegriCloud