- Allow setting $MAKE to specify using something other than "make"
[xorg-util-modular.git] / modularizevideodriver.sh
blob6bf7250c17661130dec87e80622efcfd4beda640
1 #!/bin/bash
3 ###########################
5 # Variables and setup
8 if [ -z $1 ] ; then
9 echo
10 echo Usage: $0 \<directory\>
11 echo
12 exit
15 if [ ! -z $2 ] ; then
16 if [ $2="dri" ] ; then
17 has_dri="yes"
21 MODULAR_DIR=`( cd $1 ; cd ../.. ; pwd )`
22 MODULE_DIR=`( cd $1 ; pwd )`
23 MODULE_NAME=`( basename $MODULE_DIR )`
24 modulename=`echo $MODULE_NAME | tr "[:upper:]" "[:lower:]"`
25 drivername=`echo $MODULE_NAME | sed s/xf86-video-//`
27 if [ -z foo ] ; then
28 echo Modular dir: $MODULAR_DIR
29 echo Module dir : $MODULE_DIR
30 echo Name: $MODULE_NAME
31 echo lower: $modulename
32 echo Man dir: $HAS_MAN_DIR
33 echo Include dir: $HAS_INCLUDE_DIR
36 cd $MODULE_DIR
39 # man pages?
42 for x in `ls man/*` ; do
43 man_pages=true
44 done
47 ###############################
49 # Generate autogen.sh
52 rm -f autogen.sh
54 cat <<EOF >> autogen.sh
55 #! /bin/sh
57 srcdir=\`dirname \$0\`
58 test -z "\$srcdir" && srcdir=.
60 ORIGDIR=\`pwd\`
61 cd \$srcdir
63 autoreconf -v --install || exit 1
64 cd \$ORIGDIR || exit \$?
66 \$srcdir/configure --enable-maintainer-mode "\$@"
68 EOF
70 chmod a+x autogen.sh
73 ###################################
75 # Generate toplevel Makefile.am
78 rm -f Makefile.am
80 cat <<EOF >> Makefile.am
81 # Copyright 2005 Adam Jackson.
83 # Permission is hereby granted, free of charge, to any person obtaining a
84 # copy of this software and associated documentation files (the "Software"),
85 # to deal in the Software without restriction, including without limitation
86 # on the rights to use, copy, modify, merge, publish, distribute, sub
87 # license, and/or sell copies of the Software, and to permit persons to whom
88 # the Software is furnished to do so, subject to the following conditions:
90 # The above copyright notice and this permission notice (including the next
91 # paragraph) shall be included in all copies or substantial portions of the
92 # Software.
94 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
95 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
96 # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
97 # ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
98 # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
99 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
101 AUTOMAKE_OPTIONS = foreign
104 if [ -z $man_pages ] ; then
105 echo SUBDIRS = src >> Makefile.am
106 else
107 echo SUBDIRS = src man >> Makefile.am
111 # Generate configure.ac
114 rm -f configure.ac
116 cat <<EOF >> configure.ac
117 # Copyright 2005 Adam Jackson.
119 # Permission is hereby granted, free of charge, to any person obtaining a
120 # copy of this software and associated documentation files (the "Software"),
121 # to deal in the Software without restriction, including without limitation
122 # on the rights to use, copy, modify, merge, publish, distribute, sub
123 # license, and/or sell copies of the Software, and to permit persons to whom
124 # the Software is furnished to do so, subject to the following conditions:
126 # The above copyright notice and this permission notice (including the next
127 # paragraph) shall be included in all copies or substantial portions of the
128 # Software.
130 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
131 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
132 # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
133 # ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
134 # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
135 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
137 # Process this file with autoconf to produce a configure script
139 AC_PREREQ(2.57)
140 AC_INIT([xf86-video-$drivername],
141 0.1.0,
142 [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
143 xf86-video-$drivername)
145 AC_CONFIG_SRCDIR([Makefile.am])
146 AM_CONFIG_HEADER([config.h])
147 AC_CONFIG_AUX_DIR(.)
149 AM_INIT_AUTOMAKE([dist-bzip2])
151 AM_MAINTAINER_MODE
153 # Checks for programs.
154 AC_PROG_LIBTOOL
155 AC_PROG_CC
157 AH_TOP([#include "xorg-server.h"])
159 AC_ARG_WITH(xorg-module-dir,
160 AC_HELP_STRING([--with-xorg-module-dir=DIR],
161 [Default xorg module directory [[default=\$libdir/xorg/modules]]]),
162 [moduledir="\$withval"],
163 [moduledir="\$libdir/xorg/modules"])
166 if [ ! -z $has_dri ] ; then
167 cat <<EOF >> configure.ac
169 AC_ARG_ENABLE(dri, AC_HELP_STRING([--disable-dri],
170 [Disable DRI support [[default=auto]]]),
171 [DRI="\$enableval"],
172 [DRI=auto])
176 cat <<EOF >> configure.ac
177 # Checks for pkg-config packages
178 PKG_CHECK_MODULES(XORG, [xorg-server xproto])
179 sdkdir=\$(pkg-config --variable=sdkdir xorg-server)
181 # Checks for libraries.
183 # Checks for header files.
184 AC_HEADER_STDC
188 if [ ! -z $has_dri ] ; then
189 cat <<EOF >> configure.ac
190 if test "\$DRI" != no; then
191 AC_CHECK_FILE([\${sdkdir}/dri.h],
192 [have_dri_h="yes"], [have_dri_h="no"])
193 AC_CHECK_FILE([\${sdkdir}/sarea.h],
194 [have_sarea_h="yes"], [have_sarea_h="no"])
195 AC_CHECK_FILE([\${sdkdir}/dristruct.h],
196 [have_dristruct_h="yes"], [have_dristruct_h="no"])
199 AC_MSG_CHECKING([whether to include DRI support])
200 if test x\$DRI = xauto; then
201 if test "\$ac_cv_header_dri_h" = yes -a \\
202 "\$ac_cv_header_sarea_h" = yes -a \\
203 "\$ac_cv_header_dristruct_h" = yes; then
204 DRI="yes"
205 else
206 DRI="no"
209 AC_MSG_RESULT([\$DRI])
211 AM_CONDITIONAL(DRI, test x\$DRI = xyes)
212 if test "\$DRI" = yes; then
213 PKG_CHECK_MODULES(DRI, [libdrm])
214 AC_DEFINE(XF86DRI,1,[Enable DRI driver support])
215 AC_DEFINE(XF86DRI_DEVEL,1,[Enable developmental DRI driver support])
218 AC_SUBST([DRI_CFLAGS])
221 cat <<EOF >> configure.ac
222 AC_SUBST([XORG_CFLAGS])
223 AC_SUBST([moduledir])
225 AC_OUTPUT([
226 Makefile
227 src/Makefile
230 if [ ! -z $man_pages ] ; then
231 cat <<EOF >> configure.ac
232 man/Makefile
236 cat <<EOF >> configure.ac
240 ##############################
242 # man/Makefile.am
244 if [ ! -z $man_pages ] ; then
245 cd man
247 rm -f Makefile.am
249 cat <<EOF >> Makefile.am
250 # Copyright 2005 Adam Jackson.
252 # Permission is hereby granted, free of charge, to any person obtaining a
253 # copy of this software and associated documentation files (the "Software"),
254 # to deal in the Software without restriction, including without limitation
255 # on the rights to use, copy, modify, merge, publish, distribute, sub
256 # license, and/or sell copies of the Software, and to permit persons to whom
257 # the Software is furnished to do so, subject to the following conditions:
259 # The above copyright notice and this permission notice (including the next
260 # paragraph) shall be included in all copies or substantial portions of the
261 # Software.
263 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
264 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
265 # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
266 # ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
267 # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
268 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
270 dist_man_MANS = \\
273 for x in `ls *.4` ; do
274 LAST=$x ;
275 done
277 for x in `ls *.4` ; do
278 if [ $x = $LAST ] ; then
279 echo \ \ \ \ \ \ \ \ \ $x >> Makefile.am
280 else
281 echo \ \ \ \ \ \ \ \ \ $x \\ >> Makefile.am
283 done ;
284 cd ..
287 ############################
289 # src/Makefile.am
292 cd src
294 rm -f Makefile.am
296 cat <<EOF >> Makefile.am
297 # Copyright 2005 Adam Jackson.
299 # Permission is hereby granted, free of charge, to any person obtaining a
300 # copy of this software and associated documentation files (the "Software"),
301 # to deal in the Software without restriction, including without limitation
302 # on the rights to use, copy, modify, merge, publish, distribute, sub
303 # license, and/or sell copies of the Software, and to permit persons to whom
304 # the Software is furnished to do so, subject to the following conditions:
306 # The above copyright notice and this permission notice (including the next
307 # paragraph) shall be included in all copies or substantial portions of the
308 # Software.
310 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
311 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
312 # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
313 # ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
314 # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
315 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
317 # this is obnoxious:
318 # -module lets us name the module exactly how we want
319 # -avoid-version prevents gratuitous .0.0.0 version numbers on the end
320 # _ladir passes a dummy rpath to libtool so the thing will actually link
321 # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
324 if [ ! -z $has_dri ]; then
325 cat <<EOF >> Makefile.am
326 AM_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@
328 else
329 cat <<EOF >> Makefile.am
330 AM_CFLAGS = @XORG_CFLAGS@
334 cat <<EOF >> Makefile.am
335 ${drivername}_drv_la_LTLIBRARIES = ${drivername}_drv.la
336 ${drivername}_drv_la_LDFLAGS = -module -avoid-version
337 ${drivername}_drv_ladir = @moduledir@/drivers
339 ${drivername}_drv_la_SOURCES = \\
342 for x in `ls *.[ch]` ; do
343 LAST=$x
344 done
346 for x in `ls *.[ch]` ; do
347 if [ $x = $LAST ] ; then
348 echo \ \ \ \ \ \ \ \ \ $x >> Makefile.am
349 else
350 echo \ \ \ \ \ \ \ \ \ $x \\ >> Makefile.am
352 done
354 cd ..