Add automatic NSIS Windows installer script generator.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/tools/make/trunk@25753 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2007-12-17 19:50:09 +00:00
parent 62805a46e1
commit fcbc297af8
6 changed files with 352 additions and 10 deletions

View file

@ -1,3 +1,8 @@
2007-12-17 Adam Fedor <fedor@gnu.org>
* nsi-app.template, Master/nsis.make, Documenation/make.texi,
GNUmakefile.in: Add automatic NSIS Windows installer script generator.
2007-12-17 Nicola Pero <nicola.pero@meta-innovation.com>
* GNUmakefile.in (uninstall): Remove filesystem.make

View file

@ -43,9 +43,9 @@ any later version published by the Free Software Foundation.
* Makefile Introduction::
* Makefile Structure::
* Running Make::
* Project Types::
* GNUmakefile.preamble::
* GNUmakefile.postamble::
* Project Types::
* Common Variables::
@end menu
@ -89,7 +89,7 @@ include $(GNUSTEP_MAKEFILES)/tool.make
This is all that is necessary to define the project.
@node Running Make, GNUmakefile.preamble, Makefile Structure, Top
@node Running Make, Project Types, Makefile Structure, Top
@section Running Make
@menu
* Debug Information::
@ -148,7 +148,7 @@ libraries (DLL) which are a form of shared libraries; on these systems,
DLLs will be built by default unless the Makefile Package is told to
build using static libraries instead, as in the above command.
@node Project Types, Common Variables, GNUmakefile.postamble, Top
@node Project Types, GNUmakefile.preamble, Running Make, Top
@section Project Types
@menu
* aggregate.make::
@ -159,7 +159,8 @@ build using static libraries instead, as in the above command.
* framework.make::
* java.make::
* library.make::
* native-library.make::
* native-library.make::
* nsis.make::
* objc.make::
* palette.make::
* rpm.make::
@ -454,7 +455,7 @@ library reside in the @file{two} subdirectory from where the sources are
located, and the header files will be installed into the @file{two}
subdirectory within @code{GNUSTEP_HEADERS}.
@node native-library.make, objc.make, library.make, Project Types
@node native-library.make, nsis.make, library.make, Project Types
@subsection Native Library (@file{native-library.make})
A "native library" is a project which is to be built as a shared
@ -481,7 +482,52 @@ To add the corresponding flags, you can use
This will be converted into -L../MyPath/$(GNUSTEP_OBJ_DIR) flag
on for most targets and into -F../MyPath flag for apple-apple-apple.
@node objc.make, palette.make, native-library.make, Project Types
@node nsis.make, objc.make, native-library.make, Project Types
@subsection NSIS Installer (@file{nsis.make})
The NSIS make project provides rules for automatically generating NSIS
installers for Windows operating systems. You don't need to do anything
to take advantage of this - it is included automatically by the make system.
To create an installer file by itself, run @code{make nsifile}. To
create the full installer executable, run @code{make nsis}. Note that in
order to do this, you must be either running on a Windows computer with
a release of the NSIS compiler (from @url{nsis.sourceforge.net}) or you
need to be using a cross-compiler and cross-compiled NSIS script compiler.
(NOTE: This does not currently work - you need to use the GUI NSIS compiler
to compile the installer scripts).
Currently the nsis make package only makes installers for
Applications. It will use the @file{nsi-app.template} file in the
GNUstep Makefiles directory. If you want, you can provide your own
template with customized script instructions by creating a file called
@file{PACKAGE_NAME.nsi.in}, where @code{PACKAGE_NAME} is the same as the
name of your package (see below).
Except for @code{PACKAGE_NAME}, which is required, all the following
variables are optional.
@defvr {NSIS} PACKAGE_NAME
@code{PACKAGE_NAME} defines the name of the NSIS installer. In most
cases this will be the same as the name of your project type. For
instance, if you are creating a application, and have set
@code{APP_NAME} to @samp{MyApplication}, Then set @code{PACKAGE_NAME} to
the same thing, or just use @code{PACKAGE_NAME=$(APP_NAME)}. if
@code{PACKAGE_NAME} is not set, it defaults to @code{unnamed-package}
@end defvr
@defvr {NSIS} PACKAGE_VERSION
Set @code{PACKAGE_VERSION} to the release version number of your package. If not
set, it defaults to 0.0.1
@end defvr
@defvr {NSIS} GNUSTEP_INSTALLATION_DOMAIN
Set @code{GNUSTEP_INSTALLATION_DOMAIN} to the domain where you want to install
the software. This should be either @code{SYSTEM}), @code{LOCAL}, or @code{USER}.
If not set it defaults to @code{LOCAL}.
@end defvr
@node objc.make, palette.make, nsis.make, Project Types
@subsection Objective-C Programs (@file{objc.make})
@menu
* objc.make variables::
@ -647,7 +693,7 @@ or application.
A tool is an ObjC project that by default links in the GNUstep base
library. Otherwise it is similar to the ObjC project type.
@node GNUmakefile.preamble, GNUmakefile.postamble, Running Make, Top
@node GNUmakefile.preamble, GNUmakefile.postamble, Project Types, Top
@section Global Variables (@file{GNUmakefile.preamble})
@file{GNUmakefile.preamble} is an optional file that may be put within the
@ -865,7 +911,7 @@ directories can be created during installation.
ADDITIONAL_INSTALL_DIRS = $(GNUSTEP_RESOURCES)/MyProject
@end smallexample
@node GNUmakefile.postamble, Project Types, GNUmakefile.preamble, Top
@node GNUmakefile.postamble, Common Variables, GNUmakefile.preamble, Top
@section Global Rules (@file{GNUmakefile.postamble})
The @file{GNUmakefile.postamble} file is an optional file you may
@ -881,7 +927,7 @@ define things that should happen after a process is complete.
You can even define additional rules such as ones that a particular to
your specific package or that are to be used by developers only.
@node Common Variables, , Project Types, Top
@node Common Variables, , GNUmakefile.postamble, Top
@section Common Variables (@file{common.make})
@menu
* Directory Paths::

