Skip to content

Commit

Permalink
Build: implement make install-resources. Fixes monero-project#45.
Browse files Browse the repository at this point in the history
* Moves resource copying out of CMake and into Makefile
  • Loading branch information
anonimal committed Jul 20, 2016
1 parent b9a950a commit 8ea8276
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 20 deletions.
17 changes: 1 addition & 16 deletions CMakeLists.txt
Expand Up @@ -160,17 +160,9 @@ endif()
# Load remaining includes
include_directories(${CMAKE_SOURCE_DIR})

# Set default path
# Use data-path set in Makefile. Code must call upon this definition.
if(KOVRI_DATA_PATH)
set(KOVRI_DATA_DIR ${KOVRI_DATA_PATH})
# Using custom path, make sure the code knows about this
add_definitions(-DKOVRI_CUSTOM_DATA_PATH="${KOVRI_DATA_PATH}")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(KOVRI_DATA_DIR "$ENV{APPDATA}\\kovri")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(KOVRI_DATA_DIR "$ENV{HOME}/Library/Application Support/kovri")
else()
set(KOVRI_DATA_DIR "$ENV{HOME}/.kovri")
endif()

# Show summary
Expand Down Expand Up @@ -205,11 +197,4 @@ set(TESTS_NAME "${PROJECT_NAME}-tests")
set(BENCHMARKS_NAME "${PROJECT_NAME}-benchmarks")
add_subdirectory(src)

# Copy needed resources
if(WITH_BINARY)
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/pkg/certificates" DESTINATION "${KOVRI_DATA_DIR}/")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/pkg/kovri.conf" DESTINATION "${KOVRI_DATA_DIR}/")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/pkg/tunnels.conf" DESTINATION "${KOVRI_DATA_DIR}/")
endif()

# vim: noai:ts=2:sw=2
45 changes: 41 additions & 4 deletions Makefile
Expand Up @@ -28,15 +28,38 @@

#TODO(unassigned): improve this Makefile

build = build/ # TODO(unassigned): make this more useful
remove-build = rm -fr $(build)
# Get architecture
system := $(shell uname)

# Set custom data path
# If no path is given, set default path
ifeq ($(KOVRI_DATA_PATH),)
ifeq ($(system), Linux)
data-path = $(HOME)/.kovri
endif
ifeq ($(system), Darwin)
data-path = $(HOME)/Library/Application\ Support/kovri
endif
ifneq (, $(findstring MINGW, $(system)))
data-path = $(APPDATA)\\kovri
endif
else
data-path = $(KOVRI_DATA_PATH)
endif

cmake = cmake -D CMAKE_C_COMPILER=$(CC) -D CMAKE_CXX_COMPILER=$(CXX)
# Command to install package resources to data path
copy-resources = cp -fR pkg/ $(data-path)

# Release types
# TODO(unassigned): put these to good use. We'll require rewrite of root recipe.
debug = -D CMAKE_BUILD_TYPE=Debug
#release = -D CMAKE_BUILD_TYPE=Release

# Build directory and clean command
build = build/ # TODO(unassigned): make this more useful
remove-build = rm -fR $(build)

# Current common build options
upnp = -D WITH_UPNP=ON
optimize = -D WITH_OPTIMIZE=ON
hardening = -D WITH_HARDENING=ON
Expand All @@ -45,6 +68,9 @@ benchmarks = -D WITH_BENCHMARKS=ON
static = -D WITH_STATIC=ON
doxygen = -D WITH_DOXYGEN=ON

# Our base cmake command
cmake = cmake -D CMAKE_C_COMPILER=$(CC) -D CMAKE_CXX_COMPILER=$(CXX) -D KOVRI_DATA_PATH=$(data-path)

# TODO(unassigned): implement release build options
all: shared

Expand Down Expand Up @@ -86,4 +112,15 @@ clean:
fi; \
fi

.PHONY: all shared static upnp tests doxygen everything help clean
# TODO(unassigned): we need to consider using a proper autoconf configure and make install.
# For now, we'll simply (optionally) copy resources. Binaries will remain in build directory.
install-resources:
@echo "WARNING: This will overwrite all resources and configuration files"
@if [ $$FORCE_INSTALL = "yes" ]; then $(copy-resources); \
else read -r -p "Is this what you wish to do? (y/N)?: " CONTINUE; \
if [ $$CONTINUE = "y" ] || [ $$CONTINUE = "Y" ]; then $(copy-resources); \
else echo "Exiting."; exit 1; \
fi; \
fi

.PHONY: all shared static upnp tests doxygen everything help clean install-resources

0 comments on commit 8ea8276

Please sign in to comment.