1# Copyright (c) 2010 by Peter Jeremy <peterjeremy@acm.org>
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions
6# are met:
7# 1. Redistributions of source code must retain the above copyright
8#    notice, this list of conditions and the following disclaimer.
9# 2. Redistributions in binary form must reproduce the above copyright
10#    notice, this list of conditions and the following disclaimer in the
11#    documentation and/or other materials provided with the distribution.
12#
13# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16# IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
17# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
22# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23#
24# $FreeBSD$
25
26.PATH: ${.CURDIR}/../../../../lib/libc/softfloat/bits64 ${.CURDIR}/..
27
28LIBC_DIR=	${.CURDIR}/../../../../lib/libc
29EMUFLOAT_DIR=	${LIBC_DIR}/sparc64/fpu
30
31LN=	ln -sf
32
33# Common source files
34SRCS1=	fail.c random.c softfloat.c testCases.c testLoops.c writeHex.c
35
36# Additional common sources to build testfloat/testemufloat
37SRCS2=	testFunction.c testfloat.c
38
39# Additional sources to build testemufloat
40SRCS3=	fpu.c fpu_add.c fpu_compare.c fpu_div.c fpu_emul.S fpu_explode.c \
41	fpu_implode.c fpu_mul.c fpu_qp.c fpu_sqrt.c fpu_subr.c fpu_util.c
42
43# Additional sources to build testfloat
44SRCS4=	systflags.c systfloat.S systmodes.c
45
46# Additional sources to build testsoftfloat
47SRCS5=	slowfloat.c testsoftfloat.c
48
49SRCS=	${SRCS1} ${SRCS2} ${SRCS3} ${SRCS4} ${SRCS5}
50
51OBJ_TF=		${SRCS1:R:S/$/.o/g} ${SRCS2:R:S/$/.o/g} ${SRCS4:R:S/$/.o/g}
52OBJ_TEF=	${SRCS1:R:S/$/.o/g} ${SRCS2:R:S/$/.o/g} ${SRCS3:R:S/$/.o/g}
53OBJ_TSF=	${SRCS1:R:S/$/.o/g} ${SRCS5:R:S/$/.o/g}
54
55all: testfloat testemufloat testsoftfloat
56
57CFLAGS+=	-I. -I${.CURDIR} -I${.CURDIR}/.. -I${LIBC_DIR}/sparc64/fpu \
58	-I${LIBC_DIR}/sparc64/sys -I${LIBC_DIR}/softfloat/bits64 \
59	-I${LIBC_DIR}/softfloat
60
61CLEANFILES+=	fpu.c fpu_add.c fpu_compare.c fpu_div.c fpu_emu.h \
62	fpu_explode.c fpu_implode.c fpu_mul.c fpu_qp.c fpu_sqrt.c fpu_subr.c \
63	${SRCS:R:S/$/.o/g} testfloat testemufloat testsoftfloat
64
65testsoftfloat: ${OBJ_TSF}
66	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJ_TSF}
67
68testfloat: ${OBJ_TF}
69	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJ_TF}
70
71testemufloat: ${OBJ_TEF}
72	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJ_TEF}
73
74beforedepend: fpu_emu.h
75
76# The emulator code needs to be built with a local fpu_reg.h instead of
77# the one in ${EMUFLOAT_DIR}.  Unfortunately, C preprocessor semantics
78# means that a header file in the same directory as the source file
79# overrides any alternative header file location.  In order to include
80# the wanted header file, create symlinks pointing to the real files
81# and compile through the symlink.
82fpu.c: ${EMUFLOAT_DIR}/fpu.c
83	${LN} ${.ALLSRC} ${.TARGET}
84fpu_add.c: ${EMUFLOAT_DIR}/fpu_add.c
85	${LN} ${.ALLSRC} ${.TARGET}
86fpu_compare.c: ${EMUFLOAT_DIR}/fpu_compare.c
87	${LN} ${.ALLSRC} ${.TARGET}
88fpu_div.c: ${EMUFLOAT_DIR}/fpu_div.c
89	${LN} ${.ALLSRC} ${.TARGET}
90fpu_emu.h: ${EMUFLOAT_DIR}/fpu_emu.h
91	${LN} ${.ALLSRC} ${.TARGET}
92fpu_explode.c: ${EMUFLOAT_DIR}/fpu_explode.c
93	${LN} ${.ALLSRC} ${.TARGET}
94fpu_implode.c: ${EMUFLOAT_DIR}/fpu_implode.c
95	${LN} ${.ALLSRC} ${.TARGET}
96fpu_mul.c: ${EMUFLOAT_DIR}/fpu_mul.c
97	${LN} ${.ALLSRC} ${.TARGET}
98fpu_qp.c: ${EMUFLOAT_DIR}/fpu_qp.c
99	${LN} ${.ALLSRC} ${.TARGET}
100fpu_sqrt.c: ${EMUFLOAT_DIR}/fpu_sqrt.c
101	${LN} ${.ALLSRC} ${.TARGET}
102fpu_subr.c: ${EMUFLOAT_DIR}/fpu_subr.c
103	${LN} ${.ALLSRC} ${.TARGET}
104
105.include <bsd.prog.mk>
106