pw3270.nsi.in 8.25 KB
!include "MUI2.nsh"

Name "@PROGRAM_NAME@"
Caption "@PROGRAM_NAME@ - 3270 Emulator for windows/gtk"
outfile "@PROGRAM_NAME@-@PACKAGE_VERSION@-@PACKAGE_RELEASE@-@host_cpu@-install.exe"
XPStyle on

# define the directory to install to
installDir $PROGRAMFILES\@PROGRAM_NAME@

#define the installer icon
!define MUI_ICON "src\gtk2\@PROGRAM_NAME@.ico"
!define MUI_UNICON "src\gtk2\@PROGRAM_NAME@.ico"
icon "src\gtk2\@PROGRAM_NAME@.ico"

# Get installation folder from registry if available
InstallDirRegKey HKCU "Software\@PROGRAM_NAME@" ""

RequestExecutionLevel admin

# Properties
VIProductVersion "@PACKAGE_VERSION@.@PACKAGE_RELEASE@.@PACKAGE_REVISION@"
VIAddVersionKey "ProductName" "@PROGRAM_NAME@"
VIAddVersionKey "FileDescription" "3270 Emulator for windows/gtk"
VIAddVersionKey "FileVersion" "@PACKAGE_REVISION@"
VIAddVersionKey "LegalCopyright" "GPL"

# Interface

!define MUI_ABORTWARNING
# !insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "LICENSE"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

# !insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
# !insertmacro MUI_UNPAGE_FINISH

# Languages
!insertmacro MUI_LANGUAGE "English"

# Section scripts
!include Sections.nsh

