zoukankan      html  css  js  c++  java
  • Makefile 多个文件生成一个可执行文件

    #LINUXPUBLICPATH = ../public/
    #add wain 2016-01-12
    
    CC := mipsel-linux-gcc
    
    
    EXEC = upsgsm
    # UPSWARNSVROBJS  = gsmprocess.o cloud.o gsm.o cJSON.o gsm_datastructure.o gsm_uart.o md5.o periphery.o public.o ups_gsm.o
    
    
    LIBSPATH = /opt/rampis-mt76x8-gcc7.3.0_musl/openwrt_usr
    
    INCLUDEPATH := -I$(LIBSPATH)/include/ -I/opt/code/L2001_public/release/ramips/include -I$(LIBSPATH)/lib/libiconv-full/include -I./
    #-I./curl/include/
    LIBRARYPATH := -L$(LIBSPATH)/lib/  -L$(LIBSPATH)/lib/libiconv-full/lib
    #-L./curl/lib/
    
    LIBPUBLIC  := /opt/code/L2001_public/release/ramips/lib/libpublic.a
    
    #LDLIBS += $(INCLUDEPATH) $(LIBRARYPATH) -lzlog -ljson-c -lcurl -lz -lpthread 
    LIBS := $(LIBRARYPATH) -lzlog -lz -liconv -ljson-c $(LIBPUBLIC)
    
    # CFLAGS = -Wall -O -g -D EMBED $(INCLUDEPATH) $(SNMPDINCPATH)
    CFLAGS = -Wall -O -g -D EMBED
    
    
    #LIBPUBLIC   = /workdir/guojun/work/V2CODE/L1607_public/source/trunk/libpublic.a
    
    SRCS := $(wildcard *.c) $(wildcard ./src/*.c)
    OBJS := $(patsubst %.c,%.$(TARGET).o, $(SRCS))
    DEPS := $(patsubst %.$(TARGET).o,%.$(TARGET).d, $(OBJS))
    
    all: $(TARGET)/$(EXEC)
    $(TARGET)/$(EXEC): $(DEPS) $(OBJS)
        test -d $(TARGET) || mkdir -p $(TARGET)
        $(CC) -o $(TARGET)/$(EXEC) $(OBJS) $(LIBS)
        
        # test -d ../../release/$(TARGET)/usr/local || mkdir -p ../../release/$(TARGET)/usr/local
        # test -d ../../release/$(TARGET)/usr/local/bin || mkdir -p ../../release/$(TARGET)/usr/local/bin
        # $(STRIP) $@
        # cp  -rf $@ ../../release/$(TARGET)/usr/local/bin
        test -d ../../release/$(TARGET)/bin || mkdir -p ../../release/$(TARGET)/bin
        $(STRIP) $@
        cp  -rf $@ ../../release/$(TARGET)/bin
    
    %.$(TARGET).d : %.c
        $(CC) $(INCLUDEPATH) -MM $< > $@
        $(CC) $(INCLUDEPATH) -MM $< -MQ $@ >> $@
    
    %.$(TARGET).o : %.c public.h
        $(CC) $(CFLAGS) -c $(INCLUDEPATH) -o $@ $<
    
    
    .PHONY: clean
    clean:
        -rm $(TARGET)/$(EXECUTABLE) -f
        -rm $(OBJS)  -f
        -rm $(DEPS) -f
    
    depend : $(DEPS)
        @echo "Dependencies are now up-to-date."
    
    -include $(DEPS)

    参考链接: https://www.gnu.org/software/make/manual/html_node/Automatic-Prerequisites.html

  • 相关阅读:
    关于js中this的指向问题
    关于css垂直水平居中的几种方法
    个人第一个jquery插件(tips)
    css3实现虚拟三角形
    js-关于唯一ID的创建
    面试题
    new Promise()
    JSON.parse()、JSON.stringify()和eval()的作用
    vue-router路由导航
    NodeJS
  • 原文地址:https://www.cnblogs.com/hzijone/p/13094604.html
Copyright © 2011-2022 走看看