Uboot1.1.6 top-level makefile

Source: Internet
Author: User
Tags character classes crc32 spl srec

 

Version = 1 // main version
Patchlevel = 1 // version number
Sublevel = 6 // corrected the version number
Extraversion = // version number Extension
U_boot_version = $ (Version). $ (patchlevel). $ (sublevel) $ (extraversion) // The uboot version is 1.1.6.
Version_file = $ (OBJ) include/version_autogenerated.h

Hostarch: =$ (shell uname-M | \
Sed-e s/I .86/i386 /\
-E s/sun4u/sparc64 /\
-E s/arm. */ARM /\
-E s/sa110/ARM /\
-E s/PowerPC/PPC /\
-E s/macppc/PPC /)
First, run uname-m to get i686, and send it to SED through the pipeline. Then, the SED command will execute sed-e s/I .86/i386/and replace i686 with i386, the final result is hostarch = I .pdf.
I686 indicates Ubuntu, and sed indicates replacement.

Hostos: = $ (shell uname-S | tr '[: Upper:] ''[: lower:]' | \
Sed-E's/\ (cygwin \). */cygwin /')
First, run uname-s to check the system of the Development Platform. The result is Linux, and then the tr command is sent to the tr command through the pipeline. The TR command uses the character classes [: lower:] and [: Upper:]. convert the Linux string to Linux, and then use the SED command. the final result is Hostos = Linux.

Export hostarch Hostos
These variables are passed to the makefile of the next layer.

Uboot supports generating the target file in an external Folder, which can be implemented using two commands.
1. Add the O = command
2. Set the environment variable build_dir.
If neither of the above methods is defined, it will be stored in the source code directory.
Ifdef o
Ifeq ("$ (Origin O)", "command line ")
Build_dir: = $ (o)
Endif
Endif
The above means that if the O command is defined, and the directory specified by O = is the same as the directory specified by command line
Build_dir is the directory defined by O =.
Unlike other functions, the origin function does not operate on the value of a variable. It only tells you where the variable comes from.

Ifneq ($ (build_dir ),)
Saved-output: = $ (build_dir)
Then judge whether build_dir is 0. If it is not 0, save-output stores the output directory specified by build_dir.

# Attempt to create a output directory.
$ (Shell [-d $ {build_dir}] | mkdir-p $ {build_dir })
Build_dir is not a directory. If not, it is created. [] is a condition judgment statement.

Build_dir: = $ (shell CD $ (build_dir) &/bin/pwd)
Open this directory first, call PWD to display the current path, and then assign the PATH value to build_dir
$ (If $ (build_dir), $ (error output directory "$ (saved-output)" does not exist ))
Endif # ifneq ($ (build_dir ),)
If build_dir does not exist, the directory does not exist in the saved-output is output.

Objtree: =$ (if $ (build_dir), $ (build_dir), $ (curdir ))
Srctree: = $ (curdir)
Topdir: = $ (srctree)
Lndir: = $ (objtree)
Export topdir srctree objtree
The three directories opdir srctree objtree will be called for makefile in the lower layer. You need to specify and export
Objtree and lndir are the directories for storing generated files, and topdir and srctree are the directories where the source code is located.

Mkconfig: = $ (srctree)/mkconfig
Export mkconfig
Definition variable mkconfig: this variable points to a script, that is, mkconfig in the top-level Source Code directory.

Ifneq ($ (objtree), $ (srctree ))
Remote_build: = 1
Export remote_build
Endif
If the output directory does not match the source directory, set the remote_build item and export

Ifneq ($ (objtree), $ (srctree ))
OBJ: = $ (objtree )/
SRC: = $ (srctree )/
Else
OBJ: =
SRC: =
Endif
Export OBJ SRC
If the output directory objtree and srctree are different from the current uboot directory, assign values to OBJ and SRC. Otherwise, OBJ and SRC are empty.
Obj src is defined in config. mk in the main directory, but it is also required before the main makefile contains config. mk, such as unconfig, clean, clobber, and distclean.

Ifeq ($ (objtree)/include/config. mk, $ (wildcard $ (objtree)/include/config. mk ))
Before analyzing this and the following commands, we need to understand that before compiling the U-BOOT, We need to execute # Make smdk6410_config
Smdk6410_config is a target of makefile and is defined as follows:
Smdk6410_config: unconfig
@ $ (Mkconfig) $ (@: _ Config =) arm cloud64xx smdk6410 Samsung cloud6410
Unconfig:
@ RM-F $ (OBJ) include/config. h $ (OBJ) include/config. mk \
$ (OBJ) Board/*/config. tmp $ (OBJ) Board/*/config. tmp
First, run unconfig. obj src is defined above. This command cleans up the header files generated during the last run of make * _ config and the inclusion files of makefile. Mainly include/config. h and include/config. mk files.

