summaryrefslogtreecommitdiff
path: root/debian/bbdb.emacsen-install
blob: bbe45fe095a230ede43cfc4a910586062f75868a (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/sh
# /usr/lib/emacsen-common/packages/install/bbdb

FLAVOR=$1
PACKAGE="bbdb"

if [ "X${FLAVOR}" = "X" ]; then
    echo Need argument to determine FLAVOR of emacs;
    exit 1
fi

if [ "X${PACKAGE}" = "X" ]; then
    echo Internal error: need package name;
    exit 1;
fi

ELDIR=/usr/share/emacs/site-lisp/${PACKAGE}
ELCDIR=/usr/share/${FLAVOR}/site-lisp/${PACKAGE}

COMPILE="-q -batch -f batch-byte-compile"

case "${FLAVOR}" in
    emacs)
	echo "install/${PACKAGE}: Ignoring Flavor ${FLAVOR} ..."
	;;
    *)

	echo "install/${PACKAGE}: Byte-compiling for ${FLAVOR} ..."

	rm -rf ${ELCDIR}
	cd ${ELDIR}
	TARGETS="rmail mhe gnus bbdb"

	if [ -d /usr/share/${FLAVOR}/site-lisp/vm ]; then
	    TARGETS="$TARGETS vm"
	elif [ ${FLAVOR} = xemacs20 -o ${FLAVOR} = xemacs21 ]; then
	    TARGETS="$TARGETS vm"
	fi

	if [ ${FLAVOR} = emacs19 -o ${FLAVOR} = mule2 ]; then
            MHEDIR=/usr/share/${FLAVOR}/site-lisp/../lisp
	elif [ ${FLAVOR} = xemacs20 -o ${FLAVOR} = xemacs21 ]; then
            MHEDIR=/usr/share/${FLAVOR}/site-lisp/../lisp/mh-e
	else	# emacs20
            MHEDIR=/usr/share/${FLAVOR}/site-lisp/../lisp/mail
	fi

	## for Gnus
	if [ -d /usr/share/${FLAVOR}/site-lisp/gnus ]; then
	    GNUSDIR=/usr/share/${FLAVOR}/site-lisp/gnus
	elif [ -d /usr/share/${FLAVOR}/site-lisp/semi-gnus ]; then
	    GNUSDIR=/usr/share/${FLAVOR}/site-lisp/semi-gnus
	elif [ -d /usr/share/${FLAVOR}/site-lisp/t-gnus ]; then
	    GNUSDIR=/usr/share/${FLAVOR}/site-lisp/t-gnus
	elif [ -d /usr/share/${FLAVOR}/site-lisp/chaos ]; then
	    GNUSDIR=/usr/share/${FLAVOR}/site-lisp/chaos
	fi

	if [ -z ${GNUSDIR} ]; then
	    if [ ${FLAVOR} = emacs19 -o ${FLAVOR} = mule2 ]; then
		GNUSDIR=/usr/share/emacs/19.34/lisp
	    elif [ ${FLAVOR} = xemacs20 ]; then
		GNUSDIR=/usr/lib/xemacs-20.4/lisp/gnus
	    elif [ ${FLAVOR} = xemacs21 ]; then
		GNUSDIR=/usr/share/xemacs21/packages/lisp/gnus
	    else
		GNUSDIR=/usr/share/${FLAVOR}/site-lisp/../lisp/gnus
	    fi
	fi

	LOG=`tempfile`
	
	rm -rf ${ELCDIR} && cp -a ${ELDIR} ${ELCDIR}

	# at ELCDIR
	( cd ${ELCDIR}

	    # Prevent epg from manipulating /root/.gnupg (#694417)
	    TMPGNUPGHOME=`mktemp -d --tmpdir gnupg.XXXXXXXXXX`
	    export GNUPGHOME=${TMPGNUPGHOME}

	    echo "Generating bbdb-autoloads..."
            echo "Generating bbdb-autoloads" >> $LOG
	    make autoloads >> $LOG 2>&1
	    if [ $FLAVOR != xemacs20 -a $FLAVOR != xemacs21 ]; then
		echo  "(provide 'bbdb-autoloads)" >> lisp/bbdb-autoloads.el
	    fi
	    echo "Byte-compiling bbdb..."
	    make  $TARGETS EMACS_PROG=${FLAVOR} \
		VMDIR=/usr/share/${FLAVOR}/site-lisp/vm \
		GNUSDIR=${GNUSDIR} \
		MHEDIR=${MHEDIR} >> $LOG 2>&1
	    mv lisp/*.elc utils/*.el .
	    rm -rf tex utils lisp Makefile ${TMPGNUPGHOME}
	    ${FLAVOR} ${COMPILE} *.el >> $LOG 2>&1
	)
	cat > ${ELCDIR}/load-path.el <<EOF 
(setq load-path (cons (concat "/usr/share/${FLAVOR}/site-lisp/bbdb") load-path))
(provide 'bbdb/load-path)
EOF
	if [ ! -e ${ELCDIR}/bbdb-gnus.elc ]; then
	    echo "*** installing not-compiled bbdb-gnus.el ***" >> $LOG
	    echo "install -m 644 ${ELDIR}/lisp/bbdb-gnus.el ${ELCDIR}/" >> $LOG
	    install -m 644 ${ELDIR}/lisp/bbdb-gnus.el ${ELCDIR}/
	fi

	# a hack to fix #179821, #210248, #233904
	# If bbdb is installed before vm, then bbdb does not have bbdb-vm compiled....
	install -m 644 ${ELDIR}/lisp/bbdb-vm.el ${ELCDIR}/

	# make -k clean >> $LOG
	mv $LOG ${ELCDIR}/CompilationLog
	gzip -9 ${ELCDIR}/CompilationLog
	chmod 644 ${ELCDIR}/CompilationLog.gz

	# make symlinks for source files that were not copied over to ELCDIR
	# this makes find-function and find-library work properly
	cd ${ELDIR}/lisp
	for f in *.el; do
            if [ -e ${ELCDIR}/${f}c ] && [ ! -e ${ELCDIR}/${f} ]; then
		ln -sf ${ELDIR}/lisp/${f} ${ELCDIR}/${f}
            fi
	done

	echo " done."
	;;
esac