-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_all_v2.mk
executable file
·114 lines (87 loc) · 2.8 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
#!/usr/bin/make -f
#
# Makefile to build all ptxconfigs
# Copyright (C) 2007 Carsten Schlote <[email protected]>
# 2008 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 \
# version=$$(pwd | sed -e "s~.*/OSELAS.Toolchain-~~"); \
# case "$${version}" in \
# (*trunk*) \
# svnversion | \
# sed \
# -e "s/^/trunk-/" \
# -e "s/:/./g";; \
# (*) \
# echo "$${version}";; \
# esac \
# )
VERSION := $(shell pwd | sed -e "s~.*/OSELAS.Toolchain-~~")
ARCH := $(shell \
case "$$(uname -m)" in \
(x86_64) echo amd64;; \
(i[1-9]86) echo i386;; \
(ppc) echo powerpc;; \
(*) ;; \
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)))
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 'tar -C "$(PTX_AUTOBUILD_DESTDIR)/opt" -cvjf "$(@)" "$(patsubst /opt/%,%,$(2INSTDIR_$(*)))"' | fakeroot
$(STATEDIR)/%.build: | mkdirs
@echo "building ${*}"
$(NICE) $(PTXDIST) go --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;