Patch [#22339] File/installation paths changes
authorAndrea Weikert <elubie@gmx.net>
Sun, 4 Jul 2010 15:35:23 +0000 (15:35 +0000)
committerAndrea Weikert <elubie@gmx.net>
Sun, 4 Jul 2010 15:35:23 +0000 (15:35 +0000)
Patch Tracker: http://projects.blender.org/tracker/?func=detail&aid=22339&group_id=9&atid=127

This patch implements the proposal outlined here:
http://wiki.blender.org/index.php/Dev:2.5/Source/Installation/Proposal

Original patch by Matt Ebb.
Contributions by Nathan Letwory, Damien Plisson and Andrea Weikert

NOTE:
This is a work in progress commit, some work still needs to be done on the SCons and CMake files for this to work properly, but at least should compile and the files should be created in the right directory.

Commit discussed on IRC with Ton and Campbell.

39 files changed:
SConstruct
intern/ghost/GHOST_C-api.h
intern/ghost/GHOST_ISystem.h
intern/ghost/intern/GHOST_C-api.cpp
intern/ghost/intern/GHOST_System.h
intern/ghost/intern/GHOST_SystemCarbon.cpp
intern/ghost/intern/GHOST_SystemCarbon.h
intern/ghost/intern/GHOST_SystemCocoa.h
intern/ghost/intern/GHOST_SystemCocoa.mm
intern/ghost/intern/GHOST_SystemWin32.cpp
intern/ghost/intern/GHOST_SystemWin32.h
intern/ghost/intern/GHOST_SystemX11.cpp
intern/ghost/intern/GHOST_SystemX11.h
release/scripts/ui/space_info.py
source/blender/blenfont/intern/blf_lang.c
source/blender/blenkernel/SConscript
source/blender/blenkernel/intern/blender.c
source/blender/blenlib/BLI_path_util.h
source/blender/blenlib/CMakeLists.txt
source/blender/blenlib/intern/BLI_bfile.c
source/blender/blenlib/intern/path_util.c
source/blender/blenlib/intern/path_util_cocoa.mm [new file with mode: 0644]
source/blender/blenloader/intern/writefile.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_file/fsmenu.c
source/blender/editors/space_file/fsmenu.h
source/blender/editors/space_file/space_file.c
source/blender/editors/space_image/SConscript
source/blender/editors/space_info/space_info.c
source/blender/makesrna/SConscript
source/blender/python/intern/bpy.c
source/blender/python/intern/bpy_interface.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/wm_files.h
source/creator/CMakeLists.txt
tools/Blender.py
tools/btools.py

index 531d89b..0b985f3 100644 (file)
@@ -437,6 +437,8 @@ else:
 #-- .blender
 #- dont do .blender and scripts for darwin, it is already in the bundle
 dotblendlist = []
+datafileslist = []
+datafilestargetlist = []
 dottargetlist = []
 scriptinstall = []
 
@@ -455,17 +457,26 @@ if  env['OURPLATFORM']!='darwin':
                                        if f.endswith('.ttf'):
                                                continue
                                
-                               dotblendlist.append(os.path.join(dp, f))
-                               if env['WITH_BF_FHS']:  dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[2:]))      # skip bin/.blender
-                               else:                                   dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[1:]))      # skip bin
-                               
-                               dottargetlist.append(dir + os.sep + f)
-                                       
+                               if 'locale' in dp:
+                                       datafileslist.append(os.path.join(dp,f))
+                                       if env['WITH_BF_FHS']:  dir= os.path.join(*([BLENDERPATH] + ['datafiles'] + dp.split(os.sep)[2:]))      # skip bin/.blender
+                                       else:                                   dir= os.path.join(*([BLENDERPATH] + ['.blender'] + ['datafiles'] + dp.split(os.sep)[1:]))       # skip bin
+                                       datafilestargetlist.append(dir + os.sep + f)
 
+                               else:
+                                       dotblendlist.append(os.path.join(dp, f))
+                                       if env['WITH_BF_FHS']:  dir= os.path.join(*([BLENDERPATH] + ['config'] + dp.split(os.sep)[2:])) # skip bin/.blender
+                                       else:                                   dir= os.path.join(*([BLENDERPATH] + ['.blender'] + ['config'] + dp.split(os.sep)[1:]))  # skip bin
+                                       
+                                       dottargetlist.append(dir + os.sep + f)
+                                       
                dotblenderinstall = []
                for targetdir,srcfile in zip(dottargetlist, dotblendlist):
                        td, tf = os.path.split(targetdir)
                        dotblenderinstall.append(env.Install(dir=td, source=srcfile))
+               for targetdir,srcfile in zip(datafilestargetlist, datafileslist):
+                       td, tf = os.path.split(targetdir)
+                       dotblenderinstall.append(env.Install(dir=td, source=srcfile))
                
                if env['WITH_BF_PYTHON']:
                        #-- .blender/scripts
index a5fec1f..28fa72f 100644 (file)
@@ -836,20 +836,6 @@ extern GHOST_TUns8* GHOST_getClipboard(int selection);
  */
 extern void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection);
 
-/**
- * Determine the base dir in which shared resources are located. It will first try to use
- * "unpack and run" path, then look for properly installed path, not including versioning.
- * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
- */
-extern const GHOST_TUns8* GHOST_getSystemDir();
-
-/**
- * Determine the base dir in which user configuration is stored, not including versioning.
- * If needed, it will create the base directory.
- * @return Unsigned char string pointing to user dir (eg ~/.blender/).
- */
-extern const GHOST_TUns8* GHOST_getUserDir();
-
 
 #ifdef __cplusplus
 }
index 8d80c74..b4dc883 100644 (file)
@@ -371,24 +371,6 @@ public:
        virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const = 0;
 
        
-       /***************************************************************************************
-        ** Determine special paths.
-        ***************************************************************************************/
-
-       /**
-        * Determine the base dir in which shared resources are located. It will first try to use
-        * "unpack and run" path, then look for properly installed path, not including versioning.
-        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
-        */
-       virtual const GHOST_TUns8* getSystemDir() const = 0;
-
-       /**
-        * Determine the base dir in which user configuration is stored, not including versioning.
-        * If needed, it will create the base directory.
-        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
-        */
-       virtual const GHOST_TUns8* getUserDir() const = 0;
-
 protected:
        /**
         * Initialize the system.
index 9da2020..839d85c 100644 (file)
@@ -865,15 +865,3 @@ void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection)
        GHOST_ISystem* system = GHOST_ISystem::getSystem();
        system->putClipboard(buffer, selection);
 }
-
-const GHOST_TUns8* GHOST_getSystemDir()
-{
-       GHOST_ISystem* system = GHOST_ISystem::getSystem();
-       return system->getSystemDir();
-}
-
-const GHOST_TUns8* GHOST_getUserDir()
-{
-       GHOST_ISystem* system = GHOST_ISystem::getSystem();
-       return system->getUserDir();
-}
index d6c6a35..2b45bfb 100644 (file)
@@ -297,20 +297,6 @@ public:
           */
          virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const = 0;
 
-       /**
-        * Determine the base dir in which shared resources are located. It will first try to use
-        * "unpack and run" path, then look for properly installed path, not including versioning.
-        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
-        */
-       virtual const GHOST_TUns8* getSystemDir() const = 0;
-
-       /**
-        * Determine the base dir in which user configuration is stored, not including versioning.
-        * If needed, it will create the base directory.
-        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
-        */
-       virtual const GHOST_TUns8* getUserDir() const = 0;
-
 protected:
        /**
         * Initialize the system.
index 5522a07..a4011f8 100644 (file)
@@ -1214,23 +1214,3 @@ void GHOST_SystemCarbon::putClipboard(GHOST_TInt8 *buffer, bool selection) const
                CFRelease(textData);
        }
 }
-
-const GHOST_TUns8* GHOST_SystemCarbon::getSystemDir() const
-{
-       return (GHOST_TUns8*)"/Library/Application Support/Blender";
-}
-
-const GHOST_TUns8* GHOST_SystemCarbon::getUserDir() const
-{
-       static char usrPath[256] = "";
-       char* env = getenv("HOME");
-       
-       if (env) {
-               strncpy(usrPath, env, 245);
-               usrPath[245]=0;
-               strcat(usrPath, "/Library/Application Support/Blender");
-               return (GHOST_TUns8*) usrPath;
-       }
-       else
-               return NULL;
-}
index ebd9297..fd5c61f 100644 (file)
@@ -190,20 +190,6 @@ public:
         */
        virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
 
