1# if wrapper mode 2.if (defined(NO_CROSSTOOLS) && defined(BOOTSTRAPPING)) || \ 3 (!defined(BOOTSTRAPPING) && defined(NO_TOOLCHAIN)) 4.include "Makefile.zhack" 5.else 6 7# normal mode 8LIB= gmp 9INTERNALLIB= # yes 10 11CONTRIBDIR= ${.CURDIR}/../../../contrib/gmp 12.PATH: ${CONTRIBDIR} 13 14.include "${.CURDIR}/Makefile.${MACHINE_ARCH}" 15 16CFLAGS+= -D__GMP_WITHIN_GMP -I${CONTRIBDIR} -I${.OBJDIR} -I${.CURDIR} 17CFLAGS+= -I${CONTRIBDIR}/mpn/generic 18CFLAGS+= -D__LONG_INT_BYTES=${LONG_INT_BYTES} 19CFLAGS+= -D__INT_BITS=${INT_BITS} 20CFLAGS+= -DHAVE_HOST_CPU_FAMILY_${CPU_FAMILY}=1 21 22 23# The following comes verbatim from Makefile.am 24 25MPF_OBJECTS = mpf/init$U.lo mpf/init2$U.lo mpf/inits$U.lo mpf/set$U.lo \ 26 mpf/set_ui$U.lo mpf/set_si$U.lo mpf/set_str$U.lo mpf/set_d$U.lo \ 27 mpf/set_z$U.lo mpf/iset$U.lo mpf/iset_ui$U.lo mpf/iset_si$U.lo \ 28 mpf/iset_str$U.lo mpf/iset_d$U.lo mpf/clear$U.lo mpf/clears$U.lo \ 29 mpf/get_str$U.lo mpf/dump$U.lo mpf/size$U.lo mpf/eq$U.lo mpf/reldiff$U.lo \ 30 mpf/sqrt$U.lo mpf/random2$U.lo mpf/inp_str$U.lo mpf/out_str$U.lo \ 31 mpf/add$U.lo mpf/add_ui$U.lo mpf/sub$U.lo mpf/sub_ui$U.lo mpf/ui_sub$U.lo \ 32 mpf/mul$U.lo mpf/mul_ui$U.lo mpf/div$U.lo mpf/div_ui$U.lo \ 33 mpf/cmp$U.lo mpf/cmp_d$U.lo mpf/cmp_ui$U.lo mpf/cmp_si$U.lo \ 34 mpf/mul_2exp$U.lo mpf/div_2exp$U.lo mpf/abs$U.lo mpf/neg$U.lo \ 35 mpf/set_q$U.lo mpf/get_d$U.lo mpf/get_d_2exp$U.lo mpf/set_dfl_prec$U.lo \ 36 mpf/set_prc$U.lo mpf/set_prc_raw$U.lo mpf/get_dfl_prec$U.lo \ 37 mpf/get_prc$U.lo mpf/ui_div$U.lo mpf/sqrt_ui$U.lo \ 38 mpf/ceilfloor$U.lo mpf/trunc$U.lo mpf/pow_ui$U.lo \ 39 mpf/urandomb$U.lo mpf/swap$U.lo \ 40 mpf/fits_sint$U.lo mpf/fits_slong$U.lo mpf/fits_sshort$U.lo \ 41 mpf/fits_uint$U.lo mpf/fits_ulong$U.lo mpf/fits_ushort$U.lo \ 42 mpf/get_si$U.lo mpf/get_ui$U.lo \ 43 mpf/int_p$U.lo 44 45MPZ_OBJECTS = mpz/abs$U.lo mpz/add$U.lo mpz/add_ui$U.lo \ 46 mpz/aorsmul$U.lo mpz/aorsmul_i$U.lo mpz/and$U.lo mpz/array_init$U.lo \ 47 mpz/bin_ui$U.lo mpz/bin_uiui$U.lo \ 48 mpz/cdiv_q$U.lo mpz/cdiv_q_ui$U.lo \ 49 mpz/cdiv_qr$U.lo mpz/cdiv_qr_ui$U.lo \ 50 mpz/cdiv_r$U.lo mpz/cdiv_r_ui$U.lo mpz/cdiv_ui$U.lo \ 51 mpz/cfdiv_q_2exp$U.lo mpz/cfdiv_r_2exp$U.lo \ 52 mpz/clear$U.lo mpz/clears$U.lo mpz/clrbit$U.lo \ 53 mpz/cmp$U.lo mpz/cmp_d$U.lo mpz/cmp_si$U.lo mpz/cmp_ui$U.lo \ 54 mpz/cmpabs$U.lo mpz/cmpabs_d$U.lo mpz/cmpabs_ui$U.lo \ 55 mpz/com$U.lo mpz/combit$U.lo \ 56 mpz/cong$U.lo mpz/cong_2exp$U.lo mpz/cong_ui$U.lo \ 57 mpz/divexact$U.lo mpz/divegcd$U.lo mpz/dive_ui$U.lo \ 58 mpz/divis$U.lo mpz/divis_ui$U.lo mpz/divis_2exp$U.lo mpz/dump$U.lo \ 59 mpz/export$U.lo mpz/fac_ui$U.lo mpz/fdiv_q$U.lo \ 60 mpz/fdiv_q_ui$U.lo mpz/fdiv_qr$U.lo mpz/fdiv_qr_ui$U.lo \ 61 mpz/fdiv_r$U.lo mpz/fdiv_r_ui$U.lo \ 62 mpz/fdiv_ui$U.lo mpz/fib_ui$U.lo mpz/fib2_ui$U.lo mpz/fits_sint$U.lo \ 63 mpz/fits_slong$U.lo mpz/fits_sshort$U.lo mpz/fits_uint$U.lo \ 64 mpz/fits_ulong$U.lo mpz/fits_ushort$U.lo mpz/gcd$U.lo \ 65 mpz/gcd_ui$U.lo mpz/gcdext$U.lo mpz/get_d$U.lo mpz/get_d_2exp$U.lo \ 66 mpz/get_si$U.lo mpz/get_str$U.lo mpz/get_ui$U.lo mpz/getlimbn$U.lo \ 67 mpz/hamdist$U.lo \ 68 mpz/import$U.lo mpz/init$U.lo mpz/init2$U.lo mpz/inits$U.lo \ 69 mpz/inp_raw$U.lo mpz/inp_str$U.lo mpz/invert$U.lo \ 70 mpz/ior$U.lo mpz/iset$U.lo mpz/iset_d$U.lo mpz/iset_si$U.lo \ 71 mpz/iset_str$U.lo mpz/iset_ui$U.lo mpz/jacobi$U.lo mpz/kronsz$U.lo \ 72 mpz/kronuz$U.lo mpz/kronzs$U.lo mpz/kronzu$U.lo \ 73 mpz/lcm$U.lo mpz/lcm_ui$U.lo mpz/lucnum_ui$U.lo mpz/lucnum2_ui$U.lo \ 74 mpz/millerrabin$U.lo mpz/mod$U.lo mpz/mul$U.lo mpz/mul_2exp$U.lo \ 75 mpz/mul_si$U.lo mpz/mul_ui$U.lo \ 76 mpz/n_pow_ui$U.lo mpz/neg$U.lo mpz/nextprime$U.lo \ 77 mpz/out_raw$U.lo mpz/out_str$U.lo mpz/perfpow$U.lo mpz/perfsqr$U.lo \ 78 mpz/popcount$U.lo mpz/pow_ui$U.lo mpz/powm$U.lo mpz/powm_sec$U.lo \ 79 mpz/powm_ui$U.lo mpz/pprime_p$U.lo mpz/random$U.lo mpz/random2$U.lo \ 80 mpz/realloc$U.lo mpz/realloc2$U.lo mpz/remove$U.lo \ 81 mpz/root$U.lo mpz/rootrem$U.lo mpz/rrandomb$U.lo mpz/scan0$U.lo \ 82 mpz/scan1$U.lo mpz/set$U.lo mpz/set_d$U.lo mpz/set_f$U.lo \ 83 mpz/set_q$U.lo mpz/set_si$U.lo mpz/set_str$U.lo mpz/set_ui$U.lo \ 84 mpz/setbit$U.lo \ 85 mpz/size$U.lo mpz/sizeinbase$U.lo mpz/sqrt$U.lo \ 86 mpz/sqrtrem$U.lo mpz/sub$U.lo mpz/sub_ui$U.lo mpz/swap$U.lo \ 87 mpz/tdiv_ui$U.lo mpz/tdiv_q$U.lo mpz/tdiv_q_2exp$U.lo \ 88 mpz/tdiv_q_ui$U.lo mpz/tdiv_qr$U.lo mpz/tdiv_qr_ui$U.lo \ 89 mpz/tdiv_r$U.lo mpz/tdiv_r_2exp$U.lo mpz/tdiv_r_ui$U.lo \ 90 mpz/tstbit$U.lo mpz/ui_pow_ui$U.lo mpz/ui_sub$U.lo mpz/urandomb$U.lo \ 91 mpz/urandomm$U.lo mpz/xor$U.lo 92 93MPQ_OBJECTS = mpq/abs$U.lo mpq/aors$U.lo \ 94 mpq/canonicalize$U.lo mpq/clear$U.lo mpq/clears$U.lo \ 95 mpq/cmp$U.lo mpq/cmp_si$U.lo mpq/cmp_ui$U.lo mpq/div$U.lo \ 96 mpq/get_d$U.lo mpq/get_den$U.lo mpq/get_num$U.lo mpq/get_str$U.lo \ 97 mpq/init$U.lo mpq/inits$U.lo mpq/inp_str$U.lo mpq/inv$U.lo \ 98 mpq/md_2exp$U.lo mpq/mul$U.lo mpq/neg$U.lo mpq/out_str$U.lo \ 99 mpq/set$U.lo mpq/set_den$U.lo mpq/set_num$U.lo \ 100 mpq/set_si$U.lo mpq/set_str$U.lo mpq/set_ui$U.lo \ 101 mpq/equal$U.lo mpq/set_z$U.lo mpq/set_d$U.lo \ 102 mpq/set_f$U.lo mpq/swap$U.lo 103 104MPN_OBJECTS = mpn/fib_table$U.lo mpn/mp_bases$U.lo 105 106PRINTF_OBJECTS = \ 107 printf/asprintf$U.lo printf/asprntffuns$U.lo \ 108 printf/doprnt$U.lo printf/doprntf$U.lo printf/doprnti$U.lo \ 109 printf/fprintf$U.lo \ 110 printf/printf$U.lo printf/printffuns$U.lo \ 111 printf/snprintf$U.lo printf/snprntffuns$U.lo \ 112 printf/sprintf$U.lo printf/sprintffuns$U.lo \ 113 printf/vasprintf$U.lo printf/vfprintf$U.lo printf/vprintf$U.lo \ 114 printf/vsnprintf$U.lo printf/vsprintf$U.lo 115 116# only when HAVE_OBSTACK_VPRINTF 117#PRINTF_OBJECTS += \ 118 printf/obprintf$U.lo printf/obvprintf$U.lo printf/obprntffuns$U.lo 119 120# only when ! HAVE_VSNPRINTF (when don't have vsnprintf) 121#PRINTF_OBJECTS += \ 122 printf/repl-vsnprintf$U.lo 123 124SCANF_OBJECTS = \ 125 scanf/doscan$U.lo scanf/fscanf$U.lo scanf/fscanffuns$U.lo \ 126 scanf/scanf$U.lo scanf/sscanf$U.lo scanf/sscanffuns$U.lo \ 127 scanf/vfscanf$U.lo scanf/vscanf$U.lo scanf/vsscanf$U.lo 128 129libgmp_la_SOURCES = gmp-impl.h longlong.h randmt.h \ 130 assert.c compat.c errno.c extract-dbl.c invalid.c memory.c \ 131 mp_bpl.c mp_dv_tab.c mp_minv_tab.c mp_get_fns.c mp_set_fns.c \ 132 rand.c randclr.c randdef.c randiset.c randlc2s.c randlc2x.c randmt.c \ 133 randmts.c rands.c randsd.c randsdui.c randbui.c randmui.c version.c \ 134 nextprime.c 135 136# only when COUNT_LEADING_ZEROS_NEED_CLZ_TAB 137#libgmp_la_SOURCES = mp_clz_tab.c 138 139# From configure.in 140gmp_mpn_functions_optional=umul udiv \ 141 invert_limb sqr_diagonal \ 142 mul_2 mul_3 mul_4 \ 143 addmul_2 addmul_3 addmul_4 addmul_5 addmul_6 addmul_7 addmul_8 \ 144 addlsh1_n sublsh1_n rsblsh1_n rsh1add_n rsh1sub_n \ 145 addlsh2_n sublsh2_n rsblsh2_n \ 146 addlsh_n sublsh_n rsblsh_n \ 147 add_n_sub_n addaddmul_1msb0 148 149gmp_mpn_functions=${extra_functions} \ 150 add add_1 add_n sub sub_1 sub_n neg com mul_1 addmul_1 \ 151 submul_1 lshift rshift dive_1 diveby3 divis divrem divrem_1 divrem_2 \ 152 fib2_ui mod_1 mod_34lsub1 mode1o pre_divrem_1 pre_mod_1 dump \ 153 mod_1_1 mod_1_2 mod_1_3 mod_1_4 lshiftc \ 154 mul mul_fft mul_n sqr mul_basecase sqr_basecase nussbaumer_mul \ 155 random random2 pow_1 \ 156 rootrem sqrtrem get_str set_str scan0 scan1 popcount hamdist cmp \ 157 perfsqr perfpow \ 158 gcd_1 gcd gcdext_1 gcdext gcd_lehmer gcd_subdiv_step \ 159 gcdext_lehmer gcdext_subdiv_step \ 160 div_q tdiv_qr jacbase get_d \ 161 matrix22_mul hgcd2 hgcd mullo_n mullo_basecase \ 162 toom22_mul toom32_mul toom42_mul toom52_mul toom62_mul \ 163 toom33_mul toom43_mul toom53_mul toom63_mul \ 164 toom44_mul \ 165 toom6h_mul toom6_sqr toom8h_mul toom8_sqr \ 166 toom_couple_handling \ 167 toom2_sqr toom3_sqr toom4_sqr \ 168 toom_eval_dgr3_pm1 toom_eval_dgr3_pm2 \ 169 toom_eval_pm1 toom_eval_pm2 toom_eval_pm2exp toom_eval_pm2rexp \ 170 toom_interpolate_5pts toom_interpolate_6pts toom_interpolate_7pts \ 171 toom_interpolate_8pts toom_interpolate_12pts toom_interpolate_16pts \ 172 invertappr invert binvert mulmod_bnm1 sqrmod_bnm1 \ 173 sbpi1_div_q sbpi1_div_qr sbpi1_divappr_q \ 174 dcpi1_div_q dcpi1_div_qr dcpi1_divappr_q \ 175 mu_div_qr mu_divappr_q mu_div_q \ 176 bdiv_q_1 \ 177 sbpi1_bdiv_q sbpi1_bdiv_qr \ 178 dcpi1_bdiv_q dcpi1_bdiv_qr \ 179 mu_bdiv_q mu_bdiv_qr \ 180 bdiv_q bdiv_qr \ 181 divexact bdiv_dbm1c redc_1 redc_2 redc_n powm powlo powm_sec subcnd_n \ 182 redc_1_sec trialdiv remove \ 183 and_n andn_n nand_n ior_n iorn_n nior_n xor_n xnor_n \ 184 copyi copyd zero \ 185 ${gmp_mpn_functions_optional} 186 187# end verbatim copy 188 189MULFUNC_add_n= aors_n 190MULFUNC_sub_n= aors_n 191MULFUNC_addmul_1= aorsmul_1 192MULFUNC_submul_1= aorsmul_1 193MULFUNC_popcount= popham 194MULFUNC_hamdist= popham 195MULFUNC_and_n= logops_n 196MULFUNC_andn_n= logops_n 197MULFUNC_nand_n= logops_n 198MULFUNC_ior_n= logops_n 199MULFUNC_iorn_n= logops_n 200MULFUNC_nior_n= logops_n 201MULFUNC_xor_n= logops_n 202MULFUNC_xnor_n= logops_n 203MULFUNC_lshift= lorrshift 204MULFUNC_rshift= lorrshift 205MULFUNC_addlsh1_n= aorslsh1_n 206MULFUNC_sublsh1_n= aorslsh1_n 207MULFUNC_rsh1add_n= rsh1aors_n 208MULFUNC_rsh1sub_n= rsh1aors_n 209 210 211U= 212extra_functions= 213LO_OBJECTS= ${MPF_OBJECTS} ${MPZ_OBJECTS} ${MPQ_OBJECTS} ${MPN_OBJECTS} \ 214 ${PRINTF_OBJECTS} ${SCANF_OBJECTS} 215 216.for func in ${gmp_mpn_functions} 217.for mapfunc in ${func} ${MULFUNC_${func}} 218.for mapsource in mpn/generic/${mapfunc}.c 219.for source in mpn/generic/${func}.c 220.if exists(${mapsource}) && empty(MPNSRC:M${source}) 221 222.if !exists(${source}) 223${source}: ${mapsource} mkdirs 224 cp ${.ALLSRC:Nmkdirs} ${.TARGET} 225CLEANFILES+= ${source} 226.ORDER: mkdirs ${source} 227.endif 228 229MPNSRC+= ${source} 230${source:.c=.o}: ${source} 231 ${CC} -o ${.TARGET} ${CFLAGS} -DOPERATION_${func} -c ${.ALLSRC} 232.endif 233.endfor 234.endfor 235.endfor 236.endfor 237 238SRCS= ${LO_OBJECTS:.lo=.c} ${libgmp_la_SOURCES} ${MPNSRC} 239SRCS+= tal-reent.c 240 241# the following are generated sources, so we have to add them 242# explicitly to SRCS 243GENSRC= fac_ui.h fib_table.h mpn/fib_table.c mp_bases.h perfsqr.h 244GENSRC+= trialdivtab.h 245SRCS+= ${GENSRC} 246CLEANFILES+= ${GENSRC} 247 248 249fac_ui.h: gen-fac_ui.nx 250 ${.OBJDIR}/gen-fac_ui.nx ${LONG_INT_BITS} 0 > ${.TARGET} 251 252fib_table.h: gen-fib.nx 253 ${.OBJDIR}/gen-fib.nx header ${LONG_INT_BITS} 0 > ${.TARGET} 254 255mpn/fib_table.c: gen-fib.nx 256 ${.OBJDIR}/gen-fib.nx table ${LONG_INT_BITS} 0 > ${.TARGET} 257 258mp_bases.h: gen-bases.nx 259 ${.OBJDIR}/gen-bases.nx header ${LONG_INT_BITS} 0 > ${.TARGET} 260 261mpn/mp_bases.c: gen-bases.nx 262 ${.OBJDIR}/gen-bases.nx table ${LONG_INT_BITS} 0 > ${.TARGET} 263 264perfsqr.h: gen-psqr.nx 265 ${.OBJDIR}/gen-psqr.nx ${LONG_INT_BITS} 0 > ${.TARGET} 266 267trialdivtab.h: gen-trialdivtab.nx 268 ${.OBJDIR}/gen-trialdivtab.nx ${LONG_INT_BITS} 8000 > ${.TARGET} 269 270.for _gen in fac_ui fib bases psqr trialdivtab 271gen-${_gen}.nx: gen-${_gen}.c dumbmp.c 272 ${NXCC} ${.ALLSRC:M*/gen-*} -o ${.TARGET} -lm 273CLEANFILES+= gen-${_gen}.nx 274.endfor 275 276GENDIRS= mpf mpz mpq mpn mpn/generic printf scanf 277CLEANDIRS+= ${GENDIRS} 278beforedepend: mkdirs 279mkdirs: 280 mkdir -p ${GENDIRS} 281 282.include <bsd.lib.mk> 283.endif 284