forked from TritonDataCenter/smartos-live
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
201 lines (164 loc) · 5.46 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#
# Copyright (c) 2012, Joyent, Inc. All rights reserved.
#
ROOT = $(PWD)
PROTO = $(ROOT)/proto
STRAP_PROTO = $(ROOT)/proto.strap
MPROTO = $(ROOT)/manifest.d
ifeq ($(shell uname -s),Darwin)
PATH = /bin:/usr/bin:/usr/sbin:/sbin:/opt/local/bin
else
PATH = /usr/bin:/usr/sbin:/sbin:/opt/local/bin
endif
LOCAL_SUBDIRS := $(shell ls projects/local)
OVERLAYS := $(shell cat overlay/order)
MANIFEST = manifest.gen
JSSTYLE = $(ROOT)/tools/jsstyle/jsstyle
JSLINT = $(ROOT)/tools/javascriptlint/build/install/jsl
CSTYLE = $(ROOT)/tools/cstyle
ADJUNCT_TARBALL := $(shell ls `pwd`/illumos-adjunct*.tgz 2>/dev/null \
| tail -n1 && echo $?)
STAMPFILE := $(ROOT)/proto/buildstamp
WORLD_MANIFESTS := \
$(MPROTO)/illumos.manifest \
$(MPROTO)/live.manifest \
$(MPROTO)/illumos-extra.manifest
SUBDIR_MANIFESTS := $(LOCAL_SUBDIRS:%=$(MPROTO)/%.sd.manifest)
OVERLAY_MANIFESTS := $(OVERLAYS:$(ROOT)/overlay/%=$(MPROTO)/%.ov.manifest)
world: 0-extra-stamp 0-illumos-stamp 1-extra-stamp 0-livesrc-stamp \
0-local-stamp 0-tools-stamp 0-man-stamp 0-devpro-stamp
live: world manifest
@echo $(OVERLAY_MANIFESTS)
@echo $(SUBDIR_MANIFESTS)
mkdir -p ${ROOT}/log
(cd $(ROOT) && \
pfexec ./tools/build_live $(ROOT)/$(MANIFEST) $(ROOT)/output \
$(OVERLAYS) $(ROOT)/proto $(ROOT)/man/man)
#
# Manifest construction. There are 5 sources for manifests we need to collect
# in $(MPROTO) before running the manifest tool. One each comes from
# illumos, illumos-extra, and the root of live (covering mainly what's in src).
# Additional manifests come from each of $(LOCAL_SUBDIRS), which may choose
# to construct them programmatically, and $(OVERLAYS), which must be static.
# These all end up in $(MPROTO), where we tell tools/build_manifest to look;
# it will pick up every file in that directory and treat it as a manifest.
#
# Look ma, no for loops in these shell fragments!
#
manifest: $(MANIFEST)
$(MPROTO):
mkdir -p $(MPROTO)
$(MPROTO)/live.manifest: $(MPROTO) src/manifest
gmake DESTDIR=$(MPROTO) DESTNAME=live.manifest \
-C src manifest
$(MPROTO)/illumos.manifest: $(MPROTO) projects/illumos/manifest
cp projects/illumos/manifest $(MPROTO)/illumos.manifest
$(MPROTO)/illumos-extra.manifest: $(MPROTO) 1-extra-stamp
gmake DESTDIR=$(MPROTO) DESTNAME=illumos-extra.manifest \
-C projects/illumos-extra manifest; \
.PHONY: $(MPROTO)/%.sd.manifest
$(MPROTO)/%.sd.manifest:
cd $(ROOT)/projects/local/$* && \
if [[ -f Makefile.joyent ]]; then \
gmake DESTDIR=$(MPROTO) DESTNAME=$*.sd.manifest \
-f Makefile.joyent manifest; \
else \
gmake DESTDIR=$(MPROTO) DESTNAME=$*.sd.manifest \
manifest; \
fi
$(MPROTO)/%.ov.manifest: $(MPROTO) $(ROOT)/overlay/%/manifest
cp $(ROOT)/overlay/$*/manifest $@
$(MANIFEST): $(WORLD_MANIFESTS) $(SUBDIR_MANIFESTS) $(OVERLAY_MANIFESTS)
-rm -f $(MANIFEST)
./tools/build_manifest
./tools/sorter manifest.gen > manifest.gen.sorted && \
mv manifest.gen.sorted $@
#
# Update source code from parent repositories. We do this for each local
# project as well as for illumos, illumos-extra, and illumos-live via the
# update_base tool.
#
update: update-base $(LOCAL_SUBDIRS:%=%.update)
-rm -f 0-local-stamp
.PHONY: update-base
update-base:
./tools/update_base
.PHONY: %.update
%.update:
cd $(ROOT)/projects/local/$* && \
if [[ -f Makefile.joyent ]]; then \
gmake -f Makefile.joyent update; \
else \
gmake update; \
fi
-rm -f 0-subdir-$*-stamp
0-local-stamp: $(LOCAL_SUBDIRS:%=0-subdir-%-stamp)
touch $@
0-subdir-%-stamp:
cd "$(ROOT)/projects/local/$*" && \
if [[ -f Makefile.joyent ]]; then \
gmake -f Makefile.joyent DESTDIR=$(PROTO) world install; \
else \
gmake DESTDIR=$(PROTO) world install; \
fi
touch $@
0-devpro-stamp:
[ ! -d projects/devpro ] || \
(cd projects/devpro && gmake DESTDIR=$(PROTO) install)
touch $@
0-illumos-stamp: 0-extra-stamp
(cd $(ROOT) && ./tools/build_illumos)
touch $@
0-extra-stamp:
(cd $(ROOT)/projects/illumos-extra && \
gmake STRAP=strap DESTDIR=$(STRAP_PROTO) install_strap)
(cd $(STRAP_PROTO) && gtar xzf $(ADJUNCT_TARBALL))
touch $@
1-extra-stamp: 0-illumos-stamp
(cd $(ROOT)/projects/illumos-extra && \
gmake DESTDIR=$(PROTO) install)
touch $@
0-livesrc-stamp: src/bootparams.c
(cd $(ROOT)/src && \
gmake DESTDIR=$(PROTO) && \
gmake DESTDIR=$(PROTO) install)
touch $@
0-man-stamp:
(cd $(ROOT)/man/src && gmake clean && gmake)
touch $@
0-tools-stamp: 0-builder-stamp 0-pwgen-stamp tools/cryptpass
(cp ${ROOT}/tools/cryptpass $(PROTO)/usr/lib)
touch $@
0-builder-stamp:
(cd $(ROOT)/tools/builder && gmake builder)
touch $@
0-pwgen-stamp:
(cd ${ROOT}/tools/pwgen-* && autoconf && ./configure && \
make && cp pwgen ${ROOT}/tools)
touch $@
tools/cryptpass: tools/cryptpass.c
(cd ${ROOT}/tools && gcc -Wall -W -O2 -o cryptpass cryptpass.c)
jsl: $(JSLINT)
$(JSLINT):
@(cd $(ROOT)/tools/javascriptlint; make CC=gcc install)
check: $(JSLINT)
@(cd $(ROOT)/src && make check)
clean:
rm -f $(MANIFEST)
rm -rf $(ROOT)/$(MPROTO)/*
(cd $(ROOT)/src && gmake clean)
[ ! -d $(ROOT)/projects/illumos-extra ] || \
(cd $(ROOT)/projects/illumos-extra && gmake clean)
[ ! -d projects/local ] || for dir in $(LOCAL_SUBDIRS); do \
cd $(ROOT)/projects/local/$${dir} && \
if [[ -f Makefile.joyent ]]; then \
gmake -f Makefile.joyent clean; \
else \
gmake clean; \
fi; \
done
(cd $(ROOT) && rm -rf $(PROTO))
(cd $(ROOT) && rm -rf $(STRAP_PROTO))
(cd $(ROOT) && mkdir -p $(PROTO) $(STRAP_PROTO))
rm -f 0-*-stamp 1-*-stamp
.PHONY: manifest check jsl