View file

@ -92,7 +92,7 @@ MASTER_MAKE_FILES = \
aggregate.make source-distribution.make rpm.make rules.make \
application.make bundle.make clibrary.make ctool.make \
documentation.make framework.make gswapp.make gswbundle.make \
library.make objc.make java.make java-tool.make palette.make \
library.make nsis.make objc.make java.make java-tool.make palette.make \
resource-set.make service.make subproject.make test-application.make \
test-library.make test-tool.make tool.make
@ -176,6 +176,7 @@ install: generated-files
$(makedir)/Instance/Documentation; \
done; \
$(INSTALL_DATA) $(srcdir)/app-wrapper.template $(makedir); \
$(INSTALL_DATA) $(srcdir)/nsi-app.template $(makedir); \
$(INSTALL_DATA) executable.template $(makedir); \
$(INSTALL_DATA) config-noarch.make $(makedir); \
$(INSTALL_DATA) filesystem.make $(makedir); \
@ -231,6 +232,7 @@ uninstall:
done
rm -f $(makedir)/executable.template
rm -f $(makedir)/app-wrapper.template
rm -f $(makedir)/nsi-app.template
rm -f $(GNUSTEP_SYSTEM_ROOT)/share/config.site
rm -f $(makedir)/config-noarch.make
rm -f $(makedir)/filesystem.make

179
Master/nsis.make Normal file
View file

