#!/bin/sh # This file is a part of Julia. License is MIT: https://julialang.org/license # Run as: fixup-libstdc++.sh if test -z $1 { echo "Usage: $0 " exit 1 } global libdir := $1 global private_libdir := $2 if test ! -f "$libdir/libjulia.so" { echo "ERROR: Could not open $libdir/libjulia.so" > !2 exit 2 } proc find_shlib { if test -f $1 { ldd $1 | grep $2 | cut -d' ' -f3 | xargs } } # Discover libstdc++ location and name global LIBSTD := $[find_shlib "$libdir/libjulia.so" "libstdc++.so] global LIBSTD_NAME := $[basename $LIBSTD] global LIBSTD_DIR := $[dirname $LIBSTD] if test ! -f "$private_libdir/$LIBSTD_NAME" && test -f "$LIBSTD_DIR/$LIBSTD_NAME" { cp -v "$LIBSTD_DIR/$LIBSTD_NAME" $private_libdir chmod 755 "$private_libdir/$LIBSTD_NAME" } (CommandList children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-z)} {(DQ ($ VSub_Number "$1"))} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(echo)} {(DQ ("Usage: ") ($ VSub_Number "$0") (" "))}) (C {(exit)} {(1)}) ] spids: [-1 24] ) ] spids: [-1 40] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:libdir) op: Equal rhs: {(DQ ($ VSub_Number "$1"))} spids: [43] ) ] spids: [43] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:private_libdir) op: Equal rhs: {(DQ ($ VSub_Number "$2"))} spids: [48] ) ] spids: [48] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-f)} {(DQ ($ VSub_Name "$libdir") (/libjulia.so))} {(Lit_Other "]")} ) terminator: ) ] action: [ (SimpleCommand words: [{(echo)} {(DQ ("ERROR: Could not open ") ($ VSub_Name "$libdir") (/libjulia.so))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[81])] ) (C {(exit)} {(2)}) ] spids: [-1 70] ) ] spids: [-1 89] ) (FuncDef name: find_shlib body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-f)} {(DQ ($ VSub_Number "$1"))} {(Lit_Other "]")}) terminator: ) ] action: [ (Pipeline children: [ (C {(ldd)} {(DQ ($ VSub_Number "$1"))}) (C {(grep)} {($ VSub_Number "$2")}) (C {(cut)} {(-d) (SQ <" ">)} {(-f3)}) (C {(xargs)}) ] negated: False ) ] spids: [-1 113] ) ] spids: [-1 144] ) ] spids: [97] ) spids: [92 96] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LIBSTD) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(find_shlib)} {(DQ ($ VSub_Name "$libdir") (/libjulia.so))} {(DQ ("libstdc++.so"))} ) ] ) left_token: spids: [153 164] ) } spids: [152] ) ] spids: [152] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LIBSTD_NAME) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(basename)} {($ VSub_Name "$LIBSTD")})]) left_token: spids: [167 171] ) } spids: [166] ) ] spids: [166] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LIBSTD_DIR) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(dirname)} {($ VSub_Name "$LIBSTD")})]) left_token: spids: [174 178] ) } spids: [173] ) ] spids: [173] ) (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (C {(Lit_Other "[")} {(KW_Bang "!")} {(-f)} {(DQ ($ VSub_Name "$private_libdir") (/) ($ VSub_Name "$LIBSTD_NAME"))} {(Lit_Other "]")} ) (C {(Lit_Other "[")} {(-f)} {(DQ ($ VSub_Name "$LIBSTD_DIR") (/) ($ VSub_Name "$LIBSTD_NAME"))} {(Lit_Other "]")} ) ] op_id: Op_DAmp ) terminator: ) ] action: [ (C {(cp)} {(-v)} {(DQ ($ VSub_Name "$LIBSTD_DIR") (/) ($ VSub_Name "$LIBSTD_NAME"))} {(DQ ($ VSub_Name "$private_libdir"))} ) (C {(chmod)} {(755)} {(DQ ($ VSub_Name "$private_libdir") (/) ($ VSub_Name "$LIBSTD_NAME"))}) ] spids: [-1 212] ) ] spids: [-1 240] ) ] )