aboutsummaryrefslogtreecommitdiff
blob: b5d6191b3de47ba6a459fe0d3c893e56034e72c8 (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
<?xml version="1.0" encoding="UTF-8"?>
<guide self="ebuild-writing/functions/src_compile/no-build-system/">
<chapter>
<title>No build system</title>

<body>
<p>
Occasionally some really small packages are shipped simply as a single
<c>.c</c> file. In these circumstances, you can either write your own
<c>Makefile</c> and ship it with the source tarball, or just manually
compile the thing from within the ebuild, preferebly explaining why.
Here's an example, from <c>app-misc/hilite</c>:
</p>

<codesample lang="ebuild">
src_compile() {
	$(tc-getCC) ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o ${PN} ${P}.c || die
}
</codesample>

<p>
Here's an example from <c>x11-plugins/asclock</c>, which ships with a
broken build system that doesn't actually work:
</p>

<codesample lang="ebuild">
src_compile() {
	local x
	for x in asclock parser symbols config
	do
		$(tc-getCC) \
			${CPPFLAGS} ${CFLAGS} ${ASFLAGS} \
			-I"${EPREFIX}"/usr/include \
			-Dlinux \
			-D_POSIX_C_SOURCE=199309L \
			-D_POSIX_SOURCE \
			-D_XOPEN_SOURCE \
			-D_BSD_SOURCE \
			-D_SVID_SOURCE \
			-DFUNCPROTO=15 \
			-DNARROWPROTO \
			-c -o ${x}.o ${x}.c || die "compile asclock failed"
	done
	$(tc-getCC) \
		${LDFLAGS} \
		-o asclock \
		asclock.o parser.o symbols.o config.o \
		-L"${EPREFIX}"/usr/lib \
		-L"${EPREFIX}"/usr/lib/X11 \
		-lXpm -lXext -lX11 || die "link asclock failed"
}
</codesample>

<p>
A possibly better alternative would be to patch the build system
and send it upstream.
</p>

</body>
</chapter>
</guide>