1# -------------------------------------------------
2# glogg
3# -------------------------------------------------
4
5# Debug builds: qmake CONFIG+=debug
6# Release builds: qmake
7
8TARGET = glogg
9TEMPLATE = app
10
11QT += network
12
13greaterThan(QT_MAJOR_VERSION, 4): QT += core widgets
14
15win32:Debug:CONFIG += console
16
17# Necessary when cross-compiling:
18win32:Release:QMAKE_LFLAGS += "-Wl,-subsystem,windows"
19
20# Input
21SOURCES += \
22    src/main.cpp \
23    src/session.cpp \
24    src/data/abstractlogdata.cpp \
25    src/data/logdata.cpp \
26    src/data/logfiltereddata.cpp \
27    src/data/logfiltereddataworkerthread.cpp \
28    src/data/logdataworkerthread.cpp \
29    src/data/compressedlinestorage.cpp \
30    src/mainwindow.cpp \
31    src/crawlerwidget.cpp \
32    src/abstractlogview.cpp \
33    src/logmainview.cpp \
34    src/filteredview.cpp \
35    src/optionsdialog.cpp \
36    src/persistentinfo.cpp \
37    src/configuration.cpp \
38    src/filtersdialog.cpp \
39    src/filterset.cpp \
40    src/savedsearches.cpp \
41    src/infoline.cpp \
42    src/menuactiontooltipbehavior.cpp \
43    src/selection.cpp \
44    src/quickfind.cpp \
45    src/quickfindpattern.cpp \
46    src/quickfindwidget.cpp \
47    src/sessioninfo.cpp \
48    src/recentfiles.cpp \
49    src/overview.cpp \
50    src/overviewwidget.cpp \
51    src/marks.cpp \
52    src/quickfindmux.cpp \
53    src/signalmux.cpp \
54    src/tabbedcrawlerwidget.cpp \
55    src/viewtools.cpp \
56    src/encodingspeculator.cpp \
57
58INCLUDEPATH += src/
59
60HEADERS += \
61    src/data/abstractlogdata.h \
62    src/data/logdata.h \
63    src/data/logfiltereddata.h \
64    src/data/logfiltereddataworkerthread.h \
65    src/data/logdataworkerthread.h \
66    src/data/threadprivatestore.h \
67    src/data/compressedlinestorage.h \
68    src/data/linepositionarray.h \
69    src/mainwindow.h \
70    src/session.h \
71    src/viewinterface.h \
72    src/crawlerwidget.h \
73    src/logmainview.h \
74    src/log.h \
75    src/filteredview.h \
76    src/abstractlogview.h \
77    src/optionsdialog.h \
78    src/persistentinfo.h \
79    src/configuration.h \
80    src/filtersdialog.h \
81    src/filterset.h \
82    src/savedsearches.h \
83    src/infoline.h \
84    src/filewatcher.h \
85    src/selection.h \
86    src/quickfind.h \
87    src/quickfindpattern.h \
88    src/quickfindwidget.h \
89    src/sessioninfo.h \
90    src/persistable.h \
91    src/recentfiles.h \
92    src/menuactiontooltipbehavior.h \
93    src/overview.h \
94    src/overviewwidget.h \
95    src/marks.h \
96    src/qfnotifications.h \
97    src/quickfindmux.h \
98    src/signalmux.h \
99    src/tabbedcrawlerwidget.h \
100    src/loadingstatus.h \
101    src/externalcom.h \
102    src/viewtools.h \
103    src/encodingspeculator.h \
104
105isEmpty(BOOST_PATH) {
106    message(Building using system dynamic Boost libraries)
107    macx {
108      # Path for brew installed libs
109      INCLUDEPATH += /usr/local/include
110      LIBS += -L/usr/local/lib -lboost_program_options-mt
111    }
112    else {
113      LIBS += -lboost_program_options
114    }
115}
116else {
117    message(Building using static Boost libraries at $$BOOST_PATH)
118
119    SOURCES += $$BOOST_PATH/libs/program_options/src/*.cpp \
120        $$BOOST_PATH/libs/smart_ptr/src/*.cpp
121
122    INCLUDEPATH += $$BOOST_PATH
123}
124
125FORMS += src/optionsdialog.ui
126FORMS += src/filtersdialog.ui
127
128macx {
129    # Icon for Mac
130    ICON = images/glogg.icns
131}
132else {
133    # For Windows icon
134    RC_FILE = glogg.rc
135}
136
137RESOURCES = glogg.qrc
138
139# Build HTML documentation (if 'markdown' is available)
140system(type markdown >/dev/null) {
141    MARKDOWN += doc/documentation.markdown
142}
143else {
144    message("markdown not found, HTML doc will not be generated")
145}
146
147doc_processor.name = markdown
148doc_processor.input = MARKDOWN
149doc_processor.output = doc/${QMAKE_FILE_BASE}.html
150doc_processor.commands = markdown ${QMAKE_FILE_NAME} | \
151    sed -f finish.sed >${QMAKE_FILE_OUT}
152
153doc_processor.CONFIG += target_predeps
154doc_processor.variable_out = doc.files
155
156QMAKE_EXTRA_COMPILERS += doc_processor
157
158# Install (for unix)
159icon16.path  = $$PREFIX/share/icons/hicolor/16x16/apps
160icon16.files = images/hicolor/16x16/glogg.png
161
162icon32.path  = $$PREFIX/share/icons/hicolor/32x32/apps
163icon32.files = images/hicolor/32x32/glogg.png
164
165icon_svg.path  = $$PREFIX/share/icons/hicolor/scalable/apps
166icon_svg.files = images/hicolor/scalable/glogg.svg
167
168doc.path  = $$PREFIX/share/doc/glogg
169doc.files += README
170
171desktop.path = $$PREFIX/share/applications
172desktop.files = glogg.desktop
173
174target.path = $$PREFIX/bin
175INSTALLS = target icon16 icon32 icon_svg doc desktop
176
177# Build directories
178CONFIG(debug, debug|release) {
179    DESTDIR = debug
180} else {
181    DESTDIR = release
182}
183
184OBJECTS_DIR = $${OUT_PWD}/.obj/$${DESTDIR}-shared
185MOC_DIR = $${OUT_PWD}/.moc/$${DESTDIR}-shared
186UI_DIR = $${OUT_PWD}/.ui/$${DESTDIR}-shared
187
188# Debug symbols even in release build
189QMAKE_CXXFLAGS = -g
190
191# Which compiler are we using
192system( $${QMAKE_CXX} --version | grep -e " 4\\.[7-9]" ) || macx {
193    message ( "g++ version 4.7 or newer, supports C++11" )
194    CONFIG += C++11
195}
196else {
197    CONFIG += C++0x
198}
199
200# Extra compiler arguments
201# QMAKE_CXXFLAGS += -Weffc++
202QMAKE_CXXFLAGS += -Wextra
203C++0x:QMAKE_CXXFLAGS += -std=c++0x
204C++11:QMAKE_CXXFLAGS += -std=c++11
205
206GPROF {
207    QMAKE_CXXFLAGS += -pg
208    QMAKE_LFLAGS   += -pg
209}
210
211isEmpty(LOG_LEVEL) {
212    CONFIG(debug, debug|release) {
213        DEFINES += FILELOG_MAX_LEVEL=\"logDEBUG4\"
214    } else {
215        DEFINES += FILELOG_MAX_LEVEL=\"logDEBUG\"
216    }
217}
218else {
219    message("Using specified log level: $$LOG_LEVEL")
220    DEFINES += FILELOG_MAX_LEVEL=\"$$LOG_LEVEL\"
221}
222
223macx {
224    QMAKE_CXXFLAGS += -stdlib=libc++
225    QMAKE_LFLAGS += -stdlib=libc++
226
227    QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
228}
229
230# Official builds can be generated with `qmake VERSION="1.2.3"'
231isEmpty(VERSION):system(date >/dev/null) {
232    system([ -f .tarball-version ]) {
233        QMAKE_CXXFLAGS += -DGLOGG_VERSION=\\\"`cat .tarball-version`\\\"
234    }
235    else {
236        QMAKE_CXXFLAGS += -DGLOGG_DATE=\\\"`date +'\"%F\"'`\\\"
237        QMAKE_CXXFLAGS += -DGLOGG_VERSION=\\\"`git describe`\\\"
238        QMAKE_CXXFLAGS += -DGLOGG_COMMIT=\\\"`git rev-parse --short HEAD`\\\"
239    }
240}
241else {
242    QMAKE_CXXFLAGS += -DGLOGG_VERSION=\\\"$$VERSION\\\"
243}
244
245# Optional features (e.g. CONFIG+=no-dbus)
246system(pkg-config --exists QtDBus):!no-dbus {
247    message("Support for D-BUS will be included")
248    QT += dbus
249    QMAKE_CXXFLAGS += -DGLOGG_SUPPORTS_DBUS
250    SOURCES += src/dbusexternalcom.cpp
251    HEADERS += src/dbusexternalcom.h
252}
253else {
254    message("Support for D-BUS will NOT be included")
255    win32 || macx {
256        message("Support for cross-platform IPC will be included")
257        QMAKE_CXXFLAGS += -DGLOGG_SUPPORTS_SOCKETIPC
258        SOURCES += src/socketexternalcom.cpp
259        HEADERS += src/socketexternalcom.h
260    }
261}
262
263# Version checking
264version_checker {
265    message("Version checker will be included")
266    QT += network
267    QMAKE_CXXFLAGS += -DGLOGG_SUPPORTS_VERSION_CHECKING
268    SOURCES += src/versionchecker.cpp
269    HEADERS += src/versionchecker.h
270}
271else {
272    message("Version checker will NOT be included")
273}
274
275# File watching
276linux-g++ || linux-g++-64 {
277    CONFIG += inotify
278}
279
280win32 {
281    message("File watching using Windows")
282    SOURCES += src/platformfilewatcher.cpp src/winwatchtowerdriver.cpp src/watchtower.cpp src/watchtowerlist.cpp
283    HEADERS += src/platformfilewatcher.h src/winwatchtowerdriver.h src/watchtower.h src/watchtowerlist.h
284    QMAKE_CXXFLAGS += -DGLOGG_SUPPORTS_POLLING
285}
286else {
287    inotify {
288        message("File watching using inotify")
289        QMAKE_CXXFLAGS += -DGLOGG_SUPPORTS_INOTIFY
290        SOURCES += src/platformfilewatcher.cpp src/inotifywatchtowerdriver.cpp src/watchtower.cpp src/watchtowerlist.cpp
291        HEADERS += src/platformfilewatcher.h src/inotifywatchtowerdriver.h src/watchtower.h src/watchtowerlist.h
292    }
293    else {
294        message("File watching using Qt")
295        SOURCES += src/qtfilewatcher.cpp
296        HEADERS += src/qtfilewatcher.h
297    }
298}
299
300# Performance measurement
301perf {
302    QMAKE_CXXFLAGS += -DGLOGG_PERF_MEASURE_FPS
303}
304