-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
112 lines (80 loc) · 2.15 KB
/
makefile
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
#!/bin/make
MAKEFLAGS := --warn-undefined-variables --no-builtin-rules
.SHELLFLAGS := -eu -o pipefail -c
.ONESHELL:
SHELL := bash
.DEFAULT_GOAL := dist
PACKAGE := runit-user
SRCDIR = src
BUILDDIR = build
COMPDIR = $(BUILDDIR)/comp
DISTHOME = $(BUILDDIR)/dist
DISTDIR = $(DISTHOME)/$(DISTMODE)
MAKEMODULES = lib/makemodules
DISTARCH = $(DISTHOME)/$(PACKAGE)-$(PKGVER).tar
# Applications
TAR ?= tar
FIND ?= find
RSYNC ?= rsync
INSTALL ?= install
include $(MAKEMODULES)/requiredEnvCheck.make
include $(MAKEMODULES)/findutils.make
ifeq ($(wildcard $(BUILDDIR)/configure.make),)
$(error Project not configured. Run `./configure` to generate configuration)
else
include $(BUILDDIR)/configure.make
endif
src := $(call findutils_gensrclist,-type f -not -path '$(SRCDIR)/test/*')
comp := $(subst $(SRCDIR),$(COMPDIR),$(src))
# Standard targets
.SILENT .PHONY: build
build: $(comp)
echo "Built $(PACKAGE) $(PKGVER)"
.SILENT .PHONY: dist
dist: $(DISTDIR)
.SILENT .PHONY: distarch
distarch: $(DISTARCH)
.SILENT .PHONY: install
install:
echo "Installing $(PACKAGE) $(PKGVER) to $(PREFIX)"
$(RSYNC) -hr --progress $(DISTDIR) $(PREFIX)/
.SILENT .PHONY: clean
clean:
rm -rf $(BUILDDIR)
.SILENT .PHONY: mostlyclean
mostlyclean:
rm -rf $(COMPDIR) $(DISTDIR)
.SILENT .PHONY: distclean
distclean:
rm -rf $(DISTDIR)
.SILENT .PHONY: test
test:
testdist="$(DISTDIR)/test"
if ! test -d $$testdist ; then
echo "Missing distribution in $$testdist"
exit 1
fi
cd $$testdist
# start tests
# Recipes
.SILENT: $(DISTDIR)
$(DISTDIR): makefile $(BUILDDIR)/configure.make $(comp)
# Install core package components
$(INSTALL) -d $@/{$(RUNIT_USER_BINDIR),$(LIBDIR)}
$(RSYNC) -rh $(COMPDIR)/{bin,lib} $@/$(LIBDIR)/
# Install test components
ifeq ($(DISTMODE),test)
:
endif
# Install system links
$(INSTALL) -d $@/bin
ln -sf ../$(LIBDIR)/bin/runit-user $@/bin/
echo "Updated distribution in $@"
.SILENT: $(DISTARCH)
$(DISTARCH): $(DISTDIR) makefile
$(TAR) -cf $(DISTARCH) -C $< $(subst $</,,$(wildcard $</*))
echo "Created distribution archive $@"
$(COMPDIR)/%: $(BUILDDIR)/configure.spp $(SRCDIR)/%
@ echo "Compiling $@"
@ mkdir -p $(dir $@)
tools/spp $^ $@