[Gambas-user] autotools base installer for gambas2 projects

Laurent Carlier lordheavym at ...626...
Fri Jul 13 17:45:17 CEST 2007


I've done some work with autotools for a personnal project, here is some 
results.

Theses files allow you to build your gambas project with the 
classic ./configure, make, make install, make dist, make uninstall. The 
currents limitations are :
- doesn't support gambas component building (not really hard to add)
- support only one project.

The scripts will add automaticly project name and version to the package 
created with make dist. Components needed for the build are detected (perhaps 
not perfectly). Gambas2 utilities are detected too (gba2 and gbc2)

this simple configure.ac do the trick :
dnl ---- Initialization

AC_INIT(configure.ac)
GB_INIT_PROJECT(myproject)

dnl ---- Create makefiles

AC_OUTPUT( \
Makefile \
)

the output  :
lordh at ...1728...:~/gbSVN/gameonlinuxHome/trunk$ ./reconf
/usr/share/aclocal/smpeg.m4:13: warning: underquoted definition of 
AM_PATH_SMPEG
  run info '(automake)Extending aclocal'
  or see http://sources.redhat.com/automake/automake.html#Extending-aclocal
lordh at ...1728...:~/gbSVN/gameonlinuxHome/trunk$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gambas2 binaries... Ok
checking for gb.qt component... Ok
checking for gb.net component... Ok
checking for gb.net.curl component... Ok
configure: creating ./config.status
config.status: creating Makefile
lordh at ...1728...:~/gbSVN/gameonlinuxHome/trunk$ make
Compiling GameOnLinux...
OK
lordh at ...1728...:~/gbSVN/gameonlinuxHome/trunk$ sudo make install
make[1]: entrant dans le 
répertoire « /home/lordh/gbSVN/gameonlinuxHome/trunk »
Installing GameOnLinux.gambas file in /usr/local/bin...
make[1]: Rien à faire pour « install-data-am ».
make[1]: quittant le répertoire « /home/lordh/gbSVN/gameonlinuxHome/trunk »
lordh at ...1728...:~/gbSVN/gameonlinuxHome/trunk$ sudo make uninstall
Removing GameOnLinux.gambas file...
lordh at ...1728...:~/gbSVN/gameonlinuxHome/trunk$ make dist
{ test ! -d GameOnLinux-0.0.1 || { find GameOnLinux-0.0.1 -type 
d ! -perm -200 -exec chmod u+w {} ';' && rm -fr GameOnLinux-0.0.1; }; }
mkdir GameOnLinux-0.0.1
make  \
          top_distdir="GameOnLinux-0.0.1" distdir="GameOnLinux-0.0.1" \
          dist-hook
make[1]: entrant dans le 
répertoire « /home/lordh/gbSVN/gameonlinuxHome/trunk »
make[1]: quittant le répertoire « /home/lordh/gbSVN/gameonlinuxHome/trunk »
find GameOnLinux-0.0.1 -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
          ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
          ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
          ! -type 
d ! -perm -444 -exec /bin/bash /home/lordh/gbSVN/gameonlinuxHome/trunk/install-sh -c -m 
a+r {} {} \; \
        || chmod -R a+r GameOnLinux-0.0.1
tardir=GameOnLinux-0.0.1 
&& /bin/bash /home/lordh/gbSVN/gameonlinuxHome/trunk/missing --run tar 
chof - "$tardir" | GZIP=--best gzip -c >GameOnLinux-0.0.1.tar.gz
{ test ! -d GameOnLinux-0.0.1 || { find GameOnLinux-0.0.1 -type 
d ! -perm -200 -exec chmod u+w {} ';' && rm -fr GameOnLinux-0.0.1; }; }



Have fun !

-------------- next part --------------
#######################################################################################
##
##   GB_FIND() macro is part of gambas2 project
##   by Benoit Minisini
##   others are from me (Laurent Carlier)
##
#######################################################################################

