blob: 61e67cf18bc48e7d7b9038d6ee37f8dbf83bd3a0 (
plain)
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
|
GREP = @GREP@
MOC = @MOC@
CXX = @CXX@
FLEX = @FLEX@
BISON = @BISON@
INSTALL = @INSTALL@
TOPDIR = @top_srcdir@
PROGRAM = @PROGRAM@
VERSION = @VERSION@
PROGRAM_PATH = $(TOPDIR)/bin/$(PROGRAM)
#
# allow user specified install path prefix
#
EXEC_PREFIX = @exec_prefix@
ifeq ($(EXEC_PREFIX),)
EXEC_PREFIX=/usr/local/bin
endif
CXXFLAGS = @CXXFLAGS@
INCLUDE_DIRS = @QT_INC_DIR@
IFLAGS = $(addprefix -I,$(INCLUDE_DIRS))
LIBRARIES = QtCore Xext X11 m
LIB_DIRS = @QT_LIB_DIR@ /usr/X11R6/lib
LFLAGS = $(addprefix -L,$(LIB_DIRS)) $(addprefix -l,$(LIBRARIES))
CPP_SRC = $(wildcard *.cpp) expr.ll.cpp expr.yy.cpp
HPP_SRC = $(wildcard *.hpp)
H_SRC = $(wildcard *.h) $(HPP_SRC)
MOC_HPP = $(shell $(GREP) -l Q_OBJECT $(HPP_SRC))
MOC_SRC = $(addprefix moc_,$(MOC_HPP:.hpp=.cpp))
CXX_SRC = $(CPP_SRC) $(MOC_SRC)
OBJECTS = $(sort $(CXX_SRC:.cpp=.o))
BUILD_DATE = $(shell @DATE_PROG@)
BUILD_HOST = $(shell @HOSTNAME_PROG@)
ifeq ($(VERBOSE),)
QUIET = @
else
QUIET =
endif
.PHONY : clean_moc clean_objects clean moc all build_info.h
#
# rules
#
all : $(PROGRAM_PATH)
$(PROGRAM_PATH) : $(OBJECTS)
@echo "Linking $(PROGRAM_PATH)"
$(QUIET) $(CXX) $(OBJECTS) $(LFLAGS) -o $@
app.pro :
echo "TEMPLATE = app" > $@
echo "SOURCES = $(CPP_SRC)" >> $@
echo "HEADERS = $(H_SRC)" >> $@
echo "TARGET = $(PROGRAM)" >> $@
echo "CONFIG = qt warn_on debug" >> $@
build_info.h :
echo #define BUILD_HOST "$(BUILD_HOST)" > $@
echo #define BIULD_DATE "$(BUILD_DATE)" >> $@
moc : $(MOC_SRC)
clean : clean_moc clean_objects
@echo "Removing objects and derived sources..."
$(QUIET) $(RM) core *~ .depend img/*~
clean_moc :
$(QUIET) $(RM) $(MOC_SRC)
clean_objects :
$(QUIET) $(RM) $(OBJECTS) $(PROGRAM_PATH)
depend : $(CXX_SRC)
@echo "Generating .depend file..."
$(QUIET) $(CXX) $(CXXFLAGS) $(IFLAGS) $^ -M -MG > .depend
objects : $(OBJECTS)
install :
@echo "Installing $(PROGRAM) in $(EXEC_PREFIX)"
$(QUIET) $(INSTALL) $(PROGRAM_PATH) $(EXEC_PREFIX)
# pattern rules
moc_%.cpp : %.hpp
@echo "Generating $@..."
$(QUIET) $(MOC) $< -o $@
%.o : %.cpp
@echo "Compiling $<..."
$(QUIET) $(CXX) $(CXXFLAGS) $(IFLAGS) -c $< -o $@
# rules for flex/bison
expr.ll.cpp : expr.l expr.yy.hh
$(FLEX) -o$@ -Pexpr expr.l
expr.yy.cpp expr.yy.hh : expr.y
$(BISON) -d -b expr -p expr -o expr.yy.cpp $^
#
# Include make dependancies if they have been generated
#
-include .depend
|