-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
294 lines (252 loc) · 11.6 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# Copyright (C) 2007 Lauri Leukkunen <[email protected]>
# Licensed under LGPL 2.1
TOPDIR = $(CURDIR)
OBJDIR = $(TOPDIR)
SRCDIR = $(TOPDIR)
VPATH = $(SRCDIR)
MACH := $(shell uname -m)
OS := $(shell uname -s)
ifeq ($(OS),Linux)
LIBSB2_LDFLAGS = -Wl,-soname=$(LIBSB2_SONAME) \
-Wl,--version-script=preload/export.map
SHLIBEXT = so
else
SHLIBEXT = dylib
endif
# pick main build bitness
ifeq ($(MACH),x86_64)
PRI_OBJDIR = obj-64
else
PRI_OBJDIR = obj-32
endif
CC = gcc
CXX = g++
LD = ld
PACKAGE_VERSION = 2.3.90
ifeq ($(shell if [ -d $(SRCDIR)/.git ]; then echo y; fi),y)
GIT_PV_COMMIT := $(shell git --git-dir=$(SRCDIR)/.git log -1 --pretty="format:%h" $(PACKAGE_VERSION) -- 2>/dev/null)
GIT_CUR_COMMIT := $(shell git --git-dir=$(SRCDIR)/.git log -1 --pretty="format:%h" HEAD -- 2>/dev/null)
GIT_MODIFIED := $(shell cd $(SRCDIR); git ls-files -m)
GIT_TAG_EXISTS := $(strip $(shell git --git-dir=$(SRCDIR)/.git tag -l $(PACKAGE_VERSION) 2>/dev/null))
ifeq ("$(GIT_TAG_EXISTS)","")
# Add -rc to version to signal that the PACKAGE_VERSION release has NOT
# been yet tagged
PACKAGE_VERSION := $(PACKAGE_VERSION)-rc
endif
ifneq ($(GIT_PV_COMMIT),$(GIT_CUR_COMMIT))
PACKAGE_VERSION := $(PACKAGE_VERSION)-$(GIT_CUR_COMMIT)
endif
ifneq ($(strip "$(GIT_MODIFIED)"),"")
PACKAGE_VERSION := $(PACKAGE_VERSION)-dirty
endif
endif
PACKAGE = "SB2"
LIBSB2_SONAME = "libsb2.so.1"
LLBUILD ?= $(SRCDIR)/llbuild
PROTOTYPEWARNINGS=-Wmissing-prototypes -Wstrict-prototypes
ifdef E
WERROR = -Wno-error
else
WERROR = -Werror
endif
# targets variable will be filled by llbuild
targets =
subdirs = preload luaif sblib pathmapping execs network rule_tree utils sb2d wrappers
-include config.mak
CFLAGS += -O2 -g -Wall -W
CFLAGS += -I$(OBJDIR)/include -I$(SRCDIR)/include
CFLAGS += -D_GNU_SOURCE=1 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1
CFLAGS += $(MACH_CFLAG)
LDFLAGS += $(MACH_CFLAG)
CXXFLAGS =
# Uncomment following two lines to activate the "processclock" reports:
#CFLAGS += -DUSE_PROCESSCLOCK
#LDFLAGS += -lrt
include $(LLBUILD)/Makefile.include
ifdef prefix
CONFIGURE_ARGS = --prefix=$(prefix)
else
CONFIGURE_ARGS =
endif
ifeq ($(MACH),x86_64)
all: multilib
else
all: regular
endif
do-all: $(targets)
.configure:
$(SRCDIR)/configure $(CONFIGURE_ARGS)
@touch .configure
.PHONY: .version
.version:
@(set -e; \
if [ -f .version ]; then \
version=$$(cat .version); \
if [ "$(PACKAGE_VERSION)" != "$$version" ]; then \
echo $(PACKAGE_VERSION) > .version; \
fi \
else \
echo $(PACKAGE_VERSION) > .version; \
fi)
include/scratchbox2_version.h: .version Makefile
echo "/* Automatically generated file. Do not edit. */" >include/scratchbox2_version.h
echo '#define SCRATCHBOX2_VERSION "'`cat .version`'"' >>include/scratchbox2_version.h
echo '#define LIBSB2_SONAME "'$(LIBSB2_SONAME)'"' >>include/scratchbox2_version.h
regular: .configure .version
@$(MAKE) -f $(SRCDIR)/Makefile --include-dir=$(SRCDIR) SRCDIR=$(SRCDIR) do-all
multilib:
@mkdir -p obj-32
@mkdir -p obj-64
@$(MAKE) MACH_CFLAG=-m32 -C obj-32 --include-dir=.. -f $(TOPDIR)/Makefile SRCDIR=$(TOPDIR) regular
@$(MAKE) MACH_CFLAG=-m64 -C obj-64 --include-dir=.. -f $(TOPDIR)/Makefile SRCDIR=$(TOPDIR) regular
gcc_bins = addr2line ar as cc c++ c++filt cpp g++ gcc gcov gdb gdbtui gprof ld nm objcopy objdump ranlib rdi-stub readelf run size strings strip
host_prefixed_gcc_bins = $(foreach v,$(gcc_bins),host-$(v))
sb2_modes = emulate tools simple accel nomap emulate+toolchain emulate+toolchain+utils \
obs-deb-install obs-deb-build \
obs-rpm-install obs-rpm-build obs-rpm-build+pp
sb2_net_modes = localhost offline online online_privatenets
tarball:
@git archive --format=tar --prefix=sbox2-$(PACKAGE_VERSION)/ $(PACKAGE_VERSION) | bzip2 >sbox2-$(PACKAGE_VERSION).tar.bz2
install-noarch: regular
$(P)INSTALL
@if [ -d $(prefix)/bin ] ; \
then echo "$(prefix)/bin present" ; \
else install -d -m 755 $(prefix)/bin ; \
fi
$(Q)install -d -m 755 $(prefix)/share/scratchbox2/lua_scripts
$(Q)install -d -m 755 $(prefix)/share/scratchbox2/modes
$(Q)(set -e; for d in $(sb2_modes); do \
install -d -m 755 $(prefix)/share/scratchbox2/modes/$$d; \
for f in $(SRCDIR)/modes/$$d/*; do \
install -c -m 644 $$f $(prefix)/share/scratchbox2/modes/$$d; \
done; \
done)
$(Q)install -d -m 755 $(prefix)/share/scratchbox2/net_rules
$(Q)(set -e; for d in $(sb2_net_modes); do \
install -d -m 755 $(prefix)/share/scratchbox2/net_rules/$$d; \
for f in $(SRCDIR)/net_rules/$$d/*; do \
install -c -m 644 $$f $(prefix)/share/scratchbox2/net_rules/$$d; \
done; \
done)
# "accel" == "devel" mode in 2.3.x:
$(Q)ln -sf accel $(prefix)/share/scratchbox2/modes/devel
# Rule libraries
$(Q)install -d -m 755 $(prefix)/share/scratchbox2/rule_lib
$(Q)install -d -m 755 $(prefix)/share/scratchbox2/rule_lib/fs_rules
$(Q)(set -e; for f in $(SRCDIR)/rule_lib/fs_rules/*; do \
install -c -m 644 $$f $(prefix)/share/scratchbox2/rule_lib/fs_rules; \
done)
# "scripts" and "wrappers" are visible to the user in some
# mapping modes, "lib" is for sb2's internal use
$(Q)install -d -m 755 $(prefix)/share/scratchbox2/lib
$(Q)install -d -m 755 $(prefix)/share/scratchbox2/scripts
$(Q)install -d -m 755 $(prefix)/share/scratchbox2/wrappers
$(Q)install -d -m 755 $(prefix)/share/scratchbox2/tests
@if [ -d $(prefix)/share/man/man1 ] ; \
then echo "$(prefix)/share/man/man1 present" ; \
else install -d -m 755 $(prefix)/share/man/man1 ; \
fi
@if [ -d $(prefix)/share/man/man7 ] ; \
then echo "$(prefix)/share/man/man7 present" ; \
else install -d -m 755 $(prefix)/share/man/man7 ; \
fi
$(Q)echo "$(PACKAGE_VERSION)" > $(prefix)/share/scratchbox2/version
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2 $(prefix)/bin/sb2
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-init $(prefix)/bin/sb2-init
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-config $(prefix)/bin/sb2-config
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-session $(prefix)/bin/sb2-session
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-build-libtool $(prefix)/bin/sb2-build-libtool
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-start-qemuserver $(prefix)/bin/sb2-start-qemuserver
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-qemu-gdbserver-prepare $(prefix)/bin/sb2-qemu-gdbserver-prepare
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-cmp-checkbuilddeps-output.pl $(prefix)/share/scratchbox2/lib/sb2-cmp-checkbuilddeps-output.pl
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-upgrade-config $(prefix)/share/scratchbox2/scripts/sb2-upgrade-config
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-parse-sb2-init-args $(prefix)/share/scratchbox2/scripts/sb2-parse-sb2-init-args
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-config-gcc-toolchain $(prefix)/share/scratchbox2/scripts/sb2-config-gcc-toolchain
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-config-debian $(prefix)/share/scratchbox2/scripts/sb2-config-debian
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-check-pkg-mappings $(prefix)/share/scratchbox2/scripts/sb2-check-pkg-mappings
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-exitreport $(prefix)/share/scratchbox2/scripts/sb2-exitreport
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-generate-locales $(prefix)/share/scratchbox2/scripts/sb2-generate-locales
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-logz $(prefix)/bin/sb2-logz
$(Q)install -c -m 644 $(SRCDIR)/lua_scripts/init*.lua $(prefix)/share/scratchbox2/lua_scripts/
$(Q)install -c -m 644 $(SRCDIR)/lua_scripts/rule_constants.lua $(prefix)/share/scratchbox2/lua_scripts/
$(Q)install -c -m 644 $(SRCDIR)/lua_scripts/exec_constants.lua $(prefix)/share/scratchbox2/lua_scripts/
$(Q)install -c -m 644 $(SRCDIR)/lua_scripts/argvenvp_gcc.lua $(prefix)/share/scratchbox2/lua_scripts/argvenvp_gcc.lua
$(Q)install -c -m 644 $(SRCDIR)/lua_scripts/argvenvp_misc.lua $(prefix)/share/scratchbox2/lua_scripts/argvenvp_misc.lua
$(Q)install -c -m 644 $(SRCDIR)/lua_scripts/create_reverse_rules.lua $(prefix)/share/scratchbox2/lua_scripts/create_reverse_rules.lua
$(Q)install -c -m 644 $(SRCDIR)/lua_scripts/argvmods_loader.lua $(prefix)/share/scratchbox2/lua_scripts/argvmods_loader.lua
$(Q)install -c -m 644 $(SRCDIR)/lua_scripts/add_rules_to_rule_tree.lua $(prefix)/share/scratchbox2/lua_scripts/add_rules_to_rule_tree.lua
$(Q)install -c -m 644 $(SRCDIR)/tests/* $(prefix)/share/scratchbox2/tests
$(Q)chmod a+x $(prefix)/share/scratchbox2/tests/run.sh
$(Q)install -c -m 644 $(SRCDIR)/docs/*.1 $(prefix)/share/man/man1
$(Q)install -c -m 644 $(OBJDIR)/preload/libsb2_interface.7 $(prefix)/share/man/man7
$(Q)rm -f $(prefix)/share/scratchbox2/host_usr
$(Q)ln -sf /usr $(prefix)/share/scratchbox2/host_usr
@# Wrappers:
$(Q)install -c -m 755 $(SRCDIR)/wrappers/deb-pkg-tools-wrapper $(prefix)/share/scratchbox2/wrappers/dpkg
$(Q)install -c -m 755 $(SRCDIR)/wrappers/deb-pkg-tools-wrapper $(prefix)/share/scratchbox2/wrappers/apt-get
$(Q)install -c -m 755 $(SRCDIR)/wrappers/ldconfig $(prefix)/share/scratchbox2/wrappers/ldconfig
$(Q)install -c -m 755 $(SRCDIR)/wrappers/texi2html $(prefix)/share/scratchbox2/wrappers/texi2html
$(Q)install -c -m 755 $(SRCDIR)/wrappers/dpkg-checkbuilddeps $(prefix)/share/scratchbox2/wrappers/dpkg-checkbuilddeps
$(Q)install -c -m 755 $(SRCDIR)/wrappers/debconf2po-update $(prefix)/share/scratchbox2/wrappers/debconf2po-update
$(Q)install -c -m 755 $(SRCDIR)/wrappers/host-gcc-tools-wrapper $(prefix)/share/scratchbox2/wrappers/host-gcc-tools-wrapper
$(Q)install -c -m 755 $(SRCDIR)/wrappers/gdb $(prefix)/share/scratchbox2/wrappers/gdb
$(Q)install -c -m 755 $(SRCDIR)/wrappers/ldd $(prefix)/share/scratchbox2/wrappers/ldd
$(Q)install -c -m 755 $(SRCDIR)/wrappers/pwd $(prefix)/share/scratchbox2/wrappers/pwd
$(Q)(set -e; cd $(prefix)/share/scratchbox2/wrappers; \
for f in $(host_prefixed_gcc_bins); do \
ln -sf host-gcc-tools-wrapper $$f; \
done)
ifeq ($(MACH),x86_64)
install: install-multilib
else
install: do-install
endif
do-install: install-noarch
$(P)INSTALL
@if [ -d $(prefix)/lib ] ; \
then echo "$(prefix)/lib present" ; \
else install -d -m 755 $(prefix)/lib ; \
fi
$(Q)install -d -m 755 $(prefix)/lib/libsb2
$(Q)install -d -m 755 $(prefix)/lib/libsb2/wrappers
$(Q)install -c -m 755 $(OBJDIR)/wrappers/fakeroot $(prefix)/lib/libsb2/wrappers/fakeroot
$(Q)install -c -m 755 $(OBJDIR)/preload/libsb2.$(SHLIBEXT) $(prefix)/lib/libsb2/libsb2.so.$(PACKAGE_VERSION)
$(Q)install -c -m 755 $(OBJDIR)/utils/sb2dctl $(prefix)/lib/libsb2/sb2dctl
$(Q)install -c -m 755 $(OBJDIR)/utils/sb2-show $(prefix)/bin/sb2-show
$(Q)install -c -m 755 $(OBJDIR)/utils/sb2-monitor $(prefix)/bin/sb2-monitor
$(Q)install -c -m 755 $(OBJDIR)/sb2d/sb2d $(prefix)/bin/sb2d
ifeq ($(OS),Linux)
$(Q)/sbin/ldconfig -n $(prefix)/lib/libsb2
endif
multilib_prefix=$(prefix)
install-multilib: multilib
@$(MAKE) -C obj-32 --include-dir=.. -f $(TOPDIR)/Makefile SRCDIR=$(TOPDIR) do-install-multilib bitness=32
@$(MAKE) -C obj-64 --include-dir=.. -f $(TOPDIR)/Makefile SRCDIR=$(TOPDIR) do-install
do-install-multilib:
$(P)INSTALL
@if [ -d $(multilib_prefix)/lib$(bitness) ] ; \
then echo "$(prefix)/lib$(bitness) present" ; \
else install -d -m 755 $(prefix)/lib$(bitness) ; \
fi
$(Q)install -d -m 755 $(multilib_prefix)/lib$(bitness)/libsb2
$(Q)install -c -m 755 preload/libsb2.$(SHLIBEXT) $(multilib_prefix)/lib$(bitness)/libsb2/libsb2.so.$(PACKAGE_VERSION)
ifeq ($(OS),Linux)
$(Q)/sbin/ldconfig -n $(multilib_prefix)/lib$(bitness)/libsb2
endif
CLEAN_FILES += $(targets) config.status config.log
superclean: clean
$(P)CLEAN
$(Q)rm -rf obj-32 obj-64 .configure-multilib .configure
$(Q)rm -rf include/config.h config.mak
clean-multilib:
$(P)CLEAN
-$(Q)$(MAKE) -C obj-32 --include-dir=.. -f $(TOPDIR)/Makefile SRCDIR=$(TOPDIR) do-clean
-$(Q)$(MAKE) -C obj-64 --include-dir=.. -f $(TOPDIR)/Makefile SRCDIR=$(TOPDIR) do-clean
ifeq ($(MACH),x86_64)
clean: clean-multilib do-clean
else
clean: do-clean
endif
do-clean:
$(P)CLEAN
$(Q)$(ll_clean)