Simple command line calculator http://amath.innolan.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

397 lines
10KB

  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2015-2017 Carsten Sonne Larsen <cs@innolan.dk>
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions
  8. # are met:
  9. # 1. Redistributions of source code must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. # 2. Redistributions in binary form must reproduce the above copyright
  12. # notice, this list of conditions and the following disclaimer in the
  13. # documentation and/or other materials provided with the distribution.
  14. #
  15. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  16. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. # ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
  19. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  21. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  22. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  23. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  24. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  25. # SUCH DAMAGE.
  26. #
  27. set -e
  28. APPSRCS='
  29. app/main/evaluator.cpp
  30. app/main/functions.cpp
  31. app/main/graphlist.cpp
  32. app/main/lexer.cpp
  33. app/main/nodes.cpp
  34. app/main/operators.cpp
  35. app/main/optimizer.cpp
  36. app/main/parser.cpp
  37. app/main/statements.cpp
  38. app/main/token.cpp
  39. app/main/values.cpp
  40. app/main/viewer.cpp
  41. app/system/console.cpp
  42. app/system/console_amiga.cpp
  43. app/system/console_stdc.cpp
  44. app/system/filesystem_amiga.cpp
  45. app/system/filesystem_stdc.cpp
  46. app/system/graph.cpp
  47. app/system/graph_amiga.cpp
  48. app/system/graph_gtk.cpp
  49. app/system/language.cpp
  50. app/system/language_amiga.cpp
  51. app/system/language_posix.cpp
  52. app/system/language_stdc.cpp
  53. app/system/preferences.cpp
  54. app/system/preferences_amiga.cpp
  55. app/system/preferences_stdc.cpp
  56. app/system/proc_amiga.cpp
  57. app/system/program.cpp
  58. app/system/program_amiga.cpp
  59. app/system/program_stdc.cpp
  60. app/system/program_test.cpp
  61. app/system/task_amiga.cpp
  62. app/system/task_stdc.cpp
  63. app/system/window_amiga.cpp
  64. app/system/base/io.cpp
  65. app/main.cpp
  66. '
  67. LIBAPPSRCS='
  68. app/lib/aengine.cpp
  69. app/lib/charbuf.cpp
  70. app/lib/cplex.cpp
  71. app/lib/fgrid.cpp
  72. app/lib/ntext.cpp
  73. app/lib/real.cpp
  74. '
  75. LIBREALSRCS='
  76. lib/real/acos.c
  77. lib/real/acosh.c
  78. lib/real/asin.c
  79. lib/real/asinh.c
  80. lib/real/atan.c
  81. lib/real/atan2.c
  82. lib/real/atanh.c
  83. lib/real/cbrt.c
  84. lib/real/ceil.c
  85. lib/real/copysign.c
  86. lib/real/cos.c
  87. lib/real/cosh.c
  88. lib/real/exp.c
  89. lib/real/expm1.c
  90. lib/real/fabs.c
  91. lib/real/finite.c
  92. lib/real/floor.c
  93. lib/real/fmod.c
  94. lib/real/hypot.c
  95. lib/real/isnan.c
  96. lib/real/kcos.c
  97. lib/real/kremp2.c
  98. lib/real/ksin.c
  99. lib/real/ktan.c
  100. lib/real/log.c
  101. lib/real/log10.c
  102. lib/real/log1p.c
  103. lib/real/pow.c
  104. lib/real/remp2.c
  105. lib/real/round.c
  106. lib/real/scalbn.c
  107. lib/real/sin.c
  108. lib/real/sinh.c
  109. lib/real/sqrt.c
  110. lib/real/tan.c
  111. lib/real/tanh.c
  112. lib/real/trunc.c
  113. '
  114. LIBCPLEXSRCS='
  115. lib/cplex/cacos.c
  116. lib/cplex/cacosh.c
  117. lib/cplex/cacot.c
  118. lib/cplex/cacoth.c
  119. lib/cplex/cacsc.c
  120. lib/cplex/cacsch.c
  121. lib/cplex/casec.c
  122. lib/cplex/casech.c
  123. lib/cplex/casin.c
  124. lib/cplex/casinh.c
  125. lib/cplex/catan.c
  126. lib/cplex/catanh.c
  127. lib/cplex/ccbrt.c
  128. lib/cplex/ccos.c
  129. lib/cplex/ccosh.c
  130. lib/cplex/ccot.c
  131. lib/cplex/ccoth.c
  132. lib/cplex/ccsc.c
  133. lib/cplex/ccsch.c
  134. lib/cplex/cexp.c
  135. lib/cplex/clog.c
  136. lib/cplex/clog10.c
  137. lib/cplex/clogb.c
  138. lib/cplex/cpow.c
  139. lib/cplex/csec.c
  140. lib/cplex/csech.c
  141. lib/cplex/csgn.c
  142. lib/cplex/csin.c
  143. lib/cplex/csinh.c
  144. lib/cplex/csqrt.c
  145. lib/cplex/ctan.c
  146. lib/cplex/ctanh.c
  147. lib/cplex/prim.c
  148. '
  149. LIBC1SRCS='
  150. lib/clib/alloccpy.c
  151. lib/clib/mem.c
  152. lib/clib/memcpy.c
  153. lib/clib/memset.c
  154. lib/clib/strcmp.c
  155. lib/clib/strlen.c
  156. lib/clib/untag.c
  157. '
  158. LIBC2SRCS='
  159. lib/dconv/dragon4.cpp
  160. lib/dconv/dmath.cpp
  161. lib/dconv/dprint.cpp
  162. '
  163. if make -v 2>&1 | grep GNU > /dev/null 2>&1 ; then
  164. echo "make(1) is GNU make."
  165. VALID=true
  166. else
  167. echo "make(1) is not GNU make."
  168. VALID=true
  169. fi
  170. if $VALID ; then
  171. if [ -n "$1" ];
  172. then
  173. ARCFLAG="$1 "
  174. else
  175. ARCFLAG=""
  176. fi
  177. if [ -n "$2" ];
  178. then
  179. CROSSCOMPILE="$2"
  180. else
  181. CROSSCOMPILE=""
  182. fi
  183. if [ -n "$3" ];
  184. then
  185. CROSSCOMPILEFLAGS="$3 "
  186. else
  187. CROSSCOMPILEFLAGS=""
  188. fi
  189. if [ -n "$GCC295" ];
  190. then
  191. if [ "$GCC295" = "y" ] || [ "$GCC295" = "Y" ];
  192. then
  193. gcclib="-lgcc"
  194. fi
  195. else
  196. gcclib="-lstdc++"
  197. fi
  198. if [ -n "$REGTEST" ];
  199. then
  200. if [ "$REGTEST" = "n" ] || [ "$REGTEST" = "N" ];
  201. then
  202. options="${options}"
  203. fi
  204. else
  205. options="${options} -DWITHTEST"
  206. fi
  207. if [ -n "$DEBUG" ];
  208. then
  209. if [ "$DEBUG" = "y" ] || [ "$DEBUG" = "Y" ];
  210. then
  211. appop="-O0 -g"
  212. libop="-O0 -g"
  213. exestrip=""
  214. fi
  215. else
  216. appop="-O2"
  217. libop="-O3"
  218. exestrip="-s"
  219. fi
  220. # Use under certain circumstances when GCC is causing problems with FPU
  221. #nff="-fno-strict-aliasing -ffloat-store "
  222. nff=" "
  223. (
  224. echo
  225. echo "CC = ${CROSSCOMPILE}gcc"
  226. echo "CXX = ${CROSSCOMPILE}g++"
  227. # echo "CC = ${CROSSCOMPILE}clang"
  228. # echo "CXX = ${CROSSCOMPILE}clang++"
  229. echo "AR = ${CROSSCOMPILE}ar"
  230. echo "RANLIB = ${CROSSCOMPILE}ranlib"
  231. echo "CFLAGS = ${ARCFLAG}$options ${CROSSCOMPILEFLAGS}"
  232. echo "CXXFLAGS = ${ARCFLAG}$options ${CROSSCOMPILEFLAGS}-I."
  233. # echo "CXXFLAGS = -Wno-inline-new-delete ${ARCFLAG}$options ${CROSSCOMPILEFLAGS}-I."
  234. echo "LFLAGS = $gcclib -lamathapp${outext} -lcamath${outext} -lcomplex${outext} -lamath${outext}"
  235. echo
  236. echo "FLXCAT = build/flexcat/flexcat"
  237. echo "MKDIR = mkdir"
  238. echo "COPY = cp"
  239. echo "DEL = rm -f"
  240. echo "DELREC = rm -Rf"
  241. echo
  242. echo "all: libs app"
  243. echo
  244. echo "libs: libamath libcomplex libcamath libamathapp"
  245. echo
  246. i=""
  247. l=""
  248. for f in ${APPSRCS}
  249. do
  250. b=`basename $f .cpp`
  251. # i=`sed -n -e '/#include.*"/{
  252. # s/"$//
  253. # s/.*"//
  254. # p
  255. # }' $f | sort -u`
  256. echo "${b}.o: ${f}" ${i}
  257. echo " \${CXX} ${appop} \${CXXFLAGS} -Ilib -Iapp -Wall -Werror -c ${f}"
  258. echo
  259. l="${l} ${b}.o"
  260. done
  261. libapp=""
  262. for f in ${LIBAPPSRCS}
  263. do
  264. b=`basename $f .cpp`
  265. echo "${b}.o: ${f}"
  266. echo " \${CC} ${appop} \${CXXFLAGS} -Ilib -Iapp -Wall -Werror -c ${f}"
  267. echo
  268. libapp="${libapp} ${b}.o"
  269. done
  270. libamath=""
  271. for f in ${LIBREALSRCS}
  272. do
  273. b=`basename $f .c`
  274. echo "${b}.o: ${f}"
  275. echo " \${CC} ${libop} -std=c9x \${CLAGS} ${ARCFLAG}-fno-builtin ${nff}-Wall -Werror -Ilib -Ilib/real -c ${f}"
  276. echo
  277. libamath="${libamath} ${b}.o"
  278. done
  279. libcomplex=""
  280. for f in ${LIBCPLEXSRCS}
  281. do
  282. b=`basename $f .c`
  283. echo "${b}.o: ${f}"
  284. echo " \${CC} ${libop} -std=c9x \${CFLAGS} ${ARCFLAG}-fno-builtin -Wall -Werror -Ilib -Ilib/cplex -c ${f}"
  285. echo
  286. libcomplex="${libcomplex} ${b}.o"
  287. done
  288. libc=""
  289. for f in ${LIBC1SRCS}
  290. do
  291. b=`basename $f .c`
  292. echo "${b}.o: ${f}"
  293. echo " \${CC} ${libop} -std=c9x \${CFLAGS} ${ARCFLAG}${ansicon}-fno-builtin -Wall -Werror -Ilib -c ${f}"
  294. echo
  295. libc="${libc} ${b}.o"
  296. done
  297. for f in ${LIBC2SRCS}
  298. do
  299. b=`basename $f .cpp`
  300. echo "${b}.o: ${f}"
  301. echo " \${CXX} ${libop} \${CXXFLAGS} ${ARCFLAG}-fno-builtin -Wall -Werror -Ilib -Ilib/dconv -c ${f}"
  302. echo
  303. libc="${libc} ${b}.o"
  304. done
  305. echo "catalogsa:" # Application catalogs
  306. echo " \${FLXCAT} text/keyword.cd app/localize/kword.h=text/keyword.sd"
  307. echo " \${FLXCAT} text/help.cd app/localize/help.h=text/help.sd"
  308. echo " \${FLXCAT} text/ident.cd app/localize/ident.h=text/ident.sd"
  309. echo " \${FLXCAT} text/text.cd app/localize/text.h=text/text.sd"
  310. echo
  311. echo "catalogsu:" # Unix catalogs
  312. echo " iconv -f ISO-8859-15 -t UTF-8 catalog/dansk/amath-help.ct >utext/dk-help.dict"
  313. echo " iconv -f ISO-8859-15 -t UTF-8 catalog/dansk/amath-ident.ct >utext/dk-ident.dict"
  314. echo " iconv -f ISO-8859-15 -t UTF-8 catalog/dansk/amath-text.ct >utext/dk-text.dict"
  315. echo " iconv -f ISO-8859-15 -t UTF-8 catalog/dansk/amath-keyword.ct >utext/dk-keyword.dict"
  316. echo
  317. echo "catalogsw:" # Windows catalogs
  318. echo " iconv -f ISO-8859-15 -t CP850 catalog/dansk/amath-help.ct >utext/dk-help.dict"
  319. echo " iconv -f ISO-8859-15 -t CP850 catalog/dansk/amath-ident.ct >utext/dk-ident.dict"
  320. echo " iconv -f ISO-8859-15 -t CP850 catalog/dansk/amath-text.ct >utext/dk-text.dict"
  321. echo " iconv -f ISO-8859-15 -t CP850 catalog/dansk/amath-keyword.ct >utext/dk-keyword.dict"
  322. echo
  323. echo "libamathapp: ${libapp}"
  324. echo " \${AR} rcs libamathapp${outext}.a ${libapp}"
  325. echo " \${RANLIB} libamathapp${outext}.a"
  326. echo
  327. echo "libamath: ${libamath}"
  328. echo " \${AR} rcs libamath${outext}.a ${libamath}"
  329. echo " \${RANLIB} libamath${outext}.a"
  330. echo
  331. echo "libcomplex: ${libcomplex}"
  332. echo " \${AR} rcs libcomplex${outext}.a ${libcomplex}"
  333. echo " \${RANLIB} libcomplex${outext}.a"
  334. echo
  335. echo "libcamath: ${libc}"
  336. echo " \${AR} rcs libcamath${outext}.a ${libc}"
  337. echo " \${RANLIB} libcamath${outext}.a"
  338. echo
  339. echo "app: libs ${l}"
  340. echo " \${CC} \${CFLAGS} ${ARCFLAG}${CROSSCOMPILEFLAGS}${exestrip} -L. -o amath${outext} ${l} \${LFLAGS}"
  341. echo
  342. echo "dist: app catalogs"
  343. # echo " \${MKDIR} dist"
  344. echo " \${COPY} amath dist/"
  345. echo " \${COPY} LICENSE dist/"
  346. echo " \${COPY} COPYRIGHT dist/"
  347. echo
  348. echo "amigacatalogs:"
  349. # echo " \${MKDIR} dist"
  350. echo " \${MKDIR} dist/catalog"
  351. echo " \${MKDIR} dist/catalog/english"
  352. echo " \${FLXCAT} text/help.cd catalog/english/amath-help.ct CATALOG dist/catalog/english/amath-help.catalog"
  353. echo " \${FLXCAT} text/ident.cd catalog/english/amath-ident.ct CATALOG dist/catalog/english/amath-ident.catalog"
  354. echo " \${FLXCAT} text/text.cd catalog/english/amath-text.ct CATALOG dist/catalog/english/amath-text.catalog"
  355. echo " \${MKDIR} dist/catalog/dansk"
  356. echo " \${FLXCAT} text/help.cd catalog/dansk/amath-help.ct CATALOG dist/catalog/dansk/amath-help.catalog"
  357. echo " \${FLXCAT} text/ident.cd catalog/dansk/amath-ident.ct CATALOG dist/catalog/dansk/amath-ident.catalog"
  358. echo " \${FLXCAT} text/text.cd catalog/dansk/amath-text.ct CATALOG dist/catalog/dansk/amath-text.catalog"
  359. echo " \${FLXCAT} text/keyword.cd catalog/dansk/amath-keyword.ct CATALOG dist/catalog/dansk/amath-keyword.catalog"
  360. echo
  361. echo "clean:"
  362. echo " \${DEL} ${libapp} ${libamath} ${libcomplex} ${libc} ${l} libamath${outext}.a libcamath${outext}.a libcomplex${outext}.a libamathapp${outext}.a amath${outext}"
  363. echo
  364. echo "distclean:"
  365. echo " \${DEL} ${libapp} ${libamath} ${libcomplex} ${libc} ${l} libamath${outext}.a libcamath${outext}.a libcomplex${outext}.a libamathapp${outext}.a amath${outext}"
  366. echo " \${DELREC} dist"
  367. echo
  368. echo "depend:"
  369. echo " @echo Dependencies already done"
  370. ) > Makefile
  371. echo "Makefile generated${msg}"
  372. # echo
  373. # echo "Build with debug symbols in csh:"
  374. # echo "DEBUG=\"Y\" make"
  375. echo
  376. fi