MokoMakefile/it

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(MokoMakefile)
(Before you begin)
Line 7: Line 7:
 
MokoMakefile è sviluppato da [[User:RodWhitby|Rod Whitby]] - non è un prodotto ufficiale OpenMoko (anche se sarebbe una buona cosa sfruttarlo per uso interno). Se ci sono delle discrepanze tra le [[Building_OpenMoko_from_scratch/it|istruzioni ufficiali compilazione OpenMoko]] e le operazioni di MokoMakefile, vanno considerate corrette le istruzioni ufficiali.
 
MokoMakefile è sviluppato da [[User:RodWhitby|Rod Whitby]] - non è un prodotto ufficiale OpenMoko (anche se sarebbe una buona cosa sfruttarlo per uso interno). Se ci sono delle discrepanze tra le [[Building_OpenMoko_from_scratch/it|istruzioni ufficiali compilazione OpenMoko]] e le operazioni di MokoMakefile, vanno considerate corrette le istruzioni ufficiali.
  
=== Before you begin ===
+
=== Prima di iniziare ===
'''Check that your /bin/sh (ls -l /bin/sh) is not linked to dash rather than bash.''' Using dash will cause you pain. This is true for a standard install of Ubuntu 7.04 (at least when installing from Live CD). If your /bin/sh points to /bin/dash, correct it with (as root):
+
'''Controlla che /bin/sh (ls -l /bin/sh) non sia linkato ad altro che a bash.''' L'utilizzo di dash potrebbe causare problemi, soprattutto per le installazioni standard di Ubuntu 7.04 (almeno quando installato da Live CD). Se /bin/sh punta a /bin/dash, correggilo (da root):
 
  ln -sf /bin/bash /bin/sh
 
  ln -sf /bin/bash /bin/sh
  
If you have previously built with dash as your sh shell then your perl compile is probably broken. One symptom is that the build will error and whine about an 'Unterminated quote string' another symptom is a message that says 'You haven't done a "make depend" yet!' If you get these then you need to:
+
Se hai già compilato tramite dash come shell, è probabile che la compilazione perl sia corrotta. Un sintomo è che la compilazione termina con un errore 'Unterminated quote string', oppure con 'You haven't done a "make depend" yet!'. Se si ottengono questi errori, eseguire:
 
  make clean-package-perl
 
  make clean-package-perl
 
  make clean-package-perl-native
 
  make clean-package-perl-native
and rebuild.
+
e ricompilare.
+
 
If all else fails then just rm -rf the perl work dir and the perl stamps here's an i686 host example:
+
Se qualcos'altro va storto, semplicemente rimuovere (rm -rf) le directory work e stamps di perl:
 
  rm -rf build/tmp/work/i686-linux/perl-native-5.8.7-r3  
 
  rm -rf build/tmp/work/i686-linux/perl-native-5.8.7-r3  
 
  rm -f  build/tmp/stamps/i686-linux/perl*
 
  rm -f  build/tmp/stamps/i686-linux/perl*
  
As of r99, MokoMakefile has patches which should make it build correctly with dash.
+
MokoMakefile ha delle patch che potrebbero essere compilate correttamente da dash.
  
 
=== Installation ===
 
=== Installation ===

Revision as of 16:20, 13 July 2007

Contents

MokoMakefile

MokoMakefile è un metodo completamente automatizzato per la configurazione dell'ambiente di sviluppo OpenMoko, uno strumento inestimabile che aiuta i nuovi sviluppatori ad ottenere un ambiente con le stesse configurazioni di quelli già presenti. Permette di ottenere la stessa ripetibilità nella compilazione e manutenzione dell'ambiente che OpenEmbedded introduce nell'attuale software embedded.

Nota che MokoMakefile *non* sostituisce bitbake, svn, monotone, openembedded, qmake e null'altro. Costituisce un wrapper attorno ad essi che facilita la configurazione e la manutenzione di un ambiente di sviluppo che rispecchia le istruzioni pubblicate da OpenMoko. MokoMakefile necessita circa 7 GB di spazio disponibile.

MokoMakefile è sviluppato da Rod Whitby - non è un prodotto ufficiale OpenMoko (anche se sarebbe una buona cosa sfruttarlo per uso interno). Se ci sono delle discrepanze tra le istruzioni ufficiali compilazione OpenMoko e le operazioni di MokoMakefile, vanno considerate corrette le istruzioni ufficiali.

Prima di iniziare

Controlla che /bin/sh (ls -l /bin/sh) non sia linkato ad altro che a bash. L'utilizzo di dash potrebbe causare problemi, soprattutto per le installazioni standard di Ubuntu 7.04 (almeno quando installato da Live CD). Se /bin/sh punta a /bin/dash, correggilo (da root):

