summaryrefslogtreecommitdiff
path: root/Makefile
blob: 0910fef367c695b5e74a40488d45fc46076e94d6 (plain)
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
# Copyright (C) 2007 Lauri Leukkunen <lle@rahina.org>
# Licensed under LGPL 2.1

TOPDIR = $(CURDIR)
OBJDIR = $(TOPDIR)
SRCDIR = $(TOPDIR)
VPATH = $(SRCDIR)


ifeq ($(MAKECMDGOALS),install-multilib)
BUILD_TARGET=multilib
else
BUILD_TARGET=$(targets)
endif

ifeq ($(shell uname -m),x86_64)
PRI_OBJDIR = obj-64
else
PRI_OBJDIR = obj-32
endif


CC = gcc
CXX = g++
LD = ld
PACKAGE_VERSION = "1.99.0.25"
PACKAGE = "SB2"
LIBSB2_SONAME = "libsb2.so.1"
LLBUILD ?= $(SRCDIR)/llbuild
PROTOTYPEWARNINGS=-Wmissing-prototypes -Wstrict-prototypes


# targets variable will be filled by llbuild
targets = 
subdirs = luaif preload utils

-include config.mak

CFLAGS += -O2 -g -Wall -W
CFLAGS += -I$(OBJDIR)/include -I$(SRCDIR)/include
CFLAGS += -I$(SRCDIR)/luaif/lua-5.1.2/src
CFLAGS += -D_GNU_SOURCE=1 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1
CFLAGS += -DSCRATCHBOX_ROOT="$(prefix)"
CXXFLAGS = 

include $(LLBUILD)/Makefile.include

export CC CFLAGS LDFLAGS CXX CXXFLAGS TOPDIR LLBUILD

ifdef prefix
CONFIGURE_ARGS = --prefix=$(prefix)
else
CONFIGURE_ARGS = 
endif


all: $(targets)

.configure-multilib:
	rm -rf obj-32 obj-64
	mkdir -p obj-32
	mkdir -p obj-64
	cd obj-32 && \
	CFLAGS=-m32 LDFLAGS=-m32 ../configure $(CONFIGURE_ARGS)
	cd obj-64 && \
	CFLAGS=-m64 LDFLAGS=-m64 ../configure $(CONFIGURE_ARGS)
	touch .configure-multilib

multilib: .configure-multilib
	$(MAKE) -C obj-32 --include-dir=.. -f ../Makefile SRCDIR=..
	$(MAKE) -C obj-64 --include-dir=.. -f ../Makefile SRCDIR=..


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
gcc_bins_expanded = $(foreach v,$(gcc_bins),$(prefix)/bin/host-$(v))


sources-release:
	git archive --format=tar --prefix=sbox2-$(PACKAGE_VERSION)/ $(PACKAGE_VERSION) | bzip2 >sbox2-$(PACKAGE_VERSION).tar.bz2


