Changeset 73228a1
- Timestamp:
- Sep 29, 2015 3:31:42 PM (5 years ago)
- Branches:
- master
- Children:
- 2bc8766
- Parents:
- 0848e34
- Location:
- core/c
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
core/c/README
r0848e34 r73228a1 28 28 29 29 30 Build for more than one target at a time 31 ======================================== 32 33 ./mbuild.sh is used to build a whole set of binaries at a time. 34 Each run will build a set of binaries for a specific platform. 35 36 Windows cross-compilation 37 ------------------------- 38 Install ming-w64 (on debian or whichever package that provides i686-w64-mingw32 and x86_64_w64_mingw32). 39 40 To build the 32-bit binaries run something like this: 41 CC=i686-w64-mingw32-gcc TARGET=windows BITS=32 ./mbuild-all.sh 42 43 To build the 64-bit binaries run something like this: 44 CC=x86_64-w64-mingw32-gcc TARGET=windows BITS=64 ./mbuild-all.sh 45 46 30 47 Installation and testing 31 48 ======================== -
core/c/jbigi/build.sh
r0848e34 r73228a1 1 #!/bin/ sh1 #!/bin/bash 2 2 # 3 3 # Build the jbigi library for i2p … … 8 8 # build.sh 9 9 # This script downloads gmp-4.3.2.tar.bz2 to this directory 10 # (if a different version, change the VER= line below)10 # (if a different version, change the GMP_VER= line below) 11 11 # 12 12 # To build a dynamic library (you must have a libgmp.so somewhere in your system) … … 21 21 mkdir -p lib bin/local 22 22 23 # Use 4.3.2 32bit CPUs. 24 # Use 5.0.2 64bit CPUs. 25 VER=6.0.0 26 TARVER=${VER}a 27 TAR=gmp-${TARVER}.tar.bz2 23 # Import gmp version variables and download gmp. 24 source ./download_gmp.sh 25 28 26 29 27 # If JAVA_HOME isn't set, try to figure it out on our own … … 38 36 set -e 39 37 40 download_gmp ()41 {42 URL="https://gmplib.org/download/gmp/${TAR}"43 if [ $(which wget) ]; then44 echo "Downloading $URL"45 wget -N --progress=dot $URL46 else47 echo "ERROR: Cannot find wget." >&248 echo >&249 echo "Please download $URL" >&250 echo "manually and rerun this script." >&251 exit 152 fi53 }54 55 extract_gmp ()56 {57 tar -xjf ${TAR} > /dev/null 2>&1|| (rm -f ${TAR} && download_gmp && extract_gmp || exit 1)58 }59 60 if [ "$1" != "dynamic" -a ! -d gmp-${VER} ]; then61 if [ ! -f $TAR ]; then62 download_gmp63 fi64 65 echo "Building the jbigi library with GMP Version ${VER}"66 echo "Extracting GMP..."67 extract_gmp68 fi69 70 38 cd bin/local 71 39 … … 75 43 Darwin*) 76 44 # --with-pic is required for static linking 77 ../../gmp-${ VER}/configure --with-pic;;45 ../../gmp-${GMP_VER}/configure --with-pic;; 78 46 *) 79 47 # and it's required for ASLR 80 ../../gmp-${ VER}/configure --with-pic;;48 ../../gmp-${GMP_VER}/configure --with-pic;; 81 49 esac 82 50 make -
core/c/jbigi/build_jbigi.sh
r0848e34 r73228a1 13 13 fi 14 14 15 case `uname -s` in 16 MINGW*) 17 JAVA_HOME="c:/software/j2sdk1.4.2_05" 15 16 # Allow TARGET to be overridden (e.g. for use with cross compilers) 17 [ -z $TARGET ] && TARGET=$(uname -s | tr "[A-Z]" "[a-z]") 18 19 # Note, this line does not support windows (and needs to generate a win32/win64 string for that to work) 20 BUILD_OS=$(uname -s | tr "[A-Z]" "[a-z]") 21 echo "TARGET=$TARGET" 22 23 case "$TARGET" in 24 mingw*|windows*) 18 25 COMPILEFLAGS="-Wall" 19 INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include /win32/ -I$JAVA_HOME/include/"26 INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/$BUILD_OS -I/usr/local/include" 20 27 LINKFLAGS="-shared -Wl,--kill-at" 21 28 LIBFILE="jbigi.dll";; 22 29 CYGWIN*) 23 JAVA_HOME="c:/software/j2sdk1.4.2_05"24 30 COMPILEFLAGS="-Wall -mno-cygwin" 25 INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/ win32/ -I$JAVA_HOME/include/"31 INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/$BUILD_OS/ -I$JAVA_HOME/include/" 26 32 LINKFLAGS="-shared -Wl,--kill-at" 27 33 LIBFILE="jbigi.dll";; 28 Darwin*) 29 JAVA_HOME=$(/usr/libexec/java_home) 34 darwin*) 30 35 COMPILEFLAGS="-fPIC -Wall" 31 INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include "32 LINKFLAGS="- dynamiclib -framework JavaVM"36 INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/$BUILD_OS -I/usr/local/include" 37 LINKFLAGS="-m64 -dynamiclib -framework JavaVM" 33 38 LIBFILE="libjbigi.jnilib";; 34 39 SunOS*|OpenBSD*|NetBSD*|*FreeBSD*|Linux*) 35 UNIXTYPE=$(uname -s | tr "[A-Z]" "[a-z]") 36 if [ $UNIXTYPE = "sunos" ]; then 37 UNIXTYPE="solaris" 38 elif [ $UNIXTYPE = "gnu/kfreebsd" ]; then 39 UNIXTYPE="linux" 40 if [ $BUILD_OS = "sunos" ]; then 41 BUILD_OS="solaris" 42 elif [ $BUILD_OS = "gnu/kfreebsd" ]; then 43 BUILD_OS="linux" 40 44 fi 41 45 COMPILEFLAGS="-fPIC -Wall $CFLAGS" 42 INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/$ {UNIXTYPE}-I/usr/local/include"46 INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/$BUILD_OS -I/usr/local/include" 43 47 LINKFLAGS="-shared -Wl,-soname,libjbigi.so" 44 48 LIBFILE="libjbigi.so";; … … 57 61 fi 58 62 63 [ $BITS -eq 32 ] && COMPILEFLAGS="-m32 $COMPILEFLAGS" 64 [ $BITS -eq 64 ] && COMPILEFLAGS="-m64 $COMPILEFLAGS" 65 59 66 echo "Compiling C code..." 60 67 rm -f jbigi.o $LIBFILE 68 echo "JAVA_HOME: $JAVA_HOME" 69 echo "INCLUDESs: $INCLUDES" 70 echo "LD: $LD" 71 echo "Compile: \"$CC -c $COMPILEFLAGS $INCLUDES ../../jbigi/src/jbigi.c || exit 1\"" 61 72 $CC -c $COMPILEFLAGS $INCLUDES ../../jbigi/src/jbigi.c || exit 1 73 echo "Link: \"$CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS $LIBPATH || exit 1\"" 62 74 $CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS $LIBPATH || exit 1 63 75 -
core/c/jbigi/mbuild-all.sh
r0848e34 r73228a1 1 #!/bin/ sh1 #!/bin/bash 2 2 # 3 3 # Run with BITS=32 to generate 32-bit libs on a 64-bit platform … … 8 8 # Linux and *BSD will do the right thing. 9 9 # 10 #BITS=3211 10 12 11 # … … 14 13 # 15 14 16 # FIXME Is this all?17 DARWIN_PLATFORMS="core2 corei"18 MISC_DARWIN_PLATFORMS="powerpc powerpc64 powerpc64le powerpcle"19 15 20 16 # Note: You will have to add the CPU ID for the platform in the CPU ID code … … 36 32 MISC_NETBSD_PLATFORMS="armv5tel mips64el ultrasparc2i sgi hppa2.0 alphaev56 powerpc powerpc64 powerpc64le powerpcle atari amiga m68knommu" # and many, many more 37 33 MISC_OPENBSD_PLATFORMS="alphaev56 ultrasparc2i sgi powerpc powerpc64 hppa2.0 alphaev56 armv5tel mips64el" 38 39 #40 # MINGW/Windows??41 #42 MISC_MINGW_PLATFORMS=""43 34 44 35 # … … 61 52 # As of GMP 6.0.0, libgmp 3, 62 53 X86_64_PLATFORMS="coreisbr coreihwl coreibwl bobcat jaguar bulldozer piledriver steamroller excavator atom athlon64 core2 corei nano pentium4 k10 x86_64" 63 TRANSLATE_NAME_x86_64=" x86" # The _64 tag will be appended to the filename at another place.54 TRANSLATE_NAME_x86_64="none" # Rename x86_64 to none_64 64 55 65 56 # Note! these are 32bit _ONLY_ (after the 64 bit ones) 66 X86_PLATFORMS="${X86_64_PLATFORMS} pentium pentiummmx pentium2 pentium3 pentiumm k6 k62 k63 athlon geode viac3 viac32 x86" 67 57 # Also note that the 64-bit entry "x86_64" is filtered out since it already has the more appropriate "i386" entry 58 X86_PLATFORMS="${X86_64_PLATFORMS//x86_64} pentium pentiummmx pentium2 pentium3 pentiumm k6 k62 k63 athlon geode viac3 viac32 i386" 59 TRANSLATE_NAME_i386="none" # Rename i386 to none 60 61 DARWIN_PLATFORMS="core2 corei coreisbr coreihwl coreibwl" 68 62 MINGW_PLATFORMS="${X86_PLATFORMS} ${MISC_MINGW_PLATFORMS}" 69 63 LINUX_PLATFORMS="${X86_PLATFORMS} ${MISC_LINUX_PLATFORMS}" … … 73 67 OPENBSD_PLATFORM="${X86_PLATFORMS} ${MISC_OPENBSD_PLATFORMS}" 74 68 75 # 76 # You should not need to edit anything below this comment.77 # 69 70 # Import gmp version variables and download gmp. 71 source ./download_gmp.sh 78 72 79 73 # If JAVA_HOME isn't set we'll try to figure it out … … 85 79 fi 86 80 87 if [ ! $(which m4) ]; then81 if ! command -v m4 > /dev/null; then 88 82 printf "\aWARNING: \`m4\` not found. If this process fails to complete, install m4 " >&2 89 83 printf "and re-run this script.\n\n\n\a" >&2 90 sleep 10 91 fi 92 84 exit 1 85 fi 86 87 88 if [ -z $BITS ]; then 89 BITS=32 90 printf "\aBITS variable not set, defaulting to $BITS\n\a" >&2 91 fi 92 93 if [ -z $CC ]; then 94 export CC="gcc" 95 printf "\aCC variable not set, defaulting to $CC\n\a" >&2 96 fi 97 98 if [ $BITS -eq 32 ]; then 99 export CFLAGS="-m32" 100 export LDFLAGS="-m32" 101 elif [ $BITS -eq 64 ]; then 102 export CFLAGS="-m64" 103 export LDFLAGS="-m64" 104 else 105 printf "\aBITS value \"$BITS\" not valid, please select 32 or 64\n\a" >&2 106 exit 1 107 fi 108 109 if ! command -v ${CC} > /dev/null; then 110 echo "The compiler you've selected \"$CC\" does not appear to exist" 111 exit 1 112 fi 113 114 # Set the "_64" filname filename suffix for 64-bit builds 115 if [ $BITS -ne 32 ]; then 116 [ -z $SUFFIX ] && SUFFIX="_64" 117 fi 93 118 94 119 # Allow TARGET to be overridden (e.g. for use with cross compilers) 95 120 [ -z $TARGET ] && TARGET=$(uname -s |tr "[A-Z]" "[a-z]") 96 121 97 98 # Set the version to 5.0.2 for OSX because AFAIK there are only 64bit capable CPUs for the Intel Macs 99 # FIXME do this without sed (and tail) (= portably) 100 if [ `echo $TARGET|grep darwin` ]; then 101 VER=5.0.2 102 elif [ `echo $TARGET|grep sunos` ]; then 103 VER=$(echo gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | /usr/xpg4/bin/tail -n 1) 104 else 105 VER=$(echo gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | tail -n 1) 106 fi 107 108 if [ "$VER" = "" ] ; then 109 echo "ERROR! Can't find gmp source tarball." 110 exit 1 111 fi 112 113 # If the BITS variable isn't set above we'll proceed without setting the *FLAGS 114 # variables ourselves. 115 [ -z $BITS ] && BITS=0 116 117 if [ $BITS -eq 32 ]; then 118 export CC="gcc -m32" 119 export CFLAGS="-m32" 120 export LDFLAGS="-m32" 121 SUFFIX= 122 elif [ $BITS -eq 64 ]; then 123 export CC="gcc -m64" 124 export CFLAGS="-m64" 122 # Note, this line does not support windows (and needs to generate a win32/win64 string for that to work) 123 BUILD_OS=$(uname -s | tr "[A-Z]" "[a-z]") 124 125 # Do some sanity checks for when we're cross-compiling and 126 # set up host string, ARCH_VENDOR_OS. The "\$2" will be replaced 127 # with the name of the arch at configuration time 128 if [ "$TARGET" != "$BUILD_OS" ]; then 129 case "$TARGET" in 130 windows*) 131 HOST_CONFIGURE_FLAG="\$2-w64-mingw32" 132 case "$CC" in 133 *i*86*mingw32*gcc) 134 [ $BITS -ne 32 ] && echo "Error, 32-bit cross-compiler used with non 32-bit architecture" && exit 1 135 ;; 136 *x86_64*mingw32*gcc) 137 [ $BITS -ne 64 ] && echo "Error, 64-bit cross-compiler used with non 64-bit architecture" && exit 1 138 ;; 139 *) 140 echo "No recognized cross-compiler provided in CC env variable." 141 [ $BITS -eq 32 ] && echo "For 32-bit targets, i686-w64-mingw32-gcc recommended" 142 [ $BITS -eq 64 ] && echo "For 64-bit targets, x86_64-w64-mingw32-gcc recommended" 143 exit 1; 144 ;; 145 esac 146 ;; 147 freebsd*) 148 HOST_CONFIGURE_FLAG="\$2-pc-freebsd" 149 ;; 150 darwin*) 151 HOST_CONFIGURE_FLAG="\$2-apple-darwin" 152 # case "$CC" in 153 # *i*86*darwin*) 154 155 156 # [ $BITS -ne 32 ] && echo "Error, 32-bit cross-compiler used with non 32-bit architecture" && exit 1 157 ;; 158 # *x86_64*darwin*) 159 # HOST_CONFIGURE_FLAG="\$2-apple-darwin" 160 # [ $BITS -ne 64 ] && echo "Error, 64-bit cross-compiler used with non 64-bit architecture" && exit 1 161 # ;; 162 # *) 163 # echo "No recognized cross-compiler provided in CC env variable." 164 # [ $BITS -eq 32 ] && echo "For 32-bit targets, i686-apple-darwin10-gcc recommended" 165 # [ $BITS -eq 64 ] && echo "For 64-bit targets, x86_64-apple-darwin10-gcc recommended" 166 # exit 1; 167 # ;; 168 # esac 169 # ;; 170 esac 125 171 fi 126 172 127 173 case "$TARGET" in 128 mingw*) 129 PLATFORM_LIST="${MINGW_PLATFORMS}" 174 mingw*|windows*) 130 175 NAME="jbigi" 131 176 TYPE="dll" 132 177 TARGET="windows" 133 echo "Building windows .dlls for all architectures";; 178 if [ $BITS -ne 32 ]; then 179 PLATFORM_LIST="${X86_64_PLATFORMS}" 180 else 181 PLATFORM_LIST="${X86_PLATFORMS}" 182 fi 183 echo "Building ${TARGET} .dlls for all architectures";; 134 184 darwin*) 135 PLATFORM_LIST="${DARWIN_PLATFORMS}"136 185 NAME="libjbigi" 137 186 TYPE="jnilib" 138 187 TARGET="osx" 188 PLATFORM_LIST="${DARWIN_PLATFORMS}" 139 189 echo "Building ${TARGET} .jnilibs for all architectures";; 140 190 sunos*) 141 PLATFORM_LIST="${X86_64_PLATFORMS}"142 191 NAME="libjbigi" 143 192 TYPE="so" 144 UNIXTYPE="solaris" 145 TARGET="${UNIXTYPE}" 146 if $(echo "$CFLAGS" | grep -q "\-m64") ; then 147 [ -z $SUFFIX ] && SUFFIX="_64" 193 BUILD_OS="solaris" 194 TARGET="${BUILD_OS}" 195 if [ $BITS -eq 32 ]; then 148 196 PLATFORM_LIST="${X86_PLATFORMS}" 149 197 else … … 163 211 ;; 164 212 esac 165 arch=$(uname -m | cut -f1 -d" ") 166 case ${arch} in 167 i[3-6]86) 168 arch="x86";; 169 esac 170 case ${arch} in 171 x86_64 | amd64) 172 PLATFORM_LIST="${X86_64_PLATFORMS}" 173 if [ $BITS -ne 32 ]; then 174 [ -z $SUFFIX ] && SUFFIX="_64" 175 fi 176 ;; 177 #ia64) 178 # PLATFORM_LIST="${X86_64_PLATFORMS}" 179 # TARGET="$TARGET-ia64";; 180 x86) 181 PLATFORM_LIST="${X86_PLATFORMS}";; 213 ARCH=$(uname -m | cut -f1 -d" ") 214 215 case ${ARCH} in 216 x86_64 | amd64 | i*86) 217 if [ $BITS -eq 32 ]; then 218 PLATFORM_LIST="${X86_PLATFORMS}" 219 ARCH="x86" 220 else 221 PLATFORM_LIST="${X86_64_PLATFORMS}" 222 ARCH="x86_64" 223 fi;; 182 224 arm*) 183 225 PLATFORM_LIST="${ARM_PLATFORMS}";; … … 185 227 PLATFORM_LIST="${LINUX_PLATFORMS}";; 186 228 esac 187 echo "Building ${TARGET} .sos for ${ arch}";;229 echo "Building ${TARGET} .sos for ${ARCH}";; 188 230 netbsd*|freebsd*|openbsd*) 189 231 NAME="libjbigi" 190 232 TYPE="so" 191 233 PLATFORM_LIST= 192 arch=$(uname -m | cut -f1 -d" ") 193 case ${arch} in 194 i[3-6]86) 195 arch="x86";; 196 esac 197 case ${arch} in 198 x86_64|amd64) 199 PLATFORM_LIST="${X86_64_PLATFORMS}" 200 [ -z $SUFFIX ] && SUFFIX="_64";; 201 #ia64) 202 # PLATFORM_LIST="${X86_64_PLATFORMS}" 203 # SUFFIX="{SYS}-ia64";; 204 x86) 205 PLATFORM_LIST="${X86_PLATFORMS}";; 234 ARCH=$(uname -m | cut -f1 -d" ") 235 case ${ARCH} in 236 x86_64 | amd64 | i*86) 237 if [ $BITS -eq 32 ]; then 238 PLATFORM_LIST="${X86_PLATFORMS}" 239 ARCH="x86" 240 else 241 PLATFORM_LIST="${X86_64_PLATFORMS}" 242 ARCH="x86_64" 243 fi;; 206 244 *) 207 245 case ${TARGET} in … … 217 255 esac 218 256 esac 219 echo "Building ${TARGET} .sos for ${ arch}";;257 echo "Building ${TARGET} .sos for ${ARCH}";; 220 258 *) 221 259 echo "Unsupported build environment" … … 236 274 ../../build_jbigi.sh static || return 1 237 275 PLATFORM="${2}" 276 277 # Some platforms have different build-time names from 278 # what java and NativeBigInteger refers to them as. 279 # Translate to the proper name here 238 280 eval TRANSLATED_NAME=\$TRANSLATE_NAME_$PLATFORM 239 281 if [ -n "$TRANSLATED_NAME" ]; then 240 282 PLATFORM="${TRANSLATED_NAME}" 241 283 fi 284 242 285 cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${PLATFORM}${6}.${4} 243 286 return 0 … … 265 308 # Nonfatal bail out on unsupported platform. 266 309 (cd ../../gmp-${1}; make clean) 267 if [ $(echo $TARGET| grep -q osx) ]; then 268 ../../gmp-${1}/configure --build=${2}-apple-darwin --with-pic && return 0 310 if [ "$TARGET" != "$BUILD_OS" ]; then 311 # We're cross-compiling, supply a --host flag 312 313 # Here we're making sure that the platform we're target is injected into 314 # the HOST_CONFIGURE_FLAG string. The string looks somehing like this 315 # before the eval: "$2_VENDOR_OS" 316 # and this after: "x86_VENDOR_OS" 317 eval HOST_CONFIGURE_FLAG=$HOST_CONFIGURE_FLAG 318 echo "gmp-${1}/configure --host=${HOST_CONFIGURE_FLAG} --with-pic" 319 ../../gmp-${1}/configure --host=${HOST_CONFIGURE_FLAG} --with-pic && return 0 269 320 else 270 ../../gmp-${1}/configure --build=${2} --with-pic && return 0 271 fi 321 # We're not cross-compiling, we are however building 322 # optimized versions for other platforms on our OS. 323 echo "gmp-${1}/configure --build=${2} --with-pic" 324 ../../gmp-${1}/configure --build=${2} --with-pic && return 0 325 fi 326 kate config.log 327 # if [ $(echo $TARGET| grep -q darwin) ]; then 328 329 # else 330 # ../../gmp-${1}/configure --build=${2} ${HOST_CONFIGURE_FLAG} --with-pic && return 0 331 # fi 272 332 cd .. 333 273 334 rm -R "$2" 274 335 printf "\n\nSorry, ${3}${5}${2} is not supported on your build environment.\a" … … 284 345 } 285 346 286 if [ ! -d gmp-$VER ]; then287 echo "Extracting GMP Version $VER ..."288 if [ -e gmp-$VER.tar.bz2 ]; then289 tar -xjf gmp-$VER.tar.bz2 || ( echo "Error in tarball file!" >&2 ; exit 1 )290 else291 echo "ERROR: gmp tarball not found in current directory" >&2292 exit 1293 fi294 fi295 347 296 348 if [ ! -d bin ]; then 297 349 mkdir bin 298 350 fi 351 299 352 if [ ! -d lib/net/i2p/util ]; then 300 353 mkdir -p lib/net/i2p/util 301 354 fi 302 355 303 304 356 for x in $PLATFORM_LIST 305 357 do 306 ( 307 if [ ! -d bin/$x ]; then 308 mkdir bin/$x 309 cd bin/$x 310 else 311 cd bin/$x 312 rm -Rf * 313 fi 314 315 build_file "$VER" "$x" "$NAME" "$TYPE" "-$TARGET-" "$SUFFIX" 316 ) 358 ( 359 if [ ! -d bin/$x ]; then 360 mkdir bin/$x 361 cd bin/$x 362 else 363 cd bin/$x 364 rm -Rf * 365 fi 366 build_file "$GMP_VER" "$x" "$NAME" "$TYPE" "-$TARGET-" "$SUFFIX" 367 ) 317 368 done 318 369
Note: See TracChangeset
for help on using the changeset viewer.