ln -sf /bin/bash /bin/sh

Se hai già compilato tramite dash come shell, è probabile che la compilazione perl sia corrotta. Un sintomo è che la compilazione termina con un errore 'Unterminated quote string', oppure con 'You haven't done a "make depend" yet!'. Se si ottengono questi errori, eseguire:

make clean-package-perl
make clean-package-perl-native

e ricompilare.

Se qualcos'altro va storto, semplicemente rimuovere (rm -rf) le directory work e stamps di perl:

rm -rf build/tmp/work/i686-linux/perl-native-5.8.7-r3 
rm -f  build/tmp/stamps/i686-linux/perl*

MokoMakefile ha delle patch che potrebbero essere compilate correttamente da dash.

Installation

Here are the steps to use it:

1 - Make sure your build host is set up according to:

  http://www.openembedded.org/wiki/OEandYourDistro

2 - Create your $OMDIR directory:

  mkdir /home/moko ; cd /home/moko

3 - Grab MokoMakefile:

  wget http://www.rwhitby.net/files/openmoko/Makefile

4 - Set up the environment:

  make setup

5 - Start building. Before starting a lenghty make process, check in Tips section about how to make Make multicore aware. You may want to modify the build/conf/local.conf file for your target (emulation/chroot) enviroment:

  make openmoko-devel-image

This will set up the recommended directory structure as described in Building OpenMoko from scratch, will download all the required software (from the right places with the right versions), and will immediately start building an image.

Once you have done this, you can choose to continue using the MokoMakefile to initiate your subsequent builds, or you can go into the build directory and run bitbake commands manually. The choice is yours.

Updating the environment

For easy maintenance of your build environment the following commands are available.

1 - To update the MokoMakefile to the latest version:

  make update-makefile 

2 - To update the OpenMoko repository checkout and the MokoMakefile patches to the latest version:

  make update

3 - To make sure that any recent changes to the build directory structure have been applied:

  make setup 

A quick way to rebuild a new image with the latest updates:

  make update-makefile && make update setup openmoko-devel-image

Reporting Problems

First, make sure that the problem is reproducable after running

make update-makefile ; make update ; make setup

then running

make clean-package-<foo>

(where you replace <foo> with the name of the package which is failing)

then running

make all

If you can get the error to occur three times in a row after running that sequence of commands three times, then feel free to report it to rwhitby in #openmoko on IRC.

Work-arounds

Work-arounds for temporary or isolated problems should be added to the Discussion page which is associated with this page. As they are fixed, they will be removed from that page.

Tips

  • You can reduce the amount of consumed disk space significantly by adding
  INHERIT += "rm_work"

