PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/acinclude.m4

http://github.com/systemc/scv-1.0p2-sysc2.2
m4 | 289 lines | 257 code | 9 blank | 23 comment | 0 complexity | 61a4de4fc7f43dffc5ca141f8499c9b7 MD5 | raw file
  1. dnl
  2. dnl Careful: don't use unquoted commas or double quotes in AC_MSG_ERROR, quote with [ and ]
  3. dnl
  4. AC_DEFUN(SC_VERSION_CHECK,
  5. [
  6. AC_CACHE_CHECK("for systemc version", sc_version,
  7. [
  8. cat > testsc.sh <<EOF
  9. #! /bin/sh
  10. $CXX scver.cc $1 -I[$2] -L[$3] -lsystemc -o scver 2>&5 || exit 1
  11. exit 0
  12. EOF
  13. chmod +x testsc.sh
  14. cat > scver.cc <<EOF
  15. [//
  16. // A program to get the version info from libsystemc.a
  17. //
  18. #include "systemc.h"
  19. int main() {
  20. int maj=0, min=0, kit=0;
  21. sscanf(sc_version()," SystemC %d.%d.%d ",&maj,&min,&kit);
  22. printf("%d%03d%03d\n",maj,min,kit);
  23. return 0;
  24. }]
  25. EOF
  26. if eval ./testsc.sh; then
  27. sc_version=`./scver`
  28. else
  29. sc_version="unknown"
  30. AC_MSG_WARN(Unable to determine the systemC version.
  31. Please check your SystemC installation. )
  32. date
  33. fi;
  34. rm testsc.sh scver.cc scver
  35. ]
  36. )
  37. ]
  38. )
  39. AC_DEFUN(SCV_TEST_CC_SANITY,
  40. [
  41. AC_CACHE_CHECK("for working C++ compiler", scv_cv_cc_sanity,
  42. [
  43. cat > test.sh <<EOF
  44. #! /bin/sh
  45. $CXX conftest.cc [$1] -o test.exe 2>&5
  46. if test -x test.exe; then
  47. ./test.exe
  48. else
  49. exit 1
  50. fi;
  51. EOF
  52. chmod +x test.sh
  53. cat > conftest.cc <<EOF
  54. [//
  55. // A program to determine if a C++ installation is basically sane
  56. // Use some STL and standard library functions
  57. //
  58. /* HP-UX's aCC doesn't have std defined until it sees a std lib header file */
  59. /* (unlike g++ and SunWorks CC.) */
  60. /* So define it here empty. Namespaces are extensible, so this is harmless. */
  61. namespace std {}
  62. using namespace std;
  63. #include <string>
  64. #include <stdio.h>
  65. #include <strstream.h>
  66. int main()
  67. {
  68. #define STRING_SIZE 100
  69. char buf[STRING_SIZE];
  70. int i = 1;
  71. sprintf(buf, "hello world %i", i);
  72. if (strcmp(buf,"hello world 1") != 0)
  73. {
  74. exit(1);
  75. }
  76. ostrstream outString(buf, STRING_SIZE);
  77. outString << "hello world " << i;
  78. if (strcmp(buf,"hello world 1") != 0)
  79. {
  80. exit(1);
  81. }
  82. string str = "hello world";
  83. str = str + " 1";
  84. if (str != "hello world 1")
  85. {
  86. exit(1);
  87. }
  88. //
  89. // OK!
  90. //
  91. exit(0);
  92. }]
  93. EOF
  94. if eval ./test.sh; then
  95. scv_cv_cc_sanity="ok"
  96. rm test.sh conftest.cc test.exe
  97. else
  98. scv_cv_cc_sanity="bad"
  99. AC_MSG_ERROR(A bad C++ compiler or library or linker found.
  100. Please check your C++ installation.
  101. The testfile that failed: ./conftest.cc may be useful in helping you find the problem.)
  102. date
  103. fi;
  104. ]
  105. )
  106. ]
  107. )
  108. AC_DEFUN(SCV_TEST_AUTO_NEQ,
  109. [
  110. AC_CACHE_CHECK("for compiler-provided operator!=", scv_have_auto_neq,
  111. [
  112. cat > test.sh <<EOF
  113. #! /bin/sh
  114. $CXX noteq.cpp [$1] -c -o noteq.o 2>&5 || exit 1
  115. exit 0
  116. EOF
  117. chmod +x test.sh
  118. cat > noteq.cpp <<EOF
  119. [//
  120. // A program to determine whether we need to explicitly define
  121. // operator!= when we define operator==.
  122. //
  123. #include "systemc.h"
  124. struct pppp {
  125. public:
  126. pppp(int v1, int v2) : _v1(v1), _v2(v2) {}
  127. friend bool operator ==(const pppp& o1, const pppp& o2) {
  128. return ( o1._v1 == o2._v1 ) && ( o1._v2 == o2._v2 );
  129. }
  130. private:
  131. int _v1, _v2;
  132. };
  133. int main(int argc, char *argv[])
  134. {
  135. pppp p1(0,1), p2(10,12);
  136. return p1 != p2;
  137. }]
  138. EOF
  139. if eval ./test.sh; then
  140. scv_have_auto_neq="yes"
  141. else
  142. scv_have_auto_neq="no"
  143. fi;
  144. rm -f test.sh noteq.cpp noteq.o
  145. ]
  146. )
  147. ]
  148. )
  149. AC_DEFUN(SCV_TEST_ULL_WRITE,
  150. [
  151. AC_CACHE_CHECK("for unsigned long long stream support", scv_have_ull_write,
  152. [
  153. cat > test.sh <<EOF
  154. #! /bin/sh
  155. $CXX writeull.cc [$1] -o test.exe 2>&5 || exit 1
  156. exit 0
  157. EOF
  158. chmod +x test.sh
  159. cat > writeull.cc <<EOF
  160. [//
  161. // A program to determine whether we need to roll our own
  162. // cout << unsigned long long
  163. //
  164. /* HP-UX's aCC doesn't have std defined until it sees a std lib header file */
  165. /* (unlike g++ and SunWorks CC.) */
  166. /* So define it here empty. Namespaces are extensible, so this is harmless. */
  167. namespace std {}
  168. using namespace std;
  169. #include <stdlib.h>
  170. #include <iostream.h>
  171. int main()
  172. {
  173. unsigned long long hold = 10;
  174. cout << hold << endl;
  175. exit(0);
  176. }]
  177. EOF
  178. if eval ./test.sh; then
  179. scv_have_ull_write="yes"
  180. else
  181. scv_have_ull_write="no"
  182. fi;
  183. rm -f test.sh writeull.cc test.exe
  184. ]
  185. )
  186. ]
  187. )
  188. AC_DEFUN(SCV_TEST_LD_SO,
  189. [
  190. AC_CACHE_CHECK("for ability to dynamically load libraries and access data", scv_cv_ld_so,
  191. [
  192. cat > test.sh <<EOF
  193. #! /bin/sh
  194. $CXX t1conftest.cc [$1] -o libtest$SHLIB_EXT [$2] 2>&5
  195. $CXX t2conftest.cc -o test.exe -L. -ltest 2>&5
  196. if test -x test.exe; then
  197. (LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./test.exe)
  198. else
  199. exit 1
  200. fi;
  201. EOF
  202. chmod +x test.sh
  203. cat > t1conftest.cc <<EOF
  204. struct testT { const char* name; int i; int j; };
  205. testT test[[]] = {{"test0",5,2},{"test1",3,3},{0}};
  206. EOF
  207. cat > t2conftest.cc <<EOF
  208. [#include <iostream.h>
  209. #include <string.h>
  210. #include <stdlib.h>
  211. #include <stdio.h>
  212. struct testT { const char* name; int i; int j;};
  213. static testT (*testP)[];
  214. extern testT test[];
  215. int main() {
  216. testP=(testT(*)[])(&test);
  217. static char str[10];
  218. int i=0, failed=0;
  219. while((*testP)[i].name){
  220. sprintf(str, "test%d",i);
  221. if(strcmp(str, (*testP)[i].name) != 0) ++failed;
  222. i++;
  223. }
  224. if(failed) { exit (1); }
  225. exit (0);
  226. }]
  227. EOF
  228. if eval ./test.sh; then
  229. scv_cv_ld_so="ok"
  230. rm test.sh t*conftest.cc libtest$SHLIB_EXT test.exe
  231. else
  232. scv_cv_ld_so="bad"
  233. AC_MSG_ERROR("unable to access data in shared library")
  234. date
  235. fi;
  236. ]
  237. )
  238. ]
  239. )
  240. AC_DEFUN(SCV_HP_CHECK,
  241. [
  242. dummy=dummy-$$
  243. UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
  244. UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
  245. UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
  246. UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
  247. sed 's/^ //' << EOF >$dummy.c
  248. #include <stdlib.h>
  249. #include <unistd.h>
  250. int main ()
  251. {
  252. #if defined(_SC_KERNEL_BITS)
  253. long bits = sysconf(_SC_KERNEL_BITS);
  254. #endif
  255. long cpu = sysconf (_SC_CPU_VERSION);
  256. switch (cpu)
  257. {
  258. case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
  259. case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
  260. case CPU_PA_RISC2_0:
  261. #if defined(_SC_KERNEL_BITS)
  262. switch (bits)
  263. {
  264. case 64: puts ("hppa2.0w"); break;
  265. case 32: puts ("hppa2.0n"); break;
  266. default: puts ("hppa2.0"); break;
  267. } break;
  268. #else /* !defined(_SC_KERNEL_BITS) */
  269. puts ("hppa2.0"); break;
  270. #endif
  271. default: puts ("hppa1.0"); break;
  272. }
  273. exit (0);
  274. }
  275. EOF
  276. (${CC-cc} $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
  277. rm -f $dummy.c $dummy
  278. export HP_ARCH
  279. ]
  280. )