summaryrefslogtreecommitdiff
blob: 40a3d58863daab6f0aec0aed275078491c39430e (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
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sci-electronics/kicad/kicad-20060828.ebuild,v 1.3 2007/05/30 06:23:32 calchan Exp $

inherit wxwidgets

UPSTREAM_PV="${PV:0:4}-${PV:4:2}-${PV:6:2}"
DESCRIPTION="Electronic schematic and PCB design tools."
HOMEPAGE="http://www.lis.inpg.fr/realise_au_lis/kicad/"
SRC_URI="mirror://gentoo/${P}.tar.bz2
	!minimal? ( ftp://iut-tice.ujf-grenoble.fr/cao/${PN}-${UPSTREAM_PV}.tgz )"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE="unicode doc examples minimal"

DEPEND=">=x11-libs/wxGTK-2.6
	media-gfx/wings"

pkg_setup() {
	# Tell wxwidgets.eclass the version we need. We pick the latest on the system.
	WX_GTK_VER=$(`ls /usr/bin/wx-config* | sort | tail -n 1` --release)

	# Check for proper wxGTK USE flags.
	if use unicode; then
		need-wxwidgets unicode || die "You need to install wxGTK with unicode support."
	else
		need-wxwidgets gtk2 || die "You need to install wxGTK with gtk2 support."
	fi
	built_with_use ">=x11-libs/wxGTK-${WX_GTK_VER}" opengl || die "You need to install wxGTK with opengl support."
}

src_unpack() {
	unpack ${A} || die "unpack failed"
	cd ${S}

	# Use the chosen wx-config executable
	sed -i -e "s:wx-config:${WX_CONFIG}:" libs.* || die "sed failed"
	sed -i -e "s:wx-config:${WX_CONFIG}:" */makefile.* || die "sed failed"
}

src_compile() {
	# Build the main executables
	emake -f makefile.gtk || die "make failed (main)"

	# Minizip needs to be built independently
	cd kicad/minizip
	emake -f makefile.unx || die "make failed (minizip)"
}

src_install() {
	# kicad doesn't use the autotools yet
	exeinto /usr/lib/${PN}/linux
	doexe eeschema/eeschema
	doexe pcbnew/pcbnew
	doexe cvpcb/cvpcb
	doexe kicad/kicad
	doexe kicad/minizip/minizip
	doexe gerbview/gerbview
	exeinto /usr/lib/${PN}/linux/plugins
	doexe eeschema/plugins/netlist_form_pads-pcb
	newicon kicad_icon.png kicad.png
	make_wrapper kicad "/usr/lib/${PN}/linux/kicad"
	make_desktop_entry kicad Kicad kicad.png Electronics

	# kicad requires everything to be in the same place
	cp -pPR library ${D}/usr/lib/${PN}
	cp -pPR internat ${D}/usr/lib/${PN}
	cp -pPR template ${D}/usr/lib/${PN}
	cp -pPR help ${D}/usr/lib/${PN}
	if ! use minimal ; then
		cp -pPR ${WORKDIR}/kicad/library ${D}/usr/lib/${PN}
		cp -pPR ${WORKDIR}/kicad/modules ${D}/usr/lib/${PN}
		cp -pPR ${WORKDIR}/kicad/template ${D}/usr/lib/${PN}
		if use doc ; then
			cp -pPR ${WORKDIR}/kicad/help ${D}/usr/lib/${PN}
		fi
		if use examples ; then
			cp -pPR ${WORKDIR}/kicad/demos ${D}/usr/lib/${PN}
		fi
	fi
	dodoc author.txt copyright.txt news.txt contrib.txt version.txt
}

pkg_postinst() {
	if use minimal ; then
		ewarn "If the schematic and/or board editors complain about missing libraries when you open old projects,"
		ewarn "you will have to take one or more of the following actions :"
		ewarn "- Install the missing libraries manually."
		ewarn "- Remove the libraries from the 'Libs and Dir' preferences."
		ewarn "- Fix the libraries' locations in the 'Libs and Dir' preferences."
		ewarn "- Emerge kicad without the 'minimal' USE flag."
	else
		elog "Please note that the PDF datasheets that can be linked to components from the default libraries"
		elog "cannot be mirrored by Gentoo for legal reasons."
		elog "If you want them, you need to download them yourself from :"
		elog "${HOMEPAGE}"
		elog "and install them manually."
	fi
}