summaryrefslogtreecommitdiffstats
path: root/build
blob: 92cefe0b779b42f1602e970add817fa382802b64 (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
#! /usr/bin/make -f

CFLAGS = -g -O2

configure: configure.stamp
configure.stamp:
	for target in $(PKG_TARGETS); do \
		mkdir -p "build-$${target}"; \
		done
	# Generate the main makefile.
	# Use shared BFD and opcodes libraries for all utilities.
	# Don't enable multilib (multiarch is better).
	# Enable plugins.
	# Don't expect to find Gettext.
	for target in $(PKG_TARGETS); do \
		cd "build-$${target}" && \
		target_arch_gnu=$$(oh-getarchitecture -t gnu "$${target}") && \
		CFLAGS='$(CFLAGS)' ../src/configure \
			--prefix=/usr --with-sysroot=/ \
			--program-transform-name="s&^&$${target}-&" \
			--enable-shared --disable-multilib \
			--enable-plugins --disable-nls \
			--build=$(OH_BUILD_ARCH_GNU) --host=$(OH_HOST_ARCH_GNU) \
			--target="$${target_arch_gnu}" && \
   		cd ..; \
		done
	# Generate all the individual program makefiles.
	for target in $(PKG_TARGETS); do \
		cd "build-$${target}" && make configure-host && cd ..; \
		done
	touch $@

build: build.stamp
build.stamp: configure
	# Build BFD header files.
	for target in $(PKG_TARGETS); do \
		cd "build-$${target}/bfd" && make headers && cd ../..; \
		done
	# Build ALL the things!
	for target in $(PKG_TARGETS); do \
		cd "build-$${target}" && make CFLAGS='$(CFLAGS)' && cd ..; \
		done
	touch $@

install: install.stamp
install.stamp: build
	# Install everything.
	for target in $(PKG_TARGETS); do \
		cd "build-$${target}" && \
		make CFLAGS='$(CFLAGS)' \
			prefix="$${PWD}/../dest/usr" tooldir="$${PWD}/../dest/usr" \
			install && \
		cd ..; \
		done
	# Remove static library dependency metadata generated by libtool.
	rm -f ../dest/usr/lib/*.la
	# Make symbolic links to native utilities.
	for target in $(PKG_TARGETS); do \
		if [ '$(OH_HOST_ARCH)' = "$${target}" ]; then \
			for util in "../dest/usr/bin/$${target}-"*; do \
				ln -sf "$${util##*/}" "$${util%/*}/$${util##*/$${target}}"; \
			done \
		fi; \
		done
	touch $@

binary-arch: install
	oh-strip
	oh-installfiles
	oh-installdocs binutils
	oh-gencontrol
	oh-buildopk

binary-indep: install
	oh-installfiles
	oh-installdocs binutils
	oh-gencontrol
	oh-buildopk

binary: binary-arch binary-indep