# default section
SubSection "@PROGRAM_NAME@" SecMain

	Section "Core" SecCore

		# define the output path for this file
		setOutPath $INSTDIR
		SetShellVarContext all

		createShortCut "$SMPROGRAMS\@PROGRAM_NAME@.lnk" "$INSTDIR\@PROGRAM_NAME@.exe"
		createShortCut "$DESKTOP\@PROGRAM_NAME@.lnk" "$INSTDIR\@PROGRAM_NAME@.exe"

		# Binary files
		file "/oname=$INSTDIR\@PROGRAM_NAME@.exe"	".bin\Release\@PROGRAM_NAME@.exe"
		file "/oname=$INSTDIR\@PROGRAM_NAME@.ico"	"src\gtk2\@PROGRAM_NAME@.ico"

		# Configuration files
		file "/oname=$INSTDIR\@PROGRAM_NAME@.gif"	"image\@PROGRAM_NAME@.gif"
		file "/oname=$INSTDIR\colors.conf"		"colors.conf"
		file "/oname=$INSTDIR\@PROGRAM_NAME@.conf"	"default.conf"

		# Documentation files
		file "/oname=$INSTDIR\ChangeLog"		"ChangeLog"
		file "/oname=$INSTDIR\AUTHORS"			"AUTHORS"
		file "/oname=$INSTDIR\LICENSE"			"LICENSE"

		# UI definition files
		CreateDirectory "$INSTDIR\ui"

		file "/oname=$INSTDIR\ui\@PROGRAM_NAME@.xml" 	"ui\default.xml"

		# Locale files
		CreateDirectory "$INSTDIR\@localedir@\pt_BR\LC_MESSAGES"
		file "/oname=$INSTDIR\@localedir@\pt_BR\LC_MESSAGES\@PACKAGE@.mo" ".bin\Release\locale\pt_BR\LC_MESSAGES\@PACKAGE@.mo"

		# define uninstaller name
		writeUninstaller $INSTDIR\uninstall.exe

		WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PROGRAM_NAME@" \
			         "DisplayName" "@PROGRAM_NAME@ - 3270 emulator for windows/gtk"
		WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PROGRAM_NAME@" \
			         "DisplayIcon" "$INSTDIR\@PROGRAM_NAME@.ico"
		WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PROGRAM_NAME@" \
			         "DisplayVersion" "@PACKAGE_VERSION@ (Rev: @PACKAGE_REVISION@)"


		WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PROGRAM_NAME@" \
			         "UninstallString" "$INSTDIR\uninstall.exe"
		WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PROGRAM_NAME@" \
			         "InstallLocation" "$INSTDIR"
		WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PROGRAM_NAME@" \
			         "NoModify" "1"
		WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PROGRAM_NAME@" \
			         "NoRepair" "1"

		# Save instalation dir
		WriteRegStr HKCU "Software\@PROGRAM_NAME@" "" $INSTDIR

		# Main library
		file "/oname=$SYSDIR\lib3270.dll" ".bin\Release\lib\lib3270.dll"

	sectionEnd

	SubSection "Plugins" SecPLugin

		Section /o "Rexx" RexxPlugin
			setOutPath $INSTDIR

			CreateDirectory "$INSTDIR"
			file src\plugins\rexx\rx3270.cls

			CreateDirectory "$INSTDIR\plugins"
			file "/oname=$INSTDIR\plugins\rx3270.dll" ".bin\Release\plugins\rx3270.dll"
			file "/oname=$INSTDIR\ui\rexx.xml" ui\rexx.xml

		sectionEnd

		Section /o "Pipe control" PipePlugin
			setOutPath $INSTDIR
			CreateDirectory "$INSTDIR\plugins"
			file "/oname=$INSTDIR\plugins\pipectl.dll" ".bin\Release\plugins\pipectl.dll"
		sectionEnd

	SubSectionEnd

	SubSection "Java API & Plugin" SecJava

		Section /o "JNI module" jni
			setOutPath $INSTDIR
			CreateDirectory "$INSTDIR\java"
			file "/oname=$INSTDIR\java\pw3270.jar" ".bin\Release\pw3270.jar"
			file "/oname=$INSTDIR\java\libpw3270_jni.dll" ".bin\Release\libpw3270_jni.dll"
		SectionEnd

		Section /o "Java plugin" jplugin
			setOutPath $INSTDIR
			CreateDirectory "$INSTDIR\plugins"
			file "/oname=$INSTDIR\plugins\j3270plugin.dll" ".bin\Release\plugins\j3270plugin.dll"
		SectionEnd

	SubSectionEnd


	SubSection "Extras" SecExtra

		Section "Right keypad" RKeypad
			file "/oname=$INSTDIR\ui\keypad.xml" "ui\keypad.xml"
		SectionEnd

		Section /o "Function bar" FBar
			file "/oname=$INSTDIR\ui\functions.xml" "ui\functions.xml"
		SectionEnd

		Section /o "Debug & Trace menus" SecDBGMenu

			file "/oname=$INSTDIR\ui\debug.xml" "ui\debug.xml"

		SectionEnd

		Section /o "Rexx extension library" SecRexxLib

			setOutPath $PROGRAMFILES\ooRexx
			file ".bin\Release\librx3270.dll"
			file "src\plugins\rexx\rx3270.cls"

		SectionEnd

	SubSectionEnd


SubSectionEnd

Section /o "GTK+ Runtime" SecGTK

	setOutPath $INSTDIR
	file /r ".bin\gtkruntime\*.*"

SectionEnd

Section /o "Software Development Kit" SecSDK

	CreateDirectory "$INSTDIR\sdk"
	CreateDirectory "$INSTDIR\sdk\include"
	CreateDirectory "$INSTDIR\sdk\include\lib3270"

	file "/oname=$INSTDIR\sdk\include\lib3270.h" "src\include\lib3270.h"
	file "/oname=$INSTDIR\sdk\include\lib3270\api.h" "src\include\lib3270\api.h"
	file "/oname=$INSTDIR\sdk\include\lib3270\config.h" "src\include\lib3270\config.h"
	file "/oname=$INSTDIR\sdk\include\lib3270\plugins.h" "src\include\lib3270\plugins.h"
	file "/oname=$INSTDIR\sdk\include\lib3270\macros.h" "src\include\lib3270\macros.h"

	CreateDirectory "$INSTDIR\sdk\lib"
	file "/oname=$INSTDIR\sdk\lib\lib3270.def" ".bin\Release\lib\lib3270.def"

