From 314c20d81da75b5fffd1ee8a30089bbe893ec805 Mon Sep 17 00:00:00 2001 From: Kazuki Przyborowski Date: Sat, 27 Feb 2016 06:52:42 -0600 Subject: [PATCH] Added make and cmake. --- CMakeLists.txt | 27 +++++++++++++++++++++++++++ Makefile | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 CMakeLists.txt create mode 100755 Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..2aec408 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,27 @@ +project(PyMotherless NONE) +cmake_minimum_required(VERSION 2.8) + +find_package(PythonInterp REQUIRED) + +add_custom_target(build ALL + COMMAND ${PYTHON_EXECUTABLE} setup.py build --build-base ${CMAKE_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + +# DESTDIR may be set at install time (eg: `make DESTDIR=/tmp/package install`) +# so we need to check for it when the install code is run and pass the appropriate +# argument to distutils. +# +# Note that if(\$ENV{DESTDIR}) always fails, regardless of the value of the DESTDIR +# environment variable, hence the STREQUAL test. +# See http://public.kitware.com/Bug/view.php?id=14737 +install(CODE + "set(_root_arg) + if (NOT \$ENV{DESTDIR} STREQUAL \"\") + set(_root_arg --root \$ENV{DESTDIR}) + endif() + execute_process( + COMMAND ${PYTHON_EXECUTABLE} setup.py install --prefix ${CMAKE_INSTALL_PREFIX} \${_root_arg} + WORKING_DIRECTORY \"${CMAKE_SOURCE_DIR}\" + )" + ) diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..6f527ca --- /dev/null +++ b/Makefile @@ -0,0 +1,48 @@ +#!/usr/bin/make -f + +PREFIX?="/usr/local" +DESTDIR?="/" +CMAKE?="/usr/bin/cmake" +MAKE?="/usr/bin/make" +PYTHONTWO?="/usr/bin/python2" +PYTHONTHREE?="/usr/bin/python3" +.PHONY: all install installnoclean clean pythontwoinst pythonthreeinst pythontwoinstnoclean pythonthreeinstnoclean pythontwo pythonthree pythontwonoclean pythonthreenoclean + +all: clean pythontwonoclean pythonthreenoclean + +install: pythontwoinst pythonthreeinst + +installnoclean: pythontwoinstnoclean pythonthreeinstnoclean + +clean: + if [ -d "./py2build/" ]; then cd "./py2build" && make clean; fi + if [ -d "./py3build/" ]; then cd "./py3build" && make clean; fi + rm -rfv "./build/" "./dist/" "./deb_dist/" "./PyUPC_EAN.egg-info/" "./py2build/" "./py3build" + +pythontwoinst: pythontwo + if [ -d "./py2build/" ]; then cd "./py2build" && ${MAKE} DESTDIR=${DESTDIR} install; fi + ${MAKE} clean + +pythonthreeinst: pythonthree + if [ -d "./py3build/" ]; then cd "./py3build" && ${MAKE} DESTDIR=${DESTDIR} install; fi + ${MAKE} clean + +pythontwoinstnoclean: pythontwonoclean + if [ -d "./py2build/" ]; then cd "./py2build" && ${MAKE} DESTDIR=${DESTDIR} install; fi + +pythonthreeinstnoclean: pythonthreenoclean + if [ -d "./py3build/" ]; then cd "./py3build" && ${MAKE} DESTDIR=${DESTDIR} install; fi + +pythontwo: + ${MAKE} clean + mkdir -p -v "./py2build" && cd "./py2build" && ${CMAKE} -DPYTHON_EXECUTABLE:FILEPATH=${PYTHONTWO} -DCMAKE_INSTALL_PREFIX:PATH=${PREFIX} .. && ${MAKE} + +pythonthree: + ${MAKE} clean + mkdir -p -v "./py3build" && cd "./py3build" && ${CMAKE} -DPYTHON_EXECUTABLE:FILEPATH=${PYTHONTHREE} -DCMAKE_INSTALL_PREFIX:PATH=${PREFIX} .. && ${MAKE} + +pythontwonoclean: + mkdir -p -v "./py2build" && cd "./py2build" && ${CMAKE} -DPYTHON_EXECUTABLE:FILEPATH=${PYTHONTWO} -DCMAKE_INSTALL_PREFIX:PATH=${PREFIX} .. && ${MAKE} + +pythonthreenoclean: + mkdir -p -v "./py3build" && cd "./py3build" && ${CMAKE} -DPYTHON_EXECUTABLE:FILEPATH=${PYTHONTHREE} -DCMAKE_INSTALL_PREFIX:PATH=${PREFIX} .. && ${MAKE} -- 2.11.4.GIT