summaryrefslogtreecommitdiffstats
path: root/zbar.nsi
blob: a5da39bea72f5b341258e68f03a34637964b00d1 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#------------------------------------------------------------------------
#  Copyright 2009 (c) Jeff Brown <spadix@users.sourceforge.net>
#
#  This file is part of the ZBar Bar Code Reader.
#
#  The ZBar Bar Code Reader is free software; you can redistribute it
#  and/or modify it under the terms of the GNU Lesser Public License as
#  published by the Free Software Foundation; either version 2.1 of
#  the License, or (at your option) any later version.
#
#  The ZBar Bar Code Reader is distributed in the hope that it will be
#  useful, but WITHOUT ANY WARRANTY; without even the implied warranty
#  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Lesser Public License for more details.
#
#  You should have received a copy of the GNU Lesser Public License
#  along with the ZBar Bar Code Reader; if not, write to the Free
#  Software Foundation, Inc., 51 Franklin St, Fifth Floor,
#  Boston, MA  02110-1301  USA
#
#  http://sourceforge.net/projects/zbar
#------------------------------------------------------------------------

!ifndef VERSION
  !define VERSION "test"
!endif
!ifndef PREFIX
  !define PREFIX "\usr\mingw32\usr"
!endif

!define ZBAR_KEY "Software\ZBar"
!define UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\ZBar"

OutFile zbar-${VERSION}-setup.exe

SetCompressor /SOLID bzip2

InstType "Typical"
InstType "Full"

InstallDir $PROGRAMFILES\ZBar
InstallDirRegKey HKLM ${ZBAR_KEY} "InstallDir"

!define SMPROG_ZBAR "$SMPROGRAMS\ZBar Bar Code Reader"

