Author Topic: How to make a portable CB in linux?  (Read 5388 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
How to make a portable CB in linux?
« 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!

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: How to make a portable CB in linux?
« Reply #1 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...).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to make a portable CB in linux?
« Reply #2 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...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to make a portable CB in linux?
« Reply #3 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.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: How to make a portable CB in linux?
« Reply #4 on: September 21, 2010, 06:07:47 am »
I see, thanks a lot! :D

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to make a portable CB in linux?
« Reply #5 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

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: How to make a portable CB in linux?
« Reply #6 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 $@

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to make a portable CB in linux?
« Reply #7 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.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to make a portable CB in linux?
« Reply #8 on: September 28, 2010, 07:38:50 am »
Committed in svn r6646 .