SectionEnd



# create a section to define what the uninstaller does.
# the section will always be named "Uninstall"
section "Uninstall"

	# Always delete uninstaller first
	delete $INSTDIR\uninstaller.exe

	# Set SMPROGRAMS and DESKTOP path
	SetShellVarContext all

	# now delete installed files
	delete $INSTDIR\@PROGRAM_NAME@.exe
	delete $INSTDIR\lib3270.dll
	delete $INSTDIR\@PROGRAM_NAME@.conf
	delete $INSTDIR\actions.conf
	delete $INSTDIR\ui.xml
	delete $INSTDIR\@PROGRAM_NAME@.gif
	delete $INSTDIR\@PROGRAM_NAME@.log

	delete $SMPROGRAMS\@PROGRAM_NAME@.lnk
	delete $DESKTOP\@PROGRAM_NAME@.lnk

	RMDir /r "$INSTDIR\locale"
	RMDir /r "$INSTDIR\share"
	RMDir /r "$INSTDIR\etc"
	RMDir /r "$INSTDIR\plugins"
	RMDir /r "$INSTDIR\sdk"
	RMDir /r "$INSTDIR\gtk2-runtime"

	# Delete all files
	delete "$INSTDIR\*.dll"

	# Remove registry
	DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PROGRAM_NAME@"

	# Delete System libraries
	delete $SYSDIR\lib3270.dll

	# Delete extension libraries
	delete $PROGRAMFILES\ooRexx\rx3270.dll

	RMDir /r "$INSTDIR"

sectionEnd

Function .onInit

#FindProcDLL::FindProc "@PROGRAM_NAME@.exe"
#IntCmp $R0 1 0 notRunning
#
#    MessageBox MB_OK|MB_ICONEXCLAMATION "@PROGRAM_NAME@ is running. Please close it first" /SD IDOK
#    Abort
#
#notRunning:

IfFileExists $PROGRAMFILES\ooRexx\rexx.exe RexxOK RexxNOK

RexxOK:
	SectionGetFlags "${RexxPlugin}" $0
	IntOp $0 $0 | ${SF_SELECTED}
	SectionSetFlags "${RexxPlugin}" $0

	SectionGetFlags "${SecRexxLib}" $0
	IntOp $0 $0 | ${SF_SELECTED}
	SectionSetFlags "${SecRexxLib}" $0

goto PastRexxCheck

RexxNOK:
	SectionGetFlags "${RexxPlugin}" $0
	IntOp $0 $0 | ${SF_RO}
	SectionSetFlags "${RexxPlugin}" $0

	SectionGetFlags "${SecRexxLib}" $0
	IntOp $0 $0 | ${SF_RO}
	SectionSetFlags "${SecRexxLib}" $0

PastRexxCheck:

	ReadRegStr $4 HKLM "Software\GTK2-Runtime" "DllPath"

	# remove trailing back slash
	Push $4
	Exch $EXEDIR
	Exch $EXEDIR
	Pop $4

	# if Gtk runtime DLL path exists gtk runtime is already installed.
	IfFileExists $4 gtkOK gtkNOK

gtkOK:

	SectionGetFlags "${SecGTK}" $0
	IntOp $0 $0 & ${SECTION_OFF}
	SectionSetFlags "${SecGTK}" $0

goto PastGTKCheck

gtkNOK:

	SectionGetFlags "${SecGTK}" $0
	IntOp $0 $0 | ${SF_SELECTED}
	SectionSetFlags "${SecGTK}" $0

goto PastGTKCheck



PastGTKCheck:


FunctionEnd