@ -0,0 +1,179 @@
#
# nsis.make
#
# Makefile rules to build a NSIS installer
#
# Copyright (C) 2007 Free Software Foundation, Inc.
#
# Author: Adam Fedor <fedor@gnu.org>
#
# This file is part of the GNUstep Makefile Package.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# You should have received a copy of the GNU General Public
# License along with this library; see the file COPYING.
# If not, write to the Free Software Foundation,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# BUGS: Currently only works for applications
# Pathnames only work with the GUI NSIS installer (not on msys at least)
#
# make nsifile will build the nsi installer script
# make nsis will compile it, assuming there is a suitable
# nsis compiler availabe.
# [1] Add - after common.make - the following lines in your GNUmakefile:
#
# PACKAGE_NAME = Gomoku
# PACKAGE_VERSION = 1.1.1
#
# The other important variable you may want to set in your makefiles is
#
# GNUSTEP_INSTALLATION_DOMAIN - Installation domain (defaults to LOCAL)
#
# [2] Provide a $(PACKAGE_NAME).nsi.in file, which contains the NSIS
# installer template. An example is in the gnustep-make package - which
# will be used if you don't provide your own template
#
# You can use the following if you need:
# @gs_name@ expands to the value of the make variable PACKAGE_NAME
# @gs_version@ expands to the value of the make variable PACKAGE_VERSION
#
# A special note: if you need `./configure' to be run before
# compilation (usually only needed for GNUstep core libraries
# themselves), define the following make variable:
#
# PACKAGE_NEEDS_CONFIGURE = YES
#
# in your makefile.
MAKENSIS=makensis
# These are the GNUstep Installer locations, so we need to match these
# regardless of the local directories
NSI_SYSTEM_ROOT=\\\\GNUstep\\\\System
NSI_LOCAL_ROOT=\\\\GNUstep\\\\Local
#FIXME: What should this be?
NSI_USER_ROOT=\\\\GNUstep\\\\Local
NSI_DOMAIN=$(NSI_SYSTEM_ROOT)
ifeq ($(GNUSTEP_INSTALLATION_DOMAIN), LOCAL)
NSI_DOMAIN=$(NSI_LOCAL_ROOT)
endif
ifeq ($(GNUSTEP_INSTALLATION_DOMAIN), USER)
NSI_DOMAIN=$(NSI_USER_ROOT)
endif
#
# Internal targets
#
# If we have been called with something like
#
# make DESTDIR=/var/tmp/package-build nsilist=yes install
#
# we are being called inside the nsis installation stage, and we need
# to produce the file list from the installed files.
#
GNUSTEP_FILE_LIST = $(GNUSTEP_OBJ_DIR)/file-list
GNUSTEP_DELETE_LIST = $(GNUSTEP_OBJ_DIR)/delete-list
GNUSTEP_RMDIR_LIST = $(GNUSTEP_OBJ_DIR)/rmdir-list
NSI_FILE_NAME=$(PACKAGE_NAME).nsi
;NSI_FILE=$(GNUSTEP_OBJ_DIR)/$(NSI_FILE_NAME)
NSI_FILE=$(NSI_FILE_NAME)
ifneq ($(APP_NAME),)
NSI_TEMPLATE=$(GNUSTEP_MAKEFILES)/nsi-app.template
NSI_INSTALL_DIR=$(GNUSTEP_APPS)
else
NSI_TEMPLATE=
endif
NSI_IN=$(PACKAGE_NAME).nsi.in
ifeq ($(nsilist),yes)
# Remove the old file list before installing, and initialize the new one.
before-install:: $(GNUSTEP_OBJ_DIR)
$(ECHO_NOTHING)rm -f $(GNUSTEP_FILE_LIST)$(END_ECHO)
$(ECHO_NOTHING)rm -f $(GNUSTEP_DELETE_LIST)$(END_ECHO)
$(ECHO_NOTHING)rm -f $(GNUSTEP_RMDIR_LIST)$(END_ECHO)
# Get the list of files inside DESTDIR
internal-after-install::
$(ECHO_NOTHING)cdir="nosuchdirectory"; \
for file in `$(TAR) Pcf - $(NSI_INSTALL_DIR) | $(TAR) t`; do \
wfile=`echo $$file | sed "s,$(NSI_INSTALL_DIR),," | tr '/' '\'`; \
wodir=`echo $(NSI_INSTALL_DIR) | tr '/' '\'`; \
slashsuffix=`basename $${file}yes`; \
if [ "$$slashsuffix" = yes ]; then \
newdir=`dirname $$file`/`basename $$file`; \
else \
newdir=`dirname $$file`; \
fi; \
if [ "$$file" = "$(NSI_INSTALL_DIR)/" ]; then \
:; \
elif [ -d "$$file" ]; then \
cdir=$$newdir; \
echo " RMDir \"\$$APPSDIR$$wfile\"" >> $(GNUSTEP_RMDIR_LIST); \
echo " SetOutPath \"\$$APPSDIR$$wfile\"" >> $(GNUSTEP_FILE_LIST); \
elif [ $$cdir != $$newdir ]; then \
cdir=$$newdir; \
wdir=`dirname $$file`; \
wdir=`echo $$wdir | sed "s,$(NSI_INSTALL_DIR),," | tr '/' '\'`; \
echo " SetOutPath \"\$$APPSDIR$$wdir\"" >> $(GNUSTEP_FILE_LIST); \
echo " File \"$$wodir$$wfile\"" >> $(GNUSTEP_FILE_LIST); \
echo " Delete \"\$$APPSDIR$$wfile\"" >> $(GNUSTEP_DELETE_LIST); \
else \
echo " Delete \"\$$APPSDIR$$wfile\"" >> $(GNUSTEP_DELETE_LIST); \
echo " File \"$$wodir$$wfile\"" >> $(GNUSTEP_FILE_LIST); \
fi; \
done$(END_ECHO)
endif # nsilist == yes
# NB: The nsilist is automatically deleted when GNUSTEP_OBJ_DIR is
# deleted (that is, by make clean)
.PHONY: nsifile nsis nsis_package_install
nsis_package_install:
$(ECHO_NOTHING)if [ -d $(GNUSTEP_OBJ_DIR)/package ]; then \
rm -rf $(GNUSTEP_OBJ_DIR)/package; fi$(END_ECHO)
$(ECHO_NOTHING)$(MKDIRS) $(GNUSTEP_OBJ_DIR)/package$(END_ECHO)
$(ECHO_NOTHING)$(MAKE) DESTDIR=$(GNUSTEP_OBJ_DIR)/package nsilist=yes install$(END_ECHO)
#
# The user will type `make nsifile' to generate the nsifile
#
nsifile: $(NSI_FILE)
#
# This is the real target
#
$(NSI_FILE): $(GNUSTEP_OBJ_DIR) nsis_package_install
$(ECHO_NOTHING)echo "Generating the nsi script..."$(END_ECHO)
$(ECHO_NOTHING)rm -f $@$(END_ECHO)
$(ECHO_NOTHING)rm -f ${GNUSTEP_RMDIR_LIST}.reverse$(END_ECHO)
$(ECHO_NOTHING)sed '1!G;h;$$!d' ${GNUSTEP_RMDIR_LIST} > \
${GNUSTEP_RMDIR_LIST}.reverse$(END_ECHO)
$(ECHO_NOTHING)mv ${GNUSTEP_RMDIR_LIST}.reverse \
${GNUSTEP_RMDIR_LIST}$(END_ECHO)
$(ECHO_NOTHING)if [ -f $(NSI_IN) ]; then \
nsi_infile=${NSI_IN}; \
else \
nsi_infile=${NSI_TEMPLATE}; fi; \
sed -e :t \
-e "s,@gs_domain@,$(NSI_DOMAIN),;t t" \
-e "s,@gs_name@,$(PACKAGE_NAME),;t t" \
-e "s,@gs_version@,$(PACKAGE_VERSION),;t t" \
-e "/@file_list@/ r ${GNUSTEP_FILE_LIST}" \
-e "/@delete_list@/ r ${GNUSTEP_DELETE_LIST}" \
-e "/@rmdir_list@/ r ${GNUSTEP_RMDIR_LIST}" \
$$nsi_infile > $@ \
$(END_ECHO)
nsis: nsifile
;$(ECHO_NOTHING)echo "Generating the nsis installer..."$(END_ECHO)
;${MAKENSIS} $(NSI_FILE_NAME)

