• Yocto开发笔记之《Makefile编写》(QQ交流群:519230208)


    开了一个交流群,欢迎爱好者和开发者一起交流,转载请注明出处。

    QQ群:519230208,为避免广告骚扰,申请时请注明 “开发者” 字样

    ========================================================

    automake和autoconf 生成大型项目的makefile编写 
    http://blog.csdn.net/fuli1215/article/details/6399175

    使用GNU Autoconf/Automake创建Makefile
    http://blog.csdn.net/exbob/article/details/6998430

    Makefile.am

    bin_PROGRAMS = bterminal sample_nmea
    
    bterminal_SOURCES = bterminal.c ble_serial.c
    bterminal_LDADD=../libs/libnmea.a
    
    sample_nmea_SOURCES = sample_nmea.c
    sample_nmea_LDADD=../libs/libnmea.a
    
    INCLUDES= -I../include
    
    AM_CFLAGS = @bterminal_CFLAGS@
    AM_LDFLAGS = @bterminal_LIBS@
    
    CLEANFILES = *~ 

    linux编程一定要会写makefile,否则工程不能织成网,每个文件只能单兵作战

    红色标记部分需要认真理解

    CC = gcc 
    
    #CC=arm-poky-linux-gnueabi-gcc --sysroot=/home/summer/test-yocto/qemuarm
    #LD=arm-poky-linux-gnueabi-ld --sysroot=/home/summer/test-yocto/qemuarm
    #CFLAGS=-O2 -pipe -g -feliminate-unused-debug-types
    #CXXFLAGS=-O2 -pipe -g -feliminate-unused-debug-types
     
    BIN = lib/libgpsserial.a 
    MODULES = gpsserial 
    SAMPLES = gpsreader
     
    OBJ = $(MODULES:%=build/gpsserial_gcc/%.o) 
    LINKOBJ = $(OBJ) $(RES)
    
    SMPLS = $(SAMPLES:%=samples_%)
    SMPLOBJ = $(SAMPLES:%=samples/%/main.o)
    
    INCS = -I include 
    LIBS = -lm -Llib -lgpsserial -Llibs  -lnmea
    
    .PHONY: all all-before all-after clean clean-custom doc
     
    all: all-before $(BIN) samples all-after 
    
    all-before:
        mkdir -p build/gpsserial_gcc
    
    clean: clean-custom 
        rm -f $(LINKOBJ) $(BIN) $(SMPLOBJ) $(SMPLS)
    
    doc:
        $(MAKE) -C doc
        
    remake: clean all
    
    $(BIN): $(LINKOBJ)
        ar rsc $@ $^
        ranlib $@
    
    build/gpsserial_gcc/%.o: src/%.c 
        $(CC) $(INCS) -c $< -o $@
    
    samples: $(SMPLS)
    
    samples_%: samples/%/main.o
        $(CC) $< $(LIBS) -o build/$@ -lm
    
    samples/%/main.o: samples/%/main.c
        $(CC) $(INCS)  -c $< -o $@
  • 相关阅读:
    Codeforces Round #436 (Div. 2)
    【bzoj1090】 [SCOI2003]字符串折叠
    【并查集】食物链(带权并查集)
    【图论】二分图
    【图论】关押罪犯
    关于图论的若干巴拉巴拉
    一系列的入门and一堆吐槽
    【分块】八
    9-30刷题记录
    bzoj5055
  • 原文地址:https://www.cnblogs.com/alanfang/p/5131037.html
Copyright © 2020-2023  润新知