-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
126 lines (97 loc) · 2.75 KB
/
Copy pathMakefile
File metadata and controls
126 lines (97 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#
# @file Makefile
# Makefile for ShowGraph project
# @author Boris Shurygin
#
# Main targets are:
# all - build gui and console versinos of Showgraph in debug and release modes
# debug (not yet implemented) - build debug vesion of ShowGraph (both gui and console)
# release - build release version of ShowGraph
# doc - run doxygen to generate documentation from source code
#
# targets are buit in two steps:
# 1. Generate additional .cpp files by QT tools ( MOC and RCC)
# 2. Compile all .cpp to .o and link them with Qt libs
#
#Makefile that implements main building functionality
MAKEFILE_IMPL = Makefile-impl
# Tools
export CC = gcc
export CXX = g++
exportPERL = perl
export MKDIR = mkdir
export RM = rm
export GREP = grep
export TOUCH = touch
export DOXYGEN = doxygen
#Directories
export BIN_DIR := bin
export OBJECT_DIR := objects
export SOURCES := sources
export MOC_DIR = $(OBJECT_DIR)/mocs
export DEBUG_OBJECTS_DIR := $(OBJECT_DIR)/debug
export RELEASE_OBJECTS_DIR := $(OBJECT_DIR)/release
export QT_DIR = /usr/local/Trolltech/Qt-4.7.0
#QT tools
export MOC = $(QT_DIR)/bin/moc
export RCC = $(QT_DIR)/bin/rcc
HEADERS:= $(wildcard $(SOURCES)/*/*.h $(SOURCES)/Core/*/*.h)
MOC_HEADERS:= $(patsubst $(SOURCES)/%,$(MOC_DIR)/%,$(HEADERS))
MOCS= $(MOC_HEADERS:.h=.moc)
RESOURCES:=$(wildcard $(SOURCES)/*/*.qrc)
QRC:= $(patsubst $(SOURCES)/%,$(MOC_DIR)/%,$(RESOURCES))
RCCS=$(QRC:.qrc=.rcc)
#
# All targets
#
all: release debug unittest
#showgraphcl showgraphd showgraphcld
#Debug targets
debug: showgraphd showgraphcld
showgraphd: gen showgraphd_impl
showgraphcld: gen showgraphcld_impl
showgraphd_impl showgraphcld_impl:
$(MAKE) -f $(MAKEFILE_IMPL) $@
# Release targets
release: showgraph showgraphcl
# Unit Test
unittest:
showgraph: gen showgraph_impl
showgraphcl: gen showgraphcl_impl
showgraph_impl showgraphcl_impl:
$(MAKE) -f $(MAKEFILE_IMPL) $@
#
# This part generates new CPP files from headers that have Q_OBJECT usage
#
# run QT meta-object compiler on headers to generate additional .cpp files.
# list of created files can be found in NEW_MOCS variable later
gen: $(MOCS) $(RCCS)
# rule for moc run
$(MOC_DIR)/%.moc: $(SOURCES)/%.h
@echo [moc] $*.h
@$(MKDIR) -p $(dir $@)
@$(TOUCH) $@
@(! $(GREP) -q Q_OBJECT $< || $(MOC) $< -o $(SOURCES)/$*_moc.cpp)
# rule for resource compiler
$(MOC_DIR)/%.rcc: $(SOURCES)/%.qrc
@echo [rcc] $*.qrc
@$(MKDIR) -p $(dir $@)
@$(TOUCH) $@
@$(RCC) $< -o $(<:.qrc=.cpp)
#
# Documentation
#
doc:
@echo [doxygen]
@cd autodoc;$(DOXYGEN) Doxyfile
#
# Cleanup routines
#
.PHONY: clean
clean:
$(eval EXISTING_MOCS = $(wildcard $(SOURCES)/*/*_moc.cpp))
$(eval EXISTING_RESOURCES = $(RESOURCES:.qrc=.cpp))
-$(RM) -f $(EXISTING_RESOURCES)
-$(RM) -f $(EXISTING_MOCS)
-$(RM) -rf $(OBJECT_DIR)
-$(RM) -rf $(BIN_DIR)