summaryrefslogtreecommitdiffstats
path: root/Utilities/cmake_release_unix.sh
blob: 71c5683a7883c6307b84a9ab9e68d227f73f3406 (plain)
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
#!/bin/sh
#
# CMake UNIX Release Script.
#
# Run this in an empty directory.  Your ~/.cvspass file should already
# have an entry for the CVSROOT used below.
#

# Check the command line arguments.
CONFIG_FILE=$1
if test "x$1" = "x"; then
  echo "Usage:"
  echo "  $0 <configuration-file>"
  echo ""
  echo "Sample configuration file:"
  echo "  RELEASE_TAG=\"Release-1-4\""
  echo "  VERSION=\"1.4\""
  echo "  PLATFORM=\"x86-linux\""
  exit 1
fi

# Set some defaults here.  They can be changed by the configuration
# file.
CVSROOT=":pserver:anonymous@www.cmake.org:/cvsroot/CMake"
CURSES_LIBRARY="/usr/lib/libcurses.a"
FORM_LIBRARY="/usr/lib/libform.a"
STATIC_LINK_FLAGS="-static"
RELEASE_ROOT=`pwd`
CREATE_SOURCE_TARBALL="no"
CMAKE="cmake"
GZIP="gzip"
COMPRESS="compress"
TAR="tar"
CAT="cat"
MAKE="make"
FIND="find"
CVS="cvs"
CC="gcc"
CXX="c++"
CFLAGS=""
CXXFLAGS=""

#-----------------------------------------------------------------------------
# Configuration options (could be in separate file)
echo "Reading configuration from ${CONFIG_FILE}..."
if . `pwd`/${CONFIG_FILE} ; then : ; else
  echo "Error reading configuration."
  exit 1
fi
#-----------------------------------------------------------------------------

export CC CXX CFLAGS CXXFLAGS

# Select directories.
INSTALL_DIR="${RELEASE_ROOT}/Install"
TARBALL_DIR="${RELEASE_ROOT}/Tarballs"
BUILD_DIR="${RELEASE_ROOT}/CMake-$VERSION-static"
LOG_DIR="${RELEASE_ROOT}/Logs"

# Cleanup from possible previous run.
rm -rf ${LOG_DIR} ${BUILD_DIR} ${INSTALL_DIR} ${TARBALL_DIR}
mkdir -p ${LOG_DIR} ${BUILD_DIR} ${INSTALL_DIR} ${TARBALL_DIR}

# Make sure the source is exported from CVS.
SOURCE_DIR="${RELEASE_ROOT}/CMake-$VERSION"
if test ! -d ${SOURCE_DIR} ; then
  cd ${RELEASE_ROOT}
  rm -rf CMake
  echo "Exporing CMake from CVS..."
  if ${CVS} -z3 -d ${CVSROOT} export -r ${RELEASE_TAG} \
       CMake > ${LOG_DIR}/cvs.log 2>&1 ; then : ; else
    echo "Error, see ${LOG_DIR}/cvs.log"
    exit 1
  fi
  mv CMake CMake-$VERSION
fi

# Make the source tarball if requested.
if test "${CREATE_SOURCE_TARBALL}" = "yes" ; then
  TARBALL="${TARBALL_DIR}/CMake$VERSION-src-unix.tar"
  echo "Creating CMake$VERSION-src-unix.tar"
  if ${TAR} cvf $TARBALL CMake-$VERSION \
       > ${LOG_DIR}/CMake$VERSION-src-unix.log 2>&1 ; then : ; else
    "Error, see ${LOG_DIR}/CMake$VERSION-src-unix.log"
    exit 1
  fi
  if test "x${GZIP}" != "x" ; then
    echo "Creating $TARBALL.gz"
    ${GZIP} -c $TARBALL > $TARBALL.gz
  fi
  if test "x${COMPRESS}" != "x" ; then
    echo "Creating $TARBALL.Z"
    ${COMPRESS} $TARBALL
  fi
fi

# Build the release.
cd ${BUILD_DIR}
echo "Writing CMakeCache.txt..."
${CAT} >> CMakeCache.txt <<EOF
BUILD_TESTING:BOOL=OFF
CMAKE_CXX_SHLIB_LINK_FLAGS:STRING=${STATIC_LINK_FLAGS}
CMAKE_CXX_SHLIB_BUILD_FLAGS:STRING=
CMAKE_CXX_SHLIB_RUNTIME_FLAG:STRING=
CMAKE_INSTALL_PREFIX:PATH=${INSTALL_DIR}
CURSES_LIBRARY:FILEPATH=${CURSES_LIBRARY}
FORM_LIBRARY:FILEPATH=${FORM_LIBRARY}
EOF

echo "Running CMake..."
if ${CMAKE} ${SOURCE_DIR} > ${LOG_DIR}/cmake.log 2>&1 ; then : ; else
  echo "Error, see ${LOG_DIR}/cmake.log"
  exit 1
fi

echo "Running make..."
if ${MAKE} > ${LOG_DIR}/make.log 2>&1 ; then : ; else
  echo "Error, see ${LOG_DIR}/make.log"
  exit 1
fi

echo "Running make install..."
if ${MAKE} install > ${LOG_DIR}/make_install.log 2>&1 ; then : ; else
  echo "Error, see ${LOG_DIR}/make_install.log"
  exit 1
fi

# Create the release tarballs.
cd ${INSTALL_DIR}
echo "Creating cmake-$VERSION-$PLATFORM.tar"

if ${TAR} cvf cmake-$VERSION-$PLATFORM.tar bin share \
     > ${LOG_DIR}/cmake-$VERSION-$PLATFORM.log 2>&1 ; then : ; else
  echo "Error, see ${LOG_DIR}/cmake-$VERSION-$PLATFORM.log"
  exit 1
fi

echo "Writing README"
FILES=`${FIND} bin share -type f |sed 's/^\.\///'`
${CAT} >> README <<EOF
CMake $VERSION binary for $PLATFORM - statically linked

Extract the file "cmake-$VERSION-$PLATFORM.tar" into your destination directory.
The following files will be extracted:

${FILES}

EOF

TARBALL="${TARBALL_DIR}/CMake$VERSION-$PLATFORM-static.tar"
echo "Creating CMake$VERSION-$PLATFORM-static.tar"
if ${TAR} cvf $TARBALL README cmake-$VERSION-$PLATFORM.tar \
     > ${LOG_DIR}/CMake$VERSION-$PLATFORM-static.log 2>&1 ; then : ; else
  "Error, see ${LOG_DIR}/CMake$VERSION-$PLATFORM-static.log"
  exit 1
fi

if test "x${GZIP}" != "x" ; then
  echo "Creating $TARBALL.gz"
  ${GZIP} -c $TARBALL > $TARBALL.gz
fi

if test "x${COMPRESS}" != "x" ; then
  echo "Creating $TARBALL.Z"
  ${COMPRESS} $TARBALL
fi