File: README.mingw

package info (click to toggle)
swi-prolog 6.6.6-1~bpo70+1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 82,312 kB
  • sloc: ansic: 322,250; perl: 245,822; sh: 6,651; java: 5,254; makefile: 4,423; cpp: 4,153; ruby: 1,594; yacc: 843; xml: 82; sed: 12; sql: 6
file content (557 lines) | stat: -rw-r--r-- 13,727 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
#!/bin/bash

# Compiling SWI-Prolog using MinGW
# --------------------------------
#
# This file provides an overview for building SWI-Prolog using MinGW, in
# particular using the cross-compilers that   are  distributed with most
# todays Linux distributions. This  work  is   mostly  done  by  Roberto
# Bagnara (initial port of the Prolog   kernel), Abramo Bagnara and Keri
# Harris.
#
# USAGE
#
# The remainder of the  file  is   an  executable  specification  of the
# installation process. To use it, copy this   file to a directory above
# the location where you want to   build all components. I.e., typically
# the directory above this one and source it into the bash shell:
#
#   % . README.mingw win32|win64
#
# Next, execute the functions for the parts of the process you want. The
# function build_all does everything.
#
# This script has been tested for   cross-compilation  on a Linux system
# with the mingw cross-compiler and wine installed.
#
# PREREQUISITES
#
# The open source libraries on which   SWI-Prolog depends are downloaded
# and   built   using   the   functions   download_prerequisites()   and
# build_prerequisites().  In  addition,  the  following    need   to  be
# installed:
#
#   - The Oracle Java SDK for building JPL
#	- jdk-<version>-windows-i586.exe into
#	  /C/Program Files (x86)/... (default on 64-bit Windows)
#	- jdk-<version>-windows-x64.exe into
#	  /C/Program Files/... (default on 64-bit Windows)
#   - NSIS installer generator for generating the installer.
#       - nsis-<version>-setup.exe into /C/Program Files (x86)/...
#   - MSVC tools (lib.exe) for creating MSVC compatible .lib files
#       - Install Microsoft Visual C++ Express on your Windows partition
#       - Copy "c:/Program Files (x86)/Microsoft Visual Studio 9" into
#	  your ".wine/drive_c/Program Files (x86)"
#	- Use "wine regedit" to add ...\VC\bin and ...\Common7\IDE to
#	  your wine PATH.
#	- Run "wine lib.exe" to see whether it works
#	(See
#	http://issaris.blogspot.nl/2008/04/creating-dlls-using-visual-c-8-on.html)
#
# UBUNTU PACKAGES
#
# Tested on Ubuntu 12.04 on AMD64. Installing   wine  in this version is
# broken, but can be get  te  work   using  the  following  commands. In
# particular WINE-GECKO MUST BE INSTALLED FIRST.
#
#   - Remove all wine and wingw packages
#   - apt-get install wine-gecko1.5
#   - apt-get install wine
#   - apt-get install mingw-w64
#
# If you cannot run Win64 executables with   your  wine, .wine is out of
# date. The only working advice I found   sofar is to (re)move .wine and
# start wine to create a fresh installation.
#
# Linux must be configured such that Windows  .exe files can be executed
# directly    without    explicit    invocation      of     wine.    See
# https://www.kernel.org/doc/Documentation/binfmt_misc.txt
#
# Updated for Ubuntu 14.04. This  version   ships  with MinGW 4.8, which
# provides winpthread. If you upgrade, you  must remove pthreads-w32 and
# recompile the prerequisites to depend on MinGW's native pthreads:
#
#   - Remove pthreads-w32 and all traces from $install/bin, $install/lib
#     and $install/include
#   - Run clean_prerequisites (function in this script)
#   - Run build_prerequisites (function in this script)

TARGETHOST="$1"
MAKE="make -j 4"

case "$TARGETHOST" in
    win64) BITS=64
	 ;;
    win32) BITS=32
	 ;;
    *)	   echo "Please run as . $BASH_SOURCE 'win32|win64'"
	   return
esac

PS1=W$BITS' (\W\[\e[36m\]$(__git_ps1 "; %s")\[\e[0m\]) \!_> '

export BUILDARCH=$TARGETHOST

# Versions of prerequisite packages. Used to  download the right release
# file.

