diff --git a/ext/gtk+/config.w32 b/ext/gtk+/config.w32 index 58cc2d4..ddcf22b 100644 --- a/ext/gtk+/config.w32 +++ b/ext/gtk+/config.w32 @@ -15,8 +15,6 @@ if (CHECK_HEADER("php.h") && CHECK_LIB("php5ts.lib", "php-gtk") && ADD_FLAG("CFLAGS_PHP_GTK", "/I ext\\gtk+ /I ..\\ext\\gtk+ /D HAVE_PHP_GTK=1"); - ADD_SOURCES("main", "php_gtk.c php_gtk_ext.w32.c php_gtk_util.c phpg_closure.c phpg_exceptions.c phpg_gboxed.c phpg_gobject.c phpg_gtype.c phpg_gvalue.c phpg_support.c", "php-gtk"); - EXTENSION("php-gtk", "gen_atk.c gen_gdk.c gen_gtk.c gen_pango.c php_gdk.c php_gtk+.c php_gtk+_types.c", true); // always shared AC_DEFINE("HAVE_PHP_GTK", 1, "PHP-GTK enabled"); diff --git a/generator/generator.php b/generator/generator.php index a42f39e..71a14a8 100644 --- a/generator/generator.php +++ b/generator/generator.php @@ -29,10 +29,16 @@ set_time_limit(300); -// override the default PHP 8Mb as this script tends to use alot more +// override the default PHP 8Mb as this script tends to use a lot more // and hopefully reduce the support questions a bit.. ini_set('memory_limit','64M'); +if (strstr(PHP_OS, 'WIN')) { + define('WIN_OS', true); +} else { + define('WIN_OS', false); +} + require "Getopt.php"; require "override.php"; require "arg_types.php"; @@ -92,7 +98,7 @@ class Generator { $output = vsprintf($format, $args); - if (!strstr(PHP_OS, 'WIN')) { + if (!WIN_OS) { echo $output; } @@ -963,7 +969,7 @@ class Generator { list($line, $filename) = $this->overrides->get_line_info("$class_name.$method_name.arginfo"); - if (strstr(PHP_OS, 'WIN')) { + if (WIN_OS) { $arginfo = sprintf("//line %d \"%s\"\n", $line, $filename); } else { $arginfo = sprintf("#line %d \"%s\"\n", $line, $filename); diff --git a/generator/lineoutput.php b/generator/lineoutput.php index 75ba617..8b56334 100644 --- a/generator/lineoutput.php +++ b/generator/lineoutput.php @@ -33,7 +33,7 @@ class LineOutput { function set_line($line, $filename) { - if (strstr(PHP_OS, 'WIN')) { + if (WIN_OS) { $this->write(sprintf("//line %d \"%s\"\n", $line, $filename)); } else { $this->write(sprintf("#line %d \"%s\"\n", $line, $filename)); diff --git a/generator/override.php b/generator/override.php index 1031614..ad6ec36 100644 --- a/generator/override.php +++ b/generator/override.php @@ -110,7 +110,7 @@ class Overrides { break; case 'ignore-win32': - if (strstr(PHP_OS, 'WIN')) { + if (WIN_OS) { foreach ($words as $func) $this->ignores[$func] = true; foreach (preg_split('!\s+!', $rest, -1, PREG_SPLIT_NO_EMPTY) as $func) @@ -126,7 +126,7 @@ class Overrides { break; case 'ignore-win32-glob': - if (strstr(PHP_OS, 'WIN')) { + if (WIN_OS) { foreach ($words as $func) $this->glob_ignores[] = $func; foreach (preg_split('!\s+!', $rest, -1, PREG_SPLIT_NO_EMPTY) as $func) diff --git a/win32/README.win32.txt b/win32/README.win32.txt index 8e21709..49d1b05 100644 --- a/win32/README.win32.txt +++ b/win32/README.win32.txt @@ -1,129 +1,150 @@ -Installing php-gtk on Windows NT/Windows 2000 +The Win32 Build System. -Building PHP-GTK from scratch requires the PHP5 build environment -as well as MS Visual Studio. +=========================================================== +Contents: -Get the latest version of PHP-GTK from the cvs server +1. How to build PHP-GTK 2 under Windows -cvs -d:cvsreas@cvs.php.net:/repository login -Password: phpfi -cvs -d:cvsreas@cvs.php.net:/repository co php-gtk + a. Requirements + b. Opening a command prompt + c. Generating configure.js + d. Configuring + e. Building + f. Cleaning Up -Download the following development files -ftp://ftp.gnu.org/gnu/gettext/gettext-runtime-0.12.1.bin.woe32.zip -http://www.gimp.org/~tml/gimp/win32/glib-dev-2.2.3.zip -http://www.gimp.org/~tml/gimp/win32/gtk+-dev-1.3.0-20030115.zip -ftp://ftp.gnu.org/gnu/libiconv/libiconv-1.9.1.bin.woe32.zip +2. How to install and run PHP-GTK 2 -Unzip these files to a directory structure like this: + a. Requirements + b. Installation + c. Running a PHP-GTK test script -\src\gettext-0.12.1 -\src\glib-2.2.3 -\src\gtk+1.3.0 -\src\libiconv-1.9.1 +=========================================================== +1. How to build PHP-GTK under Windows -Download these runtime environments -http://www.gimp.org/~tml/gimp/win32/gtk+-1.3.0-20030717.zip -http://www.gimp.org/~tml/gimp/win32/glib-2.2.3.zip +a. Requirements -Unzip both viles to + You need: + - Everything you already use for building PHP 5 under 'the new build system' + - A freshly-built copy of PHP 5 CGI or CLI, and the source you built it from -\src\gtk-runtime + You also need: + - The development packages for GTK+ 2.6.9, from http://www.gimp.org/~tml/gimp/win32/downloads.html + - Copies of grep.exe and sed.exe. If you have cygwin installed, they will probably be in there. If + you don't have cygwin installed, you can download them easily from http://unxutils.sourceforge.net/ + - put them either in your root directory or in \bin. + - The latest version of PHP-GTK from the CVS server -Filename might change with new releases. -Links to the latest files are found on -http://www.gimp.org/~tml/gimp/win32/downloads.html -http://www.zlatkovic.com/projects/libxml/binaries.html + Unzip the GTK+ development packages and put the libs and headers into your development environment: -Compile PHP5 as a CLI and/or CGI module and copy at lease these files to c:\php5 (or any directory of your choice). + \include\gdkconfig.h + \include\glibconfig.h + \include\glib.h + \include\glib-object.h + \include\gmodule.h -php.exe -php4ts.dll -php.ini + \include\atk\ + \include\gdk\ + \include\gdk-pixbuf\ + \include\glib\ + \include\gobject\ + \include\gtk\ + \lib\ -Add the directory to the list of Executable files in Visual Studio. -You doo thie by: - Select "Options" in the tools menu - Select "Directories" tab - Select "Ececutable files" in the drop down list - Go to the empty line and add the path to php (c:\php5) - Close the options window. + Check out the php-gtk directory as a sibling directory for \php5: + cvs -d:cvsread@cvs.php.net:/repository login + Password: phpfi + cvs -d:cvsread@cvs.php.net:/repository co php-gtk -include_path in php.ini should contain ".;" in addition to other include paths used +b. Opening a command prompt -You should also add the folowing include and lib paths to Visual Studio + Whatever approach you adopted when you built PHP, you will need to repeat in the php-gtk + directory. -Inclide files: -\src\libiconv-1.9.1\include -\src\gtk+1.3.0\include -\src\gtk+1.3.0\lib\gtk+\include -\src\glib-2.2.3\include\glib-2.0 -\src\glib-2.2.3\lib\glib-2.0\include + You will need to add the paths to your PHP sources (php5\Zend, php5\TSRM, php5\main) to + the Include env var in your compiler. You will also need to add the path to the php5ts.lib + you are building against to the Library env var, and the path to a PHP executable binary + (any PHP binary will be fine for this) to %PATH%. -Library files -\src\libiconv-1.9.1\lib -\src\gtk+1.3.0\lib -\src\glib-2.2.3\lib -\src\gettext-0.12.1\lib +c. Generating configure -Building php-gtk: -Open the workspace php-gtk.dsw -Select "php_gtk" as the active project and compile it. -It is also possible to build "combobutton", "scrollpane", "spaned" and "sqpane" + Change directory to where you have your PHP-GTK sources, i.e. cd \\php-gtk + Run buildconf.bat by typing "buildconf" at the command prompt. -Building the libglade extension requires download and installation of -http://prdownloads.sourceforge.net/wingtk/libglade-0.17.exe?download +d. Configuring -Add these paths to Visual Studio: + cscript /nologo configure.js --help -Inclide files: -\src\libglade\source\libglade-0.17 + Will give you a list of configuration options. -Library files: -\src\libglade + --with-php-build will tell the configure process (not the compiler) where your headers + and libraries are stored. You probably won't need to specify this. -Building the scintilla extension requires download and installation of -http://prdownloads.sourceforge.net/moleskine/GtkScintilla-0.8.2.tar.gz + --with-cygwin will tell the configure process where cygwin lives on your system. You might + need this to enable it to find grep and sed, which are used during the process. The + default setting is \cygwin. -This file contains source files only. + --enable-object-out-dir allows you to choose where your php-gtk2.dll should be created. + By default, the path will be either php-gtk\Release or php-gtk\Debug. -For updated versions of GTK libraries, check http://wingtk.sourceforge.net/ -Updated versions of all libraries can also be found at http://kromann.info/php5-gtk + --enable-debug will build the debug version. Please use PHP CGI if you're using debug. -Installation: -Copy all the dll files from \php-gtk\win32\Release_TS to c:\php5 (or the directory where you copied the PHP binaries to). + There is no 'shared' option because PHP-GTK libraries will always be shared. -Copy these files to c:\php5 -\src\gtk-runtime\bin\libglib-2.0-0.dll -\src\gtk-runtime\bin\libgmodule-2.0-0.dll -\src\gtk-runtime\bin\libgobject-2.0-0.dll -\src\gtk-runtime\bin\libgthread-2.0-0.dll -\src\gtk-runtime\lib\libgdk-0.dll -\src\gtk-runtime\lib\libgtk-0.dll -\src\gettext-0.12.1\bin\intl.dll -\src\libiconv-1.9.1\bin\iconv.dll -\src\libglade\libglade.dll + The log files generated during configuration are sent to win32\logs. + +e. Building + + Once you have successfully configured your build, you can build the code; simply type + "nmake" at the command prompt. + +f. Cleaning Up + + Cleaning occurs automatically during buildconf. + +2. How to install and run PHP-GTK 2 + +a. Requirements + + You need: + - The runtime packages for GTK+ 2.6.9, from http://www.gimp.org/~tml/gimp/win32/downloads.html + +b. Installation + + At present the Release version of php-gtk2.dll will only run from C:\php5, so you will + need to put php.exe (either CLI or CGI), php5ts.dll and the .dll files for any other + PHP extensions you need, into that directory. Also a copy of php.ini. + + Just to be awkward, the Debug version of php-gtk2.dll currently will _only_ run from + C:\php5\Debug using a PHP CGI executable. There is a PHP debug symbols pack available + from http://snaps.php.net. + + Retrieve the .dll files from the various GTK+ runtime zips. The 'pango\modules', 'pixbufloader' + and 'immodules' .dlls can go anywhere you like, but the rest need to be somewhere the + php5ts.dll can see them - that is, either in your root directory or in C:\php5. + + Copy the 'etc' directory and everything in it (pango\* and gtk-2.0\*) directly to + C:\Windows\System32. You will need to manually alter the paths in pango.modules, + gdk-pixbuf.loaders and (possibly) gtk.immodules to reflect the whereabouts of the + relevant .dll files. PHP-GTK 2 won't work at all without the first two of these. + + Add the following lines to your php.ini: + + extension=php_gtk.dll + php-gtk.codepage = CP1252 + + (unless of course you're using some other codepage...) + +c. Running a PHP-GTK test script + + Using the command line, navigate to your PHP-GTK directory and type: + + C:\php5\php stock-browser.php + + Or create a shortcut, starting from php-gtk\demos: + + C:\php5\php.exe -q stock-browser.php -You can load this extension from php.ini by adding this line +Enjoy! - extension=php_gtk.dll - -It is not recomended to use this method if php is used for both Gtk and Web. -The extenstion can't be loaded by php running under a web service. -The extension can also be loaded with the dl() command. - - dl("php_gtk.dll"); - -On a command line type: - cd \php-gtk\test - c:\php5\php -q gtk.php - -Or create a shortcut: - C:\php5\php.exe -q c:\php-gtk\test\gtk.php - - - -Happy hacking - -Frank M. Kromann +Steph Fox diff --git a/win32/config.w32.in b/win32/config.w32.in index 2fb2e59..ca4d2f1 100644 --- a/win32/config.w32.in +++ b/win32/config.w32.in @@ -42,8 +42,8 @@ if (CL) { STDOUT.WriteBlankLines(1); -ARG_WITH('php', 'Path to PHP 5 CLI executable', '..\\php5\\Release_TS\\php.exe'); -ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin\\bin'); +ARG_WITH('php-build', 'Path to where you extracted http://www.php.net/extra/win32build.zip. Assumes that it is a sibling of this source dir (..\\php_build) if not specified', 'no'); +ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin'); // stick objects somewhere outside of the source tree ARG_ENABLE('object-out-dir', 'Alternative location for binary objects during build', ''); @@ -78,10 +78,10 @@ DEFINE("PHP_GTK_LDFLAGS", "$(DLL_LDFLAGS)"); DEFINE("LIBS", "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib"); if (PHP_GTK_DEBUG == "yes") { - DEFINE("CFLAGS", "/nologo /LDd /MDd /Gm /ZI /GZ /I ..\\php5\\main /I ..\\php5\\regex /I ..\\php5\\Zend /I ..\\php5\\TSRM /D ZEND_WIN32 /D ZTS=1 /D ZEND_DEBUG=0 /D PHP_WIN32 /D WIN32 /D _DEBUG /D _WINDOWS /D _MBCS /D _USRDLL"); + DEFINE("CFLAGS", "/nologo /LDd /MDd /Gm /ZI /GZ /I ..\\php5 /I ..\\php5\\main /I ..\\php5\\regex /I ..\\php5\\Zend /I ..\\php5\\TSRM /D ZEND_WIN32 /D ZTS=1 /D ZEND_DEBUG=0 /D PHP_WIN32 /D WIN32 /D _DEBUG /D _WINDOWS /D _MBCS /D _USRDLL"); ADD_FLAG("LDFLAGS", "/debug"); } else { - DEFINE("CFLAGS", "/nologo /MT /W3 /GX /O2 /I ..\\php5\\main /I ..\\php5\\regex /I ..\\php5\\Zend /I ..\\php5\\TSRM /D ZEND_WIN32 /D ZTS=1 /D ZEND_DEBUG=0 /D PHP_WIN32 /D WIN32 /D NDEBUG /D _WINDOWS /D _MBCS /D _USRDLL"); + DEFINE("CFLAGS", "/nologo /MT /W3 /GX /O2 /I ..\\php5 /I ..\\php5\\main /I ..\\php5\\regex /I ..\\php5\\Zend /I ..\\php5\\TSRM /D ZEND_WIN32 /D ZTS=1 /D ZEND_DEBUG=0 /D PHP_WIN32 /D WIN32 /D NDEBUG /D _WINDOWS /D _MBCS /D _USRDLL"); } if (VCVERS < 14) { @@ -98,5 +98,19 @@ if (VCVERS >= 14) { // Base includes ADD_FLAG("CFLAGS_PHP_GTK", "/I . /I ..\\ /I ..\\.. /I main /I ..\\main /I ext /I ..\\ext"); +if (PHP_GTK_PHP_BUILD == 'no') { + if (FSO.FolderExists("..\\php_build")) { + PHP_GTK_PHP_BUILD = "..\\php_build"; + } else if (FSO.FolderExists("..\\win32build")) { + PHP_GTK_PHP_BUILD = "..\\win32build"; + } else if (FSO.FolderExists("..\\php-win32-dev\\php_build")) { + PHP_GTK_PHP_BUILD = "..\\php-win32-dev\\php_build"; + } +} + var php_usual_include_suspects = "..\\php_build\\include;..\\win32build\\include"; var php_usual_lib_suspects = "..\\php_build\\lib;..\\win32build\\lib"; + +probe_basic_headers(); + +ADD_SOURCES("main", "php_gtk.c php_gtk_ext.w32.c php_gtk_util.c phpg_closure.c phpg_exceptions.c phpg_gboxed.c phpg_gobject.c phpg_gtype.c phpg_gvalue.c phpg_support.c", "php-gtk"); diff --git a/win32/confutils.js b/win32/confutils.js index be9abc4..cf5b02e 100644 --- a/win32/confutils.js +++ b/win32/confutils.js @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -// $Id: confutils.js,v 1.1 2005-09-02 17:36:23 sfox Exp $ +// $Id: confutils.js,v 1.2 2005-09-04 06:02:28 sfox Exp $ /* set vars */ var STDOUT = WScript.StdOut; @@ -224,22 +224,15 @@ function conf_process_args() { } } if (!found) { - STDERR.WriteLine("Unknown option " + argname + "; please try configure.js --help for a list of valid options"); + STDERR.WriteLine("Unknown option " + argname) + STDERR.WriteLine("Please try configure.js --help for a list of valid options"); WScript.Quit(2); } } if (configure_help_mode) { STDOUT.WriteBlankLines(1); - STDOUT.WriteLine(word_wrap_and_indent(0, -"Options that enable extensions will accept \ -'yes' or 'no' as a parameter. They also accept 'shared' \ -as a synonym for 'yes' and request a shared build of that \ -module. Not all modules can be built as shared modules; \ -configure will display [shared] after the module name if \ -can be built that way. \ -" - )); + STDOUT.WriteLine(" There are no PHP-GTK extensions available at present."); STDOUT.WriteBlankLines(1); // Measure width to pretty-print the output @@ -634,7 +627,7 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) { if (dllname == null) { if (extname == 'php-gtk') { - dllname = extname + ".dll"; + dllname = extname + "2.dll"; } else { dllname = "php_gtk_" + extname + ".dll"; } @@ -1143,6 +1136,24 @@ function probe_msvc_compiler_version(CL) { return 0; } +// Poke around for some headers +function probe_basic_headers() +{ + var p; + + if (PHP_GTK_PHP_BUILD != "no") { + php_usual_include_suspects += ";" + PHP_GTK_PHP_BUILD + "\\include"; + php_usual_lib_suspects += ";" + PHP_GTK_PHP_BUILD + "\\lib"; + } + + // hack to catch common location of libs + if (typeof(p) == "string") { + p = p.replace(new RegExp("include$"), "lib"); + ADD_FLAG("LDFLAGS", '/libpath:"' + p + '" '); + php_usual_lib_suspects += ";" + p; + } +} + /* non-functions */ if (!FSO.FileExists("buildconf.bat")) {