Add new package: prng (#8396)
* Add new package: prng * Add missing dependencies and use force_autoreconf option * Add dependency types
This commit is contained in:
		 Javier Cervantes
					Javier Cervantes
				
			
				
					committed by
					
						 Adam J. Stewart
						Adam J. Stewart
					
				
			
			
				
	
			
			
			 Adam J. Stewart
						Adam J. Stewart
					
				
			
						parent
						
							1a27f911d3
						
					
				
				
					commit
					34149e9a2b
				
			
							
								
								
									
										45
									
								
								var/spack/repos/builtin/packages/prng/package.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								var/spack/repos/builtin/packages/prng/package.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | ||||
| ############################################################################## | ||||
| # Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC. | ||||
| # Produced at the Lawrence Livermore National Laboratory. | ||||
| # | ||||
| # This file is part of Spack. | ||||
| # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. | ||||
| # LLNL-CODE-647188 | ||||
| # | ||||
| # For details, see https://github.com/spack/spack | ||||
| # Please also see the NOTICE and LICENSE files for our notice and the LGPL. | ||||
| # | ||||
| # This program is free software; you can redistribute it and/or modify | ||||
| # it under the terms of the GNU Lesser General Public License (as | ||||
| # published by the Free Software Foundation) version 2.1, February 1999. | ||||
| # | ||||
| # This program is distributed in the hope that it will be useful, but | ||||
| # WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF | ||||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and | ||||
| # conditions of the GNU Lesser General Public License for more details. | ||||
| # | ||||
| # You should have received a copy of the GNU Lesser General Public | ||||
| # License along with this program; if not, write to the Free Software | ||||
| # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||
| ############################################################################## | ||||
| from spack import * | ||||
|  | ||||
|  | ||||
| class Prng(AutotoolsPackage): | ||||
|     """Pseudo-Random Number Generator library.""" | ||||
|  | ||||
|     homepage = "http://statmath.wu.ac.at/prng/" | ||||
|     url      = "http://statmath.wu.ac.at/prng/prng-3.0.2.tar.gz" | ||||
|  | ||||
|     version('3.0.2', '80cb0870f2d18618bd2772f9e1dc1a70') | ||||
|  | ||||
|     depends_on('automake', type='build') | ||||
|     depends_on('autoconf', type='build') | ||||
|     depends_on('libtool', type='build') | ||||
|     depends_on('m4', type='build') | ||||
|  | ||||
|     patch('prng-3.0.2-shared.patch', when="@3.0.2") | ||||
|     patch('prng-3.0.2-fix-c99-inline-semantics.patch', when="@3.0.2") | ||||
|  | ||||
|     # Force the autoreconf step | ||||
|     force_autoreconf = True | ||||
| @@ -0,0 +1,146 @@ | ||||
| Use portable 'static inline' semantics that work in GNU89 and C99 | ||||
| See also: http://www.greenend.org.uk/rjk/tech/inline.html | ||||
|  | ||||
| --- a/src/dicg.c | ||||
| +++ b/src/dicg.c | ||||
| @@ -441,7 +441,7 @@ | ||||
|   * Algorithm by Karin Schaber and Otmar Lendl. | ||||
|   * | ||||
|   */                                                   | ||||
| -inline prng_num prng_dicg_multiply(int k,prng_num c, prng_num d) | ||||
| +prng_num prng_dicg_multiply(int k,prng_num c, prng_num d) | ||||
|  { | ||||
|    int i; | ||||
|    struct mtable *t; | ||||
| --- a/src/external.c | ||||
| +++ b/src/external.c | ||||
| @@ -139,7 +139,7 @@ | ||||
|   *      gen:  Pointer to a struct prng. | ||||
|   * | ||||
|   */ | ||||
| -inline prng_num prng_tt800_get_next_int(struct prng *gen) | ||||
| +prng_num prng_tt800_get_next_int(struct prng *gen) | ||||
|  { | ||||
|  unsigned int y; | ||||
|  struct tt800_state *g; | ||||
| --- a/src/icg.c | ||||
| +++ b/src/icg.c | ||||
| @@ -110,7 +110,7 @@ | ||||
|   *      gen:  Pointer to a struct prng. | ||||
|   * | ||||
|   */ | ||||
| -inline prng_num prng_icg_get_next_int(struct prng *gen) | ||||
| +prng_num prng_icg_get_next_int(struct prng *gen) | ||||
|  { | ||||
|    s_prng_num inv, current, prod; | ||||
|     | ||||
| --- a/src/lcg.c | ||||
| +++ b/src/lcg.c | ||||
| @@ -111,7 +111,7 @@ | ||||
|   *      gen:  Pointer to a struct prng. | ||||
|   * | ||||
|   */ | ||||
| -inline prng_num prng_lcg_get_next_int(struct prng *gen) | ||||
| +prng_num prng_lcg_get_next_int(struct prng *gen) | ||||
|  { | ||||
|    s_prng_num ax, current; | ||||
|   | ||||
| --- a/src/meicg.c | ||||
| +++ b/src/meicg.c | ||||
| @@ -106,7 +106,7 @@ | ||||
|   *      gen:  Pointer to a struct prng. | ||||
|   * | ||||
|   */ | ||||
| -inline prng_num prng_meicg_get_next_int(struct prng *gen) | ||||
| +prng_num prng_meicg_get_next_int(struct prng *gen) | ||||
|  { | ||||
|    s_prng_num an, sum, inv, n; | ||||
|   | ||||
| --- a/src/mt19937.c | ||||
| +++ b/src/mt19937.c | ||||
| @@ -172,7 +172,7 @@ | ||||
|   *      gen:  Pointer to a struct prng. | ||||
|   * | ||||
|   */ | ||||
| -inline prng_num prng_mt19937_get_next_int(struct prng *gen) | ||||
| +prng_num prng_mt19937_get_next_int(struct prng *gen) | ||||
|  { | ||||
|  #define MT  gen->data.mt19937_data.mt | ||||
|  #define MTI gen->data.mt19937_data.mti | ||||
| --- a/src/prng.h | ||||
| +++ b/src/prng.h | ||||
| @@ -406,7 +406,7 @@ | ||||
|  /* INLINE fnk def. for mult_mod, I don't know if this works for non-GCC */ | ||||
|   | ||||
|  #ifdef __GNUC__ | ||||
| -extern __inline__ prng_num mult_mod(prng_num s,struct mult_mod_struct *mm) | ||||
| +static inline prng_num mult_mod(prng_num s,struct mult_mod_struct *mm) | ||||
|  { | ||||
|  s_prng_num s_tmp; | ||||
|   | ||||
| --- a/src/qcg.c | ||||
| +++ b/src/qcg.c | ||||
| @@ -107,7 +107,7 @@ | ||||
|   *      gen:  Pointer to a struct prng. | ||||
|   * | ||||
|   */ | ||||
| -inline prng_num prng_qcg_get_next_int(struct prng *gen) | ||||
| +prng_num prng_qcg_get_next_int(struct prng *gen) | ||||
|  { | ||||
|    s_prng_num current, sum, square, q_term, l_term; | ||||
|   | ||||
| --- a/src/support.c | ||||
| +++ b/src/support.c | ||||
| @@ -449,52 +449,6 @@ | ||||
|  		} | ||||
|  } | ||||
|   | ||||
| -#ifndef __cplusplus | ||||
| -/*  | ||||
| - * Modular Multiplication. Uses the precalculated values from mult_mod_setup. | ||||
| - * | ||||
| - * | ||||
| - * Input:  | ||||
| - *	s	An prng_num.  | ||||
| - *	mm	pointer to a struct mult_mod_struct initialized  | ||||
| - *		by mult_mod_setup. | ||||
| - * | ||||
| - * Output: | ||||
| - *      (mm->a*s) mod mm->p | ||||
| - * | ||||
| - */ | ||||
| -prng_num mult_mod(prng_num s,struct mult_mod_struct *mm) | ||||
| -{ | ||||
| -s_prng_num s_tmp; | ||||
| - | ||||
| -switch(mm->algorithm) | ||||
| -	{ | ||||
| -	case PRNG_MM_ZERO:	return(0); | ||||
| -			break; | ||||
| -	case PRNG_MM_ONE:	return(s); | ||||
| -			break; | ||||
| -	case PRNG_MM_SIMPLE: return((s * mm->a) % mm->p ); | ||||
| -			break; | ||||
| -	case PRNG_MM_SCHRAGE: | ||||
| -			s_tmp = mm->a * ( s % mm->q ) -  | ||||
| -				mm->r * ( s / mm->q ); | ||||
| -			if (s_tmp < 0) s_tmp += mm->p; | ||||
| -			return(s_tmp); | ||||
| -			break; | ||||
| -	case PRNG_MM_DECOMP: return(mult_mod_generic(s,mm->a,mm->p));  | ||||
| -			break; | ||||
| -#ifdef HAVE_LONGLONG | ||||
| -	case PRNG_MM_LL:	return(mult_mod_ll(s,mm->a,mm->p)); | ||||
| -			break; | ||||
| -#endif | ||||
| -	case PRNG_MM_POW2:	return((s*mm->a) & mm->mask); | ||||
| -			break; | ||||
| -	} | ||||
| -/* not reached */ | ||||
| -return(0); | ||||
| -} | ||||
| -#endif | ||||
| - | ||||
|   | ||||
|  /*  | ||||
|   * Modular Multiplication: Decomposition method (from L'Ecuyer & Cote) | ||||
| @@ -0,0 +1,52 @@ | ||||
| --- a/configure.ac | ||||
| +++ b/configure.ac | ||||
| @@ -23,6 +23,7 @@ | ||||
|  AC_PROG_RANLIB | ||||
|  AC_PROG_INSTALL | ||||
|  AC_PROG_LN_S | ||||
| +AC_PROG_LIBTOOL | ||||
|   | ||||
|  dnl Checks for typedefs, structures, and compiler characteristics. | ||||
|  AC_C_CONST | ||||
| @@ -39,10 +40,7 @@ | ||||
|  dnl Checks for library functions. | ||||
|  AC_CHECK_FUNCS(strtoul) | ||||
|   | ||||
| -dnl Set flags for compiler | ||||
| -if test X"$GCC" = Xyes ; then | ||||
| -	AC_SUBST(AM_CFLAGS,"-Wall -fomit-frame-pointer") | ||||
| -fi | ||||
| +AC_CHECK_LIB([m], [pow]) | ||||
|   | ||||
|  AC_CONFIG_FILES([\ | ||||
|          Makefile \ | ||||
| --- a/examples/Makefile.am | ||||
| +++ b/examples/Makefile.am | ||||
| @@ -1,11 +1,11 @@ | ||||
|  ## Process this file with automake to produce Makefile.in | ||||
|  # $Id$ | ||||
|   | ||||
| -LDADD = $(top_builddir)/src/libprng.a -lm | ||||
| +LDADD = $(top_builddir)/src/libprng.la -lm | ||||
|   | ||||
|  INCLUDES = -I$(top_srcdir)/src | ||||
|   | ||||
| -noinst_PROGRAMS = pairs tuples | ||||
| +check_PROGRAMS = pairs tuples | ||||
|   | ||||
|  # clean backup files | ||||
|  CLEANFILES = *~ | ||||
| --- a/src/Makefile.am | ||||
| +++ b/src/Makefile.am | ||||
| @@ -3,9 +3,9 @@ | ||||
|   | ||||
|  INCLUDES =  | ||||
|   | ||||
| -lib_LIBRARIES = libprng.a | ||||
| +lib_LTLIBRARIES = libprng.la | ||||
|   | ||||
| -libprng_a_SOURCES = \ | ||||
| +libprng_la_SOURCES = \ | ||||
|   prng.c \ | ||||
|   dicg.c \ | ||||
|   eicg.c \ | ||||
		Reference in New Issue
	
	Block a user