xref: /freebsd/sys/conf/Makefile.arm (revision 995dc984471c92c03daad19a1d35af46c086ef3e)
1# Makefile.arm -- with config changes.
2# Copyright 1990 W. Jolitz
3#	from: @(#)Makefile.i386	7.1 5/10/91
4# $FreeBSD$
5#
6# Makefile for FreeBSD
7#
8# This makefile is constructed from a machine description:
9#	config machineid
10# Most changes should be made in the machine description
11#	/sys/arm/conf/``machineid''
12# after which you should do
13#	 config machineid
14# Generic makefile changes should be made in
15#	/sys/conf/Makefile.arm
16# after which config should be rerun for all machines.
17#
18
19# Which version of config(8) is required.
20%VERSREQ=	600004
21
22# Temporary stuff while we're still embryonic
23NO_MODULES=
24
25STD8X16FONT?=	iso
26
27.if !defined(S)
28.if exists(./@/.)
29S=	./@
30.else
31S=	../../..
32.endif
33.endif
34.include "$S/conf/kern.pre.mk"
35
36SYSTEM_LD:= ${SYSTEM_LD:$S/conf/ldscript.$M=ldscript.$M}
37SYSTEM_DEP:= ${SYSTEM_DEP:$S/conf/ldscript.$M=ldscript.$M}
38
39.if defined(ARM_BIG_ENDIAN)
40CC += -mbig-endian
41SYSTEM_LD += -EB
42LD += -EB
43.endif
44
45
46.if !defined(DEBUG) && !defined(PROFLEVEL)
47STRIP_FLAGS = -S
48.endif
49
50DDB_ENABLED!=	grep DDB opt_ddb.h || true
51
52.if empty(DDB_ENABLED)
53CFLAGS += -mno-apcs-frame
54.endif
55
56SYSTEM_LD_ = ${LD} -Bdynamic -T ldscript.$M.noheader \
57	  -warn-common -export-dynamic -dynamic-linker /red/herring -o \
58	   ${FULLKERNEL}.noheader -X ${SYSTEM_OBJS} vers.o
59SYSTEM_LD_TAIL +=;sed s/" + SIZEOF_HEADERS"// ldscript.$M\
60		>ldscript.$M.noheader; \
61		${SYSTEM_LD_}; \
62		${OBJCOPY} -S -O binary ${FULLKERNEL}.noheader \
63		${KERNEL_KO}.bin; \
64		rm ${FULLKERNEL}.noheader
65
66.if defined(MFS_IMAGE)
67SYSTEM_LD_TAIL += ;sh ${S}/tools/embed_mfs.sh ${KERNEL_KO}.bin ${MFS_IMAGE};
68.endif
69
70FILES_CPU_FUNC =	$S/$M/$M/cpufunc_asm_arm7tdmi.S \
71	$S/$M/$M/cpufunc_asm_arm8.S $S/$M/$M/cpufunc_asm_arm9.S \
72	$S/$M/$M/cpufunc_asm_sa1.S $S/$M/$M/cpufunc_asm_arm10.S \
73	$S/$M/$M/cpufunc_asm_xscale.S $S/$M/$M/cpufunc_asm.S \
74	$S/$M/$M/cpufunc_asm_xscale_c3.S
75trampoline: ${KERNEL_KO}.tramp
76${KERNEL_KO}.tramp: ${KERNEL_KO} $S/$M/$M/inckern.S $S/$M/$M/elf_trampoline.c
77	echo "#define KERNNAME \"${KERNEL_KO}.tmp\"" >opt_kernname.h
78	sed s/${KERNVIRTADDR}/${KERNPHYSADDR}/ ldscript.$M > ldscript.$M.tramp
79	sed s/" + SIZEOF_HEADERS"// ldscript.$M.tramp > \
80	ldscript.$M.tramp.noheader
81	echo "#include <machine/asm.h>" >tmphack.S
82	echo "ENTRY(_start)" >>tmphack.S
83	echo "bl _startC" >>tmphack.S
84	${OBJCOPY} --strip-symbol '$$d' --strip-symbol '$$a' \
85	-g --strip-symbol '$$t' ${FULLKERNEL} ${KERNEL_KO}.tmp
86	eval $$(stat -s ${KERNEL_KO}.tmp) && \
87	echo "#define KERNSIZE $$st_size" >>opt_kernname.h
88	${CC} -O -nostdlib -I. -Xlinker -T -Xlinker ldscript.$M.tramp \
89	tmphack.S $S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S \
90	${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp
91	${CC} -O -nostdlib -I. -Xlinker -T -Xlinker ldscript.$M.tramp.noheader \
92	tmphack.S $S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S \
93	${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp.noheader
94	${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
95	${KERNEL_KO}.tramp.bin
96	${OBJCOPY} ${STRIP_FLAGS} ${KERNEL_KO}.tmp
97	echo "#define KERNNAME \"${KERNEL_KO}.tmp.gz\"" \
98	>opt_kernname.h
99	eval $$(stat -s ${KERNEL_KO}.tmp) && \
100	echo "#define KERNSIZE $$st_size" >>opt_kernname.h
101	gzip -9 ${KERNEL_KO}.tmp
102	eval $$(stat -s ${KERNEL_KO}.tmp.gz) && \
103	echo "#define KERNCOMPSIZE $$st_size" >>opt_kernname.h
104	${CC} -O2 -DKZIP -I. -c $S/kern/inflate.c -o inflate-tramp.o
105	${CC} -O -nostdlib -I. -Xlinker -T -Xlinker ldscript.$M.tramp \
106	-DKZIP tmphack.S $S/$M/$M/elf_trampoline.c inflate-tramp.o \
107	$S/$M/$M/inckern.S ${FILES_CPU_FUNC} -o ${KERNEL_KO}.gz.tramp
108	${CC} -O -nostdlib -I. -Xlinker -T -Xlinker ldscript.$M.tramp.noheader \
109	-DKZIP tmphack.S $S/$M/$M/elf_trampoline.c inflate-tramp.o \
110	$S/$M/$M/inckern.S ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp.noheader
111	${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
112	${KERNEL_KO}.gz.tramp.bin
113	rm ${KERNEL_KO}.tmp.gz ${KERNEL_KO}.tramp.noheader opt_kernname.h \
114	inflate-tramp.o tmphack.S
115
116%BEFORE_DEPEND
117
118%OBJS
119
120%FILES.c
121
122%FILES.s
123
124%FILES.m
125
126%CLEAN
127
128CLEAN+=	ldscript.$M ${KERNEL_KO}.bin ldscript.$M.noheader
129
130.if ${DDB_ENABLED} != ""
131CLEAN+= ${KERNEL_KO}.tramp ${KERNEL_KO}.tramp.bin ldscript.$M.tramp \
132	ldscript.$M.tramp.noheader ${KERNEL_KO}.gz.tramp \
133	${KERNEL_KO}.gz.tramp.bin
134
135.endif
136ldscript.$M: $S/conf/ldscript.$M
137	cat $S/conf/ldscript.$M|sed s/KERNPHYSADDR/${KERNPHYSADDR}/g| \
138	  sed s/KERNVIRTADDR/${KERNVIRTADDR}/g > ldscript.$M
139%RULES
140
141.include "$S/conf/kern.post.mk"
142