xref: /openbsd/sys/arch/hppa/conf/Makefile.hppa (revision 8529ddd3)
1#	$OpenBSD: Makefile.hppa,v 1.80 2015/01/13 01:12:49 deraadt 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?=	strip
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. -I$S/arch
25CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -MD -MP
26CWARNFLAGS=	-Werror -Wall -Wimplicit-function-declaration \
27		-Wno-main -Wno-uninitialized \
28		-Wframe-larger-than=2047
29
30CMACHFLAGS=	-mfast-indirect-calls -mportable-runtime -mno-space-regs
31CMACHFLAGS+=	-fno-builtin-printf -fno-builtin-snprintf \
32		-fno-builtin-vsnprintf -fno-builtin-log \
33		-fno-builtin-log2 -fno-builtin-malloc ${NOPIE_FLAGS}
34CMACHFLAGS+=	-fno-stack-protector
35
36COPTS?=		-O2
37CFLAGS=		${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE}
38AFLAGS=		-D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS}
39LDSCRIPT=	${_machdir}/conf/ld.script
40LINKFLAGS=	-X -T ${LDSCRIPT} -Ttext 80000 --warn-common -nopie
41
42.if ${IDENT:M-DDDB} != ""
43CFLAGS+=	-fno-omit-frame-pointer
44.endif
45
46.if ${IDENT:M-DHP7000_CPU} != ""
47CFLAGS+=	-mpa-risc-1-0
48.elif ${IDENT:M-DHP8*_CPU} != ""
49CFLAGS+=	-mpa-risc-2-0
50.else
51CFLAGS+=	-mpa-risc-1-1
52.endif
53
54.if ${IDENT:M-DDDB_STRUCT}
55DB_STRUCTINFO=	db_structinfo.h
56.else
57DB_STRUCTINFO=
58.endif
59
60HOSTCC?=	${CC}
61HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
62HOSTED_CFLAGS=	${CFLAGS}
63HOSTED_C=	${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
64
65NORMAL_C_NOP=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
66NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
67NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
68
69%OBJS
70
71%CFILES
72
73%SFILES
74
75# load lines for config "xxx" will be emitted as:
76# xxx: ${SYSTEM_DEP} swapxxx.o
77#	${SYSTEM_LD_HEAD}
78#	${SYSTEM_LD} swapxxx.o
79#	${SYSTEM_LD_TAIL}
80SYSTEM_HEAD=	locore.o param.o ioconf.o
81SYSTEM_OBJ=	${SYSTEM_HEAD} ${OBJS}
82SYSTEM_DEP=	Makefile ${SYSTEM_OBJ} ${LDSCRIPT}
83SYSTEM_LD_HEAD=	@rm -f $@
84SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \
85		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} vers.o ${OBJS}
86SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
87
88DEBUG?=
89.if ${DEBUG} == "-g"
90STRIPFLAGS=	-g -x
91SYSTEM_LD_TAIL+=; \
92		echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \
93		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
94		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
95.else
96LINKFLAGS+=	-S -x
97.endif
98
99%LOAD
100
101# cc's -MD puts the source and output paths in the dependency file;
102# since those are temp files here we need to fix it up.  It also
103# puts the file in /tmp, so we use -MF to put it in the current
104# directory as assym.P and then generate assym.d from it with a
105# good target name
106assym.h: $S/kern/genassym.sh Makefile \
107	 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf
108	cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \
109	    sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp
110	sed '1s/.*/assym.h: \\/' assym.P > assym.d
111	sort -u assym.h.tmp > assym.h
112
113param.c: $S/conf/param.c
114	rm -f param.c
115	cp $S/conf/param.c .
116
117param.o: param.c Makefile
118	${NORMAL_C}
119
120mcount.o: $S/lib/libkern/mcount.c Makefile
121	${NORMAL_C_NOP}
122
123ioconf.o: ioconf.c
124	${NORMAL_C}
125
126vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
127	sh $S/conf/newvers.sh
128	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
129
130clean::
131	rm -f eddep *bsd *bsd.gdb tags *.[dio] [a-z]*.s \
132	    [Ee]rrs linterrs assym.h ${DB_STRUCTINFO}
133
134lint:
135	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
136	    ${CFILES} ioconf.c param.c | \
137	    grep -v 'static function .* unused'
138
139depend:
140	@touch $@
141
142tags:
143	@echo "see $S/kern/Makefile for tags"
144
145db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.pl
146	${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c
147	objdump -g db_structinfo.o | perl $S/ddb/parse_structinfo.pl > $@
148	rm -f db_structinfo.o
149
150locore.o: ${_machdir}/${_mach}/locore.S assym.h
151fpemu.o spcopy.o: assym.h
152
153# The install target can be redefined by putting a
154# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
155MACHINE_NAME!=  uname -n
156install: install-kernel-${MACHINE_NAME}
157.if !target(install-kernel-${MACHINE_NAME}})
158install-kernel-${MACHINE_NAME}:
159	cmp -s bsd /bsd || ln -f /bsd /obsd
160	cp bsd /nbsd
161	mv /nbsd /bsd
162.endif
163
164# pull in the dependency information
165.if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO})
166 ${SYSTEM_OBJ}: ${DB_STRUCTINFO}
167.endif
168.ifnmake clean
169. for o in ${SYSTEM_OBJ} assym.h ${DB_STRUCTINFO}
170.  if exists(${o:R}.d)
171.   include "${o:R}.d"
172.  elif exists($o)
173    .PHONY: $o
174.  endif
175. endfor
176.endif
177
178%RULES
179