Then run @ $ (mkconfig) $ (@: _ Config =) arm cloud64xx smdk6410 Samsung cloud6410
Mkconfig is the mkcofig script file in the top-level directory. The last five are input parameters. Mkcofig in the top-level directory will be analyzed later
Generate a makefile that contains the include/config. mk file. Use five input parameters to define five variables.
Arch = arm
CPU = cloud64xx
Board = smdk6410
Vendor = Samsung
SOC = cloud6410

Generate the include/config. h header file with only one line:
# Include "config/smdk6410.h"

# Load arch, board, and CPU Configuration
Include $ (objtree)/include/config. mk
Export arch CPU board vendor SOC
Contains include/config. mk, and exports the arch CPU board vendor SOC variables.

Ifndef cross_compile
Ifeq ($ (ARCH), arm) // arch = arm
Cross_compile = arm-Linux-
Endif
Endif

Cross_compile =/usr/local/ARM/4.2.2-Eabi/usr/bin/ARM-Linux-
Export cross_compile

Specify the cross-compiler prefix. I only wrote the cross-compiler prefix related to arm.
/Usr/local/ARM/4.2.2-Eabi/usr/bin/This directory is the directory for installing the Cross Compiler

# Load other configuration
Include $ (topdir)/config. mk
Contains config. mk in the top-level directory. This file mainly defines cross-compiler and options and compilation rules.
Analyze config. mk in the top-level directory later

The following are the target files and library files required by uboot. $ (CPU) has specified CPU = initi64xx
The associated vendor = Samsung

# U-boot objects... order is important (I. e. Start must be first)

Objs = CPU/$ (CPU)/start. o
Ifeq ($ (CPU), i386)
Objs + = CPU/$ (CPU)/start16.o
Objs + = CPU/$ (CPU)/reset. o
Endif
Ifeq ($ (CPU), ppc4xx)
Objs + = CPU/$ (CPU)/resetvec. o
Endif
Ifeq ($ (CPU), mpc85xx)
Objs + = CPU/$ (CPU)/resetvec. o
Endif
Ifeq ($ (CPU), mpc86xx)
Objs + = CPU/$ (CPU)/resetvec. o
Endif
Ifeq ($ (CPU), BF533)
Objs + = CPU/$ (CPU)/start1.o CPU/$ (CPU)/interrupt. o cpu/$ (CPU)/cache. o
Objs + = CPU/$ (CPU)/cplbhdlr. o cpu/$ (CPU)/cplbmgr. o cpu/$ (CPU)/flush. o
Endif

Objs: =$ (addprefix $ (OBJ), $ (objs ))
Addprefix: adds a prefix to a function.

Library files are generated by makefiles in various directories. These files are required for Link
The directories involved in these files include lib_generic, board, CPU, lib_arm, FS, net, disk, RTC, DTT, drivers, post, and common.
Replace the following information related to the platform
$ (ARCH) = arm
$ (CPU) = maid
$ (Board) = smdk6410
$ (Vendor) = Samsung
$ (SOC) = cloud6410

Libs = lib_generic/libgeneric.
Libs + = Board/$ (boarddir)/Lib $ (board).
Boarddir seems to be vendor = Samsung
Libs + = CPU/$ (CPU)/Lib $ (CPU).
Ifdef SOC
Libs + = CPU/$ (CPU)/$ (SOC)/Lib $ (SOC).
Endif
Libs + = lib _ $ (ARCH)/Lib $ (ARCH).
Libs + = FS/cramfs/libcramfs. A fs/fat/libfat. A fs/fdos/libfdos. A fs/jffs2/libjffs2.a \
FS/reiserfs/libreiserfs. A fs/ext2/libext2fs.
Libs + = net/Libnet.
Libs + = Disk/libdisk.
Libs + = RTC/librtc.
Libs + = DTT/libdtt.
Libs + = Drivers/libdrivers.
Libs + = Drivers/NAND/libnand.
Libs + = Drivers/nand_legacy/libnand_legacy.a
# Add to support onenand. By scsuh
Libs + = Drivers/onenand/libonenand.
Ifeq ($ (CPU), mpc83xx)
Libs + = Drivers/QE.
Endif
Libs + = Drivers/sk98lin/libsk98lin.
Libs + = post/libpost. A post/CPU/libcpu.
Libs + = Common/libcommon.
Libs + = $ (boardlibs)

Libs: =$ (addprefix $ (OBJ), $ (libs ))
. Phony: $ (libs)

When the GCC library is added, both CC and cflags are the implicit variables of make. CC indicates the C compiler, and cflags indicates the command line parameters when the CC is executed.
# Add GCC lib
Platform_libs + =-L $ (shell dirname '$ (CC) $ (cflags)-print-libgcc-file-name')-lgcc

