More complex makefile with the LDS script programming

Source: Internet
Author: User
Tags builtin

First look at a makefile Example:

1 /*identify the toolchain and take a simple alias for it*/2CC = arm-linux-GCC  3LD = arm-linux-LD4AR = arm-linux-ar5Objcopy = arm-linux-objcopy6OBJDUMP = arm-linux-Objdump7 /*indicates the location of the header file*/8Includedir: = $ (shellpwd)/include9 /*-wall hint Warning,-O2 represents optimization options, optimal optimization,-fno-builtin represents itself to implement some library functions, if not added this option will conflict*/TenCFLAGS: =-wall-o2-fno-Builtin One /*-nostdinc,-nostdlib means that the two libraries are not used, and-i$ (includedir) means linking to the header file*/ ACppflags: =-nostdinc-i$ (Includedir)-nostdlib -  - /*make these defined variables effective*/ the export CC AR LD objcopy OBJDUMP includedir CFLAGS cppflags -  - /** Compile the. o file and the. A static library generated under the lib/directory together into an. elf file*/ -OBJS: = START.O main.o uart.o clock.o lcd.o lib/LIBC.A +  - Lcd70.bin: $ (OBJS) +${LD}-tlcd70.lds-o lcd70.elf $^//The main place used here is the location of the code indicated by Tlcd70.lds, the linker script.  A${objcopy}-o binary-S lcd70.elf [email protected] at${objdump}-D lcd70.elf >Lcd70.dis -  - /*indicates pseudo-target, i.e. no dependent file*/ -. phony:lib/LIBC.A - /*go to the directory to execute make command production. A static library*/ -lib/LIBC.A: inCD Lib; Make; cd.. -      to%.o:%. C +${CC} $ (cppflags) $ (CFLAGS)-c-o [email protected] $< -  the%.o:%. S *${CC} $ (cppflags) $ (CFLAGS)-c-o [email protected] $< $ Panax Notoginseng Clean : -      MakeClean-C Lib the     RM-F *.bin *.elf *.dis *.O

Makefile for production of static libraries :

string . O VSPRINTF.O /* production of static libraries */ LIBC.A: $ (OBJS)     -r-o [email protected] $^ /* generates. o files for. C and. s files */%.o:%. C    -c-o [email protected ] $<%.o:%. S    -c-o [email protected] $< clean:    rm -F LIBC.A *.o    

Linker script:

sections{    0x40000000;  // indicates the start run address of the program     . Text: {        START.O// indicates the first file to run        * (. Text)    }    . Data: {        * (. data)    }    . BSS: {        * (. BSS)    }    }

  

More complex makefile with the LDS script programming

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.