VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/Makefile@ 2208

Last change on this file since 2208 was 2178, checked in by vboxsync, 18 years ago

FE/Qt: Added Qt translation sources from the Qt distribution; created untranslated sources for existing languages; added code to load Qt translations on language change.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.7 KB
Line 
1#
2# Makefile for the VirtualBox Qt GUI.
3#
4
5#
6# Copyright (C) 2006 InnoTek Systemberatung GmbH
7#
8# This file is part of VirtualBox Open Source Edition (OSE), as
9# available from http://www.virtualbox.org. This file is free software;
10# you can redistribute it and/or modify it under the terms of the GNU
11# General Public License as published by the Free Software Foundation,
12# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13# distribution. VirtualBox OSE is distributed in the hope that it will
14# be useful, but WITHOUT ANY WARRANTY of any kind.
15#
16# If you received this file as part of a commercial VirtualBox
17# distribution, then only the terms of your commercial VirtualBox
18# license agreement apply instead of the previous paragraph.
19#
20
21ifeq ($(BUILD_TARGET),linux)
22XKEYBOARD_NEW := 1
23endif
24
25# include qmake project file
26include VBoxUI.pro
27
28# Import QDesigner UI sources
29VirtualBox_QT_UISRCS := $(FORMS)
30# Import translation sources
31VirtualBox_QT_TRANSLATIONS := $(TRANSLATIONS)
32# Import images
33VirtualBox_QT_IMAGES := $(IMAGES)
34
35# reset things to avoid possible conflicts with kBuild
36TEMPLATE :=
37LANGUAGE :=
38FORMS :=
39TRANSLATIONS :=
40IMAGES :=
41
42DEPTH = ../../../..
43include $(PATH_KBUILD)/header.kmk
44
45PROGRAMS = VirtualBox
46
47INSTALLS = VirtualBox.nls
48INSTALLS.darwin = VirtualBox.app
49
50VirtualBox_TEMPLATE = VBOXQTGUIEXE
51VirtualBox_SDKS.win = WINPSDK DXSDK
52VirtualBox_SDKS.linux = LIBSDL
53
54# Each nls/VirtualBox_xx_YY.ts file must have a qt_xx_YY.ts counterpart
55VirtualBox_QT_TRANSLATIONS_QT := \
56 $(patsubst nls/VirtualBox_%.ts,nls/qt_%.ts,\
57 $(filter nls/VirtualBox_%.ts,$(VirtualBox_QT_TRANSLATIONS)))
58
59# QDesigner UI sources are imported from VBoxUI.pro as VirtualBox_QT_UISRC
60
61# Headers containing definitions of classes that use the Q_OBJECT macro
62VirtualBox_QT_MOCHDRS = \
63 include/QIWidgetValidator.h \
64 include/QIHotKeyEdit.h \
65 include/QIStatusBar.h \
66 include/QIStateIndicator.h \
67 include/QIMessageBox.h \
68 include/QIRichLabel.h \
69 include/VMGlobalSettings.h \
70 include/VBoxGlobal.h \
71 include/VBoxVMListBox.h \
72 include/VBoxMediaComboBox.h \
73 include/VBoxSelectorWnd.h \
74 include/VBoxConsoleWnd.h \
75 include/VBoxConsoleView.h \
76 include/VBoxProblemReporter.h
77
78# Sources containing local definitions of classes that use the Q_OBJECT macro
79VirtualBox_QT_MOCSRCS = src/VBoxSelectorWnd.cpp
80ifneq ($(BUILD_TARGET),win)
81VirtualBox_QT_MOCSRCS += src/COMDefs.cpp
82endif
83
84# UI headers (ui.h) containing local definitions of classes that use the Q_OBJECT macro
85VirtualBox_QT_MOCUIHDRS = \
86 ui/VBoxVMSettingsDlg.ui.h \
87 ui/VBoxSharedFoldersSettings.ui.h
88ifeq ($(BUILD_TARGET),win)
89VirtualBox_QT_MOCUIHDRS += ui/VBoxVMNetworkSettings.ui.h
90endif
91
92
93# All generated sources. Note: this list MUST be in sync with Qt source
94# generation rules defined somewhere below!
95VirtualBox_GENSRCS = \
96 $(foreach moc,$(notdir $(basename $(VirtualBox_QT_MOCHDRS))), $(PATH_VirtualBox)/moc/moc_$(moc).cpp) \
97 $(foreach ui,$(notdir $(basename $(VirtualBox_QT_UISRCS))), $(PATH_VirtualBox)/ui/$(ui).cpp $(PATH_VirtualBox)/moc/moc_$(ui).cpp) \
98 $(PATH_VirtualBox)/ui/vbox_image_collection.cpp
99
100# All generated headers. Note: this list MUST be in sync with Qt source
101# generation rules defined somewhere below!
102VirtualBox_GENHDRS = \
103 $(foreach mocui,$(notdir $(basename $(VirtualBox_QT_MOCUIHDRS))), $(PATH_VirtualBox)/moc/$(mocui).moc) \
104 $(foreach moc,$(notdir $(basename $(VirtualBox_QT_MOCSRCS))), $(PATH_VirtualBox)/moc/$(moc).moc) \
105 $(foreach ui,$(notdir $(basename $(VirtualBox_QT_UISRCS))), $(PATH_VirtualBox)/ui/$(ui).h)
106
107# All existing .ui.h files for known .ui sources
108VirtualBox_QT_UIHDRS = \
109 $(wildcard $(addsuffix .h,$(VirtualBox_QT_UISRCS)))
110
111# All header files
112VirtualBox_HEADERS = \
113 $(wildcard include/*.h) \
114 $(VirtualBox_GENHDRS) \
115 $(VirtualBox_QT_UIHDRS)
116
117
118VirtualBox_SOURCES = \
119 $(VirtualBox_GENSRCS) \
120 src/main.cpp \
121 src/COMDefs.cpp \
122 src/QIWidgetValidator.cpp \
123 src/QIHotKeyEdit.cpp \
124 src/QIStateIndicator.cpp \
125 src/QIStatusBar.cpp \
126 src/QIMessageBox.cpp \
127 src/QIRichLabel.cpp \
128 src/VMGlobalSettings.cpp \
129 src/VBoxGlobal.cpp \
130 src/VBoxMediaComboBox.cpp \
131 src/VBoxProblemReporter.cpp \
132 src/VBoxSelectorWnd.cpp \
133 src/VBoxConsoleView.cpp \
134 src/VBoxConsoleWnd.cpp \
135 src/VBoxVMListBox.cpp \
136 src/VBoxFrameBuffer.cpp
137
138VirtualBox_SOURCES.win += \
139 src/win32/VirtualBox.rc
140
141VirtualBox_SOURCES.win += \
142 src/VBoxFBDDRAW.cpp
143
144ifdef XKEYBOARD_NEW
145VirtualBox_SOURCES.linux = \
146 src/linux/XKeyboardNew.cpp
147else
148VirtualBox_SOURCES.linux = \
149 src/linux/XKeyboard.cpp \
150 src/linux/keyboard.c
151endif
152
153VirtualBox_SOURCES.darwin = \
154 src/darwin/DarwinKeyboard.cpp \
155 src/darwin/DarwinCursor.cpp
156
157## @todo how to detect what tool is used?
158## @todo GCC3 seems to lack -Wno-missing-base-class-initializer, so we use
159# more generic -Wno-extra
160ifneq ($(BUILD_TARGET),win)
161src/COMDefs.cpp_CXXFLAGS = $(VBOX_GCC_Wno-extra)
162endif
163
164VirtualBox_DEFS = VBOX_GUI_SEPARATE_VM_PROCESS
165VirtualBox_DEFS.debug = VBOX_GUI_DEBUG VBOX_CHECK_STATE # QT_FATAL_ASSERT
166VirtualBox_DEFS.darwin = VBOX_GUI_USE_QIMAGE
167VirtualBox_DEFS.linux = VBOX_GUI_USE_SDL
168VirtualBox_DEFS.win = VBOX_GUI_USE_QIMAGE UNICODE QT_DLL
169#ifndef VBOX_OSE
170 VirtualBox_DEFS.darwin += VBOX_WITH_HACKED_QT
171#endif
172ifneq ($(BUILD_TYPE),release)
173 # non-release builds has some extra features.
174 VirtualBox_DEFS += VBOX_GUI_USE_REFRESH_TIMER VBOX_WITH_DEBUGGER_GUI_MENU
175 VirtualBox_DEFS.win += VBOX_GUI_USE_DDRAW
176 VirtualBox_DEFS.linux += VBOX_GUI_USE_QIMAGE
177endif
178ifdef VBOX_WITH_ALSA
179 VirtualBox_DEFS += VBOX_WITH_ALSA
180endif
181ifdef VBOX_OSE
182 VirtualBox_DEFS += VBOX_OSE
183endif
184
185VirtualBox_INCS = \
186 ./include \
187 $(PATH_VirtualBox)/ui \
188 $(PATH_VirtualBox)/moc \
189 $(PATH_VirtualBox)/include \
190
191
192ifeq ($(BUILD_TYPE),release)
193 VirtualBox_LDFLAGS.win += /SUBSYSTEM:windows
194else
195 VirtualBox_LDFLAGS.linux+= -rdynamic # for backtrace_symbols()
196 ifeq ($(USERNAME),dmik)
197 VirtualBox_LDFLAGS.win += /SUBSYSTEM:windows
198 else
199 VirtualBox_LDFLAGS.win += /SUBSYSTEM:console
200 endif
201endif
202VirtualBox_LDFLAGS.darwin = -framework IOKit
203VirtualBox_LIBS.win = \
204 $(PATH_SDK_WINPSDK_LIB)/Htmlhelp.Lib \
205 $(PATH_SDK_DXSDK_LIB)/ddraw.lib \
206 $(PATH_SDK_DXSDK_LIB)/dxguid.lib
207
208ifdef VBOX_WITH_DEBUGGER_GUI
209 ifeq ($(BUILD_TARGET),win)
210 VirtualBox_LIBS += $(PATH_LIB)/VBoxDbg$(VBOX_SUFF_LIB)
211 else
212 VirtualBox_LIBS += $(PATH_DLL)/VBoxDbg$(VBOX_SUFF_DLL)
213 endif
214endif
215
216WRAPPERSFILE = $(PATH_VirtualBox)/include/COMWrappers.h
217WRAPPERSINCFILE = include/COMDefs.h
218WRAPPERSTEMPLATE = include/COMWrappers.xsl
219XIDLFILE = ../../Main/idl/VirtualBox.xidl
220
221
222# generated files we need to clean manually
223OTHER_CLEAN = \
224 $(VirtualBox_GENSRCS) \
225 $(VirtualBox_GENHDRS) \
226 $(WRAPPERSFILE)
227
228
229#
230# On Mac OS X (darwin) we need to install icon resources and compusory bundle contents.
231#
232VirtualBox.app_INST = $(INST_VIRTUALBOX)Contents/
233VirtualBox.app_MODE = 644
234VirtualBox.app_SOURCES = \
235 src/darwin/PkgInfo \
236 $(PATH_TARGET)/Info.plist \
237 images/VirtualBox.icns=>Resources/virtualbox.icns
238
239$(PATH_TARGET)/Info.plist: src/darwin/Info.plist $(VBOX_VERSION_MK) | $(call DIRDEP,$(PATH_TARGET))
240 $(call MSG_L1,Generating $@)
241 $(xQUIET)$(RM) -f $@
242 $(xQUIET)$(SED) \
243 -e 's/@VBOX_VERSION_STRING@/$(VBOX_VERSION_STRING)/g' \
244 -e 's/@VBOX_VERSION_MAJOR@/$(VBOX_VERSION_MAJOR)/g' \
245 -e 's/@VBOX_VERSION_MINOR@/$(VBOX_VERSION_MINOR)/g' \
246 -e 's/@VBOX_VERSION_BUILD@/$(VBOX_VERSION_BUILD)/g' \
247 $< > $@
248
249#
250# Translation installation
251#
252
253VirtualBox.nls_INST = $(INST_BIN)nls/
254VirtualBox.nls_SOURCES = $(patsubst %.ts,$(PATH_VirtualBox)/nls/%.qm,$(notdir $(VirtualBox_QT_TRANSLATIONS)))
255VirtualBox.nls_SOURCES += $(patsubst %.ts,$(PATH_VirtualBox)/nls/%.qm,$(notdir $(VirtualBox_QT_TRANSLATIONS_QT)))
256VirtualBox.nls_MODE = 644
257
258
259
260# Commit the magic.
261# (note: before custom rules that make usage of generated variables!).
262include $(PATH_KBUILD)/footer.kmk
263
264
265
266#
267# Qt source file generation rules
268#
269
270## @todo move QT source generation macros to kBuild
271
272## Generate a rule to create a MOC source file from a header containing
273# classes that use the Q_OBJECT macro.
274# @param $mochdr header file with Q_OBJECT
275define def_qt_gen_src_moc
276
277$(eval mocsrc := $(PATH_$(target))/moc/moc_$(notdir $(basename $(mochdr))).cpp)
278
279$(target)_GENSRCS_REAL += $(mocsrc)
280
281$(mocsrc): $(mochdr)
282 $$(call MSG_L1,moc $(mochdr),=> $$@)
283 $$(QUIET)$$(MKDIR) -p $$(@D)
284 $$(QUIET)$$(VBOX_MOC) $(mochdr) -o $$@
285
286endef
287
288## Generate a rule to create a MOC include file from a source containing
289# local classes that use the Q_OBJECT macro. This include is then included
290# by that source, so it must be generated before the source gets compiled.
291# @param $mocsrc source file with Q_OBJECT
292define def_qt_gen_inc_moc
293
294$(eval mocobj := $(PATH_$(target)_$(mocsrc))/$(notdir $(basename $(mocsrc)))$(SUFF_OBJ))
295$(eval mocinc := $(PATH_$(target))/moc/$(notdir $(basename $(mocsrc))).moc)
296
297$(target)_GENHDRS_REAL += $(mocinc)
298
299$(mocobj): $(mocinc)
300
301.NOTPARALLEL: $(mocinc)
302$(mocinc): $(mocsrc)
303 $$(call MSG_L1,moc $(mocsrc),=> $$@)
304 $$(QUIET)$$(MKDIR) -p $$(@D)
305 $$(QUIET)$$(VBOX_MOC) -i $(mocsrc) -o $$@
306
307endef
308
309## Generate a rule to create a MOC include file from a UI header (ui.h) containing
310# local classes that use the Q_OBJECT macro. This include is then included
311# by that header, so it must be generated before the UI source gets compiled.
312# @param $mocuihdr UI header file with Q_OBJECT
313define def_qt_gen_inc_mocuihdr
314
315$(eval uisrc := $(PATH_$(target))/ui/$(notdir $(basename $(basename $(mocuihdr)))).cpp)
316$(eval uiobj := $(PATH_$(target)_$$(uisrc))/$(notdir $(basename $$(uisrc)))$(SUFF_OBJ))
317$(eval mocuiinc := $(PATH_$(target))/moc/$(notdir $(basename $(mocuihdr))).moc)
318
319$(target)_GENHDRS_REAL += $(mocuiinc)
320
321.NOTPARALLEL: $(mocuiinc)
322$(uisrc): $(mocuiinc)
323$(mocuiinc): $(mocuihdr)
324 $$(call MSG_L1,moc $(mocuihdr),=> $$@)
325 $$(QUIET)$$(MKDIR) -p $$(@D)
326 $$(QUIET)$$(VBOX_MOC) -i $(mocuihdr) -o $$@
327
328endef
329
330## Generate a rule to create a header and source files from an UI
331# definition source (.ui).
332# @param $uifile UI definintion source file
333define def_qt_gen_src_ui
334
335$(eval uisrc := $(PATH_$(target))/ui/$(notdir $(basename $(uifile))).cpp)
336$(eval uihdr := $(PATH_$(target))/ui/$(notdir $(basename $(uifile))).h)
337$(eval mocsrc := $(PATH_$(target))/moc/moc_$(notdir $(basename $(uifile))).cpp)
338
339$(target)_GENSRCS_REAL += $(uisrc) $(mocsrc)
340$(target)_GENHDRS_REAL += $(uihdr)
341
342.NOTPARALLEL: $(uihdr)
343$(uihdr): $(uifile) | $$(call DIRDEP,$(dir $(uihdr)))
344 $$(call MSG_L1,uic $(uifile),=> $$@)
345 $$(QUIET)$$(VBOX_UIC) $(uifile) -o $$@
346
347$(uisrc): $(uihdr) $(uifile) $(wildcard $(uifile).h) | $$(call DIRDEP,$(dir $(uisrc)))
348 $$(call MSG_L1,uic $(uifile),=> $$@)
349 $$(QUIET)$$(VBOX_UIC) $(uifile) -i $(uihdr) -o $$@
350
351$(mocsrc): $(uihdr) | $$(call DIRDEP,$(dir $(mocsrc)))
352 $$(call MSG_L1,moc $(uihdr),=> $$@)
353 $$(QUIET)$$(VBOX_MOC) $(uihdr) -o $$@
354
355endef
356
357## Generate a rule to create a .qm file from a NLS translation
358# source (.ts).
359# @param $tsfile Translation source file
360define def_qt_gen_nls
361
362$(eval qmfile := $(PATH_$(target))/nls/$(notdir $(basename $(tsfile))).qm)
363
364OTHER_CLEAN += $(qmfile)
365
366$(qmfile): $(tsfile) | $$(call DIRDEP,$(dir $(qmfile)))
367 $$(call MSG_L1,lrelease $(tsfile),=> $$@)
368 $$(QUIET)$$(VBOX_LRELEASE) $(tsfile) -qm $$@
369
370endef
371
372## Generate rules for generating the Qt source for a target.
373# @param $target Target name.
374define def_qt_gen_src
375
376# moc srcs from hdrs with Q_OBJECT
377$(foreach mochdr,$($(target)_QT_MOCHDRS),$(eval $(def_qt_gen_src_moc)))
378# moc includes from srcs with Q_OBJECT
379$(foreach mocsrc,$($(target)_QT_MOCSRCS),$(eval $(def_qt_gen_inc_moc)))
380# moc includes from UI headers with Q_OBJECT
381$(foreach mocuihdr,$($(target)_QT_MOCUIHDRS),$(eval $(def_qt_gen_inc_mocuihdr)))
382# UI sources
383$(foreach uifile,$($(target)_QT_UISRCS),$(eval $(def_qt_gen_src_ui)))
384# NLS files
385$(foreach tsfile,$($(target)_QT_TRANSLATIONS),$(eval $(def_qt_gen_nls)))
386$(foreach tsfile,$($(target)_QT_TRANSLATIONS_QT),$(eval $(def_qt_gen_nls)))
387# dirs
388$$(call DIRDEP,$(PATH_$(target))/ui/) \
389$$(call DIRDEP,$(PATH_$(target))/moc/) \
390$$(call DIRDEP,$(PATH_$(target))/nls/):
391 $$(call MSG_L2,Creating directory $$@)
392 $$(QUIET)$$(MKDIR) -p $$@
393
394endef
395
396# Generate Qt source rules.
397$(foreach target,VirtualBox,$(eval $(def_qt_gen_src)))
398
399
400# Generate COM Wrappers
401.NOTPARALLEL: $(WRAPPERSFILE) $(WRAPPERSINCFILE)
402
403$(WRAPPERSINCFILE): $(WRAPPERSFILE)
404
405$(WRAPPERSFILE): $(XIDLFILE) $(WRAPPERSTEMPLATE) | $(call DIRDEP,$(PATH_VirtualBox)/include/)
406 $(call MSG_L1,xsltproc $<,=> $@)
407 $(QUIET)$(VBOX_XSLTPROC) -o $@ $(WRAPPERSTEMPLATE) $<
408
409$(call DIRDEP,$(PATH_VirtualBox)/include/):
410 $(call MSG_L2,Creating directory $@)
411 $(QUIET)$(MKDIR) -p $@
412
413# this is actually necessary only for Win32 target with disabled dependencies
414define def_wrapper_deps
415$(src): $(WRAPPERSFILE) $(WRAPPERSINCFILE)
416endef
417
418$(foreach src,$(VirtualBox_SOURCES),$(eval $(def_wrapper_deps)))
419
420# static images imported from VBoxUI.pro as VirtualBox_QT_IMAGES
421
422$(PATH_VirtualBox)/ui/vbox_image_collection.txt: VBoxUI.pro $(VirtualBox_QT_IMAGES)
423 @echo " \
424 $(VirtualBox_QT_IMAGES) \
425 " > $@
426
427$(PATH_VirtualBox)/ui/vbox_image_collection.cpp: $(PATH_VirtualBox)/ui/vbox_image_collection.txt
428 $(call MSG_L1,uic $<,=> $@)
429 $(QUIET)$(VBOX_UIC) -o $@ -embed VBoxGUI -f $<
430
431VirtualBox_GENSRCS += $(PATH_VirtualBox)/ui/vbox_image_collection.cpp
432OTHER_CLEAN += $(PATH_VirtualBox)/ui/vbox_image_collection.txt
433
434
435#
436# Hand made dependencies go here.
437# Basically, here are dependencies for generated UI source files that
438# include generated headers in turn.
439#
440
441$(PATH_VirtualBox)/ui/VBoxDiskImageManagerDlg.cpp: \
442 $(PATH_VirtualBox)/ui/VBoxNewHDWzd.h
443
444# Make all generated UI sources dependent on all generated headers (since they
445# may include them). This is safer than indifidual dependencies above but
446# currently disabled, because will cause all UI sources to be rebuilt one a
447# single one changes.
448#$(patsubst %,$(PATH_VirtualBox)/ui/%.cpp,$(notdir $(basename $(VirtualBox_QT_UISRCS)))) : $(VirtualBox_GENHDRS)
449
450
451#
452# Custom targets
453#
454
455# Update all known NLS translation (.ts) files in the nls/ subdirectory.
456# NOTE: This target is intened to be run only by the GUI maintainer shortly
457# before a new product release. VirtualBox_xx_YY.ts is a template for new
458# languages and should never be actually translated or installed.
459updatenls: $(VirtualBox_SOURCES) $(VirtualBox_HEADERS)
460 $(call MSG_L1,lupdate all languages (nls/*.ts))
461 $(QUIET)$(VBOX_LUPDATE) $^ -ts $(VirtualBox_QT_TRANSLATIONS) nls/VirtualBox_xx_YY.ts
462
463
464#
465# Test targets
466#
467
468test:
469 @echo ====================
470 @echo $(VirtualBox_GENSRCS) | $(SED) -e "s/ /\n/g"
471 @echo --------------------
472 @echo $(VirtualBox_GENSRCS_REAL) | $(SED) -e "s/ /\n/g"
473 @echo ====================
474 @echo $(VirtualBox_GENHDRS) | $(SED) -e "s/ /\n/g"
475 @echo --------------------
476 @echo $(VirtualBox_GENHDRS_REAL) | $(SED) -e "s/ /\n/g"
477 @echo ====================
478
479test2:
480 @echo $(OTHER_CLEAN) | $(SED) -e "s/ /\n/g"
481
482test3:
483 @echo $(VirtualBox_HEADERS) | $(SED) -e "s/ /\n/g"
484
485testwrappers: $(WRAPPERSFILE)
486
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette