-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_fp_system_library_openjpeg.sh
executable file
·263 lines (210 loc) · 11.1 KB
/
setup_fp_system_library_openjpeg.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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#!/bin/bash -e
#-----------------------------------------------------------------------------------------
# NOTE:
# sudo apt-get install cmake
#-----------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------
# Script information
script_name='FP ENVIRONMENT - SYSTEM LIBRARIES GENERIC - OPENJPEG'
script_version="1.0.0"
script_date='2022/05/18'
# Define library name, archive and repository
library_clean=true
library_name='openjpeg'
library_archive_generic='openjpeg.tar.gz'
library_archive_reference='v2.4.0.tar.gz'
library_archive_address='https://github.com/uclouvain/openjpeg/archive/refs/tags/'
# Define library building root and source path
generic_path_building_destination=$HOME/fp_system_libs_generic
generic_path_building_source=$HOME/fp_system_libs_generic/source
generic_file_env='fp_system_libs_generic_openjpeg'
generic_path_installer_exec=$(pwd)
generic_path_installer_archive=$(pwd)
# Define library deps
library_deps_zlib_main=${generic_path_building_destination}/zlib
library_deps_zlib_include=${generic_path_building_destination}/zlib/include/
# Define library line command
library_cmd_archive_remove_source='rm -rf %LIBRARY_PATH_BUILDING_SOURCE'
library_cmd_archive_remove_destination='rm -rf %LIBRARY_PATH_BUILDING_DESTINATION'
library_cmd_archive_download_local='cp %LIBRARY_ARCHIVE_LINK_LOCAL %LIBRARY_ARCHIVE_BUILDING_SOURCE'
library_cmd_archive_download_remote='wget %LIBRARY_ARCHIVE_LINK_REMOTE -O %LIBRARY_ARCHIVE_BUILDING_SOURCE'
library_cmd_archive_unzip="tar -xvf %LIBRARY_ARCHIVE_BUILDING_SOURCE -C %LIBRARY_PATH_BUILDING_SOURCE --strip-components=1"
library_cmd_archive_configure='cmake . -DZLIB_LIBRARY=%LIBRARY_DEPS_ZLIB_MAIN -DZLIB_INCLUDE_DIR=%LIBRARY_DEPS_ZLIB_INCLUDE -DCMAKE_INSTALL_PREFIX=%LIBRARY_PATH_BUILDING_DESTINATION'
library_cmd_archive_build='make'
library_cmd_archive_install='make install'
# ----------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------
# Info script start
echo " ==================================================================================="
echo " ==> "$script_name" (Version: "$script_version" Release_Date: "$script_date")"
echo " ==> START ..."
# ----------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------
# Info start
echo " ===> BUILDING LIBRARY "${library_name}" ..."
# Create library path for installer executables and archive
if [ ! -d "${generic_path_installer_exec}" ]; then
mkdir -p ${generic_path_installer_exec}
fi
if [ ! -d "${generic_path_installer_archive}" ]; then
mkdir -p ${generic_path_installer_archive}
fi
# Define and create library path for building source and destination
library_path_building_source=${generic_path_building_source}/${library_name}/
library_path_building_destination=${generic_path_building_destination}/${library_name}
if ${library_clean}; then
if [ -d "${library_path_building_source}" ]; then
rm -rf ${library_path_building_source}
fi
if [ -d "${library_path_building_destination}" ]; then
rm -rf ${library_path_building_destination}
fi
fi
if [ ! -d "${library_path_building_source}" ]; then
mkdir -p ${library_path_building_source}
fi
if [ ! -d "${library_path_building_destination}" ]; then
mkdir -p ${library_path_building_destination}
fi
# Define library path bin, include and lib
library_path_bin=${library_path_building_destination}/bin/
library_path_include=${library_path_building_destination}/include/
library_path_lib=${library_path_building_destination}/lib/
# ----------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------
# Check library on local repository
if [ ! -d "${library_path_bin}" -a ! -d "${library_path_lib}" ]; then
# ----------------------------------------------------------------------------------------
# Check archive availability
echo " ====> CHECK ARCHIVE "${library_archive_reference}" ... "
# Define library remote and local link(s)
library_archive_link_remote=${library_archive_address}/${library_archive_reference}
library_archive_link_local=${generic_path_installer_archive}/${library_archive_reference}
if [ -f "$library_archive_link_local" ]; then
library_cmd_archive_download_selected=${library_cmd_archive_download_local}
echo " ====> CHECK ARCHIVE "${library_archive_reference}" ... FOUND IN LOCAL REPOSITORY "
else
library_cmd_archive_download_selected=${library_cmd_archive_download_remote}
echo " ====> CHECK ARCHIVE "${library_archive_reference}" ... NOT FOUND IN LOCAL REPOSITORY. IT WILL SEARCH IN REMOTE REPOSITORY"
fi
# ----------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------
# Download archive source(s)
echo " ====> DOWNLOAD ARCHIVE "${library_archive_reference}" ... "
# Define archive source path and file_name
library_archive_building_source=${library_path_building_source}${library_archive_generic}
# Define download command-line
library_cmd_archive_download_filled=${library_cmd_archive_download_selected/'%LIBRARY_ARCHIVE_LINK_LOCAL'/$library_archive_link_local}
library_cmd_archive_download_filled=${library_cmd_archive_download_filled/'%LIBRARY_ARCHIVE_LINK_REMOTE'/$library_archive_link_remote}
library_cmd_archive_download_filled=${library_cmd_archive_download_filled/'%LIBRARY_ARCHIVE_BUILDING_SOURCE'/$library_archive_building_source}
# Execute command-line
if ! ${library_cmd_archive_download_filled} ; then
# Info tag end (failed)
echo " ====> DOWNLOAD ARCHIVE ... FAILED. ERRORS IN EXECUTING $library_cmd_archive_download_filled COMMAND-LINE"
exit
else
# Info tag end (completed)
echo " ====> DOWNLOAD ARCHIVE ${library_cmd_archive_download_filled} ... DONE"
fi
# ----------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------
# Unzip archive source(s)
echo " ====> UNZIP ARCHIVE "${library_archive_generic}" ... "
# Define archive source path and file_name
library_archive_building_source=${library_path_building_source}${library_archive_generic}
# Define download command-line
library_cmd_archive_unzip=${library_cmd_archive_unzip/'%LIBRARY_ARCHIVE_BUILDING_SOURCE'/$library_archive_building_source}
library_cmd_archive_unzip=${library_cmd_archive_unzip/'%LIBRARY_PATH_BUILDING_SOURCE'/$library_path_building_source}
# Execute command-line
if ! ${library_cmd_archive_unzip} > /dev/null ; then
# Info tag end (failed)
echo " ====> UNZIP ARCHIVE ... FAILED. ERRORS IN EXECUTING $library_cmd_archive_unzip COMMAND-LINE"
exit
else
# Info tag end (completed)
echo " ====> UNZIP ARCHIVE ${library_archive_generic} ... DONE"
fi
# ----------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------
# Configure archive source(s)
echo " ====> CONFIGURE ARCHIVE "${library_archive_generic}" ... "
# Define download command-line
library_cmd_archive_configure=${library_cmd_archive_configure/'%LIBRARY_PATH_BUILDING_DESTINATION'/$library_path_building_destination}
library_cmd_archive_configure=${library_cmd_archive_configure/'%LIBRARY_DEPS_ZLIB_MAIN'/$library_deps_zlib_main}
library_cmd_archive_configure=${library_cmd_archive_configure/'%LIBRARY_DEPS_ZLIB_INCLUDE'/$library_deps_zlib_include}
if [ ! -d "${library_deps_zlib_main}" ]; then
echo " ===> LIBRARY ZLIB NOT FOUND. EXIT"
exit
fi
# Execute command-line
cd $library_path_building_source
if ! ${library_cmd_archive_configure} ; then
# Info tag end (failed)
echo " ====> CONFIGURE ARCHIVE ... FAILED. ERRORS IN EXECUTING $library_cmd_archive_configure COMMAND-LINE"
exit
else
# Info tag end (completed)
echo " ====> CONFIGURE ARCHIVE ${library_cmd_archive_configure} ... DONE"
fi
# ----------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------
# Build archive source(s)
echo " ====> BUILD ARCHIVE "${library_archive_generic}" ... "
# Execute command-line
cd $library_path_building_source
if ! ${library_cmd_archive_build} ; then
# Info tag end (failed)
echo " ====> BUILD ARCHIVE ... FAILED. ERRORS IN EXECUTING $library_cmd_archive_build COMMAND-LINE"
exit
else
# Info tag end (completed)
echo " ====> BUILD ARCHIVE ${library_archive_generic} ... DONE"
fi
# ----------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------
# Install archive source(s)
echo " ====> INSTALL ARCHIVE "${library_archive_generic}" ... "
# Execute command-line
cd $library_path_building_source
if ! ${library_cmd_archive_install} ; then
# Info tag end (failed)
echo " ====> INSTALL ARCHIVE ... FAILED. ERRORS IN EXECUTING $library_cmd_archive_install COMMAND-LINE"
exit
else
# Info tag end (completed)
echo " ====> INSTALL ARCHIVE ${library_archive_generic} ... DONE"
fi
# ----------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------
# Create environmental file
echo " ====> CREATE ENVIRONMENTAL FILE ... "
# Delete old version of environmetal file
cd $generic_path_building_destination
if [ -f $generic_file_env ] ; then
rm $generic_file_env
fi
# Export LIBRARY PATH(S)
echo "LD_LIBRARY_PATH="'$LD_LIBRARY_PATH'":${library_path_lib}" >> $generic_file_env
echo "export LD_LIBRARY_PATH" >> $generic_file_env
# Export BINARY PATH(S)
echo "PATH=${library_path_bin}:"'$PATH'"" >> $generic_file_env
echo "export PATH" >> $generic_file_env
echo " ====> CREATE ENVIRONMENTAL FILE ... DONE"
# ----------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------
# Info end
echo " ===> BUILDING LIBRARY "${library_name}" ... DONE"
# ----------------------------------------------------------------------------------------
else
# ----------------------------------------------------------------------------------------
# Info end
echo " ===> BUILDING LIBRARY "${library_name}" ... SKIPPED. LIBRARY PREVIOUSLY INSTALLED"
# ----------------------------------------------------------------------------------------
fi
# ----------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------
# Info script end
echo " ==> ... END"
echo " ==> Bye, Bye"
echo " ==================================================================================="
# ----------------------------------------------------------------------------------------