Better unix filesystem integration as documented here

http://wiki.blender.org/index.php/BlenderDev/Blender2.5/Unix_FHS

for scons WITH_BF_FHS enabled an alternative layout eg.
scons WITH_BF_FHS=1 BF_INSTALLDIR="/usr/local"

for CMake just run "make install" after make (CMAKE_INSTALL_PREFIX is used for the base path)

Currently only scripts use both the system and user path correctly, other areas of blender have their own path code inline with lots of ifdefs, needs to be carefully updated.
This commit is contained in:
Campbell Barton 2009-09-21 03:16:26 +00:00
parent 6c655aa2a7
commit e7abdd7d56
20 changed files with 273 additions and 163 deletions

@ -51,6 +51,10 @@ PROJECT(Blender)
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
# Note! - Could create this from the blender version string
# ...but thats quite involved, make sure this matches the blender version.
SET(BLENDER_VERSION 2.5)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Set default config options # Set default config options
OPTION(WITH_PLAYER "Build Player" OFF) OPTION(WITH_PLAYER "Build Player" OFF)

@ -186,6 +186,15 @@ if not env['BF_FANCY']:
SetOption('num_jobs', int(env['BF_NUMJOBS'])) SetOption('num_jobs', int(env['BF_NUMJOBS']))
print "Build with %d parallel jobs" % (GetOption('num_jobs')) print "Build with %d parallel jobs" % (GetOption('num_jobs'))
# BLENDERPATH is a unix only option to enable typical style paths this is
# spesifically a data-dir, which is used a lot but cant replace BF_INSTALLDIR
# because the blender binary is installed in $BF_INSTALLDIR/bin/blender
if env['WITH_BF_FHS']:
BLENDERPATH = os.path.join(env['BF_INSTALLDIR'], 'share', 'blender', env['BF_VERSION'])
else:
BLENDERPATH = env['BF_INSTALLDIR']
# disable elbeem (fluidsim) compilation? # disable elbeem (fluidsim) compilation?
if env['BF_NO_ELBEEM'] == 1: if env['BF_NO_ELBEEM'] == 1:
env['CPPFLAGS'].append('-DDISABLE_ELBEEM') env['CPPFLAGS'].append('-DDISABLE_ELBEEM')
@ -198,7 +207,7 @@ if env['WITH_BF_OPENMP'] == 1:
env['CPPFLAGS'].append('/openmp') env['CPPFLAGS'].append('/openmp')
env['CXXFLAGS'].append('/openmp') env['CXXFLAGS'].append('/openmp')
else: else:
if env['CC'][-3:] == 'icc': # to be able to handle CC=/opt/bla/icc case if env['CC'].endswith('icc'): # to be able to handle CC=/opt/bla/icc case
env.Append(LINKFLAGS=['-openmp', '-static-intel']) env.Append(LINKFLAGS=['-openmp', '-static-intel'])
env['CCFLAGS'].append('-openmp') env['CCFLAGS'].append('-openmp')
env['CPPFLAGS'].append('-openmp') env['CPPFLAGS'].append('-openmp')
@ -301,7 +310,7 @@ if env['WITH_BF_SDL'] == False and env['OURPLATFORM'] in ('win32-vc', 'win32-min
# lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir # lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
B.root_build_dir = env['BF_BUILDDIR'] B.root_build_dir = env['BF_BUILDDIR']
B.doc_build_dir = env['BF_DOCDIR'] B.doc_build_dir = os.path.join(BLENDERPATH, 'doc')
if not B.root_build_dir[-1]==os.sep: if not B.root_build_dir[-1]==os.sep:
B.root_build_dir += os.sep B.root_build_dir += os.sep
if not B.doc_build_dir[-1]==os.sep: if not B.doc_build_dir[-1]==os.sep:
@ -426,7 +435,10 @@ if env['OURPLATFORM']=='darwin':
source=[dp+os.sep+f for f in df] source=[dp+os.sep+f for f in df]
blenderinstall.append(env.Install(dir=dir,source=source)) blenderinstall.append(env.Install(dir=dir,source=source))
else: else:
blenderinstall = env.Install(dir=env['BF_INSTALLDIR'], source=B.program_list) if env['WITH_BF_FHS']: dir= os.path.join(env['BF_INSTALLDIR'], 'bin')
else: dir= env['BF_INSTALLDIR']
blenderinstall = env.Install(dir=dir, source=B.program_list)
#-- .blender #-- .blender
#- dont do .blender and scripts for darwin, it is already in the bundle #- dont do .blender and scripts for darwin, it is already in the bundle
@ -450,7 +462,13 @@ if env['OURPLATFORM']!='darwin':
continue continue
dotblendlist.append(os.path.join(dp, f)) dotblendlist.append(os.path.join(dp, f))
dottargetlist.append(env['BF_INSTALLDIR']+dp[3:]+os.sep+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
# print dir+ os.sep + f
print dir
dottargetlist.append(dir + os.sep + f)
dotblenderinstall = [] dotblenderinstall = []
for targetdir,srcfile in zip(dottargetlist, dotblendlist): for targetdir,srcfile in zip(dottargetlist, dotblendlist):
@ -464,8 +482,12 @@ if env['OURPLATFORM']!='darwin':
for dp, dn, df in os.walk(scriptpath): for dp, dn, df in os.walk(scriptpath):
if '.svn' in dn: if '.svn' in dn:
dn.remove('.svn') dn.remove('.svn')
dir=env['BF_INSTALLDIR']+'/.blender/'+os.path.basename(scriptpath)+dp[len(scriptpath):]
source=[dp+os.sep+f for f in df] if env['WITH_BF_FHS']: dir = BLENDERPATH
else: dir = os.path.join(env['BF_INSTALLDIR'], '.blender')
dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
source=[os.path.join(dp, f) for f in df]
scriptinstall.append(env.Install(dir=dir,source=source)) scriptinstall.append(env.Install(dir=dir,source=source))
#-- icons #-- icons
@ -477,8 +499,8 @@ if env['OURPLATFORM']=='linux2':
if '.svn' in tn: if '.svn' in tn:
tn.remove('.svn') tn.remove('.svn')
for f in tf: for f in tf:
iconlist.append(tp+os.sep+f) iconlist.append(os.path.join(tp, f))
icontargetlist.append(env['BF_INSTALLDIR']+tp[19:]+os.sep+f) icontargetlist.append( os.path.join(*([BLENDERPATH] + tp.split(os.sep)[2:] + [f])) )
iconinstall = [] iconinstall = []
for targetdir,srcfile in zip(icontargetlist, iconlist): for targetdir,srcfile in zip(icontargetlist, iconlist):
@ -499,24 +521,25 @@ for tp, tn, tf in os.walk('release/plugins'):
if '.svn' in tn: if '.svn' in tn:
tn.remove('.svn') tn.remove('.svn')
for f in tf: for f in tf:
pluglist.append(tp+os.sep+f) pluglist.append(os.path.join(tp, f))
plugtargetlist.append(env['BF_INSTALLDIR']+tp[7:]+os.sep+f) plugtargetlist.append( os.path.join(*([BLENDERPATH] + tp.split(os.sep)[1:] + [f])) )
# header files for plugins # header files for plugins
pluglist.append('source/blender/blenpluginapi/documentation.h') pluglist.append('source/blender/blenpluginapi/documentation.h')
plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'documentation.h') plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'documentation.h'))
pluglist.append('source/blender/blenpluginapi/externdef.h') pluglist.append('source/blender/blenpluginapi/externdef.h')
plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'externdef.h') plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'externdef.h'))
pluglist.append('source/blender/blenpluginapi/floatpatch.h') pluglist.append('source/blender/blenpluginapi/floatpatch.h')
plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'floatpatch.h') plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'floatpatch.h'))
pluglist.append('source/blender/blenpluginapi/iff.h') pluglist.append('source/blender/blenpluginapi/iff.h')
plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'iff.h') plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'iff.h'))
pluglist.append('source/blender/blenpluginapi/plugin.h') pluglist.append('source/blender/blenpluginapi/plugin.h')
plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'plugin.h') plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'plugin.h'))
pluglist.append('source/blender/blenpluginapi/util.h') pluglist.append('source/blender/blenpluginapi/util.h')
plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'util.h') plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'util.h'))
pluglist.append('source/blender/blenpluginapi/plugin.DEF') pluglist.append('source/blender/blenpluginapi/plugin.DEF')
plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep + 'plugin.def') plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'plugin.def'))
plugininstall = [] plugininstall = []
for targetdir,srcfile in zip(plugtargetlist, pluglist): for targetdir,srcfile in zip(plugtargetlist, pluglist):
@ -531,7 +554,7 @@ for tp, tn, tf in os.walk('release/text'):
for f in tf: for f in tf:
textlist.append(tp+os.sep+f) textlist.append(tp+os.sep+f)
textinstall = env.Install(dir=env['BF_INSTALLDIR'], source=textlist) textinstall = env.Install(dir=BLENDERPATH, source=textlist)
if env['OURPLATFORM']=='darwin': if env['OURPLATFORM']=='darwin':
allinstall = [blenderinstall, plugininstall, textinstall] allinstall = [blenderinstall, plugininstall, textinstall]

@ -274,4 +274,3 @@ BF_DEBUG_CCFLAGS = ['-g']
BF_BUILDDIR='../build/darwin' BF_BUILDDIR='../build/darwin'
BF_INSTALLDIR='../install/darwin' BF_INSTALLDIR='../install/darwin'
BF_DOCDIR='../install/doc'

@ -189,7 +189,6 @@ BF_DEBUG_FLAGS = '-g'
BF_BUILDDIR = '../build/irix6' BF_BUILDDIR = '../build/irix6'
BF_INSTALLDIR='../install/irix6' BF_INSTALLDIR='../install/irix6'
BF_DOCDIR='../install/doc'
#Link against pthread #Link against pthread
LDIRS = [] LDIRS = []

@ -189,8 +189,6 @@ BF_DEBUG_CCFLAGS = ['-g']
BF_BUILDDIR = '../build/linux2' BF_BUILDDIR = '../build/linux2'
BF_INSTALLDIR='../install/linux2' BF_INSTALLDIR='../install/linux2'
BF_DOCDIR='../install/doc'
#Link against pthread #Link against pthread
PLATFORM_LINKFLAGS = ['-pthread'] PLATFORM_LINKFLAGS = ['-pthread']

@ -139,4 +139,3 @@ BF_PROFILE_LINKFLAGS = ['-pg']
BF_BUILDDIR = '../build/linuxcross' BF_BUILDDIR = '../build/linuxcross'
BF_INSTALLDIR='../install/linuxcross' BF_INSTALLDIR='../install/linuxcross'
BF_DOCDIR='../install/doc'

@ -151,4 +151,3 @@ BF_DEBUG_CCFLAGS = ['-g']
BF_BUILDDIR='../build/openbsd3' BF_BUILDDIR='../build/openbsd3'
BF_INSTALLDIR='../install/openbsd3' BF_INSTALLDIR='../install/openbsd3'
BF_DOCDIR='../install/doc'

@ -165,7 +165,6 @@ BF_DEBUG_CCFLAGS = []
BF_BUILDDIR = '../build/sunos5' BF_BUILDDIR = '../build/sunos5'
BF_INSTALLDIR='../install/sunos5' BF_INSTALLDIR='../install/sunos5'
BF_DOCDIR='../install/doc'
PLATFORM_LINKFLAGS = [] PLATFORM_LINKFLAGS = []

@ -152,4 +152,3 @@ BF_PROFILE = False
BF_BUILDDIR = '..\\build\\win32-mingw' BF_BUILDDIR = '..\\build\\win32-mingw'
BF_INSTALLDIR='..\\install\\win32-mingw' BF_INSTALLDIR='..\\install\\win32-mingw'
BF_DOCDIR = '..\\install\\doc'

@ -173,4 +173,3 @@ PLATFORM_LINKFLAGS = ['/SUBSYSTEM:CONSOLE','/MACHINE:IX86','/INCREMENTAL:NO','/N
BF_BUILDDIR = '..\\build\\win32-vc' BF_BUILDDIR = '..\\build\\win32-vc'
BF_INSTALLDIR='..\\install\\win32-vc' BF_INSTALLDIR='..\\install\\win32-vc'
BF_DOCDIR='..\\install\\doc'

@ -192,7 +192,6 @@ PLATFORM_LINKFLAGS = ['/SUBSYSTEM:CONSOLE','/MACHINE:X64','/INCREMENTAL:NO','/NO
BF_BUILDDIR = '..\\build\\blender25-win64-vc' BF_BUILDDIR = '..\\build\\blender25-win64-vc'
BF_INSTALLDIR='..\\install\\blender25-win64-vc' BF_INSTALLDIR='..\\install\\blender25-win64-vc'
BF_DOCDIR='..\\install\\blender25-win64-vc\\doc'

@ -42,7 +42,14 @@ struct ListBase;
struct direntry; struct direntry;
char *BLI_gethome(void); char *BLI_gethome(void);
char *BLI_gethome_folder(char *folder_name); char *BLI_gethome_folder(char *folder_name, int flag);
/* BLI_gethome_folder flag */
#define BLI_GETHOME_LOCAL 1<<1 /* relative location for portable binaries */
#define BLI_GETHOME_SYSTEM 1<<2 /* system location, or set from the BLENDERPATH env variable (UNIX only) */
#define BLI_GETHOME_USER 1<<3 /* home folder ~/.blender */
#define BLI_GETHOME_ALL (BLI_GETHOME_SYSTEM|BLI_GETHOME_LOCAL|BLI_GETHOME_USER)
void BLI_setenv(const char *env, const char *val); void BLI_setenv(const char *env, const char *val);
void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file); void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file);

@ -856,98 +856,123 @@ char *BLI_gethome(void) {
#endif #endif
} }
/* this function returns the path to a blender folder, if it exists, /* this function returns the path to a blender folder, if it exists
* trying in this order: * utility functions for BLI_gethome_folder */
*
* path_to_executable/release/folder_name (in svn)
* ./release/folder_name (in svn)
* $HOME/.blender/folder_name
* path_to_executable/.blender/folder_name
*
* returns NULL if none is found. */
char *BLI_gethome_folder(char *folder_name) /* #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)
{
char tmppath[FILE_MAXDIR];
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_DEBUG
printf("\tpath found: %s\n", targetpath);
#endif
return 1;
}
else {
#ifdef PATH_DEBUG
printf("\tpath missing: %s\n", targetpath);
#endif
targetpath[0] = '\0';
return 0;
}
}
static int gethome_path_local(char *targetpath, char *folder_name)
{ {
extern char bprogname[]; /* argv[0] from creator.c */ extern char bprogname[]; /* argv[0] from creator.c */
static char homedir[FILE_MAXDIR] = "";
static char fulldir[FILE_MAXDIR] = "";
char tmpdir[FILE_MAXDIR];
char bprogdir[FILE_MAXDIR]; char bprogdir[FILE_MAXDIR];
char cwd[FILE_MAXDIR];
char *s; char *s;
int i; int i;
#ifdef PATH_DEBUG
printf("gethome_path_local...\n");
#endif
/* try release/folder_name (binary relative) */
/* use argv[0] (bprogname) to get the path to the executable */ /* use argv[0] (bprogname) to get the path to the executable */
s = BLI_last_slash(bprogname); s = BLI_last_slash(bprogname);
i = s - bprogname + 1; i = s - bprogname + 1;
BLI_strncpy(bprogdir, bprogname, i); BLI_strncpy(bprogdir, bprogname, i);
/* try path_to_executable/release/folder_name (in svn) */ /* try ./.blender/folder_name */
if (folder_name) { if(test_data_path(targetpath, bprogdir, ".blender", folder_name))
BLI_snprintf(tmpdir, sizeof(tmpdir), "release/%s", folder_name); return 1;
BLI_make_file_string("/", fulldir, bprogdir, tmpdir);
if (BLI_exists(fulldir)) return fulldir;
else fulldir[0] = '\0';
}
/* try ./release/folder_name (in svn) */ if(test_data_path(targetpath, bprogdir, "release", folder_name))
if(folder_name) { return 1;
BLI_snprintf(fulldir, sizeof(fulldir), "./release/%s", folder_name);
if (BLI_exists(fulldir)) return fulldir;
else fulldir[0] = '\0';
}
/* BLI_gethome() can return NULL if env vars are not set */ /* try release/folder_name (CWD relative) */
s = BLI_gethome(); if(test_data_path(targetpath, BLI_getwdN(cwd), "release", folder_name))
return 1;
if(!s) { /* bail if no $HOME */ return 0;
printf("$HOME is NOT set\n"); }
return NULL;
}
if(strstr(s, ".blender")) static int gethome_path_user(char *targetpath, char *folder_name)
BLI_strncpy(homedir, s, FILE_MAXDIR); {
else char *home_path= BLI_gethome();
BLI_make_file_string("/", homedir, s, ".blender");
/* if $HOME/.blender/folder_name exists, return it */ #ifdef PATH_DEBUG
if(BLI_exists(homedir)) { printf("gethome_path_user...\n");
if (folder_name) { #endif
BLI_make_file_string("/", fulldir, homedir, folder_name);
if(BLI_exists(fulldir)) /* try $HOME/folder_name */
return test_data_path(targetpath, home_path, ".blender", folder_name);
}
static int gethome_path_system(char *targetpath, char *folder_name)
{
extern char blender_path[]; /* unix prefix eg. /usr/share/blender/2.5 creator.c */
if(!blender_path[0])
return 0;
#ifdef PATH_DEBUG
printf("gethome_path_system...\n");
#endif
/* try $BLENDERPATH/folder_name */
return test_data_path(targetpath, blender_path, NULL, folder_name);
}
char *BLI_gethome_folder(char *folder_name, int flag)
{
static char fulldir[FILE_MAXDIR] = "";
/* first check if this is a redistributable bundle */
if(flag & BLI_GETHOME_LOCAL) {
if (gethome_path_local(fulldir, folder_name))
return fulldir; return fulldir;
} }
else
return homedir;
}
else
homedir[0] = '\0';
/* using tmpdir to preserve homedir (if) found above: /* then check if the OS has blender data files installed in a global location */
* the ideal is to have a home dir with folder_name dir inside if(flag & BLI_GETHOME_SYSTEM) {
* it, but if that isn't available, it's possible to if (gethome_path_system(fulldir, folder_name))
* have a 'broken' home dir somewhere and a folder_name dir in the
* svn sources */
BLI_make_file_string("/", tmpdir, bprogdir, ".blender");
if(BLI_exists(tmpdir)) {
if(folder_name) {
BLI_make_file_string("/", fulldir, tmpdir, folder_name);
if(BLI_exists(fulldir)) {
BLI_strncpy(homedir, tmpdir, FILE_MAXDIR);
return fulldir; return fulldir;
} }
else {
homedir[0] = '\0'; /* now check the users home dir for data files */
fulldir[0] = '\0'; if(flag & BLI_GETHOME_USER) {
} if (gethome_path_user(fulldir, folder_name))
} return fulldir;
else return homedir;
} }
return NULL; return NULL;
} }
#ifdef PATH_DEBUG
#undef PATH_DEBUG
#endif
void BLI_setenv(const char *env, const char*val) void BLI_setenv(const char *env, const char*val)
{ {
/* SGI or free windows */ /* SGI or free windows */

@ -232,26 +232,10 @@ static PyObject *CreateGlobalDictionary( bContext *C )
return dict; return dict;
} }
/* Use this so we can include our own python bundle */
#if 0
wchar_t* Py_GetPath(void)
{
int i;
static wchar_t py_path[FILE_MAXDIR] = L"";
char *dirname= BLI_gethome_folder("python");
if(dirname) {
i= mbstowcs(py_path, dirname, FILE_MAXDIR);
printf("py path %s, %d\n", dirname, i);
}
return py_path;
}
#endif
/* must be called before Py_Initialize */ /* must be called before Py_Initialize */
void BPY_start_python_path(void) void BPY_start_python_path(void)
{ {
char *py_path_bundle= BLI_gethome_folder("python"); char *py_path_bundle= BLI_gethome_folder("python", BLI_GETHOME_ALL);
if(py_path_bundle==NULL) if(py_path_bundle==NULL)
return; return;
@ -589,7 +573,8 @@ void BPY_run_ui_scripts(bContext *C, int reload)
char *dirname; char *dirname;
char path[FILE_MAX]; char path[FILE_MAX];
char *dirs[] = {"ui", "io", NULL}; char *dirs[] = {"ui", "io", NULL};
int a, err; int path_flags[] = {BLI_GETHOME_LOCAL|BLI_GETHOME_SYSTEM, BLI_GETHOME_USER}; /* SYSTEM / NON-SYSTEM */
int a, err, flag_iter;
PyGILState_STATE gilstate; PyGILState_STATE gilstate;
PyObject *sys_path; PyObject *sys_path;
@ -599,8 +584,11 @@ void BPY_run_ui_scripts(bContext *C, int reload)
sys_path= PySys_GetObject("path"); /* borrow */ sys_path= PySys_GetObject("path"); /* borrow */
PyList_Insert(sys_path, 0, Py_None); /* place holder, resizes the list */ PyList_Insert(sys_path, 0, Py_None); /* place holder, resizes the list */
/* Scan system scripts first, then local/user */
for(flag_iter=0; flag_iter < sizeof(path_flags)/sizeof(int); flag_iter++) {
for(a=0; dirs[a]; a++) { for(a=0; dirs[a]; a++) {
dirname= BLI_gethome_folder(dirs[a]); dirname= BLI_gethome_folder(dirs[a], path_flags[flag_iter]);
if(!dirname) if(!dirname)
continue; continue;
@ -650,6 +638,7 @@ void BPY_run_ui_scripts(bContext *C, int reload)
closedir(dir); closedir(dir);
} }
}
PyList_SetSlice(sys_path, 0, 1, NULL); /* remove the first item */ PyList_SetSlice(sys_path, 0, 1, NULL); /* remove the first item */

@ -66,6 +66,13 @@ IF(NOT WITH_SDL)
ADD_DEFINITIONS(-DDISABLE_SDL) ADD_DEFINITIONS(-DDISABLE_SDL)
ENDIF(NOT WITH_SDL) ENDIF(NOT WITH_SDL)
IF(UNIX AND NOT APPLE)
SET(BLENDERPATH ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION})
CMAKE_POLICY(SET CMP0005 NEW)
# blender_path in creator.c
ADD_DEFINITIONS(-DBLENDERPATH="${BLENDERPATH}")
ENDIF(UNIX AND NOT APPLE)
IF(CMAKE_SYSTEM_NAME MATCHES "Linux") IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
ADD_DEFINITIONS(-DWITH_BINRELOC) ADD_DEFINITIONS(-DWITH_BINRELOC)
INCLUDE_DIRECTORIES(${BINRELOC_INC}) INCLUDE_DIRECTORIES(${BINRELOC_INC})
@ -96,6 +103,9 @@ IF(WITH_INSTALL)
ENDIF(UNIX) ENDIF(UNIX)
IF(UNIX AND NOT APPLE) IF(UNIX AND NOT APPLE)
# Local installation, "make install" can be done after this optionally
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
TARGET blender POST_BUILD MAIN_DEPENDENCY blender TARGET blender POST_BUILD MAIN_DEPENDENCY blender
COMMAND rm -Rf ${TARGETDIR}/.blender COMMAND rm -Rf ${TARGETDIR}/.blender
@ -152,6 +162,27 @@ IF(WITH_INSTALL)
COMMAND find ${TARGETDIR} -name .svn -prune -exec rm -rf {} "\;" COMMAND find ${TARGETDIR} -name .svn -prune -exec rm -rf {} "\;"
) )
# Above we bundle a portable distrobution in ./bin
# This is an optional "make install" which installs blender on the system.
INSTALL(
PROGRAMS ${TARGETDIR}/blender
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
)
IF(WITH_GAMEENGINE AND WITH_PLAYER)
INSTALL(
PROGRAMS ${TARGETDIR}/blenderplayer
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
)
ENDIF(WITH_GAMEENGINE AND WITH_PLAYER)
INSTALL(
DIRECTORY ${TARGETDIR}/.blender/
DESTINATION ${BLENDERPATH}
)
# end "make install"
ENDIF(UNIX AND NOT APPLE) ENDIF(UNIX AND NOT APPLE)
IF(APPLE) IF(APPLE)

@ -1,5 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
Import ('env') Import ('env')
import os
sources = 'creator.c' sources = 'creator.c'
@ -32,4 +33,8 @@ if env['WITH_BF_PYTHON']:
else: else:
defs.append('DISABLE_PYTHON') defs.append('DISABLE_PYTHON')
if env['WITH_BF_FHS']: # /usr -> /usr/share/blender/2.5
defs.append('BLENDERPATH=\\"' + os.path.join(env['BF_INSTALLDIR'], 'share', 'blender', env['BF_VERSION']) + '\\"')
env.BlenderLib ( libname = 'bf_creator', sources = Split(sources), includes = Split(incs), defines = defs, libtype='core', priority = 0 ) env.BlenderLib ( libname = 'bf_creator', sources = Split(sources), includes = Split(incs), defines = defs, libtype='core', priority = 0 )

@ -116,6 +116,18 @@ extern int pluginapi_force_ref(void); /* from blenpluginapi:pluginapi.c */
char bprogname[FILE_MAXDIR+FILE_MAXFILE]; /* from blenpluginapi:pluginapi.c */ char bprogname[FILE_MAXDIR+FILE_MAXFILE]; /* from blenpluginapi:pluginapi.c */
char btempdir[FILE_MAXDIR+FILE_MAXFILE]; char btempdir[FILE_MAXDIR+FILE_MAXFILE];
/* unix path support.
* defined by the compiler. eg "/usr/share/blender/2.5" "/opt/blender/2.5" */
#ifndef BLENDERPATH
#define BLENDERPATH ""
#endif
#if !(defined(__APPLE__) && defined(WIN32))
char blender_path[FILE_MAXDIR+FILE_MAXFILE] = BLENDERPATH;
#else
char blender_path[FILE_MAXDIR+FILE_MAXFILE] = "";
#endif
/* Initialise callbacks for the modules that need them */ /* Initialise callbacks for the modules that need them */
static void setCallbacks(void); static void setCallbacks(void);
@ -221,6 +233,12 @@ static void print_help(void)
printf (" \t\t passed unchanged. Access via Python's sys.argv\n"); printf (" \t\t passed unchanged. Access via Python's sys.argv\n");
printf ("\nEnvironment Variables:\n"); printf ("\nEnvironment Variables:\n");
printf (" $HOME\t\t\tStore files such as .blender/ .B.blend .Bfs .Blog here.\n"); printf (" $HOME\t\t\tStore files such as .blender/ .B.blend .Bfs .Blog here.\n");
#if !(defined(__APPLE__) && defined(WIN32))
printf (" $BLENDERPATH\tSystem directory to use for data files and scripts.\n");
printf (" \tFor this build of blender the default BLENDERPATH is...\n");
printf (" \t\"%s\"\n", blender_path);
printf (" \tseting the $BLENDERPATH will override this\n");
#endif
#ifdef WIN32 #ifdef WIN32
printf (" $TEMP\t\tStore temporary files here.\n"); printf (" $TEMP\t\tStore temporary files here.\n");
#else #else
@ -305,6 +323,12 @@ int main(int argc, char **argv)
BLI_where_am_i(bprogname, argv[0]); BLI_where_am_i(bprogname, argv[0]);
{ /* override the hard coded blender path */
char *blender_path_env = getenv("BLENDERPATH");
if(blender_path_env)
BLI_strncpy(blender_path, blender_path_env, sizeof(blender_path));
}
RNA_init(); RNA_init();
RE_engines_init(); RE_engines_init();

@ -1,6 +1,11 @@
#!/usr/bin/python #!/usr/bin/python
Import ('env') Import ('env')
import os
if env['WITH_BF_FHS']:
BLENDERPATH = os.path.join(env['BF_INSTALLDIR'], 'share', 'blender', env['BF_VERSION'])
else:
BLENDERPATH = env['BF_INSTALLDIR']
from optparse import OptionParser from optparse import OptionParser
import epydoc import epydoc
@ -14,7 +19,7 @@ optvalues["quiet"] = 0
optvalues["include_source_code"] = 0 optvalues["include_source_code"] = 0
optvalues["inheritance"] = "included" optvalues["inheritance"] = "included"
optvalues["show_private"] = 0 optvalues["show_private"] = 0
optvalues["target"] = env["BF_DOCDIR"]+"/BGE_API/" optvalues["target"] = os.path.join(BLENDERPATH, 'doc')
optvalues["url"] = "http://www.blender.org" optvalues["url"] = "http://www.blender.org"
optvalues["top"] = "Game Engine API" optvalues["top"] = "Game Engine API"
optvalues["name"] = "Blender" optvalues["name"] = "Blender"

@ -405,8 +405,11 @@ def PyInstall(target=None, source=None, env=None):
print 'Install command:', cmd print 'Install command:', cmd
commands.getoutput(cmd) commands.getoutput(cmd)
if env['WITH_BF_FHS']: dir = os.path.join(env['BF_INSTALLDIR'], 'share', 'blender', env['BF_VERSION']) # BLENDERPATH
else: dir = os.path.join(env['BF_INSTALLDIR'], '.blender')
py_src = env.subst( env['BF_PYTHON_LIBPATH'] + '/python'+env['BF_PYTHON_VERSION'] ) py_src = env.subst( env['BF_PYTHON_LIBPATH'] + '/python'+env['BF_PYTHON_VERSION'] )
py_target = env.subst( env['BF_INSTALLDIR'] + '/.blender/python/lib/python'+env['BF_PYTHON_VERSION'] ) py_target = env.subst( dir + '/python/lib/python'+env['BF_PYTHON_VERSION'] )
# Copied from source/creator/CMakeLists.txt, keep in sync. # Copied from source/creator/CMakeLists.txt, keep in sync.
print 'Install python from:' print 'Install python from:'

@ -69,6 +69,8 @@ def validate_arguments(args, bc):
'WITH_BF_DOCS', 'WITH_BF_DOCS',
'BF_NUMJOBS', 'BF_NUMJOBS',
'BF_MSVS', 'BF_MSVS',
'WITH_BF_FHS',
'BF_VERSION',
] ]
# Have options here that scons expects to be lists # Have options here that scons expects to be lists
@ -91,7 +93,7 @@ def validate_arguments(args, bc):
'BF_BSC', 'BF_CONFIG', 'BF_BSC', 'BF_CONFIG',
'BF_PRIORITYLIST', 'BF_BUILDINFO','CC', 'CXX', 'BF_QUICKDEBUG', 'BF_PRIORITYLIST', 'BF_BUILDINFO','CC', 'CXX', 'BF_QUICKDEBUG',
'BF_LISTDEBUG', 'LCGDIR', 'BF_X264_CONFIG', 'BF_XVIDCORE_CONFIG', 'BF_LISTDEBUG', 'LCGDIR', 'BF_X264_CONFIG', 'BF_XVIDCORE_CONFIG',
'BF_DOCDIR', 'BF_UNIT_TEST'] 'BF_UNIT_TEST']
okdict = {} okdict = {}
@ -362,7 +364,6 @@ def read_opts(cfg, args):
('BF_BUILDDIR', 'Build dir', ''), ('BF_BUILDDIR', 'Build dir', ''),
('BF_INSTALLDIR', 'Installation dir', ''), ('BF_INSTALLDIR', 'Installation dir', ''),
('BF_DOCDIR', 'Dir where BPy documentation will be created', ''),
('CC', 'C compiler to use', ''), ('CC', 'C compiler to use', ''),
('CXX', 'C++ compiler to use', ''), ('CXX', 'C++ compiler to use', ''),
@ -388,6 +389,9 @@ def read_opts(cfg, args):
('BF_NUMJOBS', 'Number of build processes to spawn', '1'), ('BF_NUMJOBS', 'Number of build processes to spawn', '1'),
('BF_MSVS', 'Generate MSVS project files and solution', False), ('BF_MSVS', 'Generate MSVS project files and solution', False),
(BoolVariable('WITH_BF_FHS', 'Use the Unix "Filesystem Hierarchy Standard" rather then a redistributable directory layout', False)),
('BF_VERSION', 'The root path for Unix (non-apple)', '2.5'),
(BoolVariable('BF_UNIT_TEST', 'Build with unit test support.', False)) (BoolVariable('BF_UNIT_TEST', 'Build with unit test support.', False))
) # end of opts.AddOptions() ) # end of opts.AddOptions()