-       /**
-        * Determine the base dir in which shared resources are located. It will first try to use
-        * "unpack and run" path, then look for properly installed path, not including versioning.
-        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
-        */
-       virtual const GHOST_TUns8* getSystemDir() const;
-
-       /**
-        * Determine the base dir in which user configuration is stored, not including versioning.
-        * If needed, it will create the base directory.
-        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
-        */
-       virtual const GHOST_TUns8* getUserDir() const;
-
 protected:
        /**
         * Initializes the system.
index b97c36f..e97f8c7 100644 (file)
@@ -213,20 +213,6 @@ public:
         */
        virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
 
-       /**
-        * Determine the base dir in which shared resources are located. It will first try to use
-        * "unpack and run" path, then look for properly installed path, not including versioning.
-        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
-        */
-       virtual const GHOST_TUns8* getSystemDir() const;
-
-       /**
-        * Determine the base dir in which user configuration is stored, not including versioning.
-        * If needed, it will create the base directory.
-        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
-        */
-       virtual const GHOST_TUns8* getUserDir() const;
-
        /**
      * Handles a window event. Called by GHOST_WindowCocoa window delegate
      * @param eventType The type of window event
index 2cec247..00b00c6 100644 (file)
@@ -1780,61 +1780,3 @@ void GHOST_SystemCocoa::putClipboard(GHOST_TInt8 *buffer, bool selection) const
        
        [pool drain];
 }
-
-#pragma mark Base directories retrieval
-
-const GHOST_TUns8* GHOST_SystemCocoa::getSystemDir() const
-{
-       static GHOST_TUns8 tempPath[512] = "";
-       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-       NSFileManager *fileManager;
-       NSString *basePath;
-       NSArray *paths;
-       
-       paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSLocalDomainMask, YES);
-       
-       if ([paths count] > 0)
-               basePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Blender"];
-       else { //Fall back to standard unix path in case of issue
-               basePath = @"/usr/share/blender";
-       }
-       
-       /* Ensure path exists, creates it if needed */
-       fileManager = [NSFileManager defaultManager];
-       if (![fileManager fileExistsAtPath:basePath isDirectory:NULL]) {
-               [fileManager createDirectoryAtPath:basePath attributes:nil];
-       }
-       
-       strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
-       
-       [pool drain];
-       return tempPath;
-}
-
-const GHOST_TUns8* GHOST_SystemCocoa::getUserDir() const
-{
-       static GHOST_TUns8 tempPath[512] = "";
-       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-       NSFileManager *fileManager;
-       NSString *basePath;
-       NSArray *paths;
-
-       paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
-
-       if ([paths count] > 0)
-               basePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Blender"];
-       else { //Fall back to HOME in case of issue
-               basePath = [NSHomeDirectory() stringByAppendingPathComponent:@".blender"];
-       }
-       
-       /* Ensure path exists, creates it if needed */
-       fileManager = [NSFileManager defaultManager];
-       if (![fileManager fileExistsAtPath:basePath isDirectory:NULL]) {
-               [fileManager createDirectoryAtPath:basePath attributes:nil];
-       }
-       
-       strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
-       
-       [pool drain];
-       return tempPath;
-}
index 91c1927..41cbb72 100644 (file)
@@ -1092,13 +1092,3 @@ void GHOST_SystemWin32::putClipboard(GHOST_TInt8 *buffer, bool selection) const
                return;
        }
 }
-
-const GHOST_TUns8* GHOST_SystemWin32::getSystemDir() const
-{
-       return NULL;
-}
-
-const GHOST_TUns8* GHOST_SystemWin32::getUserDir() const
-{
-       return NULL;
-}
index e65393a..84fca33 100644 (file)
@@ -188,20 +188,6 @@ public:
        virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
        
 
-       /**
-        * Determine the base dir in which shared resources are located. It will first try to use
-        * "unpack and run" path, then look for properly installed path, not including versioning.
-        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
-        */
-       virtual const GHOST_TUns8* getSystemDir() const;
-
-       /**
-        * Determine the base dir in which user configuration is stored, not including versioning.
-        * If needed, it will create the base directory.
-        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
-        */
-        virtual const GHOST_TUns8* getUserDir() const;
-
        /**
         * Creates a drag'n'drop event and pushes it immediately onto the event queue. 
         * Called by GHOST_DropTargetWin32 class.
index 052c868..f286f8a 100644 (file)
@@ -1458,22 +1458,3 @@ void GHOST_SystemX11::putClipboard(GHOST_TInt8 *buffer, bool selection) const
                        fprintf(stderr, "failed to own primary\n");
        }
 }
-
-const GHOST_TUns8* GHOST_SystemX11::getSystemDir() const
-{
-       return (GHOST_TUns8*)"/usr/share/blender";
-}
-
-const GHOST_TUns8* GHOST_SystemX11::getUserDir() const
-{
-       static char path[256];
-       char* env = getenv("HOME");
-       if(env) {
-               strncpy(path, env, 245);
-               path[245]=0;
-               strcat(path, "/.blender/");
-               return (GHOST_TUns8*) path;
-       } else {
-               return NULL;
-       }
-}
index ee6cbed..6a4ff1b 100644 (file)
@@ -226,20 +226,6 @@ public:
         */
        void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
 
-       /**
-        * Determine the base dir in which shared resources are located. It will first try to use
-        * "unpack and run" path, then look for properly installed path, not including versioning.
-        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
-        */
-       const GHOST_TUns8* getSystemDir() const;
-
-       /**
-        * Determine the base dir in which user configuration is stored, not including versioning.
-        * If needed, it will create the base directory.
-        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
-        */
-       const GHOST_TUns8* getUserDir() const;
-
        /**
         * Atom used for ICCCM, WM-spec and Motif.
         * We only need get this atom at the start, it's relative
index 5ed6043..db8750a 100644 (file)
@@ -124,27 +124,6 @@ class INFO_MT_file(bpy.types.Menu):
         layout.operator("wm.exit_blender", text="Quit", icon='QUIT')
 
 
-class INFO_MT_file_open_recent(bpy.types.Menu):
-    bl_idname = "INFO_MT_file_open_recent"
-    bl_label = "Open Recent..."
-
-    def draw(self, context):
-        import os
-        layout = self.layout
-        layout.operator_context = 'EXEC_AREA'
-
-        filepath = os.path.join(bpy.app.home, ".Blog")
-
-        if os.path.isfile(filepath):
-            file = open(filepath, "rU")
-            for line in file:
-                line = line.rstrip()
-                layout.operator("wm.open_mainfile", text=line, icon='FILE_BLEND').filepath = line
-            file.close()
-        else:
-            layout.label(text='No recent files')
-
-
 class INFO_MT_file_import(bpy.types.Menu):
     bl_idname = "INFO_MT_file_import"
     bl_label = "Import"
@@ -374,7 +353,6 @@ class HELP_OT_operator_cheat_sheet(bpy.types.Operator):
 classes = [
     INFO_HT_header,
     INFO_MT_file,
-    INFO_MT_file_open_recent,
     INFO_MT_file_import,
     INFO_MT_file_export,
     INFO_MT_file_external_data,
index bc2de70..1baf2c8 100644 (file)
@@ -59,65 +59,19 @@ char global_messagepath[1024];
 char global_language[32];
 char global_encoding_name[32];
 
-#if defined(__APPLE__)
-void BLF_lang_init(void) /* Apple Only, todo - use BLI_gethome_folder  */
-{
-       char *bundlepath;
-
-       strcpy(global_encoding_name, SYSTEM_ENCODING_DEFAULT);
-
-       /* set messagepath directory */
-#ifndef LOCALEDIR
-#define LOCALEDIR "/usr/share/locale"
-#endif
-
-       strcpy(global_messagepath, ".blender/locale");
-
-       if (!BLI_exist(global_messagepath)) { /* locale not in current dir */
-               BLI_make_file_string("/", global_messagepath, BLI_gethome(), ".blender/locale");
 
-               if (!BLI_exist(global_messagepath)) { /* locale not in home dir */
-                       /* message catalogs are stored inside the application bundle */
-                       bundlepath= BLI_getbundle();
-                       strcpy(global_messagepath, bundlepath);
-                       strcat(global_messagepath, "/Contents/Resources/locale");
-                       if (!BLI_exist(global_messagepath)) { /* locale not in bundle (now that's odd..) */
-                               strcpy(global_messagepath, LOCALEDIR);
-
-                               if (!BLI_exist(global_messagepath)) { /* locale not in LOCALEDIR */
-                                       strcpy(global_messagepath, "message"); /* old compatibility as last */
-                               }
-                       }
-               }
-       }
-}
-#elif defined(_WIN32)
-void BLF_lang_init(void) /* Windows Only, todo - use BLI_gethome_folder  */
+void BLF_lang_init(void)
 {
-       strcpy(global_encoding_name, SYSTEM_ENCODING_DEFAULT);
+       char *messagepath= BLI_get_folder(BLENDER_DATAFILES, "locale");
        
-       strcpy(global_messagepath, ".blender/locale");
-
-       if (!BLI_exist(global_messagepath)) { /* locale not in current dir */
-               BLI_make_file_string("/", global_messagepath, BLI_gethome(), ".blender/locale");
-
-               if (!BLI_exist(global_messagepath)) { /* locale not in home dir */
-                       BLI_make_file_string("/", global_messagepath, BLI_gethome(), "/locale");
-               }
-       }
-}
-#else
-void BLF_lang_init(void)  /* not win or mac */
-{
-       char *messagepath= BLI_gethome_folder("locale", BLI_GETHOME_ALL);
+       BLI_strncpy(global_encoding_name, SYSTEM_ENCODING_DEFAULT, sizeof(global_encoding_name));
        
-       if(messagepath)
-               strncpy(global_messagepath, messagepath, sizeof(global_messagepath));
+       if (messagepath)
+               BLI_strncpy(global_messagepath, messagepath, sizeof(global_messagepath));
        else
                global_messagepath[0]= '\0';
-
 }
-#endif
+
 
 void BLF_lang_set(const char *str)
 {
index 6198520..a670565 100644 (file)
@@ -67,6 +67,7 @@ if env['BF_NO_ELBEEM']:
 
 if env['WITH_BF_LCMS']:
        defs.append('WITH_LCMS')
+       incs += ' ' + env['BF_LCMS_INC']
 
 if env['WITH_BF_LZO']:
        incs += ' #/extern/lzo/minilzo'
index 9a97d97..57e72fc 100644 (file)
@@ -55,6 +55,7 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_dynstr.h"
+#include "BLI_path_util.h"
 
 #include "IMB_imbuf.h"
 
@@ -368,7 +369,7 @@ int BKE_read_file(bContext *C, char *dir, void *unused, ReportList *reports)
        BlendFileData *bfd;
        int retval= 1;
 
-       if(strstr(dir, ".B25.blend")==0) /* dont print user-pref loading */
+       if(strstr(dir, BLENDER_STARTUP_FILE)==0) /* dont print user-pref loading */
                printf("read blend: %s\n", dir);
 
        bfd= BLO_read_from_file(dir, reports);
index fb30e99..24b74b4 100644 (file)
@@ -45,6 +45,58 @@ char *BLI_gethome_folder(char *folder_name, int flag);
 #define BLI_GETHOME_USER               1<<3 /* home folder ~/.blender */
 #define BLI_GETHOME_ALL                        (BLI_GETHOME_SYSTEM|BLI_GETHOME_LOCAL|BLI_GETHOME_USER)
 
+
+#ifdef __APPLE__
+typedef enum {
+       BasePath_Temporary = 1,
+       BasePath_BlenderShared,
+       BasePath_BlenderUser,
+       BasePath_ApplicationBundle
+} basePathesTypes;
+
+/**
+ * Gets the base path. The path may not exist.
+ * Note that return string must be copied as its persistence is not guaranteed
+ *
+ * @return base path of pathType
+ */
+const char* BLI_osx_getBasePath(basePathesTypes pathType);
+#endif
+
+char *BLI_get_folder(int folder_id, char *subfolder);
+char *BLI_get_folder_create(int folder_id, char *subfolder);
+
+/* folder_id */
+
+/* general, will find baserd on user/local/system priority */
+#define BLENDER_CONFIG                         1
+#define BLENDER_DATAFILES                      2
+#define BLENDER_SCRIPTS                                3
+#define BLENDER_PLUGINS                                4
+#define BLENDER_PYTHON                         5
+
+/* user-specific */
+#define BLENDER_USER_CONFIG                    31
+#define BLENDER_USER_DATAFILES         32
+#define BLENDER_USER_SCRIPTS           33
+#define BLENDER_USER_PLUGINS           34
+
+/* system */
+#define BLENDER_SYSTEM_CONFIG          51      /* optional */
+#define BLENDER_SYSTEM_DATAFILES       52
+#define BLENDER_SYSTEM_SCRIPTS         53
+#define BLENDER_SYSTEM_PLUGINS         54
+#define BLENDER_SYSTEM_PYTHON          54
+
+#define BLENDER_TEMP                           80
+
+#define BLENDER_USERFOLDER(id) (id >= BLENDER_USER_CONFIG && id <= BLENDER_USER_PLUGINS)
+
+#define BLENDER_STARTUP_FILE   "startup.blend"
+#define BLENDER_BOOKMARK_FILE  "bookmarks.txt"
+#define BLENDER_HISTORY_FILE   "recent-files.txt"
+
+
 void BLI_setenv(const char *env, const char *val);
 void BLI_setenv_if_new(const char *env, const char* val);
 
@@ -135,15 +187,6 @@ char *get_install_dir(void);
 void BLI_where_is_temp(char *fullname, int usertemp);
 
 
-       /**
-        * determines the full path to the application bundle on OS X
-        *
-        * @return path to application bundle
-        */
-#ifdef __APPLE__
-char* BLI_getbundle(void);
-#endif
-
 #ifdef WITH_ICONV
 void BLI_string_to_utf8(char *original, char *utf_8, const char *code);
 #endif
index 628c2dc..185e1c9 100644 (file)
@@ -33,6 +33,10 @@ SET(INC
        ${ZLIB_INC}
 )
 
+IF(APPLE)
+       SET(SRC ${SRC} intern/path_util_cocoa.m)
+ENDIF(APPLE)
+
 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
 SET(INC
        ${INC}
index 2330beb..b9ac687 100644 (file)
@@ -48,8 +48,6 @@
 #include "BLI_storage.h"
 #include "BLI_bfile.h"
 
-#include "GHOST_C-api.h"
-
 /* Internal bfile classification flags */
 #define BCF_OPEN     (0)
 #define BCF_FOPEN    (1<<0)
 
 
 /* Declaration of internal functions */
-static void chomp(char* line);
-static void expand_envvars(char* src, char* dst);
 static void fill_paths(BFILE *bfile, const char *path, const char *relpath);
-static void init_vars_from_file(const char* path);
 static void free_paths(BFILE* bfile);
-static void setup_temp();
 
 
 /*** Exported functions ***/
@@ -274,204 +268,8 @@ void BLI_bfile_set_error(BFILE *bfile, int error) {
 }
 
 
-void BLI_bfile_init_vars() {
-       char file[MAXPATHLEN];
-       char temp[MAXPATHLEN];
-       extern char bprogname[];
-       FILE* fp;
-
-       /* This one is unconditional */
-       sprintf(temp, "%d", BLENDER_VERSION);
-       BLI_setenv("BLENDER_VERSION", temp);
-
-       /* Is this unpack&run? */
-       sprintf(temp, "%s/%d/environment", dirname(bprogname), BLENDER_VERSION);
-       if (BLI_exist(temp)) {
-               BLI_setenv_if_new("BLENDER_SHARE", dirname(bprogname));
-       } else {
-               BLI_setenv_if_new("BLENDER_SHARE", (const char*)GHOST_getSystemDir());
-       }
-
-       strcpy(file, (const char*)GHOST_getUserDir());
-       BLI_add_slash(file);
-       strcat(file, LAST_SESSION_FILE);
-       fp = fopen(file, "r");
-       /* 1st line, read previous version */
-       if (fp && (fscanf(fp, "%3c\n", temp) == 1)) {
-               temp[3] = '\0';
-               BLI_setenv("BLENDER_VERSION_PREV", temp);
-               /* 2nd line, read previous session path if needed */
-               if (!getenv("BLENDER_TEMP")) {
-                       if ((fgets(temp, MAXPATHLEN, fp) != NULL)) {
-                               /* Clean any \n */
-                               chomp(temp);
-                               /* Check the dir is still there or generate new one */
-                               if (!BLI_exist(temp)) {
-                                       setup_temp();
-                               }
-                       } else {
-                               /* We have to generate it for sure */
-                               setup_temp();
-                       }
-               }
-       } else {
-               /* Probably new user, or only <=249 before */
-               BLI_setenv("BLENDER_VERSION_PREV", "0");
-               setup_temp();
-       }
-
-       if (fp) {
-               fclose(fp);
-       }
-
-       /* Loaded session info (or created), so time to store current data */
-       // TODO use own fuctions to get safe saving
-       fp = fopen(file, "w");
-       if (fp) {
-               fprintf(fp, "%s\n%s\n", getenv("BLENDER_VERSION"), getenv("BLENDER_TEMP"));
-               fclose(fp);
-       }
-
-       /* Load vars from user and system files */
-       strcpy(file, (const char *)GHOST_getUserDir());
-       BLI_add_slash(file);
-       strcat(file, ENVIRONMENT_FILE);
-       init_vars_from_file(file);
-       sprintf(temp, "/%d/environment", BLENDER_VERSION);
-       BLI_make_file_string("/", file, getenv("BLENDER_SHARE"), temp);
-       init_vars_from_file(file);
-}
-
-
 /*** Internal functions ***/
 
-/**
- Eliminate trailing EOL by writing a \0 over it.
- Name taken from Perl.
- */
-static void chomp(char* line) {
-       int len = strlen(line);
-#ifndef WIN32
-       if (line[len - 1] == '\n') {
-               line[len - 1] = '\0';
-       }
-#else
-       if ((line[len - 2] == '\r' ) && ((line[len - 1] == '\n'))) {
-               line[len - 2] = '\0';
-       }
-#endif /* WIN32 */
-}
-
-
-/**
- Parse a file with lines like FOO=bar (comment lines have # as first
- character) assigning to envvar FOO the value bar if FOO does not
- exist yet.
- Any white space before FOO, around the = or trailing will be used,
- so beware.
- */
-#define MAX_LINE 4096
-#define ENV_VAR 256
-#define VAR_LEN 8192
-static void init_vars_from_file(const char* path) {
-       char line[MAX_LINE];
-       char name[ENV_VAR];
-       FILE *fp;
-       char* separator;
-       char expanded[VAR_LEN];
-
-       fp = fopen(path, "r");
-       if (!fp) return;
-
-       while (fgets(line, MAX_LINE, fp) != NULL) {
-               /* Ignore comment lines */
-               if (line[0] == '#')
-                       continue;
-
-               /* Split into envvar name and contents */
-               separator = strchr(line, '=');
-               if (separator && ((separator - line) < ENV_VAR)) {
-                       /* First remove EOL */
-                       chomp(line);
-                       strncpy(name, line, separator - line);
-                       name[separator - line] = '\0';
-                       expand_envvars(separator + 1, expanded);
-                       BLI_setenv_if_new(name, expanded);
-               }
-       }
-       fclose(fp);
-}
-
-
-/**
- Look for ${} (or %%) env vars in src and expand if the var
- exists (even if empty value). If not exist, the name is left as is.
- The process is done all over src, and nested ${${}} is not supported.
- src must be \0 terminated, and dst must be big enough.
-*/
-#ifndef WIN32
- #define ENVVAR_PREFFIX "${"
- #define ENVVAR_P_SIZE 2
- #define ENVVAR_SUFFIX "}"
- #define ENVVAR_S_SIZE 1
-#else
- #define ENVVAR_PREFFIX "%"
- #define ENVVAR_P_SIZE 1
- #define ENVVAR_SUFFIX "%"
- #define ENVVAR_S_SIZE 1
-#endif /* WIN32 */
-static void expand_envvars(char* src, char* dst) {
-       char* hit1;
-       char* hit2;
-       char name[ENV_VAR];
-       char* value;
-       int prevlen;
-       int done = 0;
-       char* source = src;
-
-       dst[0] = '\0';
-       while (!done) {
-               hit1 = strstr(source, ENVVAR_PREFFIX);
-               if (hit1) {
-                       hit2 = strstr(hit1 + ENVVAR_P_SIZE, ENVVAR_SUFFIX);
-                       if (hit2) {
-                               /* "Copy" the leading part, if any */
-                               if (hit1 != source) {
-                                       prevlen = strlen(dst);
-                                       strncat(dst, source, hit1 - source);
-                                       dst[prevlen + (hit1 - source)] = '\0';
-                               }
-                               /* Figure the name of the env var we just found  */
-                               strncpy(name, hit1 + ENVVAR_P_SIZE,
-                                               hit2 - (hit1 + ENVVAR_P_SIZE));
-                               name[hit2 - (hit1 + ENVVAR_P_SIZE)] = '\0';
-                               /* See if we can get something with that name */
-                               value = getenv(name);
-                               if (value) {
-                                       /* Push the var value */
-                                       strcat(dst, value);
-                               } else {
-                                       /* Leave the var name, so it is clear that it failed */
-                                       strcat(dst, ENVVAR_PREFFIX);
-                                       strcat(dst, name);
-                                       strcat(dst, ENVVAR_SUFFIX);
-                               }
-                               /* Continue after closing mark, like a new string */
-                               source = hit2 + ENVVAR_S_SIZE;
-                       } else {
-                               /* Non terminated var so "copy as is" and finish */
-                               strcat(dst, source);
-                               done = 1;
-                       }
-               } else {
-                       /* "Copy" whatever is left */
-                       strcat(dst, source);
-                       done = 1;
-               }
-       }
-}
-
-
 /**
  Return a full path if the filename exists when combined
  with any item from pathlist. Or NULL otherwise.
@@ -572,24 +370,3 @@ static void free_paths(BFILE* bfile) {
                MEM_freeN(bfile->tpath);
        }
 }
-
-
-/**
- Create a temp directory in safe and multiuser way.
- */
-static void setup_temp() {
-       char template[MAXPATHLEN];
-       char* tempdir;
-
-       if (getenv("TMPDIR")) {
-               sprintf(template, "%s/blender-XXXXXX", getenv("TMPDIR"));
-       } else {
-               sprintf(template, "/tmp/blender-XXXXXX");
-// MacOSX NSTemporaryDirectory and WIN32 ???
-// https://bugs.launchpad.net/cuneiform-linux/+bug/267136
-// https://svn.r-project.org/R/trunk/src/main/mkdtemp.c
-       }
-       tempdir = mkdtemp(template);
-       BLI_setenv("BLENDER_TEMP", tempdir);
-}
-
index 2d5234a..b43da1c 100644 (file)
@@ -44,6 +44,7 @@
 #include "BLI_storage_types.h"
 
 #include "BKE_utildefines.h"
+#include "BKE_blender.h"       // BLENDER_VERSION
 
 
 
 
 #else /* non windows */
 
-#ifdef __APPLE__
-#include <sys/param.h>
-#include <CoreFoundation/CoreFoundation.h>
-#endif
-
 #ifdef __linux__
 #include "binreloc.h"
 #endif
@@ -759,7 +755,11 @@ char *BLI_gethome(void) {
                }
 
                                
-               /* add user profile support for WIN 2K / NT */
+               /* add user profile support for WIN 2K / NT.
+                * This is %APPDATA%, which translates to either
+                * %USERPROFILE%\Application Data or since Vista
+                * to %USERPROFILE%\AppData\Roaming
+                */
                hResult = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdatapath);
                
                if (hResult == S_OK)
@@ -794,7 +794,7 @@ char *BLI_gethome(void) {
 /* this function returns the path to a blender folder, if it exists
  * utility functions for BLI_gethome_folder */
 
-/* #define PATH_DEBUG */ /* for testing paths that are checked */
+// #define PATH_DEBUG /* for testing paths that are checked */
 
 static int test_data_path(char *targetpath, char *path_base, char *path_sep, char *folder_name)
 {
@@ -905,6 +905,303 @@ char *BLI_gethome_folder(char *folder_name, int flag)
        return NULL;
 }
 
+
+/* NEW stuff, to be cleaned up when fully migrated */
+/* ************************************************************* */
+/* ************************************************************* */
+
+#define PATH_DEBUG2
+
+static char *blender_version_decimal(void)
+{
+       static char version_str[5];
+       sprintf(version_str, "%d.%02d", BLENDER_VERSION/100, BLENDER_VERSION%100);
+       return version_str;
+}
+
+static int test_path(char *targetpath, char *path_base, char *path_sep, char *folder_name)
+{
+       char tmppath[FILE_MAX];
+       
+       if(path_sep)    BLI_join_dirfile(tmppath, path_base, path_sep);
+       else                    BLI_strncpy(tmppath, path_base, sizeof(tmppath));
+       
+       BLI_make_file_string("/", targetpath, tmppath, folder_name);
+       
+       if (BLI_exists(targetpath)) {
+#ifdef PATH_DEBUG2
+               printf("\tpath found: %s\n", targetpath);
+#endif
+               return 1;
+       }
+       else {
+#ifdef PATH_DEBUG2
+               printf("\tpath missing: %s\n", targetpath);
+#endif
+               //targetpath[0] = '\0';
+               return 0;
+       }
+}
+
+static int test_env_path(char *path, char *envvar)
+{
+       char *env = envvar?getenv(envvar):NULL;
+       if (!env) return 0;
+       
+       if (BLI_exists(env)) {
+               BLI_strncpy(path, env, FILE_MAX);
+               return 1;
+       } else {
+               path[0] = '\0';
+               return 0;
+       }
+}
+
+static int get_path_local(char *targetpath, char *folder_name)
+{
+       extern char bprogname[]; /* argv[0] from creator.c */
+       char bprogdir[FILE_MAX];
+       char cwd[FILE_MAX];
+       char *s;
+       int i;
+       
+#ifdef PATH_DEBUG2
+       printf("get_path_local...\n");
+#endif
+       
+       
+       /* use argv[0] (bprogname) to get the path to the executable */
+       s = BLI_last_slash(bprogname);
+       i = s - bprogname + 1;
+       BLI_strncpy(bprogdir, bprogname, i);
+       
+       /* try EXECUTABLE_DIR/folder_name */
+       if(test_path(targetpath, bprogdir, "", folder_name))
+               return 1;
+       
+       /* try CWD/release/folder_name */
+       if(test_path(targetpath, BLI_getwdN(cwd), "release", folder_name))
+               return 1;
+       
+       /* try EXECUTABLE_DIR/release/folder_name */
+       if(test_path(targetpath, bprogdir, "release", folder_name))
+               return 1;
+       
+       /* try EXECUTABLE_DIR/2.5/folder_name - new default directory for local blender installed files */
+       if(test_path(targetpath, bprogdir, blender_version_decimal(), folder_name))
+               return 1;
+
+       /* try ./.blender/folder_name -- DEPRECATED, need to update build systems */
+       if(test_path(targetpath, bprogdir, ".blender", folder_name))
+               return 1;
+
+       return 0;
+}
+
+#ifdef WIN32
+static int get_knownfolder_path(char *path, int folder) 
+{
+       static char knownpath[MAXPATHLEN];
+       HRESULT hResult = SHGetFolderPath(NULL, folder, NULL, SHGFP_TYPE_CURRENT, knownpath);
+       
+       if (hResult == S_OK)
+       {
+               if (BLI_exists(knownpath)) { /* from fop, also below... */
+                       BLI_strncpy(path, knownpath, FILE_MAX);
+                       return 1;
+               }
+       }
+       return 0;
+}
+#endif
+
+static int get_path_user(char *targetpath, char *folder_name, char *envvar)
+{
+       char user_path[FILE_MAX];
+#if defined(WIN32)
+       char appdata[FILE_MAX];
+#endif
+
+       user_path[0] = '\0';
+
+       if (test_env_path(targetpath, envvar))
+               return 1;
+
+#if defined(__APPLE__)
+       BLI_snprintf(user_path, FILE_MAX, "%s/%s", BLI_osx_getBasePath(BasePath_BlenderUser), blender_version_decimal());
+#elif defined(WIN32)
+       if (get_knownfolder_path(appdata, CSIDL_APPDATA)) {     
+               BLI_snprintf(user_path, FILE_MAX, "%s\\Blender Foundation\\Blender\\%s", appdata, blender_version_decimal());
+       }
+#else /* UNIX */
+       /* XXX example below - replace with OS API */
+       BLI_snprintf(user_path, FILE_MAX, "%s/.blender/%s", BLI_gethome(), blender_version_decimal());
+#endif
+
+       if(!user_path[0])
+               return 0;
+       
+#ifdef PATH_DEBUG2
+       printf("get_path_user: %s\n", user_path);
+#endif
+       
+       /* try $HOME/folder_name */
+       return test_path(targetpath, user_path, NULL, folder_name);
+}
+
+static int get_path_system(char *targetpath, char *folder_name, char *envvar)
+{
+       char system_path[FILE_MAX];
+#if defined(WIN32)
+       char appdata[FILE_MAX];
+#endif
+
+       if (test_env_path(targetpath, envvar))
+               return 1;
+       
+#if defined(__APPLE__)
+       BLI_snprintf(system_path, FILE_MAX, "%s/%s", BLI_osx_getBasePath(BasePath_ApplicationBundle), blender_version_decimal());
+#elif defined(WIN32)
+       if (get_knownfolder_path(appdata, CSIDL_COMMON_APPDATA)) {      
+               BLI_snprintf(system_path, FILE_MAX, "%s\\Blender Foundation\\Blender\\%s", appdata, blender_version_decimal());
+       }
+#else /* UNIX */
+       /* XXX example below - replace with OS API */
+       BLI_snprintf(system_path, FILE_MAX, "/usr/share/blender/%s", blender_version_decimal());
+#endif
+       
+       if(!system_path[0])
+               return 0;
+       
+#ifdef PATH_DEBUG2
+       printf("get_path_system: %s\n", system_path);
+#endif
+       
+       /* try $BLENDERPATH/folder_name */
+       return test_path(targetpath, system_path, NULL, folder_name);
+}
+
+/* get a folder out of the 'folder_id' presets for paths */
+/* returns the path if found, NULL string if not */
+char *BLI_get_folder(int folder_id, char *subfolder)
+{
+       static char path[FILE_MAX] = "";
+       char search_path[FILE_MAX];
+       
+       switch (folder_id) {
+               case BLENDER_DATAFILES:         /* general case */
+                       BLI_join_dirfile(search_path, "datafiles", subfolder);
+                       if (get_path_user(path, search_path, "BLENDER_USER_DATAFILES")) break;
+                       if (get_path_local(path, search_path)) break;
+                       if (get_path_system(path, search_path, "BLENDER_SYSTEM_DATAFILES")) break;
+                       return NULL;
+                       
+               case BLENDER_USER_DATAFILES:            
+                       BLI_join_dirfile(search_path, "datafiles", subfolder);
+                       if (get_path_user(path, search_path, "BLENDER_USER_DATAFILES")) break;
+                       return NULL;
+                       
+               case BLENDER_SYSTEM_DATAFILES:
+                       BLI_join_dirfile(search_path, "datafiles", subfolder);
+                       if (get_path_system(path, search_path, "BLENDER_SYSTEM_DATAFILES"))     break;
+                       return NULL;
+                       
+               case BLENDER_CONFIG:            /* general case */
+                       BLI_join_dirfile(search_path, "config", subfolder);
+                       if (get_path_user(path, search_path, "BLENDER_USER_CONFIG")) break;
+                       if (get_path_local(path, search_path)) break;
+                       if (get_path_system(path, search_path, "BLENDER_SYSTEM_CONFIG")) break;
+                       return NULL;
+                       
+               case BLENDER_USER_CONFIG:
+                       BLI_join_dirfile(search_path, "config", subfolder);
+                       if (get_path_user(path, search_path, "BLENDER_USER_CONFIG")) break;
+                       return NULL;
+                       
+               case BLENDER_SYSTEM_CONFIG:
+                       BLI_join_dirfile(search_path, "config", subfolder);
+                       if (get_path_system(path, search_path, "BLENDER_SYSTEM_CONFIG")) break;
+                       return NULL;
+                       
+               case BLENDER_SCRIPTS:           /* general case */
+                       BLI_join_dirfile(search_path, "scripts", subfolder);
+                       if (get_path_user(path, search_path, "BLENDER_USER_SCRIPTS")) break;            
+                       if (get_path_local(path, search_path)) break;
+                       if (get_path_system(path, search_path, "BLENDER_SYSTEM_SCRIPTS")) break;
+                       return NULL;
+                       
+               case BLENDER_USER_SCRIPTS:
+                       BLI_join_dirfile(search_path, "scripts", subfolder);
+                       if (get_path_user(path, search_path, "BLENDER_USER_SCRIPTS")) break;
+                       return NULL;
+                       
+               case BLENDER_SYSTEM_SCRIPTS:
+                       BLI_join_dirfile(search_path, "scripts", subfolder);
+                       if (get_path_system(path, search_path, "BLENDER_SYSTEM_SCRIPTS")) break;
+                       return NULL;
+                       
+               case BLENDER_PYTHON:            /* general case */
+                       BLI_join_dirfile(search_path, "python", subfolder);
+                       if (get_path_local(path, search_path)) break;
+                       if (get_path_system(path, search_path, "BLENDER_SYSTEM_PYTHON")) break;
+                       return NULL;
+                       
+               case BLENDER_SYSTEM_PYTHON:
+                       BLI_join_dirfile(search_path, "scripts", subfolder);
+                       
+                       if (get_path_system(path, search_path, "BLENDER_SYSTEM_PYTHON")) break;
+                       return NULL;
+       }
+       
+       return path;
+}
+
+static char *BLI_get_user_folder_notest(int folder_id, char *subfolder)
+{
+       static char path[FILE_MAX] = "";
+       char search_path[FILE_MAX];
+
+       switch (folder_id) {
+               case BLENDER_USER_DATAFILES:
+                       BLI_join_dirfile(search_path, "datafiles", subfolder);
+                       get_path_user(path, search_path, "BLENDER_USER_DATAFILES");
+                       break;
+               case BLENDER_USER_CONFIG:
+                       BLI_join_dirfile(search_path, "config", subfolder);
+                       get_path_user(path, search_path, "BLENDER_USER_CONFIG");
+                       break;
+       }
+       if ('\0' == path[0]) {
+               return NULL;
+       }
+       return path;
+}
+
+char *BLI_get_folder_create(int folder_id, char *subfolder)
+{
+       char *path;
+
+       /* only for user folders */
+       if (!ELEM(folder_id, BLENDER_USER_DATAFILES, BLENDER_USER_CONFIG))
+               return NULL;
+       
+       path = BLI_get_folder(folder_id, subfolder);
+       
+       if (!path) {
+               path = BLI_get_user_folder_notest(folder_id, subfolder);
+               if (path) BLI_recurdir_fileops(path);
+       }
+       
+       return path;
+}
+
+
+/* End new stuff */
+/* ************************************************************* */
+/* ************************************************************* */
+
+
+
 #ifdef PATH_DEBUG
 #undef PATH_DEBUG
 #endif
@@ -1158,6 +1455,9 @@ void BLI_join_dirfile(char *string, const char *dir, const char *file)
        
        if(string != dir) /* compare pointers */
                BLI_strncpy(string, dir, FILE_MAX);
+
+       if (!file)
+               return;
        
        sl_dir= BLI_add_slash(string);
        
@@ -1465,26 +1765,6 @@ char *get_install_dir(void) {
        }
 }
 
-/* 
- * returns absolute path to the app bundle
- * only useful on OS X 
- */
-#ifdef __APPLE__
-char* BLI_getbundle(void) {
-       CFURLRef bundleURL;
-       CFStringRef pathStr;
-       static char path[MAXPATHLEN];
-       CFBundleRef mainBundle = CFBundleGetMainBundle();
-
-       bundleURL = CFBundleCopyBundleURL(mainBundle);
-       pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
-       CFStringGetCString(pathStr, path, MAXPATHLEN, kCFStringEncodingASCII);
-       CFRelease(pathStr);
-       CFRelease(bundleURL);
-       return path;
-}
-#endif
-
 #ifdef WITH_ICONV
 
 void BLI_string_to_utf8(char *original, char *utf_8, const char *code)
diff --git a/source/blender/blenlib/intern/path_util_cocoa.mm b/source/blender/blenlib/intern/path_util_cocoa.mm
new file mode 100644 (file)
index 0000000..00593af
--- /dev/null
@@ -0,0 +1,96 @@
+/* path_util_cocoa.m\r
+ *\r
+ * Functions specific to osx that use API available only in Objective-C\r
+ *\r
+ *\r
+ * $Id: util_cocoa.m 25007 2009-11-29 19:16:52Z kazanbas $\r
+ *\r
+ * ***** BEGIN GPL LICENSE BLOCK *****\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software Foundation,\r
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\r
+ *\r
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.\r
+ * All rights reserved.\r
+ *\r
+ * The Original Code is: all of this file.\r
+ *\r
+ * Contributor(s): Damien Plisson 2010\r
+ *\r
+ * ***** END GPL LICENSE BLOCK *****\r
+ * \r
+ */\r
+\r
+\r
+#import <Cocoa/Cocoa.h>\r
+\r
+#include <string.h>\r
+\r
+#include "BLI_path_util.h"\r
+\r
+\r
+\r
+/**\r
+ * Gets the ~/Library/Application Data/Blender folder\r
+ */\r
+const char* BLI_osx_getBasePath(basePathesTypes pathType)\r
+{\r
+       static char tempPath[512] = "";\r
+       \r
+       NSAutoreleasePool *pool;\r
+       NSString *basePath;\r
+       NSArray *paths;\r
+       \r
+       pool = [[NSAutoreleasePool alloc] init];\r
+       \r
+       switch (pathType) {\r
+                       /* Standard pathes */\r
+               case BasePath_Temporary:\r
+                       strcpy(tempPath, [NSTemporaryDirectory() cStringUsingEncoding:NSASCIIStringEncoding]);\r
+                       [pool drain];\r
+                       return tempPath;\r
+                       break;\r
+                       \r
+                       /* Blender specific pathes */\r
+               case BasePath_BlenderShared:\r
+                       paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSLocalDomainMask, YES);\r
+                       if ([paths count] > 0)\r
+                               basePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Blender"];\r
+                       else { //Error\r
+                               basePath = @"";\r
+                       }\r
+                       break;\r
+               case BasePath_BlenderUser:\r
+                       paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);\r
+                       if ([paths count] > 0)\r
+                               basePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Blender"];\r
+                       else { //Error\r
+                               basePath = @"";\r
+                       }\r
+                       break;\r
+               case BasePath_ApplicationBundle:\r
+                       basePath = [[NSBundle mainBundle] bundlePath];\r
+                       break;\r
+\r
+               default:\r
+                       tempPath[0] = 0;\r
+                       [pool drain];\r
+                       return tempPath;\r
+       }\r
+               \r
+       strcpy(tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);\r
+       \r
+       [pool drain];\r
+       return tempPath;\r
+}
\ No newline at end of file
index 497c2d3..82d46a8 100644 (file)
@@ -2502,7 +2502,7 @@ int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *report
                        makeFilesAbsolute(G.sce, NULL);
        }
 
