File: build-osx.sh

package info (click to toggle)
librecad 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 106,400 kB
  • sloc: cpp: 188,363; ansic: 3,069; sh: 336; xml: 43; makefile: 24
file content (149 lines) | stat: -rwxr-xr-x 3,653 bytes parent folder | download | duplicates (3)
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
#!/bin/bash -xe

# this script builds LibreCAD in OS/X
# The dependency required to be able to build LibreCAD:
# qt, boost, muparser

# Options
# -p=|--qtpath= : Set's a specific path where to startqmake from example : build-osx.sh -p=/opt/Qt5.2.1/5.2.1/clang_64/bin
# default is set to /opt/local/bin/ for backwards compatibility of this script
#
# -q=|-qmake_opts= : Set's additional qmake options exaomple : -qmake_opts="QMAKE_MAC_SDK=macosx10.9"
# default is set to "-spec mkspec/macports" for backwards compatibility reasons of this script
#
# -no-p|--no-qtpath : Removes the default qtpath, this makes the default search path take over to find qmake
#
# -cert=|-codesign-identity= : Run macdeployqt -codesign=<identity> (requires Qt >= 5.4.0)
# Example: ./build-osx.sh -cert=123456789A
# Use 'security find-identity -v -p codesigning' to get a list of signing identities.
# Example: A000000000000000000000000000000000000001 "Developer ID Application: John Smith (123456789A)"

SCRIPTPATH="$(dirname "$0")"

for i in /opt/local/libexec /usr/local/opt /usr/local
do
    if [ -x "$i/qt5/bin/qmake" ]
    then
        QT_PATH=$i/qt5/bin/
        break
    fi
done
if [ -z "$QT_PATH" ]
then
    echo QT_PATH could not be determined, exiting >&2
    exit 1
fi

echo QT_PATH="$QT_PATH"

QMAKE_OPTS=""
CODESIGN_IDENTITY=""

for i in "$@"
do
case $i in
    -q=*|-qmake_opts=*)
    QMAKE_OPTS="${i#*=}"
    ;;
    -p=*|--qtpath*=)
    QT_PATH="${i#*=}"
    if [[ $QT_PATH ]]
    then
        QT_PATH=${QT_PATH%/}/
    fi
    ;;
    -no-p|--no-qtpath)
    QT_PATH=
    ;;
    -cert=*|-codesign-identity=*)
    CODESIGN_IDENTITY="${i#*=}"
    ;;
    *)
            # unknown option
    ;;
esac
done

#validate QT_PATH
if [[ ! -f ${QT_PATH}qmake ]]
then
	QT_PATH=$(dirname "$(which qmake)")/
	if [[ -z $QT_PATH ]]
	then
		echo "can not locate qmake"
		exit 1
	fi
fi

QMAKE_CMD=${QT_PATH}qmake

# validate QT_VERSION
QT_VERSION=$(${QMAKE_CMD} -query QT_VERSION)
QT_VERSION_ARRAY=( ${QT_VERSION//./ } )
echo "QT_VERSION=${QT_VERSION_ARRAY[0]}.${QT_VERSION_ARRAY[1]}.${QT_VERSION_ARRAY[2]}"

# validate CODESIGN
if [[ $CODESIGN_IDENTITY ]]
then
	if [ "${QT_VERSION_ARRAY[0]}" -lt 5 ]
	then
		echo "macdeployqt -codesign requires QT_VERSION >= 5.4.0"
		exit 1
	else
		if [ "${QT_VERSION_ARRAY[1]}" -lt 4 ]
		then
	                echo "macdeployqt -codesign requires QT_VERSION >= 5.4.0"
			exit 1
		fi
	fi
fi

cd "${SCRIPTPATH}"/..

# have to clean up any existing binary files to avoid crashes of bug#422
rm -rf LibreCAD.app

# Run distclean if a previous version of Makefile exists
if [ -f Makefile ]; then
    $QMAKE_CMD $QMAKE_OPTS -r
    make distclean
fi

rm -rf generated
$QMAKE_CMD $QMAKE_OPTS -r

#undefined symbol x86_64: https://qt-project.org/forums/viewthread/35646
# RVT July 12 2015, this is now controlled with QMAKE_MAC_SDK
#find . -iname makefile -exec sed -i '' \
#	-e 's:mmacosx-version-min=10.[1-9]:mmacosx-version-min=10.8:g' \
#	-e 's:MacOSX10.[1-9].sdk:MacOSX10.8.sdk:g'  \
#	'{}' ';'

#to make it auto, use "make -j"
#hardcoded to 4 jobs, because "make -j" crashes our mac building box
make -j4

APP_FILE=LibreCAD
OUTPUT_DMG=${APP_FILE}.dmg

if [[ $CODESIGN_IDENTITY ]]
then
	${QT_PATH}macdeployqt ${APP_FILE}.app -verbose=2 -dmg -always-overwrite -codesign=$CODESIGN_IDENTITY
else
	${QT_PATH}macdeployqt ${APP_FILE}.app -verbose=2 -dmg -always-overwrite
fi

#bz2 compression
hdiutil convert -format UDBZ -ov -o "$OUTPUT_DMG" "$OUTPUT_DMG"

if [[ -f  "${OUTPUT_DMG}" ]]
then
	echo "DMG installer generated:"
	ls -lh "${OUTPUT_DMG}"
fi

rm -f "${TMP_DMG}"
if [[ $CODESIGN_IDENTITY ]]
then
	codesign -s $CODESIGN_IDENTITY -v $OUTPUT_DMG
fi