GMP_VERSION=5.0.5
PTHREADS_VERSION=2-9-1-release
SSL_VERSION=1.0.1g
JPEG_VERSION=8d
ZLIB_VERSION=1.2.7
ARCHIVE_VERSION=3.1.2
UUID_VERSION=1.6.2

PLDIR=pl

# installation prefix.  This path should not have spaces in one of the
# directory names.

install="${install-$HOME/mingw$BITS}"
src="$(pwd)"
PATH=$install/swipl/bin:$PATH

# Check whether we are cross-compiling or running under MSYS in Windows.
# Note that the MSYS version has not yet been tested.

case "$(uname)" in
    MINGW*)
	CROSSCOMPILING=no
	export PATH=$install/bin:$PATH
	DRIVEC="/C"
	MINGWGCC=gcc
	;;
    *)
	CROSSCOMPILING=yes
	export WINEDEBUG=-all
	DRIVEC="$HOME/.wine/drive_c"
	export WINEPATH="$(winepath -w $install/bin)"
	;;
esac

if [ "$CROSSCOMPILING" = yes ]; then
  if [ -z "$CROSS" ]; then
    case $TARGETHOST in
      win64)
	CROSS=x86_64-w64-mingw32
	;;
      win32)
        if [ -r /usr/bin/i686-w64-mingw32-gcc ]; then
	  CROSS=i686-w64-mingw32
	else
	  CROSS=i586-mingw32msvc
	fi
	;;
    esac
  fi
  MINGWGCC=$CROSS-gcc
fi

# See whether pthread is built-in

if [ -r "$($MINGWGCC -print-file-name=libwinpthread-1.dll)" ]; then
  PTHREADS_VERSION=
fi

# Java configuration
# Note that Win64 javac and javadoc crash under Wine (1.5.6).  But, we
# can use the native Linux versions

if [ -z "$JAVAROOT" ]; then
  case $TARGETHOST in
    win64)
      JAVAROOT="$DRIVEC/Program Files/Java"
      if [ "$CROSSCOMPILING" = yes ]; then
        export JAVAC=javac
	export JAVADOC=javadoc
      fi
      ;;
    win32)
      JAVAROOT="$DRIVEC/Program Files (x86)/Java"
      ;;
  esac
fi
JAVAPREFIX="$(echo "$JAVAROOT"/jdk*)/bin"
export JAVAPREFIX

# Set some variables to find the Windows libraries and include files

# export COFLAGS=-g
export CIFLAGS="-I$install/include"
export CPPFLAGS=-I$install/include
export LDFLAGS="-L$install/lib"
export PKGLDFLAGS=-I$install/lib


################################################################
# end of gathering info about the environment; the remainder are
# functions that perform steps of the build process
################################################################

################
# Handy for running autoconf from a directory

config()
{ if [ -r ./configure ]; then
    ./configure --host=$CROSS --prefix=$install
  elif  [ -r ../src/configure ]; then
    ./configure --host=$CROSS --prefix=$install
  fi
}


################
# Create target directories

make_mingw_dirs()
{ mkdir -p $install/include
  mkdir -p $install/lib
  mkdir -p $install/bin
}


###########################
# Download and install the GMP library.

download_gmp()
{ GMP_FILE=gmp-$GMP_VERSION.tar.bz2

  [ -f $GMP_FILE ] || \
    wget ftp://ftp.gmplib.org/pub/gmp-$GMP_VERSION/$GMP_FILE
  tar jxf $GMP_FILE
}

build_gmp()
{ ( cd gmp-$GMP_VERSION
    ./configure --host=$CROSS --prefix=$install \
       --enable-shared --disable-static
    make
    make install
  )
}

###########################
# Download and install the Pthreads-win32 library.  Only if PTHREADS_VERSION
# is set. Else we assume a recent MinGW64, which ships with
# libwinpthread

download_pthread_win32()
{ if [ ! -z "$PTHREADS_VERSION" ]; then
    PTHREADS_FILE=pthreads-w32-$PTHREADS_VERSION.tar.gz

    cd $src
    [ -f $PTHREADS_FILE ] || \
      wget ftp://sourceware.org/pub/pthreads-win32/$PTHREADS_FILE

    tar xzf $PTHREADS_FILE
  fi
}

