]> Pileus Git - ~andy/sunrise/blob - x11-wm/dwm/dwm-2.8.ebuild
1e61eb767ccf9938c2b4b3cf3170887e3d66cb2a
[~andy/sunrise] / x11-wm / dwm / dwm-2.8.ebuild
1 # Copyright 1999-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 inherit toolchain-funcs
6
7 DESCRIPTION="a dynamic window manager for X11"
8 HOMEPAGE="http://suckless.org/view/dynamic+window+manager"
9 SRC_URI="http://suckless.org/download/${P}.tar.gz"
10
11 LICENSE="MIT"
12 SLOT="0"
13 KEYWORDS="~amd64 ~x86"
14 IUSE="savedconfig"
15
16 DEPEND="x11-libs/libX11"
17 RDEPEND=${DEPEND}
18
19 src_unpack() {
20         unpack ${A}
21         cd "${S}"
22
23         sed -i \
24                 -e "s/.*strip.*//" \
25                 Makefile || die "sed failed"
26
27         sed -i \
28                 -e "s/CFLAGS = -Os/CFLAGS +=/" \
29                 -e "s/LDFLAGS =/LDFLAGS +=/" \
30                 config.mk || die "sed failed"
31
32         if use savedconfig; then
33                 local conf root
34                 [[ -r config.h ]] && rm config.h
35                 for conf in ${PF} ${P} ${PN}; do
36                         for root in "${PORTAGE_CONFIGROOT}" "${ROOT}" /; do
37                                 configfile=${root}etc/portage/savedconfig/${conf}.config.h
38                                 if [[ -r ${configfile} ]]; then
39                                         elog "Found your ${configfile} and using it."
40                                         cp ${configfile} "${S}"/config.h
41                                         return 0
42                                 fi
43                         done
44                 done
45                 ewarn "Could not locate user configfile, so we will save a default one."
46         fi
47 }
48
49 src_compile() {
50         local msg
51         use savedconfig && msg=", please check the configfile"
52         emake CC=$(tc-getCC) || die "emake failed${msg}"
53 }
54
55 src_install() {
56         emake DESTDIR="${D}" PREFIX="/usr" install || die "emake install failed"
57
58         insinto /usr/share/${PN}
59         newins config.h ${PF}.config.h
60
61         exeinto /etc/X11/Sessions
62         newexe "${FILESDIR}"/dwm-session dwm
63
64         dodoc README
65 }
66
67 pkg_preinst() {
68         mv "${D}"/usr/share/${PN}/${PF}.config.h "${T}"/
69         if use savedconfig; then
70                 local config_dir="${PORTAGE_CONFIGROOT:-${ROOT}}/etc/portage/savedconfig"
71                 elog "Saving this build config to ${config_dir}/${PF}.config.h"
72                 elog "Read this ebuild for more info on how to take advantage of this option."
73                 mkdir -p "${config_dir}"
74                 cp "${T}"/${PF}.config.h "${config_dir}"/${PF}.config.h
75         fi
76 }
77
78 pkg_postinst() {
79         elog "This ebuild has support for user defined configs"
80         elog "Please read this ebuild for more details and re-emerge as needed"
81         elog "if you want to add or remove functionality for ${PN}"
82
83         if ! has_version x11-misc/dmenu; then
84                 elog "Installing ${PN} without x11-misc/dmenu"
85                 elog "To have a menu you can install x11-misc/dmenu"
86         fi
87
88         elog "You can custom status bar with a script in HOME/.dwm/dwmrc"
89         elog "the ouput is redirected to the standard input of dwm"
90 }