PageRenderTime 14ms CodeModel.GetById 9ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/farmR/configure.ac

https://code.google.com/p/javawfm/
m4 | 228 lines | 158 code | 46 blank | 24 comment | 0 complexity | 7e8cb71011167aab23d8b8057430c8f5 MD5 | raw file
  1AC_PREREQ(2.61)
  2AC_INIT(farmR,1.0,iracooke@gmail.com)
  3AC_CONFIG_SRCDIR([src/glpkjni.h])
  4AC_CONFIG_HEADER([])
  5AC_CONFIG_AUX_DIR([tools])
  6
  7AC_CANONICAL_BUILD
  8AC_CANONICAL_HOST
  9
 10# find R home and set CC/CFLAGS
 11: ${R_HOME=`R RHOME`}
 12if test -z "${R_HOME}"; then
 13   echo "could not determine R_HOME"
 14   exit 1
 15fi
 16RBIN="${R_HOME}/bin/R"
 17CC=`"${RBIN}" CMD config CC`;
 18CFLAGS=`"${RBIN}" CMD config CFLAGS`
 19CPPFLAGS=`"${RBIN}" CMD config CPPFLAGS`
 20
 21AC_SUBST(PLATFORM)
 22
 23JNIPREFIX=lib
 24JNISO=.so
 25
 26# we need to adjust a few things according to OS ..
 27case "${host_os}" in
 28  darwin*)
 29    JNISO=.jnilib
 30	;;	
 31  *)
 32    ;;
 33esac
 34
 35AC_SUBST(JNIPREFIX)
 36AC_SUBST(JNISO)
 37
 38
 39# Checks for programs.
 40AC_PROG_CXX
 41AC_PROG_CC
 42
 43# Checks for libraries.
 44
 45# Checks for header files.
 46AC_HEADER_STDC
 47AC_CHECK_HEADERS([stdlib.h])
 48
 49# Checks for typedefs, structures, and compiler characteristics.
 50AC_C_CONST
 51AC_HEADER_STDBOOL
 52
 53
 54#Checking for Java support in R and gathering Java environment variables. This is taken from the configure.ac of rJava
 55AC_MSG_CHECKING([Java support in R])
 56R_JAVA_HOME=`"${RBIN}" CMD config JAVA_HOME`
 57: ${JAVA_HOME="${R_JAVA_HOME}"}
 58if test -z "${JAVA_HOME}"; then
 59   AC_MSG_ERROR([absent
 60R was configured without Java support. Please run
 61R CMD javareconf
 62as root to add Java support to R.
 63
 64If you don't have root privileges, run
 65R CMD javareconf -e
 66to set all Java-related variables and then install rJava.
 67(works with R 2.5.0 only)])
 68fi
 69
 70: ${JAR=`"${RBIN}" CMD config JAR|sed 's/ERROR:.*//'`}
 71: ${JAVA=`"${RBIN}" CMD config JAVA|sed 's/ERROR:.*//'`}
 72: ${JAVAC=`"${RBIN}" CMD config JAVAC|sed 's/ERROR:.*//'`}
 73: ${JAVAH=`"${RBIN}" CMD config JAVAH|sed 's/ERROR:.*//'`}
 74: ${JAVA_CPPFLAGS=`"${RBIN}" CMD config JAVA_CPPFLAGS|sed 's/ERROR:.*//'`}
 75: ${JAVA_LIBS=`"${RBIN}" CMD config JAVA_LIBS|sed 's/ERROR:.*//'`}
 76
 77AC_MSG_RESULT([present:
 78interpreter : '${JAVA}'
 79archiver    : '${JAR}'
 80compiler    : '${JAVAC}'
 81header prep.: '${JAVAH}'
 82cpp flags   : '${JAVA_CPPFLAGS}'
 83java libs   : '${JAVA_LIBS}'])
 84
 85java_error='One or more Java configuration variables are not set.'
 86if test -z "${JAVA}"; then
 87   java_error='Java interpreter is missing or not registered in R'
 88fi
 89if test -z "${JAVAC}"; then
 90   java_error='Java Development Kit (JDK) is missing or not registered in R'
 91fi
 92
 93have_all_flags=no
 94if test -n "${JAVA}" && test -n "${JAVAC}" && test -n "${JAVAH}" && \
 95   test -n "${JAVA_CPPFLAGS}" && test -n "${JAVA_LIBS}" && test -n "${JAR}"; then
 96  have_all_flags=yes;
 97fi
 98if test "${have_all_flags}" = no; then
 99  AC_MSG_ERROR([${java_error}
100Make sure R is configured with full Java support (including JDK). Run
101R CMD javareconf
102as root to add Java support to R.
103
104If you don't have root privileges, run
105R CMD javareconf -e
106to set all Java-related variables and then install rJava.
107])
108fi
109
110if test `echo foo | sed -e 's:foo:bar:'` = bar; then
111   JAVA_CPPFLAGS0=`echo ${JAVA_CPPFLAGS} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'`
112   JAVA_LIBS0=`echo ${JAVA_LIBS} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'`
113   JAVA_LD_LIBRARY_PATH0=`echo ${JAVA_LD_LIBRARY_PATH} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'`
114else
115   AC_MSG_WARN([sed is not working properly - the configuration may fail])
116   JAVA_CPPFLAGS0="${JAVA_CPPFLAGS}"
117   JAVA_LIBS0="${JAVA_LIBS}"
118   JAVA_LD_LIBRARY_PATH0="${JAVA_LD_LIBRARY_PATH}"
119fi
120
121LIBS="${LIBS} ${JAVA_LIBS0}"
122CFLAGS="${CFLAGS} ${JAVA_CPPFLAGS0}"
123LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${JAVA_LD_LIBRARY_PATH0}"
124
125AC_MSG_CHECKING([whether JNI programs can be compiled])
126AC_LINK_IFELSE([
127#include <jni.h>
128int main(void) {
129    jobject o;
130    JNI_CreateJavaVM(0, 0, 0);
131    return 0;
132}
133	],[AC_MSG_RESULT(yes)],
134	[AC_MSG_ERROR([Cannot compile a simple JNI program. See config.log for details.
135
136Make sure you have Java Development Kit installed and correctly registered in R.
137If in doubt, re-run "R CMD javareconf" as root.
138])])
139
140#AC_MSG_CHECKING([JNI data types])
141#AC_TRY_RUN(
142#	[
143#include <jni.h>
144#int main(void) {
145#  return (sizeof(int)==sizeof(jint) && sizeof(long)==sizeof(long) && sizeof(jbyte)==sizeof(char) && #sizeof(jshort)==sizeof(short) && sizeof(jfloat)==sizeof(float) && sizeof(jdouble)==sizeof(double))?0:1;
146#}
147#	],
148#	[AC_MSG_RESULT([ok])],
149#	[AC_MSG_ERROR([One or more JNI types differ from the corresponding native type. You may need to use non-standard #compiler flags or a different compiler in order to fix this.])],
150#	[AC_MSG_RESULT([don't know (cross-compiling)])])
151
152
153AC_SUBST(JAVA_LIBS)
154AC_SUBST(JAVA_CPPFLAGS)
155AC_SUBST(JAVA_HOME)
156AC_SUBST(JAVA)
157AC_SUBST(JAVAC)
158AC_SUBST(JAVAH)
159
160
161
162GLPKINSTDIR=`pwd`;
163GLPKINSTDIR=${GLPKINSTDIR}/src/depends/glpk/
164
165AC_SUBST(GLPKINSTDIR)
166
167case "${host_os}" in
168  darwin*)
169    JNISO=.jnilib
170	;;	
171  *)
172    ;;
173esac
174
175if test -z `echo ${R_ARCH}`; then
176	R_ARCH=/`uname -m`;
177fi
178
179case "${R_ARCH}" in /i386*)
180	ARCHFLAG=i386 ;;
181	*) ARCHFLAG=ppc 
182	;;
183esac
184AC_SUBST(ARCHFLAG)
185
186
187
188(echo $host_os)
189case "${host_os}" in 
190	darwin*)
191	PLATFORM=Darwin
192	(echo "Configuring for Darwin")
193	# Manually set the -arch flag for compilation. On snow leopard configure scripts tend to get this wrong
194	#	ARCHFLAG=`uname -m`;
195	
196
197	(echo "Configuring ")
198	(echo $ARCHFLAG)
199
200	(echo "Configuring coin-Cbc")
201	(cd src/depends/coin-Cbc/ && \
202		./configure \
203		--enable-static --disable-shared --with-pic ADD_CXXFLAGS="-arch $ARCHFLAG" ADD_CFLAGS="-arch $ARCHFLAG ")
204
205	(echo "Done configuring coin-CBC")
206	;;
207*)
208	# On all systems other than darwinassume that configure can guess the architecture appropriately. 
209	(echo "Configuring ")
210	PLATFORM=linux
211
212	(echo "Configuring coin-Cbc")
213	(cd src/depends/coin-Cbc/ && \
214		./configure \
215		--enable-static --disable-shared --with-pic)
216
217	(echo "Done configuring coin-CBC")
218	;;
219esac
220
221
222AC_SUBST(PLATFORM)
223
224# Checks for library functions.
225
226AC_CONFIG_FILES([src/Makevars])
227#AC_CONFIG_SUBDIRS([src/depends/coin-Cbc])
228AC_OUTPUT