in your local.conf (e.g. /home/moko/build/conf/local.conf). This will remove the contents of each build/tmp/work/*/<package> directory after the corresponding package builds correctly.


  • If you an encounter an error with monotone similar to the following:
  mtn: misuse: database /home/moko/OE.mtn is laid out according to an old schema

Then you need to upgrade OE.mtn Use the following command while in /home/moko:

  # mtn --db OE.mtn db migrate
  • If a certain package does not build due to corrupted download or some such try to remove the sources and rebuild it.
rm sources/<package>*
cd build
. ../setup-env
bitbake -crebuild <package>

after that your build might just work again.

  • For people with multiple CPU's (or dual-core ones) this small patch might be useful to build things faster.

Edit the local.conf and add the following lines:

PARALLEL_MAKE = "-j 4"
BB_NUMBER_THREADS = "4"

Change the PARALLEL_MAKE and BB_NUMBER_THREADS values to something that suits better if it chokes your machine.

QEMU

The MokoMakefile now has support for automatically building, flashing, and running the new Neo1973 emulator (which is based on QEMU).

Dependencies:

  • lynx ('apt-get install lynx' in Ubuntu 7.04)
  • netpbm ('apt-get install netpbm' in Ubuntu 7.04)
  • sdl-devel ('apt-get install libsdl1.2-dev in Ubuntu .704')

“make qemu” will build qemu-neo1973, download the latest official OpenMoko images, flash the images into the virtual NAND flash, and run the emulator (you still need to install the makefile as mentioned above, however).

Other targets are “make download-images” (to download the latest official images), “make flash-qemu-official” (to flash those images) and “make flash-qemu-local” (which will flash your latest locally built images), which can then be followed by “make run-qemu” or “make run-qemu-snapshot” to run the emulator with the most recently flashed images.

Make sure you have the “lynx” and “netpbm” packages installed on your build host first.

You're also invited to read more about how to run OpenMoko under QEMU in the article dedicated to this subject.

Developing with MokoMakefile

To make in-tree changes and have them built and used by qemu:

 cd /home/moko/openmoko
 quilt new descriptive-patch-name.patch
 quilt add trunk/src/name-of-file-to-change # do this for every file you are about to modify
 ...make the changes...
 quilt refresh # this creates a file in /home/moko/patches/openmoko-HEAD/ and updates the quilt series file there

Note: Do NOT use absolute paths as this confuses quilt and will get you a diff of the file against /dev/null!

To build the changes and have them used by qemu:

 make build-qemu
 make flash-qemu-local
 make run-qemu

If you want to modify applications instead of the openmoko toolchain, this is what you have to do (example: openmoko-messages):

 /usr/src/openmoko# . ./setup-env
 /usr/src/openmoko# cd openmoko/
 /usr/src/openmoko/openmoko# bitbake -c unpack openmoko-messages
 /usr/src/openmoko/openmoko# cd \
 ../build/tmp/work/armv4t-linux/openmoko-messages-0.0.1+svnnow-r2_2276/openmoko-messages/
 /usr/src/openmoko/build/tmp/work/armv4t-linux/openmoko-messages-0.0.1+svnnow-r2_2276/openmoko-messages# \
 vim src/detail-area.c
 /usr/src/openmoko/build/tmp/work/armv4t-linux/openmoko-messages-0.0.1+svnnow-r2_2276/openmoko-messages# \
 cd -
 /usr/src/openmoko/openmoko# bitbake openmoko-messages

Then continue with MokoMakefile usage.

If you want to add an application to your openmoko distribution, do this: All file edits should be done using quilt as described above. That way a patch can easily be submitted to the openmoko project. First, create a directory that will correspond to your package and edit a .bb file in there:

 /usr/src/openmoko# cd openmoko/
 /usr/src/openmoko/openmoko# quilt new mycoolpackage.patch
 /usr/src/openmoko/openmoko# mkdir trunk/oe/packages/mycoolpackage
 /usr/src/openmoko/openmoko# quilt add trunk/oe/packages/mycoolpackage/mycoolpackage_1.bb
 /usr/src/openmoko/openmoko# quilt edit trunk/oe/packages/mycoolpackage/mycoolpackage_1.bb

The file should have the following content:

 DESCRIPTION = "This is a cool package"
 SECTION = "username/mycoolpackage"
 PV = "1"
 
 inherit autotools
 
 SRC_URI = "http://www.example.com/download/mycoolpackage-1.tar.gz"

Explanation:

  • DESCRIPTION - Just a short text explaining the package
  • SECTION - I have no clue, but I'll use username/mycoolpackage for now
  • PV - Package Version
  • inherit autotools - The package can be compiled by './configure && make && make install' so we tell MokoMakefile to do it this way.
  • SRC_URI = ... - This is the download location of the package source. It's imperative that the tar.gz contains a directory called packagename-packageversion (in this case: mycoolpackage-1) so that MokoMakefile can find it automatically or the build will fail.

This is not all. We also need to tell MokoMakfile that it needs to build and include the package in the image. To do this, do

 /usr/src/openmoko/openmoko# quilt edit trunk/oe/packages/tasks/task-openmoko.bb

Here, increase the value PR by one and add mycoolpackage \ (with the backslash!) just before the line reading # update-alternatives \.

Now run

 /usr/src/openmoko/openmoko# quilt refresh
 /usr/src/openmoko/openmoko# cd ..
 /usr/src/openmoko# make update all

And if everything's alright you should now have an OpenMoko image to flash to your phone or run in qemu as described above.

Testimonials

MokoMakefile is recommended by 4 out of 4 new developers on #openmoko, with testimonials such as "For some reason last night I couldn't get my manual install of everything to work (bb complained about my bbpath I think) ... but with your makefile, it works great!", and "MokoMakefile rocks!".

Project page: http://mokomakefile.projects.openmoko.org/

Personal tools

MokoMakefile

MokoMakefile è un metodo completamente automatizzato per la configurazione dell'ambiente di sviluppo OpenMoko, uno strumento inestimabile che aiuta i nuovi sviluppatori ad ottenere un ambiente con le stesse configurazioni di quelli già presenti. Permette di ottenere la stessa ripetibilità nella compilazione e manutenzione dell'ambiente che OpenEmbedded introduce nell'attuale software embedded.

Nota che MokoMakefile *non* sostituisce bitbake, svn, monotone, openembedded, qmake e null'altro. Costituisce un wrapper attorno ad essi che facilita la configurazione e la manutenzione di un ambiente di sviluppo che rispecchia le istruzioni pubblicate da OpenMoko. MokoMakefile necessita circa 7 GB di spazio disponibile.

MokoMakefile è sviluppato da Rod Whitby - non è un prodotto ufficiale OpenMoko (anche se sarebbe una buona cosa sfruttarlo per uso interno). Se ci sono delle discrepanze tra le istruzioni ufficiali compilazione OpenMoko e le operazioni di MokoMakefile, vanno considerate corrette le istruzioni ufficiali.

Before you begin

Check that your /bin/sh (ls -l /bin/sh) is not linked to dash rather than bash. Using dash will cause you pain. This is true for a standard install of Ubuntu 7.04 (at least when installing from Live CD). If your /bin/sh points to /bin/dash, correct it with (as root):

ln -sf /bin/bash /bin/sh

If you have previously built with dash as your sh shell then your perl compile is probably broken. One symptom is that the build will error and whine about an 'Unterminated quote string' another symptom is a message that says 'You haven't done a "make depend" yet!' If you get these then you need to:

make clean-package-perl
make clean-package-perl-native

and rebuild.

If all else fails then just rm -rf the perl work dir and the perl stamps here's an i686 host example:

rm -rf build/tmp/work/i686-linux/perl-native-5.8.7-r3 
rm -f  build/tmp/stamps/i686-linux/perl*

As of r99, MokoMakefile has patches which should make it build correctly with dash.

Installation

Here are the steps to use it:

1 - Make sure your build host is set up according to:

  http://www.openembedded.org/wiki/OEandYourDistro

2 - Create your $OMDIR directory:

  mkdir /home/moko ; cd /home/moko

3 - Grab MokoMakefile:

  wget http://www.rwhitby.net/files/openmoko/Makefile

4 - Set up the environment:

  make setup

5 - Start building. Before starting a lenghty make process, check in Tips section about how to make Make multicore aware. You may want to modify the build/conf/local.conf file for your target (emulation/chroot) enviroment:

  make openmoko-devel-image

This will set up the recommended directory structure as described in Building OpenMoko from scratch, will download all the required software (from the right places with the right versions), and will immediately start building an image.

Once you have done this, you can choose to continue using the MokoMakefile to initiate your subsequent builds, or you can go into the build directory and run bitbake commands manually. The choice is yours.

Updating the environment

For easy maintenance of your build environment the following commands are available.

1 - To update the MokoMakefile to the latest version:

  make update-makefile 

2 - To update the OpenMoko repository checkout and the MokoMakefile patches to the latest version:

  make update

3 - To make sure that any recent changes to the build directory structure have been applied:

  make setup 

A quick way to rebuild a new image with the latest updates:

  make update-makefile && make update setup openmoko-devel-image

Reporting Problems

First, make sure that the problem is reproducable after running

make update-makefile ; make update ; make setup

then running

make clean-package-<foo>

(where you replace <foo> with the name of the package which is failing)

then running

make all

If you can get the error to occur three times in a row after running that sequence of commands three times, then feel free to report it to rwhitby in #openmoko on IRC.

Work-arounds

Work-arounds for temporary or isolated problems should be added to the Discussion page which is associated with this page. As they are fixed, they will be removed from that page.

Tips

  • You can reduce the amount of consumed disk space significantly by adding
  INHERIT += "rm_work"

in your local.conf (e.g. /home/moko/build/conf/local.conf). This will remove the contents of each build/tmp/work/*/<package> directory after the corresponding package builds correctly.


  • If you an encounter an error with monotone similar to the following:
  mtn: misuse: database /home/moko/OE.mtn is laid out according to an old schema

