Grooming.
This commit is contained in:
parent
10f79df939
commit
5fc39246d1
134
package.mk
134
package.mk
@ -1,27 +1,45 @@
|
|||||||
# Used by default for working directory and log file names
|
# Used by default for working directory and log file names
|
||||||
gen_uuid != uuidgen
|
gen_uuid != uuidgen
|
||||||
|
|
||||||
|
Q ?= @
|
||||||
|
|
||||||
# Main configuration variables
|
# Main configuration variables
|
||||||
|
|
||||||
SLOT ?= /usr/baguette
|
SLOT ?= /usr/baguette
|
||||||
PREFIX := $(SLOT)
|
PREFIX := $(SLOT)
|
||||||
BINDIR := $(PREFIX)/bin
|
BINDIR := $(PREFIX)/bin
|
||||||
LIBDIR := $(PREFIX)/lib
|
LIBDIR := $(PREFIX)/lib
|
||||||
SHAREDIR := $(PREFIX)/share
|
SHAREDIR := $(PREFIX)/share
|
||||||
INCLUDEDIR := $(PREFIX)/include
|
INCLUDEDIR := $(PREFIX)/include
|
||||||
MANDIR := $(SHAREDIR)/man
|
MANDIR := $(SHAREDIR)/man
|
||||||
|
|
||||||
ARCH_DETECTED != uname -m
|
ARCH_DETECTED != uname -m
|
||||||
ARCH ?= $(ARCH_DETECTED)
|
ARCH ?= $(ARCH_DETECTED)
|
||||||
|
|
||||||
keep_build_env ?= false
|
CBUILD ?= $(ARCH)
|
||||||
|
CHOST ?= $(ARCH)
|
||||||
|
|
||||||
|
# pkg info
|
||||||
|
# URL
|
||||||
|
release ?= 0
|
||||||
patches ?=
|
patches ?=
|
||||||
|
|
||||||
Q ?= @
|
|
||||||
|
|
||||||
JOBS ?= 1
|
JOBS ?= 1
|
||||||
|
|
||||||
release ?= 0
|
# Variables
|
||||||
|
builddir => bdir
|
||||||
|
pkgdir => pkg_fake_root_dir
|
||||||
|
srcdir => source_directory
|
||||||
|
scripts != ls $(name).(pre|post)-(install|update|deinstall) 2>/dev/null
|
||||||
|
|
||||||
|
# Options
|
||||||
|
#chrooted ?= false
|
||||||
|
ignore_build_deps ?= false
|
||||||
|
keep_build_env ?= false
|
||||||
|
|
||||||
|
install_build_dependencies ?= check_build_dependencies
|
||||||
|
check_build_dependencies:
|
||||||
|
@echo -e "\033[1;35;47mbuild-dependencies: $(build-dependencies)\033[0m"
|
||||||
|
$(Q)[ $(ignore_build_deps) != "false" ] && echo "ignoring" || install-packages $(build-dependencies)
|
||||||
|
|
||||||
export SLOT PREFIX BINDIR LIBDIR SHAREDIR INCLUDEDIR MANDIR
|
export SLOT PREFIX BINDIR LIBDIR SHAREDIR INCLUDEDIR MANDIR
|
||||||
|
|
||||||
@ -30,24 +48,6 @@ CXX ?= clang++
|
|||||||
CFLAGS_USER ?=
|
CFLAGS_USER ?=
|
||||||
CFLAGS ?= -Os -Wall $(CFLAGS_USER)
|
CFLAGS ?= -Os -Wall $(CFLAGS_USER)
|
||||||
|
|
||||||
# Options to pass to different build operations.
|
|
||||||
CONFIGURE_OPTIONS_USER ?=
|
|
||||||
CONFIGURE_OPTIONS ?= --disable-nls --without-gettext \
|
|
||||||
--prefix=$(PREFIX) \
|
|
||||||
$(CONFIGURE_OPTIONS_USER)
|
|
||||||
|
|
||||||
MAKE_OPTIONS_USER ?=
|
|
||||||
MAKE_OPTIONS ?= CC=$(CC) CXX=$(CXX) -j$(JOBS) \
|
|
||||||
$(MAKE_OPTIONS_USER)
|
|
||||||
|
|
||||||
MAKE_INSTALL_OPTIONS_USER ?=
|
|
||||||
MAKE_INSTALL_OPTIONS ?= DESTDIR=$(pkg_fake_root_dir) \
|
|
||||||
$(MAKE_INSTALL_OPTIONS_USER)
|
|
||||||
|
|
||||||
CMAKE_OPTIONS_USER ?=
|
|
||||||
CMAKE_OPTIONS ?= -DCMAKE_INSTALL_PREFIX=$(PREFIX) \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
|
||||||
$(CMAKE_OPTIONS_USER)
|
|
||||||
|
|
||||||
tarballs_directory = /tmp/src# where to store package sources
|
tarballs_directory = /tmp/src# where to store package sources
|
||||||
repository_directory = /tmp/pkg# local package repository
|
repository_directory = /tmp/pkg# local package repository
|
||||||
@ -67,14 +67,45 @@ log_patching = >> $(log_file).patching.info 2>> $(log_file).patching.err
|
|||||||
# shortcut
|
# shortcut
|
||||||
bdir ?= $(pkg_build_dir)
|
bdir ?= $(pkg_build_dir)
|
||||||
|
|
||||||
# Automatic process of the file extension.
|
|
||||||
auto_ext != echo $(URL) | grep -oE "(zip|tar.xz|tar.bz2|tar.gz)$$"
|
download_backend ?= $(tarball)
|
||||||
|
|
||||||
|
# Steps one may override.
|
||||||
|
configure_backend ?= configure_autotools configure_cmake
|
||||||
|
build_backend ?= build_make
|
||||||
|
fake_root_install_backend ?= fake_root_install_make
|
||||||
|
create_steps ?= build-env configure build fake_root_install packages clean_working_dir
|
||||||
|
|
||||||
|
|
||||||
|
# Automatic process of the file extension (to select the extracting tool).
|
||||||
|
auto_ext != echo $(URL) | grep -oE "(zip|tar.xz|tar.bz2|tgz|tar.gz)$$"
|
||||||
ext ?= $(auto_ext)
|
ext ?= $(auto_ext)
|
||||||
|
|
||||||
|
|
||||||
PACKAGE_MANAGER ?= baguette # Available: baguette, apk
|
PACKAGE_MANAGER ?= baguette # Available: baguette, apk
|
||||||
export PACKAGE_MANAGER
|
export PACKAGE_MANAGER
|
||||||
|
|
||||||
|
|
||||||
|
# Options to pass to different build operations.
|
||||||
|
CONFIGURE_OPTIONS_USER ?=
|
||||||
|
CONFIGURE_OPTIONS ?= --disable-nls --without-gettext \
|
||||||
|
--prefix=$(PREFIX) \
|
||||||
|
$(CONFIGURE_OPTIONS_USER)
|
||||||
|
|
||||||
|
MAKE_OPTIONS_USER ?=
|
||||||
|
MAKE_OPTIONS ?= CC=$(CC) CXX=$(CXX) -j$(JOBS) \
|
||||||
|
$(MAKE_OPTIONS_USER)
|
||||||
|
|
||||||
|
MAKE_INSTALL_OPTIONS_USER ?=
|
||||||
|
MAKE_INSTALL_OPTIONS ?= DESTDIR=$(pkg_fake_root_dir) \
|
||||||
|
$(MAKE_INSTALL_OPTIONS_USER)
|
||||||
|
|
||||||
|
CMAKE_OPTIONS_USER ?=
|
||||||
|
CMAKE_OPTIONS ?= -DCMAKE_INSTALL_PREFIX=$(PREFIX) \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
$(CMAKE_OPTIONS_USER)
|
||||||
|
|
||||||
|
|
||||||
package_ext := baguette
|
package_ext := baguette
|
||||||
ifeq ($(PACKAGE_MANAGER), apk)
|
ifeq ($(PACKAGE_MANAGER), apk)
|
||||||
package_ext := apk
|
package_ext := apk
|
||||||
@ -82,13 +113,6 @@ endif
|
|||||||
|
|
||||||
download_tool ?= wget
|
download_tool ?= wget
|
||||||
|
|
||||||
# We can easily override backends.
|
|
||||||
download_backend ?= $(tarball)
|
|
||||||
configure_backend ?= configure_default_backends
|
|
||||||
build_backend ?= build_default_backends
|
|
||||||
fake_root_install_backend ?= fake_root_install_default_backends
|
|
||||||
create_steps ?= build-env configure build fake_root_install packages clean_working_dir
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Default implementations.
|
# Default implementations.
|
||||||
@ -127,11 +151,11 @@ tarball = $(tarballs_directory)/$(name)-$(version).$(ext)
|
|||||||
|
|
||||||
# Backends: ftp and wget
|
# Backends: ftp and wget
|
||||||
download_ftp:
|
download_ftp:
|
||||||
@ [ -f $(tarball) ] || echo ftp -O $(tarball) $(URL)
|
@ [ -f $(tarball) ] || echo ftp -o $(tarball) $(URL)
|
||||||
$(Q)[ -f $(tarball) ] || ftp -O $(tarball) $(URL)
|
$(Q)[ -f $(tarball) ] || ftp -o $(tarball) $(URL)
|
||||||
download_wget:
|
download_wget:
|
||||||
@ [ -f $(tarball) ] || echo wget -O $(tarball) $(URL)
|
@ [ -f $(tarball) ] || echo wget -O $(tarball) $(URL)
|
||||||
$(Q)[ -f $(tarball) ] || wget -O $(tarball) $(URL)
|
$(Q)[ -f $(tarball) ] || wget $(WGET_OPTS) -O $(tarball) $(URL)
|
||||||
|
|
||||||
# How to create the file (download).
|
# How to create the file (download).
|
||||||
$(tarball): download_$(download_tool)
|
$(tarball): download_$(download_tool)
|
||||||
@ -147,6 +171,8 @@ extract_zip:
|
|||||||
$(Q)cd $(pkg_build_par_dir) && unzip $(tarball)
|
$(Q)cd $(pkg_build_par_dir) && unzip $(tarball)
|
||||||
extract_tar.%:
|
extract_tar.%:
|
||||||
$(Q)cd $(pkg_build_par_dir) && tar xf $(tarball)
|
$(Q)cd $(pkg_build_par_dir) && tar xf $(tarball)
|
||||||
|
extract_tgz:
|
||||||
|
$(Q)cd $(pkg_build_par_dir) && tar xf $(tarball)
|
||||||
|
|
||||||
extract_backend ?= extract_$(ext)
|
extract_backend ?= extract_$(ext)
|
||||||
ifeq ($(download_backend),)
|
ifeq ($(download_backend),)
|
||||||
@ -194,7 +220,6 @@ configure_cmake:
|
|||||||
echo "no CMakeLists.txt - pass cmake backend" ; \
|
echo "no CMakeLists.txt - pass cmake backend" ; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
configure_default_backends: configure_autotools configure_cmake
|
|
||||||
configure: pre_configure $(configure_backend)
|
configure: pre_configure $(configure_backend)
|
||||||
@echo "Configure: done"
|
@echo "Configure: done"
|
||||||
|
|
||||||
@ -212,7 +237,6 @@ build_make:
|
|||||||
echo "no Makefile - pass" ; \
|
echo "no Makefile - pass" ; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
build_default_backends: build_make
|
|
||||||
build: pre_build $(build_backend)
|
build: pre_build $(build_backend)
|
||||||
@echo "Build: done"
|
@echo "Build: done"
|
||||||
|
|
||||||
@ -221,16 +245,15 @@ build: pre_build $(build_backend)
|
|||||||
#
|
#
|
||||||
|
|
||||||
fake_root_install_make:
|
fake_root_install_make:
|
||||||
$(Q)[ -f $(bdir)/Makefile ] && ( \
|
$(Q)if [ -f $(bdir)/Makefile ]; then \
|
||||||
cd $(bdir); \
|
cd $(bdir); \
|
||||||
echo `pwd` "$$ make install $(MAKE_INSTALL_OPTIONS)"; \
|
echo `pwd` "$$ make install $(MAKE_INSTALL_OPTIONS)"; \
|
||||||
echo `pwd` "$$ make install $(MAKE_INSTALL_OPTIONS)" $(log_it); \
|
echo `pwd` "$$ make install $(MAKE_INSTALL_OPTIONS)" $(log_it); \
|
||||||
make install $(MAKE_INSTALL_OPTIONS) $(log_it); \
|
make install $(MAKE_INSTALL_OPTIONS) $(log_it); \
|
||||||
) || ( \
|
else \
|
||||||
echo "no Makefile - pass" \
|
echo "no Makefile - pass" ; \
|
||||||
)
|
fi
|
||||||
|
|
||||||
fake_root_install_default_backends: fake_root_install_make
|
|
||||||
fake_root_install: create_fake_root_dir pre_fake_root_install $(fake_root_install_backend) post_fake_root_install
|
fake_root_install: create_fake_root_dir pre_fake_root_install $(fake_root_install_backend) post_fake_root_install
|
||||||
@echo "Install (fake root): done"
|
@echo "Install (fake root): done"
|
||||||
|
|
||||||
@ -260,6 +283,8 @@ extract_src_zip:
|
|||||||
$(Q)cd $(pkg_fake_root_src_dir) && unzip $(tarball)
|
$(Q)cd $(pkg_fake_root_src_dir) && unzip $(tarball)
|
||||||
extract_src_tar.%:
|
extract_src_tar.%:
|
||||||
$(Q)cd $(pkg_fake_root_src_dir) && tar xf $(tarball)
|
$(Q)cd $(pkg_fake_root_src_dir) && tar xf $(tarball)
|
||||||
|
extract_src_tgz:
|
||||||
|
$(Q)cd $(pkg_fake_root_src_dir) && tar xf $(tarball)
|
||||||
|
|
||||||
extract_src_backend = create_fake_root_src_dir extract_src_$(ext) $(package_src)
|
extract_src_backend = create_fake_root_src_dir extract_src_$(ext) $(package_src)
|
||||||
ifeq ($(download_backend),)
|
ifeq ($(download_backend),)
|
||||||
@ -271,7 +296,7 @@ package_src: $(extract_src_backend)
|
|||||||
$(package_src):
|
$(package_src):
|
||||||
@echo "Packaging $@"
|
@echo "Packaging $@"
|
||||||
$(Q)[ ! -z "$(patches)" ] && cp -v $(patches) $(pkg_fake_root_src_dir) || :
|
$(Q)[ ! -z "$(patches)" ] && cp -v $(patches) $(pkg_fake_root_src_dir) || :
|
||||||
$(Q)cd $(pkg_fake_root_src_dir) && dependencies="" conflicts="" provides="" create-package $@ $(log_it)
|
$(Q)cd $(pkg_fake_root_src_dir) && name=$(name)-src dependencies="" conflicts="" provides="" create-package $@ $(log_it)
|
||||||
|
|
||||||
package_doc = $(repository_directory)/$(ARCH)/$(name)-doc-$(version)-r$(release).$(package_ext)
|
package_doc = $(repository_directory)/$(ARCH)/$(name)-doc-$(version)-r$(release).$(package_ext)
|
||||||
package_doc: $(package_doc)
|
package_doc: $(package_doc)
|
||||||
@ -280,7 +305,7 @@ $(package_doc):
|
|||||||
$(Q)cd $(pkg_fake_root_dir) && create-split-doc $(log_it)
|
$(Q)cd $(pkg_fake_root_dir) && create-split-doc $(log_it)
|
||||||
$(Q)if [ -d "$(pkg_fake_root_doc_dir)" ] ; then \
|
$(Q)if [ -d "$(pkg_fake_root_doc_dir)" ] ; then \
|
||||||
cd $(pkg_fake_root_doc_dir) ; \
|
cd $(pkg_fake_root_doc_dir) ; \
|
||||||
dependencies="" conflicts="" provides="" create-package $@ $(log_it) ; \
|
name=$(name)-doc dependencies="" conflicts="" provides="" create-package $@ $(log_it) ; \
|
||||||
else \
|
else \
|
||||||
echo -e "\033[0;35;40m>> no '$(pkg_fake_root_doc_dir)' directory\033[0m" ; \
|
echo -e "\033[0;35;40m>> no '$(pkg_fake_root_doc_dir)' directory\033[0m" ; \
|
||||||
fi
|
fi
|
||||||
@ -292,7 +317,7 @@ $(package_man):
|
|||||||
$(Q)cd $(pkg_fake_root_dir) && create-split-man >> $(log_file).info 2>> $(log_file).err
|
$(Q)cd $(pkg_fake_root_dir) && create-split-man >> $(log_file).info 2>> $(log_file).err
|
||||||
$(Q)if [ -d "$(pkg_fake_root_man_dir)" ] ; then \
|
$(Q)if [ -d "$(pkg_fake_root_man_dir)" ] ; then \
|
||||||
cd $(pkg_fake_root_man_dir) ; \
|
cd $(pkg_fake_root_man_dir) ; \
|
||||||
dependencies="" conflicts="" provides="" create-package $@ $(log_it) ; \
|
name=$(name)-man dependencies="" conflicts="" provides="" create-package $@ $(log_it) ; \
|
||||||
else \
|
else \
|
||||||
echo -e "\033[0;35;40m>> no '$(pkg_fake_root_man_dir)' directory\033[0m" ; \
|
echo -e "\033[0;35;40m>> no '$(pkg_fake_root_man_dir)' directory\033[0m" ; \
|
||||||
fi
|
fi
|
||||||
@ -304,7 +329,7 @@ $(package_dev):
|
|||||||
$(Q)cd $(pkg_fake_root_dir) && create-split-dev >> $(log_file).info 2>> $(log_file).err
|
$(Q)cd $(pkg_fake_root_dir) && create-split-dev >> $(log_file).info 2>> $(log_file).err
|
||||||
$(Q)if [ -d "$(pkg_fake_root_dev_dir)" ] ; then \
|
$(Q)if [ -d "$(pkg_fake_root_dev_dir)" ] ; then \
|
||||||
cd $(pkg_fake_root_dev_dir) ; \
|
cd $(pkg_fake_root_dev_dir) ; \
|
||||||
dependencies="" conflicts="" provides="" create-package $@ $(log_it) ; \
|
name=$(name)-dev dependencies="" conflicts="" provides="" create-package $@ $(log_it) ; \
|
||||||
else \
|
else \
|
||||||
echo -e "\033[0;35;40m>> no '$(pkg_fake_root_dev_dir)' directory\033[0m" ; \
|
echo -e "\033[0;35;40m>> no '$(pkg_fake_root_dev_dir)' directory\033[0m" ; \
|
||||||
fi
|
fi
|
||||||
@ -316,7 +341,7 @@ $(package_libs):
|
|||||||
$(Q)cd $(pkg_fake_root_dir) && create-split-libs >> $(log_file).info 2>> $(log_file).err
|
$(Q)cd $(pkg_fake_root_dir) && create-split-libs >> $(log_file).info 2>> $(log_file).err
|
||||||
$(Q)if [ -d "$(pkg_fake_root_libs_dir)" ] ; then \
|
$(Q)if [ -d "$(pkg_fake_root_libs_dir)" ] ; then \
|
||||||
cd $(pkg_fake_root_libs_dir) ; \
|
cd $(pkg_fake_root_libs_dir) ; \
|
||||||
dependencies="" conflicts="" provides="" create-package $@ $(log_it) ; \
|
name=$(name)-libs dependencies="" conflicts="" provides="" create-package $@ $(log_it) ; \
|
||||||
else \
|
else \
|
||||||
echo -e "\033[0;35;40m>> no '$(pkg_fake_root_libs_dir)' directory\033[0m" ; \
|
echo -e "\033[0;35;40m>> no '$(pkg_fake_root_libs_dir)' directory\033[0m" ; \
|
||||||
fi
|
fi
|
||||||
@ -335,9 +360,8 @@ splits: package_src package_doc package_man package_dev package_libs
|
|||||||
# The main package is the last to be created since it includes
|
# The main package is the last to be created since it includes
|
||||||
# all content that wasn't matched by splits.
|
# all content that wasn't matched by splits.
|
||||||
packages: create_repository_dir splits package_base
|
packages: create_repository_dir splits package_base
|
||||||
@true
|
|
||||||
build-env: check_binaries download extract patching
|
build-env: check_binaries download extract patching
|
||||||
create: $(create_steps)
|
create: $(install_build_dependencies) $(create_steps)
|
||||||
|
|
||||||
include $(SYSCONF)/package.local.mk
|
include $(SYSCONF)/package.local.mk
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user