nasm.nsi 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. #!Nsis Installer Command Script
  2. #
  3. # Copyright (c) 2009, Shao Miller (shao.miller@yrdsb.edu.on.ca)
  4. # Copyright (c) 2009, Cyrill Gorcunov (gorcunov@gmail.com)
  5. # All rights reserved.
  6. #
  7. # The script requires NSIS v2.45 (or any later)
  8. #
  9. # Redistribution and use in source and binary forms, with or without
  10. # modification, are permitted provided that the following conditions are met:
  11. # * Redistributions of source code must retain the above copyright
  12. # notice, this list of conditions and the following disclaimer.
  13. # * Redistributions in binary form must reproduce the above copyright
  14. # notice, this list of conditions and the following disclaimer in the
  15. # documentation and/or other materials provided with the distribution.
  16. #
  17. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. # ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  19. # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20. # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR
  21. # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  23. # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  24. # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  25. # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  26. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. !addincludedir "${objdir}\nsis"
  28. !addincludedir "${srcdir}\nsis"
  29. !include "version.nsh"
  30. !include "arch.nsh"
  31. !define PRODUCT_NAME "Netwide Assembler"
  32. !define PRODUCT_SHORT_NAME "nasm"
  33. !define PACKAGE_NAME "${PRODUCT_NAME} ${VERSION}"
  34. !define PACKAGE_SHORT_NAME "${PRODUCT_SHORT_NAME}-${VERSION}"
  35. SetCompressor /solid lzma
  36. !if "${NSIS_PACKEDVERSION}" >= 0x3000000
  37. Unicode true
  38. !endif
  39. !define MULTIUSER_EXECUTIONLEVEL Highest
  40. !define MULTIUSER_MUI
  41. !define MULTIUSER_INSTALLMODE_COMMANDLINE
  42. !define MULTIUSER_INSTALLMODE_INSTDIR "NASM"
  43. !include "NASMMultiUser.nsh"
  44. !insertmacro MULTIUSER_PAGE_INSTALLMODE
  45. !insertmacro MULTIUSER_INSTALLMODEPAGE_INTERFACE
  46. ;--------------------------------
  47. ;General
  48. ;Name and file
  49. Name "${PACKAGE_NAME}"
  50. OutFile "${objdir}\${PACKAGE_SHORT_NAME}-installer-${ARCH}.exe"
  51. ;Get installation folder from registry if available
  52. InstallDirRegKey HKCU "Software\${PRODUCT_SHORT_NAME}" ""
  53. ;Request application privileges for Windows Vista
  54. RequestExecutionLevel user
  55. ;--------------------------------
  56. ;Variables
  57. Var StartMenuFolder
  58. Var CmdFailed
  59. ;--------------------------------
  60. ;Interface Settings
  61. Caption "${PACKAGE_SHORT_NAME} installation"
  62. Icon "${srcdir}\nsis\nasm.ico"
  63. UninstallIcon "${srcdir}\nsis\nasm-un.ico"
  64. !define MUI_ABORTWARNING
  65. ;--------------------------------
  66. ;Pages
  67. !insertmacro MUI_PAGE_COMPONENTS
  68. !insertmacro MUI_PAGE_DIRECTORY
  69. ;Start Menu Folder Page Configuration
  70. !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
  71. !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${PRODUCT_SHORT_NAME}"
  72. !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_SHORT_NAME}"
  73. !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
  74. !insertmacro MUI_PAGE_INSTFILES
  75. !insertmacro MUI_UNPAGE_CONFIRM
  76. !insertmacro MUI_UNPAGE_INSTFILES
  77. ;--------------------------------
  78. ;Installer Sections
  79. !insertmacro MUI_LANGUAGE English
  80. Section "NASM" SecNasm
  81. Sectionin RO
  82. SetOutPath "$INSTDIR"
  83. File "${srcdir}\LICENSE"
  84. File "${objdir}\nasm.exe"
  85. File "${objdir}\ndisasm.exe"
  86. File "${srcdir}\nsis\nasm.ico"
  87. ;Store installation folder
  88. WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}" "" $INSTDIR
  89. ;Store shortcuts folder
  90. WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}\" "lnk" $SMPROGRAMS\$StartMenuFolder
  91. WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}\" "bat-lnk" $DESKTOP\${PRODUCT_SHORT_NAME}.lnk
  92. ;
  93. ; the bat we need
  94. StrCpy $CmdFailed "true"
  95. FileOpen $0 "nasmpath.bat" w
  96. IfErrors skip
  97. StrCpy $CmdFailed "false"
  98. FileWrite $0 "@set path=$INSTDIR;%path%$\r$\n"
  99. FileWrite $0 "@%comspec%"
  100. FileClose $0
  101. CreateShortCut "$DESKTOP\${PRODUCT_SHORT_NAME}.lnk" "$INSTDIR\nasmpath.bat" "" "$INSTDIR\nasm.ico" 0
  102. skip:
  103. ;Create uninstaller
  104. WriteUninstaller "$INSTDIR\Uninstall.exe"
  105. !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
  106. ;Create shortcuts
  107. CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
  108. StrCmp $CmdFailed "true" +2
  109. CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${PRODUCT_SHORT_NAME}-shell.lnk" "$INSTDIR\nasmpath.bat"
  110. CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${PRODUCT_SHORT_NAME}.lnk" "$INSTDIR\nasm.exe" "" "$INSTDIR\nasm.ico" 0
  111. CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
  112. !insertmacro MUI_STARTMENU_WRITE_END
  113. SectionEnd
  114. Section "RDOFF" SecRdoff
  115. File "${objdir}\rdoff\ldrdf.exe"
  116. File "${objdir}\rdoff\rdf2bin.exe"
  117. File "${objdir}\rdoff\rdf2com.exe"
  118. File "${objdir}\rdoff\rdf2ith.exe"
  119. File "${objdir}\rdoff\rdf2ihx.exe"
  120. File "${objdir}\rdoff\rdf2srec.exe"
  121. File "${objdir}\rdoff\rdfdump.exe"
  122. File "${objdir}\rdoff\rdflib.exe"
  123. SectionEnd
  124. Section "Manual" SecManual
  125. SetOutPath "$INSTDIR"
  126. File "${objdir}\doc\nasmdoc.pdf"
  127. CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Manual.lnk" "$INSTDIR\nasmdoc.pdf"
  128. SectionEnd
  129. Section "VS8 integration" SecVS8
  130. CreateDirectory "$INSTDIR\VSrules"
  131. SetOutPath "$INSTDIR\VSrules"
  132. File "${srcdir}\contrib\VSrules\nasm.README"
  133. File "${srcdir}\contrib\VSrules\nasm.rules"
  134. SectionEnd
  135. ;--------------------------------
  136. ;Descriptions
  137. ;Language strings
  138. LangString DESC_SecNasm ${LANG_ENGLISH} "NASM assembler and disassember modules"
  139. LangString DESC_SecManual ${LANG_ENGLISH} "Complete NASM manual (pdf file)"
  140. LangString DESC_SecRdoff ${LANG_ENGLISH} "RDOFF utilities (you may not need it if you don't know what is it)"
  141. LangString DESC_SecVS8 ${LANG_ENGLISH} "Visual Studio 2008 NASM integration (rules file)"
  142. ;Assign language strings to sections
  143. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  144. !insertmacro MUI_DESCRIPTION_TEXT ${SecNasm} $(DESC_SecNasm)
  145. !insertmacro MUI_DESCRIPTION_TEXT ${SecRdoff} $(DESC_SecRdoff)
  146. !insertmacro MUI_DESCRIPTION_TEXT ${SecManual} $(DESC_SecManual)
  147. !insertmacro MUI_DESCRIPTION_TEXT ${SecVS8} $(DESC_SecVS8)
  148. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  149. ;--------------------------------
  150. ;Uninstaller Section
  151. Section "Uninstall"
  152. ;
  153. ; files on HDD
  154. IfFileExists "$INSTDIR" +3 +1
  155. MessageBox MB_OK "No files found, aborting."
  156. Abort
  157. MessageBox MB_YESNO "The following directory will be deleted$\n$INSTDIR" IDYES rm_instdir_true IDNO rm_instdir_false
  158. rm_instdir_true:
  159. RMDir /r /rebootok "$INSTDIR"
  160. rm_instdir_false:
  161. ;
  162. ; Desktop link
  163. ReadRegStr $0 HKCU Software\${PRODUCT_SHORT_NAME} "bat-lnk"
  164. StrCmp $0 0 +1 +3
  165. MessageBox MB_OK "Invalid path to a bat-lnk file, aborting"
  166. Abort
  167. IfFileExists $0 +3 +1
  168. MessageBox MB_OK "No bat-lnk files found, aborting."
  169. Abort
  170. MessageBox MB_YESNO "The following file will be deleted$\n$0" IDYES rm_batlinks_true IDNO rm_batlinks_false
  171. rm_batlinks_true:
  172. Delete /rebootok "$0"
  173. RMDir "$0"
  174. rm_batlinks_false:
  175. ;
  176. ; Start menu folder
  177. ReadRegStr $0 HKCU Software\${PRODUCT_SHORT_NAME} "lnk"
  178. StrCmp $0 0 +1 +3
  179. MessageBox MB_OK "Invalid path to a lnk file, aborting"
  180. Abort
  181. IfFileExists $0 +3 +1
  182. MessageBox MB_OK "No lnk files found, aborting."
  183. Abort
  184. MessageBox MB_YESNO "The following directory will be deleted$\n$0" IDYES rm_links_true IDNO rm_links_false
  185. rm_links_true:
  186. Delete /rebootok "$0\*"
  187. RMDir "$0"
  188. rm_links_false:
  189. DeleteRegKey /ifempty HKCU "Software\${PRODUCT_SHORT_NAME}"
  190. SectionEnd
  191. ;
  192. ; MUI requires this hooks
  193. Function .onInit
  194. SetRegView ${BITS}
  195. !insertmacro MULTIUSER_INIT
  196. FunctionEnd
  197. Function un.onInit
  198. !insertmacro MULTIUSER_UNINIT
  199. FunctionEnd