Then you need to upgrade OE.mtn Use the following command while in /home/moko:

  # mtn --db OE.mtn db migrate
  • If a certain package does not build due to corrupted download or some such try to remove the sources and rebuild it.
rm sources/<package>*
cd build
. ../setup-env
bitbake -crebuild <package>

after that your build might just work again.

  • For people with multiple CPU's (or dual-core ones) this small patch might be useful to build things faster.

Edit the local.conf and add the following lines:

PARALLEL_MAKE = "-j 4"
BB_NUMBER_THREADS = "4"

Change the PARALLEL_MAKE and BB_NUMBER_THREADS values to something that suits better if it chokes your machine.

QEMU

The MokoMakefile now has support for automatically building, flashing, and running the new Neo1973 emulator (which is based on QEMU).

Dependencies:

  • lynx ('apt-get install lynx' in Ubuntu 7.04)
  • netpbm ('apt-get install netpbm' in Ubuntu 7.04)
  • sdl-devel ('apt-get install libsdl1.2-dev in Ubuntu .704')

“make qemu” will build qemu-neo1973, download the latest official OpenMoko images, flash the images into the virtual NAND flash, and run the emulator (you still need to install the makefile as mentioned above, however).

Other targets are “make download-images” (to download the latest official images), “make flash-qemu-official” (to flash those images) and “make flash-qemu-local” (which will flash your latest locally built images), which can then be followed by “make run-qemu” or “make run-qemu-snapshot” to run the emulator with the most recently flashed images.

