docs/C - Misc. tutorials.txt
author Titus von Boxberg <titus@v9g.de>
Mon Aug 22 09:40:31 2011 +0200 (2011-08-22)
changeset 2626 c7c9e98d36d8
parent 2571 c18e79033384
child 2628 a4f56e266879
permissions -rw-r--r--
configure: require libtoolize, create wrapper to it

libtoolize must be checked_for and there needs to be a wrapper
that points to GNU libtoolize since that may be installed
as glibtoolize.
This fixes a problem with building Cloog/PPL that was

Reported-by: "Pierrick Brossin" <pierrick@bs-network.net>
Signed-off-by: "Titus von Boxberg" <titus@v9g.de>
     1 File.........: C - Misc. tutorials.txt
     2 Copyright....: (C) 2010 Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
     3 License......: Creative Commons Attribution Share Alike (CC-by-sa), v2.5
     4 
     5 
     6 Misc. tutorials  /
     7 ________________/
     8 
     9 
    10 Using crosstool-NG on FreeBSD (and other *BSD) |
    11 -----------------------------------------------+
    12 
    13 Contributed by: Titus von Boxberg
    14 
    15 Prerequisites and instructions for using ct-ng for building a cross toolchain on FreeBSD as host.
    16 
    17 0) Tested on FreeBSD 8.0
    18 
    19 1) Install (at least) the following ports
    20    archivers/lzma
    21    textproc/gsed
    22    devel/gmake
    23    devel/patch
    24    shells/bash
    25    devel/bison
    26    lang/gawk
    27    devel/automake110
    28    ftp/wget
    29 
    30    Of course, you should have /usr/local/bin in your PATH.
    31 
    32 2) run ct-ng's configure with the following tool configuration:
    33    ./configure --with-sed=/usr/local/bin/gsed --with-make=/usr/local/bin/gmake \
    34    --with-patch=/usr/local/bin/gpatch
    35    [...other configure parameters as you like...]
    36 
    37 3) proceed as described in general documentation
    38    but use gmake instead of make
    39 
    40 
    41 Using crosstool-NG on MacOS-X |
    42 ------------------------------+
    43 
    44 Contributed by: Titus von Boxberg
    45 
    46 Prerequisites and instructions for using crosstool-NG for building a cross
    47 toolchain on MacOS as host.
    48 
    49 0) Mac OS Snow Leopard, with Developer Tools 3.2 installed, or
    50    Mac OS Leopard, with Developer Tools & newer gcc (>= 4.3) installed
    51    via macports
    52 
    53 1) You have to use a case sensitive file system for ct-ng's build and target
    54    directories. Use a disk or disk image with a case sensitive fs that you
    55    mount somewhere.
    56 
    57 2) Install macports (or similar easy means of installing 3rd party software),
    58    make sure that macport's bin dir is in your PATH.
    59    Furtheron assuming it is /opt/local/bin.
    60 
    61 3) Install (at least) the following macports
    62    lzmautils
    63    libtool
    64    binutils
    65    gsed
    66    gawk
    67    gcc43 (only necessary for Leopard OSX 10.5)
    68 
    69    On Leopard, make sure that the macport's gcc is called with the default
    70    commands (gcc, g++,...), e.g. via macport gcc_select
    71 
    72 4) run ct-ng's configure with the following tool configuration
    73    (assuming you have installed the tools via macports in /opt/local):
    74    ./configure --with-sed=/opt/local/bin/gsed                 \
    75                --with-libtool=/opt/local/bin/glibtool         \
    76                --with-libtoolize=/opt/local/bin/glibtoolize   \
    77                --with-objcopy=/opt/local/bin/gobjcopy         \
    78                --with-objdump=/opt/local/bin/gobjdump         \
    79                --with-readelf=/opt/local/bin/greadelf         \
    80                [...other configure parameters as you like...]
    81 
    82 5) proceed as described in standard documentation
    83 
    84 -----
    85 
    86 HINTS:
    87 - Apparently, GNU make's builtin variable .LIBPATTERNS is misconfigured
    88   under MacOS: It does not include lib%.dylib.
    89   This affects build of (at least) gdb-7.1
    90   Put 'lib%.a lib%.so lib%.dylib' as .LIBPATTERNS into your environment
    91   before executing ct-ng build.
    92   See http://www.gnu.org/software/make/manual/html_node/Libraries_002fSearch.html
    93   as an explanation.
    94 - ct-ng menuconfig will not work on Snow Leopard 10.6.3 since libncurses
    95   is broken with this release. MacOS <= 10.6.2 and >= 10.6.4 are ok.
    96 
    97 
    98 Using Mercurial to hack crosstool-NG |
    99 -------------------------------------+
   100 
   101 Contributed by: Titus von Boxberg
   102 
   103 PREREQUISITES:
   104 
   105 Configuring Mercurial:
   106   You need mercurial with the following extensions:
   107    - mq        : http://mercurial.selenic.com/wiki/MqExtension
   108    - patchbomb : http://mercurial.selenic.com/wiki/PatchbombExtension
   109   Usually, these two extensions are already part of the installation package.
   110   The mq extension maintains a separate queue of your local changes
   111   that you can change at any later time.
   112   With the patchbomb extension you can email those patches directly
   113   from your local repo.
   114 
   115   Your configuration file for mercurial, e.g. ~/.hgrc should contain
   116   at least the following sections (but have a look at `man hgrc`):
   117   # ---
   118   [email]
   119   # configure sending patches directly via Mercurial
   120   from = "Your Name" <your@email.address>
   121   # How to send email:
   122   method = smtp
   123 
   124   [smtp]
   125   # SMTP configuration (only for method=smtp)
   126   host = localhost
   127   tls = true
   128   username =
   129   password =
   130 
   131   [extensions]
   132   # The following lines enable the two extensions:
   133   hgext.mq =
   134   hgext.patchbomb =
   135   # ----
   136 
   137 Create your local repository as a clone:
   138   hg clone http://crosstool-ng.org/hg/crosstool-ng crosstool-ng
   139 
   140 Setting up the mq extension in your local copy:
   141   cd crosstool-ng
   142   hg qinit
   143 
   144 
   145 CREATING PATCHES:
   146 
   147 Recording your changes in the patch queue maintained by mq:
   148   # First, create a new patch entry in the patch queue:
   149   hg qnew -D -U -e short_patch_name1
   150   <edit patch description as commit message (see below for an example)>
   151 
   152   <now edit the ct-ng sources and check them>
   153 
   154   # if you execute `hg status` here, your modifications of the working
   155   # copy should show up.
   156 
   157   # Now the following command takes your modifications from the working copy
   158   # into the patch entry
   159   hg qrefresh -D [-e]
   160   <reedit patch description [-e] if desired>
   161 
   162   # Now your changes are recorded, and `hg status` should show a clean
   163   # working copy
   164 
   165 Repeat the above steps for all your modifications.
   166 The command `hg qseries` informs you about the content of your patch queue.
   167 
   168 
   169 CONTRIBUTING YOUR PATCHES:
   170 
   171 Once you are satisfied with your patch series, you can (you should!)
   172 contribute them back to upstream.
   173 This is easily done using the `hg email` command.
   174 
   175 `hg email` sends your new changesets to a specified list of recipients,
   176 each patch in its own email, all ordered in the way you entered them (oldest
   177 first). The command line flag --outgoing selects all changesets that are in
   178 your local but not yet in the upstream repository. Here, these are exactly
   179 the ones you entered into your local patch queue in the section above, so
   180 --outgoing is what you want.
   181 
   182 Each email gets the subject set to:  "[PATCH x of n] <series summary>"
   183 where 'x' is the serial number in the email series, and 'n' is the total number
   184 of patches in the series. The body of the email is the complete patch, plus
   185 a handful of metadata, that helps properly apply the patch, keeping the log
   186 message, attribution and date, tracking file changes (move, delete, modes...)
   187 
   188 `hg email` also threads all outgoing patch emails below an introductory
   189 message. You should use the introductory message (command line flag --intro)
   190 to describe the scope and motivation for the whole patch series. The subject
   191 for the introductory message gets set to:  "[PATCH 0 of n] <series summary>"
   192 and you get the chance to set the <series summary>.
   193 
   194 Here is a sample `hg email` complete command line:
   195 Note: replace " (at) " with "@"
   196 
   197   hg email --outgoing --intro   \
   198            --to '"Yann E. MORIN" <yann.morin.1998 (at) anciens.enib.fr>'    \
   199            --cc 'crossgcc (at) sourceware.org'
   200 
   201   # It then opens an editor and lets you enter the subject
   202   # and the body for the introductory message.
   203 
   204 Use `hg email` with the additional command line switch -n to
   205 first have a look at the email(s) without actually sending them.
   206 
   207 
   208 MAINTAINING YOUR PATCHES:
   209 
   210 When the patches are refined by discussing them on the mailing list,
   211 you may want to finalize and resend them.
   212 
   213 The mq extension has the idiosyncrasy of imposing a stack onto the queue:
   214 You can always reedit/refresh only the patch on top of stack.
   215 The queue consists of applied and unapplied patches
   216 (if you reached here via the above steps, all of your patches are applied),
   217 where the 'stack' consists of the applied patches, and 'top of stack'
   218 is the latest applied patch.
   219 
   220 The following output of `hg qseries` is now used as an example:
   221   0 A short_patch_name1
   222   1 A short_patch_name2
   223   2 A short_patch_name3
   224   3 A short_patch_name4
   225 
   226 You are now able to edit patch 'short_patch_name4' (which is top of stack):
   227   <Edit the sources>
   228   # and execute again
   229   hg qrefresh -D [-e]
   230   <and optionally [-e] reedit the commit message>
   231 
   232 If you want to edit e.g. patch short_patch_name2, you have to modify
   233 mq's stack so this patch gets top of stack.
   234 For this purpose see `hg help qgoto`, `hg help qpop`, and `hg help qpush`.
   235 
   236   hg qgoto short_patch_name2
   237   # The patch queue should now look like
   238   hg qseries
   239     0 A short_patch_name1
   240     1 A short_patch_name2
   241     2 U short_patch_name3
   242     3 U short_patch_name4
   243   # so patch # 1 (short_patch_name2) is top of stack.
   244   <now reedit the sources for short_patch_name2>
   245   # and execute again
   246   hg qrefresh -D [-e]
   247   <and optionally [-e] reedit the commit message>
   248   # the following command reapplies the now unapplied two patches:
   249   hg qpush -a
   250   # you can also use `hg qgoto short_patch_name4` to get there again.
   251 
   252 
   253 RESENDING YOUR REEDITED PATCHES:
   254 
   255 By mailing list policy, please resend your complete patch series.
   256 --> Go back to section "CONTRIBUTING YOUR PATCHES" and resubmit the full set.
   257 
   258 
   259 SYNCING WITH UPSTREAM AGAIN:
   260 
   261 You can sync your repo with upstream at any time by executing
   262   # first unapply all your patches:
   263   hg qpop -a
   264   # next fetch new changesets from upstream
   265   hg pull
   266   # then update your working copy
   267   hg up
   268   # optionally remove already upstream integrated patches (see below)
   269   hg qdelete <short_name_of_already_applied_patch>
   270   # and reapply your patches if any non upstream-integrated left (but see below)
   271   hg qpush -a
   272 
   273 Eventually, your patches get included into the upstream repository
   274 which you initially cloned.
   275 In this case, before executing the hg qpush -a from above
   276 you should manually "hg qdelete" the patches that are already integrated upstream.
   277 
   278 
   279 HOW TO FORMAT COMMIT MESSAGES (aka patch descriptions):
   280 
   281 Commit messages should look like (without leading pipes):
   282  |component: short, one-line description
   283  |
   284  |optional longer description
   285  |on multiple lines if needed
   286  |
   287  |Signed-off-by: as documented in section 7 of ct-ng's documentation
   288 
   289 Here is an example commit message (see revision 8bb5151c5b01):
   290  kernel/linux: fix type in version strings
   291 
   292  I missed refreshing the patch before pushing. :-(
   293 
   294  Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>