# # Copyright (C) 2008-2014 Tvheadend Foundation CIC # # This file is part of Tvheadend # # Tvheadend is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Tvheadend is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Tvheadend. If not, see . # # For more details, including opportunities for alternative licensing, # please read the LICENSE file. # # ############################################################################ # ############################################################################ # Generic makefile for handling static 3rd party libraries # ############################################################################ # # Required inputs # # LIB_NAME - The name of the library used in files uploaded/downloaded # LIB_FILES - The files to be packaged # # Optional inputs # # PCLOUD_CACHE - Use cached builds from pcloud # PCLOUD_USER - The pcloud user account for uploads # PCLOUD_PASS - The pcloud password # PCLOUD_BASEDIR - The base directory for uploads # PCLOUD_HASHDIR - The public hash for the base directory for downloads # MAKEFILE ?= $(firstword $(MAKEFILE_LIST)) # ./configure override PCLOUD_CACHE ?= $(CONFIG_PCLOUD_CACHE) default: libcacheput # Setup environment for scripts export ARCH export CODENAME export ROOTDIR export BUILDDIR export LIBDIR export PCLOUD_CACHE export PCLOUD_USER export PCLOUD_PASS export PCLOUD_BASEDIR export PCLOUD_HASHDIR LIB_STATIC_STAMP := $(BUILDDIR)/$(LIB_NAME)_static_stamp define LIBCACHEGET_TIMESTAMP @touch $(LIB_STATIC_STAMP) endef # Download cache .PHONY: libcacheget libcacheget: ifeq ($(PCLOUD_CACHE),yes) @if ! test -f $(LIB_STATIC_STAMP); then\ ( $(ROOTDIR)/support/lib.sh download $(LIB_NAME) &&\ $(ROOTDIR)/support/lib.sh unpack $(LIB_NAME) ) || true;\ touch $(LIB_STATIC_STAMP);\ fi endif # Download and Upload on demand .PHONY: libcacheput libcacheput: build ifneq ($(PCLOUD_USER),) @$(ROOTDIR)/support/lib.sh upload $(LIB_NAME) $(LIB_FILES) endif # ############################################################################ # Helper routines # ############################################################################ define DOWNLOAD @mkdir -p $(LIB_ROOT)/build @if test -z "$${TVHEADEND_FILE_CACHE}"; then \ printf "WGET $(1)\n"; \ wget --no-verbose --no-check-certificate -O $(2) $(1); \ else \ file=$$(basename $(2)); \ cp "$$TVHEADEND_FILE_CACHE/$${file}" $(2); \ fi @{ \ sum=$$(sha1sum $(2) | cut -d ' ' -f 1); \ printf "SHA1SUM test '$${sum}' == '$(3)': "; \ test "y$${sum}" = "y$(3)"; \ } @echo "OK" endef define UNTAR @{ \ printf "UNTAR $(1)\n"; \ tar x -C $(LIB_ROOT) -$(2)f $(LIB_ROOT)/$(1); \ } endef define PATCH @{ \ cd $(LIB_ROOT)/$(1); \ for f in $(2); do \ p=$(ROOTDIR)/support/patches/$${f}; \ printf "PATCH $${p}\n"; \ patch -p0 -i $${p}; \ done \ } endef # ############################################################################ # Editor Configuration # # vim:sts=2:ts=2:sw=2:et! # ############################################################################