-       BLI_make_file_string(G.sce, userfilename, BLI_gethome(), ".B25.blend");
+       BLI_make_file_string(G.sce, userfilename, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
        write_user_block= BLI_streq(dir, userfilename);
 
        if(write_flags & G_FILE_RELATIVE_REMAP)
index 622b9dd..499fe3b 100644 (file)
@@ -457,25 +457,20 @@ static void init_internal_icons()
        ImBuf *bbuf= NULL;
        int x, y, icontype;
        char iconfilestr[FILE_MAXDIR+FILE_MAXFILE];
-       char filenamestr[FILE_MAXFILE+16];      // 16 == strlen(".blender/icons/")+1
        
        if ((btheme!=NULL) && (strlen(btheme->tui.iconfile) > 0)) {
-       
-#ifdef WIN32
-               sprintf(filenamestr, "icons/%s", btheme->tui.iconfile);
-#else
-               sprintf(filenamestr, ".blender/icons/%s", btheme->tui.iconfile);
-#endif
-               
-               BLI_make_file_string("/", iconfilestr, BLI_gethome(), filenamestr);
-               
-               if (BLI_exists(iconfilestr)) {
-                       bbuf = IMB_loadiffname(iconfilestr, IB_rect);
-                       if(bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H) {
-                               if (G.f & G_DEBUG)
-                                       printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr);
-                               IMB_freeImBuf(bbuf);
-                               bbuf= NULL;
+               char *datadir= BLI_get_folder(BLENDER_DATAFILES, NULL);
+               if (datadir) {
+                       BLI_make_file_string("/", iconfilestr, datadir, btheme->tui.iconfile);
+                       
+                       if (BLI_exists(iconfilestr)) {
+                               bbuf = IMB_loadiffname(iconfilestr, IB_rect);
+                               if(bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H) {
+                                       if (G.f & G_DEBUG)
+                                               printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr);
+                                       IMB_freeImBuf(bbuf);
+                                       bbuf= NULL;
+                               }
                        }
                }
        }
@@ -555,14 +550,14 @@ static void init_iconfile_list(struct ListBase *list)
        char icondirstr[FILE_MAX];
        char iconfilestr[FILE_MAX+16]; /* allow 256 chars for file+dir */
        char olddir[FILE_MAX];
-       
+       char *datadir= NULL;
+
        list->first = list->last = NULL;
+       datadir = BLI_get_folder(BLENDER_DATAFILES, NULL);
 
-#ifdef WIN32
-       BLI_make_file_string("/", icondirstr, BLI_gethome(), "icons");
-#else
-       BLI_make_file_string("/", icondirstr, BLI_gethome(), ".blender/icons");
-#endif
+       if (!datadir) return;
+
+       BLI_make_file_string("/", icondirstr, datadir, "");
        
        if(BLI_exists(icondirstr)==0)
                return;
index 7c2a2f4..55a44b3 100644 (file)
@@ -391,7 +391,7 @@ static int bookmark_add_exec(bContext *C, wmOperator *op)
                char name[FILE_MAX];
        
                fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, 0, 1);
