Commits

Leonardo de Moura committed 39846d3

Added install-python/uninstall-python commands to Makefile

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>

Comments (0)

Files changed (3)

 LDFLAGS=@LDFLAGS@ -lpthread -fopenmp
 LDFLAGS_EXTRA=
 PREFIX=@prefix@
+HAS_PYTHON=@HAS_PYTHON@
+PYTHON_PACKAGE_DIR=@PYTHON_PACKAGE_DIR@
 #########################
 
 Z3=z3
 	@rm -f $(PREFIX)/include/z3_v1.h
 	@rm -f $(PREFIX)/include/z3_macros.h
 	@rm -f $(PREFIX)/include/z3++.h
+
+install-python: $(BIN_DIR)/lib$(Z3).so
+	@if test $(HAS_PYTHON) -eq 0; then echo "Python is not available in your system."; exit 1; fi
+	@echo "Installing Python bindings at $(PYTHON_PACKAGE_DIR)."
+	@cp python/z3.py $(PYTHON_PACKAGE_DIR)
+	@cp python/z3core.py $(PYTHON_PACKAGE_DIR)
+	@cp python/z3types.py $(PYTHON_PACKAGE_DIR)
+	@cp python/z3consts.py $(PYTHON_PACKAGE_DIR)
+	@cp python/z3tactics.py $(PYTHON_PACKAGE_DIR)
+	@cp python/z3printer.py $(PYTHON_PACKAGE_DIR)
+	@cp $(BIN_DIR)/lib$(Z3).so $(PYTHON_PACKAGE_DIR)
+
+uninstall-python: 
+	@if test $(HAS_PYTHON) -eq 0; then echo "Python is not available in your system."; exit 1; fi
+	@echo "Uninstalling Python bindings from $(PYTHON_PACKAGE_DIR)."
+	@rm -f $(PYTHON_PACKAGE_DIR)/z3.py
+	@rm -f $(PYTHON_PACKAGE_DIR)/z3core.py
+	@rm -f $(PYTHON_PACKAGE_DIR)/z3types.py
+	@rm -f $(PYTHON_PACKAGE_DIR)/z3consts.py
+	@rm -f $(PYTHON_PACKAGE_DIR)/z3tactics.py
+	@rm -f $(PYTHON_PACKAGE_DIR)/z3printer.py
+	@rm -f $(PYTHON_PACKAGE_DIR)/$(BIN_DIR)/lib$(Z3).so
   make
   sudo make install
 
-To uninstall z3, use
+To uninstall Z3, use
 
   sudo make uninstall
 
+To install Z3 Python bindings, use
+
+  sudo make install-python
+
+To uninstall Z3 Python bindings, use
+
+  sudo make uninstall-python
+  
+
 Remark: the Z3 makefile imports the source file list from Visual Studio project files.
 To add new source files to the Z3 core, you must include them at: lib/lib.vcxproj
 
 AC_SUBST(COMP_VERSIONS)
 AC_SUBST(STATIC_FLAGS)
 
+cat > tst_python.py <<EOF
+from sys import version
+if version >= "3":
+   exit(1)
+exit(0)
+EOF
+
+if python tst_python.py; then
+  HAS_PYTHON="1"
+  HAS_PYTHON_MSG="yes"
+cat > get_py_dir.py << EOF
+import distutils.sysconfig
+print distutils.sysconfig.get_python_lib()
+EOF
+  if python get_py_dir.py > dir.txt; then
+    PYTHON_PACKAGE_DIR=`cat dir.txt`
+  else
+    HAS_PYTHON="0"
+    HAS_PYTHON_MSG="no"
+  fi
+  rm -f dir.txt
+  rm -f get_py_dir.py
+else
+  HAS_PYTHON="0"
+  HAS_PYTHON_MSG="no"
+fi
+AC_SUBST(PYTHON_PACKAGE_DIR)
+AC_SUBST(HAS_PYTHON)
+rm -f tst_python.py
+
 cat > tst64.c <<EOF
     int main() {
     	return sizeof(unsigned) == sizeof(void*);
 Z3 was configured with success.
 Host platform: $PLATFORM
 Arithmetic:    $ARITH
+Python:        $HAS_PYTHON_MSG
 
 Type 'make' to compile Z3.
+Type 'sudo make install' to install Z3.
+Type 'sudo make install-python' to install Z3 Python bindings.
 EOF
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.