Icon ${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico
UninstallIcon ${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico

# do we need admin to install uninstall info?
#RequestExecutionLevel admin


!include "MUI2.nsh"
!include "Memento.nsh"


Name "ZBar"
Caption "ZBar ${VERSION} Setup"


!define MEMENTO_REGISTRY_ROOT HKLM
!define MEMENTO_REGISTRY_KEY ${UNINSTALL_KEY}

!define MUI_ABORTWARNING
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_UNFINISHPAGE_NOAUTOCLOSE

!define MUI_ICON ${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico
!define MUI_UNICON ${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico

!define MUI_WELCOMEFINISHPAGE_BITMAP ${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp
!define MUI_UNWELCOMEFINISHPAGE_BITMAP ${NSISDIR}\Contrib\Graphics\Wizard\orange-uninstall.bmp

!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP ${NSISDIR}\Contrib\Graphics\Header\orange.bmp
!define MUI_HEADERIMAGE_UNBITMAP ${NSISDIR}\Contrib\Graphics\Header\orange-uninstall.bmp

!define MUI_WELCOMEPAGE_TITLE "Welcome to the ZBar ${VERSION} Setup Wizard"
!define MUI_WELCOMEPAGE_TEXT \
    "This wizard will guide you through the installation of the \
    ZBar Bar Code Reader version ${VERSION}."

!insertmacro MUI_PAGE_WELCOME

!insertmacro MUI_PAGE_LICENSE "share\doc\zbar\LICENSE.md"

!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_COMPONENTSPAGE_CHECKBITMAP ${NSISDIR}\Contrib\Graphics\Checks\simple-round2.bmp

!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

Function ShowREADME
     Exec '"notepad.exe" "$INSTDIR\README-windows.md"'
FunctionEnd

!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION ShowREADME
!define MUI_FINISHPAGE_LINK \
        "Visit the ZBar website for the latest news, FAQs and support"
!define MUI_FINISHPAGE_LINK_LOCATION "https://github.com/mchehab/zbar"

!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

Section "ZBar Core Files (required)" SecCore
    DetailPrint "Installing ZBar Program and Library..."
    SectionIn 1 2 RO

    SetOutPath $INSTDIR
    File share\doc\zbar\README-windows.md
    File share\doc\zbar\NEWS.md
    File share\doc\zbar\TODO.md
    File share\doc\zbar\COPYING
    File share\doc\zbar\LICENSE.md

    # emit a batch file to add the install directory to the path
    FileOpen $0 zbarvars.bat w
    FileWrite $0 "@rem  Add the ZBar installation directory to the path$\n"
    FileWrite $0 "@rem  so programs may be run from the command prompt$\n"
    FileWrite $0 "@set PATH=%PATH%;$INSTDIR\bin$\n"
    FileWrite $0 "@cd /D $INSTDIR$\n"
    FileWrite $0 "@echo For basic command instructions type:$\n"
    FileWrite $0 "@echo     zbarcam --help$\n"
    FileWrite $0 "@echo     zbarimg --help$\n"
    FileWrite $0 "@echo Try running:$\n"
    FileWrite $0 "@echo     zbarimg -d examples\barcode.png$\n"
    FileClose $0

    SetOutPath $INSTDIR\bin
    File bin\libzbar-0.dll
    File bin\zbarimg.exe
    File bin\zbarcam.exe

    # dependencies
    File ${PREFIX}\bin\zlib1.dll
    File ${PREFIX}\bin\libjpeg-7.dll
    File ${PREFIX}\bin\libpng12-0.dll
    File ${PREFIX}\bin\libtiff-3.dll
    File ${PREFIX}\bin\libxml2-2.dll
    File ${PREFIX}\bin\libiconv-2.dll
    File ${PREFIX}\bin\libMagickCore-2.dll
    File ${PREFIX}\bin\libMagickWand-2.dll

    FileOpen $0 zbarcam.bat w
    FileWrite $0 "@set PATH=%PATH%;$INSTDIR\bin$\n"
    FileWrite $0 "@echo This is the zbarcam output window.$\n"
    FileWrite $0 "@echo Hold a bar code in front of the camera (make sure it's in focus!)$\n"
    FileWrite $0 "@echo and decoded results will appear below.$\n"
    FileWrite $0 "@echo.$\n"
    FileWrite $0 "@echo Initializing camera, please wait...$\n"
    FileWrite $0 "@echo.$\n"
    FileWrite $0 "@zbarcam.exe --prescale=640x480$\n"
    FileWrite $0 "@if errorlevel 1 pause$\n"
    FileClose $0

    SetOutPath $INSTDIR\doc
    File share\doc\zbar\html\*

    SetOutPath $INSTDIR\examples
    File share\zbar\barcode.png
SectionEnd

#SectionGroup "Start Menu and Desktop Shortcuts" SecShortcuts
    Section "Start Menu Shortcuts" SecShortcutsStartMenu
        DetailPrint "Creating Start Menu Shortcuts..."
        SectionIn 1 2
        SetOutPath "${SMPROG_ZBAR}"
        #CreateShortCut "${SMPROG_ZBAR}\ZBar.lnk" "$INSTDIR\ZBar.exe"
        CreateDirectory "${SMPROG_ZBAR}"
        CreateShortCut "zbarcam.lnk" "$\"$INSTDIR\bin\zbarcam.bat$\"" "" \
                       "$INSTDIR\bin\zbarcam.exe"
        ExpandEnvStrings $0 '%comspec%'
        CreateShortCut "ZBar Command Prompt.lnk" \
                       $0 "/k $\"$\"$INSTDIR\zbarvars.bat$\"$\"" $0
        CreateShortCut "Command Reference.lnk" \
                       "$\"$INSTDIR\doc\ref.html$\""
    SectionEnd

#    Section "Desktop Shortcut" SecShortcutsDesktop
#        DetailPrint "Creating Desktop Shortcut..."
#        SectionIn 1 2
#        SetOutPath $INSTDIR
#        #CreateShortCut "$DESKTOP\ZBar.lnk" "$INSTDIR\ZBar.exe"
#    SectionEnd
#SectionGroupEnd

Section "Development Headers and Libraries" SecDevel
    DetailPrint "Installing ZBar Development Files..."
    SectionIn 2

    SetOutPath $INSTDIR\include
    File include\zbar.h

    SetOutPath $INSTDIR\include\zbar
    File include\zbar\Video.h
    File include\zbar\Exception.h
    File include\zbar\Symbol.h
    File include\zbar\Image.h
    File include\zbar\ImageScanner.h
    File include\zbar\Window.h
    File include\zbar\Processor.h
    File include\zbar\Decoder.h
    File include\zbar\Scanner.h

    SetOutPath $INSTDIR\lib
    File lib\libzbar-0.def
    File lib\libzbar-0.lib
    File lib\libzbar.dll.a

    SetOutPath $INSTDIR\examples
    File share\zbar\scan_image.cpp
    File share\zbar\scan_image.vcproj
SectionEnd

Section -post
    DetailPrint "Creating Registry Keys..."
    SetOutPath $INSTDIR
    WriteRegStr HKLM ${ZBAR_KEY} "InstallDir" $INSTDIR

    # register uninstaller
    WriteRegStr HKLM ${UNINSTALL_KEY} "UninstallString" \
                "$\"$INSTDIR\uninstall.exe$\""
    WriteRegStr HKLM ${UNINSTALL_KEY} "QuietUninstallString" \
                "$\"$INSTDIR\uninstall.exe$\" /S"
    WriteRegStr HKLM ${UNINSTALL_KEY} "InstallLocation" "$\"$INSTDIR$\""

    WriteRegStr HKLM ${UNINSTALL_KEY} "DisplayName" "ZBar Bar Code Reader"
    WriteRegStr HKLM ${UNINSTALL_KEY} "DisplayIcon" "$INSTDIR\bin\zbarimg.exe,0"
    WriteRegStr HKLM ${UNINSTALL_KEY} "DisplayVersion" "${VERSION}"

    WriteRegStr HKLM ${UNINSTALL_KEY} "URLInfoAbout" "http://zbar.sf.net/"
    WriteRegStr HKLM ${UNINSTALL_KEY} "HelpLink" "http://zbar.sf.net/"
    WriteRegDWORD HKLM ${UNINSTALL_KEY} "NoModify" "1"
    WriteRegDWORD HKLM ${UNINSTALL_KEY} "NoRepair" "1"

    DetailPrint "Generating Uninstaller..."
    WriteUninstaller $INSTDIR\uninstall.exe
SectionEnd


Section Uninstall
    DetailPrint "Uninstalling ZBar Bar Code Reader.."

    DetailPrint "Deleting Files..."
    Delete $INSTDIR\examples\barcode.png
    Delete $INSTDIR\examples\scan_image.cpp
    Delete $INSTDIR\examples\scan_image.vcproj
    RMDir $INSTDIR\examples
    RMDir /r $INSTDIR\include
    RMDir /r $INSTDIR\doc
    RMDir /r $INSTDIR\lib
    RMDir /r $INSTDIR\bin
    Delete $INSTDIR\README-windows.md
    Delete $INSTDIR\NEWS.md
    Delete $INSTDIR\TODO.md
    Delete $INSTDIR\COPYING
    Delete $INSTDIR\LICENSE.md
    Delete $INSTDIR\zbarvars.bat
    Delete $INSTDIR\uninstall.exe
    RMDir $INSTDIR

    DetailPrint "Removing Shortcuts..."
    RMDir /r "${SMPROG_ZBAR}"

    DetailPrint "Deleting Registry Keys..."
    DeleteRegKey HKLM ${ZBAR_KEY}
    DeleteRegKey HKLM ${UNINSTALL_KEY}
SectionEnd


!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
    !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} \
        "The core files required to use the bar code reader"
#    !insertmacro MUI_DESCRIPTION_TEXT ${SecShortcuts} \
#        "Adds icons to your start menu and/or your desktop for easy access"
    !insertmacro MUI_DESCRIPTION_TEXT ${SecShortcutsStartMenu} \
        "Adds shortcuts to your start menu"
#    !insertmacro MUI_DESCRIPTION_TEXT ${SecShortcutsDesktop} \
#        "Adds an icon on your desktop"
    !insertmacro MUI_DESCRIPTION_TEXT ${SecDevel} \
        "Optional files used to develop other applications using ZBar"
!insertmacro MUI_FUNCTION_DESCRIPTION_END