]> git.lyx.org Git - features.git/commitdiff
Automate setting of LYX_DIR_XXx and LYX_USERDIR_XXx environment variable names.
authorEnrico Forestieri <forenr@lyx.org>
Sat, 26 Jul 2008 10:45:38 +0000 (10:45 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Sat, 26 Jul 2008 10:45:38 +0000 (10:45 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25898 a592a061-630c-0410-9148-cb99ea01b6c8

config/lyxinclude.m4
configure.ac
development/cmake/CMakeLists.txt
development/cmake/config.h.cmake
development/scons/SConstruct
development/scons/scons_utils.py
src/support/Package.cpp
src/support/Package.h

index 620ebe40b05590a15ea830b45f06d042aae5a9c8..fc5df0f852bf78a19d5a12c94d6bdd2308f2af64 100644 (file)
@@ -736,8 +736,8 @@ do
 done])
 
 dnl Extract the single digits from PACKAGE_VERSION and make them available.
-dnl Defines LYX_MAJOR_VERSION, LYX_MINOR_VERSION, LYX_RELEASE_LEVEL, and
-dnl LYX_RELEASE_PATCH, the latter being possibly equal to 0.
+dnl Defines LYX_MAJOR_VERSION, LYX_MINOR_VERSION, LYX_RELEASE_LEVEL,
+dnl LYX_RELEASE_PATCH (possibly equal to 0), LYX_DIR_VER, and LYX_USERDIR_VER.
 AC_DEFUN([LYX_SET_VERSION_INFO],
 [lyx_major=`echo $PACKAGE_VERSION | sed -e 's/[[.]].*//'`
  lyx_patch=`echo $PACKAGE_VERSION | sed -e "s/^$lyx_major//" -e 's/^.//'`
@@ -746,8 +746,12 @@ AC_DEFUN([LYX_SET_VERSION_INFO],
  lyx_release=`echo $lyx_patch | sed -e 's/[[^0-9]].*//'`
  lyx_patch=`echo $lyx_patch | sed -e "s/^$lyx_release//" -e 's/^[[.]]//' -e 's/[[^0-9]].*//'`
  test "x$lyx_patch" = "x" && lyx_patch=0
+ lyx_dir_ver=`echo LYX_DIR_${lyx_major}${lyx_minor}x`
+ lyx_userdir_ver=`echo LYX_USERDIR_${lyx_major}${lyx_minor}x`
  AC_SUBST(LYX_MAJOR_VERSION,$lyx_major)
  AC_SUBST(LYX_MINOR_VERSION,$lyx_minor)
  AC_SUBST(LYX_RELEASE_LEVEL,$lyx_release)
  AC_SUBST(LYX_RELEASE_PATCH,$lyx_patch)
+ AC_SUBST(LYX_DIR_VER,"$lyx_dir_ver")
+ AC_SUBST(LYX_USERDIR_VER,"$lyx_userdir_ver")
 ])
index 988e51094ae0427529ec66240747a4d43539fe30..b677521dddd43ead5eab7887eb9e1acab0196cb1 100644 (file)
@@ -451,6 +451,8 @@ AC_DEFINE_UNQUOTED([PROGRAM_SUFFIX],
 
 AC_DEFINE_UNQUOTED([LYX_DATE],"$LYX_DATE",[Date of release])
 AC_DEFINE_UNQUOTED([VERSION_INFO],"$VERSION_INFO",[Full version info])
+AC_DEFINE_UNQUOTED([LYX_DIR_VER],"$lyx_dir_ver",[Versioned env var for system dir])
+AC_DEFINE_UNQUOTED([LYX_USERDIR_VER],"$lyx_userdir_ver",[Versioned env var for user dir])
 AC_DEFINE_UNQUOTED([LYX_MAJOR_VERSION],$lyx_major,[Major version number])
 AC_DEFINE_UNQUOTED([LYX_MINOR_VERSION],$lyx_minor,[Minor version number])
 AC_DEFINE_UNQUOTED([LYX_RELEASE_LEVEL],$lyx_release,[Release version number])
index 101580ce0db636d58b97585fe74fe58204e07e0e..b44bb70797aef92382ab2a80d65980b71d5a1bd9 100644 (file)
@@ -28,6 +28,8 @@ set(PACKAGE_VERSION 1.6svn)
 set(LYX_DATE "2007/2008")
 #TODO
 set(VERSION_INFO "CMake Build")
+set(LYX_DIR_VER "LYX_DIR_16x")
+set(LYX_USERDIR_VER "LYX_USERDIR_16x")
 
 set(PROGRAM_SUFFIX "")
 set(LYX_ABS_INSTALLED_DATADIR "/usr/local/share/lyx")
index d0cf2a886d4242ff820256cf31da7ad634c65128..b3a15cca53338ef0e3de9f283a057770699a5bae 100644 (file)
@@ -25,6 +25,8 @@
 #cmakedefine PACKAGE_VERSION "${PACKAGE_VERSION}"
 #cmakedefine LYX_DATE "${LYX_DATE}"
 #cmakedefine VERSION_INFO "${VERSION_INFO}"
+#cmakedefine LYX_DIR_VER "${LYX_DIR_VER}"
+#cmakedefine LYX_USERDIR_VER "${LYX_USERDIR_VER}"
 
 #cmakedefine PROGRAM_SUFFIX "${PPROGRAM_SUFFIX}"
 #cmakedefine LYX_ABS_INSTALLED_DATADIR "${LYX_DIR}"
index 8becd1272a8ed72fb175bbcadff9efcc149deeb1..b19b096c8d2162b4ac18b20dbc58ab795dda38e6 100644 (file)
@@ -58,7 +58,7 @@ if version[0] == 0 and version[1] == 96 and version[2] < 92:
 #
 # get version number from configure.ac so that JMarc does
 # not have to change SConstruct during lyx release
-package_version, lyx_date = utils.getVerFromConfigure(top_src_dir)
+package_version, majmin_ver, lyx_date = utils.getVerFromConfigure(top_src_dir)
 package_cygwin_version = '%s-1' % package_version
 boost_version = ['1_34']
 
@@ -1038,6 +1038,10 @@ result = utils.createConfigFile(conf,
             'Define to the version of this package.'),
         ('#define VERSION_INFO "%s"' % env['VERSION_INFO'].replace('\n', '\\n'),
             'Full version info'),
+        ('#define LYX_DIR_VER "LYX_DIR_%sx"' % majmin_ver,
+            'Versioned env var for system dir'),
+        ('#define LYX_USERDIR_VER "LYX_USERDIR_%sx"' % majmin_ver,
+            'Versioned env var for user dir'),
         ('#define LYX_DATE "%s"' % lyx_date,
             'Date of release'),
         ('#define PROGRAM_SUFFIX "%s"' % program_suffix,
index 3f5a120417ad51c2b77688ea8cbdffe277965f04..bc8a63a7904ee2319703a15cae82017f7269d658 100644 (file)
@@ -18,6 +18,7 @@ from SCons.Util import *
 
 def getVerFromConfigure(path):
     ''' get lyx version from the AC_INIT line of configure.ac,
+        packed major and minor version numbers from the lyx version,
         and LYX_DATE from an AC_SUBST line.
     '''
     try:
@@ -29,16 +30,20 @@ def getVerFromConfigure(path):
     # AC_INIT(LyX,1.4.4svn,[lyx-devel@lists.lyx.org],[lyx])
     ver_pat = re.compile('AC_INIT\([^,]+,([^,]+),')
     date_pat = re.compile('AC_SUBST\(LYX_DATE, \["(.*)"\]\)')
+    majmin_pat = re.compile('(\d+)\.(\d+)\..*')
     version = 'x.x.x'
+    majmin = 'xx'
     date = 'Not released'
     for line in config.readlines():
         if ver_pat.match(line):
             (version,) = ver_pat.match(line).groups()
+            majmin_match = majmin_pat.match(version)
+            majmin = majmin_match.group(1) + majmin_match.group(2)
         if date_pat.match(line):
             (date,) = date_pat.match(line).groups()
         if version != 'x.x.x' and date != 'Not released':
             break
-    return version.strip(), date.strip()
+    return version.strip(), majmin.strip(), date.strip()
 
 
 def relativePath(path, base):
index 51b9ea2d84a0ea09fd15c4df2bcccea2936dcc3b..eccd3e7ef8abec5a57961d058fbe91720c0396ef 100644 (file)
@@ -461,13 +461,11 @@ get_system_support_dir(FileName const & abs_binary,
                        return path;
        }
 
-       // 2. Use the "LYX_DIR_16x" environment variable.
-       // FIXME We need to iherit the actual version number from elsewhere
-       // otherwise we will forget to update this for new major releases
-       path = extract_env_var_dir("LYX_DIR_16x");
+       // 2. Use the "LYX_DIR_${major}${minor}x" environment variable.
+       path = extract_env_var_dir(LYX_DIR_VER);
        if (!path.empty()) {
                searched_dirs.push_back(path);
-               if (check_env_var_dir(path, chkconfig_ltx, "LYX_DIR_16x"))
+               if (check_env_var_dir(path, chkconfig_ltx, LYX_DIR_VER))
                        return path;
        }
 
@@ -555,12 +553,12 @@ get_system_support_dir(FileName const & abs_binary,
        // FIXME UNICODE
        throw ExceptionMessage(ErrorException, _("No system directory"),
                bformat(_("Unable to determine the system directory "
-                                        "having searched\n"
-                                        "\t%1$s\n"
-                                        "Use the '-sysdir' command line parameter or "
-                                        "set the environment variable LYX_DIR_16x to "
-                                        "the LyX system directory containing the file "
-                                        "`chkconfig.ltx'."),
+                               "having searched\n"
+                               "\t%1$s\n"
+                               "Use the '-sysdir' command line parameter or "
+                               "set the environment variable " LYX_DIR_VER " "
+                               "to the LyX system directory containing the "
+                               "file `chkconfig.ltx'."),
                          from_utf8(searched_dirs_str)));
 
        // Keep the compiler happy.
@@ -579,8 +577,8 @@ bool userSupportDir(FileName const & default_user_support_dir,
        if (!result.empty())
                return true;
 
-       // 2. Use the LYX_USERDIR_16x environment variable.
-       result = extract_env_var_dir("LYX_USERDIR_16x");
+       // 2. Use the LYX_USERDIR_${major}${minor}x environment variable.
+       result = extract_env_var_dir(LYX_USERDIR_VER);
        if (!result.empty())
                return true;
 
index 0cb4336ee236bd777858dc5bfd35b61ef6f3b000..8cd2e013c7abd808aa9c4246c23fb8d2ac3ca5d1 100644 (file)
@@ -94,7 +94,7 @@ public:
 
        /** The user_support directory was set explicitly using either
         *  the -userdir command line switch or
-        *  the LYX_USERDIR_16x environment variable.
+        *  the LYX_USERDIR_${major}${minor}x environment variable.
         */
        bool explicit_user_support() const { return explicit_user_support_dir_; }