-               BLI_make_file_string("/", name, BLI_gethome(), ".Bfs");
+               BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
                fsmenu_write_file(fsmenu, name);
        }
 
@@ -423,7 +423,7 @@ static int bookmark_delete_exec(bContext *C, wmOperator *op)
                        char name[FILE_MAX];
                        
                        fsmenu_remove_entry(fsmenu, FS_CATEGORY_BOOKMARKS, index);
-                       BLI_make_file_string("/", name, BLI_gethome(), ".Bfs");
+                       BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
                        fsmenu_write_file(fsmenu, name);
                        ED_area_tag_redraw(sa);
                }
@@ -619,7 +619,7 @@ int file_exec(bContext *C, wmOperator *exec_op)
                folderlist_free(sfile->folders_next);
 
                fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir,0, 1);
-               BLI_make_file_string(G.sce, filepath, BLI_gethome(), ".Bfs");
+               BLI_make_file_string(G.sce, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
                fsmenu_write_file(fsmenu_get(), filepath);
                WM_event_fileselect_event(C, op, EVT_FILESELECT_EXEC);
 
index 08a6b5a..a7d6288 100644 (file)
@@ -248,7 +248,37 @@ void fsmenu_write_file(struct FSMenu* fsmenu, const char *filename)
        fclose(fp);
 }
 
