cmake_release.sh 23.4 KB
Newer Older
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
#!/bin/sh
#=============================================================================
#
# Program:   CMake - Cross-Platform Makefile Generator
# Module:    $RCSfile$
# Language:  C++
# Date:      $Date$
# Version:   $Revision$
#
# Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
# See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
#
#    This software is distributed WITHOUT ANY WARRANTY; without even 
#    the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
#    PURPOSE.  See the above copyright notices for more information.
#
#=============================================================================

#
# CMake UNIX Release Script.
#
# Run with no arguments for documentation.
#

# Release version number.
Bill Hoffman's avatar
Bill Hoffman committed
26
27
TAG="CMake-2-4-6"
VERSION="2.4.6"
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
CMAKE_VERSION="2.4"
RELEASE="1"
PREVIOUS_VERSION="2.2.3"
PREVIOUS_RELEASE="1"

# CVSROOT setting used to check out CMake.
CVSROOT=":pserver:anonymous@www.cmake.org:/cvsroot/CMake"
CVSROOT_GREP=":pserver:anonymous@www.cmake.org:[0-9]*/cvsroot/CMake"

# CMake release root directory.
RELEASE_ROOT_NAME="CMakeReleaseRoot"
RELEASE_ROOT="${HOME}/${RELEASE_ROOT_NAME}"
INSTALL_DIR="Install"

# Installation prefix used during tarball creation.  Tarballs are
# relative to the installation prefix and do not include this in their
# paths.
PREFIX="/usr/local"

# Directory relative to PREFIX where documentation should be placed.
DOC_DIR="/doc/cmake"

# No default compiler.  The config file must provide it.
CC=""
CXX=""
CFLAGS=""
CXXFLAGS=""

# Provide a default make and build flags.
MAKE="make"
BUILD_FLAGS=""
BOOTSTRAP_FLAGS=""

# Details of remote invocation.
[ -z "$REMOTE" ] && SELF="$0"

#-----------------------------------------------------------------------------
usage()
{
    cat <<EOF
CMake Release Script Usage:
  $0 [command]

Typical usage:
  Cleanup remote host release directory:

    $0 remote <host> clean

  Create binary release tarball:

    $0 remote_binary <host>

  Create source release tarball:

    $0 remote_source <host>

  Upload tarballs:

    $0 upload

  Create and upload cygwin package:

    $0 cygwin_package
    $0 cygwin_upload

Available commands:

EOF
    cat "$0" | awk '
/^#--*$/               { doc=1; text="" }

/(^#$|^#[^-].*$)/     {
  if(doc)
    {
    if(text != "") { text = sprintf("%s  %s\n", text, $0) }
    else           { text = sprintf("  %s\n", $0) }
    }
}

/^[A-Za-z0-9_]*\(\)$/ {
  doc=0;
  if(text != "") { printf("%s:\n%s\n", $0, text) }
}
'
}

#-----------------------------------------------------------------------------
error_log()
{
    echo "An error has been logged to $1:" &&
    cat "$1" &&
    return 1
}

#-----------------------------------------------------------------------------
check_host()
{
    HOST="$1"
    if [ -z "$HOST" ]; then
        echo "Must specify host."
        return 1
    fi
}

