1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
# Copyright 2019-2021 Zygmunt Krynicki.
#
# This file is part of zmk.
#
# Zmk is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3 as
# published by the Free Software Foundation.
#
# Zmk 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Zmk. If not, see <https://www.gnu.org/licenses/>.
NAME = zmk
VERSION = 0.5.1 # This needs to match ZMK.Version
ZMK.SrcDir ?= .
-include config.zmk.mk
ZMK.Path = $(ZMK.SrcDir)
include $(ZMK.Path)/z.mk
# Manual pages present in the package.
ZMK.manPages = \
z.mk.5 \
zmk.AllClean.5 \
zmk.Configure.5 \
zmk.Coverity.5 \
zmk.Directories.5 \
zmk.Library.A.5 \
zmk.Library.DyLib.5 \
zmk.Library.So.5 \
zmk.OS.5 \
zmk.Program.5 \
zmk.Script.5 \
zmk.Silent.5 \
zmk.Symlink.5 \
zmk.Toolchain.5
# Use git to augment version.
$(eval $(call ZMK.Import,GitVersion))
$(eval $(call ZMK.Import,Directories))
$(eval $(call ZMK.Import,Configure))
# Install all of zmk to the sub-directory in the include directory.
# Except for z.mk itself, which should live there directly.
$(foreach f,$(ZMK.DistFiles),$(eval $f.InstallDir=$(includedir)/zmk))
z.mk.InstallDir=$(includedir)
$(foreach f,$(ZMK.DistFiles),$(eval $(call ZMK.Expand,InstallUninstall,$f)))
# Install all of the manual pages, generating them from .in files first.
all:: $(foreach f,$(ZMK.manPages),man/$f)
clean::
$(call Silent.Say,RM,$(addprefix man/,$(ZMK.manPages)))
$(Silent.Command)rm -f $(addprefix man/,$(ZMK.manPages))
ifneq ($(ZMK.SrcDir),.)
$(Silent.Command)test -d man && rmdir man || :
endif
$(CURDIR)/man: # For out-of-tree builds.
$(Silent.Command)install -d $@
man/%: man/%.in | $(CURDIR)/man
$(call Silent.Say,SED,$@)
$(Silent.Command)sed -e 's/@VERSION@/$(VERSION)/g' $< >$@
$(foreach f,$(ZMK.manPages),$(eval $(call ZMK.Expand,ManPage,man/$f)))
# Build the release tarball.
ZMK.releaseArchive?=$(NAME)-$(VERSION).tar.gz
$(ZMK.releaseArchive).Files = GNUmakefile README.md LICENSE NEWS
$(ZMK.releaseArchive).Files += $(addsuffix .in,$(addprefix man/,$(ZMK.manPages)))
$(ZMK.releaseArchive).Files += $(addprefix examples/hello-c/,Makefile Test.mk hello.c)
$(ZMK.releaseArchive).Files += $(addprefix examples/hello-cpp/,Makefile Test.mk hello.cpp)
$(ZMK.releaseArchive).Files += $(addprefix examples/hello-objc/,Makefile Test.mk hello.m README.txt)
$(ZMK.releaseArchive).Files += $(addprefix examples/libhello-c/,Makefile Test.mk hello.c hello.h)
$(ZMK.releaseArchive).Files += $(addprefix examples/libhello-cpp/,Makefile Test.mk hello.cpp hello.h)
$(ZMK.releaseArchive).Files += $(addprefix examples/libhello-objc/,Makefile Test.mk hello.m hello.h)
$(ZMK.releaseArchive).Files += $(addprefix examples/script/,Makefile Test.mk hello.sh)
$(ZMK.releaseArchive).Files += $(addprefix examples/true_false/,Makefile Test.mk true_false.c README.txt)
$(ZMK.releaseArchive).Files += $(addprefix tests/Configure/,Makefile Test.mk integration/Makefile integration/Test.mk)
$(ZMK.releaseArchive).Files += $(addprefix tests/Directories/,Makefile Test.mk)
$(ZMK.releaseArchive).Files += $(addprefix tests/Directory/,Makefile Test.mk)
$(ZMK.releaseArchive).Files += $(addprefix tests/Header/,Makefile Test.mk foo.h include/bar.h froz.h)
$(ZMK.releaseArchive).Files += $(addprefix tests/HeaderGroup/,Makefile Test.mk foo.h bar.h froz.h)
$(ZMK.releaseArchive).Files += $(addprefix tests/Library.A/,Makefile Test.mk foo.c)
$(ZMK.releaseArchive).Files += $(addprefix tests/Library.DyLib/,Makefile Test.mk foo.c bar.c)
$(ZMK.releaseArchive).Files += $(addprefix tests/Library.So/,Makefile Test.mk foo.c bar.c)
$(ZMK.releaseArchive).Files += $(addprefix tests/ManPage/,Makefile Test.mk foo.1 foo.2 foo.3 foo.4 foo.5 foo.6 foo.7 foo.8 foo.9 man/bar.1 man/bar.2 man/bar.3 man/bar.4 man/bar.5 man/bar.6 man/bar.7 man/bar.8 man/bar.9)
$(ZMK.releaseArchive).Files += $(addprefix tests/ObjectGroup/,Makefile Test.mk main.c main.cpp main.m main.cxx main.cc src/main.c)
$(ZMK.releaseArchive).Files += $(addprefix tests/OS/,Makefile Test.mk)
$(ZMK.releaseArchive).Files += $(addprefix tests/Program/,Makefile Test.mk main.c main.cpp main.m main.cxx main.cc src/main.c)
$(ZMK.releaseArchive).Files += $(addprefix tests/Symlink/,Makefile Test.mk)
$(ZMK.releaseArchive).Files += $(addprefix tests/Tarball.Src/,Makefile Test.mk foo.txt home/alice/.gnupg/fake-gpg-data home/bob/.gitkeep home/eve/.gnupg/fake-gpg-data)
$(ZMK.releaseArchive).Files += $(addprefix tests/Toolchain/,Makefile Test.mk integration/Makefile integration/Test.mk)
$(ZMK.releaseArchive).Files += $(addprefix tests/Target.distclean/,Makefile Test.mk)
$(ZMK.releaseArchive).Files += $(addprefix tests/Target.check/,Makefile Test.mk)
$(ZMK.releaseArchive).Files += tests/bin/GREP
$(eval $(call ZMK.Expand,Tarball.Src,$(ZMK.releaseArchive)))
check:: check-unit
# Some hackery is performed to map slashes to dashes, except in "(lib)?hello-".
tests = $(patsubst -%-,%,$(subst /,-,$(subst $(ZMK.SrcDir)/,/,$(dir $(shell find $(ZMK.SrcDir) -name Test.mk)))))
.PHONY: check-unit
check-unit: $(addprefix check-,$(tests))
.PHONY: $(addprefix check-,$(tests))
check-%: ZMK.testDir=$(patsubst examples/libhello/%,examples/libhello-%,$(patsubst examples/hello/%,examples/hello-%,$(subst -,/,$*)))
$(addprefix check-,$(tests)): check-%:
$(call Silent.Say,MAKE-TEST,$(ZMK.testDir))
ifeq ($(ZMK.IsOutOfTreeBuild),yes)
$(Silent.Command)mkdir -p $(ZMK.testDir)
$(Silent.Command)$(strip $(MAKE) \
--warn-undefined-variables \
ZMK.test.SrcDir=$(ZMK.SrcDir)/$(ZMK.testDir) \
-I $(abspath $(ZMK.Path)) \
-C $(ZMK.testDir) \
-f $(ZMK.SrcDir)/$(ZMK.testDir)/Test.mk)
else
$(Silent.Command)$(strip $(MAKE) \
--warn-undefined-variables \
-I $(abspath $(ZMK.Path)) \
-C $(ZMK.testDir) \
-f Test.mk)
endif
hack:
sudo ln -s $(abspath $(ZMK.OutOfTreeSourcePath)z.mk) $(includedir)/z.mk
sudo ln -s $(abspath $(ZMK.OutOfTreeSourcePath)zmk) $(includedir)/zmk
|