Move xf86XTrapMod.c from dixmods/extmod to dixmods.
[xorg-util-modular.git] / modularizelibrary.sh
blob05c5d57e66ab166b0d88d1389c2cbeb9efb7bc50
1 #!/bin/bash
3 # Variables
5 if [ -z $1 ] ; then
6 echo
7 echo Usage: $0 \<directory\>
8 echo
9 exit
12 # fixme: modular dir should
14 MODULAR_DIR=`( cd $1 ; cd ../.. ; pwd )`
15 MODULE_DIR=`( cd $1 ; pwd )`
16 MODULE_NAME=`( basename $MODULE_DIR )`
17 modulename=`echo $MODULE_NAME | tr "[:upper:]" "[:lower:]"`
19 if [ -x $MODULE_DIR/man ] ; then
20 HAS_MAN_DIR="yes"
21 else
22 HAS_MAN_DIR="no"
25 if [ -x $MODULE_DIR/include ] ; then
26 HAS_INCLUDE_DIR="yes"
27 else
28 HAS_INCLUDE_DIR="no"
31 if [ -z foo ] ; then
32 echo Modular dir: $MODULAR_DIR
33 echo Module dir : $MODULE_DIR
34 echo Name: $MODULE_NAME
35 echo lower: $modulename
36 echo Man dir: $HAS_MAN_DIR
37 echo Include dir: $HAS_INCLUDE_DIR
41 # Generate build files
42 # Generate autogen.sh
43 # Copy from Xfixes
44 cp $MODULAR_DIR/lib/Xfixes/autogen.sh $MODULAR_DIR/lib/$MODULE_NAME
46 cd $MODULE_DIR
48 touch AUTHORS
49 touch ChangeLog
50 touch COPYING
51 touch INSTALL
52 touch NEWS
53 touch README
55 # touch
56 # Generate README
57 # touch
58 # Generate Makefile.am
60 rm -f Makefile.am
62 cat <<EOF >> Makefile.am
64 # Copyright 2005 Red Hat, Inc.
66 # Permission to use, copy, modify, distribute, and sell this software and its
67 # documentation for any purpose is hereby granted without fee, provided that
68 # the above copyright notice appear in all copies and that both that
69 # copyright notice and this permission notice appear in supporting
70 # documentation, and that the name of Red Hat not be used in
71 # advertising or publicity pertaining to distribution of the software without
72 # specific, written prior permission. Red Hat makes no
73 # representations about the suitability of this software for any purpose. It
74 # is provided "as is" without express or implied warranty.
76 # RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
77 # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
78 # EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
79 # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
80 # DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
81 # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
82 # PERFORMANCE OF THIS SOFTWARE.
84 EOF
86 if [ $HAS_MAN_DIR = "yes" ] ; then
87 cat << EOF >> Makefile.am
88 SUBDIRS = src man
89 EOF
90 else
91 cat <<EOF >> Makefile.am
92 SUBDIRS = src
93 EOF
96 cat <<EOF >> Makefile.am
98 pkgconfigdir = \$(libdir)/pkgconfig
99 pkgconfig_DATA = $modulename.pc
101 EXTRA_DIST = $modulename.pc.in autogen.sh
105 # Generate configure.ac
107 rm -f configure.ac
109 cat <<EOF >> $MODULE_DIR/configure.ac
111 dnl Copyright 2005 Red Hat, Inc.
112 dnl
113 dnl Permission to use, copy, modify, distribute, and sell this software and its
114 dnl documentation for any purpose is hereby granted without fee, provided that
115 dnl the above copyright notice appear in all copies and that both that
116 dnl copyright notice and this permission notice appear in supporting
117 dnl documentation, and that the name of Red Hat not be used in
118 dnl advertising or publicity pertaining to distribution of the software without
119 dnl specific, written prior permission. Red Hat makes no
120 dnl representations about the suitability of this software for any purpose. It
121 dnl is provided "as is" without express or implied warranty.
122 dnl
123 dnl RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
124 dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
125 dnl EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
126 dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
127 dnl DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
128 dnl TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
129 dnl PERFORMANCE OF THIS SOFTWARE.
131 dnl Process this file with autoconf to create configure.
133 AC_PREREQ([2.57])
135 AC_INIT(lib$MODULE_NAME, 7.0.0, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], lib$MODULE_NAME)
136 AM_INIT_AUTOMAKE([dist-bzip2])
137 AM_MAINTAINER_MODE
139 AM_CONFIG_HEADER(config.h)
141 # Check for progs
142 AC_PROG_CC
143 AC_PROG_LIBTOOL
145 # Check for dependencies
146 PKG_CHECK_MODULES(DEP, x11)
148 AC_SUBST(DEP_CFLAGS)
149 AC_SUBST(DEP_LIBS)
151 AC_OUTPUT([Makefile
152 src/Makefile
155 if [ $HAS_MAN_DIR = yes ] ; then
156 cat <<EOF >> configure.ac
157 man/Makefile
161 cat <<EOF >> configure.ac
162 $modulename.pc])
165 # Generate .pc.in
167 cat <<EOF > $modulename.pc.in
168 prefix=@prefix@
169 exec_prefix=@exec_prefix@
170 libdir=@libdir@
171 includedir=@includedir@
173 Name: $MODULE_NAME
174 Description: The $MODULE_NAME Library
175 Version: @PACKAGE_VERSION@
176 Cflags: -I\${includedir} @DEP_CFLAGS@
177 Libs: -L\${libdir} -l$MODULE_NAME @DEP_LIBS@
182 # src/Makefile
185 cd src
187 rm -f Makefile.am
189 cat <<EOF > Makefile.am
190 lib_LTLIBRARIES = lib$MODULE_NAME.la
192 lib${MODULE_NAME}_la_SOURCES = \
195 for x in `ls *.[ch]` ; do
196 LAST=$x
197 done
199 for x in `ls *.[ch]`; do
200 if [ $x = $LAST ] ; then
201 echo \ \ \ \ \ \ \ \ \ $x >> Makefile.am
202 else
203 echo \ \ \ \ \ \ \ \ \ $x \\ >> Makefile.am
205 done
207 if [ $HAS_INCLUDE_DIR = yes ] ; then
209 HEADERFILE=`find ../include -name "*.h" | head -1`
211 INCLUDE_SRC_DIR=`dirname $HEADERFILE | sed "s/../\\$(top_srcdir)/"`
213 INCLUDE_INSTALL_DIR=`dirname $HEADERFILE | sed "s/..\/include/\\$(includedir)/"`
215 cat <<EOF >> Makefile.am
217 INCLUDES = -I$INCLUDE_SRC_DIR
223 cat <<EOF >> Makefile.am
225 lib${MODULE_NAME}_la_LIBADD = @DEP_LIBS@
227 lib${MODULE_NAME}_la_LDFLAGS = -version-info 7:0:0 -no-undefined
232 if [ $HAS_INCLUDE_DIR = yes ] ; then
234 cat <<EOF >> Makefile.am
236 lib${MODULE_NAME}includedir = $INCLUDE_INSTALL_DIR
237 lib${MODULE_NAME}include_HEADERS = \\
240 for f in `find ../include -name "*.h"` ; do
241 LAST=$f
242 done
244 for f in `find ../include -name "*.h"` ; do
246 NAME=`echo $f | sed "s/../\\$(top_srcdir)/"`
248 echo -n \ \ \ \ $NAME >> Makefile.am
250 if [ $LAST = $f ] ; then
251 echo >> Makefile.am
252 else
253 echo \\ >> Makefile.am
255 done
258 echo >> Makefile.am
261 # man/Makefile
264 if [ $HAS_MAN_DIR = yes ] ; then
266 cd ../man
267 rm -f Makefile.am
268 cat <<EOF > Makefile.am
269 # Copyright 2005 Red Hat, Inc.
271 # Permission to use, copy, modify, distribute, and sell this software and its
272 # documentation for any purpose is hereby granted without fee, provided that
273 # the above copyright notice appear in all copies and that both that
274 # copyright notice and this permission notice appear in supporting
275 # documentation, and that the name of Red Hat not be used in
276 # advertising or publicity pertaining to distribution of the software without
277 # specific, written prior permission. Red Hat makes no representations about
278 # the suitability of this software for any purpose. It is provided "as is" without
279 # express or implied warranty.
281 # RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
282 # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
283 # EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
284 # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
285 # DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
286 # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
287 # PERFORMANCE OF THIS SOFTWARE.
290 man_MANS = \\
293 for x in `ls *.3` ; do
294 LAST=$x
295 done
297 for x in `ls *.3`; do
298 if [ $x = $LAST ] ; then
299 echo \ \ \ \ \ \ \ \ \ $x >> Makefile.am
300 else
301 echo \ \ \ \ \ \ \ \ \ $x \\ >> Makefile.am
303 done
305 echo "EXTRA_DIST = \$(man3_MANS)" >> Makefile.am