summaryrefslogtreecommitdiffstats
path: root/Utilities/Release/Cygwin/cygwin-package.sh.in
blob: dff27f14dbbf8632f5a0acfd3be01bae95594a85 (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
TOP_DIR=`cd \`echo "$0" | sed -n '/\//{s/\/[^\/]*$//;p;}'\`;pwd`

# create build directory
mkdirs()
{
  (
  mkdir -p "$TOP_DIR/@CPACK_PACKAGE_FILE_NAME@/.build"
  )
}

# cd into
# untar source tree and apply patch
prep()
{
  (
  cd "$TOP_DIR" &&
  tar xvfj @CPACK_PACKAGE_FILE_NAME@.tar.bz2
  patch -p0 < "@CPACK_PACKAGE_FILE_NAME@-@CPACK_CYGWIN_PATCH_NUMBER@.patch" &&
  mkdirs
  )
}

conf()
{
  (
  cd "$TOP_DIR/@CPACK_PACKAGE_FILE_NAME@/.build" &&
  ../bootstrap --parallel=2
  )
}

build()
{
  (
  cd "$TOP_DIR/@CPACK_PACKAGE_FILE_NAME@/.build" &&
  make -j2 &&
  make test
  )
}

clean()
{
  (
  cd "$TOP_DIR/@CPACK_PACKAGE_FILE_NAME@/.build" &&
  make clean
  )
}

pkg()
{
  (
  cd "$TOP_DIR/@CPACK_PACKAGE_FILE_NAME@/.build" &&
  ./bin/cpack &&
  mv @CPACK_PACKAGE_FILE_NAME@-@CPACK_CYGWIN_PATCH_NUMBER@.tar.bz2 "$TOP_DIR"
  )
}

spkg()
{
 (
  cd "$TOP_DIR/@CPACK_PACKAGE_FILE_NAME@/.build" &&
  ./bin/cpack --config  CPackSourceConfig.cmake &&
  mv @CPACK_PACKAGE_FILE_NAME@-@CPACK_CYGWIN_PATCH_NUMBER@-src.tar.bz2 "$TOP_DIR"
  )
}

finish()
{
  (
  rm -rf "@CPACK_PACKAGE_FILE_NAME@"
  )
}

case $1 in
  prep)         prep    ; STATUS=$? ;;
  mkdirs)       mkdirs  ; STATUS=$? ;;
  conf)         conf    ; STATUS=$? ;;
  build)        build   ; STATUS=$? ;;
  clean)        clean   ; STATUS=$? ;;
  package)      pkg     ; STATUS=$? ;;
  pkg)          pkg     ; STATUS=$? ;;
  src-package)  spkg    ; STATUS=$? ;;
  spkg)         spkg    ; STATUS=$? ;;
  finish)       finish  ; STATUS=$? ;;
  all) (
       prep && conf && build && pkg && spkg && finish ;
       STATUS=$?
       ) ;;
  *) echo "Error: bad argument (all or one of these: prep mkdirs conf build clean package pkg src-package spkg finish)" ; exit 1 ;;
esac
exit ${STATUS}