Refactor installation
- Avoid installing files that are already installed - Use the .ext conventions for the variables names - Only create install targets for things to install - Create a new `INSTALLABLE` variable Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
parent
de73b3c76e
commit
085a0856ee
2
AUTHORS
2
AUTHORS
|
@ -1,6 +1,8 @@
|
|||
This software was brought to you by:
|
||||
|
||||
- Ben Porter <freedomben@protonmail.com>
|
||||
- Christophe de Dinechin <christophe@dinechin.org>
|
||||
- Christophe de Dinechin <ddd@bsd11-turbo>
|
||||
- Christophe de Dinechin <dinechin@redhat.com>
|
||||
|
||||
Thank you!
|
||||
|
|
23
Makefile
23
Makefile
|
@ -36,21 +36,19 @@
|
|||
|
||||
# Package description
|
||||
PACKAGE_NAME=make-it-quick
|
||||
PACKAGE_VERSION=0.2.7
|
||||
PACKAGE_VERSION=0.3.0
|
||||
PACKAGE_DESCRIPTION=A simple auto-configuring build system for C and C++ programs
|
||||
PACKAGE_URL=http://github.com/c3d/make-it-quick
|
||||
|
||||
# Things to install
|
||||
HDR_INSTALL= \
|
||||
HEADERS= \
|
||||
rules.mk \
|
||||
config.mk \
|
||||
$(wildcard config.*.mk) \
|
||||
$(MIQ_OBJDIR)config.system-setup.mk
|
||||
|
||||
PREFIX.config=$(PREFIX.share)$(PACKAGE_DIR)config/
|
||||
PACKAGE_INSTALL.lib=$(DESTDIR)$(PREFIX.config)
|
||||
LIB_INSTALL=$(wildcard config/check*.c)
|
||||
DOC_INSTALL= README.md AUTHORS NEWS
|
||||
WARE.config=$(wildcard config/check*.c)
|
||||
WARE.doc= README.md AUTHORS NEWS
|
||||
TESTS=example/
|
||||
|
||||
# Make sure we generate the config.system
|
||||
|
@ -61,22 +59,13 @@ MIQ=./
|
|||
include $(MIQ)rules.mk
|
||||
|
||||
# Install the check*.c files as data
|
||||
INSTALL.lib=$(INSTALL.data)
|
||||
INSTALL.config=$(INSTALL.data)
|
||||
|
||||
# Generation of the system setup file
|
||||
SYSTEM_SETUP= \
|
||||
$(SYSCONFIG:%=SYSCONFIG?="$(SYSCONFIG)") \
|
||||
$(PREFIX:%=PREFIX?="$(PREFIX)") \
|
||||
$(PREFIX.bin:%=PREFIX.bin?="$(PREFIX.bin)") \
|
||||
$(PREFIX.sbin:%=PREFIX.sbin?="$(PREFIX.sbin)") \
|
||||
$(PREFIX.hdr:%=PREFIX.hdr?="$(PREFIX.hdr)") \
|
||||
$(PREFIX.share:%=PREFIX.share?="$(PREFIX.share)") \
|
||||
$(PREFIX.lib:%=PREFIX.lib?="$(PREFIX.lib)") \
|
||||
$(PREFIX.dll:%=PREFIX.dll?="$(PREFIX.dll)") \
|
||||
$(PREFIX.libexec:%=PREFIX.libexec?="$(PREFIX.libexec)") \
|
||||
$(PREFIX.man:%=PREFIX.man?="$(PREFIX.man)") \
|
||||
$(PREFIX.doc:%=PREFIX.doc?="$(PREFIX.doc)") \
|
||||
$(PREFIX.var:%=PREFIX.var?="$(PREFIX.var)") \
|
||||
$(foreach i,$(INSTALLABLE),$(PREFIX.$i:%=PREFIX.$i?=$(PREFIX.$i))) \
|
||||
CONFIG_SOURCES="$(PREFIX.config)"
|
||||
|
||||
$(MIQ_OBJDIR)config.system-setup.mk:
|
||||
|
|
|
@ -47,7 +47,7 @@ EXT.obj= .obj
|
|||
|
||||
# Because of the above, we need to put the number before the extesion
|
||||
# e.g. where Linux would have libfoo.so.1.3.2, cygwin has libfoo.1.3.2.dll
|
||||
MIQ_DLLBASE= $(@:%.install_dll=%)
|
||||
MIQ_DLLBASE= $(@:%.install.dll=%)
|
||||
MIQ_DLLNAME= $(MIQ_DLLBASE:%$(EXT.dll)=%$(PRODUCTS_VERSION:%=.$(MIQ_V_VERSION))$(EXT.dll))
|
||||
MIQ_SONAME= $(MIQ_SOBASE:%$(EXT.dll)=%)$(MIQ_V_MAJOR:%=.%)$(EXT.dll)
|
||||
MIQ_SONAME_OPT= $(PRODUCTS_VERSION:%=-Wl,-soname -Wl,$(MIQ_SONAME))
|
||||
|
|
|
@ -73,12 +73,13 @@ GEN_AUTHORS= (echo "This software was brought to you by:"; \
|
|||
sed -e 's/^/- /g'; \
|
||||
echo ""; \
|
||||
echo "Thank you!")
|
||||
GEN_NEWS= grep '^$(shell git tag -n1 `git describe`)' $@ || \
|
||||
GEN_NEWS_TAG= $(shell git tag -n1 `git describe`)
|
||||
GEN_NEWS= $(GEN_NEWS_TAG:%=grep '^$(GEN_NEWS_TAG' $@ || \
|
||||
(touch $@; \
|
||||
(git tag -l $(shell git describe) -n999 ; \
|
||||
echo ""; \
|
||||
cat $@) \
|
||||
> $@.latest && mv $@.latest $@)
|
||||
> $@.latest && mv $@.latest $@))
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
|
62
config.mk
62
config.mk
|
@ -64,8 +64,36 @@ LAST_LOG?=$(LOGS)make.log
|
|||
# Stuff to clean
|
||||
TO_CLEAN= *~ *.bak
|
||||
|
||||
# Stuff to install
|
||||
TO_INSTALL=
|
||||
# Kinds of installable stuff
|
||||
INSTALLABLE= exe \
|
||||
lib \
|
||||
dll \
|
||||
header \
|
||||
share \
|
||||
license \
|
||||
man \
|
||||
doc \
|
||||
var \
|
||||
etc \
|
||||
config \
|
||||
sysconfig \
|
||||
pkgconfig
|
||||
|
||||
# Stuff to install, with one of the suffixes above
|
||||
WARE.exe?= $(MIQ_OUTEXE)
|
||||
WARE.lib?= $(MIQ_OUTLIB)
|
||||
WARE.dll?= $(MIQ_OUTDLL)
|
||||
WARE.man?= $(MANPAGES)
|
||||
WARE.header?= $(HEADERS)
|
||||
WARE.doc?= $(wildcard README*)
|
||||
WARE.license?= $(wildcard COPYING* LICENSE*)
|
||||
WARE.pkgconfig?=$(PACKAGE_NAME:%=%.pc)
|
||||
|
||||
# Where we pick up the stuff to install (default is source)
|
||||
WARE_DIR.pkgconfig?=$(MIQ_OBJDIR)
|
||||
|
||||
# Where to put system configuration files
|
||||
SYSCONFIG?=$(PREFIX.etc)
|
||||
|
||||
# Buildenv for recursive builds
|
||||
RECURSE_BUILDENV=$(BUILDENV)
|
||||
|
@ -98,7 +126,7 @@ PACKAGE_DLLS=$(MIQ_PRODDLL)
|
|||
CONFIG_SOURCES?=$(MIQ)config/
|
||||
|
||||
# Sources to reformat
|
||||
CLANG_FORMAT_SOURCES=$(SOURCES) $(HDR_INSTALL)
|
||||
CLANG_FORMAT_SOURCES=$(SOURCES) $(WARE.header)
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
@ -106,32 +134,34 @@ CLANG_FORMAT_SOURCES=$(SOURCES) $(HDR_INSTALL)
|
|||
#------------------------------------------------------------------------------
|
||||
|
||||
# Variables typically provided by configure scripts
|
||||
SYSCONFIG?=/etc/
|
||||
PREFIX?=/usr/local/
|
||||
PREFIX.bin?=$(PREFIX)bin/
|
||||
PREFIX.sbin?=$(PREFIX)sbin/
|
||||
PREFIX.lib?=$(PREFIX)lib/
|
||||
PREFIX.libexec?=$(PREFIX)libexec/
|
||||
PREFIX.exe?=$(PREFIX.bin)
|
||||
PREFIX.lib?=$(PREFIX)lib/
|
||||
PREFIX.dll?=$(PREFIX.lib)
|
||||
PREFIX.h?=$(PREFIX)include/
|
||||
PREFIX.header?=$(PREFIX)include/
|
||||
PREFIX.share?=$(PREFIX)share/
|
||||
PREFIX.man?=$(PREFIX.share)man/
|
||||
PREFIX.doc?=$(PREFIX.share)doc/
|
||||
PREFIX.license?=$(PREFIX.doc)
|
||||
PREFIX.config?=$(PREFIX.share)config/
|
||||
PREFIX.var?=$(PREFIX)var/
|
||||
PREFIX.etc?=/etc/
|
||||
PREFIX.sysconfig=$(SYSCONFIG)
|
||||
PREFIX.pkgconfig=$(PREFIX.share)pkgconfig/
|
||||
|
||||
|
||||
# Package configuration directories by default
|
||||
# The defaut is to install binaries and shared libraries in the prefix
|
||||
# but to install headers and data items under a directory named after project
|
||||
PACKAGE_INSTALL?=$(DESTDIR)$(PREFIX)
|
||||
PACKAGE_INSTALL.bin?=$(DESTDIR)$(PREFIX.bin)
|
||||
PACKAGE_INSTALL.lib?=$(DESTDIR)$(PREFIX.lib)
|
||||
PACKAGE_INSTALL.dll?=$(DESTDIR)$(PREFIX.dll)
|
||||
PACKAGE_INSTALL.h?=$(DESTDIR)$(PREFIX.h)$(PACKAGE_DIR)
|
||||
PACKAGE_INSTALL.share?=$(DESTDIR)$(PREFIX.share)$(PACKAGE_DIR)
|
||||
PACKAGE_INSTALL.man?=$(DESTDIR)$(PREFIX.man)
|
||||
PACKAGE_INSTALL.doc?=$(DESTDIR)$(PREFIX.doc)$(PACKAGE_DIR)
|
||||
PACKAGE_INSTALL.pkgconfig?=$(DESTDIR)$(PREFIX.share)pkgconfig/
|
||||
PACKAGE_INSTALL.sysconfig?=$(DESTDIR)$(SYSCONFIG)$(PACKAGE_DIR)
|
||||
define package-install
|
||||
|
||||
PACKAGE_INSTALL.$1?=$$(DESTDIR)$$(PREFIX.$1)
|
||||
|
||||
endef
|
||||
$(eval $(foreach i,$(INSTALLABLE),$(call package-install,$i)))
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
|
90
rules.mk
90
rules.mk
|
@ -88,21 +88,8 @@ MIQ_LDFLAGS= $(LDFLAGS) \
|
|||
|
||||
MIQ_PACKAGE= $(PACKAGE_NAME:%=$(MIQ_OBJDIR)%.pc)
|
||||
|
||||
MIQ_INSTALL= $(TO_INSTALL:%=%.$(DO_INSTALL)) \
|
||||
$(MIQ_OUTEXE:%=%.$(DO_INSTALL)_exe) \
|
||||
$(MIQ_OUTLIB:%=%.$(DO_INSTALL)_lib) \
|
||||
$(MIQ_OUTDLL:%=%.$(DO_INSTALL)_dll) \
|
||||
$(EXE_INSTALL:%=%.$(DO_INSTALL)_exe) \
|
||||
$(LIB_INSTALL:%=%.$(DO_INSTALL)_lib) \
|
||||
$(DLL_INSTALL:%=%.$(DO_INSTALL)_dll) \
|
||||
$(HEADERS:%=%.$(DO_INSTALL)_hdr) \
|
||||
$(HDR_INSTALL:%=%.$(DO_INSTALL)_hdr) \
|
||||
$(SHR_INSTALL:%=%.$(DO_INSTALL)_shr) \
|
||||
$(DOC_INSTALL:%=%.$(DO_INSTALL)_doc) \
|
||||
$(MANPAGES:%=%.gz.$(DO_INSTALL)_man) \
|
||||
$(MAN_INSTALL:%=%.gz.$(DO_INSTALL)_man) \
|
||||
$(ETC_INSTALL:%=%.$(DO_INSTALL)_etc) \
|
||||
$(MIQ_PACKAGE:%=%.$(DO_INSTALL)_pc)
|
||||
MIQ_DOINSTALL= $(foreach i,$(INSTALLABLE),$(WARE.$i:%=%.$(DO_INSTALL).$i))
|
||||
MIQ_INSTALL= $(DO_INSTALL:%=$(MIQ_DOINSTALL))
|
||||
|
||||
MIQ_SOURCES= $(SOURCES) \
|
||||
$(SOURCES_BUILDENV_$(BUILDENV)) \
|
||||
|
@ -212,6 +199,7 @@ rebuild: re-$(TARGET)
|
|||
# Installation
|
||||
install: install-$(TARGET)
|
||||
uninstall: uninstall-$(TARGET)
|
||||
reinstall: reinstall-$(TARGET)
|
||||
|
||||
clean: $(SUBDIRS:%=%.clean) $(VARIANTS:%=%.variant-clean)
|
||||
-$(PRINT_CLEAN) rm -f $(TO_CLEAN) $(MIQ_OBJECTS) $(DEPENDENCIES) $(MIQ_OUTPRODS) $(MIQ_TOLINK) config.h
|
||||
|
@ -280,7 +268,7 @@ endif
|
|||
.objects: $(MIQ_OBJDIR:%=%.mkdir)
|
||||
.product: $(MIQ_OUTPRODS)
|
||||
.postbuild: .product .install
|
||||
.install: $(DO_INSTALL:%=$(MIQ_INSTALL))
|
||||
.install: $(MIQ_INSTALL)
|
||||
.tests: $(TESTS:%=%.test)
|
||||
.goodbye: .postbuild
|
||||
|
||||
|
@ -328,6 +316,8 @@ install-%:
|
|||
$(PRINT_COMMAND) $(MAKE) $* DO_INSTALL=install
|
||||
uninstall-%:
|
||||
$(PRINT_COMMAND) $(MAKE) TARGET=$* DO_INSTALL=uninstall .install
|
||||
reinstall-%:
|
||||
$(PRINT_COMMAND) $(MAKE) TARGET=$* DO_INSTALL=reinstall .install
|
||||
|
||||
# Deep build (re-check all libraries instead of just resulting .a)
|
||||
deep-%:
|
||||
|
@ -392,7 +382,7 @@ PRINT_COMPILE= $(PRINT_COMMAND) $(INFO) "[COMPILE$(MIQ_PRINTCOUNT)] " $<;
|
|||
PRINT_LINK= $(PRINT_COMMAND) $(INFO) "[LINK]" $(shell basename $@);
|
||||
PRINT_GENERATE= $(PRINT_COMMAND) $(INFO) "[GENERATE]" "$(shell basename "$@")" $(COLORIZE);
|
||||
PRINT_VARIANT= $(PRINT_COMMAND) $(INFO) "[VARIANT]" "$*";
|
||||
PRINT_INSTALL= $(PRINT_COMMAND) $(INFO) "[INSTALL]" "$(*F) in $(<D)" $(COLORIZE);
|
||||
PRINT_INSTALL= $(PRINT_COMMAND) $(INFO) "[INSTALL]" "$(@F) => $(@D)/" $(COLORIZE);
|
||||
PRINT_UNINSTALL=$(PRINT_COMMAND) $(INFO) "[UNINSTALL] " "$(*F)" $(COLORIZE);
|
||||
PRINT_CLEAN= $(PRINT_COMMAND) $(INFO) "[CLEAN] " "$@ $(MIQ_PRETTYDIR)" $(COLORIZE);
|
||||
PRINT_COPY= $(PRINT_COMMAND) $(INFO) "[COPY]" "$< '=>' $@" ;
|
||||
|
@ -637,50 +627,28 @@ benchmark: $(BENCHMARKS:%=%.benchmark)
|
|||
# Install targets
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Installing the product: always need to build it first
|
||||
%.install: $(PACKAGE_INSTALL).mkdir-only %
|
||||
$(PRINT_INSTALL) $(INSTALL.data) $* $(PACKAGE_INSTALL)
|
||||
%.install_exe: $(PACKAGE_INSTALL.bin).mkdir-only %
|
||||
$(PRINT_INSTALL) $(INSTALL.bin) $* $(PACKAGE_INSTALL.bin)
|
||||
%.install_lib: $(PACKAGE_INSTALL.lib).mkdir-only %
|
||||
$(PRINT_INSTALL) $(INSTALL.lib) $* $(PACKAGE_INSTALL.lib)
|
||||
%.install_dll: $(PACKAGE_INSTALL.dll).mkdir-only %
|
||||
$(PRINT_INSTALL) $(INSTALL.dll)
|
||||
%.install_hdr: $(PACKAGE_INSTALL.h).mkdir-only %
|
||||
$(PRINT_INSTALL) $(INSTALL.h) $* $(PACKAGE_INSTALL.h)
|
||||
%.install_shr: $(PACKAGE_INSTALL.share).mkdir-only %
|
||||
$(PRINT_INSTALL) $(INSTALL.share) $* $(PACKAGE_INSTALL.share)
|
||||
%.install_man: $(PACKAGE_INSTALL.man).mkdir-only %
|
||||
$(PRINT_COMMAND) $(MKDIR) -p $(MIQ_MANDIR)
|
||||
$(PRINT_INSTALL) $(INSTALL.man) $* $(MIQ_MANDIR)
|
||||
%.install_doc: $(PACKAGE_INSTALL.doc).mkdir-only %
|
||||
$(PRINT_INSTALL) $(INSTALL.doc) $* $(PACKAGE_INSTALL.doc)
|
||||
%.install_etc: $(PACKAGE_INSTALL.sysconfig).mkdir-only %
|
||||
$(PRINT_INSTALL) $(INSTALL.etc) $* $(PACKAGE_INSTALL.sysconfig)
|
||||
%.install_pc: $(PACKAGE_INSTALL.pkgconfig).mkdir-only %
|
||||
$(PRINT_INSTALL) $(INSTALL.data) $* $(PACKAGE_INSTALL.pkgconfig)
|
||||
# Helper macro:
|
||||
# $1: install pattern
|
||||
# $2: what to install
|
||||
define install-rules
|
||||
|
||||
# Uninstalling the product
|
||||
%.uninstall:
|
||||
$(PRINT_UNINSTALL) $(UNINSTALL) $(*F:%=$(PACKAGE_INSTALL)%) ; $(UNINSTALL.dir) $(PACKAGE_INSTALL) $(UNINSTALL.ok)
|
||||
%.uninstall_exe:
|
||||
$(PRINT_UNINSTALL) $(UNINSTALL) $(*F:%=$(PACKAGE_INSTALL.bin)%) ; $(UNINSTALL.dir) $(PACKAGE_INSTALL.bin) $(UNINSTALL.ok)
|
||||
%.uninstall_lib:
|
||||
$(PRINT_UNINSTALL) $(UNINSTALL) $(*F:%=$(PACKAGE_INSTALL.lib)%) ; $(UNINSTALL.dir) $(PACKAGE_INSTALL.lib) $(UNINSTALL.ok)
|
||||
%.uninstall_dll:
|
||||
$(PRINT_UNINSTALL) $(UNINSTALL) $(*F:%=$(PACKAGE_INSTALL.dll)%) ; $(UNINSTALL.dir) $(PACKAGE_INSTALL.dll) $(UNINSTALL.ok)
|
||||
%.uninstall_hdr:
|
||||
$(PRINT_UNINSTALL) $(UNINSTALL) $(*F:%=$(PACKAGE_INSTALL.h)%) ; $(UNINSTALL.dir) $(PACKAGE_INSTALL.h) $(UNINSTALL.ok)
|
||||
%.uninstall_shr:
|
||||
$(PRINT_UNINSTALL) $(UNINSTALL) $(*F:%=$(PACKAGE_INSTALL.share)%) ; $(UNINSTALL.dir) $(PACKAGE_INSTALL.share) $(UNINSTALL.ok)
|
||||
%.uninstall_doc:
|
||||
$(PRINT_UNINSTALL) $(UNINSTALL) $(*F:%=$(PACKAGE_INSTALL.doc)%) ; $(UNINSTALL.dir) $(PACKAGE_INSTALL.doc) $(UNINSTALL.ok)
|
||||
%.uninstall_man:
|
||||
$(PRINT_UNINSTALL) $(UNINSTALL) $(*F:%=$(PACKAGE_INSTALL.man)%)
|
||||
%.uninstall_etc:
|
||||
$(PRINT_UNINSTALL) $(UNINSTALL) $(*F:%=$(PACKAGE_INSTALL.sysconfig)%)
|
||||
%.uninstall_pc:
|
||||
$(PRINT_UNINSTALL) $(UNINSTALL) $(*F:%=$(PACKAGE_INSTALL.pkgconfig)%) ; $(UNINSTALL.dir) $(PACKAGE_INSTALL.pkgconfig) $(UNINSTALL.ok)
|
||||
$2.install.$1: $$(PACKAGE_INSTALL.$1)$(notdir $2)
|
||||
$$(PACKAGE_INSTALL.$1)$(notdir $2): $$(WARE_DIR.$1)$2 | .install-directories
|
||||
$$(PRINT_INSTALL) $$(firstword $$(INSTALL.$1) $$(INSTALL)) $$(WARE_DIR.$1)$2 $$(PACKAGE_INSTALL.$1)
|
||||
|
||||
$2.uninstall.$1:
|
||||
$$(PRINT_UNINSTALL) $$(firstword $$(UNINSTALL.$1) $$(UNINSTALL)) $$(PACKAGE_INSTALL.$1)$2; $$(UNINSTALL.dir) $$(PACKAGE_INSTALL.$1) $$(UNINSTALL.ok)
|
||||
|
||||
$2.reinstall: $2 $$(PACKAGE_INSTALL.$1).mkdir-only
|
||||
$$(PRINT_INSTALL) $$(firstword $$(INSTALL.$1) $$(INSTALL)) $2 $$(PACKAGE_INSTALL.$1)
|
||||
|
||||
.install-directories: $$(PACKAGE_INSTALL.$1).mkdir-only
|
||||
|
||||
endef
|
||||
|
||||
# Generate rules for all the installable stuff
|
||||
$(eval $(foreach i,$(INSTALLABLE),$(foreach w,$(WARE.$i),$(call install-rules,$i,$w))))
|
||||
.install: .install-directories
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
@ -698,7 +666,7 @@ MIQ_GENPC= \
|
|||
(echo 'prefix=$(PREFIX.bin)' ;\
|
||||
echo 'exec_prefix=$${prefix}' ;\
|
||||
echo 'libdir=$(PREFIX.lib)' ;\
|
||||
echo 'includedir=$(PREFIX.h)' ;\
|
||||
echo 'includedir=$(PREFIX.header)' ;\
|
||||
echo 'Name: $(PACKAGE_NAME)' ;\
|
||||
echo 'Description: $(PACKAGE_DESCRIPTION)' ;\
|
||||
echo 'Version: $(PACKAGE_VERSION)' ;\
|
||||
|
|
Loading…
Reference in New Issue