-void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename)
+void fsmenu_read_bookmarks(struct FSMenu* fsmenu, const char *filename)
+{
+       char line[256];
+       FSMenuCategory category = FS_CATEGORY_BOOKMARKS;
+       FILE *fp;
+
+       fp = fopen(filename, "r");
+       if (!fp) return;
+
+       while ( fgets ( line, 256, fp ) != NULL ) /* read a line */
+       {
+               if (strncmp(line, "[Bookmarks]", 11)==0){
+                       category = FS_CATEGORY_BOOKMARKS;
+               } else if (strncmp(line, "[Recent]", 8)==0){
+                       category = FS_CATEGORY_RECENT;
+               } else {
+                       int len = strlen(line);
+                       if (len>0) {
+                               if (line[len-1] == '\n') {
+                                       line[len-1] = '\0';
+                               }
+                               if (BLI_exist(line)) {
+                                       fsmenu_insert_entry(fsmenu, category, line, 0, 1);
+                               }
+                       }
+               }
+       }
+       fclose(fp);
+}
+
+void fsmenu_read_system(struct FSMenu* fsmenu)
 {
        char line[256];
        FSMenuCategory category = FS_CATEGORY_BOOKMARKS;
@@ -482,31 +512,9 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename)
        }
 #endif
 #endif
-
-       fp = fopen(filename, "r");
-       if (!fp) return;
-
-       while ( fgets ( line, 256, fp ) != NULL ) /* read a line */
-       {
-               if (strncmp(line, "[Bookmarks]", 11)==0){
-                       category = FS_CATEGORY_BOOKMARKS;
-               } else if (strncmp(line, "[Recent]", 8)==0){
-                       category = FS_CATEGORY_RECENT;
-               } else {
-                       int len = strlen(line);
-                       if (len>0) {
-                               if (line[len-1] == '\n') {
-                                       line[len-1] = '\0';
-                               }
-                               if (BLI_exist(line)) {
-                                       fsmenu_insert_entry(fsmenu, category, line, 0, 1);
-                               }
-                       }
-               }
-       }
-       fclose(fp);
 }
 
+
 static void fsmenu_free_category(struct FSMenu* fsmenu, FSMenuCategory category)
 {
        FSMenuEntry *fsme= fsmenu_get_category(fsmenu, category);
index 8304b10..dcf8d3e 100644 (file)
@@ -68,7 +68,10 @@ void fsmenu_remove_entry             (struct FSMenu* fsmenu, FSMenuCategory category, int i
 void   fsmenu_write_file               (struct FSMenu* fsmenu, const char *filename);
        
        /** reads the 'bookmarks' from the specified file */
-void   fsmenu_read_file                (struct FSMenu* fsmenu, const char *filename);
+void   fsmenu_read_bookmarks   (struct FSMenu* fsmenu, const char *filename);
+
+       /** adds system specific directories */
+void   fsmenu_read_system      (struct FSMenu* fsmenu);
 
        /** Free's all the memory associated with the fsmenu */
 void   fsmenu_free                             (struct FSMenu* fsmenu);
index 300a728..261b705 100644 (file)
@@ -591,9 +591,16 @@ void ED_spacetype_file(void)
 
 void ED_file_init(void)
 {
-       char name[FILE_MAX];
-       BLI_make_file_string("/", name, BLI_gethome(), ".Bfs");
-       fsmenu_read_file(fsmenu_get(), name);
+       char *cfgdir = BLI_get_folder(BLENDER_CONFIG, NULL);
+       
+       fsmenu_read_system(fsmenu_get());
+
+       if (cfgdir) {
+               char name[FILE_MAX];
+               BLI_make_file_string("/", name, cfgdir, BLENDER_BOOKMARK_FILE);
+               fsmenu_read_bookmarks(fsmenu_get(), name);
+       }
+       
        filelist_init_icons();
        IMB_thumb_makedirs();
 }
index b38e147..4e1918b 100644 (file)
@@ -11,6 +11,7 @@ defs = []
 
 if env['WITH_BF_LCMS']:
        defs.append('WITH_LCMS')
+       incs += ' ' + env['BF_LCMS_INC']
 if env['WITH_BF_OPENEXR']:
        defs.append('WITH_OPENEXR')
 if env['WITH_BF_TIFF']:
index 0d9f1c9..0f483f4 100644 (file)
@@ -38,6 +38,7 @@
 
 #include "BKE_context.h"
 #include "BKE_colortools.h"
+#include "BKE_global.h"
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
 
@@ -49,7 +50,7 @@
 #include "WM_types.h"
 
 #include "UI_resources.h"
-
+#include "UI_interface.h"
 
 #include "info_intern.h"       // own include
 
@@ -179,6 +180,31 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn)
        
 }
 
+static void recent_files_menu(const bContext *C, Menu *menu)
+{
+       struct RecentFile *recent;
+       uiLayout *layout= menu->layout;
+       uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
+       if (G.recent_files.first) {
+               for(recent = G.recent_files.first; (recent); recent = recent->next) {
+                       uiItemStringO(layout, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
+               }
+       } else {
+               uiItemL(layout, "No Recent Files", 0);
+       }
+}
+
+void recent_files_menu_register()
+{
+       MenuType *mt;
+
+       mt= MEM_callocN(sizeof(MenuType), "spacetype info menu recent files");
+       strcpy(mt->idname, "INFO_MT_file_open_recent");
+       strcpy(mt->label, "Open Recent...");
+       mt->draw= recent_files_menu;
+       WM_menutype_add(mt);
+}
+
 /* only called once, from space/spacetypes.c */
 void ED_spacetype_info(void)
 {
@@ -217,7 +243,8 @@ void ED_spacetype_info(void)
        
        BLI_addhead(&st->regiontypes, art);
        
-       
+       recent_files_menu_register();
+
        BKE_spacetype_register(st);
 }
 
index c4ee90d..bd500ad 100644 (file)
@@ -37,7 +37,8 @@ if env['WITH_BF_QUICKTIME']:
 
 if env['WITH_BF_LCMS']:
        defs.append('WITH_LCMS')
-
+       incs += ' ' + env['BF_LCMS_INC']
+       
 if env['WITH_BF_GAMEENGINE']:
        defs.append('GAMEBLENDER=1')
 
index 8601ad9..b978e46 100644 (file)
@@ -145,7 +145,7 @@ void BPy_init_modules( void )
        PyObject *mod;
 
        /* Needs to be first since this dir is needed for future modules */
-       char *modpath= BLI_gethome_folder("scripts/modules", BLI_GETHOME_ALL);
+       char *modpath= BLI_get_folder(BLENDER_SCRIPTS, "modules");
        if(modpath) {
                // printf("bpy: found module path '%s'.\n", modpath);
                PyObject *sys_path= PySys_GetObject("path"); /* borrow */
index 000d428..6a1495b 100644 (file)
@@ -177,7 +177,7 @@ static PyObject *CreateGlobalDictionary( bContext *C, const char *filename )
 /* must be called before Py_Initialize */
 void BPY_start_python_path(void)
 {
-       char *py_path_bundle= BLI_gethome_folder("python", BLI_GETHOME_ALL);
+       char *py_path_bundle= BLI_get_folder(BLENDER_PYTHON, NULL);
 
        if(py_path_bundle==NULL)
                return;
index 5298711..d926bbf 100644 (file)
 #include "wm_window.h"
 #include "wm_event_system.h"
 
-static void writeBlog(void);
+static void write_history(void);
 
 /* To be able to read files without windows closing, opening, moving 
    we try to prepare for worst case:
@@ -298,7 +298,7 @@ void WM_read_file(bContext *C, char *name, ReportList *reports)
                if (retval!=0) {
                        G.relbase_valid = 1;
                        if(!G.background) /* assume automated tasks with background, dont write recent file list */
-                               writeBlog();
+                               write_history();
                }
 
 // XXX         undo_editmode_clear();
@@ -333,17 +333,23 @@ int WM_read_homefile(bContext *C, wmOperator *op)
 {
        ListBase wmbase;
        char tstr[FILE_MAXDIR+FILE_MAXFILE], scestr[FILE_MAXDIR];
-       char *home= BLI_gethome();
        int from_memory= op?RNA_boolean_get(op->ptr, "factory"):0;
        int success;
-               
-       BLI_clean(home);
        
        free_ttfont(); /* still weird... what does it here? */
                
        G.relbase_valid = 0;
        if (!from_memory) {
-               BLI_make_file_string(G.sce, tstr, home, ".B25.blend");
+               char *cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL);
+               if (cfgdir) {
+                       BLI_make_file_string(G.sce, tstr, cfgdir, BLENDER_STARTUP_FILE);
+               } else {
+                       tstr[0] = '\0';
+                       from_memory = 1;
+                       if (op) {
+                               BKE_report(op->reports, RPT_INFO, "Config directory with startup.blend file found."); 
+                       }
+               }
        }
        strcpy(scestr, G.sce);  /* temporary store */
        
@@ -391,15 +397,19 @@ int WM_read_homefile(bContext *C, wmOperator *op)
 }
 
 
-void read_Blog(void)
+void read_history(void)
 {
        char name[FILE_MAX];
        LinkNode *l, *lines;
        struct RecentFile *recent;
        char *line;
        int num;
+       char *cfgdir = BLI_get_folder(BLENDER_CONFIG, NULL);
+
+       if (!cfgdir) return;
+
+       BLI_make_file_string("/", name, cfgdir, BLENDER_HISTORY_FILE);
 
-       BLI_make_file_string("/", name, BLI_gethome(), ".Blog");
        lines= BLI_read_file_as_lines(name);
 
        G.recent_files.first = G.recent_files.last = NULL;
@@ -428,14 +438,14 @@ void read_Blog(void)
 
 }
 
-static void writeBlog(void)
+static void write_history(void)
 {
        struct RecentFile *recent, *next_recent;
        char name[FILE_MAXDIR+FILE_MAXFILE];
        FILE *fp;
        int i;
 
-       BLI_make_file_string("/", name, BLI_gethome(), ".Blog");
+       BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_HISTORY_FILE);
 
        recent = G.recent_files.first;
        /* refresh .Blog of recent opened files, when current file was changed */
@@ -620,7 +630,7 @@ int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports)
                if(fileflags & G_FILE_AUTOPLAY) G.fileflags |= G_FILE_AUTOPLAY;
                else G.fileflags &= ~G_FILE_AUTOPLAY;
 
