xref: /openbsd-src/sys/arch/hppa/conf/Makefile.hppa (revision bf198cc6eba0ca1f6d79f71e8e2243d386241fa8)
1#	$OpenBSD: Makefile.hppa,v 1.105 2018/02/09 03:59:15 tb Exp $
2
3# For instructions on building kernels consult the config(8) and options(4)
4# manual pages.
5#
6# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
7#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
8# DEBUG is set to -g by config if debugging is requested (config -g).
9# PROF is set to -pg by config if profiling is requested (config -p).
10
11.include <bsd.own.mk>
12
13SIZE?=	size
14STRIP?=	ctfstrip
15
16# source tree is located via $S relative to the compilation directory
17.ifndef S
18S!=	cd ../../../..; pwd
19.endif
20
21_machdir?=	$S/arch/${_mach}
22_archdir?=	$S/arch/${_arch}
23
24INCLUDES=	-nostdinc -I$S -I${.OBJDIR} -I$S/arch
25CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -MD -MP
26CWARNFLAGS=	-Werror -Wall -Wimplicit-function-declaration \
27		-Wno-uninitialized -Wno-pointer-sign \
28		-Wframe-larger-than=2047
29
30CMACHFLAGS=	-mfast-indirect-calls -mportable-runtime -mno-space-regs
31CMACHFLAGS+=	-ffreestanding ${NOPIE_FLAGS}
32CMACHFLAGS+=	-fno-stack-protector
33SORTR=		sort -R
34
35DEBUG?=		-g
36COPTS?=		-O2
37CFLAGS=		${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE}
38AFLAGS=		-D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS}
39LINKFLAGS=	-X -T ld.script -Ttext 80000 --warn-common -nopie
40
41.if ${IDENT:M-DDDB} != ""
42CFLAGS+=	-fno-omit-frame-pointer
43.endif
44.if ${IDENT:M-DSMALL_KERNEL}
45SORTR=		cat
46.endif
47
48.if ${IDENT:M-DHP7000_CPU} != ""
49CFLAGS+=	-mpa-risc-1-0
50.elif ${IDENT:M-DHP8*_CPU} != ""
51CFLAGS+=	-mpa-risc-2-0
52.else
53CFLAGS+=	-mpa-risc-1-1
54.endif
55
56HOSTCC?=	${CC}
57HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
58HOSTED_CFLAGS=	${CFLAGS}
59HOSTED_C=	${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
60
61NORMAL_C_NOP=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
62NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
63NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
64
65%OBJS
66
67%CFILES
68
69%SFILES
70
71# load lines for config "xxx" will be emitted as:
72# xxx: ${SYSTEM_DEP} swapxxx.o
73#	${SYSTEM_LD_HEAD}
74#	${SYSTEM_LD} swapxxx.o
75#	${SYSTEM_LD_TAIL}
76SYSTEM_HEAD=	locore0.o gap.o
77SYSTEM_OBJ=	${SYSTEM_HEAD} ${OBJS} param.o ioconf.o
78SYSTEM_DEP=	Makefile ${SYSTEM_OBJ} ld.script
79SYSTEM_LD_HEAD=	@rm -f $@
80SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \
81		umask 007; \
82		echo ${OBJS} param.o ioconf.o vers.o | tr " " "\n" | ${SORTR} > lorder; \
83		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} `cat lorder`
84SYSTEM_LD_TAIL=	@${SIZE} $@
85
86.if ${DEBUG} == "-g"
87STRIPFLAGS=	-S
88SYSTEM_LD_TAIL+=; umask 007; \
89		echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \
90		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
91		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
92.else
93LINKFLAGS+=	-S
94.endif
95
96%LOAD
97
98# cc's -MD puts the source and output paths in the dependency file;
99# since those are temp files here we need to fix it up.  It also
100# puts the file in /tmp, so we use -MF to put it in the current
101# directory as assym.P and then generate assym.d from it with a
102# good target name
103assym.h: $S/kern/genassym.sh Makefile \
104	 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf
105	cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \
106	    sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp
107	sed '1s/.*/assym.h: \\/' assym.P > assym.d
108	sort -u assym.h.tmp > assym.h
109
110param.c: $S/conf/param.c
111	rm -f param.c
112	cp $S/conf/param.c .
113
114param.o: param.c Makefile
115	${NORMAL_C}
116
117mcount.o: $S/lib/libkern/mcount.c Makefile
118	${NORMAL_C_NOP}
119
120ioconf.o: ioconf.c
121	${NORMAL_C}
122
123ld.script: ${_machdir}/conf/ld.script
124	cp ${_machdir}/conf/ld.script $@
125
126makegap.sh:
127	cp $S/conf/makegap.sh $@
128
129MAKE_GAP = LD="${LD}" sh makegap.sh 0x00000000	# BREAK 0,0 -> trap
130
131gap.o:	Makefile makegap.sh vers.o
132	${MAKE_GAP}
133
134vers.o: ${SYSTEM_DEP:Ngap.o}
135	sh $S/conf/newvers.sh
136	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
137
138clean:
139	rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* \
140	    gap.link ld.script lorder makegap.sh param.c
141
142cleandir: clean
143	rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c
144
145depend obj:
146
147locore0.o: ${_machdir}/${_mach}/locore0.S assym.h
148locore.o: ${_machdir}/${_mach}/locore.S assym.h
149fpemu.o spcopy.o: assym.h
150
151hardlink-obsd:
152	[[ ! -f /bsd ]] || cmp -s bsd /bsd || ln -f /bsd /obsd
153
154newinstall:
155	umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \
156	    sha256 -h /var/db/kernel.SHA256 /bsd
157
158install: update-link hardlink-obsd newinstall
159
160# pull in the dependency information
161.ifnmake clean
162. for o in ${SYSTEM_OBJ:Ngap.o} assym.h
163.  if exists(${o:R}.d)
164.   include "${o:R}.d"
165.  elif exists($o)
166    .PHONY: $o
167.  endif
168. endfor
169.endif
170
171%RULES
172