build_pthread_win32()
{ if [ -d pthreads-w32-$PTHREADS_VERSION ]; then
    ( cd pthreads-w32-$PTHREADS_VERSION
      make -f GNUmakefile CROSS=$CROSS- \
	  LFLAGS="-lwsock32 -Wl,--out-implib=libpthreadGC2.dll.a" GC
      cp pthread.h semaphore.h sched.h $install/include/
      cp pthreadGC2.dll $install/bin/
      cp libpthreadGC2.dll.a $install/lib/
    )
  fi
}

###########################
# Download and install ssl

download_ssl()
{ SSL_FILE=openssl-$SSL_VERSION.tar.gz
  [ -f $SSL_FILE ] || wget http://www.openssl.org/source/$SSL_FILE
  tar xzf $SSL_FILE
}

build_ssl()
{ ( cd openssl-$SSL_VERSION
    export CC=$MINGWGCC
    case $CROSS in
	i?86*)	 MINGW=mingw
		 ;;
	x86_64*) MINGW=mingw64
		 ;;
	*)	 echo "SSL: Unknown CROSS: $CROSS"
		 exit 1
		 ;;
    esac;
    ./Configure $MINGW --prefix=$install shared threads
    make CROSS_COMPILE=$CROSS- depend
    make CROSS_COMPILE=$CROSS-
    make CROSS_COMPILE=$CROSS- install_sw
  )
}

###########################
# Download and install jpeg

download_jpeg()
{ JPEG_FILE=jpegsrc.v$JPEG_VERSION.tar.gz

  [ -f $JPEG_FILE ] || wget http://www.ijg.org/files/$JPEG_FILE
  tar xzf $JPEG_FILE
}

build_jpeg()
{ ( cd jpeg-$JPEG_VERSION
    ./configure --host=$CROSS --prefix=$install --enable-shared
    make
    make install
  )
}

###########################
# Download and install libXpm

download_libxpm()
{ if [ -d libXpm ]; then
     (cd libXpm && git pull)
  else
     git clone git://www.swi-prolog.org/home/pl/git/misc/libXpm.git
  fi
}

build_libxpm()
{ ( cd libXpm/lib
    autoconf
    ./configure --host=$CROSS --prefix=$install
    make -f Makefile.mingw
    make -f Makefile.mingw install
  )
}

###########################
# Download and install zlib

download_zlib()
{ ZLIB_FILE=zlib-$ZLIB_VERSION.tar.bz2

  [ -f $ZLIB_FILE ] || \
    wget http://garr.dl.sourceforge.net/project/libpng/zlib/$ZLIB_VERSION/$ZLIB_FILE
  tar xjf $ZLIB_FILE
}

build_zlib()
{ ( cd zlib-$ZLIB_VERSION
    make -f win32/Makefile.gcc PREFIX=$CROSS- BINARY_PATH=$install/bin INCLUDE_PATH=$install/include LIBRARY_PATH=$install/lib SHARED_MODE=1 IMPLIB=libz.dll.a install
  )
}

#################################
# Download and install libarchive

download_libarchive()
{ ARCHIVE_FILE=libarchive-$ARCHIVE_VERSION.tar.gz

  [ -f $ARCHIVE_FILE ] || \
    wget http://www.libarchive.org/downloads/$ARCHIVE_FILE
  tar xzf $ARCHIVE_FILE
}

# lt_cv_deplibs_check_method=pass_all works around a bug in libtool
# causing: "linker path does not have real file for library" error on MinGW
# See http://lists.cairographics.org/archives/cairo/2009-July/017686.html

build_libarchive()
{ ( cd libarchive-$ARCHIVE_VERSION
    export CFLAGS="-I$install/include"
    export LDFLAGS="-L$install/lib"
    export lt_cv_deplibs_check_method='pass_all'
    export ac_cv_func__localtime64_s='no'
    export ac_cv_func__ctime64_s='no'
    ./configure --host=$CROSS --prefix=$install --with-pic \
    --without-iconv --without-openssl --without-nettle --without-xml2 \
    --without-expat --without-libregex --without-bz2lib \
    --without-lzmadec --without-lzma --without-lzo2
    make
    make install
  )
}


download_libuuid()
{ UUID_FILE=uuid-$UUID_VERSION.tar.gz

  [ -f $UUID_FILE ] || \
  curl ftp://ftp.ossp.org/pkg/lib/uuid/$UUID_FILE > $UUID_FILE
  tar zxvf $UUID_FILE
}

build_libuuid()
{ ( cd uuid-$UUID_VERSION
    ./configure --host=$CROSS --prefix=$install
    make
    make install
  )
}


