OESF Portables Forum

Model Specific Forums => Sharp Zaurus => Zaurus - pdaXrom => Topic started by: VirtusRex on June 21, 2007, 10:26:41 am

Title: Compile Package Help!
Post by: VirtusRex on June 21, 2007, 10:26:41 am
Hello all,

I’ve want to start compiling packages I see on the net, but I’m not sure where to begin. Basically, I want to take taz.gz file and create a package from it.

For example, I’m trying to create a custom security suite of applications for my zaurus C1000 running PDAXii13 5.4.6., so far I’m trying to compile dsniff.tar.gz.

Basically, where do I begin???

Thanks in advance,

VirtusRex
Title: Compile Package Help!
Post by: Capn_Fish on June 21, 2007, 11:00:28 am
Here's some instructions I typed up on how to compile stuff:

1. Download the zgcc image from the pdaXrom dowloads page (distro.ibiblio.org/pub/linux/distributions/pdaxrom/download/VERSION/C7x0-c860/zgcc-3.4.x.img) and put it somewhere that your Z can access (SD, CF, or NAND).

2. Make the directorys /opt/native/arm/3.4.x-xscale-softvfp (mkdir -p /opt/native/arm/3.4.x-xscale-softvfp) where x is the number in the zgcc image name.

3. Mount the image (mount -o loop /path/to/zgcc-3.4.x.img /opt/native/arm/3.4.x-xscale-softvfp). If you are using r121 or above, you need to add the "-t squashfs" option after "-o loop," but I get the impression you're using beta 1 or 3.

4. Install pcre and libiconv. If you already have them installed, reinstall them. It will probably complain about having them missing.

5. See if GCC is found. Type GCC in the terminal. If it says "gcc: no input files," it's working.

6. Download some source code to compile (usually a .tar.gz or .tar.bz2 extention, but sometimes .zip). Make sure to decompress it to a Linux filesystem (ext2 or ext3). Look in the source folder for a file called "configure" or "autogen.sh." If either of them exists, you're good to go. If only a Makefile exists, it should work, but I have had some issue.

6. cd to the source directory (cd /path/to/source-x.x.x)

7. If there is no "configure" file, but there is an "autogen.sh" file, do a "./autogen.sh," which should create a "configure file" go to step 9.

8. If there is no configure or autogen.sh file, look for a file called "Makefile." If that exists, go to step 10.

9. Configue the build. Type "CFLAGS=" -O2 -mtune=xscale -mcpu=xscale" CXXFLAGS="-O2 -mtune=xscale -mcpu=xscale" ./conigure --prefix=/usr --help" That will bring up a list of options that you can use to configurewhat will be built into the app. The FLAGS before executing configure turn on optimizations. The --prefix=/usr means that stuff will go in /usr instead of /usr/local, which can be helpful for libs and just makes things easier. Redo the configure without --help and with the options you want.

10. Type 'make' to build the app. Wait a long time. If it crashes, look at the top of the error messages...It'll probably say missing something, in which case you need to install/build and install a lib.

11. Install the app. Do a "grep DESTDIR Makefile." if that returns anything, you're good. If it is a gnu app and doesn't return anything, your still good. Other stuff, be wary. That means (to me at least) that you'll have to dig through your /usr dir for all of the files it installed. I will assume that you can use this option.

Do a "make DESTDIR=/a/temp/place/to/install/it/Data/ install".    This installs the app with /a/temp/... as the root so you can package it up. You'll see why data is there later.

12. Go to .../Data/usr and go into lib and bin, in each doing a "strip *" which will make the package smaller. You can remove docs and man pages if you so desire. I keed the include directory because it doesn't take up a lot of space and is helpful for compiling some apps in the future.

13. Go back to the .../Data directory and do a "tar -czf ../data.tar.gz ./*", which puts everything from the package into a file called data.tar.gz in the next folder up. Go to that dir (cd ../) and make another folder called Control. Go into it (cd Control) and make a file called control (<favorite editor> control). Make the file in this format:

Package: <packagename>
Version: <version>
Architecture: armv5tel
Maintainer: <yournamehere>
Description: <description>

Save it, then do a "tar -czf ../control.tar.gz ./*". go into the previous direcotry (cd ../) and make another file called debian-binary (<editor> debian-binary). Type "2.0" no quotes on the first line and save it. You are now ready to make a package.

14. Make the package. Do a "tar -czf packagename_version_armv5tel.ipk ./data.tar.gz ./control.tar.gz ./debian-binary" and you have an installable ipk. Note that the package name and version must match the ones in the control file or else it won't uninstall correctly (it will install fine, though) (I think).


Note that you should have swap when compiling to avoid running out of RAM.

Hope that helps.
Title: Compile Package Help!
Post by: VirtusRex on June 21, 2007, 12:05:03 pm
Thanks, but I noticed that it's for C7x0-c860, is this ok for my C1000?
Title: Compile Package Help!
Post by: Capn_Fish on June 21, 2007, 12:49:03 pm
The zgcc image? Yes. It only appears in the C7x0-C860 section for some reason, though.
Title: Compile Package Help!
Post by: Meanie on June 21, 2007, 07:39:42 pm
Quote
Thanks, but I noticed that it's for C7x0-c860, is this ok for my C1000?
[div align=\"right\"][a href=\"index.php?act=findpost&pid=163496\"][{POST_SNAPBACK}][/a][/div]

a slightly easier route would be to use my zgcc image (zgcc-3.4.6.squashfs) and simply place it under /home/root, or put it anywhere you want and symlink it to /home/root
this will automatically create the mount directory and mount the file for you at each boot, but of course you can mount it manually as well as described by capn fish.

you can extract the source package to a ext2/ext3 filesystem as capn fish said and run autogen.sh or configure. if there already is a configure file, you can just run zconfigure or zconfigure-optimized why which preset some of the variables for you followed by make

then you can do a newipk packagename, ie

cd /build/ipks/
newipk mynewpackage
cd -
make DESTDIR=/build/ipks/mynewpackage/data

this will create a new package structure for you under /build/ipks/mynewpackage

then edit /build/ipks/mynewpackage/control/control and put in relevant information like mainainer and version number, etc..

then generate the package
cd /build/ipks
makeipk mynewpackage
and voila

some make processes don't automatically strip the resulting binaries, some do, so to be sure, just do a strip on all the generated binaries under .../mynewpackage/data/... before you run makeipk
Title: Compile Package Help!
Post by: VirtusRex on June 22, 2007, 02:54:14 pm
thanks guys, that helped a lot. I managed to compile and install libnet!

VirtusRex
Title: Compile Package Help!
Post by: louigi600 on June 23, 2007, 07:34:51 am
If you have a normal PC running linux you could also use that with a cross compile toolchain ... generally a normal PC will perform much better that a Z for compiling.
Unless you have a really old Pentium II machine relatively modern computers have something close to an order of magnitude grater resources in all directions:
                        Z                             PC
RAM            64Mb                         512Mb and above is quite common
CPU Clock 400Mhz                     4Ghz processors ane now avalible
STORAGE   at most 16Gb CF   750Gb SATA HDU are now avalible
                     but only 128Mb
                     onboard*

* The 16Gb CF costs as much as (if not more then) a 500Gb SATA HDU but performs more or less as fast as a 250Mb PIOMODE II IDE HDU + when you plug it in the Z will be usless for about 2 minutes .

Also IO performance of the PC periferals is buch better that IO performance on the Z.
 
Even if your PC is not the most modern avalibleyou will still get very much better compile performance on a 1Ghz Celeron with 256Mb Ram and 40Gb pATA HDU.