xref: /netbsd-src/external/lgpl3/gmp/dist/tune/Makefile.am (revision 82ad575716605df31379cf04a2f3efbc97b8a6f5)
1## Process this file with automake to generate Makefile.in
2
3# Copyright 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
4#
5# This file is part of the GNU MP Library.
6#
7# The GNU MP Library is free software; you can redistribute it and/or modify
8# it under the terms of the GNU Lesser General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or (at your
10# option) any later version.
11#
12# The GNU MP Library is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15# License for more details.
16#
17# You should have received a copy of the GNU Lesser General Public License
18# along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20
21INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/tests
22
23EXTRA_DIST = alpha.asm pentium.asm sparcv9.asm hppa.asm hppa2.asm hppa2w.asm \
24  ia64.asm powerpc.asm powerpc64.asm x86_64.asm many.pl
25noinst_HEADERS = speed.h
26
27# Prefer -static on the speed and tune programs, since that can avoid
28# overheads of shared library linkages on some systems.  Libtool tends to
29# botch -static if configured with --disable-static, perhaps reasonably
30# enough.  In any event under --disable-static the only choice is a dynamic
31# link so there's no point in -static.
32#
33if ENABLE_STATIC
34STATIC = -static
35else
36STATIC =
37endif
38
39
40EXTRA_LTLIBRARIES = libspeed.la
41
42libspeed_la_SOURCES =							\
43  common.c divrem1div.c divrem1inv.c divrem2div.c divrem2inv.c		\
44  freq.c								\
45  gcdext_single.c gcdext_double.c gcdextod.c gcdextos.c			\
46  jacbase1.c jacbase2.c jacbase3.c					\
47  mod_1_div.c mod_1_inv.c modlinv.c					\
48  noop.c powm_mod.c powm_redc.c pre_divrem_1.c				\
49  set_strb.c set_strs.c set_strp.c time.c
50
51libspeed_la_DEPENDENCIES = $(SPEED_CYCLECOUNTER_OBJ) \
52  $(top_builddir)/tests/libtests.la $(top_builddir)/libgmp.la
53libspeed_la_LIBADD = $(libspeed_la_DEPENDENCIES) $(LIBM)
54libspeed_la_LDFLAGS = $(STATIC)
55
56$(top_builddir)/tests/libtests.la:
57	cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la
58
59
60# The library code is faster static than shared on some systems, so do
61# tuning and measuring with static, since users who care about maximizing
62# speed will be using that.  speed-dynamic exists to show the difference.
63#
64# On Solaris 8, gcc 2.95.2 -static is somehow broken (it creates executables
65# that immediately seg fault), so -all-static is not used.  The only thing
66# -all-static does is make libc static linked as well as libgmp, and that
67# makes a difference only when measuring malloc and friends in the speed
68# program.  This can always be forced with "make speed_LDFLAGS=-all-static
69# ..." if desired, see tune/README.
70
71EXTRA_PROGRAMS = speed speed-dynamic speed-ext tuneup
72
73DEPENDENCIES = libspeed.la
74LDADD = $(DEPENDENCIES)
75
76speed_SOURCES = speed.c
77speed_LDFLAGS = $(STATIC)
78
79speed_dynamic_SOURCES = speed.c
80
81speed_ext_SOURCES = speed-ext.c
82speed_ext_LDFLAGS = $(STATIC)
83
84tuneup_SOURCES = tuneup.c
85nodist_tuneup_SOURCES = sqr_basecase.c $(TUNE_MPN_SRCS)
86tuneup_DEPENDENCIES = $(TUNE_SQR_OBJ) libspeed.la
87tuneup_LDADD = $(tuneup_DEPENDENCIES)
88tuneup_LDFLAGS = $(STATIC)
89
90
91tune:
92	$(MAKE) $(AM_MAKEFLAGS) tuneup$(EXEEXT)
93	./tuneup
94
95allprogs: $(EXTRA_PROGRAMS)
96
97# $(MANY_CLEAN) and $(MANY_DISTCLEAN) are hooks for many.pl
98CLEANFILES = $(EXTRA_PROGRAMS) $(EXTRA_LTLIBRARIES) \
99	$(TUNE_MPN_SRCS) sqr_asm.asm \
100	stg.gnuplot stg.data \
101	mtg.gnuplot mtg.data \
102	fibg.gnuplot fibg.data \
103	graph.gnuplot graph.data \
104	$(MANY_CLEAN)
105DISTCLEANFILES = sqr_basecase.c  $(MANY_DISTCLEAN)
106
107
108# Generating these little files at build time seems better than including
109# them in the distribution, since the list can be changed more easily.
110#
111# mpn/generic/tdiv_qr.c uses mpn_divrem_1 and mpn_divrem_2, but only for 1
112# and 2 limb divisors, which are never used during tuning, so it doesn't
113# matter whether it picks up a tuned or untuned version of those.
114#
115# divrem_1 and mod_1 are recompiled renamed to "_tune" to avoid a linking
116# problem.  If a native divrem_1 provides an mpn_divrem_1c entrypoint then
117# common.c will want that, but the generic divrem_1 doesn't provide it,
118# likewise for mod_1.  The simplest way around this is to have the tune
119# build versions renamed suitably.
120#
121# FIXME: Would like say mul_n.c to depend on $(top_builddir)/mul_n.c so the
122# recompiled object will be rebuilt if that file changes.
123
124TUNE_MPN_SRCS = $(TUNE_MPN_SRCS_BASIC) divrem_1.c mod_1.c
125TUNE_MPN_SRCS_BASIC = bdiv_q.c bdiv_qr.c				\
126  dcpi1_div_qr.c dcpi1_divappr_q.c dcpi1_bdiv_qr.c dcpi1_bdiv_q.c	\
127  invertappr.c invert.c binvert.c divrem_2.c gcd.c gcdext.c		\
128  get_str.c set_str.c matrix22_mul.c hgcd.c mul_n.c sqr.c		\
129  mullo_n.c mul_fft.c mul.c tdiv_qr.c mulmod_bnm1.c sqrmod_bnm1.c	\
130  nussbaumer_mul.c toom6h_mul.c toom8h_mul.c toom6_sqr.c toom8_sqr.c	\
131  toom22_mul.c toom2_sqr.c toom33_mul.c toom3_sqr.c toom44_mul.c toom4_sqr.c
132
133$(TUNE_MPN_SRCS_BASIC):
134	for i in $(TUNE_MPN_SRCS_BASIC); do \
135	  echo "#define TUNE_PROGRAM_BUILD 1" >$$i; \
136	  echo "#include \"mpn/generic/$$i\"" >>$$i; \
137	done
138
139divrem_1.c:
140	echo "#define TUNE_PROGRAM_BUILD 1"                >divrem_1.c
141	echo "#define __gmpn_divrem_1  mpn_divrem_1_tune" >>divrem_1.c
142	echo "#include \"mpn/generic/divrem_1.c\""        >>divrem_1.c
143
144mod_1.c:
145	echo "#define TUNE_PROGRAM_BUILD 1"          >mod_1.c
146	echo "#define __gmpn_mod_1  mpn_mod_1_tune" >>mod_1.c
147	echo "#include \"mpn/generic/mod_1.c\""     >>mod_1.c
148
149sqr_asm.asm: $(top_builddir)/mpn/sqr_basecase.asm
150	echo 'define(SQR_TOOM2_THRESHOLD_OVERRIDE,SQR_TOOM2_THRESHOLD_MAX)' >sqr_asm.asm
151	echo 'include(../mpn/sqr_basecase.asm)' >>sqr_asm.asm
152
153
154include ../mpn/Makeasm.am
155