###########################
# Do the whole lot for all prerequisites

clean_prerequisites()
{ ( cd gmp-$GMP_VERSION && make distclean )
  ( cd openssl-$SSL_VERSION && make distclean )
  ( cd jpeg-$JPEG_VERSION && make distclean )
  ( cd libXpm/lib && make distclean )
  ( cd zlib-$ZLIB_VERSION && make distclean )
  ( cd libarchive-$ARCHIVE_VERSION && make distclean )
  ( cd uuid-$UUID_VERSION && make distclean )
  if [ -d pthreads-w32-$PTHREADS_VERSION ]; then
    ( cd pthreads-w32-$PTHREADS_VERSION && make distclean )
  fi
}


download_prerequisites()
{ download_gmp
  download_pthread_win32
  download_ssl
  download_jpeg
  download_libxpm
  download_zlib
  download_libarchive
  download_libuuid
}

build_prerequisites()
{ build_gmp
  build_pthread_win32
  build_ssl
  build_jpeg
  build_libxpm
  build_zlib
  build_libarchive
  build_libuuid
}

###########################
# Download and unpack a SWI-Prolog source distribution.

enter_topdir()
{ if [ ! -r build.templ ]; then
    if [ -r $PLDIR/build.templ ]; then
      cd $PLDIR
    else
      echo "ERROR: Cannot find SWI-Prolog sources"
      return 1
    fi
  fi
}


download_swipl()
{ if [ ! -d $PLDIR -a ! -r build.templ ]; then
    git clone git://www.swi-prolog.org/home/pl/git/$PLDIR.git
  fi

  ( enter_topdir
    git pull
    ./prepare --yes
  )
}

build_swipl_core()
{ export CIFLAGS="-I$install/include"
  export LDFLAGS="-L$install/lib"
  ( enter_topdir
    wineserver || true
    ./configure --host=$CROSS --prefix=$install \
        --disable-readline --disable-libdirversion \
        --enable-shared --disable-static
    $MAKE 2>&1 | tee make.out
    if [ "${PIPESTATUS[0]}" != 0 ]; then exit 1; fi
    make install 2>&1 | tee make-install.out
    if [ "${PIPESTATUS[0]}" != 0 ]; then exit 1; fi
  )
}

dist_dlls="libarchive-*.dll libeay32.dll libgmp-*.dll libjpeg-*.dll "
dist_dlls+="*pthread*.dll ssleay32.dll zlib*.dll"
if [ -r "$(echo $install/bin/libgcc*.dll)" ]; then
  dist_dlls+=" $(basename $install/bin/libgcc*.dll)"
fi

# this assumes that the required GCC dlls are copied into $install

copy_dlls()
{ (cd $install/bin && cp $dist_dlls $install/swipl/bin)
  if [ -r $install/lib/libpthreadGC2.dll.a ]; then
    cp $install/lib/libpthreadGC2.dll.a $install/swipl/lib
  fi
}


# Usage: build_swipl_packages [pkg ...]

build_swipl_packages()
{ ( enter_topdir
    cd packages
    export CPPFLAGS=-I$install/include
    export PKGLDFLAGS=-I$install/lib
    [ -z "$1" ] || export PKG="$1"
    ./configure --host=$CROSS --prefix=$install
    $MAKE 2>&1 | tee -a ../make.out
    if [ "${PIPESTATUS[0]}" != 0 ]; then exit 1; fi
    make install 2>&1 | tee -a ../make-install.out
    if [ "${PIPESTATUS[0]}" != 0 ]; then exit 1; fi
    make html-install || exit 1
  )
}

check_build()
{ ( enter_topdir
    [ -f make.out ] && scripts/check_build_log.sh make.out
  )
}

build_swipl()
{ build_swipl_core
  copy_dlls
  build_swipl_packages
  check_build
}

clean_swipl()
{ ( enter_topdir
    make distclean
  )
}

uninstall_swipl()
{ rm -rf $install/swipl
}


build_installer()
{ ( enter_topdir
    cd ${BUILDARCH-src}
    make installer
  )
}

###########################
# Do the whole lot

build_all()
{ make_mingw_dirs
  build_prerequisites
  build_swipl
}

######################
# Create a new release

build_release()
{ clean_swipl
  uninstall_swipl
  download_swipl
  build_swipl
  build_installer
}