forked from Schischu/STLinux.Toolchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_all_v2.mk
executable file
·123 lines (91 loc) · 3.41 KB
/
build_all_v2.mk
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
#!/usr/bin/make -f
#
# Makefile to build all ptxconfigs
# Copyright (C) 2007 Carsten Schlote <[email protected]>
# 2008, 2011 Marc Kleine-Budde <[email protected]>
#
SHELL := /bin/bash
#
# config
#
PTX_AUTOBUILD_DESTDIR := ${PWD}/inst
export PTX_AUTOBUILD_DESTDIR
BENICE := true
BUILDDATE := $(shell date +%y%m%d-%H%M)
VERSION := $(shell ./scripts/setlocalversion ./.tarball-version)
ARCH := $(shell \
case "$$(uname -m)" in \
(x86_64) echo amd64;; \
(i[1-9]86) echo i386;; \
(ppc) echo powerpc;; \
(sh) echo sh;; \
(*) ;; \
esac \
)
ifeq ($(ARCH),)
$(error failed to detect arch, or arch is unsupported)
endif
PTXDIST := ./p --force
ifdef BENICE
NICE += nice -20
endif
CONFIGDIR := ptxconfigs
CONFIGFILES := $(wildcard $(CONFIGDIR)/*.ptxconfig) $(wildcard $(CONFIGDIR)/*/*.ptxconfig)
CONFIGS := $(notdir $(basename $(CONFIGFILES)))
CONFIGS_ := $(subst _,-,$(CONFIGS))
define gen_2config
$(eval 2CONFIG_$(subst _,-,$(1)) := $(1))
endef
define gen_2configfile
$(eval 2CONFIGFILE_$(subst _,-,$(notdir $(basename $(1)))) := $(1))
endef
define gen_2instdir
$(eval 2INSTDIR_$(subst _,-,$(notdir $(basename $(1)))) := \
$(shell PTX_AUTOBUILD_DESTDIR='' source "$(1)" && echo "$${PTXCONF_SYSROOT_CROSS}"))
endef
$(foreach cfg,$(CONFIGS),$(call gen_2config,$(cfg)))
$(foreach cfgfile,$(CONFIGFILES),$(call gen_2configfile,$(cfgfile)))
$(foreach cfgfile,$(CONFIGFILES),$(call gen_2instdir,$(cfgfile)))
STATEDIR := gstate
DISTDIR := dist
PREFIX := $(DISTDIR)/oselas.toolchain-$(VERSION)-
CONFIGS_PREFIX := $(foreach config,$(CONFIGS_),$(addprefix $(PREFIX),$(config)))
DEB_PREFIX := $(PREFIX)
DEB_SUFFIX := _$(VERSION)_$(ARCH).deb
TBZ2_PREFIX := $(PREFIX)
TBZ2_SUFFIX := _$(ARCH).tar.bz2
DEBS := $(foreach config,$(CONFIGS_PREFIX),$(addsuffix $(DEB_SUFFIX),$(config)))
TBZ2S := $(foreach config,$(CONFIGS_PREFIX),$(addsuffix $(TBZ2_SUFFIX),$(config)))
OLDCONFIGS := $(foreach config,$(CONFIGS_),$(addsuffix .oldconfig,$(config)))
all: $(TBZ2S) $(DEBS)
$(DEB_PREFIX)%$(DEB_SUFFIX): $(STATEDIR)/%.build | mkdirs
@scripts/make_deb.sh -d "$(@)" -s "$(PTX_AUTOBUILD_DESTDIR)/$(2INSTDIR_$(*))"
$(TBZ2_PREFIX)%$(TBZ2_SUFFIX): $(STATEDIR)/%.build | mkdirs
@echo Creating $(notdir $@) ...
@echo 'tar -C "$(PTX_AUTOBUILD_DESTDIR)/opt" --exclude=gcc-first -cjf "$(@)" "$(patsubst /opt/%,%,$(2INSTDIR_$(*)))"' | fakeroot
$(foreach config,$(CONFIGS_),$(eval $(STATEDIR)/$(config).build: $(2CONFIGFILE_$(config))))
$(STATEDIR)/%.build: | mkdirs
@echo "building ${*}"
$(NICE) $(PTXDIST) go --ptxconfig=$(2CONFIGFILE_$(*))
@find "`source "$(2CONFIGFILE_$(*))" && echo "$${PTXCONF_SYSROOT_CROSS}"`" -depth -type d -print0 | xargs -r -0 -- rmdir --ignore-fail-on-non-empty --
find \
"`source "$(2CONFIGFILE_$(*))" && echo "$${PTXCONF_SYSROOT_CROSS}"`/libexec/" \
"`source "$(2CONFIGFILE_$(*))" && echo "$${PTXCONF_SYSROOT_CROSS}"`/bin/" \
"`source "$(2CONFIGFILE_$(*))" && echo "$${PTXCONF_SYSROOT_CROSS}"`/"*/bin/ \
-type f \( -executable -o -name "*.so*" \) \
| xargs strip || true
@touch "$@"
$(STATEDIR)/%.pkgs: $(DEB_PREFIX)%$(DEB_SUFFIX) $(TBZ2_PREFIX)%$(TBZ2_SUFFIX) | mkdirs
@:
oldconfig: $(OLDCONFIGS)
%.oldconfig:
$(PTXDIST) oldconfig --ptxconfig=$(2CONFIGFILE_$(*))
mkdirs:
@mkdir -p $(STATEDIR) $(DISTDIR)
print-%:
@echo "$* is \"$($(*))\""
help:
@echo "Available DPKG targets:"
@for i in $(DEBS); do echo $$i; done;
@echo "Available tarball targets:"
@for i in $(TBZ2S); do echo $$i; done;