www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Auto tools and D

reply Steve Teale <steve.teale britseyeview.com> writes:
Has anyone succeeded in getting a piece of Linux software written with DMD to
the point where you could just do

./configure
make
sudo make install

If so, I could use some help.

Steve
Sep 10 2011
parent reply "Nick Sabalausky" <a a.a> writes:
"Steve Teale" <steve.teale britseyeview.com> wrote in message 
news:j4hh0n$73t$1 digitalmars.com...
 Has anyone succeeded in getting a piece of Linux software written with DMD 
 to
 the point where you could just do

 ./configure
 make
 sudo make install

 If so, I could use some help.

It's pretty easy, really: ----------------------------- $cat configure #!/bin/sh echo Done $cat makefile all: ./the-REAL-buildscript-maybe-even-written-in-D install: ./the-REAL-install-script ----------------------------- Ok, granted, that sounds rather tongue-in-cheek, but I'm fairily serious about it: Is there some reason you need to actually put it all through autotools? I'm no expert, but autotools strikes me as just a collection of workarounds to paper over some of the crappiness of C/C++ and make. Why apply it to D?
Sep 11 2011
next sibling parent reply Russel Winder <russel russel.org.uk> writes:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Sun, 2011-09-11 at 03:46 -0400, Nick Sabalausky wrote:
[ . . . ]
 Ok, granted, that sounds rather tongue-in-cheek, but I'm fairily serious=

 about it: Is there some reason you need to actually put it all through=

 autotools? I'm no expert, but autotools strikes me as just a collection o=

 workarounds to paper over some of the crappiness of C/C++ and make. Why=

 apply it to D?

Autotools is a very good piece of m4 hacking but it is a sticking plaster over Make =E2=80=94 which was a revolution and revelation in 1978, = but is now not start of the art. I guess if you want to stay with Make then CMake is the way forward. Otherwise SCons or Waf. Or Drake? --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Sep 11 2011
parent reply Steve Teale <steve.teale britseyeview.com> writes:
Russel,

Thanks for the tips - I shall try SCons.

Steve
Sep 11 2011
parent Steve Teale <steve.teale britseyeview.com> writes:
I was able to get some distance down the road with:

env = Environment()

def CheckPKGConfig(context, version):
     context.Message( 'Checking for pkg-config... ' )
     ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' %
version)[0]
     context.Result( ret )
     return ret

def CheckPKG(context, name):
     context.Message( 'Checking for %s... ' % name )
     ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
     context.Result( ret )
     return ret

# Configuration:

conf = Configure(env, custom_tests = { 'CheckPKGConfig' : CheckPKGConfig,
                                       'CheckPKG' : CheckPKG })

if not conf.CheckPKGConfig('0.15.0'):
     print 'pkg-config >= 0.15.0 not found.'
     Exit(1)

if not conf.CheckPKG('gtk+-2.0 >= 2.24.4'):
     print 'gtk+-2.0 >= 2.24.4 not found.'
     Exit(1)

if not conf.CheckPKG('glib-2.0 >= 2.28.6'):
     print 'glib-2.0 >= 2.28.6 not found.'
     Exit(1)

if not conf.CheckPKG('cairo >= 1.10.2'):
     print 'cairo >= 1.10.2 not found.'
     Exit(1)

if not conf.CheckPKG('pango >= 1.28.4'):
     print 'pango >= 1.28.4 not found.'
     Exit(1)

# Your extra checks here

env = conf.Finish()


Program('compo', Glob('*.d'), LIBS = [ 'gtkd', 'phobos2', 'dl', 'rt' ],
                              LIBPATH = [ '/usr/lib32' ], DPATH =
['/usr/local/include/d'])

This at least allows me to check for the versions of GTK+ components that I
built
against.

But I don't know how to check for the versions of DMD and gtkD.

Does your stuff get me anywhere in that direction Russel?

Steve
Sep 11 2011
prev sibling next sibling parent Russel Winder <russel russel.org.uk> writes:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Steve,

On Sun, 2011-09-11 at 12:37 +0000, Steve Teale wrote:
 Russel,
=20
 Thanks for the tips - I shall try SCons.
=20
 Steve

