summaryrefslogtreecommitdiffstats
path: root/scripts/lib/ptxd_lib_dgen.sh
blob: 63e3288be02047d93fd5d0e17cb1bc867ee4aad2 (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
#!/bin/bash
#
# Copyright (C) 2006, 2007 by the PTXdist project
#               2008, 2009 by Marc Kleine-Budde <mkl@pengutronix.de>
#
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXdist project and license conditions
# see the README file.
#

export PTXDIST_DGEN_DIR="${PTXDIST_TEMPDIR}/dgen"

ptxd_kconfig_dep_all() {
    while [ ${#} -gt 0 ]; do
	ptxd_kconfig dep "${1}" || {
	    ptxd_dialog_msgbox \
		"error: error during generation of dependencies\n" \
		"	(maybe amd64 executable on x86)"
	    return 1
	}
	shift
    done
}

#
# generates:
#
# PTX_MAP_[BR]_DEP_<PACKAGE>=<DEP>:<DEP>
#
ptxd_dgen_configdeps() {
    local i
    local config[0]=ptx

    if [ -e "${PTXDIST_PLATFORMCONFIG}" ]; then
	config[1]=platform
    fi

    {
	PTXDIST_DEP_TARGET="build" ptxd_kconfig_dep_all "${config[@]}" \
	    | sed -ne "s~DEP:\([^:]*\):\(.*\)~PTX_MAP_B_DEP_\1=\2~p"
	PTXDIST_DEP_TARGET="run" ptxd_kconfig_dep_all "${config[@]}" \
	    | sed -ne "s~DEP:\([^:]*\):\(.*\)~PTX_MAP_R_DEP_\1=\2~p"
    } > "${PTX_MAP_DEPS}.tmp"
    check_pipe_status || return
}

#
# get package *.make files without duplicates
#
ptxd_dgen_rulesfiles() {
    {
	local rulesdir
	ptxd_in_path PTXDIST_PATH_RULES || return
	for rulesdir in "${ptxd_reply[@]}"; do
	    find "${rulesdir}/" -mindepth 1 -maxdepth 1 -name "*.make" -a \! -path "*#*"
	done
    } | gawk '{
	    n=gensub(".*/", "", "g");
	    if (!(n in names))
		print "include", $0;
	    names[n]=1;
	}' > "${PTX_DGEN_RULESFILES_MAKE}.tmp"
    check_pipe_status
}



#
# generates
#
# PTX_MAP_TO_FILENAME_<PACKAGE>="<filename.make>"
# PTX_MAP_TO_package_<PACKAGE>="<package>"
# PTX_MAP_TO_PACKAGE_<package>="<PACKAGE>"
#
ptxd_dgen_map_all() {
    local dgen_ptxconfig="${PTXDIST_DGEN_DIR}/ptxconfig"
    local dgen_platformconfig="${PTXDIST_DGEN_DIR}/platformconfig"

    {
	echo "${PTX_DGEN_RULESFILES_MAKE}.tmp"
	echo "${PTX_MAP_DEPS}.tmp"
	echo "${dgen_ptxconfig}"
	if [ -e "${dgen_platformconfig}" ]; then
	    echo "${dgen_platformconfig}"
	fi
    } | {
	export \
	    PTX_MAP_ALL \
	    PTX_MAP_ALL_MAKE \
	    PTX_MAP_DEPS \
	    PTX_DGEN_DEPS_PRE \
	    PTX_DGEN_DEPS_POST \
	    PTX_DGEN_RULESFILES_MAKE
	xargs gawk -f "${PTXDIST_LIB_DIR}/ptxd_lib_dgen.awk"
    }
    check_pipe_status
}



ptxd_dgen() {
    mkdir -p -- \
	"${STATEDIR}" \
	"${PTXDIST_DGEN_DIR}" || return

    ptxd_dgen_configdeps &&
    ptxd_dgen_rulesfiles &&
    ptxd_dgen_map_all
}