Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 18 Nov 2018, 03:53
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
A Script to Wrap all gcc functions w/ CPLUS_INCLUDE_PATH
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [2 Posts]  
Author Message
s243a

Joined: 02 Sep 2014
Posts: 1280

PostPosted: Sun 03 Jun 2018, 03:04    Post subject:  A Script to Wrap all gcc functions w/ CPLUS_INCLUDE_PATH
Subject description: & gcc version
 

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:

#!/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.
Back to top
View user's profile Send private message 
slavvo67

Joined: 12 Oct 2012
Posts: 1570
Location: The other Mr. 305

PostPosted: Thu 05 Jul 2018, 12:16    Post subject:  

Can you throw in your magic script for compiling GCC? Trying to update to the newest version.... Cool
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [2 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0607s ][ Queries: 11 (0.0246s) ][ GZIP on ]