From 1568d7f42886fe3f5f8ea79110791cdd8e0786df Mon Sep 17 00:00:00 2001 From: james Date: Sun, 22 Apr 2007 08:21:16 +0000 Subject: Version is now specified in version.m4 for both unix and windows versions. Reworked the Windows build scripting system, with settings (other than version #) specified in settings.in. Moved the native scripting grammar as defined by trans.pl away from NSIS and to something more generic. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@1867 e7ae566f-a301-0410-adde-c780ea21d3b5 --- config-win32.h | 4 +- configure.ac | 2 +- domake-win | 8 ++++ install-win32/copyinstaller | 16 +++++--- install-win32/m4todef.pl | 15 +++++++ install-win32/macro.pl | 45 +++++++++++++------- install-win32/makebin | 2 +- install-win32/makeopenvpn | 2 +- install-win32/maketap | 4 +- install-win32/maketapinstall | 4 +- install-win32/nsitran.pl | 27 ------------ install-win32/openvpn.nsi | 5 ++- install-win32/settings.in | 59 +++++++++++++++++++++++++++ install-win32/signinstaller | 2 +- install-win32/signtap | 2 +- install-win32/trans.pl | 97 ++++++++++++++++++++++++++++++++++++++++++++ install-win32/version.nsi | 62 ---------------------------- install-win32/winconfig | 16 ++++---- tap-win32/tapdrvr.c | 2 +- version.m4 | 2 +- 20 files changed, 244 insertions(+), 132 deletions(-) create mode 100644 install-win32/m4todef.pl delete mode 100644 install-win32/nsitran.pl create mode 100644 install-win32/settings.in create mode 100644 install-win32/trans.pl delete mode 100644 install-win32/version.nsi diff --git a/config-win32.h b/config-win32.h index 2457318..6d313a7 100644 --- a/config-win32.h +++ b/config-win32.h @@ -35,7 +35,7 @@ #include #include -#include "autodefs/nsidefs.h" +#include "autodefs/defs.h" #define sleep(x) Sleep((x)*1000) @@ -228,7 +228,7 @@ typedef unsigned long in_addr_t; #define PACKAGE_TARNAME "openvpn" /* Define to the version of this package. */ -#define PACKAGE_VERSION "PRODUCT_VERSION" +#define PACKAGE_VERSION PRODUCT_VERSION /* Define to the full name and version of this package. */ #ifdef DEBUG_LABEL diff --git a/configure.ac b/configure.ac index db84a5d..af57577 100644 --- a/configure.ac +++ b/configure.ac @@ -26,7 +26,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) m4_include(version.m4) -AC_INIT([OpenVPN], [OPENVPN_VERSION], [openvpn-users@lists.sourceforge.net], [openvpn]) +AC_INIT([OpenVPN], [PRODUCT_VERSION], [openvpn-users@lists.sourceforge.net], [openvpn]) AM_CONFIG_HEADER(config.h) AC_CONFIG_SRCDIR(syshead.h) diff --git a/domake-win b/domake-win index a4d6069..4aaa9ca 100644 --- a/domake-win +++ b/domake-win @@ -1,7 +1,15 @@ #!/bin/sh +# This is the master OpenVPN build script for Windows. +# See top-devel definitions in install-win32/version.nsi +# +# Example usage: +# # make without signing: # SIGNCODE="null" ./domake-win +# +# write installer to desktop +# INSTALLER_DEST="/c/Documents and Settings/James/Desktop" ./domake-win install-win32/winconfig install-win32/makeopenvpn diff --git a/install-win32/copyinstaller b/install-win32/copyinstaller index 96c213d..feecd13 100644 --- a/install-win32/copyinstaller +++ b/install-win32/copyinstaller @@ -1,11 +1,15 @@ #!/bin/sh -# copy the installer +# copy the installer to the $INSTALLER_DEST directory. # load version.nsi definitions -. autodefs/nsidefs.sh +. autodefs/defs.sh -cd install-win32 -ls openvpn*.exe 2>/dev/null || exit 1 -exe=`ls -t openvpn*.exe | head -n 1` -cp $exe .. +if [ -n "$INSTALLER_DEST" ] ; then + cd install-win32 + ls openvpn*.exe 2>/dev/null || exit 1 + exe=install-win32/`ls -t openvpn*.exe | head -n 1` + cd .. + echo cp $exe "$INSTALLER_DEST" + cp $exe "$INSTALLER_DEST" +fi diff --git a/install-win32/m4todef.pl b/install-win32/m4todef.pl new file mode 100644 index 0000000..c4f0409 --- /dev/null +++ b/install-win32/m4todef.pl @@ -0,0 +1,15 @@ +#!/usr/bin/perl + +# used to convert version.m4 to simple +# definition format + +while () { + chomp; + if (/^\s*$/) { + print "\n"; + } elsif (/^define\((\w+),\[(.*?)\]\)/) { + print "define $1 \"$2\"\n"; + } elsif (/^dnl(.*)$/) { + print "#$1\n"; + } +} diff --git a/install-win32/macro.pl b/install-win32/macro.pl index 6e7afdc..4705310 100644 --- a/install-win32/macro.pl +++ b/install-win32/macro.pl @@ -1,33 +1,50 @@ +#!/usr/bin/perl + # Simple macro processor. # Macros are defined in a control file that follows -# NSIS format such as version.nsi. Stdin is then -# copied to stdout, and any occurrence of @@MACRO@@ is -# substituted. - -die "usage: macro.pl " if (@ARGV < 1); -($control_file) = @ARGV; +# a simple definition-based grammar as documented in the +# trans script. Stdin is then copied to stdout, and any +# occurrence of @@MACRO@@ is substituted. Macros can also +# be specified on the command line. -open(CONTROL, "< $control_file") or die "cannot open $control_file"; +die "usage: macro [-O] [-C] [-Dname=var ...] [control-file ...] " if (@ARGV < 1); %Parms = (); +$open_quote = "@@"; +$close_quote = "@@"; -while () { - chomp; - if (/^!define\s+(\w+)\s+['"]?(.+?)['"]?\s*$/) { - $Parms{$1} = $2 - } +while ($arg=shift(@ARGV)) { + if ($arg =~ /^-/) { + if ($arg =~ /^-D(\w+)=(.*)$/) { + $Parms{$1} = $2 + } elsif ($arg =~ /-O(.*)$/) { + $open_quote = $1; + } elsif ($arg =~ /-C(.*)$/) { + $close_quote = $1; + } else { + die "unrecognized option: $arg"; + } + } else { + open(CONTROL, "< $arg") or die "cannot open $arg"; + while () { + chomp; + if (/^define\s+(\w+)\s+['"]?(.+?)['"]?\s*$/) { + $Parms{$1} = $2 + } + } + } } while () { s{ - @@ + \Q$open_quote\E \s* ( \w+ ) \s* - @@ + \Q$close_quote\E }{ $Parms{$1} }xge; diff --git a/install-win32/makebin b/install-win32/makebin index 7547ee1..0e26fe3 100644 --- a/install-win32/makebin +++ b/install-win32/makebin @@ -3,7 +3,7 @@ # Assemble binaries into bin # get version.nsi definitions -. autodefs/nsidefs.sh +. autodefs/defs.sh rm -rf bin mkdir bin diff --git a/install-win32/makeopenvpn b/install-win32/makeopenvpn index c572af6..48522e6 100644 --- a/install-win32/makeopenvpn +++ b/install-win32/makeopenvpn @@ -1,7 +1,7 @@ #!/bin/sh # get version.nsi definitions -. autodefs/nsidefs.sh +. autodefs/defs.sh # build OpenVPN binary [ "$MAKE_CLEAN" = "yes" ] && make -f makefile.w32 clean diff --git a/install-win32/maketap b/install-win32/maketap index 1ee4ed5..c3a9f26 100644 --- a/install-win32/maketap +++ b/install-win32/maketap @@ -4,7 +4,7 @@ # Requires the Windows DDK # get version.nsi definitions -. autodefs/nsidefs.sh +. autodefs/defs.sh amdtarget="" if [ -z "$TAP_BIN_AMD64" ]; then @@ -27,4 +27,4 @@ if [ -n "$TAP_BIN_AMD64" ]; then cp "$TAP_BIN_AMD64" $t/amd64 fi -title openvpn &>/dev/null +title openvpn-build &>/dev/null diff --git a/install-win32/maketapinstall b/install-win32/maketapinstall index 96fd14a..1ebc220 100644 --- a/install-win32/maketapinstall +++ b/install-win32/maketapinstall @@ -6,7 +6,7 @@ # tapinstall source code. # get version.nsi definitions -. autodefs/nsidefs.sh +. autodefs/defs.sh if ! [ -d "$TISRC" ] ; then echo "$TISRC" NOT INSTALLED @@ -39,4 +39,4 @@ if [ -n "$TI_BIN_AMD64" ]; then cp "$TI_BIN_AMD64" $t/objfre_wnet_amd64/amd64 fi -title openvpn &>/dev/null +title openvpn-build &>/dev/null diff --git a/install-win32/nsitran.pl b/install-win32/nsitran.pl deleted file mode 100644 index 49512b4..0000000 --- a/install-win32/nsitran.pl +++ /dev/null @@ -1,27 +0,0 @@ -# This is a simple language translator. It translates -# the NSIS format of version.nsi to either C, sh, or Javascript. - -($mode) = @ARGV; - -$comment = "This file was automatically generated by nsitran.pl"; - -print "// $comment\n" if ($mode eq "c"); -print "# $comment\n" if ($mode eq "sh"); -print "// $comment\n" if ($mode eq "js"); - -print "\n"; - -while () { - chomp; - if (/^\s*$/) { - print "\n"; - } elsif (/^[#;](.*)$/) { - print "//$1\n" if ($mode eq "c"); - print "#$1\n" if ($mode eq "sh"); - print "//$1\n" if ($mode eq "js"); - } elsif (/^!define\s+(\w+)\s+(.+)$/) { - print "#define $1 $2\n" if ($mode eq "c"); - print "[ -z \"\$$1\" ] && export $1=$2\n[ \"\$$1\" = \"null\" ] && unset $1\n" if ($mode eq "sh"); - print "var $1=$2;\n" if ($mode eq "js"); - } -} diff --git a/install-win32/openvpn.nsi b/install-win32/openvpn.nsi index fc10644..535b9c8 100755 --- a/install-win32/openvpn.nsi +++ b/install-win32/openvpn.nsi @@ -7,12 +7,13 @@ ; OpenVPN install script for Windows, using NSIS -!include "version.nsi" +!define HOME ".." + +!include "${HOME}\autodefs\defs.nsi" !include "MUI.nsh" !include "setpath.nsi" !include "GetWindowsVersion.nsi" -!define HOME ".." !define BIN "${HOME}\bin" !define PRODUCT_NAME "OpenVPN" diff --git a/install-win32/settings.in b/install-win32/settings.in new file mode 100644 index 0000000..98ea71b --- /dev/null +++ b/install-win32/settings.in @@ -0,0 +1,59 @@ +# Version numbers, settings, and dependencies +# for Windows OpenVPN installer. + +# Get the OpenVPN version number +include "autodefs/version.in" + +# Include the OpenVPN GUI exe in the installer. +# May be undefined. +define OPENVPN_GUI_DIR "../openvpn-gui" +define OPENVPN_GUI "openvpn-gui-1.0.3.exe" + +# Prebuilt libraries. DMALLOC is optional. +define OPENSSL_DIR "../openssl-0.9.7l" +define LZO_DIR "../lzo-2.02" +define DMALLOC_DIR "../dmalloc-5.4.2" + +# Write TAP driver and tapinstall.exe to this directory, +# to use as prebuilt binaries for future builds. May +# be undefined. +;define DRVBINDEST "../tapbin" + +# Don't build TAP driver and tapinstall.exe -- instead get +# them as prebuilt binaries from this directory. May be +# undefined. +;define DRVBINSRC "../tapbin" + +# tapinstall.exe source code. +# Not needed if DRVBINSRC is defined. +define TISRC "../tapinstall" + +# TAP Adapter parameters. +define PRODUCT_TAP_MAJOR_VER 9 +define PRODUCT_TAP_MINOR_VER 3 +define PRODUCT_TAP_RELDATE "04/18/2007" + +# Service template files service.[ch] (get from Platform SDK). +# If undefined, don't build openvpnserv.exe +define SVC_TEMPLATE "../svc-template" + +# DDK Version. +# DDK distribution is assumed to be in C:\WINDDK\${DDKVER} +# Not needed if DRVBINSRC is defined. +define DDKVER 5600 + +# Code Signing. +# This directory should contain signcode.exe + key files. +# If undefined, don't sign any files. +define SIGNCODE "../sign" + +# INF2CAT should point to the MS inf2cat distribution. +# inf2cat is used for driver signing. +# If undefined, don't sign any files. +define INF2CAT "../inf2cat" + +# -j parameter passed to make +define MAKE_JOBS 2 + +# do a make clean before make +define MAKE_CLEAN "yes" diff --git a/install-win32/signinstaller b/install-win32/signinstaller index 01dccd3..013688b 100644 --- a/install-win32/signinstaller +++ b/install-win32/signinstaller @@ -6,7 +6,7 @@ c=`pwd` # load version.nsi definitions -. autodefs/nsidefs.sh +. autodefs/defs.sh if [ -n "$SIGNCODE" ] ; then diff --git a/install-win32/signtap b/install-win32/signtap index 0dc3b05..46f3056 100644 --- a/install-win32/signtap +++ b/install-win32/signtap @@ -8,7 +8,7 @@ c=`pwd` # load version.nsi definitions -. autodefs/nsidefs.sh +. autodefs/defs.sh if [ -z "$DRVBINSRC" ] ; then # copy driver files into tap-win32/dist diff --git a/install-win32/trans.pl b/install-win32/trans.pl new file mode 100644 index 0000000..b275ea8 --- /dev/null +++ b/install-win32/trans.pl @@ -0,0 +1,97 @@ +#!/usr/bin/perl + +# This script translates a simple definition-based grammar +# to either C, sh, Javascript, or in (in = identity grammar, i.e. +# same grammar as input). +# +# Input grammar: +# (1) comments having ';' or '#' as the first char in the line +# (2) a blank line +# (3) include "file" +# (4) define foo bar +# (5) define foo "bar" +# +# Environmental variables can be used to override a setting. +# The special value "null" causes the variable to be undefined. +# If an environmental value is bracketed, i.e [abc], the brackets +# will be converted to double quotes prior to output. + +sub comment { + my ($cmt) = @_; + print "//$cmt\n" if ($mode =~ /^(c|js|h)$/); + print "#$cmt\n" if ($mode =~ /^(sh|nsi|in)$/); +} + +sub define { + my ($name, $value) = @_; + if ($mode eq "sh") { + print "[ -z \"\$$name\" ] && export $name=$value\n"; + print "[ \"\$$name\" = \"$nulltag\" ] && unset $name\n"; + } else { + if ($ENV{$name}) { + $value = $ENV{$name}; + $value = "\"$1\"" if ($value =~ /\[(.*)\]$/); + } + if ($value ne $nulltag) { + print "#define $name $value\n" if ($mode =~ /^(c|h)$/); + print "!define $name $value\n" if ($mode eq "nsi"); + print "define $name $value\n" if ($mode eq "in"); + print "var $name=$value;\n" if ($mode eq "js"); + } else { + print "//#undef $name\n" if ($mode =~ /^(c|h)$/); + print "#!undef $name\n" if ($mode eq "nsi"); + print ";undef $name\n" if ($mode eq "in"); + print "//undef $name\n" if ($mode eq "js"); + } + } +} + +sub include_file { + local $_; + $include_file_level++; + die "!include file nesting too deep" if ($include_file_level > $max_inc_depth); + my ($parm) = @_; + my $fn = "$incdir/$parm"; + local *IN; + open(IN, "< $fn") or die "cannot open $fn"; + while () { + chomp; + if (/^\s*$/) { + print "\n"; + } elsif (/^[#;](.*)$/) { + comment ($1); + } elsif (/^define\s+(\w+)\s+(.+)$/) { + define ($1, $2); + } elsif (/^include\s+"(.+)"/) { + include_file ($1); + } else { + die "can't parse this line: $_\n"; + } + } + $include_file_level--; +} + +die "usage: trans [-I] [files ...]" if (@ARGV < 1); + +($mode) = shift(@ARGV); +die "mode must be one of c, h, sh, js, nsi, or in" if !($mode =~ /^(c|h|sh|js|nsi|in)$/); + +$nulltag = "null"; +$max_inc_depth = 10; +$include_file_level = 0; +$incdir = "."; + +comment(" This file was automatically generated by trans.pl"); + +while ($arg=shift(@ARGV)) { + if ($arg =~ /^-/) { + if ($arg =~ /^-I(.*)$/) { + $incdir = $1; + } else { + die "unrecognized option: $arg"; + } + } else { + print "\n"; + include_file ($arg); + } +} diff --git a/install-win32/version.nsi b/install-win32/version.nsi deleted file mode 100644 index 7fbaf0b..0000000 --- a/install-win32/version.nsi +++ /dev/null @@ -1,62 +0,0 @@ -# Version numbers, settings, and dependencies -# for Windows OpenVPN installer. - -!define PRODUCT_VERSION "2.1_rc2f" - -# Include the OpenVPN GUI exe in the installer. -# May be undefined. -!define OPENVPN_GUI_DIR "../openvpn-gui" -!define OPENVPN_GUI "openvpn-gui-1.0.3.exe" - -# For now, use prebuilt AMD64 tap/tapinstall -#!define TAP_BIN_AMD64 "../amd64/tap/tap0901.sys" -#!define TI_BIN_AMD64 "../amd64/tapinstall/tapinstall.exe" - -# Prebuilt libraries. DMALLOC is optional. -!define OPENSSL_DIR "../openssl-0.9.7l" -!define LZO_DIR "../lzo-2.02" -!define DMALLOC_DIR "../dmalloc-5.4.2" - -# Write TAP driver and tapinstall.exe to this directory, -# to use as prebuilt binaries for future builds. May -# be undefined. -;!define DRVBINDEST "../tapbin" - -# Don't build TAP driver and tapinstall.exe -- instead get -# them as prebuilt binaries from this directory. May be -# undefined. -;!define DRVBINSRC "../tapbin" - -# tapinstall.exe source code. -# Not needed if DRVBINSRC is defined. -!define TISRC "../tapinstall" - -# TAP Adapter parameters. -!define PRODUCT_TAP_MAJOR_VER 9 -!define PRODUCT_TAP_MINOR_VER 3 -!define PRODUCT_TAP_RELDATE "04/18/2007" - -# Service template files service.[ch] (get from Platform SDK). -# If undefined, don't build openvpnserv.exe -!define SVC_TEMPLATE "../svc-template" - -# DDK Version. -# DDK distribution is assumed to be in C:\WINDDK\${DDKVER} -# Not needed if DRVBINSRC is defined. -!define DDKVER 5600 - -# Code Signing. -# This directory should contain signcode.exe + key files. -# If undefined, don't sign any files. -!define SIGNCODE "../sign" - -# INF2CAT should point to the MS inf2cat distribution. -# inf2cat is used for driver signing. -# If undefined, don't sign any files. -!define INF2CAT "../inf2cat" - -# -j parameter passed to make -!define MAKE_JOBS 2 - -# do a make clean before make -!define MAKE_CLEAN "yes" diff --git a/install-win32/winconfig b/install-win32/winconfig index bca1bb6..7fd49cd 100644 --- a/install-win32/winconfig +++ b/install-win32/winconfig @@ -8,20 +8,20 @@ c=`pwd` rm -rf autodefs mkdir autodefs -TRAN="perl install-win32/nsitran.pl" -VER=install-win32/version.nsi -MACRO="perl install-win32/macro.pl $VER" +MACRO="perl install-win32/macro.pl autodefs/defs.in" # silly vista security theatre PATCH="/tmp/p.exe" cp `which patch` $PATCH -# translate version.nsi to C and sh -$TRAN c <$VER >autodefs/nsidefs.h -$TRAN sh <$VER >autodefs/nsidefs.sh +# build multi-grammar definition files +perl install-win32/m4todef.pl autodefs/version.in +for g in "h" "sh" "nsi" "in" ; do + perl install-win32/trans.pl $g install-win32/settings.in >autodefs/defs.$g +done -# load version.nsi definitions -. autodefs/nsidefs.sh +# load sh definitions +. autodefs/defs.sh # configure tap driver sources $MACRO tap-win32/SOURCES diff --git a/tap-win32/tapdrvr.c b/tap-win32/tapdrvr.c index 7e8d2d6..16a46cd 100755 --- a/tap-win32/tapdrvr.c +++ b/tap-win32/tapdrvr.c @@ -39,7 +39,7 @@ // TAP_IOCTL_CONFIG_TUN ioctl. //====================================================== -#include "../../autodefs/nsidefs.h" +#include "../../autodefs/defs.h" #ifndef DDKVER #error DDKVER must be defined to the DDK Version as in c:\WinDDK\[DDKVER]\... #endif diff --git a/version.m4 b/version.m4 index e759b3e..98e5654 100644 --- a/version.m4 +++ b/version.m4 @@ -1,2 +1,2 @@ dnl define the OpenVPN version -define(OPENVPN_VERSION,[2.1_rc2f]) +define(PRODUCT_VERSION,[2.1_rc2f]) -- cgit