Multi-package Makefile Example

254 views
Skip to first unread message

Mitchell Hashimoto

unread,
Jan 24, 2012, 7:36:08 PM1/24/12
to golan...@googlegroups.com
Hi,

I'm currently working on a standalone application which is comprised of multiple packages. I was previously using godag for compilation (http://code.google.com/p/godag/) which is a fantastic tool. Unfortunately, this doesn't work with the latest weekly and I require the latest weekly for the database standard libraries. So now I think I'm stuck with moving back to Makefiles, but I can't find any up-to-date examples of a multi-package makefile for a project. The basic layout of the project is the following:

src/main.go
src/package_A/package_A.go
src/package_B/package_B.go
src/package_C/package_C.go

The packages may have dependencies on each other (but nothing circular), and main depends on all packages.

Can anyone point me in the right direction of where I can look into how to easily build this project?

Best,
Mitchell

John Asmuth

unread,
Jan 24, 2012, 7:46:47 PM1/24/12
to golan...@googlegroups.com
the "go" tool can do it, if you set the right env vars.

gb (http://code.google.com/p/go-gb) can do it, and also generate makefiles for you (gb --makefiles).

Mitchell Hashimoto

unread,
Jan 24, 2012, 7:49:39 PM1/24/12
to golan...@googlegroups.com
John,

On Tue, Jan 24, 2012 at 4:46 PM, John Asmuth <jas...@gmail.com> wrote:
the "go" tool can do it, if you set the right env vars.

Anywhere I can find documentation on these env vars? 
 

gb (http://code.google.com/p/go-gb) can do it, and also generate makefiles for you (gb --makefiles).

Thanks, I'll take a look at this as well.

Mitchell

Dave Cheney

unread,
Jan 24, 2012, 7:50:40 PM1/24/12
to golan...@googlegroups.com
I strongly recommend gb, it just works.

http://code.google.com/p/go-gb/

If you decided to use makefiles, the DEPS= stanza may be of some use.

Cheers

Dave

Sent from my iPhone

John Asmuth

unread,
Jan 24, 2012, 8:03:34 PM1/24/12
to golan...@googlegroups.com


On Tuesday, January 24, 2012 7:49:39 PM UTC-5, Mitchell Hashimoto wrote:
On Tue, Jan 24, 2012 at 4:46 PM, John Asmuth <jas...@gmail.com> wrote:
the "go" tool can do it, if you set the right env vars.
Anywhere I can find documentation on these env vars? 

In a terminal, run "go help gopath". This is the best documentation I have found regarding that env var. Unfortunately it doesn't show up in the godoc - you have to get it from the terminal (someone please correct me if I'm wrong). 

Kyle Lemons

unread,
Jan 25, 2012, 12:45:30 AM1/25/12
to golan...@googlegroups.com
In a terminal, run "go help gopath". This is the best documentation I have found regarding that env var. Unfortunately it doesn't show up in the godoc - you have to get it from the terminal (someone please correct me if I'm wrong). 

It's not in the cmd/go documentation, but it's still visible under src/cmd/go/help.go if you want to hunt for it :)

Jim Whitehead II

unread,
Jan 25, 2012, 3:47:37 AM1/25/12
to golan...@googlegroups.com

FWIW I've been keeping a simple project on Github up-to-date with the
latest changes to the build tools. I've just converted it over to
using the 'go' tool and it was fairly easy to set up and get working.
The project consists of two commands (buffer and hello), one of which
relies on another package in the project. Perhaps it will give you an
idea of how you might set things up.

https://github.com/jnwhiteh/golang-examples

- Jim

Reply all
Reply to author
Forward
0 new messages