A Script to Wrap all gcc functions w/ CPLUS_INCLUDE_PATH

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

A Script to Wrap all gcc functions w/ CPLUS_INCLUDE_PATH

#1 Post by s243a »

So I wanted to use the latest gcc on TazPup and every function (e.g. c++ and gcc) had a -63 suffix at the end of it. I thought it might be good to link gcc to gcc-63 and then I though, while maybe instead I should great a wrapper function called gcc which exports the necessary environmental variables (we could also add compiler options).

So the script can do either depending on if you set the variable "METHOD" to either wrap or link. I think I might want a third option where it will export the environmental variables if they aren't already set.

Anyway, I really don't know if any of this is a good Idea but here is my script

Code: Select all

#!/bin/bash
export SUFF='-63'
export METHOD='wrap'  
 read -r -d '' HDR <<'EOF'
#!/bin/bash
#CPATH=
export C_INCLUDE_PATH='/usr/libgcc63/gcc/i486-slitaz-linux/6.3.0/include'
export CPLUS_INCLUDE_PATH='/usr/include/c++/6.3.0'
#OBJC_INCLUDE_PATH
EOF
echo "HDR=$HDR"
D='$' #I can't get the dollar sign end of line terminator to work with sed no matter what I do!
for line in `cat /var/lib/tazpkg/installed/gcc63/files.list`; do #'/usr/bin/c++-63'; do #
  read -r -d '' SED_EXP <<EOF
s/^\(.*\)\($SUFF\)/a='\1'; b='\2'/p 
EOF
echo "SED_EXP=$SED_EXP" 
export SED_EXP #Not sure if this is necessary
  echo "line=$line"
  export line #Not sure if this is necessary
  echo "$line2"
  EXP=$( echo "$line" | sed -n "$SED_EXP")
  echo "EXP=$EXP"
  eval "$EXP"
  if [ -n "$b" ]; then
    DNAME="$( dirname $a)"; echo "DNAME=$DNAME"
    cd "$DNAME"
    LNAME="$( basename $a )"
    echo "LNAME=$LNAME"
    ONAME="$LNAME"-63
    echo "ONAME=$ONAME";
    case $METHOD in 
        'wrap')
           echo "$HDR" > "$LNAME"; echo "$ONAME "'$@'>>"$LNAME"; chmod 773 "$LNAME"; ;;
        'link')
           ln -s "$ONAME" "$LNAME"; ;;
    esac  
    #exit
  fi
done
https://pastebin.com/hACMDaia

The biggest headache was getting sed to do the write thing, and I still can't get the '$' symbol to match the end of the line, so I guess this is a potential bug in my script. Fortunately none of the paths I'm applying it to have -63 in the middle so the bug hasn't caused me problems yet.

I'm thinking that I'll try it with perl instead of sed due to not being able to match the end of the line with sed.

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#2 Post by slavvo67 »

Can you throw in your magic script for compiling GCC? Trying to update to the newest version.... 8)

Post Reply