summaryrefslogtreecommitdiff
path: root/source4/heimdal_build/et_compile_wrapper.sh
blob: d7d47ba363fee296beaf5adaed3040079b392824 (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
#!/bin/sh
#

SELF=$0
SELFDIR=`dirname ${SELF}`

SRCDIR=$1
BUILDDIR=$2
DESTDIR=$3

CMD=$4
FILE=$5
SOURCE=$6
shift 6

test -z "${SRCDIR}" && {
	echo "${SELF}:SRCDIR: '${SRCDIR}'" >&2;
	exit 1;
}

test -z "${BUILDDIR}" && {
	echo "${SELF}:BUILDDIR: '${BUILDDIR}'" >&2;
	exit 1;
}

test -z "${DESTDIR}" && {
	echo "${SELF}:DESTDIR: '${DESTDIR}'" >&2;
	exit 1;
}

test -z "${CMD}" && {
	echo "${SELF}:CMD: '${CMD}'" >&2;
	exit 1;
}

test -z "${FILE}" && {
	echo "${SELF}:FILE: '${FILE}'" >&2;
	exit 1;
}

test -z "${SOURCE}" && {
	echo "${SELF}:SOURCE: '${SOURCE}'" >&2;
	exit 1;
}

CURDIR=`pwd`

cd ${SRCDIR} && {
	ABS_SRCDIR=`pwd`
	cd ${CURDIR}
} || {
	echo "${SELF}:cannot cd into '${SRCDIR}'" >&2;
	exit 1;
}

cd ${BUILDDIR} && {
	ABS_BUILDDIR=`pwd`
	cd ${CURDIR}
} || {
	echo "${SELF}:cannot cd into '${BUILDDIR}'" >&2;
	exit 1;
}

cd ${DESTDIR} && {
	${ABS_BUILDDIR}/${CMD} ${ABS_SRCDIR}/${FILE} >&2 || exit 1;
	cd ${CURDIR}
	TMP="${SOURCE}.$$"
	mv ${SOURCE} ${TMP} && {
		echo "#include \"config.h\"" > ${SOURCE} && {
			cat ${TMP} >> ${SOURCE}
		}
	}
	rm ${TMP}
} || {
	echo "${SELF}:cannot cd into '${BUILDDIR}'" >&2;
	exit 1;
}

exit 0;