summaryrefslogtreecommitdiff
path: root/scripts/xdt-autogen.in
blob: b614fe041335d9671d0edbb859c965bdc8089443 (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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#!/bin/sh
#
# $Id$
#
# Copyright (c) 2002-2005 
#         The Xfce development team. All rights reserved.
#
# Written for Xfce by Benedikt Meurer <benny@xfce.org>.
#
# xdt-autogen - Part of the Xfce developer tools.
#


##
## Determine XDG data dirs
##
test -z "${XDG_DATA_HOME}" && XDG_DATA_HOME="${HOME}/.local/share"
test -z "${XDG_DATA_DIRS}" && XDG_DATA_DIRS="/usr/local/share:/usr/share"
test -d "@DATADIR@" && XDG_DATA_DIRS="@DATADIR@:${XDG_DATA_DIRS}"
XDG_DATA_DIRS="${XDG_DATA_HOME}:${XDG_DATA_DIRS}"
export XDG_DATA_DIRS XDG_DATA_HOME


##
## Search for the configure.{ac,in} file
##
SOURCE_DIR=`pwd`; test -z "${SOURCE_DIR}" && SOURCE_DIR="."
if test -f "${SOURCE_DIR}/configure.ac"; then
  CONFIGURE_FILE="${SOURCE_DIR}/configure.ac";
elif test -f "${SOURCE_DIR}/configure.in"; then
  CONFIGURE_FILE="${SOURCE_DIR}/configure.in";
else
  cat >&2 <<EOF
xdt-autogen: Directory "${SOURCE_DIR}" does not look like a
             top-level package directory.
EOF
  exit 1
fi


##
## Check for a suitable make
##
if test x"${MAKE}" = x""; then
  if (type gmake) >/dev/null 2>/dev/null; then
    MAKE="gmake"
  elif (type make) >/dev/null 2>/dev/null; then
    MAKE="make"
  else
    cat >&2 <<EOF
xdt-autogen: You must have "make" installed on your system.
EOF
    exit 1
  fi
  export MAKE
fi


##
## cleanup autogenerated files
##
if test x"$1" = x"clean"; then
  echo "Running ${MAKE} distclean..."
  (cd ${SOURCE_DIR} ;
   ${MAKE} distclean) >/dev/null 2>&1

  echo "Cleaning generated files..."
  (cd ${SOURCE_DIR} ;
   rm -f config.* configure configure.lineno aclocal.m4 ;
   rm -f compile depcomp ltmain.sh missing install-sh ;
   rm -f po/*.gmo po/Makefile.in.in ;
   rm -f stamp-h1 *.spec ;
   rm -f mkinstalldirs libtool ;
   rm -rf autom4te.cache ;
   rm -f intltool-*)
  rm -f `find ${SOURCE_DIR} -name Makefile.in`

  exit 0
fi


##
## Check for autoconf
##
test -z "${XDT_PROG_AUTOCONF}" && XDT_PROG_AUTOCONF="autoconf"
(${XDT_PROG_AUTOCONF} --version) </dev/null >/dev/null 2>&0 || {
  cat >&2 <<EOF
xdt-autogen: You must have "autoconf" installed on your system.
             Download the appropriate package for your distribution,
             or get the source tarball at ftp://ftp.gnu.org/pub/gnu/.
EOF
  exit 1
}


##
## Check for intltoolize
##
test -z "${XDT_PROG_INTLTOOLIZE}" && XDT_PROG_INTLTOOLIZE="intltoolize"
if grep "^AC_PROG_INTLTOOL" "${CONFIGURE_FILE}" >/dev/null 2>&1; then
  (${XDT_PROG_INTLTOOLIZE} --version) </dev/null >/dev/null 2>&1 || {
    cat >&2 <<EOF
xdt-autogen: You must have "intltool" installed on your system.
             You can download the source tarball from
             ftp://ftp.gnome.org/pub/GNOME/.
EOF
    exit 1
  }
fi


##
## Check for libtoolize
##
test -z "${XDT_PROG_LIBTOOLIZE}" && XDT_PROG_LIBTOOLIZE="libtoolize"
if grep "^AC_PROG_LIBTOOL" "${CONFIGURE_FILE}" >/dev/null 2>&1; then
  (${XDT_PROG_LIBTOOLIZE} --version) </dev/null >/dev/null 2>&0 || {
    cat >&2 <<EOF
xdt-autogen: You must have "libtool" installed on your system.
             Download the appropriate package for your distribution,
             or get the source tarball at ftp://ftp.gnu.org/pub/gnu/.
EOF
    exit 1
  }
fi


##
## Check for glib-gettextize
##
test -z "${XDT_PROG_GLIB_GETTEXTIZE}" && XDT_PROG_GLIB_GETTEXTIZE="glib-gettextize"
if test -d "${SOURCE_DIR}/po"; then
  (${XDT_PROG_GLIB_GETTEXTIZE} --version) </dev/null >/dev/null 2>&1 || {
    cat >&2 <<EOF
xdt-autogen: You must have "glib2" installed. You can get if from
             ftp://ftp.gtk.org/pub/gtk/.
EOF
    exit 1
  }
fi


##
## Check for gtkdocize
##
test -z "${XDT_PROG_GTKDOCIZE}" && XDT_PROG_GTKDOCIZE="gtkdocize"
if grep "^GTK_DOC_CHECK" "${CONFIGURE_FILE}" >/dev/null 2>&1; then
  (${XDT_PROG_GTKDOCIZE} --version) </dev/null >/dev/null 2>&1 || {
    cat >&2 <<EOF
xdt-autogen: You have "gtk-doc" installed. You can get if from
             http://www.gtk.org/gtk-doc/.
EOF
    exit 1
  }
fi


##
## Check for aclocal
##
test -z "${XDT_PROG_ACLOCAL}" && XDT_PROG_ACLOCAL="aclocal"
(${XDT_PROG_ACLOCAL} --version) </dev/null >/dev/null 2>&1 || {
  cat >&2 <<EOF
xdt-autogen: You must have "autoconf" installed (which includes the
             "aclocal" tool). You can get the source tarball at
             ftp://ftp.gnu.org/pub/gnu/.
EOF
  exit 1
}


##
## Check for autoheader
##
test -z "${XDT_PROG_AUTOHEADER}" && XDT_PROG_AUTOHEADER="autoheader"
if grep "^AM_CONFIG_HEADER" "${CONFIGURE_FILE}" >/dev/null 2>&1; then
  (${XDT_PROG_AUTOHEADER} --version) </dev/null >/dev/null 2>&1 || {
    cat >&2 <<EOF
xdt-autogen: You must have "autoconf" installed (which includes the
             "autoheader" tool). You can get the source tarball at
             ftp://ftp.gnu.org/pub/gnu/.
EOF
    exit 1
  }
fi


##
## Check for automake
##
test -z "${XDT_PROG_AUTOMAKE}" && XDT_PROG_AUTOMAKE="automake"
(${XDT_PROG_AUTOMAKE} --version) </dev/null >/dev/null 2>&1 || {
  cat >&2 <<EOF
xdt-autogen: You must have "automake" installed on your system.
             You can get the source tarball at
             ftp://ftp.gnu.org/pub/gnu/.
EOF
  exit 1
}


##
## Check for configure flags
##
test -z "${XDT_CONFIGURE_FLAGS}" && XDT_CONFIGURE_FLAGS="--enable-maintainer-mode"
CONFIGURE_FLAGS="${XDT_CONFIGURE_FLAGS} $@"


##
## Check for aclocal flags
##
ACLOCAL_FLAGS="${ACLOCAL_FLAGS} ${XDT_ACLOCAL_FLAGS}"
test -d "${SOURCE_DIR}/m4macros" && ACLOCAL_FLAGS="${ACLOCAL_FLAGS} -I ${SOURCE_DIR}/m4macros"
test -d "${SOURCE_DIR}/m4" && ACLOCAL_FLAGS="${ACLOCAL_FLAGS} -I ${SOURCE_DIR}/m4"
for path in `echo "${XDG_DATA_DIRS}" | sed 's,:, ,g'`; do
  if test -d "${path}/xfce4/dev-tools/m4macros"; then
    ACLOCAL_FLAGS="${ACLOCAL_FLAGS} -I ${path}/xfce4/dev-tools/m4macros"
  elif test -d "${path}/xfce4/dev-tools/m4"; then
    ACLOCAL_FLAGS="${ACLOCAL_FLAGS} -I ${path}/xfce4/dev-tools/m4"
  fi
done


##
## Do the real work(TM)
##
if test -d "${SOURCE_DIR}/po"; then
  if test ! -f "${SOURCE_DIR}/aclocal.m4"; then
    (echo "Creating ${SOURCE_DIR}/aclocal.m4..." &&
     echo "dnl Auto-generated by xdt-autogen" > "${SOURCE_DIR}/aclocal.m4") || exit 1
  fi
  (echo "Running ${XDT_PROG_GLIB_GETTEXTIZE} --force --copy..." &&
   ${XDT_PROG_GLIB_GETTEXTIZE} --force --copy) || exit 1
  if test -f "${SOURCE_DIR}/aclocal.m4" -a ! -w "${SOURCE_DIR}/aclocal.m4"; then
    (echo "Making ${SOURCE_DIR}/aclocal.m4 writable..." &&
     chmod u+w "${SOURCE_DIR}/aclocal.m4") || exit 1
  fi
fi

if grep "^AC_PROG_INTLTOOL" "${CONFIGURE_FILE}" >/dev/null 2>&1; then
  (echo "Running ${XDT_PROG_INTLTOOLIZE} --automake --copy --force" &&
   ${XDT_PROG_INTLTOOLIZE} --automake --copy --force) || exit 1
fi

if grep "^AC_PROG_LIBTOOL" "${CONFIGURE_FILE}" >/dev/null 2>&1; then
  (echo "Running ${XDT_PROG_LIBTOOLIZE} --force --copy..." &&
   ${XDT_PROG_LIBTOOLIZE} --force --copy) || exit 1
fi

if grep "^GTK_DOC_CHECK" "${CONFIGURE_FILE}" >/dev/null 2>&1; then
  (echo "Running ${XDT_PROG_GTKDOCIZE} --copy..." &&
   ${XDT_PROG_GTKDOCIZE} --copy) || exit 1
fi

(echo "Running ${XDT_PROG_ACLOCAL} ${ACLOCAL_FLAGS}..." &&
 ${XDT_PROG_ACLOCAL} ${ACLOCAL_FLAGS}) || exit 1

if grep "^AM_CONFIG_HEADER" "${CONFIGURE_FILE}" >/dev/null 2>&1; then
  (echo "Running ${XDT_PROG_AUTOHEADER}..." &&
   ${XDT_PROG_AUTOHEADER}) || exit 1
fi

(echo "Running ${XDT_PROG_AUTOMAKE} --add-missing --copy --gnu..." &&
 ${XDT_PROG_AUTOMAKE} --add-missing --copy --gnu) || exit 1

(echo "Running ${XDT_PROG_AUTOCONF}..." &&
 ${XDT_PROG_AUTOCONF}) || exit 1


##
## Run configure
##
if test x"${NOCONFIGURE}" = x""; then
  (echo "Running ${SOURCE_DIR}/configure ${CONFIGURE_FLAGS}..." &&
   cd "${SOURCE_DIR}" &&
   ./configure ${CONFIGURE_FLAGS} &&
   echo "Now type \"make\" to compile.") || exit 1
else
  echo "Skipping configure process."
fi


# vi:set ts=2 sw=2 et ai: