Permalink
Browse files

CDRIVER-139 shared install fixes

  • Loading branch information...
1 parent d6f058c commit bc9ec4a77f1d3b17807135ab2ee8e9dad6933863 @banker banker committed Jun 1, 2012
Showing with 52 additions and 29 deletions.
  1. +16 −12 Makefile
  2. +36 −17 SConstruct
View
28 Makefile
@@ -17,8 +17,10 @@
# Version
MONGO_MAJOR=0
MONGO_MINOR=5
+MONGO_PATCH=2
BSON_MAJOR=$(MONGO_MAJOR)
BSON_MINOR=$(MONGO_MINOR)
+BSON_PATCH=$(MONGO_PATCH)
# Library names
MONGO_LIBNAME=libmongoc
@@ -37,17 +39,16 @@ MONGO_OBJECTS=src/bson.o src/encoding.o src/gridfs.o src/md5.o src/mongo.o \
src/numbers.o
BSON_OBJECTS=src/bson.o src/numbers.o src/encoding.o
-DYN_MONGO_OBJECTS=src/bson.os src/encoding.os src/gridfs.os src/md5.os \
- src/mongo.os src/numbers.os
-DYN_BSON_OBJECTS=src/bson.os src/numbers.os src/encoding.os
-
ifeq ($(ENV),posix)
TESTS+=test/env_posix_test
MONGO_OBJECTS+=src/env_posix.o
else
MONGO_OBJECTS+=src/env_standard.o
endif
+DYN_MONGO_OBJECTS=$(foreach i,$(MONGO_OBJECTS),$(patsubst %.o,%.os,$(i)))
+DYN_BSON_OBJECTS=$(foreach i,$(BSON_OBJECTS),$(patsubst %.o,%.os,$(i)))
+
# Compile flags
ALL_DEFINES=$(DEFINES)
ALL_DEFINES+=-D_POSIX_SOURCE
@@ -86,14 +87,17 @@ ALL_LDFLAGS=$(LDFLAGS)
# Shared libraries
DYLIBSUFFIX=so
STLIBSUFFIX=a
+
MONGO_DYLIBNAME=$(MONGO_LIBNAME).$(DYLIBSUFFIX)
-MONGO_DYLIB_MINOR_NAME=$(MONGO_LIBNAME).$(DYLIBSUFFIX).$(MONGO_MAJOR).$(MONGO_MINOR)
-MONGO_DYLIB_MAJOR_NAME=$(MONGO_LIBNAME).$(DYLIBSUFFIX).$(MONGO_MAJOR)
+MONGO_DYLIB_MAJOR_NAME=$(MONGO_DYLIBNAME).$(MONGO_MAJOR)
+MONGO_DYLIB_MINOR_NAME=$(MONGO_DYLIB_MAJOR_NAME).$(MONGO_MINOR)
+MONGO_DYLIB_PATCH_NAME=$(MONGO_DYLIB_MINOR_NAME).$(MONGO_PATCH)
MONGO_DYLIB_MAKE_CMD=$(CC) -shared -Wl,-soname,$(MONGO_DYLIB_MINOR_NAME) -o $(MONGO_DYLIBNAME) $(ALL_LDFLAGS) $(DYN_MONGO_OBJECTS)
BSON_DYLIBNAME=$(BSON_LIBNAME).$(DYLIBSUFFIX)
-BSON_DYLIB_MINOR_NAME=$(BSON_LIBNAME).$(DYLIBSUFFIX).$(BSON_MAJOR).$(BSON_MINOR)
-BSON_DYLIB_MAJOR_NAME=$(BSON_LIBNAME).$(DYLIBSUFFIX).$(BSON_MAJOR)
+BSON_DYLIB_MAJOR_NAME=$(BSON_DYLIBNAME).$(BSON_MAJOR)
+BSON_DYLIB_MINOR_NAME=$(BSON_DYLIB_MAJOR_NAME).$(BSON_MINOR)
+BSON_DYLIB_PATCH_NAME=$(BSON_DYLIB_MINOR_NAME).$(BSON_PATCH)
BSON_DYLIB_MAKE_CMD=$(CC) -shared -Wl,-soname,$(BSON_DYLIB_MINOR_NAME) -o $(BSON_DYLIBNAME) $(ALL_LDFLAGS) $(DYN_BSON_OBJECTS)
# Static libraries
@@ -156,10 +160,10 @@ $(BSON_STLIBNAME): $(BSON_OBJECTS)
install:
mkdir -p $(INSTALL_INCLUDE_PATH) $(INSTALL_LIBRARY_PATH)
$(INSTALL) src/mongo.h src/bson.h $(INSTALL_INCLUDE_PATH)
- $(INSTALL) $(MONGO_DYLIBNAME) $(INSTALL_LIBRARY_PATH)/$(MONGO_DYLIB_MINOR_NAME)
- $(INSTALL) $(BSON_DYLIBNAME) $(INSTALL_LIBRARY_PATH)/$(BSON_DYLIB_MINOR_NAME)
- cd $(INSTALL_LIBRARY_PATH) && ln -sf $(MONGO_DYLIB_MINOR_NAME) $(MONGO_DYLIB_MAJOR_NAME)
- cd $(INSTALL_LIBRARY_PATH) && ln -sf $(BSON_DYLIB_MINOR_NAME) $(BSON_DYLIB_MAJOR_NAME)
+ $(INSTALL) $(MONGO_DYLIBNAME) $(INSTALL_LIBRARY_PATH)/$(MONGO_DYLIB_PATCH_NAME)
+ $(INSTALL) $(BSON_DYLIBNAME) $(INSTALL_LIBRARY_PATH)/$(BSON_DYLIB_PATCH_NAME)
+ cd $(INSTALL_LIBRARY_PATH) && ln -sf $(MONGO_DYLIB_PATCH_NAME) $(MONGO_DYLIB_MINOR_NAME)
+ cd $(INSTALL_LIBRARY_PATH) && ln -sf $(BSON_DYLIB_PATCH_NAME) $(BSON_DYLIB_MINOR_NAME)
cd $(INSTALL_LIBRARY_PATH) && ln -sf $(MONGO_DYLIB_MINOR_NAME) $(MONGO_DYLIBNAME)
cd $(INSTALL_LIBRARY_PATH) && ln -sf $(BSON_DYLIB_MINOR_NAME) $(BSON_DYLIBNAME)
$(INSTALL) $(MONGO_STLIBNAME) $(INSTALL_LIBRARY_PATH)
View
53 SConstruct
@@ -178,8 +178,8 @@ bSharedObjs = env.SharedObject(bLibFiles)
bsonEnv = env.Clone()
if os.sys.platform == "linux2":
- env.Append( SHLINKFLAGS = "-shared -Wl,-soname,libmongoc.so." + VERSION )
- bsonEnv.Append( SHLINKFLAGS = "-shared -Wl,-soname,libbson.so." + VERSION )
+ env.Append( SHLINKFLAGS = "-shared -Wl,-soname,libmongoc.so." + MAJOR_VERSION + "." + MINOR_VERSION )
+ bsonEnv.Append( SHLINKFLAGS = "-shared -Wl,-soname,libbson.so." + MAJOR_VERSION + "." + MINOR_VERSION)
dynm = env.SharedLibrary( "mongoc" , mSharedObjs )
dynb = bsonEnv.SharedLibrary( "bson" , bSharedObjs )
@@ -199,36 +199,55 @@ def remove_without_exception(filename):
except:
print "Could not find " + filename + ". Skipping removal."
-mongoc_target = os.path.join(install_library_path, "libmongoc." + shared_obj_suffix + "." + MAJOR_VERSION + "." + MINOR_VERSION)
-mongoc_major_target = os.path.join(install_library_path, "libmongoc." + shared_obj_suffix + "." + MAJOR_VERSION)
-mongoc_base_target = os.path.join(install_library_path, "libmongoc." + shared_obj_suffix)
+def makedirs_without_exception(path):
+ try:
+ os.makedirs(path)
+ except:
+ print path + ": already exists, skipping"
-bson_target = os.path.join(install_library_path, "libbson." + shared_obj_suffix + "." + MAJOR_VERSION + "." + MINOR_VERSION)
-bson_major_target = os.path.join(install_library_path, "libbson." + shared_obj_suffix + "." + MAJOR_VERSION)
-bson_base_target = os.path.join(install_library_path, "libbson." + shared_obj_suffix)
+mongoc_target = os.path.join(install_library_path, "libmongoc." + shared_obj_suffix)
+mongoc_major_target = mongoc_target + "." + MAJOR_VERSION
+mongoc_minor_target = mongoc_major_target + "." + MINOR_VERSION
+mongoc_patch_target = mongoc_minor_target + "." + PATCH_VERSION
+
+bson_target = os.path.join(install_library_path, "libbson." + shared_obj_suffix)
+bson_major_target = bson_target + "." + MAJOR_VERSION
+bson_minor_target = bson_major_target + "." + MINOR_VERSION
+bson_patch_target = bson_minor_target + "." + PATCH_VERSION
def uninstall_shared_libraries(target=None, source=None, env=None):
remove_without_exception(mongoc_major_target)
- remove_without_exception(mongoc_base_target)
+ remove_without_exception(mongoc_minor_target)
+ remove_without_exception(mongoc_patch_target)
remove_without_exception(mongoc_target)
remove_without_exception(bson_major_target)
- remove_without_exception(bson_base_target)
+ remove_without_exception(bson_minor_target)
+ remove_without_exception(bson_patch_target)
remove_without_exception(bson_target)
def install_shared_libraries(target=None, source=None, env=None):
import shutil
uninstall_shared_libraries()
- shutil.copy("libmongoc." + shared_obj_suffix, mongoc_target)
- os.symlink(mongoc_target, mongoc_base_target)
- os.symlink(mongoc_target, mongoc_major_target)
+ makedirs_without_exception(install_library_path)
+ shutil.copy("libmongoc." + shared_obj_suffix, mongoc_patch_target)
+ os.symlink(mongoc_patch_target, mongoc_minor_target)
+ os.symlink(mongoc_minor_target, mongoc_target)
+
+ shutil.copy("libbson." + shared_obj_suffix, bson_patch_target)
+ os.symlink(bson_patch_target, bson_minor_target)
+ os.symlink(bson_minor_target, bson_target)
- shutil.copy("libbson." + shared_obj_suffix, bson_target)
- os.symlink(bson_target, bson_base_target)
- os.symlink(bson_target, bson_major_target)
+def install_headers(target=None, source=None, env=None):
+ import shutil
+ # -- uninstall headers here?
+
+ makedirs_without_exception(install_include_path)
+ for hdr in headers:
+ shutil.copy(hdr, install_include_path)
-env.Alias("install", [], install_shared_libraries)
+env.Alias("install", [], [install_shared_libraries, install_headers] )
env.Command("uninstall", [], uninstall_shared_libraries)

0 comments on commit bc9ec4a

Please sign in to comment.