User Tools

Site Tools


doc:howto:build

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:howto:build [2014/03/05 22:21]
guraltsev swapped position of two paragraphs that were in the wrong order
doc:howto:build [2015/07/19 15:14] (current)
grumbler_eburg [Make options]
Line 9: Line 9:
     * ''​SED''​ should not be set.  If it is, run ''​`unset SED`''​ before compiling. (See [[https://​dev.openwrt.org/​ticket/​10612|Ticket 10612]].)     * ''​SED''​ should not be set.  If it is, run ''​`unset SED`''​ before compiling. (See [[https://​dev.openwrt.org/​ticket/​10612|Ticket 10612]].)
     * ''​GREP_OPTIONS''​ should not have ''​--initial-tab''​ or other options affecting its output     * ''​GREP_OPTIONS''​ should not have ''​--initial-tab''​ or other options affecting its output
 +    * Add ''<​buildroot dir>/​staging_dir/​host/​bin''​ and ''<​buildroot dir>/​staging_dir/​toolchain-<​platform>​-<​gcc_ver>​-<​libc_ver>/​bin''​ in front of your ''​PATH''​ variable in ''​~/​.bashrc''​. The staging directory is created shortly after starting the build and the toolchain directory is created when the toolchain build begins. The build spawns multiple shells, some of which expect the toolchain binaries to be present in the ''​PATH''​.
  
 ===== Procedure ===== ===== Procedure =====
Line 21: Line 22:
  
  
-==== Updating Sources ==== +==== Updating Sources ​with Git ====
-You can check the currently installed revision with +
-<WRAP prewrap 1000px><​code>​ +
-svn info +
-</​code></​WRAP>​+
  
 +:!: OpenWrt sources change frequently. It is recommended that you work with the latest sources.
  
-Update sources: +<​code>​ 
-<WRAP prewrap 1000px><​code>​ +git pull 
-svn update +</​code>​
-</​code>​</​WRAP>​ +
-//OpenWrt sources change frequently. It is recommended that you work with the latest sources.//​ +
  
 ==== Updating Feeds ==== ==== Updating Feeds ====
-  ​- Update feeds: ​<WRAP prewrap 1000px><​code>​./​scripts/​feeds update -a</code></​WRAP>+ 
 +see [[doc:​devel:​feeds]] 
 + 
 +:!: //​Installing//​ in context of ''​./​scripts/​feeds''​ script means "​making package available in ''​make menuconfig''"​ rather than really installing or compiling package. 
 + 
 +  ​- Update feeds: <​code>​./​scripts/​feeds update -a</​code>​
   - Make downloaded package/​packages available in ''​make menuconfig'':​   - Make downloaded package/​packages available in ''​make menuconfig'':​
-    * single package:<WRAP prewrap 1000px><​code>​./​scripts/​feeds install <​PACKAGENAME></​code></​WRAP+    * single package:<​code>​./​scripts/​feeds install <​PACKAGENAME></​code>​ 
-    * all packages:<WRAP prewrap 1000px><​code>​./​scripts/​feeds install -a</code></​WRAP>+    * all packages:<​code>​./​scripts/​feeds install -a</​code>​
  
-Please note that //​installing//​ in context of ''​./​scripts/​feeds''​ script means "​making package available in ''​make menuconfig''"​ rather than really installing or compiling package. 
  
 ===== Image Configuration ===== ===== Image Configuration =====
 +
 +Typical actions:
 +  - run ''​make menuconfig''​ and set target;
 +  - run ''​make defconfig'';​
 +  - run ''​make menuconfig''​ and modify set of package;
 +  - run ''​scripts/​diffconfig.sh >​mydiffconfig''​ (save your changes in the text file ''​mydiffconfig''​);​
 +  - run ''​make V=s''​ (build OpenWRT with console logging, you will look where build failed.).
 ==== Make menuconfig ==== ==== Make menuconfig ====
 The **OpenWrt Buildroot configuration interface** handles the selection of the target platform, packages to be compiled, packages to be included in the firmware file, some kernel options, etc. \\ Start the OpenWrt Buildroot configuration interface by issuing the following command:\\ The **OpenWrt Buildroot configuration interface** handles the selection of the target platform, packages to be compiled, packages to be included in the firmware file, some kernel options, etc. \\ Start the OpenWrt Buildroot configuration interface by issuing the following command:\\
-<WRAP prewrap 1000px><​code>​+<​code>​
 make menuconfig make menuconfig
-</code></​WRAP>+</​code>​
  
 This will update the dependencies of your existing configuration automatically,​ and you can now proceed to build your updated images. ​ This will update the dependencies of your existing configuration automatically,​ and you can now proceed to build your updated images. ​
Line 80: Line 86:
  
 While you won't typically need to do this, you can do it: While you won't typically need to do this, you can do it:
-<WRAP prewrap 1000px><​code>​ +<​code>​ 
-make kernel_menuconfig +make kernel_menuconfig ​CONFIG_TARGET=subtarget 
-</code></​WRAP+</​code>​ 
-The changes can be reviewed with +CONFIG_TARGET allows you to select which config you want to edit. possible options: target, subtarget, env. 
-<WRAP prewrap 1000px><​code>​+ 
 +:FIXME: (git) 
 +SVN: The changes can be reviewed with 
 +<​code>​
 svn diff target/​linux/​ svn diff target/​linux/​
-</code></​WRAP>+</​code>​
 and reverted with  and reverted with 
-<WRAP prewrap 1000px><​code>​+<​code>​
 svn revert -R target/​linux/​ svn revert -R target/​linux/​
-</code></​WRAP>+</​code>​
  
  
Line 103: Line 112:
 The '​Kernel modules'​ option is required if you need specific (non-standard) drivers and so forth – this would typically be things like modules for USB or particular network interface drivers etc. The '​Kernel modules'​ option is required if you need specific (non-standard) drivers and so forth – this would typically be things like modules for USB or particular network interface drivers etc.
  
 +==== Configure using config diff file ====
 +Beside ''​make menuconfig''​ another way to configure is using a configuration diff file. This file includes only the changes compared to the default configuration. A benefit is that this file can be version controlled with your OpenWRT based project. It's also less affected by OpenWRT updates, because it only contains the changes. ​
 +
 +=== Creating diff file ===
 +This file is created using the ''<​buildroot dir>/​scripts/​diffconfig.sh''​ script. ​
 +
 +=== Using diff file ===
 +These changes can form the basis of a config file (''<​buildroot dir>/​.config''​). By running ''​make defconfig''​ these changes will be expanded into a full config. ​
 +<​code>​
 +cat diffconfig > .config # append changes to bottom of .config
 +make defconfig # expand to full config
 +</​code>​
 +
 +These changes can also be added to the bottom of the config file (''<​buildroot dir>/​.config''​),​ by running ''​make defconfig''​ these changes will override the existing configuration.
 +<​code>​
 +cat diffconfig >> .config # append changes to bottom of .config
 +make defconfig # apply changes
 +</​code>​
  
 ==== Patches ==== ==== Patches ====
Line 122: Line 149:
 ==== Defconfig ==== ==== Defconfig ====
 [[https://​forum.openwrt.org/​viewtopic.php?​pid=140470#​p140470|select your target before issuing defconfig]] [[https://​forum.openwrt.org/​viewtopic.php?​pid=140470#​p140470|select your target before issuing defconfig]]
-<WRAP prewrap 1000px><​code>​+<​code>​
 make defconfig make defconfig
-</code></​WRAP>+</​code>​
 will produce a general purpose configuration of the build system including a check of dependencies and prerequisites for the build environment etc will produce a general purpose configuration of the build system including a check of dependencies and prerequisites for the build environment etc
  
Line 132: Line 159:
 Everything is now ready for building the image(s), which is done with one single command: Everything is now ready for building the image(s), which is done with one single command:
  
-<WRAP prewrap 1000px><​code>​+<​code>​
 make make
-</​code></​WRAP>+</​code>​ 
 +or 
 +<​code>​ 
 +make world 
 +</code>
  
 This simple command will trigger a cascade of activity. As already stated, it will This simple command will trigger a cascade of activity. As already stated, it will
Line 141: Line 172:
   - create opkg-packages   - create opkg-packages
   - generate a firmware image file ready to be [[generic.flashing|flashed]].   - generate a firmware image file ready to be [[generic.flashing|flashed]].
 +
 +==== The make sequience ====
 +Top command ''​make world''​ calls the following sequence of the commands:\\
 +''​make target/​compile''​\\
 +''​make package/​cleanup''​\\
 +''​make package/​compile''​\\
 +''​make package/​install''​\\
 +''​make package/​preconfig''​\\
 +''​make target/​install''​\\
 +''​make package/​index''​
 +
 +You may run each command independency. For example, if the process of compilation of packages stops on error, you may fix problem and next continue without cleanup:\\
 +''​make package/​compile''​\\
 +''​make package/​install''​\\
 +''​make package/​preconfig''​\\
 +''​make target/​install''​\\
 +''​make package/​index''​
  
 ==== Make options ==== ==== Make options ====
 +
 +=== Warnings, errors and tracing ===
 +The parameter ''​V=xx''​ specifies level of messages in the process of the build.
 +
 +Value of ''​V''​ may be
 +  * ''​1''​ - print a messages containing the working directory before and after other processing.
 +  * ''​w''​ - same as ''​1'';​
 +  * ''​99''​ - trace of the build, ordinary messages yellow, error messages red, debug - black;
 +  * ''​s''​ - same as ''​99''​.
 +
 +Examples:
 +<​code>​make V=s</​code>​
 +Trace build.
 +
 +<​code>​make V=99</​code>​
 +
 +Same.
 +
 +<​code>​make V=sw</​code>​
 +
 +Same effect.
 +
 +<​code>​make V=w</​code>​
 +Trace of directories.
 +
 === Building on multi-core CPU === === Building on multi-core CPU ===
-**Build may FAIL**+:!: **Build may FAIL**
  
 The build process can be accelerated by running multiple concurrent job processes using the ''​-j''​-option:​ The build process can be accelerated by running multiple concurrent job processes using the ''​-j''​-option:​
-<WRAP prewrap 1000px><​code>​+<​code>​
 make -j 3 make -j 3
-</code></​WRAP>+</​code>​
   * Use the standard formula ''<​your number of CPU cores + 1>''​   * Use the standard formula ''<​your number of CPU cores + 1>''​
   * If this produces random build errors try compiling again without the ''​-j''​-option   * If this produces random build errors try compiling again without the ''​-j''​-option
Line 156: Line 229:
 If you intend to use your system while building, you can have the build process use only idle I/O and CPU capacity like this (dualcore CPU): If you intend to use your system while building, you can have the build process use only idle I/O and CPU capacity like this (dualcore CPU):
  
-<WRAP prewrap 1000px><​code>​+<​code>​
 ionice -c 3 nice -n19 make -j 2 ionice -c 3 nice -n19 make -j 2
-</code></​WRAP>+</​code>​
  
 === Building single Packages === === Building single Packages ===
 When developing or packaging software for OpenWrt, it is convenient to be able to build only the package in question (e.g. with package ''​cups''​):​ When developing or packaging software for OpenWrt, it is convenient to be able to build only the package in question (e.g. with package ''​cups''​):​
  
-<WRAP prewrap 1000px><​code>​+<​code>​
 make package/​cups/​compile V=s make package/​cups/​compile V=s
-</​code>​</​WRAP>​ +</​code>​
- +
-For the package ''​mc (midnight commander)'',​ which is contained the feed //​packages//​ it looks like this: +
-<WRAP prewrap 1000px><​code>​ +
-make package/​feeds/​packages/​mc/​compile V=s +
-</​code></​WRAP>​ +
- +
-//Note that the path start in ''​package''​ directory and ''​package/​feeds''​ may not have exactly the same structure as ''​feeds''​. For example package in ''​~/​openwrt/​trunk/​feeds/​packages/​**net**/​snort''​ will be compiled using ''​make ~/​openwrt/​trunk/​**package**/​feeds/​packages/​snort/​**compile** V=s''​.//​+
  
 +For a rebuild:
 +<​code>​
 +make package/​cups/​{clean,​compile,​install} V=s
 +</​code>​
  
 +It doesn'​t matter what feed the package is located in, this same syntax works for any installed package.
  
 === Spotting build errors === === Spotting build errors ===
 If for some reason the build fails, the easiest way to spot the error is to do: If for some reason the build fails, the easiest way to spot the error is to do:
  
-<WRAP prewrap 1000px><​code>​+<​code>​
 make V=s 2>&1 | tee build.log | grep -i error make V=s 2>&1 | tee build.log | grep -i error
-</code></​WRAP>+</​code>​
  
 The above saves a full verbose copy of the build output (with stdout piped to stderr) in ''/​openwrt/​trunk/​build.log''​ and only shows errors on the screen. The above saves a full verbose copy of the build output (with stdout piped to stderr) in ''/​openwrt/​trunk/​build.log''​ and only shows errors on the screen.
Line 187: Line 258:
 Another example: Another example:
  
-<WRAP prewrap 1000px><​code>​+<​code>​
 ionice -c 3 nice -n 20 make -j 2 V=s CONFIG_DEBUG_SECTION_MISMATCH=y 2>&1 | tee build.log | egrep -i '​(warn|error)'​ ionice -c 3 nice -n 20 make -j 2 V=s CONFIG_DEBUG_SECTION_MISMATCH=y 2>&1 | tee build.log | egrep -i '​(warn|error)'​
-</code></​WRAP>+</​code>​
  
 The above saves a full verbose copy of the build output (with stdout piped to stderr) in build.log and outputs only warnings and errors while building using only background resources on a dual core CPU. The above saves a full verbose copy of the build output (with stdout piped to stderr) in build.log and outputs only warnings and errors while building using only background resources on a dual core CPU.
Line 199: Line 270:
 Depending on your CPU, the process will take a while, or while longer. If you want an acoustic notification,​ you could use ''​echo -e '​\a''':​ Depending on your CPU, the process will take a while, or while longer. If you want an acoustic notification,​ you could use ''​echo -e '​\a''':​
  
-<WRAP prewrap 1000px><​code>​+<​code>​
 make V=s ; echo -e '​\a'​ make V=s ; echo -e '​\a'​
-</code></​WRAP>+</​code>​
  
 +=== Skipping failed packages ===
 +If you are building everything (not just packages enough to make a flashable image) and build stops on a package you don't care about you can skip failed packages by using //​IGNORE_ERRORS=1//​
 +<​code>​
 +IGNORE_ERRORS=1 make <make options>
 +</​code>​
 ===== Locating Images ===== ===== Locating Images =====
 After a successful build, the freshly built image(s) can be found in the newly created ''<​buildroot_dir>/​bin''​ directory. The compiled files are additionally classified by the target platform, so e.g. a firmware built for an ar71xx device will be located in ''<​buildroot_dir>/​bin/​ar71xx''​ directory. After a successful build, the freshly built image(s) can be found in the newly created ''<​buildroot_dir>/​bin''​ directory. The compiled files are additionally classified by the target platform, so e.g. a firmware built for an ar71xx device will be located in ''<​buildroot_dir>/​bin/​ar71xx''​ directory.
Line 212: Line 288:
  
 ==== Clean ==== ==== Clean ====
-<WRAP prewrap 1000px><​code>​+<​code>​
 make clean make clean
-</code></​WRAP>+</​code>​
  
 deletes contents of the directories ''/​bin''​ and ''/​build_dir''​. deletes contents of the directories ''/​bin''​ and ''/​build_dir''​.
 +make clean does not remove the toolchain,​ 
 +it also avoids cleaning architectures/​targets other than the one you have selected in your ''​.config''​
  
 ==== Dirclean ==== ==== Dirclean ====
-<WRAP prewrap 1000px><​code>​+<​code>​
 make dirclean make dirclean
-</code></​WRAP>+</​code>​
  
 deletes contents of the directories ''/​bin''​ and ''/​build_dir''​ and additionally ''/​staging_dir''​ and ''/​toolchain''​ (=the cross-compile tools) and ''/​logs''​. '​Dirclean'​ is your basic "Full clean" operation. deletes contents of the directories ''/​bin''​ and ''/​build_dir''​ and additionally ''/​staging_dir''​ and ''/​toolchain''​ (=the cross-compile tools) and ''/​logs''​. '​Dirclean'​ is your basic "Full clean" operation.
Line 228: Line 305:
  
 ==== Distclean ==== ==== Distclean ====
-<WRAP prewrap 1000px><​code>​+<​code>​
 make distclean make distclean
-</code></​WRAP>+</​code>​
  
 nukes everything you have compiled or configured and also deletes all downloaded feeds contents and package sources. nukes everything you have compiled or configured and also deletes all downloaded feeds contents and package sources.
Line 243: Line 320:
  
 Clean linux objects. Clean linux objects.
-<WRAP prewrap 1000px><​code>​+<​code>​
 make target/​linux/​clean make target/​linux/​clean
-</code></​WRAP>+</​code>​
  
 Clean package base-files objects. Clean package base-files objects.
-<WRAP prewrap 1000px><​code>​+<​code>​
 make package/​base-files/​clean make package/​base-files/​clean
-</code></​WRAP>+</​code>​
  
 Clean luci. Clean luci.
-<WRAP prewrap 1000px><​code>​ +<​code>​ 
-make package/feeds/luci/​luci/​clean +make package/​luci/​clean 
-</code></​WRAP>+</​code>​
  
 ===== Examples ===== ===== Examples =====
Line 263: Line 340:
  
 ===== Troubleshooting ===== ===== Troubleshooting =====
-First get more information on the problem using the make option ''"​make V=s"''​.+ 
 +  * Beware of unusual environment variables such as 
 +     * ''​GREP_OPTIONS''​ which should not have ''​--initial-tab''​ or other options affecting its output 
 +     * **''​SED''​ should not be set.  If it is, run `unset SED` before compiling.** (See [[https://​dev.openwrt.org/​ticket/​10612|Ticket 10612]].) 
 + 
 +  * First get more information on the problem using the make option ''"​make V=s"''​
 + 
 + 
 +==== Errors building gcc ==== 
 +If the build fails with errors that include "​[s-attrib] Killed"​ and "​[all-gcc] Error 2" while compiling gcc, this indicates you are out of disk space or RAM. This could be likely if you are building within a virtual machine with < 1 Gb RAM allocated and no swap.
  
 ==== Missing source code file, due to download problems ==== ==== Missing source code file, due to download problems ====
 First check if the URL path in the make file contains a trailing slash, then try with it removed (helped several times). First check if the URL path in the make file contains a trailing slash, then try with it removed (helped several times).
-Otherwise try to download the source code manually and put it into "​dl"​ directory.+Otherwise try to download the [[http://​www.acalculator.com|source]] code manually and put it into "​dl"​ directory.
  
 ==== Compilation errors ==== ==== Compilation errors ====
Line 275: Line 361:
 Compiling with make -j ... sometimes gives random errors. Try compiling without -j first before reporting the problem. Compiling with make -j ... sometimes gives random errors. Try compiling without -j first before reporting the problem.
  
-====  Bad environment variables ==== +
-  * ''​GREP_OPTIONS''​ should not have ''​--initial-tab''​ or other options affecting its output +
-  * **''​SED''​ should not be set.  If it is, run `unset SED` before compiling.** (See [[https://​dev.openwrt.org/​ticket/​10612|Ticket 10612]].) +
-  * others?+
  
 ==== I can't find my <​package>​ in menuconfig ==== ==== I can't find my <​package>​ in menuconfig ====
-  - Have you run this command? [[doc:​howto:​build#​updating.feeds|See this.]] ​<WRAP prewrap 1000px><​code>​./​scripts/​feeds install <​package></​code></​WRAP+  - Have you run this command? [[doc:​howto:​build#​updating.feeds|See this.]] <​code>​./​scripts/​feeds install <​package></​code>​ 
-  - Maybe you are not looking for it in the right submenu. See the ''​Makefile''​ of the package to find out. <WRAP prewrap 1000px><​code>​cat ​package/feeds/packages/<​package>/​Makefile</​code></​WRAP> You are looking for this: \\ ''​define Package/<​package>/​Default+  - Maybe you are not looking for it in the right submenu. See the ''​Makefile''​ of the package to find out. <​code>​cat feeds/<​feedname>​/<​package>/​Makefile</​code>​ You are looking for this: \\ ''​define Package/<​package>/​Default
   SUBMENU:​=**Firewall**   SUBMENU:​=**Firewall**
   SECTION:​=net   SECTION:​=net
   CATEGORY:​=**Network**''​   CATEGORY:​=**Network**''​
-  - Menuconfig appears to cache package lists and (especially) profiles. Try deleting the ''<​buildroot_dir>/​tmp''​ directory and then running ''​make menuconfig''​ again. ​<WRAP prewrap 1000px><​code>​+  - Menuconfig appears to cache package lists and (especially) profiles. Try deleting the ''<​buildroot_dir>/​tmp''​ directory and then running ''​make menuconfig''​ again. <​code>​
 cd ~/​openwrt/​trunk cd ~/​openwrt/​trunk
 rm -rf tmp rm -rf tmp
-make menuconfig</​code></​WRAP> Also try refreshing your package indexes: ​<WRAP prewrap 1000px><​code>​./​scripts/​feeds update -i</code></​WRAP> The ''​-i''​ is important if you're not using the latest revisions of any packages, as this flag prevents updates from the feed sources. +make menuconfig</​code>​ Also try refreshing your package indexes: <​code>​./​scripts/​feeds update -i</​code>​ The ''​-i''​ is important if you're not using the latest revisions of any packages, as this flag prevents updates from the feed [[http://www.followthesteps.net/​sky-contact-phone-number/ ​sources]].
- +
-====  Error: No rule to make target... ==== +
-Make sure the path starts with ''​package''​ directory and that the path actually exist. The structure of ''​feeds''​ and ''​package/​feeds''​ directory is different. ​[[doc:howto:​build#​building.single.packages|See this.]] +
-  * Wrong: ''​make feeds/​packages/​**utils**/​screen/​compile V=s''​ +
-  * Correct: ''​make **package**/​feeds/​packages/​screen/​compile V=s''​+
  
 ==== WARNING: skipping <​package>​ -- package not selected ==== ==== WARNING: skipping <​package>​ -- package not selected ====
-Run ''​make menuconfig''​ and enable compilation for your package. It should be labeled with ''<​*>''​ or ''<​M>''​ to work correctly. Read [[doc:​howto:​build#​image.configuration]] further up in this article.+Run ''​make menuconfig''​ and enable compilation for your package. It should be labeled with ''<​*>''​ or ''<​M>''​ to work correctly. Read [[doc:​howto:​build#​image.configuration]] further up in this [[http://​www.fixithere.net | article]].
  
  
doc/howto/build.1394054506.txt.bz2 · Last modified: 2014/03/05 22:21 by guraltsev