微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > GNU ARM汇编--(十七)u-boot的makefile和mkconfig解读

GNU ARM汇编--(十七)u-boot的makefile和mkconfig解读

时间:11-26 来源:互联网 点击:

        1. stackusageifsupported
        2. CFLAGS_STACK:=$(callcc-option,-fstack-usage)
        3. CFLAGS+=$(CFLAGS_STACK)
        4. #$(CPPFLAGS)sets-g,whichcausesgcctopassasuitable-g
        5. #optiontotheassembler.
        6. AFLAGS_DEBUG:=
        7. #turnjbsrintojsrform68k
        8. ifeq($(ARCH),m68k)
        9. ifeq($(findstring3.4,$(shell$(CC)--version)),3.4)
        10. AFLAGS_DEBUG:=-Wa,-gstabs,-S
        11. endif
        12. endif
        13. AFLAGS:=$(AFLAGS_DEBUG)-D__ASSEMBLY__$(CPPFLAGS)
        14. LDFLAGS+=$(PLATFORM_LDFLAGS)
        15. LDFLAGS_FINAL+=-Bstatic
        16. LDFLAGS_u-boot+=-T$(obj)u-boot.lds$(LDFLAGS_FINAL)
        17. ifneq($(CONFIG_SYS_TEXT_BASE),)
        18. LDFLAGS_u-boot+=-Ttext$(CONFIG_SYS_TEXT_BASE)
        19. endif
        20. LDFLAGS_u-boot-spl+=-T$(obj)u-boot-spl.lds$(LDFLAGS_FINAL)
        21. ifneq($(CONFIG_SPL_TEXT_BASE),)
        22. LDFLAGS_u-boot-spl+=-Ttext$(CONFIG_SPL_TEXT_BASE)
        23. endif
        24. #LocationofausableBFDlibrary,wherewedefine"usable"as
        25. #"builtfor${HOST},supports${TARGET}".Sensiblevaluesare
        26. #-Whencross-compiling:therootofthecross-environment
        27. #-Linux/ppc(native):/usr
        28. #-NetBSD/ppc(native):youlose...(mustextractthesefromthe
        29. #binutilsbuilddirectory,plusthenativeandU-Bootinclude
        30. #filesdontlikeeachother)
        31. #
        32. #Sofar,thisisusedonlybytools/gdb/Makefile.
        33. ifeq($(HOSTOS),darwin)
        34. BFD_ROOT_DIR=/usr/local/tools
        35. else
        36. ifeq($(HOSTARCH),$(ARCH))
        37. #native
        38. BFD_ROOT_DIR=/usr
        39. else
        40. #BFD_ROOT_DIR=/LinuxPPC/CDK#Linux/i386
        41. #BFD_ROOT_DIR=/usr/pkg/cross#NetBSD/i386
        42. BFD_ROOT_DIR=/opt/powerpc
        43. endif
        44. endif
        45. #########################################################################
        46. exportHOSTCCHOSTCFLAGSHOSTLDFLAGSPEDCFLAGSHOSTSTRIPCROSS_COMPILE
        47. ASLDCCCPPARNMSTRIPOBJCOPYOBJDUMPMAKE
        48. exportCONFIG_SYS_TEXT_BASEPLATFORM_CPPFLAGSPLATFORM_RELFLAGSCPPFLAGSCFLAGSAFLAGS
        49. #########################################################################
        50. #Allowboardstousecustomoptimizeflagsonaperdir/filebasis
        51. BCURDIR=$(subst$(SRCTREE)/,,$(CURDIR:$(obj)%=%))
        52. ALL_AFLAGS=$(AFLAGS)$(AFLAGS_$(BCURDIR)/$(@F))$(AFLAGS_$(BCURDIR))
        53. ALL_CFLAGS=$(CFLAGS)$(CFLAGS_$(BCURDIR)/$(@F))$(CFLAGS_$(BCURDIR))
        54. EXTRA_CPPFLAGS=$(CPPFLAGS_$(BCURDIR)/$(@F))$(CPPFLAGS_$(BCURDIR))
        55. ALL_CFLAGS+=$(EXTRA_CPPFLAGS)
        56. #The_DEPversionusesthe$
        57. #Seerules.mk
        58. EXTRA_CPPFLAGS_DEP=$(CPPFLAGS_$(BCURDIR)/$(addsuffix.o,$(basename$<)))
        59. $(CPPFLAGS_$(BCURDIR))
        60. $(obj)%.s:%.S
        61. $(CPP)$(ALL_AFLAGS)-o$@$
        62. $(obj)%.o:%.S
        63. $(CC)$(ALL_AFLAGS)-o$@$<-c
        64. $(obj)%.o:%.c
        65. $(CC)$(ALL_CFLAGS)-o$@$<-c
        66. $(obj)%.i:%.c
        67. $(CPP)$(ALL_CFLAGS)-o$@$<-c
        68. $(obj)%.s:%.c
        69. $(CC)$(ALL_CFLAGS)-o$@$<-c-S
        70. #########################################################################
        71. #Ifthelistofobjectstolinkisempty,justcreateanemptybuilt-in.o
        72. cmd_link_o_target=$(if$(strip$1),
        73. $(LD)$(LDFLAGS)-r-o$@$1,
        74. rm-f$@;$(AR)rcs$@)
        75. #########################################################################


        主要是一些变量和函数的定义,编译链接的参数设置以及依赖规则.

        最后分析下make:

        [cpp]view plaincopy

        1. $(obj)include/autoconf.mk.dep:$(obj)include/config.hinclude/common.h
        2. @$(XECHO)Generating$@;
        3. set-e;
        4. :Generatethedependancies;
        5. $(CC)-xc-DDO_DEPS_ONLY-M$(CFLAGS)$(CPPFLAGS)
        6. -MQ$(obj)include/autoconf.mkinclude/common.h>$@
        7. $(obj)include/autoconf.mk:$(obj)include/config.h
        8. @$(XECHO)Generating$@;
        9. set-e;
        10. :Extracttheconfigmacros;
        11. $(CPP)$(CFLAGS)-DDO_DEPS_ONLY-dMinclude/common.h|
        12. sed-n-ftools/scripts/define2mk.sed>$@.tmp&&
        13. mv$@.tmp$@

        第一个是生成include/autoconf.mk的依赖文件

        第二个是根据include/config.h的文件内容,利用tools/scripts/define2mk.sed脚本将所有的CONFIG提取到autoconf.mk文件中

        终极目标是:ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map

        u-boot.srec也是根据u-boot用objcopy工具搞出来的,不知的什么作用

        u-boot.bin也是根据u-boot用objcopy工具搞出来的,最终烧写的二进制bin档

        System.map是符号列表

        [cpp]view plaincopy

        1. $(obj)u-boot.bin:$(obj)u-boot
        2. $(OBJCOPY)${OBJCFLAGS}-Obinary$<$@
        3. $(BOARD_SIZE_CHECK)
        4. ###################################################################################
        5. #要得到最后的

  • Copyright © 2017-2020 微波EDA网 版权所有

    网站地图

    Top