@@ -246,20 +246,37 @@ function run_package_std() {
246
246
cp " $rel_dir /" * .a " $lib_dir " 2> /dev/null || log " $rel_dir does not contain *.a files"
247
247
# Create an SO file from the copied a file
248
248
log " Creating a shared library from the compiled static library"
249
- log " Running : $cc --shared -L$lib_dir \
250
- -Wl,--whole-archive -liec61131std \
251
- -o $lib_dir /out.so -Wl,--no-whole-archive \
252
- -lm \
253
- -fuse-ld=lld \
254
- --target=$val "
255
- $cc --shared -L" $lib_dir " \
256
- -Wl,--whole-archive -liec61131std \
257
- -o " $lib_dir /out.so" -Wl,--no-whole-archive \
258
- -lm \
259
- -fuse-ld=lld \
260
- --target=" $val "
261
-
262
- mv " $lib_dir /out.so" " $lib_dir /libiec61131std.so"
249
+ # Check if we're on macOS and adjust linker flags accordingly
250
+ unameOut=" $( uname -s) "
251
+ case " ${unameOut} " in
252
+ Darwin* )
253
+ log " Running : $cc --shared -L$lib_dir \
254
+ -Wl,-force_load,$lib_dir /libiec61131std.a \
255
+ -o $lib_dir /libiec61131std.so \
256
+ -lm -framework CoreFoundation \
257
+ --target=$val "
258
+ $cc --shared -L" $lib_dir " \
259
+ -Wl,-force_load," $lib_dir /libiec61131std.a" \
260
+ -o " $lib_dir /libiec61131std.so" \
261
+ -lm -framework CoreFoundation \
262
+ --target=" $val "
263
+ ;;
264
+ * )
265
+ log " Running : $cc --shared -L$lib_dir \
266
+ -Wl,--whole-archive -liec61131std \
267
+ -o $lib_dir /libiec61131std.so -Wl,--no-whole-archive \
268
+ -lm \
269
+ -fuse-ld=lld \
270
+ --target=$val "
271
+ $cc --shared -L" $lib_dir " \
272
+ -Wl,--whole-archive -liec61131std \
273
+ -o " $lib_dir /libiec61131std.so" -Wl,--no-whole-archive \
274
+ -lm \
275
+ -fuse-ld=lld \
276
+ --target=" $val "
277
+ ;;
278
+ esac
279
+
263
280
done
264
281
else
265
282
lib_dir=$OUTPUT_DIR /lib
@@ -272,21 +289,36 @@ function run_package_std() {
272
289
cp " $rel_dir /" * .a " $lib_dir " 2> /dev/null || log " $rel_dir does not contain *.a files"
273
290
# Create an SO file from the copied a file
274
291
log " Creating a shared library from the compiled static library"
275
- log " Running : $cc --shared -L" $lib_dir " \
276
- -Wl,--whole-archive -liec61131std \
277
- -o " $lib_dir /out.so" -Wl,--no-whole-archive \
278
- -lm \
279
- -fuse-ld=lld "
280
- $cc --shared -L" $lib_dir " \
281
- -Wl,--whole-archive -liec61131std \
282
- -o " $lib_dir /out.so" -Wl,--no-whole-archive \
283
- -lm \
284
- -fuse-ld=lld
285
- mv " $lib_dir /out.so" " $lib_dir /libiec61131std.so"
292
+ # Check if we're on macOS and adjust linker flags accordingly
293
+ unameOut=" $( uname -s) "
294
+ case " ${unameOut} " in
295
+ Darwin* )
296
+ log " Running : $cc --shared -L" $lib_dir " \
297
+ -Wl,-force_load,$lib_dir /libiec61131std.a \
298
+ -o " $lib_dir /libiec61131std.so" \
299
+ -lm -framework CoreFoundation"
300
+ $cc --shared -L" $lib_dir " \
301
+ -Wl,-force_load," $lib_dir /libiec61131std.a" \
302
+ -o " $lib_dir /libiec61131std.so" \
303
+ -lm -framework CoreFoundation
304
+ ;;
305
+ * )
306
+ log " Running : $cc --shared -L" $lib_dir " \
307
+ -Wl,--whole-archive -liec61131std \
308
+ -o " $lib_dir /libiec61131std.so" -Wl,--no-whole-archive \
309
+ -lm \
310
+ -fuse-ld=lld "
311
+ $cc --shared -L" $lib_dir " \
312
+ -Wl,--whole-archive -liec61131std \
313
+ -o " $lib_dir /libiec61131std.so" -Wl,--no-whole-archive \
314
+ -lm \
315
+ -fuse-ld=lld
316
+ ;;
317
+ esac
286
318
fi
287
319
288
320
log " Enabling read/write on the output folder"
289
- chmod a+rw $OUTPUT_DIR -R
321
+ chmod -R a+rw $OUTPUT_DIR
290
322
291
323
}
292
324
506
538
507
539
if [[ -d $project_location /target/ ]]; then
508
540
log " Allow access to target folders"
509
- chmod a+rw -R $project_location /target/
541
+ chmod -R a+rw $project_location /target/
510
542
fi
511
543
512
544
if [[ $offline -ne 0 ]]; then
0 commit comments