aboutsummaryrefslogtreecommitdiff
path: root/project/setup/cygwin-copy.sh
blob: 6e47c33519e40eefa4a2ac7923f335d429e55277 (plain) (blame)
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
#!/usr/bin/env bash

    #####################################################################
    ##                    _______ _______ _______                      ##
    ##                   |  ___  |____   |  ___  |                     ##
    ##                   | |   |_|    / /| |   |_|                     ##
    ##                   | |_____    / / | |_____                      ##
    ##                   |_____  |  / /  |_____  |                     ##
    ##                    _    | | / /    _    | |                     ##
    ##                   | |___| |/ /____| |___| |                     ##
    ##                   |_______|_______|_______|                     ##
    ##                                                                 ##
    ##                        Wiimms SZS Tools                         ##
    ##                      http://szs.wiimm.de/                       ##
    ##                                                                 ##
    #####################################################################
    ##                                                                 ##
    ##   This file is part of the SZS project.                         ##
    ##   Visit http://szs.wiimm.de/ for project details and sources.   ##
    ##                                                                 ##
    ##   Copyright (c) 2011-2019 by Dirk Clemens <wiimm@wiimm.de>      ##
    ##                                                                 ##
    #####################################################################

#------------------------------------------------------------------------------
# setup

CYGWIN_DIR="@@CYGWIN-DIR@@"
CYGWIN_TOOLS="@@CYGWIN-TOOLS@@"
BIN_FILES="@@BIN-FILES@@"
DISTRIB_PATH="@@DISTRIB-PATH@@"

BIN_PATH="$DISTRIB_PATH/bin"
mkdir -p "$BIN_PATH" || exit 1

#------------------------------------------------------------------------------
# copy cygwin tools

for tool in $CYGWIN_TOOLS
do
    cp --preserve=time "$CYGWIN_DIR/$tool.exe" "$BIN_PATH" || exit 1
done

#------------------------------------------------------------------------------
# copy wit tools

for tool in $BIN_FILES
do
    if [[ -s ./$tool.exe ]]
    then
	CYGWIN_TOOLS="$CYGWIN_TOOLS $tool"
	ln -f ./$tool.exe "$BIN_PATH" || exit 1
    fi
done

#------------------------------------------------------------------------------
# copy needed cygwin dlls

CYGCHECK="$( which cygcheck 2>/dev/null )"

for tool in $CYGWIN_TOOLS
do
    if [[ $CYGCHECK ]]
    then
	"$CYGCHECK" "$BIN_PATH/$tool.exe" \
		| grep -E 'cygwin.*\\bin\\.*\.dll' \
		| sed 's/.*\\//'
    else
	ldd "$BIN_PATH/$tool.exe" | grep -F "=> $CYGWIN_DIR/" | awk '{print $1}'
    fi
done | sort | uniq | while read dll
do
    cp --preserve=time "$CYGWIN_DIR/$dll" "$BIN_PATH" || exit 1
done

#------------------------------------------------------------------------------
# done

exit 0