• 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

  • 相关阅读:
    Python笔记初识
    visio开发者图形分类个人爱好
    亿图图示与visio结合使用
    xmind visio mindmanager edraw比较
    Pycharm安装步骤
    win32com问题
    Win32.com安装
    Pycharm安装步骤
    Phython笔记初识
    跨域问题解决方案
  • 原文地址:https://www.cnblogs.com/hzijone/p/13094604.html
Copyright © 2020-2023  润新知