diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4 index f173f6962c..446dce894e 100644 --- a/config/lyxinclude.m4 +++ b/config/lyxinclude.m4 @@ -610,6 +610,7 @@ AC_ARG_WITH(packaging, esac]) AC_MSG_RESULT($lyx_use_packaging) lyx_install_macosx=false +lyx_install_cygwin=false case $lyx_use_packaging in macosx) AC_DEFINE(USE_MACOSX_PACKAGING, 1, [Define to 1 if LyX should use a MacOS X application bundle file layout]) PACKAGE=LyX${version_suffix} @@ -632,10 +633,14 @@ case $lyx_use_packaging in PACKAGE=lyx${version_suffix} program_suffix=$version_suffix pkgdatadir='${datadir}/${PACKAGE}' - default_prefix=$ac_default_prefix ;; + default_prefix=$ac_default_prefix + case ${host} in + *cygwin*) lyx_install_cygwin=true ;; + esac ;; *) LYX_ERROR([Unknown packaging type $lyx_use_packaging]) ;; esac AM_CONDITIONAL(INSTALL_MACOSX, $lyx_install_macosx) +AM_CONDITIONAL(INSTALL_CYGWIN, $lyx_install_cygwin) dnl Next two lines are only for autoconf <= 2.59 datadir='${datarootdir}' AC_SUBST(datarootdir) diff --git a/configure.ac b/configure.ac index 054da29f9a..f81818aa40 100644 --- a/configure.ac +++ b/configure.ac @@ -401,6 +401,8 @@ AC_CONFIG_FILES([Makefile \ development/MacOSX/Info.plist \ development/MacOSX/lyxrc.dist \ development/MacOSX/spotlight/Makefile \ + development/cygwin/Makefile \ + development/cygwin/lyxrc.dist \ development/lyx.spec \ intl/Makefile \ lib/Makefile \ diff --git a/development/Makefile.am b/development/Makefile.am index 25716c7af4..f7d88dd6c3 100644 --- a/development/Makefile.am +++ b/development/Makefile.am @@ -4,6 +4,10 @@ if INSTALL_MACOSX SUBDIRS = MacOSX endif +if INSTALL_CYGWIN +SUBDIRS = cygwin +endif + EXTRA_DIST = boostworkaround.txt coding/Rules coding/Recommendations \ FORMAT lyx.rpm.README \ lyxserver lyx.spec.in lyx.spec Seminar.txt \ diff --git a/development/cygwin/Makefile.am b/development/cygwin/Makefile.am new file mode 100644 index 0000000000..5e9e22e933 --- /dev/null +++ b/development/cygwin/Makefile.am @@ -0,0 +1,20 @@ +include $(top_srcdir)/config/common.am + +.c.o: + $(CC) -I$(top_builddir) $< -O2 -c -o $@ -mwindows -e _mainCRTStartup + +.rc.o: + cp $(top_srcdir)/development/Win32/packaging/icons/lyx_*32x32.ico . + windres -I$(top_builddir) --preprocessor "$(CPP) -xc-header -DRC_INVOKED" $< -o $@ + +bin_PROGRAMS = lyxeditor lyxwin +bin_SCRIPTS = lyxeditor.sh +dist_noinst_DATA = lyxprofile + +lyxeditor_SOURCES = lyxeditor.c +lyxwin_SOURCES = lyxwin.c lyxwinres.rc + +CLEANFILES += lyxeditor.sh lyx_32x32.ico lyx_doc_32x32.ico + +lyxeditor.sh: + cp $(top_srcdir)/development/tools/lyxeditor $@ diff --git a/development/cygwin/lyxeditor.c b/development/cygwin/lyxeditor.c new file mode 100644 index 0000000000..c82a9f22be --- /dev/null +++ b/development/cygwin/lyxeditor.c @@ -0,0 +1,43 @@ +/** + * \file lyxeditor.c + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Enrico Forestieri + * + * Full author contact details are available in file CREDITS. + * + * This is a wrapper program for the lyxeditor.sh script or lyxclient program, + * meant to be used with yap or sumatrapdf for inverse search. + */ + +#include "config.h" +#include +#include +#include +#include +#include + +int main(int ac, char **av) +{ + char buf[2 * PATH_MAX]; + char posixpath[PATH_MAX + 1]; + + if (ac < 3 || ac > 4) { + MessageBox(0, "Usage: lyxeditor [-g] ", + "ERROR: Wrong number of arguments", 0); + return 1; + } + + if (ac == 3) { + cygwin_conv_to_full_posix_path(av[1], posixpath); + sprintf(buf, "lyxeditor.sh" PROGRAM_SUFFIX " '%s' %s", + posixpath, av[2]); + } else { + cygwin_conv_to_full_posix_path(av[2], posixpath); + sprintf(buf, "lyxclient" PROGRAM_SUFFIX " %s '%s' %s", + av[1], posixpath, av[3]); + } + system(buf); + return 0; +} diff --git a/development/cygwin/lyxprofile b/development/cygwin/lyxprofile new file mode 100644 index 0000000000..81ef67f8c4 --- /dev/null +++ b/development/cygwin/lyxprofile @@ -0,0 +1,52 @@ +# Set up the home directory if not already set in the system environment. +if [ -z "${HOME}" ]; then + USER=`id -un` + HOME=`grep "^${USER}:" /etc/passwd | cut -d: -f6` + if [ -z "${HOME}" -o ! -d "${HOME}" ]; then + DOCSFOLDER=`regtool -q get '\HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal'` + test -n "${DOCSFOLDER}" && HOME=`cygpath -u "${DOCSFOLDER}"` || HOME=/tmp + fi +fi +export HOME + +# Set up your Language (if you do not want English) by +# replacing C (for C locale) with your country code in +# the following line. +export LANG=C + +# Set up the output charset for your locale. +# You may need to experiment with this if you get garbage +# in menus ("`a" instead of "à", for example). +export OUTPUT_CHARSET=iso-8859-1 + +# Set up Hostname/IP address where LyX can find an X-server. +export DISPLAY=localhost:0.0 + +# ======================================================== +# Below this line you should not change anything if you're +# not familiar with configuration of an unix application! +# ======================================================== +export PATH="/usr/local/bin:/usr/bin:/usr/X11R6/bin:$PATH" +export USER="`id -un`" +export MAKE_MODE=unix +export OSTYPE=cygwin + +unset DOSDRIVE +unset DOSDIR +unset TMPDIR +unset TMP + +for f in /etc/profile.d/*.sh ; do + if [ -f "${f}" ]; then + . "${f}" + fi +done + +if [ ! -z "${CDPATH}" ]; then + cd "${CDPATH}" + unset CDPATH +else + cd "${HOME}" +fi + +test -f "${HOME}/.bashrc" && . "${HOME}/.bashrc" diff --git a/development/cygwin/lyxrc.dist.in b/development/cygwin/lyxrc.dist.in new file mode 100644 index 0000000000..89f1fa2188 --- /dev/null +++ b/development/cygwin/lyxrc.dist.in @@ -0,0 +1,20 @@ +### This file is part of +### ======================================================== +### LyX, The Document Processor +### +### Copyright 1995 Matthias Ettrich +### Copyright 1995-2008 The LyX Team. +### +### ======================================================== + +# The file lyxrc.dist gives initial global options for all LyX users. +# Almost all settings here can be overridden through the preferences in LyX. + +\screen_dpi 96 +\screen_zoom 150 +\screen_font_roman "Times New Roman" +\screen_font_sans "Arial" +\screen_font_typewriter "Courier New" +\preview_scale_factor 1.0 +\serverpipe "~/.lyx@version_suffix@/lyxpipe" +\path_prefix "/usr/local/bin:/usr/bin:/usr/X11R6/bin" diff --git a/development/cygwin/lyxwin.c b/development/cygwin/lyxwin.c new file mode 100644 index 0000000000..d57bfa4e02 --- /dev/null +++ b/development/cygwin/lyxwin.c @@ -0,0 +1,72 @@ +/** + * \file lyxwin.c + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Claus Hentschel + * \author Enrico Forestieri + * + * Full author contact details are available in file CREDITS. + * + * This is the wrapper program for LyX/Cygwin. Using this wrapper no + * DOS window will be present when running LyX from the Windows GUI. + * The bad side of this: no error output can be seen ;-) + * + * It launches the real binary using the native Windows GUI. + */ + +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include + +int main (int argc, char **argv, char **environ) +{ + FILE *fp; + char *s; + char posixpath[PATH_MAX]; + char cmd[4096] = PACKAGE " "; + char const *nargs[5] = { + "/bin/bash", "--login", + "-c", cmd, + NULL + }; + int i = 1; + + while (i < argc) { + int done = 0; + int lyxfile = (s = strrchr(argv[i], '.')) + && strcasecmp(s, ".lyx") == 0; + /* Add initial quote */ + strcat(cmd, "\""); + cygwin_conv_to_posix_path(argv[i], posixpath) ; + /* Hack to account for shares */ + if (lyxfile && argv[i][0] == '\\' && argv[i][1] != '\\') + strcat(cmd, "/"); + /* add the argument */ + strcat(cmd, posixpath); + /* add closing quote */ + strcat(cmd, "\" "); + if (!done && lyxfile && (s = strrchr(posixpath,'/'))) { + *s = '\0'; + if (setenv("CDPATH", posixpath, 1) == 0) + done = 1; + } + ++i; + } + + strcat(cmd, "/dev/null 2>&1"); + + /* fprintf(stderr , "Command is: |%s|\n", cmd); */ + /* ensure bash reads our global env changes */ + putenv("BASH_ENV=/etc/lyxprofile") ; + /* exec sub command */ + spawnv(_P_NOWAIT, "/bin/bash", nargs); + /* exit with no error */ + return(0) ; +} diff --git a/development/cygwin/lyxwinres.rc b/development/cygwin/lyxwinres.rc new file mode 100644 index 0000000000..6bceb3b0a7 --- /dev/null +++ b/development/cygwin/lyxwinres.rc @@ -0,0 +1,44 @@ +/* Icons */ +IDI_ICON1 ICON DISCARDABLE "lyx_32x32.ico" +IDI_ICON2 ICON DISCARDABLE "lyx_doc_32x32.ico" + +#include "config.h" +#include + +#if LYX_RELEASE_PATCH > 0 +#define PATCH_TAG ".LYX_RELEASE_PATCH" +#else +#define PATCH_TAG "" +#endif + +LANGUAGE 0x9, 0x1 /* LANG_ENGLISH, SUBLANG_DEFAULT */ + +VS_VERSION_INFO VERSIONINFO +FILEVERSION LYX_MAJOR_VERSION,LYX_MINOR_VERSION,LYX_RELEASE_LEVEL,LYX_RELEASE_PATCH +PRODUCTVERSION LYX_MAJOR_VERSION,LYX_MINOR_VERSION,LYX_RELEASE_LEVEL,LYX_RELEASE_PATCH +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS 0x0L +FILEOS VOS__WINDOWS32 +FILETYPE VFT_APP +FILESUBTYPE 0x0L +{ + BLOCK "StringFileInfo" + { + BLOCK "040904b0" + { + VALUE "FileDescription", "LyX/Cygwin Launcher\0" + VALUE "OriginalFilename", "lyx-win" PROGRAM_SUFFIX ".exe\0" + VALUE "CompanyName", "LyX Team\0" + VALUE "FileVersion", "LYX_MAJOR_VERSION.LYX_MINOR_VERSION.LYX_RELEASE_LEVEL" PATCH_TAG "\0" + VALUE "InternalName", "lyx-win\0" + VALUE "LegalCopyright", "Copyright \251 1995 by Matthias Ettrich, 1995-2008 LyX Team\0" + VALUE "ProductName", "LyX/Cygwin\0" + VALUE "ProductVersion", PACKAGE_VERSION "\0" + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x409, 1200 + } +} +