install-noarch: $(BUILD_TARGET)
	install -d -m 755 $(prefix)/bin
	install -d -m 755 $(prefix)/share/scratchbox2/lua_scripts
	install -d -m 755 $(prefix)/share/scratchbox2/lua_scripts/pathmaps
	install -d -m 755 $(prefix)/share/scratchbox2/lua_scripts/pathmaps/emulate
	install -d -m 755 $(prefix)/share/scratchbox2/lua_scripts/pathmaps/simple
	install -d -m 755 $(prefix)/share/scratchbox2/lua_scripts/pathmaps/maemo

	install -d -m 755 $(prefix)/share/scratchbox2/scripts
	install -d -m 755 $(prefix)/share/scratchbox2/tests
	install -d -m 755 $(prefix)/share/scratchbox2/modeconf
	install -d -m 755 $(prefix)/share/man/man1
	echo "$(PACKAGE_VERSION)" > $(prefix)/share/scratchbox2/version
	install -c -m 755 $(SRCDIR)/utils/sb2 $(prefix)/bin/sb2
	install -c -m 755 $(SRCDIR)/utils/sb2-init $(prefix)/bin/sb2-init
	install -c -m 755 $(SRCDIR)/utils/sb2-config $(prefix)/bin/sb2-config
	install -c -m 755 $(SRCDIR)/utils/sb2-build-libtool $(prefix)/bin/sb2-build-libtool
	install -c -m 755 $(SRCDIR)/utils/sb2-build-qemuserver $(prefix)/bin/sb2-build-qemuserver
	install -c -m 755 $(SRCDIR)/utils/sb2-mkinitramfs $(prefix)/bin/sb2-mkinitramfs
	install -c -m 755 $(SRCDIR)/utils/sb2-start-qemuserver $(prefix)/bin/sb2-start-qemuserver
	install -c -m 755 $(SRCDIR)/utils/deb-pkg-tools-wrapper $(prefix)/share/scratchbox2/scripts/dpkg
	install -c -m 755 $(SRCDIR)/utils/deb-pkg-tools-wrapper $(prefix)/share/scratchbox2/scripts/apt-get
	install -c -m 755 $(SRCDIR)/utils/dpkg-checkbuilddeps $(prefix)/share/scratchbox2/scripts/dpkg-checkbuilddeps
	install -c -m 755 $(SRCDIR)/utils/debconf2po-update $(prefix)/share/scratchbox2/scripts/debconf2po-update
	install -c -m 755 $(SRCDIR)/utils/sb2-check-pkg-mappings $(prefix)/share/scratchbox2/scripts/sb2-check-pkg-mappings
	install -c -m 755 $(SRCDIR)/utils/sb2-exitreport $(prefix)/share/scratchbox2/scripts/sb2-exitreport
	install -c -m 755 $(SRCDIR)/utils/sb2-logz $(prefix)/bin/sb2-logz
	install -c -m 644 $(SRCDIR)/lua_scripts/main.lua $(prefix)/share/scratchbox2/lua_scripts/main.lua
	install -c -m 644 $(SRCDIR)/lua_scripts/mapping.lua $(prefix)/share/scratchbox2/lua_scripts/mapping.lua
	install -c -m 644 $(SRCDIR)/lua_scripts/argvenvp.lua $(prefix)/share/scratchbox2/lua_scripts/argvenvp.lua
	install -c -m 644 $(SRCDIR)/lua_scripts/argvenvp_gcc.lua $(prefix)/share/scratchbox2/lua_scripts/argvenvp_gcc.lua

	install -c -m 644 $(SRCDIR)/lua_scripts/pathmaps/emulate/*.lua $(prefix)/share/scratchbox2/lua_scripts/pathmaps/emulate/
	install -c -m 644 $(SRCDIR)/lua_scripts/pathmaps/simple/*.lua $(prefix)/share/scratchbox2/lua_scripts/pathmaps/simple/
	install -c -m 644 $(SRCDIR)/lua_scripts/pathmaps/maemo/*.lua $(prefix)/share/scratchbox2/lua_scripts/pathmaps/maemo/
	install -c -m 644 $(SRCDIR)/modeconf/* $(prefix)/share/scratchbox2/modeconf/
	install -c -m 644 $(SRCDIR)/tests/* $(prefix)/share/scratchbox2/tests
	chmod a+x $(prefix)/share/scratchbox2/tests/run.sh

	install -c -m 644 $(SRCDIR)/docs/sb2.1 $(prefix)/share/man/man1/sb2.1
	rm -f $(prefix)/share/scratchbox2/host_usr
	ln -sf /usr $(prefix)/share/scratchbox2/host_usr
	@for f in $(gcc_bins_expanded); do \
		ln -sf /bin/true $$f; \
	done

install: do-install

do-install: install-noarch
	install -d -m 755 $(prefix)/lib
	install -d -m 755 $(prefix)/lib/libsb2
	install -c -m 755 $(OBJDIR)/preload/libsb2.so $(prefix)/lib/libsb2/libsb2.so.$(PACKAGE_VERSION)
	install -c -m 755 $(OBJDIR)/utils/sb2-show $(prefix)/bin/sb2-show
	install -c -m 755 $(OBJDIR)/utils/sb2-monitor $(prefix)/bin/sb2-monitor
	/sbin/ldconfig -n $(prefix)/lib/libsb2


multilib_prefix=$(prefix)

install-multilib: install-noarch
	$(MAKE) -C obj-32 --include-dir=.. -f ../Makefile SRCDIR=.. do-install-multilib bitness=32
	$(MAKE) -C obj-64 --include-dir=.. -f ../Makefile SRCDIR=.. do-install

do-install-multilib:
	install -d -m 755 $(multilib_prefix)/lib$(bitness)
	install -d -m 755 $(multilib_prefix)/lib$(bitness)/libsb2
	install -c -m 755 preload/libsb2.so $(multilib_prefix)/lib$(bitness)/libsb2/libsb2.so.$(PACKAGE_VERSION)
	/sbin/ldconfig -n $(multilib_prefix)/lib$(bitness)/libsb2


CLEAN_FILES += $(targets) config.status config.log

# make all object files depend on include/config.h

superclean: clean
	rm -rf obj-32 obj-64 .configure-multilib

clean-multilib:
	$(MAKE) -C obj-32 --include-dir .. -f ../Makefile clean
	$(MAKE) -C obj-64 --include-dir .. -f ../Makefile clean

clean:
	$(ll_clean)