• 转载的makefile


    #set your project name
    PRJ_NAME = MGameServer
    #set your project type : choose one below
    PRJ_TYPE = g++ -o
    #PRJ_TYPE =
    #PRJ_TYPE = ar -r

    #set Debug or Release
    Compile_Flag = Debug
    #Compile_Flag = Release

    #set your output path
    Output:= bin

    #set your source folder
    SRC := SRC
    #add the lib you used here
    #LIBS := -lLib1 -lLib2 -lLib3
    LIBS := -levent -llua -lmysqlclient -levent_pthreads  -lpthread
    #LIBPATH := -Lpath1 -Lpath2 -Lpath3
    LIBPATH := -L/root/mysql/lib -L/usr/libevent/lib
    INCLUDEPATH := -I/usr/libevent/include -I/root/workspace/mysql/include -I/root/workspace/GameServer/include 
    # INCLUDEPATH := -I/usr/lib/XXX/include

    ###################################
    #DON"T MODIFY THE BELOWS

    #combine output folder
    FinalOutput := $(Output)/$(Compile_Flag)/

    #list all dirs
    SUBDIRS := $(shell find $(SRC) -type d)
    #flags in makefile
    DEBUG_FLAG = -std=c++0x -O0 -g3 -Wall -c -fmessage-length=0
    RELEASE_FLAG = -std=c++0x  -O3 -Wall -c -fmessage-length=0
    RM := rm -rf

    #set compile flag
    ifeq ($(Compile_Flag),Debug)
    CFLAGS := $(DEBUG_FLAG)
    else
    CFLAGS := $(RELEASE_FLAG)
    endif

    #prepare files
    CPP_SRCS:=$(shell find $(SRC) -name *.cpp)
    OBJS:=$(CPP_SRCS:%.cpp=$(FinalOutput)%.o)

    #all target
    all: dir $(FinalOutput)$(PRJ_NAME)
    dir:
     mkdir -p $(FinalOutput);
     for val in $(SUBDIRS);do
       mkdir -p $(FinalOutput)$${val};
     done;

    #tool invocations
    $(FinalOutput)$(PRJ_NAME):$(OBJS)
     @echo 'Building target: $@'
     @echo 'Invoking:GCC C++ Linker'
     $(PRJ_TYPE) $(LIBPATH) -o"$@" $^ $(LIBS)
     @echo 'Finished building target: $@'
     @echo ' '

    $(FinalOutput)%o:./%cpp
     @echo 'Building file: $<'
     @echo 'Invoking:GCC C++ Compiler'
     g++ $(CFLAGS) $(INCLUDEPATH) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
     @echo 'Finished building: $<'
     @echo ' '

    #other targets
    clean:
     -$(RM) $(Output)/*
     -@echo ' '
    .PHONY:all clean
    .SECONDARY:

  • 相关阅读:
    Redis命令——小白学习 Redis 数据库日记(2017-06-13)
    Buses(形容城市公车交通情况)
    Things you need to prepare before going to airport
    bathroom words
    this指针
    友元
    成员对象和封闭类
    静态成员变量和静态成员函数、 常量对象和常量成员函数
    C++类
    shell选择语句、循环语句
  • 原文地址:https://www.cnblogs.com/liulebao/p/3382150.html
Copyright © 2020-2023  润新知