## ---------------------------------------------------------------------------
## GB_INIT_PROJECT
## Initialization and checking for gambas things
##
##   $1 = gambas2 project to build 
## ---------------------------------------------------------------------------

AC_DEFUN([GB_INIT_PROJECT],
[
  if !(test -e $1/.project); then
    AC_MSG_ERROR(Cannot find .project file for $1 !)
  fi

  AM_INIT_AUTOMAKE(`cat $1/.project | grep Title | sed s/"Title="//g`, `cat $1/.project | grep Version | sed s/"Version="//g`)

  ## List of needed components
  COMPONENTS=`cat $1/.project | grep Library | sed s/"Library="//g`

  AC_MSG_CHECKING(for gambas2 binaries)
  GB_FIND(gbc2 gba2,/usr /usr/local, bin sbin)
  if test "$gb_val" != "no"; then
    AC_MSG_RESULT(Ok)
    gb_path=$gb_val
    AC_SUBST(gb_path)
  else
    AC_MSG_RESULT(No)
    AC_MSG_ERROR(Failed to find gbc2 and gba2 utilities, check your gambas2 installation !)
  fi

  for comp in $COMPONENTS; do
    AC_MSG_CHECKING(for $comp component)
    GB_FIND(${comp}.component, /usr /usr/local, lib/gambas2)
    if test "$gb_val" != "no"; then
      AC_MSG_RESULT(Ok)
    else
      AC_MSG_RESULT(No)
      AC_MSG_ERROR(Failed to find $comp component !)
    fi
  done

])

## ---------------------------------------------------------------------------
## GB_FIND
## Find files in directories
##
##   $1 = Files to search
##   $2 = Directories
##   $3 = Sub-directories patterns
##
##   Returns a path list in $gb_val
## ---------------------------------------------------------------------------

AC_DEFUN([GB_FIND],
[
dnl echo "Searching $1, $2, $3"
gb_val=""
gb_save=`pwd`
gb_file_list="$1"

for gb_main_dir in $2; do
  if test -d $gb_main_dir; then
    cd $gb_main_dir
    for gb_search_dir in $3; do
      for gb_dir in $gb_search_dir/ $gb_search_dir/*/ $gb_search_dir/*/*/; do

        gb_new_file_list=""
        gb_find_dir=""

        for gb_file in $gb_file_list; do

          gb_find=no
          if test -r "$gb_main_dir/$gb_dir/$gb_file" || test -d "$gb_main_dir/$gb_dir/$gb_file"; then

            ifelse($4,[],

              gb_find=yes,

              for gb_test in $4; do
                gb_output=`ls -la $gb_main_dir/$gb_dir/$gb_file | grep "$gb_test"`
                if test "x$gb_output" != "x"; then
                  gb_find=yes
                fi
              done
            )

          fi

          if test "$gb_find" = "yes"; then
            if test "x$gb_find_dir" = "x"; then
              if test "x$gb_val" = "x"; then
                gb_val="$gb_main_dir/$gb_dir"
              else
                gb_val="$gb_val $gb_main_dir/$gb_dir"
              fi
            fi
            gb_find_dir=yes
          else
            gb_new_file_list="$gb_new_file_list $gb_file"
          fi

        done

        gb_file_list=$gb_new_file_list

        if test "x$gb_file_list" = "x " || test "x$gb_file_list" = "x"; then
          break 3
        fi

      done
    done
  fi
done

if test "x$gb_file_list" != "x " && test "x$gb_file_list" != "x"; then
  gb_val=no
fi

cd $gb_save
])
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reconf
Type: application/x-shellscript
Size: 82 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20070713/067c8047/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile.am
Type: text/x-makefile
Size: 609 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20070713/067c8047/attachment-0001.bin>
-------------- next part --------------
dnl ---- Initialization

AC_INIT(configure.ac)
GB_INIT_PROJECT(GameOnLinux)

dnl ---- Create makefiles

AC_OUTPUT( \
Makefile \
)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20070713/067c8047/attachment.sig>


More information about the User mailing list