Thread overview
Auto tools and D
Sep 11, 2011
Steve Teale
Sep 11, 2011
Nick Sabalausky
Sep 11, 2011
Russel Winder
Sep 11, 2011
Steve Teale
Sep 11, 2011
Russel Winder
Sep 11, 2011
Chris Molozian
Sep 11, 2011
Steve Teale
Sep 12, 2011
Russel Winder
September 11, 2011
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
September 11, 2011
"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?


September 11, 2011
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 of 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 — 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?

-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 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


September 11, 2011
Russel,

Thanks for the tips - I shall try SCons.

Steve
September 11, 2011
Steve,

On Sun, 2011-09-11 at 12:37 +0000, Steve Teale wrote:
> Russel,
> 
> Thanks for the tips - I shall try SCons.
> 
> 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.

-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 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


September 11, 2011
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
> 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.
>
September 11, 2011
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
September 12, 2011
Steve,

On Sun, 2011-09-11 at 18:28 +0000, Steve Teale wrote:
> 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

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:
> 
> 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)

I tend to avoid these repetitious tests by doing:

for dependency in (
    'gtk+-2.0 >= 2.24.4',
    'glib-2.0 >= 2.28.6',
    'cairo >= 1.10.2',
    'pango >= 1.28.4',
    ):
    if not conf.CheckPKG(dependency):
        print dependency + ' 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?

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?

-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 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