View file

@ -434,3 +434,9 @@ include $(GNUSTEP_MAKEFILES)/Master/rpm.make
# Rules for building debian/* scripts for DEBs, and DEBs
#
#include $(GNUSTEP_MAKEFILES)/Master/deb.make <TODO>
#
# Rules for building NSIS installers
#
include $(GNUSTEP_MAKEFILES)/Master/nsis.make

104
nsi-app.template Normal file
View file

@ -0,0 +1,104 @@
; @gs_name@.app installer script
;
!define PRODUCT_NAME "@gs_name@"
!define PRODUCT_VERSION "@gs_version@"
!define PRODUCT_PUBLISHER "GNUstep"
!define PRODUCT_WEB_SITE "http://www.gnustep.org"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\GNUstep"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"
; MUI 1.67 compatible ------
!include "MUI.nsh"
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Start menu page
var ICONS_GROUP
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "GNUstep\Apps"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
; Reserve files
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; MUI end ------
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "@gs_name@-${PRODUCT_VERSION}-setup.exe"
InstallDir "C:\GNUstep"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
Var APPSDIR
Section "Main" SEC01
SetOverwrite try
StrCpy $APPSDIR "$INSTDIR@gs_domain@\Applications"
;@file_list@
SectionEnd
Section Uninstall
StrCpy $APPSDIR "$INSTDIR@gs_domain@\Applications"
;@delete_list@
;@rmdir_list@
Delete "$INSTDIR\Uninstall${PRODUCT_NAME}.exe"
Delete "$SMPROGRAMS\$ICONS_GROUP\${PRODUCT_NAME}.lnk"
RMDir "$SMPROGRAMS\$ICONS_GROUP\Uninstall"
RMDir "$SMPROGRAMS\$ICONS_GROUP"
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
SetAutoClose true
SectionEnd
Section -AdditionalIcons
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
CreateDirectory "$SMPROGRAMS\$ICONS_GROUP\Uninstall"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\${PRODUCT_NAME}.lnk" "$APPSDIR\${PRODUCT_NAME}.app\${PRODUCT_NAME}.exe"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall\Uninstall${PRODUCT_NAME}.lnk" "$INSTDIR\Uninstall${PRODUCT_NAME}.exe"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
Section -Post
WriteUninstaller "$INSTDIR\Uninstall${PRODUCT_NAME}.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\Uninstall${PRODUCT_NAME}.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\m.ico"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd
Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd