U-BOOT master makefile code

Source: Internet
Author: User
Tags srec

#
# (C) Copyright 2000-2006
# Wolfgang Denk, denx software engineering, wd@denx.de.
#
# See File credits for list of people who contributed to this
# Project.
#
# This program is free software; you can redistribute it and/or
# Modify it under the terms of the GNU General Public License
# Published by the Free Software foundatio; either version 2
# The license, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# But without any warranty; without even the implied warranty
# Merchantability or fitness for a special purpose. See
# GNU General Public License for more details.
#
# You shoshould have written ed a copy of the GNU General Public License
# Along with this program; if not, write to the Free Software
# Foundation, inc., 59 temple place, Suite 330, Boston,
# Ma 02111-1307 USA
#

Version = 1
Patchlevel = 1
Sublevel = 6
Extraversion =
U_boot_version = $ (Version). $ (patchlevel). $ (sublevel) $ (extraversion)
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 /)

Hostos: = $ (shell uname-S | tr '[: Upper:] ''[: lower:]' |/
Sed-E's // (cygwin/). */cygwin /')

Export hostarch Hostos

# Deal with colliding definitions from tcsh etc.
Vendor =

######################################## #################################
#
# U-boot build supports producing a object files to the separate external
# Directory. Two use cases are supported:
#
#1) add O = to the make command line
# 'Make o =/tmp/build all'
#
#2) Set environement variable build_dir to point to the desired location
# 'Export build_dir =/tmp/build'
# 'Make'
#
# The second approach can also be used with a makeall script
# 'Export build_dir =/tmp/build'
# './Makeall'
#
# Command line 'o = 'setting overrides build_dir environent variable.
#
# When none of the above methods is used the local build is saved med and
# The object files are placed in the source directory.
#

Ifdef o // If O is defined
Ifeq ("$ (Origin O)", "command line ")
Build_dir: = $ (o)
Endif
Endif

Ifneq ($ (build_dir ),)
Saved-output: = $ (build_dir)

# Attempt to create a output directory.
$ (Shell [-d $ {build_dir}] | mkdir-p $ {build_dir })

# Verify if it was successful.
Build_dir: = $ (shell CD $ (build_dir) &/bin/pwd)
$ (If $ (build_dir), $ (error output directory "$ (saved-output)" does not exist ))
Endif # ifneq ($ (build_dir ),)

# Objtree and lndir stores the directory of generated files, and the srctree and topdir directories store the source code.
Objtree: =$ (if $ (build_dir), $ (build_dir), $ (curdir ))
Srctree: = $ (curdir)
Topdir: = $ (srctree)
Lndir: = $ (objtree)
Export topdir srctree objtree

# Mkconfig point to the mkconfig script in the top-level directory
Mkconfig: = $ (srctree)/mkconfig
Export mkconfig

Ifneq ($ (objtree), $ (srctree ))
Remote_build: = 1
Export remote_build
Endif

# $ (OBJ) and (SRC) are defined in config. mk but here in main makefile
# We also need them before config. mk is wrongly ded which is the case
# Some targets like unconfig, clean, clobber, distclean, etc.
Ifneq ($ (objtree), $ (srctree ))
OBJ: = $ (objtree )/
SRC: = $ (srctree )/
Else
OBJ: =
SRC: =
Endif
Export OBJ SRC

######################################## #################################

# Include/config. mk, which is equivalent to three variables named Arch, board, and CPU in makefile.
Ifeq ($ (objtree)/include/config. mk, $ (wildcard $ (objtree)/include/config. mk ))

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