#-----------------------------------------------------------------------------
# Run a command on the specified remote host.
#
#  remote <host> [command]
#
# Only one level of remote invocation is allowed.  The <host>
# specification must be a valid ssh destination with public
# key authentication and no password.
remote()
{
    if [ ! -z "$REMOTE" ]; then
        echo "Cannot do recursive remote calls."
        return 1
    fi
    check_host "$1" || return 1
    shift
    RTASK="'$1'"; shift; for i in "$@"; do RTASK="${RTASK} '$i'"; done
    RESULT=0
    echo "------- Running remote task on $HOST. -------" &&
    (echo "REMOTE=\"1\"" &&
        (echo TASK=\"`(eval echo '${RTASK}') | (sed 's/"/\\\\"/g')`\") &&
        cat $SELF) | ssh -e none "$HOST" /bin/sh  || RESULT=1
    echo "-------- Remote task on $HOST done.  --------" &&
    return $RESULT
}

#-----------------------------------------------------------------------------
# Copy tarballs from the specified host.
#
#  remote_copy <host> [EXPR]
#
# The <host> specification must be a valid ssh destination
# with public key authentication and no password.  Only
# files matching the given expression are copied.  If
# no expression is given, "*" is used.
remote_copy()
{
    check_host "$1" || return 1
    EXPR="$2"
    [ ! -z "$EXPR" ] || EXPR="*"
    echo "------- Copying tarballs from $HOST. -------" &&
    scp "$HOST:${RELEASE_ROOT_NAME}/Tarballs/${EXPR}" . &&
    echo "---- Done copying tarballs from $HOST. -----"
}

#-----------------------------------------------------------------------------
remote_copy_source()
{
    check_host "$1" || return 1
    remote_copy "$HOST" "cmake-${VERSION}.tar*"
}

#-----------------------------------------------------------------------------
remote_copy_binary()
{
    check_host "$1" || return 1
    remote_copy "$HOST" "cmake-${VERSION}-*"
}

#-----------------------------------------------------------------------------
# Create source tarballs on the specified host and copy them locally.
#
#  remote_source <host>
#
# The <host> specification must be a valid ssh destination
# with public key authentication and no password.
remote_source()
{
    check_host "$1" || return 1
    remote "$HOST" source_tarball &&
    remote_copy_source "$HOST"
}

#-----------------------------------------------------------------------------
# Create binary tarballs on the specified host and copy them locally.
#
#  remote_binary <host>
#
# The <host> specification must be a valid ssh destination
# with public key authentication and no password.
remote_binary()
{
    check_host "$1" || return 1
    remote "$HOST" binary_tarball &&
    remote_copy_binary "$HOST"
}

#-----------------------------------------------------------------------------
# Upload any tarballs in the current directory to the CMake FTP site.
#
#  upload
#
# The user must be able to ssh to kitware@www.cmake.org with public
# key authentication and no password.
upload()
{
    echo "------- Copying tarballs to www.cmake.org. -------"
    scp cmake-${VERSION}*tar.* kitware@www.cmake.org:/projects/FTP/pub/cmake/v${CMAKE_VERSION}
    echo "---- Done copying tarballs to www.cmake.org. -----"
}

#-----------------------------------------------------------------------------
setup()
{
    [ -z "${DONE_setup}" ] || return 0 ; DONE_setup="yes"
    mkdir -p ${RELEASE_ROOT}/Logs &&
    echo "Entering ${RELEASE_ROOT}" &&
    cd ${RELEASE_ROOT}
}

#-----------------------------------------------------------------------------
# Remove the release root directory.
#
#  clean
#
clean()
{
    cd "${HOME}" &&
    echo "Cleaning up ${RELEASE_ROOT}" &&
    rm -rf ${RELEASE_ROOT_NAME}/*
}

#-----------------------------------------------------------------------------
cvs_login()
{
    [ -z "${DONE_cvs_login}" ] || return 0 ; DONE_cvs_login="yes"
    setup || return 1
    (
        if [ -f "${HOME}/.cvspass" ]; then
            CVSPASS="${HOME}/.cvspass"
        else
            CVSPASS=""
        fi
        if [ -z "`grep \"$CVSROOT_GREP\" ${CVSPASS} /dev/null`" ]; then
            echo "cmake" | cvs -q -z3 -d $CVSROOT login
        else
            echo "Already logged in."
        fi
    ) >Logs/cvs_login.log 2>&1 || error_log Logs/cvs_login.log
}

#-----------------------------------------------------------------------------
utilities()
{
    [ -z "${DONE_utilities}" ] || return 0 ; DONE_utilities="yes"
    cvs_login || return 1
    (
        if [ -d "ReleaseUtilities/CVS" ]; then
            cd ReleaseUtilities && cvs -z3 -q update -dAP -r ${TAG}
        else
            rm -rf CheckoutTemp &&
            mkdir CheckoutTemp &&
            cd CheckoutTemp &&
            cvs -q -z3 -d $CVSROOT co -r ${TAG} CMake/Utilities/Release &&
            mv CMake/Utilities/Release ../ReleaseUtilities &&
            cd .. &&
            rm -rf CheckoutTemp
        fi
    ) >Logs/utilities.log 2>&1 || error_log Logs/utilities.log
}

#-----------------------------------------------------------------------------
config()
{
    [ -z "${DONE_config}" ] || return 0 ; DONE_config="yes"
    utilities || return 1
    CONFIG_FILE="config_`uname`"
    echo "Loading ${CONFIG_FILE} ..."
    . "${RELEASE_ROOT}/ReleaseUtilities/${CONFIG_FILE}" >Logs/config.log 2>&1 || error_log Logs/config.log
    if [ -z "${CC}" ] || [ -z "${CXX}" ] || [ -z "${PLATFORM}" ]; then
        echo "${CONFIG_FILE} should specify CC, CXX, and PLATFORM." &&
        return 1
    fi
    export CC CXX CFLAGS CXXFLAGS LDFLAGS PATH LD_LIBRARY_PATH MAKE
}

#-----------------------------------------------------------------------------
checkout()
{
    [ -z "${DONE_checkout}" ] || return 0 ; DONE_checkout="yes"
    config || return 1
    echo "Updating CMake from cvs ..." &&
    (
        if [ -d cmake-${VERSION}/CVS ]; then
            cd cmake-${VERSION} &&
            cvs -q -z3 -d $CVSROOT update -dAP -r ${TAG}
        else
        rm -rf cmake-${VERSION} &&
        rm -rf CheckoutTemp &&
        mkdir CheckoutTemp &&
        cd CheckoutTemp &&
            cvs -q -z3 -d $CVSROOT co -r ${TAG} CMake &&
        mv CMake ../cmake-${VERSION} &&
        cd .. &&
        rm -rf CheckoutTemp
        fi
    ) >Logs/checkout.log 2>&1 || error_log Logs/checkout.log
}

#-----------------------------------------------------------------------------
# Create source tarballs for CMake.
#
#  source_tarball
#
source_tarball()
{
    [ -z "${DONE_source_tarball}" ] || return 0 ; DONE_source_tarball="yes"
    config || return 1
    [ -d "cmake-${VERSION}" ] || checkout || return 1
    echo "Creating source tarballs ..." &&
    (
        mkdir -p Tarballs &&
        rm -rf Tarballs/cmake-${VERSION}.tar* &&
        tar cvf Tarballs/cmake-${VERSION}.tar --exclude CVS cmake-${VERSION} &&
        gzip -c Tarballs/cmake-${VERSION}.tar >Tarballs/cmake-${VERSION}.tar.gz &&
        compress Tarballs/cmake-${VERSION}.tar
    ) >Logs/source_tarball.log 2>&1 || error_log Logs/source_tarball.log
}

#-----------------------------------------------------------------------------
write_cache()
{
    write_standard_cache
}

#-----------------------------------------------------------------------------
write_standard_cache()
{
    cat > CMakeCache.txt <<EOF
BUILD_TESTING:BOOL=ON
CMAKE_SKIP_RPATH:BOOL=1
CMAKE_VERBOSE_MAKEFILE:BOOL=1
HAVE_LIBDL:INTERNAL=0
HAVE_DLOPEN:INTERNAL=0
HAVE_GETHOSTBYADDR_R:INTERNAL=0
HAVE_GETHOSTBYADDR_R_5:INTERNAL=0
HAVE_GETHOSTBYADDR_R_5_REENTRANT:INTERNAL=0
HAVE_GETHOSTBYADDR_R_7:INTERNAL=0
HAVE_GETHOSTBYADDR_R_7_REENTRANT:INTERNAL=0
HAVE_GETHOSTBYADDR_R_8:INTERNAL=0
HAVE_GETHOSTBYADDR_R_8_REENTRANT:INTERNAL=0
HAVE_GETHOSTBYNAME_R:INTERNAL=0
HAVE_GETHOSTBYNAME_R_3:INTERNAL=0
HAVE_GETHOSTBYNAME_R_3_REENTRANT:INTERNAL=0
HAVE_GETHOSTBYNAME_R_5:INTERNAL=0
HAVE_GETHOSTBYNAME_R_5_REENTRANT:INTERNAL=0
HAVE_GETHOSTBYNAME_R_6:INTERNAL=0
HAVE_GETHOSTBYNAME_R_6_REENTRANT:INTERNAL=0
HAVE_GETPASS_R:INTERNAL=0
HAVE_GMTIME_R:INTERNAL=0
HAVE_INET_NTOA_R:INTERNAL=0
HAVE_INET_NTOA_R_DECL:INTERNAL=0
HAVE_INET_NTOA_R_DECL_REENTRANT:INTERNAL=0
HAVE_LOCALTIME_R:INTERNAL=0
HAVE_STRTOK_R:INTERNAL=0
EOF
}

#-----------------------------------------------------------------------------
cache()
{
    [ -z "${DONE_cache}" ] || return 0 ; DONE_cache="yes"
    config || return 1
    echo "Writing CMakeCache.txt ..." &&
    (
        rm -rf "cmake-${VERSION}-${PLATFORM}" &&
        mkdir -p "cmake-${VERSION}-${PLATFORM}" &&
        cd "cmake-${VERSION}-${PLATFORM}" &&
        write_cache
    ) >Logs/cache.log 2>&1 || error_log Logs/cache.log
}

#-----------------------------------------------------------------------------
configure()
{
    [ -z "${DONE_configure}" ] || return 0 ; DONE_configure="yes"
    config || return 1
    [ -d "cmake-${VERSION}" ] || checkout || return 1
    cache || return 1
    echo "Running bootstrap ..." &&
    (
        cd "cmake-${VERSION}-${PLATFORM}" &&
        ../cmake-${VERSION}/bootstrap --prefix=${PREFIX} ${BOOTSTRAP_FLAGS}
    ) >Logs/configure.log 2>&1 || error_log Logs/configure.log
}

#-----------------------------------------------------------------------------
build()
{
    [ -z "${DONE_build}" ] || return 0 ; DONE_build="yes"
    config || return 1
    if [ ! -d "cmake-${VERSION}-${PLATFORM}/Bootstrap" ]; then
        configure || return 1
    fi
    echo "Running make ..." &&
    (
        cd "cmake-${VERSION}-${PLATFORM}" &&
        ${MAKE} ${BUILD_FLAGS}
    ) >Logs/build.log 2>&1 || error_log Logs/build.log
}

#-----------------------------------------------------------------------------
tests()
{
    [ -z "${DONE_tests}" ] || return 0 ; DONE_tests="yes"
    config || return 1
    [ -f "cmake-${VERSION}-${PLATFORM}/bin/ccmake" ] || build || return 1
    echo "Running tests ..." &&
    (
        cd "cmake-${VERSION}-${PLATFORM}" &&
        rm -rf Tests &&
        ./bin/ctest -V
    ) >Logs/tests.log 2>&1 || error_log Logs/tests.log
}

#-----------------------------------------------------------------------------
package()
{
Bill Hoffman's avatar
Bill Hoffman committed
450
    [ -z "${DONE_package}" ] || return 0 ; DONE_package="yes"
451
452
453
454
455
    config || return 1
    [ -d "cmake-${VERSION}-${PLATFORM}/Tests/Simple" ] || tests || return 1
    echo "Running make package ..." &&
    (
        cd "cmake-${VERSION}-${PLATFORM}" &&
Bill Hoffman's avatar
Bill Hoffman committed
456
        ${MAKE} package
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
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
    ) >Logs/install.log 2>&1 || error_log Logs/install.log
}
#-----------------------------------------------------------------------------
install()
{
    [ -z "${DONE_install}" ] || return 0 ; DONE_install="yes"
    config || return 1
    [ -d "cmake-${VERSION}-${PLATFORM}/Tests/Simple" ] || tests || return 1
    echo "Running make install ..." &&
    (
        rm -rf ${INSTALL_DIR} &&
        cd "cmake-${VERSION}-${PLATFORM}" &&
        ${MAKE} install DESTDIR="${RELEASE_ROOT}/${INSTALL_DIR}"
    ) >Logs/install.log 2>&1 || error_log Logs/install.log
}

#-----------------------------------------------------------------------------
strip()
{
    [ -z "${DONE_strip}" ] || return 0 ; DONE_strip="yes"
    config || return 1
    [ -f "${INSTALL_DIR}/usr/local/bin/ccmake" ] || package || return 1
    echo "Stripping executables ..." &&
    (
        strip ${INSTALL_DIR}${PREFIX}/bin/*
    ) >Logs/strip.log 2>&1 || error_log Logs/strip.log
}

#-----------------------------------------------------------------------------
manifest()
{
    [ -z "${DONE_manifest}" ] || return 0 ; DONE_manifest="yes"
    config || return 1
    [ -f "${INSTALL_DIR}/usr/local/bin/ccmake" ] || install || return 1
    echo "Writing MANIFEST ..." &&
    (
        mkdir -p ${INSTALL_DIR}${PREFIX}${DOC_DIR} &&
        rm -rf ${INSTALL_DIR}${PREFIX}${DOC_DIR}/MANIFEST &&
        touch ${INSTALL_DIR}${PREFIX}${DOC_DIR}/MANIFEST &&
        cd ${INSTALL_DIR}${PREFIX} &&
        FILES=`find . -type f |sed 's/^\.\///'` &&
        cd ${RELEASE_ROOT} &&
        (cat >> ${INSTALL_DIR}${PREFIX}${DOC_DIR}/MANIFEST <<EOF
${FILES}
EOF
        ) &&
        rm -rf ${INSTALL_DIR}/README &&
        (cat > ${INSTALL_DIR}/README <<EOF
CMake $VERSION binary for $PLATFORM

Extract the file "cmake-${VERSION}-${PLATFORM}-files.tar" into your
destination directory (typically /usr/local).  The following files will
be extracted:

${FILES}

EOF
        )
    ) >Logs/manifest.log 2>&1 || error_log Logs/manifest.log
}

#-----------------------------------------------------------------------------
# Create binary tarballs for CMake.
#
#  binary_tarball
#
binary_tarball()
{
    [ -z "${DONE_binary_tarball}" ] || return 0 ; DONE_binary_tarball="yes"
    config || return 1
    strip || return 1
}

#-----------------------------------------------------------------------------
cygwin_source_tarball()
{
    [ -z "${DONE_cygwin_source_tarball}" ] || return 0 ; DONE_cygwin_source_tarball="yes"
    config || return 1
    [ -d "cmake-${VERSION}" ] || checkout || return 1
    echo "Creating cygwin source tarball ..." &&
    (
        mkdir -p Cygwin &&
        rm -rf Cygwin/cmake-${VERSION}.tar.bz2 &&
        tar cvjf Cygwin/cmake-${VERSION}.tar.bz2 --exclude CVS cmake-${VERSION}
    ) >Logs/cygwin_source_tarball.log 2>&1 || error_log Logs/cygwin_source_tarball.log
}

#-----------------------------------------------------------------------------
cygwin_source_patch()
{
    [ -z "${DONE_cygwin_source_patch}" ] || return 0 ; DONE_cygwin_source_patch="yes"
    config || return 1
    [ -d "cmake-${VERSION}" ] || checkout || return 1
    echo "Creating source patch for cygwin ..." &&
    (
        mkdir -p Cygwin &&
        rm -rf Cygwin/Patched &&
        mkdir -p Cygwin/Patched &&
        (tar c --exclude CVS cmake-${VERSION} | (cd Cygwin/Patched; tar x)) &&
        cd Cygwin/Patched &&
        mkdir -p cmake-${VERSION}/CYGWIN-PATCHES &&
        (
            CYGVERSION=`uname -r`
            cat > cmake-${VERSION}/CYGWIN-PATCHES/cmake.README <<EOF
cmake
--------------------------------------
Runtime requirements:
  cygwin-${CYGVERSION} or newer

Build requirements
  cygwin-${CYGVERSION} or newer
  make

Canonical homepage:
  http://www.cmake.org

Canonical download:
  ftp://www.cmake.org/pub/cmake/

------------------------------------

Build instructions:
  unpack cmake-${VERSION}-${RELEASE}-src.tar.bz2
    if you use setup to install this src package, it will be
	 unpacked under /usr/src automatically
  cd /usr/src
  ./cmake-${VERSION}-${RELEASE}.sh all

This will create:
  /usr/src/cmake-${VERSION}-${RELEASE}.tar.bz2
  /usr/src/cmake-${VERSION}-${RELEASE}-src.tar.bz2

-------------------------------------------

Port Notes:

The directory /usr/share/cmake-${VERSION}/include is purposely not
located at /usr/include/cmake-${VERSION} or /usr/include/cmake.  The
files it contains are not meant for inclusion in any C or C++ program.
They are used for compiling dynamically loadable CMake commands inside
projects that provide them.  CMake will automatically provide the
proper include path when the files are needed.

------------------

Cygwin port maintained by: CMake Developers <cmake@www.cmake.org>

EOF
        ) &&
        (
            cat > cmake-${VERSION}/CYGWIN-PATCHES/setup.hint <<EOF
# CMake setup.hint file for cygwin setup.exe program
category: Devel 
Bill Hoffman's avatar
Bill Hoffman committed
610
requires: libncurses8 cygwin
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
sdesc: "A cross platform build manager" 
ldesc: "CMake is a cross platform build manager. It allows you to specify build parameters for C and C++ programs in a cross platform manner. For cygwin Makefiles will be generated. CMake is also capable of generating microsoft project files, nmake, and borland makefiles. CMake can also perform system inspection operations like finding installed libraries and header files." 
EOF
        ) &&
        dos2unix cmake-${VERSION}/CYGWIN-PATCHES/setup.hint &&
        cp cmake-${VERSION}/CYGWIN-PATCHES/setup.hint ../setup.hint &&
        (diff -x CVS -urN "../../cmake-${VERSION}" "cmake-${VERSION}" > "../cmake-${VERSION}-${RELEASE}.patch"; [ "$?" = "1" ])
    ) >Logs/cygwin_source_patch.log 2>&1 || error_log Logs/cygwin_source_patch.log
}

#-----------------------------------------------------------------------------
cygwin_package_script()
{
    [ -z "${DONE_cygwin_package_script}" ] || return 0 ; DONE_cygwin_package_script="yes"
    utilities || return 1
    echo "Creating cygwin packaging script ..." &&
    (
        mkdir -p Cygwin &&
        cp ReleaseUtilities/cygwin-package.sh.in Cygwin/cmake-${VERSION}-${RELEASE}.sh &&
        chmod u+x Cygwin/cmake-${VERSION}-${RELEASE}.sh
    ) >Logs/cygwin_package_script.log 2>&1 || error_log Logs/cygwin_package_script.log
}

#-----------------------------------------------------------------------------
# Create the CMake cygwin package files.
#
#  cygwin_package
#
# This command should be run from a cygwin prompt.
cygwin_package()
{
    [ -z "${DONE_cygwin_package}" ] || return 0 ; DONE_cygwin_package="yes"
    config || return 1
    [ -f "Cygwin/cmake-${VERSION}.tar.bz2" ] || cygwin_source_tarball || return 1
    [ -f "Cygwin/cmake-${VERSION}-${RELEASE}.patch" ] || cygwin_source_patch || return 1
    [ -f "Cygwin/cmake-${VERSION}-${RELEASE}.sh" ] || cygwin_package_script || return 1
    echo "Running cygwin packaging script ..." &&
    (
        rm -rf Cygwin/Package &&
        mkdir -p Cygwin/Package &&
        cd Cygwin/Package &&
        cp ../setup.hint . &&
        cp ../cmake-${VERSION}.tar.bz2 . &&
        cp ../cmake-${VERSION}-${RELEASE}.patch . &&
        cp ../cmake-${VERSION}-${RELEASE}.sh . &&
        ./cmake-${VERSION}-${RELEASE}.sh all
    ) >Logs/cygwin_package.log 2>&1 || error_log Logs/cygwin_package.log
}

#-----------------------------------------------------------------------------
# Upload the CMake cygwin package files.
#
#  cygwin_upload
#
# This should be run after "cygwin_package".
cygwin_upload()
{
    setup || return 1
    echo "------- Copying cywgin packages to www.cmake.org. -------"
    scp Cygwin/Package/cmake-${VERSION}-${RELEASE}-src.tar.bz2 \
        Cygwin/Package/cmake-${VERSION}-${RELEASE}.tar.bz2 \
        Cygwin/Package/setup.hint \
        kitware@www.cmake.org:/projects/FTP/pub/cmake/cygwin
    echo "---- Done copying cygwin packages to www.cmake.org. -----"
}

#-----------------------------------------------------------------------------
win32_zipfile()
{
    setup || return 1
    echo "Creating windows non-admin install zip file ..." &&
    (
        mkdir -p Win32 &&
        cd "c:/Program Files" &&
        rm -rf cmake-${VERSION}-x86-win.zip &&
        zip -r cmake-${VERSION}-x86-win.zip CMake \
            -x CMake/INSTALL.LOG -x CMake/UNWISE.EXE -x CMake/WiseUpdt.exe &&
        mv cmake-${VERSION}-x86-win.zip ${RELEASE_ROOT}/Win32
    ) >Logs/win32_zipfile.log 2>&1 || error_log Logs/win32_zipfile.log
}

#-----------------------------------------------------------------------------
win32_upload()
{
    setup || return 1
    echo "------- Copying windows zip file to www.cmake.org. -------"
    scp Win32/cmake-${VERSION}-x86-win.zip \
        kitware@www.cmake.org:/projects/FTP/pub/cmake/v${CMAKE_VERSION}
    echo "---- Done copying windows zip file to www.cmake.org. -----"
}

#-----------------------------------------------------------------------------
# Install CMake into the OSX package directory structure.
#
#  osx_install
#
# This will build CMake if it is not already built.
osx_install()
{
    [ -z "${DONE_osx_install}" ] || return 0 ; DONE_osx_install="yes"
    config || return 1
    [ -f "cmake-${VERSION}-${PLATFORM}/bin/ccmake" ] || build || return 1
    if [ -z "${WX_RESOURCES}" ]; then
        echo "${CONFIG_FILE} should specify WX_RESOURCES."
        return 1
    fi
    echo "Running make install for OSX package ..." &&
    (
        rm -rf OSX &&
        mkdir -p OSX/Resources &&
        (
            cd "cmake-${VERSION}-${PLATFORM}" &&
            ${MAKE} install DESTDIR="${RELEASE_ROOT}/OSX/Package_Root"
        ) &&
        cp cmake-${VERSION}/Copyright.txt OSX/Resources/License.txt
    ) >Logs/osx_install.log 2>&1 || error_log Logs/osx_install.log
# Use this version when the wxCMakeSetup dialog is restored:
#     (
#         rm -rf OSX &&
#         mkdir -p OSX/Resources &&
#         mkdir -p OSX/Package_Root/Applications &&
#         (
#             cd "cmake-${VERSION}-${PLATFORM}" &&
#             ${MAKE} install DESTDIR="${RELEASE_ROOT}/OSX/Package_Root"
#         ) &&
#         cp cmake-${VERSION}/Copyright.txt OSX/Resources/License.txt &&
#         cp -r cmake-${VERSION}-${PLATFORM}/bin/CMake.app OSX/Package_Root/Applications &&
#         echo "APPL????" > OSX/Package_Root/Applications/CMake.app/Contents/PkgInfo &&
#         cp "${WX_RESOURCES}" OSX/Package_Root/Applications/CMake.app/Contents/Resources/wxCMakeSetup.rsrc
#     ) >Logs/osx_install.log 2>&1 || error_log Logs/osx_install.log
}

#-----------------------------------------------------------------------------
run()
{
    CMD="'$1'"; shift; for i in "$@"; do CMD="${CMD} '$i'"; done
    eval "$CMD"
}

# Determine task and evaluate it.
if [ -z "$TASK" ] && [ -z "$REMOTE" ] ; then
    if [ -z "$1" ]; then
        usage
    else
        run "$@"
    fi
else
    [ -z "$TASK" ] || eval run "$TASK"
fi