]> OCCT Git - occt-wok.git/commitdiff
Added opportunity to generate AutoMake files for new platform
authormmv <maxim.mezheninov@opencascade.com>
Mon, 9 Dec 2013 12:04:40 +0000 (16:04 +0400)
committermmv <maxim.mezheninov@opencascade.com>
Mon, 9 Dec 2013 12:04:40 +0000 (16:04 +0400)
src/WOKTclLib/OS.tcl
src/WOKTclLib/osutils.tcl
src/WOKTclLib/templates/build_android [new file with mode: 0755]
src/WOKTclLib/templates/template.ac [changed mode: 0644->0755]
src/WOKTclLib/templates/template.mam [changed mode: 0644->0755]
src/WOKsite/wok_tclshrc.tcl [changed mode: 0644->0755]

index aea000a96b515a6f6120f62d5975f699c63679d3..b7c5f2e95fd38d4316acdd51772f7aaa5fefd27c 100755 (executable)
@@ -3148,7 +3148,7 @@ proc OS:cbp { theModules theOutDir } {
   return $aProjectFiles
 }
 
-proc OS:MKAMK { theOutDir {theModules {}} theSubPath} {
+proc OS:MKAMK { theOutDir {theModules {}} theSubPath isAndroid} {
   wokUtils:FILES:mkdir $theOutDir
 
   foreach aModule $theModules {
@@ -3156,7 +3156,7 @@ proc OS:MKAMK { theOutDir {theModules {}} theSubPath} {
       puts " toolkit: $aToolKit ==> [woklocate -p ${aToolKit}:source:EXTERNLIB]"
       wokUtils:FILES:rmdir $theOutDir/$aToolKit
       wokUtils:FILES:mkdir $theOutDir/$aToolKit
-      osutils:tk:mkam $theOutDir/$aToolKit $aToolKit
+      osutils:tk:mkam $theOutDir/$aToolKit $aToolKit $isAndroid
     }
     foreach anExecutable [OS:executable $aModule] {
       wokUtils:FILES:rmdir $theOutDir/$anExecutable
@@ -3166,7 +3166,7 @@ proc OS:MKAMK { theOutDir {theModules {}} theSubPath} {
   }
 
   osutils:am:adm $theOutDir $theModules
-  osutils:am:root [wokinfo -p HomeDir] $theSubPath $theModules
+  osutils:am:root [wokinfo -p HomeDir] $theSubPath $theModules $isAndroid
 
   puts "The automake files are stored in the $theOutDir directory"
 }
@@ -3301,7 +3301,7 @@ set THE_GUIDS_LIST($aTKNullKey) "{00000000-0000-0000-0000-000000000000}"
 
 # Entry function to generate project files and solutions for IDE
 proc OS:MKPRC { {theOutDir {}} {theProjectType {}} {theIDE ""} } {
-  set aSupportedIDE { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "cmake" "amk" "xcd"}
+  set aSupportedIDE { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "cmake" "amk" "xcd" "android"}
 
   if { [lsearch $aSupportedIDE $theIDE] < 0 } {
     puts stderr "WOK does not support generation of project files for the selected IDE: $theIDE\nSupported IDEs: [join ${aSupportedIDE} " "]"
@@ -3368,7 +3368,8 @@ proc OS:MKPRC { {theOutDir {}} {theProjectType {}} {theIDE ""} } {
     "vc12"  { OS:MKVC  $anOutDir $aModules $anAllSolution $theIDE }
     "cbp"   { OS:MKCBP $anOutDir $aModules $anAllSolution }
     "cmake" { OS:MKCMK "${anOutRoot}/.." $aModules $anAllSolution }
-    "amk"   { OS:MKAMK $anOutDir $aModules "adm/${aWokStation}/${theIDE}"}
+    "amk"   { OS:MKAMK $anOutDir $aModules "adm/${aWokStation}/${theIDE}" ""}
+       "android" { OS:MKAMK $anOutDir $aModules "adm/${aWokStation}/${theIDE}" "true"}
     "xcd"   {
       set ::THE_GUIDS_LIST($::aTKNullKey) "000000000000000000000000" 
       OS:MKXCD $anOutDir $aModules $anAllSolution
index 1901402d1b9e6689b6d5038f62d43dc734d12eba..0960c3ba0d36fe01aa12b8bfbc1a362964eae338 100755 (executable)
@@ -1121,7 +1121,7 @@ proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
 ;# Create in dir the Makefile.am associated with toolkit tkloc.
 ;# Returns the full path of the created file.
 ;#
-proc osutils:tk:mkam { dir tkloc } {
+proc osutils:tk:mkam { dir tkloc isAndroid} {
   set pkgs [woklocate -p ${tkloc}:PACKAGES]
   if { $pkgs == {} } {
     puts stderr "osutils:tk:mkam : Error. File PACKAGES not found for toolkit $tkloc."
@@ -1157,6 +1157,15 @@ proc osutils:tk:mkam { dir tkloc } {
   } else {
     set libadd ""
   }
+
+  if { $isAndroid !={} }   {
+  set avoidversion "lib${tkloc}_la_LDFLAGS = -avoid-version" 
+ } else {
+  set avoidversion ""
+  }
+  
+  regsub -all -- {__AVOIDVERSION__} $tmplat $avoidversion tmplat
+  
   regsub -all -- {__LIBADD__} $tmplat $libadd tmplat
   set source [osutils:am:__SOURCES__ $lsrc]
   regsub -all -- {__SOURCES__} $tmplat $source tmplat
@@ -1363,7 +1372,7 @@ proc osutils:am:adm { dir {lesmodules {}} } {
 ;# Create in dir the Makefile.am and configure.ac in CASROOT directory.
 ;# Returns the full path of the created file.
 ;#
-proc osutils:am:root { dir theSubPath {lesmodules {}} } {
+proc osutils:am:root { dir theSubPath {lesmodules {}} isAndroid} {
   set amstring "srcdir = @srcdir@\n\n"
   append amstring "SUBDIRS = ${theSubPath}\n\n"
   append amstring "VPATH = @srcdir@ @top_srcdir@/${theSubPath}: @top_srcdir@/${theSubPath}:\n\n"
@@ -1422,6 +1431,25 @@ proc osutils:am:root { dir theSubPath {lesmodules {}} } {
     }
     set lower [string tolower ${lower}]
 
+
+  if {$isAndroid !={} } {
+       set flags       {Linux*) CXXFLAGS="$CXXFLAGS -DLIN -D_GNU_SOURCE=1"
+               CFLAGS="$CFLAGS -DLIN"
+               LDFLAGS="$LDFLAGS -lstdc++ -lc";;}
+       set pthread {AC_CHECK_LIB([c],[pthread_create],[],[AC_MSG_ERROR([Posix threads required])])
+               CSF_ThreadLibs_LIB=-lc}
+       set fpucontrol "fpu_control.h"
+       set pathmakefile "adm/lin/android/Makefile"
+  } else {
+  set flags    {Linux*) CXXFLAGS="$CXXFLAGS -DLIN -DLININTEL -D_GNU_SOURCE=1 -mmmx -msse -msse2 -mfpmath=sse -Wall"
+               CFLAGS="$CFLAGS -DLIN -DLININTEL -fexceptions -mmmx -msse -msse2 -mfpmath=sse -Wall"
+               LDFLAGS="$LDFLAGS -lstdc++ -lrt";;}
+               
+       set pthread {AC_CHECK_LIB([pthread],[pthread_create],[],[AC_MSG_ERROR([Posix threads required])])
+                               CSF_ThreadLibs_LIB=-lpthread}
+       set fpucontrol ""
+       set pathmakefile "adm/lin/amk/Makefile"
+  }
     append amstring "\n\nif ENABLE_${up}\n"
     append amstring "  ${theModule}_DIRS = \$(${theModule}_PKGS)\n"
     append amstring "else\n"
@@ -1511,6 +1539,10 @@ proc osutils:am:root { dir theSubPath {lesmodules {}} } {
   append amstring $exelocal
   append amstring $phony
 
+  regsub -all -- {__PATHMAKEFILE__} $acstring $pathmakefile acstring
+  regsub -all -- {__PTHREAD__} $acstring $pthread acstring
+  regsub -all -- {__FPUCONTROL__} $acstring $fpucontrol acstring
+  regsub -all -- {__LINUXFLAGS__} $acstring $flags acstring
   regsub -all -- {__ENABLEMODULES__} $acstring $enablestr acstring
   regsub -all -- {__CONFMODULES__} $acstring $confstr acstring
   regsub -all -- {__CONDMODULES__} $acstring $condstr acstring
diff --git a/src/WOKTclLib/templates/build_android b/src/WOKTclLib/templates/build_android
new file mode 100755 (executable)
index 0000000..125c104
--- /dev/null
@@ -0,0 +1,133 @@
+#!/bin/bash
+#################################################################
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+#################################################################
+# Please define variables (required)
+ndk=/path/to/android-ndk-r8e
+prefix=/path/to/libs
+toolchain=/android-toolchain
+#################################################################
+
+exportvar() 
+{
+ if [ ! -e $ndk$toolchain/sysroot/usr/include/jni.h ]; then 
+   echo "Abort. No toolchain found."
+   exit 0 
+ fi 
+ echo "Running export..."
+ export SYSROOT="$ndk$toolchain/sysroot"
+ export PATH=$PATH:$ndk$toolchain/bin
+ export CXX="$ndk$toolchain/bin/arm-linux-androideabi-g++ --sysroot=$SYSROOT"
+ export CC="$ndk$toolchain/bin/arm-linux-androideabi-gcc --sysroot=$SYSROOT"
+ export NM="$ndk$toolchain/bin/arm-linux-androideabi-nm --sysroot=$SYSROOT"
+ export CPP="$ndk$toolchain/bin/arm-linux-androideabi-cpp --sysroot=$SYSROOT"
+ export AS="$ndk$toolchain/bin/arm-linux-androideabi-as --sysroot=$SYSROOT"
+ export OBJCOPY="$ndk$toolchain/bin/arm-linux-androideabi-objcopy --sysroot=$SYSROOT"
+ export OBJDUMP="$ndk$toolchain/bin/arm-linux-androideabi-objdump --sysroot=$SYSROOT"
+ export STRIP="$ndk$toolchain/bin/arm-linux-androideabi-strip --sysroot=$SYSROOT"
+ export RANLIB="$ndk$toolchain/bin/arm-linux-androideabi-ranlib --sysroot=$SYSROOT"
+ export CCLD="$ndk$toolchain/bin/arm-linux-androideabi-gcc --sysroot=$SYSROOT"
+ export AR="$ndk$toolchain/bin/arm-linux-androideabi-ar --sysroot=$SYSROOT"
+ export LD="$ndk$toolchain/bin/arm-linux-androideabi-ld"
+}
+
+configure() 
+{
+ exportvar
+ echo "Running configure..."
+ ./configure --without-tk --without-tcl --disable-vis --disable-draw --enable-data --enable-algo --enable-dxe --enable-caf --disable-static --enable-debug=no --enable-production=yes --enable-shared=yes --build=i686-pc-linux-gnu --target=arm-linux-androideabi --host=arm-linux-androideabi --prefix=$prefix
+             
+ echo "Done."
+} 
+
+build() 
+{
+ exportvar
+ echo "Running make..."
+ core=$(echo "`nproc`" *2 | bc -l)
+ make -j $core
+ echo "Running make install..."
+ make install
+ echo "Done."
+ exit 0
+}
+
+strip() 
+{ 
+ echo "Running strip..."
+ export STRIP="$ndk$toolchain/bin/arm-linux-androideabi-strip";
+ for f in $prefix/lib/*.so; do $STRIP --strip-unneeded $f; done
+ echo "Done." 
+} 
+
+test() 
+{ 
+ echo "Running test..."
+ if [ ! -e $prefix/lib/libTKernel.so ]; then 
+  echo "Nothing to be done."
+  exit 0 
+ fi
+ cat <<_ACEOF > test.cpp 
+ #include <BRepPrimAPI_MakeTorus.hxx>
+ #include <iostream>
+ int main() {
+   BRepPrimAPI_MakeTorus Torus(4.0, 2.0);
+   return 0;
+ }
+_ACEOF
+
+export CXX="$ndk$toolchain/bin/arm-linux-androideabi-g++"
+$CXX test.cpp -DHAVE_IOSTREAM -DHAVE_FSTREAM -DHAVE_LIMITS_H -DHAVE_IOMANIP \
+-I$prefix/inc/ -L$prefix/lib/ -Wl,--start-group -lTKPrim -lTKMath -lTKernel \
+-lTKG2d -lTKBRep -lTKGeomBase -lTKG3d -lTKTopAlgo -lTKGeomAlgo -Wl,--end-group
+echo "Done."
+}  
+
+help() 
+{
+echo "Download android-ndk-rXX: (Linux XX-bit (x86))
+http://developer.android.com/tools/sdk/ndk/index.html
+
+Create toolchain:
+/android-ndk-rXX/build/tools/make-standalone-toolchain.sh 
+--platform=android-X
+--install-dir=\$ndk/android-toolchain
+--toolchain=arm-linux-androideabi-4.7 
+
+Run scripts:
+./build_configure
+./build_Android configure
+./build_Android build 
+
+For additional information, please read: \$ndk/docs"
+}
+
+case "$1" in
+    configure)
+  configure
+  ;;
+    build)
+  build
+  ;;
+    strip)
+  strip
+  ;;
+    test)
+  test
+  ;;
+    help)
+  help
+  ;;
+ *) 
+ echo   "Usage: $0 {configure|build|test|strip|help}" >&2
+ exit 1 
+esac 
+
+exit 0
old mode 100644 (file)
new mode 100755 (executable)
index de6cfdf..f549532
@@ -36,7 +36,7 @@ dnl Checks for header files.
 AC_HEADER_STDC
 AC_LANG([C])
 AC_MSG_CHECKING([ for C header files ])
-AC_CHECK_HEADERS(dlfcn.h dl.h ieeefp.h time.h sys/time.h pwd.h)
+AC_CHECK_HEADERS(dlfcn.h dl.h ieeefp.h time.h sys/time.h pwd.h __FPUCONTROL__)
 AC_CHECK_HEADERS(sys/statvfs.h sys/vfs.h sys/param.h osfcn.h netdb.h)
 AC_CHECK_HEADERS(sys/ioctl.h net/if.h sys/systeminfo.h sys/utsname.h)
 AC_CHECK_HEADERS(sysent.h unistd.h sys/unistd.h sys/socket.h)
@@ -143,9 +143,7 @@ CXXFLAGS="$CXXFLAGS -DCSFDB -DOCC_CONVERT_SIGNALS"
 CFLAGS="$CFLAGS -DCSFDB -DOCC_CONVERT_SIGNALS"
 
 case $platform in
-       Linux*) CXXFLAGS="$CXXFLAGS -DLIN -DLININTEL -D_GNU_SOURCE=1 -mmmx -msse -msse2 -mfpmath=sse -Wall"
-               CFLAGS="$CFLAGS -DLIN -DLININTEL -fexceptions -mmmx -msse -msse2 -mfpmath=sse -Wall"
-               LDFLAGS="$LDFLAGS -lstdc++ -lrt";;
+       __LINUXFLAGS__
        SunOS*) CXXFLAGS="$CXXFLAGS -Usun -DSOLARIS -instances=static"
                CFLAGS="$CFLAGS -Usun -DSOLARIS -instances=static"
                LDFLAGS="$LDFLAGS -instances=static"
@@ -1081,5 +1079,5 @@ echo "--------------------------  -----"
 __REPMODULES__
 echo
 
-AC_OUTPUT([Makefile adm/lin/amk/Makefile custom.sh \
+AC_OUTPUT([Makefile __PATHMAKEFILE__ custom.sh \
 __ACCONFMODULES__])
old mode 100644 (file)
new mode 100755 (executable)
index 5669bce..da41e85
@@ -14,6 +14,7 @@ __INCLUDES__
 
 lib_LTLIBRARIES=lib__TKNAM__.la
 
+__AVOIDVERSION__
 lib__TKNAM___la_LIBADD = $(CSF_OPT_LIBS) \
 __LIBADD__ \
 __EXTERNLIB__
old mode 100644 (file)
new mode 100755 (executable)
index 62e50f5..df6ae32
@@ -301,7 +301,8 @@ proc wgenprojbat {thePath theIDE} {
     "vc11"  { file copy -force -- "$::env(WOKHOME)/lib/templates/msvc.bat" "$aBox/msvc.bat" }
     "cbp"   { file copy -force -- "$::env(WOKHOME)/lib/templates/codeblocks.sh" "$aBox/codeblocks.sh" }
     "xcd"   { file copy -force -- "$::env(WOKHOME)/lib/templates/xcode.sh" "$aBox/xcode.sh" }
-
+       "android" {file copy -force -- "$::env(WOKHOME)/lib/templates/build_android" "$aBox/build_android" }
+  }
   }
 }
 
@@ -315,7 +316,7 @@ proc removeAllOccurrencesOf { theObject theList } {
 
 # Wrapper-function to generate VS project files
 proc wgenproj { args } {
-  set aSupportedTargets { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "cmake" "amk" "xcd" }
+  set aSupportedTargets { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "cmake" "amk" "xcd" "android"}
   set anArgs $args
 
   # Setting default IDE.
@@ -382,6 +383,7 @@ proc wgenproj { args } {
       cmake -  CMake
       amk   -  AutoMake
       xcd   -  Xcode"
+         android - Android AutoMake"   
       return
   }