# The following is a cross-Compiler
Ifndef cross_compile
Ifeq ($ (hostarch), PPC)
Cross_compile =
Else
Ifeq ($ (ARCH), PPC)
Cross_compile = PowerPC-Linux-
Endif
Ifeq ($ (ARCH), arm)
Cross_compile = arm-Linux-
Endif
Ifeq ($ (ARCH), i386)
Ifeq ($ (hostarch), i386)
Cross_compile =
Else
Cross_compile = i386-linux-
Endif
Endif
Ifeq ($ (ARCH), MIPS)
Cross_compile = mips_4kc-
Endif
Ifeq ($ (ARCH), NiO)
Cross_compile = nios-elf-
Endif
Ifeq ($ (ARCH), nios2)
Cross_compile = nios2-elf-
Endif
Ifeq ($ (ARCH), m68k)
Cross_compile = m68k-elf-
Endif
Ifeq ($ (ARCH), microblaze)
Cross_compile = Mb-
Endif
Ifeq ($ (ARCH), Blackfin)
Cross_compile = bfin-elf-
Endif
Ifeq ($ (ARCH), avr32)
Cross_compile = avr32-
Endif
Endif
Endif

Export cross_compile

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

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

Objs = CPU/$ (CPU)/start. O // The sequence is very important, and start. O must be placed at the beginning.
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), mpc83xx)
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 ))

Required library files:

Libs = lib_generic/libgeneric.
Libs + = Board/$ (boarddir)/Lib $ (board).
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
Libs + = Drivers/USB/libusb.
Libs + = Drivers/sk98lin/libsk98lin.
Libs + = Common/libcommon.
Libs + = $ (boardlibs)

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

# Based on the arch, CPU, board, and SOC variables defined in the include/config. mk File above.
# The Directory files on which the hardware platform depends can be determined based on these definitions.
# Smdk2410 platform related directories and corresponding library files are as follows.
# Board/smdk2410/: library file board/smdk2410/libsmdk2410.a
# CPU/ARM920T/: library file CPU/ARM920T/libarm920t.
# CPU/ARM920T/s3c24x0/: library file CPU/ARM920T/s3c24x0/libs3c24x0.
# Lib_arm/: library file lib_arm/libarm.
# Include/ASM-arm/: The following two are header files.
# Include/configs/smdk2410.h

 

# Add GCC lib
Platform_libs + =-L $ (shell dirname '$ (CC) $ (cflags)-print-libgcc-file-name ') -lgcc-LC-L/usr/local/ARM/4.3.2/ARM-None-Linux-gnueabi/libc/armv4t/usr/lib

# The "Tools" are needed early, so put this first
# Don't include stuff already done in $ (libs)
@ Execute the make file under the tools, examples, post, post/CPU subdirectory
Subdirs = tools/
Examples/
Post/
Post/CPU
. Phony: $ (subdirs)

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 ))

######################################## #################################
######################################## #################################
# Final image files:

All = $ (OBJ) u-boot.srec $ (OBJ) u-boot.bin $ (OBJ) system. Map $ (u_boot_nand)

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 $ <$ @

$ (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): @ CPU/start. o
Echo $ (objs)
$ (Make)-c cpu/$ (CPU) $ (if $ (remote_build), $ @, $ (notdir $ @))

$ (Libs): @ dependency target $ (libs). There are too many targets, all of which are the library files *. A in each subdirectory. Execute make in the corresponding subdirectory to complete the tasks:
$ (Make)-C $ (DIR $ (SUBST $ (OBJ), $ @))

USB:
$ (Make)-C Drivers/USB

$ (Subdirs): @ pseudo-target subdirs: Execute make files under the tools, examples, post, post/CPU sub-directories.
$ (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

Analyze the generation of the most critical U-boot ELF File image: (for details, see makefile)

Version: @ dependency target version: Generate version information to version_file.
@ 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: @ dependency target depend: generate the. Depend file for each subdirectory, And. Depend lists the dependent files of each target file.
@ Generate method: Call make _ depend of each subdirectory.
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

######################################## #################################
Else
All $ (OBJ) u-boot.hex $ (OBJ) u-boot.srec $ (OBJ) u-boot.bin/
$ (OBJ) u-boot.img $ (OBJ) u-boot.dis $ (OBJ) U-boot/
$ (Subdirs) version gdbtools Updater env depend/
Dep tags ctags etags $ (OBJ) system. MAP:
@ Echo "system not configured-see readme"> & 2
@ Exit 1
Endif

. Phony: changelog
Changelog:
Git log -- no-merges U-Boot-1_1_5 .. |/
Unexpand-A | sed-E's // S/S * $ // '> $ @

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.