Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Loaden on September 19, 2010, 02:57:03 am

Title: How to make a portable CB in linux?
Post by: Loaden on September 19, 2010, 02:57:03 am
Hi, all, I am build CB use this bash script:
Quote
./configure --prefix=/usr --with-contrib-plugins=all,-byogames,-Cccc,-cbkoders,-codesnippets,-copystrings,-envvars,-headerfixup,-libfinder,-NassiShneiderman,-exporter
make -j2
sudo make install
read -n1 -p "Press any key to continue..."
After build finished, I wonder how to make a portable CB?
In "make install" step, there have any options for portable?
Like this:
Quote
make install --enable-portable --DESTDIR=~
Thanks!
Title: Re: How to make a portable CB in linux?
Post by: MortenMacFly on September 19, 2010, 08:36:01 pm
In "make install" step, there have any options for portable?
No. The best way to make C::B portable is NOT using automake for the build, but use C::B itself to compile C::B using the unix project file and then running the update script. This will create a run script which you can modify to make C::B "portable" by adjusting the CB_DATA_DIR (don't recall exactly the name of this environment variable atm...).
Title: Re: How to make a portable CB in linux?
Post by: oBFusCATed on September 19, 2010, 09:11:22 pm
Loaden you could use --prefix=/home/loaden/cb, then all files will be placed in that dir, and you can copy them around (not sure if will be portable)...
On linux, too few people care about the 'portable' thing, it is pretty windowsish...
Title: Re: How to make a portable CB in linux?
Post by: Jenna on September 19, 2010, 09:16:16 pm
Loaden you could use --prefix=/home/loaden/cb, then all files will be placed in that dir, and you can copy them around (not sure if will be portable)...
On linux, too few people care about the 'portable' thing, it is pretty windowsish...
On most linux system this will not work, because make install relinks the libraries with full path to avoid name conflicts.
Title: Re: How to make a portable CB in linux?
Post by: Loaden on September 21, 2010, 06:07:47 am
I see, thanks a lot! :D
Title: Re: How to make a portable CB in linux?
Post by: Jenna on September 21, 2010, 08:25:45 am
@Loaden and all other linux users (especially if the shell is not bash):
Can you try this patch for the update-script ?

It should make C::B portable (if it is compile dwith C::B and the directory/file-structure below output or devel is not changed), because it dynamically fetches the APP_DIR variable at runtime, but I did not test it on any other shell.

Code
Index: update
===================================================================
--- update (revision 6620)
+++ update (working copy)
@@ -106,14 +106,14 @@
 if [ "x$MSYSTEM" = "x" ] ; then
   echo Creating launch-scripts
   echo "#!/bin/sh" > output/run.sh
-  echo -n "APP_DIR=" >> output/run.sh
-  echo `pwd`/output >> output/run.sh
+  echo 'APP_DIR=`dirname "$0"`' >> output/run.sh
+  echo 'APP_DIR=`( cd "$APP_DIR" && pwd )`' >> output/run.sh
   echo "export LD_LIBRARY_PATH=\$APP_DIR:\$LD_LIBRARY_PATH" >> output/run.sh
   echo "\$APP_DIR/codeblocks \$@" >> output/run.sh
   chmod +x output/run.sh
   echo "#!/bin/sh" > devel/run.sh
-  echo -n "APP_DIR=" >> devel/run.sh
-  echo `pwd`/devel >> devel/run.sh
+  echo 'APP_DIR=`dirname "$0"`' >> devel/run.sh
+  echo 'APP_DIR=`( cd "$APP_DIR" && pwd )`' >> devel/run.sh
   echo "export LD_LIBRARY_PATH=\$APP_DIR:\$LD_LIBRARY_PATH" >> devel/run.sh
   echo "\$APP_DIR/codeblocks \$@" >> devel/run.sh
   chmod +x devel/run.sh
Title: Re: How to make a portable CB in linux?
Post by: Loaden on September 21, 2010, 11:55:38 am
@Loaden and all other linux users (especially if the shell is not bash):
Can you try this patch for the update-script ?
Works well! :)
Here is the run.sh content.
Quote
#!/bin/sh
APP_DIR=`dirname "$0"`
APP_DIR=`( cd "$APP_DIR" && pwd )`
export LD_LIBRARY_PATH=$APP_DIR:$LD_LIBRARY_PATH
$APP_DIR/codeblocks $@
Title: Re: How to make a portable CB in linux?
Post by: Jenna on September 23, 2010, 11:31:28 am
@Loaden and all other linux users (especially if the shell is not bash):
Can you try this patch for the update-script ?
Works well! :)

Thanks for testing.

Did anyone else test it ?
Especially if you do not have bash as default-shell ?

Any feedback is welcome !!
If there are no objection during the next days, I will commit the change to trunk.
Title: Re: How to make a portable CB in linux?
Post by: Jenna on September 28, 2010, 07:38:50 am
Committed in svn r6646 .