Skip to content

Commit f53ec69

Browse files
committed
w32, w64: Add build rule for installer
The new rules in Makefile allow building installers for QEMU on Windows using NSIS, a package which is also available for Linux distributions (so cross builds are possible). The rules for NSIS are in qemu.nsi which also uses two new images. Signed-off-by: Stefan Weil <[email protected]>
1 parent 461bdb3 commit f53ec69

File tree

4 files changed

+305
-0
lines changed

4 files changed

+305
-0
lines changed

Makefile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,61 @@ qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \
437437
qemu-img.texi qemu-nbd.texi qemu-options.texi \
438438
qemu-monitor.texi qemu-img-cmds.texi
439439

440+
ifdef CONFIG_WIN32
441+
442+
INSTALLER = qemu-setup-$(VERSION)$(EXESUF)
443+
444+
nsisflags = -V2 -NOCD
445+
446+
ifneq ($(wildcard $(SRC_PATH)/dll),)
447+
ifeq ($(ARCH),x86_64)
448+
# 64 bit executables
449+
DLL_PATH = $(SRC_PATH)/dll/w64
450+
nsisflags += -DW64
451+
else
452+
# 32 bit executables
453+
DLL_PATH = $(SRC_PATH)/dll/w32
454+
endif
455+
endif
456+
457+
.PHONY: installer
458+
installer: $(INSTALLER)
459+
460+
INSTDIR=/tmp/qemu-nsis
461+
462+
$(INSTALLER): $(SRC_PATH)/qemu.nsi
463+
make install prefix=${INSTDIR}
464+
ifdef SIGNCODE
465+
(cd ${INSTDIR}; \
466+
for i in *.exe; do \
467+
$(SIGNCODE) $${i}; \
468+
done \
469+
)
470+
endif # SIGNCODE
471+
(cd ${INSTDIR}; \
472+
for i in qemu-system-*.exe; do \
473+
arch=$${i%.exe}; \
474+
arch=$${arch#qemu-system-}; \
475+
echo Section \"$$arch\" Section_$$arch; \
476+
echo SetOutPath \"\$$INSTDIR\"; \
477+
echo File \"\$${BINDIR}\\$$i\"; \
478+
echo SectionEnd; \
479+
done \
480+
) >${INSTDIR}/system-emulations.nsh
481+
makensis $(nsisflags) \
482+
$(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
483+
$(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
484+
-DBINDIR="${INSTDIR}" \
485+
$(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
486+
-DSRCDIR="$(SRC_PATH)" \
487+
-DOUTFILE="$(INSTALLER)" \
488+
$(SRC_PATH)/qemu.nsi
489+
rm -r ${INSTDIR}
490+
ifdef SIGNCODE
491+
$(SIGNCODE) $(INSTALLER)
492+
endif # SIGNCODE
493+
endif # CONFIG_WIN
494+
440495
# Add a dependency on the generated files, so that they are always
441496
# rebuilt before other object files
442497
ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))

pc-bios/qemu-nsis.bmp

151 KB
Binary file not shown.

pc-bios/qemu-nsis.ico

4.73 KB
Binary file not shown.

qemu.nsi

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
;!/usr/bin/makensis
2+
3+
; This NSIS script creates an installer for QEMU on Windows.
4+
5+
; Copyright (C) 2006-2012 Stefan Weil
6+
;
7+
; This program is free software: you can redistribute it and/or modify
8+
; it under the terms of the GNU General Public License as published by
9+
; the Free Software Foundation, either version 2 of the License, or
10+
; (at your option) version 3 or any later version.
11+
;
12+
; This program is distributed in the hope that it will be useful,
13+
; but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
; GNU General Public License for more details.
16+
;
17+
; You should have received a copy of the GNU General Public License
18+
; along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
20+
; NSIS_WIN32_MAKENSIS
21+
22+
!define PRODUCT "QEMU"
23+
!define URL "http://www.qemu.org/"
24+
25+
!define UNINST_EXE "$INSTDIR\qemu-uninstall.exe"
26+
!define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}"
27+
28+
!ifndef BINDIR
29+
!define BINDIR nsis.tmp
30+
!endif
31+
!ifndef SRCDIR
32+
!define SRCDIR .
33+
!endif
34+
!ifndef OUTFILE
35+
!define OUTFILE "qemu-setup.exe"
36+
!endif
37+
38+
; Optionally install documentation.
39+
!ifndef CONFIG_DOCUMENTATION
40+
!define CONFIG_DOCUMENTATION
41+
!endif
42+
43+
; Use maximum compression.
44+
SetCompressor /SOLID lzma
45+
46+
!include "MUI2.nsh"
47+
48+
; The name of the installer.
49+
Name "QEMU"
50+
51+
; The file to write
52+
OutFile "${OUTFILE}"
53+
54+
; The default installation directory.
55+
!ifdef W64
56+
InstallDir $PROGRAMFILES64\qemu
57+
!else
58+
InstallDir $PROGRAMFILES\qemu
59+
!endif
60+
61+
; Registry key to check for directory (so if you install again, it will
62+
; overwrite the old one automatically)
63+
InstallDirRegKey HKLM "Software\qemu" "Install_Dir"
64+
65+
; Request administrator privileges for Windows Vista.
66+
RequestExecutionLevel admin
67+
68+
;--------------------------------
69+
; Interface Settings.
70+
;!define MUI_HEADERIMAGE "qemu-nsis.bmp"
71+
; !define MUI_SPECIALBITMAP "qemu.bmp"
72+
!define MUI_ICON "${SRCDIR}\pc-bios\qemu-nsis.ico"
73+
!define MUI_UNICON "${SRCDIR}\pc-bios\qemu-nsis.ico"
74+
!define MUI_WELCOMEFINISHPAGE_BITMAP "${SRCDIR}\pc-bios\qemu-nsis.bmp"
75+
; !define MUI_HEADERIMAGE_BITMAP "qemu-install.bmp"
76+
; !define MUI_HEADERIMAGE_UNBITMAP "qemu-uninstall.bmp"
77+
; !define MUI_COMPONENTSPAGE_SMALLDESC
78+
; !define MUI_WELCOMEPAGE_TEXT "Insert text here.$\r$\n$\r$\n$\r$\n$_CLICK"
79+
80+
;--------------------------------
81+
; Pages.
82+
83+
!insertmacro MUI_PAGE_WELCOME
84+
!insertmacro MUI_PAGE_LICENSE "${SRCDIR}\COPYING"
85+
!insertmacro MUI_PAGE_COMPONENTS
86+
!insertmacro MUI_PAGE_DIRECTORY
87+
!insertmacro MUI_PAGE_INSTFILES
88+
!define MUI_FINISHPAGE_LINK "Visit the QEMU Wiki online!"
89+
!define MUI_FINISHPAGE_LINK_LOCATION "${URL}"
90+
!insertmacro MUI_PAGE_FINISH
91+
92+
!insertmacro MUI_UNPAGE_CONFIRM
93+
!insertmacro MUI_UNPAGE_INSTFILES
94+
95+
;--------------------------------
96+
; Languages.
97+
98+
!insertmacro MUI_LANGUAGE "English"
99+
!insertmacro MUI_LANGUAGE "French"
100+
!insertmacro MUI_LANGUAGE "German"
101+
102+
;--------------------------------
103+
104+
; The stuff to install.
105+
Section "${PRODUCT} (required)"
106+
107+
SectionIn RO
108+
109+
; Set output path to the installation directory.
110+
SetOutPath "$INSTDIR"
111+
112+
File "${SRCDIR}\Changelog"
113+
File "${SRCDIR}\COPYING"
114+
File "${SRCDIR}\COPYING.LIB"
115+
File "${SRCDIR}\README"
116+
File "${SRCDIR}\VERSION"
117+
118+
File "${BINDIR}\*.bmp"
119+
File "${BINDIR}\*.bin"
120+
File "${BINDIR}\*.dtb"
121+
File "${BINDIR}\*.rom"
122+
File "${BINDIR}\openbios-*"
123+
124+
File /r "${BINDIR}\keymaps"
125+
!ifdef CONFIG_GTK
126+
File /r "${BINDIR}\share"
127+
!endif
128+
129+
!ifdef W64
130+
SetRegView 64
131+
!endif
132+
133+
; Write the installation path into the registry
134+
WriteRegStr HKLM SOFTWARE\${PRODUCT} "Install_Dir" "$INSTDIR"
135+
136+
; Write the uninstall keys for Windows
137+
WriteRegStr HKLM "${UNINST_KEY}" "DisplayName" "QEMU"
138+
WriteRegStr HKLM "${UNINST_KEY}" "UninstallString" '"${UNINST_EXE}"'
139+
WriteRegDWORD HKLM "${UNINST_KEY}" "NoModify" 1
140+
WriteRegDWORD HKLM "${UNINST_KEY}" "NoRepair" 1
141+
WriteUninstaller "qemu-uninstall.exe"
142+
SectionEnd
143+
144+
Section "Tools" SectionTools
145+
SetOutPath "$INSTDIR"
146+
File "${BINDIR}\qemu-img.exe"
147+
File "${BINDIR}\qemu-io.exe"
148+
SectionEnd
149+
150+
SectionGroup "System Emulations" SectionSystem
151+
152+
!include "${BINDIR}\system-emulations.nsh"
153+
154+
SectionGroupEnd
155+
156+
!ifdef DLLDIR
157+
Section "Libraries (DLL)" SectionDll
158+
SetOutPath "$INSTDIR"
159+
File "${DLLDIR}\*.dll"
160+
SectionEnd
161+
!endif
162+
163+
!ifdef CONFIG_DOCUMENTATION
164+
Section "Documentation" SectionDoc
165+
SetOutPath "$INSTDIR"
166+
File "${BINDIR}\qemu-doc.html"
167+
File "${BINDIR}\qemu-tech.html"
168+
CreateDirectory "$SMPROGRAMS\${PRODUCT}"
169+
CreateShortCut "$SMPROGRAMS\${PRODUCT}\User Documentation.lnk" "$INSTDIR\qemu-doc.html" "" "$INSTDIR\qemu-doc.html" 0
170+
CreateShortCut "$SMPROGRAMS\${PRODUCT}\Technical Documentation.lnk" "$INSTDIR\qemu-tech.html" "" "$INSTDIR\qemu-tech.html" 0
171+
SectionEnd
172+
!endif
173+
174+
; Optional section (can be disabled by the user)
175+
Section "Start Menu Shortcuts" SectionMenu
176+
CreateDirectory "$SMPROGRAMS\${PRODUCT}"
177+
CreateShortCut "$SMPROGRAMS\${PRODUCT}\Uninstall.lnk" "${UNINST_EXE}" "" "${UNINST_EXE}" 0
178+
SectionEnd
179+
180+
;--------------------------------
181+
182+
; Uninstaller
183+
184+
Section "Uninstall"
185+
; Remove registry keys
186+
!ifdef W64
187+
SetRegView 64
188+
!endif
189+
DeleteRegKey HKLM "${UNINST_KEY}"
190+
DeleteRegKey HKLM SOFTWARE\${PRODUCT}
191+
192+
; Remove shortcuts, if any
193+
Delete "$SMPROGRAMS\${PRODUCT}\User Documentation.lnk"
194+
Delete "$SMPROGRAMS\${PRODUCT}\Technical Documentation.lnk"
195+
Delete "$SMPROGRAMS\${PRODUCT}\Uninstall.lnk"
196+
RMDir "$SMPROGRAMS\${PRODUCT}"
197+
198+
; Remove files and directories used
199+
Delete "$INSTDIR\Changelog"
200+
Delete "$INSTDIR\COPYING"
201+
Delete "$INSTDIR\COPYING.LIB"
202+
Delete "$INSTDIR\README"
203+
Delete "$INSTDIR\VERSION"
204+
Delete "$INSTDIR\*.bmp"
205+
Delete "$INSTDIR\*.bin"
206+
Delete "$INSTDIR\*.dll"
207+
Delete "$INSTDIR\*.dtb"
208+
Delete "$INSTDIR\*.rom"
209+
Delete "$INSTDIR\openbios-*"
210+
Delete "$INSTDIR\qemu-img.exe"
211+
Delete "$INSTDIR\qemu-io.exe"
212+
Delete "$INSTDIR\qemu.exe"
213+
Delete "$INSTDIR\qemu-system-*.exe"
214+
Delete "$INSTDIR\qemu-doc.html"
215+
Delete "$INSTDIR\qemu-tech.html"
216+
RMDir /r "$INSTDIR\keymaps"
217+
RMDir /r "$INSTDIR\share"
218+
; Remove generated files
219+
Delete "$INSTDIR\stderr.txt"
220+
Delete "$INSTDIR\stdout.txt"
221+
; Remove uninstaller
222+
Delete "${UNINST_EXE}"
223+
RMDir "$INSTDIR"
224+
SectionEnd
225+
226+
;--------------------------------
227+
228+
; Descriptions (mouse-over).
229+
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
230+
!insertmacro MUI_DESCRIPTION_TEXT ${SectionSystem} "System emulation."
231+
!insertmacro MUI_DESCRIPTION_TEXT ${Section_alpha} "Alpha system emulation."
232+
!insertmacro MUI_DESCRIPTION_TEXT ${Section_alphaw} "Alpha system emulation (GUI)."
233+
!insertmacro MUI_DESCRIPTION_TEXT ${Section_i386} "PC i386 system emulation."
234+
!insertmacro MUI_DESCRIPTION_TEXT ${Section_i386w} "PC i386 system emulation (GUI)."
235+
!insertmacro MUI_DESCRIPTION_TEXT ${SectionTools} "Tools."
236+
!ifdef DLLDIR
237+
!insertmacro MUI_DESCRIPTION_TEXT ${SectionDll} "Runtime Libraries (DLL)."
238+
!endif
239+
!ifdef CONFIG_DOCUMENTATION
240+
!insertmacro MUI_DESCRIPTION_TEXT ${SectionDoc} "Documentation."
241+
!endif
242+
!insertmacro MUI_DESCRIPTION_TEXT ${SectionMenu} "Menu entries."
243+
!insertmacro MUI_FUNCTION_DESCRIPTION_END
244+
245+
;--------------------------------
246+
; Functions.
247+
248+
Function .onInit
249+
!insertmacro MUI_LANGDLL_DISPLAY
250+
FunctionEnd

0 commit comments

Comments
 (0)