qmake生成的Makefile分析

#############################################################################
# Makefile for building: test
# Generated by qmake (2.01a) (Qt 4.6.2) on: ?? 1? 29 16:32:35 2011
# Project:  test.pro
# Template: app
# Command: /usr/bin/qmake -unix -o Makefile test.pro
#############################################################################

####### Compiler, tools and options

#各种变量定义,主要的用粗体注释了

CC            = gcc
CXX           = g++
DEFINES       =
CFLAGS        = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS      = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
INCPATH       = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4 -I. -I.
LINK          = g++
LFLAGS        =
LIBS          = $(SUBLIBS)  -L/usr/lib -lpthread
AR            = ar cqs
RANLIB        =
QMAKE         = /usr/bin/qmake
TAR           = tar -cf
COMPRESS      = gzip -9f
COPY          = cp -f
SED           = sed
COPY_FILE     = $(COPY)
COPY_DIR      = $(COPY) -r
STRIP         = strip
INSTALL_FILE  = install -m 644 -p
INSTALL_DIR   = $(COPY_DIR)
INSTALL_PROGRAM = install -m 755 -p
DEL_FILE      = rm -f
SYMLINK       = ln -f -s
DEL_DIR       = rmdir
MOVE          = mv -f
CHK_DIR_EXISTS= test -d
MKDIR         = mkdir -p

####### Output directory

OBJECTS_DIR   = ./

####### Files

SOURCES       = main.cpp
OBJECTS       = main.o

DIST          = /usr/share/qt4/mkspecs/common/g++.conf \
        /usr/share/qt4/mkspecs/common/unix.conf \
        /usr/share/qt4/mkspecs/common/linux.conf \
        /usr/share/qt4/mkspecs/qconfig.pri \
        /usr/share/qt4/mkspecs/features/qt_functions.prf \
        /usr/share/qt4/mkspecs/features/qt_config.prf \
        /usr/share/qt4/mkspecs/features/exclusive_builds.prf \
        /usr/share/qt4/mkspecs/features/default_pre.prf \
        /usr/share/qt4/mkspecs/features/debug.prf \
        /usr/share/qt4/mkspecs/features/default_post.prf \
        /usr/share/qt4/mkspecs/features/warn_on.prf \
        /usr/share/qt4/mkspecs/features/qt.prf \
        /usr/share/qt4/mkspecs/features/unix/thread.prf \
        /usr/share/qt4/mkspecs/features/moc.prf \
        /usr/share/qt4/mkspecs/features/resources.prf \
        /usr/share/qt4/mkspecs/features/uic.prf \
        /usr/share/qt4/mkspecs/features/yacc.prf \
        /usr/share/qt4/mkspecs/features/lex.prf \
        /usr/share/qt4/mkspecs/features/include_source_dir.prf \
        test.pro
QMAKE_TARGET  = test
DESTDIR       =
TARGET        = test

first: all
####### Implicit rules

#后缀规则是一种古老定义隐含规则的方式,在新版本的make中使用模式规则作为
对它的替代,模式规则相比后缀规则更加清晰明了。在现在版本中保留它的原因是为了
能够兼容旧的makefile文件。

可识别的后缀指的是特殊目标“.SUFFIXES”所有依赖的名字。通过给特殊目标
“SUFFIXES”添加依赖来增加一个可被识别的后缀。具体参考gnumake 手册

$@
表示规则的目标文件名。如果目标是一个文档文件(Linux中,一般称.a文件为
文档文件,也称为静态库文件) ,那么它代表这个文档的文件名。在多目标模式
规则中,它代表的是哪个触发规则被执行的目标文件名。

$<
规则的第一个依赖文件名。如果是一个目标文件使用隐含规则来重建,则它代表
由隐含规则加入的第一个依赖文件。

$^
规则的所有依赖文件列表,使用空格分隔。如果目标是静态库文件,它所代表的
只能是所有库成员(.o文件)名。一个文件可重复的出现在目标的依赖中,变量
“$^”只记录它的一次引用情况。就是说变量“$^”会去掉重复的依赖文件。

 

.SUFFIXES: .o .c .cpp .cc .cxx .C

.cpp.o:
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.cc.o:
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.cxx.o:
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.C.o:
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.c.o:
    $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"

####### Build rules

all: Makefile $(TARGET)

$(TARGET):  $(OBJECTS) 
    $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)

#如果test.pro更新,更新Makefile

