forked from w1hkj/fldigi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetupmxe64.sh
executable file
·214 lines (170 loc) · 5.86 KB
/
setupmxe64.sh
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
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
#!/bin/bash
export MXE_DIR=$HOME/.fldigiMXE
# ======================================================================
# script support functions
function MXEBuildFail
{
echo -e "\nERROR: MXE Package failed to build. Aborting installation.\n\n"
HALT
}
# Completely stops the script and all subshells/processes
function HALT
{
kill -10 $MYPID
}
# Detect the running OS, set a global variable with Linux distribution-name
function DetectOS
{
OS_detected="-1"
cat /etc/redhat-release | grep -i fedora > /dev/null
if [[ $? -eq 0 ]]; then
OS_detected="fedora"
return
fi
cat /etc/os-release | grep -i mint > /dev/null # must come before debian and ubuntu
if [[ $? -eq 0 ]]; then
OS_detected="mint"
return
fi
cat /etc/os-release | grep -i ubuntu > /dev/null # must come before debian
if [[ $? -eq 0 ]]; then
OS_detected="ubuntu"
return
fi
cat /etc/os-release | grep -i debian > /dev/null # this also detects MX Linux
if [[ $? -eq 0 ]]; then
OS_detected="debian"
return
fi
cat /etc/os-release | grep -i opensuse > /dev/null
if [[ $? -eq 0 ]]; then
OS_detected="opensuse"
return
fi
if [ $OS_detected -eq "-1" ]; then
echo -e "\nERROR: OS detection failed. Aborting\n"
exit 1
else
echo -e "\nOS Detected: $OS_detected\n"
return
fi
exit 100 # Should never get here
}
function AmRoot
{
if [ "$EUID" -ne 0 ]; then
echo -e "\nERROR: Package installation must be done as the ROOT user. \n"
exit 1
fi
}
function PKGInstallDebian
{
# This block also used for MX Linux
apt -y build-dep fldigi || exit 1 # install Fldigi build dependencies
apt -y install openssl make autoconf git gperf libgdk-pixbuf2.0-dev libtool libtool-bin libssl-dev p7zip nsis bison flex ruby libgettextpo-dev intltool patch lzip python || exit 1
}
function PKGInstallFedora
{
dnf -y builddep fldigi || exit 1 # install Fldigi build dependencies
dnf -y install openssl openssl-static yum-utils make autoconf git gperf gdk-pixbuf2-devel libtool p7zip nsis bison flex ruby gettext-devel intltool patch lzip python2 || exit 1
}
function PKGInstallMint
{
apt build-dep -y fldigi || exit 1 # install Fldigi build dependencies
apt install -y openssl make autoconf git gperf libgdk-pixbuf2.0-dev libtool libtool-bin p7zip nsis bison flex ruby libgettextpo-dev intltool patch lzip python || exit 1
}
function PKGInstallOpenSuse
{
zypper -n si -d fldigi || exit 1 # install Fldigi build dependencies
zypper -n install openssl libopenssl-devel make autoconf git gperf gdk-pixbuf-devel libtool p7zip bison flex ruby tinygettext-devel intltool patch lzip python || exit 1
echo -e "\n\nWARNING: Package nsis missing on OpenSuse. Cannot create Windows Installer.\n\n"
}
function PKGInstallUbuntu
{
apt -y build-dep fldigi || exit 1 # install Fldigi build dependencies
apt -y install openssl make autoconf git gperf libgdk-pixbuf2.0-dev libtool libtool-bin libssl-dev p7zip nsis bison flex ruby libgettextpo-dev intltool patch lzip python || exit 1
}
function MXEDownload
{
mkdir $MXE_DIRECTORY || exit 1
cd $MXE_DIRECTORY || exit 1
git clone https://github.com/mxe/mxe.git mxe || exit 1
# Checkout and install a specific MXE revision
if $do_checkout ; then
cd mxe || exit 1
git checkout $GITHASH || exit 1
cd ..
fi
# Log the current Git-Revision hash for debugging
cd mxe
git rev-parse HEAD > ../HEAD.log
}
function InstallOSPackages
{
DetectOS
echo -e "\nInstalling required OS packages for: $OS_detected \n"
case "$OS_detected" in
"debian")
PKGInstallDebian
;;
"fedora")
PKGInstallFedora
;;
"mint")
PKGInstallMint
;;
"opensuse")
PKGInstallOpenSuse
;;
"ubuntu")
PKGInstallUbuntu
;;
*)
exit 1
esac
echo -e "\nAll $OS_detected OS packages successfully installed\n"
}
# Check if the MXE directory already exists, and exit if it does
function CheckDirectoryMXE
{
if [ -d $MXE_DIRECTORY ]; then
echo -e "\nERROR: MXE directory already exists\nTo remove run: # setupmxe.sh clean\n"
exit 1
fi
}
# ======================================================================
echo -e "\nInstalling 64-bit MXE crossbuild sub-environment in $MXE_DIR \n"
#CheckDirectoryMXE # If an MXE directory already exists, display message and exit
#MXEDownload
#MXEInstall64
cd $MXE_DIR || exit 1
cd mxe || exit 1
MXE_64="MXE_TARGETS=x86_64-w64-mingw32.static" # 64-bit libraries
# Compatible with all X86_64 processors
CFLAGS=" -march=x86-64 -mtune=k8 -O2 -ffast-math -mno-3dnow -mmmx -msse -msse2 -mfpmath=sse "
CXXFLAGS=" -march=x86-64 -mtune=k8 -O2 -ffast-math -mno-3dnow -mmmx -msse -msse2 -mfpmath=sse "
export MXE_64
export CFLAGS
export CXXFLAGS
echo -e "\nStarting compile of MXE 64-bit cross-compile environment"
echo "Settings:"
echo -e "\t$MXE_DIR"
echo -e "\t$MXE_64"
echo -e "\tCFLAGS=$CFLAGS"
echo -e "\tCXXFLAGS=$CXXFLAGS\n\n"
# NOTE: The order these are compiled in matters
make -j 4 $MXE_64 cc | tee $MXE_DIR/cc.64.log || MXEBuildFail
make -j 4 $MXE_64 zlib | tee $MXE_DIR/zlib.64.log || MXEBuildFail
make -j 4 $MKE_64 libpng | tee $MXE_DIR/libpng.64.log || MXEBuildFail
make -j 4 $MKE_64 pthreads | tee $MXE_DIR/pthreads.64.log || MXEBuildFail
make -j 4 $MKE_64 pcre | tee $MXE_DIR/pcre.64.log || MXEBuildFail
make -j 4 $MKE_64 gnutls | tee $MXE_DIR/gnutls.64.log || MXEBuildFail
make -j 4 $MKE_64 portaudio | tee $MXE_DIR/portaudio.64.log || MXEBuildFail
make -j 4 $MKE_64 libsndfile | tee $MXE_DIR/libsndfile.64.log || MXEBuildFail
make -j 4 $MKE_64 libsamplerate | tee $MXE_DIR/libsamplerate.64.log || MXEBuildFail
make -j 4 $MKE_64 hamlib | tee $MXE_DIR/hamlib.64.log || MXEBuildFail
make -j 4 $MKE_64 fltk | tee $MXE_DIR/fltk.64.log || MXEBuildFail
make -j 4 $MKE_64 libgnurx | tee $MXE_DIR/libgnurx.64.log || MXEBuildFail
date > $MXE_DIR/DATE.64.log # log the date/time MXE finished setup
echo -e "\nMXE 64-bit cross-compile environment successfully setup"
echo -e "MXE windows 64-bit crossbuild environment installed in $MXE_DIR \n\n"