-               writeBlog();
+               write_history();
 
                /* run this function after because the file cant be written before the blend is */
                if (ibuf_thumb) {
@@ -652,7 +662,8 @@ int WM_write_homefile(bContext *C, wmOperator *op)
        if(win->screen->full == SCREENTEMP)
                wm_window_close(C, wm, win);
        
-       BLI_make_file_string("/", tstr, BLI_gethome(), ".B25.blend");
+       BLI_make_file_string("/", tstr, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
+       printf("trying to save homefile at %s \n", tstr);
        
        /*  force save as regular blend file */
        fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN);
index 02e645e..acb3f5e 100644 (file)
@@ -163,7 +163,7 @@ void WM_init(bContext *C, int argc, char **argv)
        
        G.ndofdevice = -1;      /* XXX bad initializer, needs set otherwise buttons show! */
        
-       read_Blog();
+       read_history();
        BLI_strncpy(G.lib, G.sce, FILE_MAX);
 
 }
index c633ed8..15a3825 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef WM_FILES_H
 #define WM_FILES_H
 
-extern void read_Blog(void);
+extern void read_history(void);
 extern void delete_autosave(void);
 
 
index 1199755..b4d9be5 100644 (file)
@@ -210,18 +210,16 @@ IF(WITH_INSTALL)
                        COMMAND cp -Rf ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
                        COMMAND cp -Rf ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
                        COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
-                       COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/.blender
-                       COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
-                       COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
+                       COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/datafiles
+                       COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/datafiles/
+                       COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/datafiles/
                )
       
                IF(WITH_INTERNATIONAL)
                        ADD_CUSTOM_COMMAND(
                                TARGET blender POST_BUILD MAIN_DEPENDENCY blender
-                               COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
-                               COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/Resources/
-                               COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
-                               COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/Resources/
+                               COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/datafiles/
+                               COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/datafiles/
                        )
                ENDIF(WITH_INTERNATIONAL)
       
@@ -233,9 +231,10 @@ IF(WITH_INSTALL)
                        ENDIF(WITH_LIBS10.5)
                        ADD_CUSTOM_COMMAND(
                                TARGET blender POST_BUILD MAIN_DEPENDENCY blender
-                               COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
-                               COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/
-                               COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/
+                               COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/scripts/
+                               COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/python/
+                               COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/python/
+                               COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${TARGETDIR}/blender.app/Contents/MacOS/python/
                                COMMAND find ${TARGETDIR}/blender.app -name "*.py?" -prune -exec rm -rf {} "\;"
                        )
                ENDIF(WITH_PYTHON)      
index 6356210..cd6e465 100644 (file)
@@ -145,6 +145,8 @@ def setup_staticlibs(lenv):
                libincs += Split(lenv['BF_OPENEXR_LIBPATH'])
                if lenv['WITH_BF_STATICOPENEXR']:
                        statlibs += Split(lenv['BF_OPENEXR_LIB_STATIC'])
+       if lenv['WITH_BF_LCMS']:
+               libincs += Split(lenv['BF_LCMS_LIBPATH'])
        if lenv['WITH_BF_TIFF']:
                libincs += Split(lenv['BF_TIFF_LIBPATH'])
        if lenv['WITH_BF_FFTW3']:
index e76ada3..a703103 100644 (file)
@@ -73,7 +73,7 @@ def validate_arguments(args, bc):
             'BF_FANCY', 'BF_QUIET', 'BF_LINE_OVERWRITE',
             'BF_X264_CONFIG',
             'BF_XVIDCORE_CONFIG',
-            'WITH_BF_LCMS', 'BF_LCMS_LIB',
+            'WITH_BF_LCMS', 'BF_LCMS', 'BF_LCMS_INC', 'BF_LCMS_LIB', 'BF_LCMS_LIBPATH',
             'WITH_BF_DOCS',
             'BF_NUMJOBS',
             'BF_MSVS',
@@ -261,12 +261,18 @@ def read_opts(env, cfg, args):
         ('BF_PNG_LIB', 'PNG library', ''),
         ('BF_PNG_LIBPATH', 'PNG library path', ''),
 
-       (BoolVariable('WITH_BF_TIFF', 'Use TIFF if true', True)),
+        (BoolVariable('WITH_BF_TIFF', 'Use TIFF if true', True)),
         ('BF_TIFF', 'TIFF base path', ''),
         ('BF_TIFF_INC', 'TIFF include path', ''),
         ('BF_TIFF_LIB', 'TIFF library', ''),
         ('BF_TIFF_LIBPATH', 'TIFF library path', ''),
 
+        (BoolVariable('WITH_BF_LCMS', 'Enable color correction with lcms', False)),
+        ('BF_LCMS', 'LCMS base path', ''),
+        ('BF_LCMS_INC', 'LCMS include path', ''),
+        ('BF_LCMS_LIB', 'LCMS library', ''),
+        ('BF_LCMS_LIBPATH', 'LCMS library path', ''),
+
         (BoolVariable('WITH_BF_ZLIB', 'Use ZLib if true', True)),
         ('BF_ZLIB', 'ZLib base path', ''),
         ('BF_ZLIB_INC', 'ZLib include path', ''),
@@ -418,9 +424,6 @@ def read_opts(env, cfg, args):
         (BoolVariable('WITH_BF_LZO', 'Enable fast LZO pointcache compression', True)),
         (BoolVariable('WITH_BF_LZMA', 'Enable best LZMA pointcache compression', True)),
         
-        (BoolVariable('WITH_BF_LCMS', 'Enable color correction with lcms', False)),
-        ('BF_LCMS_LIB', 'LCMSlibrary', 'lcms'),
-
         ('BF_X264_CONFIG', 'configuration flags for x264', ''),
         ('BF_XVIDCORE_CONFIG', 'configuration flags for xvidcore', ''),
         (BoolVariable('WITH_BF_DOCS', 'Generate API documentation', False)),