Common makefile Methods

Source: Internet
Author: User

SELF: http://www.cppblog.com/Khan/archive/2007/03/28/20762.html

# Project: m3server
# Makefile created by Khan. Lau

# Application name
Bin = m3server.exe
Lib = m3server.

# Output directory
Configuration = debug
# Configuration = release

# Obtain the current working path of the project
Project_path: = $ (shell CD) \ SRC

CPP = g ++
Cc = gcc

Compiler = $ (CPP)

# C/C ++ LIBRARY PATH
Libpath = "D:/develop/cplus/mingw/lib"

Windres = windres.exe
Res =

Linkobj = $ (configuration)/khan_queue.o \
$ (Configuration)/db_mysql.o \
$ (Configuration)/threadpool. O \
$ (Configuration)/util. O \
$ (Configuration)/m3server. O \
$ (Configuration)/cppobject. O \
$ (Configuration)/cppsocket. O \
$ (Configuration)/cppudpsocket. O \
$ (Configuration)/cppserversocket. O \
$ (Configuration)/readconfig. O \
$ (RES)

# Package path
Libs =-L $ (libpath )\
-Lws2_32 \
-L "d:/develop/cplus/mysql5.0/lib"-lmysql \
-L "d:/develop/cplus/pthread/Pre-built.2/lib"-lpthreadgc2

# C class library path
INCs =-I $ (libpath)/include

# C ++ class library path
Cxxincs =-I $ (libpath)/include \
-I $ (libpath)/include/C ++/3.2.3 \
-I $ (libpath)/include/C ++/3.2.3/backward \
-I $ (libpath)/include/C ++/3.2.3/mingw32 \
-I "d:/develop/cplus/pthread/Pre-built.2/include "\
-I $ (project_path )\
-I "d:/develop/cplus/mysql5.0/include"

Cxxflags =-g-wall $ (cxxincs)
Cflags =-g-wall $ (INCs)
Rm = Rm-F

. Phony: All all-before all-after clean-custom rebuild strip

ALL: All-before $ (LIB) $ (BIN) All-after

Clean: Clean-custom
$ {Rm} $ (linkobj) $ (configuration)/$ (BIN) $ (configuration)/$ (LIB)

# Package static libraries
$ (LIB): $ (linkobj)
Ar-r $ (configuration)/$ (LIB) $ (linkobj)

$ (BIN): $ (linkobj)
$ (Compiler) $ (configuration)/$ (LIB)-o $ (configuration)/$ (BIN) $ (libs)

# Reduce the size of executable files
Strip:
Strip $ (configuration)/$ (BIN)

######################################## ######################################## ##

# Class library
$ (Configuration)/khan_queue.o: src/lib/khan_queue.c
$ (Compiler)-C src/lib/khan_queue.c-o $ (configuration)/khan_queue.o $ (cxxflags)

$ (Configuration)/db_mysql.o: src/lib/db_mysql.c
$ (Compiler)-C src/lib/db_mysql.c-o $ (configuration)/db_mysql.o $ (cxxflags)

$ (Configuration)/threadpool. O: src/lib/threadpool. c
$ (Compiler)-C src/lib/threadpool. C-o $ (configuration)/threadpool. o $ (cxxflags)

$ (Configuration)/util. O: src/lib/util. c
$ (Compiler)-C src/lib/util. C-o $ (configuration)/util. o $ (cxxflags)

$ (Configuration)/cppobject. O: src/lib/cppobject. cpp
$ (Compiler)-C src/lib/cppobject. cpp-o $ (configuration)/cppobject. o $ (cxxflags)

$ (Configuration)/cppsocket. O: src/lib/cppsocket. cpp
$ (Compiler)-C src/lib/cppsocket. cpp-o $ (configuration)/cppsocket. o $ (cxxflags)

$ (Configuration)/cppudpsocket. O: src/lib/cppudpsocket. cpp
$ (Compiler)-C src/lib/cppudpsocket. cpp-o $ (configuration)/cppudpsocket. o $ (cxxflags)

$ (Configuration)/cppserversocket. O: src/lib/cppserversocket. cpp
$ (Compiler)-C src/lib/cppserversocket. cpp-o $ (configuration)/cppserversocket. o $ (cxxflags)

$ (Configuration)/readconfig. O: src/lib/readconfig. cpp
$ (Compiler)-C src/lib/readconfig. cpp-o $ (configuration)/readconfig. o $ (cxxflags)

######################################## ######################################## ###

# Core code
$ (Configuration)/m3server. O: src/kernel/m3server. cpp
$ (Compiler)-C src/kernel/m3server. cpp-o $ (configuration)/m3server. o $ (cxxflags)

######################################## ######################################## ###

Rebuild: clean all

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.