# The "Tools" are needed early, so put this first
# Don't include stuff already done in $ (libs)
Subdirs = tools \
Examples \
Post \
Post/CPU
. Phony: $ (subdirs)
. What is phony's pseudo-goal?

Ifeq ($ (config_nand_u_boot), Y)
Nand_spl = nand_spl
U_boot_nand = $ (OBJ) u-boot-nand.bin
Endif

_ Objs: = $ (SUBST $ (OBJ), $ (objs ))
_ Libs: = $ (SUBST $ (OBJ), $ (libs ))
$ (SUBST text, to, from) string replacement function, leave $ (objs) in $ (OBJ) empty

The following is the final generation of various image files
All = $ (OBJ) u-boot.srec $ (OBJ) u-boot.bin $ (OBJ) system. Map $ (u_boot_nand)
The final file to be generated, u_boot_nand defined above, for u-boot-nand.bin

All depends on $ (all) to generate the image file. Pay attention to various dependencies.
ALL: $ (all)

$ (OBJ) u-boot.hex: $ (OBJ) U-boot
$ (Objcopy) $ {objcflags}-O ihex $ <$ @

$ (OBJ) u-boot.srec: $ (OBJ) U-boot
$ (Objcopy) $ {objcflags}-o srec $ <$ @

$ (OBJ) u-boot.bin: $ (OBJ) U-boot
$ (Objcopy) $ {objcflags}-O binary $ <$ @
$ (Objdump)-d $ <>$ <. Dis

$ (OBJ) u-boot.img: $ (OBJ) u-boot.bin
./Tools/mkimage-A $ (ARCH)-T Firmware-C none \
-A $ (text_base)-E 0 \
-N $ (shell sed-n-e's/. * u_boot_version // P' $ (version_file) | \
Sed-E's/"[] * $/for $ (board) Board "/')\
-D $ <$ @

$ (OBJ) u-boot.dis: $ (OBJ) U-boot
$ (Objdump)-d $ <>$ @

$ (OBJ) U-boot: depend version $ (subdirs) $ (objs) $ (libs) $ (ldscript)
Undef_sym = '$ (objdump)-x $ (libs) | sed-n-e's /. * \ (_ u_boot_cmd _. * \)/-U \ 1/P' | sort | uniq ';\
CD $ (lndir) & $ (LD) $ (ldflags) $ undef_sym $ (_ objs )\
-- Start-group $ (_ libs) -- end-group $ (platform_libs )\
-Map u-boot.map-o u-boot

$ (Objs ):
$ (Make)-c cpu/$ (CPU) $ (if $ (remote_build), $ @, $ (notdir $ @))

$ (Libs ):
$ (Make)-C $ (DIR $ (SUBST $ (OBJ), $ @))

$ (Subdirs ):
$ (Make)-C $ @ All

$ (Nand_spl): Version
$ (Make)-C nand_spl/board/$ (boarddir) All

$ (U_boot_nand): $ (nand_spl) $ (OBJ) u-boot.bin
Cat $ (OBJ) nand_spl/u-boot-spl-16k.bin $ (OBJ) u-boot.bin> $ (OBJ) u-boot-nand.bin

