xref: /minix/external/lgpl3/gmp/lib/libgmp/Makefile (revision 0a6a1f1d)
1*0a6a1f1dSLionel Sambuc#	$NetBSD: Makefile,v 1.24 2013/12/19 01:07:03 gdt Exp $
2e3209ae7SThomas Veerman
3e3209ae7SThomas Veerman.include <bsd.init.mk>
4e3209ae7SThomas Veerman
5e3209ae7SThomas Veerman# We don't install gmp, just provide it for GCC.
6e3209ae7SThomas VeermanLIBISPRIVATE?=	yes
7e3209ae7SThomas Veerman
884d9c625SLionel SambucGMP_MACHINE_ARCH?=	${MACHINE_ARCH:S/earmv4/arm/:C/armv[5-7]/arm/}
984d9c625SLionel Sambuc
10e3209ae7SThomas Veerman.if ${LIBISPRIVATE} != "yes"
11e3209ae7SThomas VeermanINCS=         gmp.h
12e3209ae7SThomas VeermanINCSDIR=      /usr/include
13e3209ae7SThomas Veerman.endif
14e3209ae7SThomas Veerman
15e3209ae7SThomas VeermanDIST=${.CURDIR}/../../dist
16e3209ae7SThomas Veerman
17e3209ae7SThomas VeermanLIB=	gmp
18e3209ae7SThomas Veerman
19e3209ae7SThomas VeermanMPF_SRCS = \
20e3209ae7SThomas Veerman	init.c init2.c inits.c set.c			\
21e3209ae7SThomas Veerman	set_ui.c set_si.c set_str.c set_d.c		\
22e3209ae7SThomas Veerman	set_z.c iset.c iset_ui.c iset_si.c		\
23e3209ae7SThomas Veerman	iset_str.c iset_d.c clear.c clears.c		\
24e3209ae7SThomas Veerman	get_str.c dump.c size.c eq.c reldiff.c		\
25e3209ae7SThomas Veerman	sqrt.c random2.c inp_str.c out_str.c		\
26e3209ae7SThomas Veerman	add.c add_ui.c sub.c sub_ui.c ui_sub.c		\
27e3209ae7SThomas Veerman	mul.c mul_ui.c div.c div_ui.c			\
28e3209ae7SThomas Veerman	cmp.c cmp_d.c cmp_ui.c cmp_si.c			\
29e3209ae7SThomas Veerman	mul_2exp.c div_2exp.c abs.c neg.c		\
30e3209ae7SThomas Veerman	set_q.c get_d.c get_d_2exp.c set_dfl_prec.c	\
31e3209ae7SThomas Veerman	set_prc.c set_prc_raw.c get_dfl_prec.c		\
32e3209ae7SThomas Veerman	get_prc.c ui_div.c sqrt_ui.c			\
33e3209ae7SThomas Veerman	ceilfloor.c trunc.c pow_ui.c			\
34e3209ae7SThomas Veerman	urandomb.c swap.c				\
35e3209ae7SThomas Veerman	fits_sint.c fits_slong.c fits_sshort.c		\
36e3209ae7SThomas Veerman	fits_uint.c fits_ulong.c fits_ushort.c		\
37e3209ae7SThomas Veerman	get_si.c get_ui.c				\
38e3209ae7SThomas Veerman	int_p.c
39e3209ae7SThomas Veerman
40e3209ae7SThomas VeermanMPZ_SRCS = \
41e3209ae7SThomas Veerman	abs.c add.c add_ui.c				\
42e3209ae7SThomas Veerman	aorsmul.c aorsmul_i.c and.c array_init.c	\
43e3209ae7SThomas Veerman	bin_ui.c bin_uiui.c				\
44e3209ae7SThomas Veerman	cdiv_q.c cdiv_q_ui.c				\
45e3209ae7SThomas Veerman	cdiv_qr.c cdiv_qr_ui.c				\
46e3209ae7SThomas Veerman	cdiv_r.c cdiv_r_ui.c cdiv_ui.c			\
47e3209ae7SThomas Veerman	cfdiv_q_2exp.c cfdiv_r_2exp.c			\
48e3209ae7SThomas Veerman	clear.c clears.c clrbit.c			\
49e3209ae7SThomas Veerman	cmp.c cmp_d.c cmp_si.c cmp_ui.c			\
50e3209ae7SThomas Veerman	cmpabs.c cmpabs_d.c cmpabs_ui.c			\
51e3209ae7SThomas Veerman	com.c combit.c					\
52e3209ae7SThomas Veerman	cong.c cong_2exp.c cong_ui.c			\
53e3209ae7SThomas Veerman	divexact.c divegcd.c dive_ui.c			\
54e3209ae7SThomas Veerman	divis.c divis_ui.c divis_2exp.c dump.c		\
55e3209ae7SThomas Veerman	export.c fac_ui.c fdiv_q.c			\
56e3209ae7SThomas Veerman	fdiv_q_ui.c fdiv_qr.c fdiv_qr_ui.c		\
57e3209ae7SThomas Veerman	fdiv_r.c fdiv_r_ui.c				\
58e3209ae7SThomas Veerman	fdiv_ui.c fib_ui.c fib2_ui.c fits_sint.c	\
59e3209ae7SThomas Veerman	fits_slong.c fits_sshort.c fits_uint.c		\
60e3209ae7SThomas Veerman	fits_ulong.c fits_ushort.c gcd.c		\
61e3209ae7SThomas Veerman	gcd_ui.c gcdext.c get_d.c get_d_2exp.c		\
62e3209ae7SThomas Veerman	get_si.c get_str.c get_ui.c getlimbn.c		\
63e3209ae7SThomas Veerman	hamdist.c					\
64e3209ae7SThomas Veerman	import.c init.c init2.c inits.c 		\
65e3209ae7SThomas Veerman	inp_raw.c inp_str.c invert.c			\
66e3209ae7SThomas Veerman	ior.c iset.c iset_d.c iset_si.c			\
67e3209ae7SThomas Veerman	iset_str.c iset_ui.c jacobi.c kronsz.c		\
68e3209ae7SThomas Veerman	kronuz.c kronzs.c kronzu.c			\
69e3209ae7SThomas Veerman	lcm.c lcm_ui.c lucnum_ui.c lucnum2_ui.c		\
70e3209ae7SThomas Veerman	millerrabin.c mod.c mul.c mul_2exp.c		\
71e3209ae7SThomas Veerman	mul_si.c mul_ui.c				\
72e3209ae7SThomas Veerman	n_pow_ui.c neg.c nextprime.c			\
73e3209ae7SThomas Veerman	out_raw.c out_str.c perfpow.c perfsqr.c		\
74e3209ae7SThomas Veerman	popcount.c pow_ui.c powm.c powm_sec.c		\
75e3209ae7SThomas Veerman	powm_ui.c pprime_p.c random.c random2.c		\
76e3209ae7SThomas Veerman	realloc.c realloc2.c remove.c			\
77e3209ae7SThomas Veerman	root.c rootrem.c rrandomb.c scan0.c		\
78e3209ae7SThomas Veerman	scan1.c set.c set_d.c set_f.c			\
79e3209ae7SThomas Veerman	set_q.c set_si.c set_str.c set_ui.c		\
80e3209ae7SThomas Veerman	setbit.c					\
81e3209ae7SThomas Veerman	size.c sizeinbase.c sqrt.c			\
82e3209ae7SThomas Veerman	sqrtrem.c sub.c sub_ui.c swap.c			\
83e3209ae7SThomas Veerman	tdiv_ui.c tdiv_q.c tdiv_q_2exp.c		\
84e3209ae7SThomas Veerman	tdiv_q_ui.c tdiv_qr.c tdiv_qr_ui.c		\
85e3209ae7SThomas Veerman	tdiv_r.c tdiv_r_2exp.c tdiv_r_ui.c		\
86e3209ae7SThomas Veerman	tstbit.c ui_pow_ui.c ui_sub.c urandomb.c	\
87e3209ae7SThomas Veerman	urandomm.c xor.c
88e3209ae7SThomas Veerman
89e3209ae7SThomas VeermanMPQ_SRCS = \
90e3209ae7SThomas Veerman	abs.c aors.c					\
91e3209ae7SThomas Veerman	canonicalize.c clear.c clears.c			\
92e3209ae7SThomas Veerman	cmp.c cmp_si.c cmp_ui.c div.c			\
93e3209ae7SThomas Veerman	get_d.c get_den.c get_num.c get_str.c		\
94e3209ae7SThomas Veerman	init.c inits.c inp_str.c inv.c			\
95e3209ae7SThomas Veerman	md_2exp.c mul.c neg.c out_str.c			\
96e3209ae7SThomas Veerman	set.c set_den.c set_num.c			\
97e3209ae7SThomas Veerman	set_si.c set_str.c set_ui.c			\
98e3209ae7SThomas Veerman	equal.c set_z.c set_d.c				\
99e3209ae7SThomas Veerman	set_f.c swap.c
100e3209ae7SThomas Veerman
101e3209ae7SThomas VeermanMPN_GENERIC_SRCS = \
102e3209ae7SThomas Veerman	popcount.c \
103e3209ae7SThomas Veerman	hamdist.c
104e3209ae7SThomas Veerman
105e3209ae7SThomas VeermanPRINTF_SRCS =						\
106e3209ae7SThomas Veerman	asprintf.c asprntffuns.c			\
107e3209ae7SThomas Veerman	doprnt.c doprntf.c doprnti.c			\
108e3209ae7SThomas Veerman	fprintf.c					\
109e3209ae7SThomas Veerman	obprintf.c obvprintf.c obprntffuns.c		\
110e3209ae7SThomas Veerman	printf.c printffuns.c				\
111e3209ae7SThomas Veerman	snprintf.c snprntffuns.c			\
112e3209ae7SThomas Veerman	sprintf.c sprintffuns.c				\
113e3209ae7SThomas Veerman	vasprintf.c vfprintf.c vprintf.c		\
114e3209ae7SThomas Veerman	vsnprintf.c vsprintf.c				\
115e3209ae7SThomas Veerman	repl-vsnprintf.c
116e3209ae7SThomas Veerman
117e3209ae7SThomas VeermanSCANF_SRCS =						\
118e3209ae7SThomas Veerman	doscan.c fscanf.c fscanffuns.c			\
119e3209ae7SThomas Veerman	scanf.c sscanf.c sscanffuns.c			\
120e3209ae7SThomas Veerman	vfscanf.c vscanf.c vsscanf.c
121e3209ae7SThomas Veerman
122e3209ae7SThomas VeermanSRCS+= 									\
123e3209ae7SThomas Veerman	assert.c compat.c errno.c extract-dbl.c invalid.c memory.c	\
124e3209ae7SThomas Veerman	mp_bpl.c mp_clz_tab.c mp_dv_tab.c mp_minv_tab.c mp_get_fns.c	\
12584d9c625SLionel Sambuc	mp_set_fns.c randclr.c randdef.c randiset.c randlc2s.c 	\
126e3209ae7SThomas Veerman	randlc2x.c randmt.c randmts.c rands.c randsd.c randsdui.c 	\
127e3209ae7SThomas Veerman	randbui.c randmui.c version.c nextprime.c
128e3209ae7SThomas Veerman
129e3209ae7SThomas VeermanSRCS+=	tal-reent.c
130e3209ae7SThomas Veerman
131e3209ae7SThomas Veerman# these are generated
132e3209ae7SThomas VeermanSRCS+=	fib_table.c mp_bases.c
133e3209ae7SThomas Veerman
134e3209ae7SThomas Veerman# Build the files that may have multiple identical base names under
135e3209ae7SThomas Veerman# different names.
136e3209ae7SThomas Veerman.for _dir _srcfile in \
137e3209ae7SThomas Veerman	${MPF_SRCS:C/^/mpf /} \
138e3209ae7SThomas Veerman	${MPZ_SRCS:C/^/mpz /} \
139e3209ae7SThomas Veerman	${MPQ_SRCS:C/^/mpq /} \
140e3209ae7SThomas Veerman	${PRINTF_SRCS:C/^/printf /} \
141e3209ae7SThomas Veerman	${SCANF_SRCS:C/^/scanf /}
142e3209ae7SThomas Veerman${_dir}_${_srcfile}: #Makefile
143e3209ae7SThomas Veerman	echo '#include "'${_dir}/${_srcfile}'"' > ${.TARGET}
144e3209ae7SThomas Veerman
145e3209ae7SThomas VeermanSRCS+=		${_dir}_${_srcfile}
146e3209ae7SThomas VeermanCLEANFILES+=	${_dir}_${_srcfile}
147e3209ae7SThomas Veerman
148e3209ae7SThomas Veerman.endfor
149e3209ae7SThomas Veerman
150*0a6a1f1dSLionel SambucCPPFLAGS+=	-I. -I${DIST} -I${.CURDIR}/arch/${GMP_MACHINE_ARCH} \
151*0a6a1f1dSLionel Sambuc		-D__GMP_WITHIN_GMP -DHAVE_CONFIG_H
152e3209ae7SThomas Veerman
153e3209ae7SThomas VeermanWITHOUT_MAN=	yes
154e3209ae7SThomas Veerman
155*0a6a1f1dSLionel SambucDPSRCS= fac_table.h fib_table.h fib_table.c jacobitab.h mp_bases.h \
156*0a6a1f1dSLionel Sambuc	mp_bases.c perfsqr.h trialdivtab.h
157e3209ae7SThomas Veerman
15884d9c625SLionel Sambucgen-fac: gen-fac.c
15984d9c625SLionel Sambuc	${HOST_CC} -o ${.OBJDIR}/gen-fac ${.ALLSRC}
16084d9c625SLionel Sambuc
16184d9c625SLionel Sambucfac_table.h: gen-fac
16284d9c625SLionel Sambuc	${.OBJDIR}/gen-fac ${GMP_LIMB_BITS} 0 > ${.OBJDIR}/fac_table.h
163e3209ae7SThomas Veerman
164e3209ae7SThomas Veermangen-fib: gen-fib.c
165e3209ae7SThomas Veerman	${HOST_CC} -o ${.OBJDIR}/gen-fib ${.ALLSRC}
166e3209ae7SThomas Veerman
167e3209ae7SThomas Veermanfib_table.h: gen-fib
168e3209ae7SThomas Veerman	${.OBJDIR}/gen-fib header ${GMP_LIMB_BITS} 0 > ${.OBJDIR}/fib_table.h
169e3209ae7SThomas Veerman
170e3209ae7SThomas Veermanfib_table.c: gen-fib
171e3209ae7SThomas Veerman	${.OBJDIR}/gen-fib table ${GMP_LIMB_BITS} 0 > ${.OBJDIR}/fib_table.c
172e3209ae7SThomas Veerman
173e3209ae7SThomas Veermangen-bases: gen-bases.c
174e3209ae7SThomas Veerman	${HOST_CC} -o ${.OBJDIR}/gen-bases ${.ALLSRC} -lm
175e3209ae7SThomas Veerman
176e3209ae7SThomas Veermanmp_bases.h: gen-bases
177e3209ae7SThomas Veerman	${.OBJDIR}/gen-bases header ${GMP_LIMB_BITS} 0 > ${.OBJDIR}/mp_bases.h
178e3209ae7SThomas Veerman
179e3209ae7SThomas Veermanmp_bases.c: gen-bases
180e3209ae7SThomas Veerman	${.OBJDIR}/gen-bases table ${GMP_LIMB_BITS} 0 > ${.OBJDIR}/mp_bases.c
181e3209ae7SThomas Veerman
18284d9c625SLionel Sambucgen-jacobitab: gen-jacobitab.c
18384d9c625SLionel Sambuc	${HOST_CC} -o ${.OBJDIR}/gen-jacobitab ${.ALLSRC} -lm
18484d9c625SLionel Sambuc
18584d9c625SLionel Sambucjacobitab.h: gen-jacobitab
18684d9c625SLionel Sambuc	${.OBJDIR}/gen-jacobitab > ${.OBJDIR}/jacobitab.h
18784d9c625SLionel Sambuc
188e3209ae7SThomas Veermanperfsqr.h: gen-psqr.c
189e3209ae7SThomas Veerman	${HOST_CC} -o ${.OBJDIR}/gen-psqr ${.ALLSRC}
190e3209ae7SThomas Veerman	${.OBJDIR}/gen-psqr ${GMP_LIMB_BITS} 0 > ${.OBJDIR}/perfsqr.h
191e3209ae7SThomas Veerman
192*0a6a1f1dSLionel Sambucgen-trialdivtab: gen-trialdivtab.c
193*0a6a1f1dSLionel Sambuc	${HOST_CC} -o ${.OBJDIR}/gen-trialdivtab ${.ALLSRC} -lm
194e3209ae7SThomas Veerman
195*0a6a1f1dSLionel Sambuctrialdiv.c: trialdivtab.h
196*0a6a1f1dSLionel Sambuctrialdivtab.h: gen-trialdivtab Makefile
197*0a6a1f1dSLionel Sambuc	${.OBJDIR}/gen-trialdivtab $(GMP_LIMB_BITS) 8000 > ${.OBJDIR}/trialdivtab.h
198*0a6a1f1dSLionel Sambuc
199*0a6a1f1dSLionel SambucCLEANFILES+=	${DPSRCS} gen-fac gen-fib gen-bases gen-jacobitab \
200*0a6a1f1dSLionel Sambuc		gen-psqr gen-trialdivtab
20184d9c625SLionel Sambuc
20284d9c625SLionel Sambuc.include "${.CURDIR}/arch/${GMP_MACHINE_ARCH}/Makefile.inc"
20384d9c625SLionel Sambuc
204*0a6a1f1dSLionel Sambuc# Makefile.inc must define GMP_LIMB_BITS.
205*0a6a1f1dSLionel Sambuc.if !defined(GMP_LIMB_BITS)
206*0a6a1f1dSLionel Sambuc.BEGIN:
207*0a6a1f1dSLionel Sambuc	@echo "GMP_LIMB_BITS not defined!"
208*0a6a1f1dSLionel Sambuc	false
209*0a6a1f1dSLionel Sambuc.endif
210*0a6a1f1dSLionel Sambuc
21184d9c625SLionel Sambuc# XXX stuff looks for "../config.m4"
21284d9c625SLionel Sambucdummy:
21384d9c625SLionel Sambuc	mkdir dummy
21484d9c625SLionel Sambuc${.OBJDIR}/config.m4: ${.CURDIR}/arch/${GMP_MACHINE_ARCH}/config.m4
215*0a6a1f1dSLionel Sambuc	rm -f ${.OBJDIR}/config.m4 && cp ${.CURDIR}/arch/${GMP_MACHINE_ARCH}/config.m4 ${.OBJDIR}/config.m4
21684d9c625SLionel Sambuc
21784d9c625SLionel SambucCLEANFILES+=	config.m4
21884d9c625SLionel Sambucclean: cleandummy
21984d9c625SLionel Sambuccleandummy: .PHONY
22084d9c625SLionel Sambuc	-rmdir dummy
22184d9c625SLionel Sambuc
222*0a6a1f1dSLionel SambucBUILD_S_INCS=	-I${.CURDIR} -I${.OBJDIR}/dummy -I${DIST}/ -I${DIST}/mpn \
223*0a6a1f1dSLionel Sambuc		-I${.OBJDIR}
22484d9c625SLionel Sambuc
22584d9c625SLionel Sambuc.for _build _src in ${ASM_SRCS_LIST}
22684d9c625SLionel Sambuc${_build:R}.s: Makefile dummy ${.OBJDIR}/config.m4 ${DIST}/${_src}
22784d9c625SLionel Sambuc	${TOOL_M4} -DCONFIG_TOP_SRCDIR=${DIST} ${BUILD_S_INCS} \
22884d9c625SLionel Sambuc		${M4FLAGS} ${M4FLAGS.${.TARGET:R}} \
22984d9c625SLionel Sambuc		-DOPERATION_${.TARGET:R} ${DIST}/${_src} > ${.TARGET}
23084d9c625SLionel Sambuc
23184d9c625SLionel SambucSRCS+=		${_build:R}.s
23284d9c625SLionel SambucCLEANFILES+=	${_build:R}.s
23384d9c625SLionel Sambuc.endfor
23484d9c625SLionel Sambuc
23584d9c625SLionel Sambuc.for _build _src in ${C_SRCS_LIST}
23684d9c625SLionel Sambucmpn_${_build}: Makefile
23784d9c625SLionel Sambuc	echo '#include "${_src}"' > ${.TARGET}
23884d9c625SLionel Sambuc
23984d9c625SLionel SambucCPPFLAGS.mpn_${_build}+= -DOPERATION_${_build:R}
24084d9c625SLionel Sambuc
24184d9c625SLionel SambucSRCS+=		mpn_${_build}
24284d9c625SLionel SambucCLEANFILES+=	mpn_${_build}
24384d9c625SLionel Sambuc.endfor
244e3209ae7SThomas Veerman
245e3209ae7SThomas Veerman.include <bsd.lib.mk>
246e3209ae7SThomas Veerman
247e3209ae7SThomas Veerman.PATH:	${DIST} \
24884d9c625SLionel Sambuc	${DIST}/rand \
249e3209ae7SThomas Veerman	${DIST}/mpn/generic \
25084d9c625SLionel Sambuc	${.CURDIR}/arch/${GMP_MACHINE_ARCH} \
251e3209ae7SThomas Veerman	${DIST}/mpf \
252e3209ae7SThomas Veerman	${DIST}/mpz
253e3209ae7SThomas Veerman
254e3209ae7SThomas Veerman# Don't warn about functions which cannot be stack smash protected as
255e3209ae7SThomas Veerman# there are a lot of them.
256e3209ae7SThomas VeermanCOPTS += -Wno-stack-protector
25784d9c625SLionel Sambuc.if !empty(GMP_MACHINE_ARCH:M*arm*)
25884d9c625SLionel SambucCOPTS += -marm
25984d9c625SLionel Sambuc.endif
260e3209ae7SThomas Veerman
26184d9c625SLionel SambucCWARNFLAGS.clang+=	-Wno-unused-value -Wno-tautological-compare -Wno-parentheses
262