SCons 2.1.0 just came out, though I have to admit I use Mercurial tip. The DMD tool that comes as standard with SCons is not really sufficient to the task. I have a friendly fork of this at https://bitbucket.org/russel/scons_dmd_new. The idea had been to create a patch to merge into SCons core just before each release, but I failed this time :-( If you find any issues feel free to hassle me and or email the folk on the SCons user list. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Sep 11 2011
prev sibling next sibling parent Chris Molozian <chris cmoz.me> writes:
Perhaps give Jam (http://www.freetype.org/jam/index.html) a try, it's 
got builds for almost every platform and works well for me. I use this 
Jamfile for most D projects:


# Requires the Jam (ftjam) build tool (http://www.freetype.org/jam/)
ALL_LOCATE_TARGET = build ;
SubDir TOP ;

# auxiliary rules to support building D code with perforce Jam
rule UserObject {
     switch $(>:S) {
      case .d : Dc $(<) : $(>) ;
      case * :
         Exit "Unknown suffix on " $(>) " - see UserObject rule in 
Jambase." ;
     }
}

rule Dc {
     Depends $(<) : $(>) ;
     DCFLAGS on $(<) += $(DCFLAGS) $(SUBDIRDCFLAGS) ;
}

actions Dc {
     $(DC) -c -of$(<) $(DCFLAGS) $(DOPTIM) $(>)
}

# override the Link action to correct for the dmd compiler -o flag
actions Link bind NEEDLIBS {
     $(LINK) $(LINKFLAGS) -of$(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
}


DC = dmd ;
DCFLAGS = -fPIC -O -inline -release -w -wi -I./src/ ;
LINK = $(DC) ;
DFILES = [ GLOB src : *.d ] ;

MainFromObjects myprogam : $(DFILES:S=.o) ;
Objects $(DFILES) ;


Hope this helps,

Chris


On 09/11/11 17:28, Russel Winder wrote:
 Steve,

 On Sun, 2011-09-11 at 12:37 +0000, Steve Teale wrote:
 Russel,

 Thanks for the tips - I shall try SCons.

 Steve

The DMD tool that comes as standard with SCons is not really sufficient to the task. I have a friendly fork of this at https://bitbucket.org/russel/scons_dmd_new. The idea had been to create a patch to merge into SCons core just before each release, but I failed this time :-( If you find any issues feel free to hassle me and or email the folk on the SCons user list.

Sep 11 2011
prev sibling parent Russel Winder <russel russel.org.uk> writes:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Steve,

On Sun, 2011-09-11 at 18:28 +0000, Steve Teale wrote:
 I was able to get some distance down the road with:
=20
 env =3D Environment()
=20
 def CheckPKGConfig(context, version):
      context.Message( 'Checking for pkg-config... ' )
      ret =3D context.TryAction('pkg-config --atleast-pkgconfig-version=3D=

      context.Result( ret )
      return ret
=20
 def CheckPKG(context, name):
      context.Message( 'Checking for %s... ' % name )
      ret =3D context.TryAction('pkg-config --exists \'%s\'' % name)[0]
      context.Result( ret )
      return ret

The support for pkg-config in SCons needs improving, you shouldn't have to define these sorts of function yourself. I have variants on the above, but the itch to actually create something in SCons never got bad enough to have to scratch. If there were others definitely using pkg-config with SCons, we should club together and create something that people could use and which could be lined up for inclusion in SCons.
 # Configuration:
=20
 conf =3D Configure(env, custom_tests =3D { 'CheckPKGConfig' : CheckPKGCon=

                                        'CheckPKG' : CheckPKG })
=20
 if not conf.CheckPKGConfig('0.15.0'):
      print 'pkg-config >=3D 0.15.0 not found.'
      Exit(1)
=20
 if not conf.CheckPKG('gtk+-2.0 >=3D 2.24.4'):
      print 'gtk+-2.0 >=3D 2.24.4 not found.'
      Exit(1)
=20
 if not conf.CheckPKG('glib-2.0 >=3D 2.28.6'):
      print 'glib-2.0 >=3D 2.28.6 not found.'
      Exit(1)
=20
 if not conf.CheckPKG('cairo >=3D 1.10.2'):
      print 'cairo >=3D 1.10.2 not found.'
      Exit(1)
=20
 if not conf.CheckPKG('pango >=3D 1.28.4'):
      print 'pango >=3D 1.28.4 not found.'
      Exit(1)

I tend to avoid these repetitious tests by doing: for dependency in ( 'gtk+-2.0 >=3D 2.24.4', 'glib-2.0 >=3D 2.28.6', 'cairo >=3D 1.10.2', 'pango >=3D 1.28.4', ): if not conf.CheckPKG(dependency): print dependency + ' not found.' Exit(1)
 # Your extra checks here
=20
 env =3D conf.Finish()
=20
=20
 Program('compo', Glob('*.d'), LIBS =3D [ 'gtkd', 'phobos2', 'dl', 'rt' ],
                               LIBPATH =3D [ '/usr/lib32' ], DPATH =3D
 ['/usr/local/include/d'])
=20
 This at least allows me to check for the versions of GTK+ components that=

 against.
=20
 But I don't know how to check for the versions of DMD and gtkD.
=20
 Does your stuff get me anywhere in that direction Russel?

The DMD tool handles all the Phobos and known transitive dependencies so by including it you can get rid of the LIBPATH and DPATH stuff and also the LIBS, except the gtkd. I wonder if it might be worth having a gtkd tool? --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Sep 12 2011