Makefile: test.pro  /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \
        /usr/share/qt4/mkspecs/common/unix.conf \
        /usr/share/qt4/mkspecs/common/linux.conf \
        /usr/share/qt4/mkspecs/qconfig.pri \
        /usr/share/qt4/mkspecs/features/qt_functions.prf \
        /usr/share/qt4/mkspecs/features/qt_config.prf \
        /usr/share/qt4/mkspecs/features/exclusive_builds.prf \
        /usr/share/qt4/mkspecs/features/default_pre.prf \
        /usr/share/qt4/mkspecs/features/debug.prf \
        /usr/share/qt4/mkspecs/features/default_post.prf \
        /usr/share/qt4/mkspecs/features/warn_on.prf \
        /usr/share/qt4/mkspecs/features/qt.prf \
        /usr/share/qt4/mkspecs/features/unix/thread.prf \
        /usr/share/qt4/mkspecs/features/moc.prf \
        /usr/share/qt4/mkspecs/features/resources.prf \
        /usr/share/qt4/mkspecs/features/uic.prf \
        /usr/share/qt4/mkspecs/features/yacc.prf \
        /usr/share/qt4/mkspecs/features/lex.prf \
        /usr/share/qt4/mkspecs/features/include_source_dir.prf
    $(QMAKE) -unix -o Makefile test.pro
/usr/share/qt4/mkspecs/common/g++.conf:
/usr/share/qt4/mkspecs/common/unix.conf:
/usr/share/qt4/mkspecs/common/linux.conf:
/usr/share/qt4/mkspecs/qconfig.pri:
/usr/share/qt4/mkspecs/features/qt_functions.prf:
/usr/share/qt4/mkspecs/features/qt_config.prf:
/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
/usr/share/qt4/mkspecs/features/default_pre.prf:
/usr/share/qt4/mkspecs/features/debug.prf:
/usr/share/qt4/mkspecs/features/default_post.prf:
/usr/share/qt4/mkspecs/features/warn_on.prf:
/usr/share/qt4/mkspecs/features/qt.prf:
/usr/share/qt4/mkspecs/features/unix/thread.prf:
/usr/share/qt4/mkspecs/features/moc.prf:
/usr/share/qt4/mkspecs/features/resources.prf:
/usr/share/qt4/mkspecs/features/uic.prf:
/usr/share/qt4/mkspecs/features/yacc.prf:
/usr/share/qt4/mkspecs/features/lex.prf:
/usr/share/qt4/mkspecs/features/include_source_dir.prf:
qmake:  FORCE
    @$(QMAKE) -unix -o Makefile test.pro

dist:
    @$(CHK_DIR_EXISTS) .tmp/test1.0.0 || $(MKDIR) .tmp/test1.0.0
    $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/test1.0.0/ && $(COPY_FILE) --parents main.cpp .tmp/test1.0.0/ && (cd `dirname .tmp/test1.0.0` && $(TAR) test1.0.0.tar test1.0.0 && $(COMPRESS) test1.0.0.tar) && $(MOVE) `dirname .tmp/test1.0.0`/test1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/test1.0.0

clean:compiler_clean
    -$(DEL_FILE) $(OBJECTS)
    -$(DEL_FILE) *~ core *.core

####### Sub-libraries

distclean: clean
    -$(DEL_FILE) $(TARGET)
    -$(DEL_FILE) Makefile

mocclean: compiler_moc_header_clean compiler_moc_source_clean

mocables: compiler_moc_header_make_all compiler_moc_source_make_all

compiler_moc_header_make_all:
compiler_moc_header_clean:
compiler_rcc_make_all:
compiler_rcc_clean:
compiler_image_collection_make_all: qmake_image_collection.cpp
compiler_image_collection_clean:
    -$(DEL_FILE) qmake_image_collection.cpp
compiler_moc_source_make_all:
compiler_moc_source_clean:
compiler_uic_make_all:
compiler_uic_clean:
compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
compiler_yacc_impl_make_all:
compiler_yacc_impl_clean:
compiler_lex_make_all:
compiler_lex_clean:
compiler_clean:

####### Compile

main.o: main.cpp
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp

####### Install

install_document: first FORCE
    @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/root/test/./install/ || $(MKDIR) $(INSTALL_ROOT)/root/test/./install/
    echo aaa; mkdir aaa
    -$(INSTALL_FILE) /root/test/test.pro.user $(INSTALL_ROOT)/root/test/./install/

uninstall_document:  FORCE
    -$(DEL_FILE) -r $(INSTALL_ROOT)/root/test/./install/test.pro.user
    -$(DEL_DIR) $(INSTALL_ROOT)/root/test/./install/

install_target: first FORCE
    @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/root/test/./install/ || $(MKDIR) $(INSTALL_ROOT)/root/test/./install/
    -$(INSTALL_PROGRAM) "$(QMAKE_TARGET)" "$(INSTALL_ROOT)/root/test/install/$(QMAKE_TARGET)"

uninstall_target:  FORCE
    -$(DEL_FILE) "$(INSTALL_ROOT)/root/test/install/$(QMAKE_TARGET)"
    -$(DEL_DIR) $(INSTALL_ROOT)/root/test/./install/

install:  install_document install_target  FORCE

uninstall: uninstall_document uninstall_target   FORCE

FORCE:

posted on 2011-09-15 14:50  katago  阅读(4834)  评论(0编辑  收藏  举报