zoukankan      html  css  js  c++  java
  • 【makefile】01 经典应用示例

     经典应用示例

    1. 文件结构

    NetServer
    ├── docs
    │   └── images
    │       ├── WebBench_hello.png
    │       ├── WebBench_html.png
    │       ├── wrk_hello_4_iothread_2_workerthread.png
    │       ├── wrk_hello_4_iothread.png
    │       ├── wrk_hello.png
    │       ├── wrk_html_4_iothread_2_workerthread.png
    │       ├── wrk_html_4_iothread.png
    │       └── wrk_html.png
    ├── LICENSE
    ├── Makefile
    ├── NetServer
    │   ├── Channel.cpp
    │   ├── Channel.h
    │   ├── coroutine
    │   │   ├── coroutine.cpp
    │   │   ├── coroutine-C-style
    │   │   │   ├── coroutine.cpp
    │   │   │   ├── coroutine.h
    │   │   │   └── coroutine_test.cpp
    │   │   ├── coroutine.h
    │   │   ├── coroutine_test.cpp
    │   │   ├── LICENSE
    │   │   └── README.md
    │   ├── EchoServer.cpp
    │   ├── EchoServer.h
    │   ├── EventLoop.cpp
    │   ├── EventLoop.h
    │   ├── EventLoopThread.cpp
    │   ├── EventLoopThread.h
    │   ├── EventLoopThreadPool.cpp
    │   ├── EventLoopThreadPool.h
    │   ├── HttpServer.cpp
    │   ├── HttpServer.h
    │   ├── HttpSession.cpp
    │   ├── HttpSession.h
    │   ├── index.html
    │   ├── log
    │   │   ├── LICENSE
    │   │   ├── logger.cpp
    │   │   ├── logger.h
    │   │   ├── logtest.cpp
    │   │   └── README.md
    │   ├── main.cpp
    │   ├── Poller.cpp
    │   ├── Poller.h
    │   ├── Socket.cpp
    │   ├── Socket.h
    │   ├── TcpConnection.cpp
    │   ├── TcpConnection.h
    │   ├── TcpServer.cpp
    │   ├── TcpServer.h
    │   ├── ThreadPool.cpp
    │   ├── ThreadPool.h
    │   ├── Timer.cpp
    │   ├── Timer.h
    │   ├── TimerManager.cpp
    │   └── TimerManager.h
    └── README.md

    2. makefile文件书写:

     1 IR_BIN = .
     2 DIR_OBJ = ./obj
     3 DIR_SRC = ./NetServer
     4 
     5 SRC = $(wildcard $(DIR_SRC)/*.cpp)
     6 OBJ = $(patsubst %.cpp,$(DIR_OBJ)/%.o,$(notdir $(SRC)))
     7 
     8 
     9 CXX_FLAG = -g -Wall -std=c++11 -pthread -O3
    10 CC = g++
    11 
    12 TARGET = httpserver
    13 
    14 $(DIR_BIN)/$(TARGET) : $(OBJ)
    15     $(CC) $(CXX_FLAG) -o $@ $^
    16 
    17 $(DIR_OBJ)/%.o : $(DIR_SRC)/%.cpp
    18     if [ ! -d $(DIR_OBJ) ];    then mkdir -p $(DIR_OBJ); fi;
    19     $(CC) $(CXX_FLAG) -c $< -o $@
    20 
    21 .PHONY : clean
    22 clean : 
    23     -rm -rf $(DIR_OBJ)

    参考资料

    1. NetServer

    2. 跟我一起写Makefile

  • 相关阅读:
    java第五周作业
    ajax初探--实现简单实时验证
    Html+CSS二周目--->常用概念
    Html+CSS--->第一周初探
    Servlet细节整合
    多线程基础
    设计模式之单例模式(Singleton)
    配置文件Java读写
    Java基础之IO流
    JDBC基础
  • 原文地址:https://www.cnblogs.com/sunbines/p/15422843.html
Copyright © 2011-2022 走看看