Make sure you have the “lynx” and “netpbm” packages installed on your build host first.

You're also invited to read more about how to run OpenMoko under QEMU in the article dedicated to this subject.

Developing with MokoMakefile

To make in-tree changes and have them built and used by qemu:

 cd /home/moko/openmoko
 quilt new descriptive-patch-name.patch
 quilt add trunk/src/name-of-file-to-change # do this for every file you are about to modify
 ...make the changes...
 quilt refresh # this creates a file in /home/moko/patches/openmoko-HEAD/ and updates the quilt series file there

Note: Do NOT use absolute paths as this confuses quilt and will get you a diff of the file against /dev/null!

To build the changes and have them used by qemu:

 make build-qemu
 make flash-qemu-local
 make run-qemu

If you want to modify applications instead of the openmoko toolchain, this is what you have to do (example: openmoko-messages):

 /usr/src/openmoko# . ./setup-env
 /usr/src/openmoko# cd openmoko/
 /usr/src/openmoko/openmoko# bitbake -c unpack openmoko-messages
 /usr/src/openmoko/openmoko# cd \
 ../build/tmp/work/armv4t-linux/openmoko-messages-0.0.1+svnnow-r2_2276/openmoko-messages/
 /usr/src/openmoko/build/tmp/work/armv4t-linux/openmoko-messages-0.0.1+svnnow-r2_2276/openmoko-messages# \
 vim src/detail-area.c
 /usr/src/openmoko/build/tmp/work/armv4t-linux/openmoko-messages-0.0.1+svnnow-r2_2276/openmoko-messages# \
 cd -
 /usr/src/openmoko/openmoko# bitbake openmoko-messages

Then continue with MokoMakefile usage.

If you want to add an application to your openmoko distribution, do this: All file edits should be done using quilt as described above. That way a patch can easily be submitted to the openmoko project. First, create a directory that will correspond to your package and edit a .bb file in there:

 /usr/src/openmoko# cd openmoko/
 /usr/src/openmoko/openmoko# quilt new mycoolpackage.patch
 /usr/src/openmoko/openmoko# mkdir trunk/oe/packages/mycoolpackage
 /usr/src/openmoko/openmoko# quilt add trunk/oe/packages/mycoolpackage/mycoolpackage_1.bb
 /usr/src/openmoko/openmoko# quilt edit trunk/oe/packages/mycoolpackage/mycoolpackage_1.bb

The file should have the following content:

 DESCRIPTION = "This is a cool package"
 SECTION = "username/mycoolpackage"
 PV = "1"
 
 inherit autotools
 
 SRC_URI = "http://www.example.com/download/mycoolpackage-1.tar.gz"

Explanation:

  • DESCRIPTION - Just a short text explaining the package
  • SECTION - I have no clue, but I'll use username/mycoolpackage for now
  • PV - Package Version
  • inherit autotools - The package can be compiled by './configure && make && make install' so we tell MokoMakefile to do it this way.
  • SRC_URI = ... - This is the download location of the package source. It's imperative that the tar.gz contains a directory called packagename-packageversion (in this case: mycoolpackage-1) so that MokoMakefile can find it automatically or the build will fail.

This is not all. We also need to tell MokoMakfile that it needs to build and include the package in the image. To do this, do

 /usr/src/openmoko/openmoko# quilt edit trunk/oe/packages/tasks/task-openmoko.bb

Here, increase the value PR by one and add mycoolpackage \ (with the backslash!) just before the line reading # update-alternatives \.

Now run

 /usr/src/openmoko/openmoko# quilt refresh
 /usr/src/openmoko/openmoko# cd ..
 /usr/src/openmoko# make update all

And if everything's alright you should now have an OpenMoko image to flash to your phone or run in qemu as described above.

Testimonials

MokoMakefile is recommended by 4 out of 4 new developers on #openmoko, with testimonials such as "For some reason last night I couldn't get my manual install of everything to work (bb complained about my bbpath I think) ... but with your makefile, it works great!", and "MokoMakefile rocks!".

Project page: http://mokomakefile.projects.openmoko.org/