Version:
@ Echo-n "# define u_boot_version \" U-Boot ">$ (version_file );\
Echo-n "$ (u_boot_version)" >$ (version_file );\
Echo-N $ (shell $ (config_shell) $ (topdir)/tools/setlocalversion \
$ (Topdir) >>$ (version_file );\
Echo "\" ">>$ (version_file)

Gdbtools:
$ (Make)-C tools/GDB all | Exit 1

Updater:
$ (Make)-C tools/Updater all | Exit 1

Env:
$ (Make)-C tools/ENV all | Exit 1

Depend Dep:
For dir in $ (subdirs); do $ (make)-C $ dir _ depend; done

Tags ctags:
Ctags-w-o $ (objtree)/ctags 'Find $ (subdirs) include \
Lib_generic board/$ (boarddir) CPU/$ (CPU) lib _ $ (ARCH )\
FS/cramfs fs/fat fs/fdos fs/jffs2 \
Net disk rtc dtt drivers Drivers/sk98lin common \
\ (-Name CVS-prune \)-O \ (-name '*. [CH]'-Print \)'

Etags:
Etags-a-o $ (objtree)/etags 'Find $ (subdirs) include \
Lib_generic board/$ (boarddir) CPU/$ (CPU) lib _ $ (ARCH )\
FS/cramfs fs/fat fs/fdos fs/jffs2 \
Net disk rtc dtt drivers Drivers/sk98lin common \
\ (-Name CVS-prune \)-O \ (-name '*. [CH]'-Print \)'

$ (OBJ) system. MAP: $ (OBJ) U-boot
@ $ (Nm) $ <| \
Grep-V '\ (Compiled \) \ | \(\. o $ \) \ | \ ([auw] \) \ | \(\. \. ng $ \) \ | \ (lash [RL] Di \) '| \
Sort> $ (OBJ) system. Map
Next, analyze
Unconfig:
@ RM-F $ (OBJ) include/config. h $ (OBJ) include/config. mk \
$ (OBJ) Board/*/config. tmp $ (OBJ) Board/*/config. tmp
This statement has been analyzed, that is, the first operation in mkconfig is performed, that is, deleting the header file and contained file in the last makexxx operation.

The next very long section is the xxx_config definition related to the platform and the Development Board. For example, when you execute make smdk6410_config
The following definition is found:
Smdk6410_config: unconfig
@ $ (Mkconfig) $ (@: _ Config =) arm cloud64xx smdk6410 Samsung cloud6410

Finally, the definition of the clean command
Clean:
Find $ (objtree)-type F \
\ (-Name 'core'-o-name' *. Bak '-o-name '*~ '\
-O-name '*~ '-O-name'. depend *'\
-O-name '*. O'-o-name' *. A' \)-Print \
| Xargs Rm-F
Rm-f u-boot *
Rm-F $ (OBJ) Examples/hello_world $ (OBJ) Examples/timer \
$ (OBJ) Examples/eepro100_eeprom $ (OBJ) Examples/sched \
$ (OBJ) Examples/mem_to_mem_idma2intr $ (OBJ) Examples/82559_eeprom \
$ (OBJ) Examples/smc91111_eeprom $ (OBJ) Examples/interrupt \
$ (OBJ) Examples/test_burst
Rm-F $ (OBJ) Tools/img2srec $ (OBJ) Tools/mkimage $ (OBJ) Tools/envcrc \
$ (OBJ) Tools/gen_eth_addr
Rm-F $ (OBJ) Tools/mpc86x_clk $ (OBJ) Tools/NCB
Rm-F $ (OBJ) Tools/easylogo $ (OBJ) Tools/BMP _logo
Rm-F $ (OBJ) Tools/GDB/astest $ (OBJ) Tools/GDB/gdbcont $ (OBJ) Tools/GDB/gdbsend
Rm-F $ (OBJ) Tools/ENV/fw_printenv $ (OBJ) Tools/ENV/fw_setenv
Rm-F $ (OBJ) Board/cray/L1/bootscript. C $ (OBJ) Board/cray/L1/bootscript. Image
Rm-F $ (OBJ) Board/netstar/EEPROM $ (OBJ) Board/netstar/crcek $ (OBJ) Board/netstar/crcit
Rm-F $ (OBJ) Board/netstar/*. SREC $ (OBJ) Board/netstar/*. Bin
Rm-F $ (OBJ) Board/TRAb/trab_fkt $ (OBJ) Board/voiceblue/EEPROM
Rm-F $ (OBJ) Board/maid/u-boot.lds $ (OBJ) Board/integratorcp/u-boot.lds
Rm-F $ (OBJ) include/BMP _logo.h
Rm-F $ (OBJ) nand_spl/U-boot-SPL $ (OBJ) nand_spl/u-boot-spl.map

Clobber: clean
Find $ (objtree)-type F \ (-name. Depend \
-O-name '*. SREC'-o-name '*. bin'-o-name u-boot.img \)\
-Print0 \
| Xargs-0 Rm-F
Rm-F $ (objs) $ (OBJ) *. Bak $ (OBJ) ctags $ (OBJ) etags $ (OBJ) tags $ (OBJ) include/version_autogenerated.h
Rm-fr $ (OBJ )*.*~
Rm-F $ (OBJ) U-boot $ (OBJ) u-boot.map $ (OBJ) u-boot.hex $ (all)
Rm-F $ (OBJ) Tools/crc32.c $ (OBJ) Tools/environment. C $ (OBJ) Tools/ENV/crc32.c
Rm-F $ (OBJ) Tools/inca-Swap-bytes $ (OBJ) CPU/mpc%x/bedbug_603e.c
Rm-F $ (OBJ) include/ASM/proc $ (OBJ) include/ASM/arch $ (OBJ) include/ASM
[! -D $ (objtree)/nand_spl] | find $ (OBJ) nand_spl-lname "*"-print | xargs Rm-F

Ifeq ($ (objtree), $ (srctree ))
Mrproper \
Distclean: clobber unconfig
Else
Mrproper \
Distclean: clobber unconfig
Rm-RF $ (objtree )/*
Endif

Backup:
F = 'basename $ (topdir) '; CD ..;\
Gtar -- force-local-zcvf 'date "has been created using f-0000y-0000m-0000d-0000t.tar.gz" '$ F

Haha, it's over. Next time, let's talk about how uboot generates image files. The task is heavy. Haha

 

Reproduced http://www.cnblogs.com/winceARM/archive/2010/10/16/1853066.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.