All of lore.kernel.org
 help / color / mirror / Atom feed
From: George Dunlap <dunlapg@umich.edu>
To: Wei Liu <wei.liu2@citrix.com>
Cc: Ronald Rojas <ronladred@gmail.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH RFC] tools/xenlight: Create xenlight Makefile
Date: Wed, 30 Nov 2016 09:40:47 +1100	[thread overview]
Message-ID: <CAFLBxZa4FnSTMfdbnGT816Cka=uKCjwVuKav0syaFHooe+_NUg@mail.gmail.com> (raw)
In-Reply-To: <20161129071908.GL11640@citrix.com>

On Tue, Nov 29, 2016 at 6:19 PM, Wei Liu <wei.liu2@citrix.com> wrote:
> On Mon, Nov 28, 2016 at 12:18:03PM -0500, Ronald Rojas wrote:
>> diff --git a/tools/Makefile b/tools/Makefile
>> index 71515b4..b89f06b 100644
>> --- a/tools/Makefile
>> +++ b/tools/Makefile
>> @@ -11,6 +11,7 @@ SUBDIRS-y += misc
>>  SUBDIRS-y += examples
>>  SUBDIRS-y += hotplug
>>  SUBDIRS-y += xentrace
>> +SUBDIRS-y += golang/xenlight
>
> This shouldn't be built unconditionally.
>
> Please use configure to probe for go compiler first.
>
> "GNU autotools" is the term to google for. But I guess it wouldn't be
> too hard to follow existing examples.
>
> Don't hesitate to ask questions.

BTW I suggested that Ronald start with enabling it unconditionally, so
that he could get something straightforward related to his project
(golang bindings) accomplished before having to dive right into
something complicated and unrelated (autoconf).

But it's probably worth communicating that here with a comment.  I'll
respond directly to his mail.

>>  SUBDIRS-$(CONFIG_XCUTILS) += xcutils
>>  SUBDIRS-$(CONFIG_X86) += firmware
>>  SUBDIRS-y += console
>> @@ -311,6 +312,20 @@ subdir-install-debugger/gdbsx: .phony
>>  subdir-all-debugger/gdbsx: .phony
>>       $(MAKE) -C debugger/gdbsx all
>>
>> +subdir-all-golang/xenlight: .phony
>> +     $(MAKE) -C golang/xenlight all
>> +
>> +subdir-clean-golang/xenlight: .phony
>> +     $(MAKE) -C golang/xenlight clean
>> +
>> +subdir-install-golang/xenlight: .phony
>> +     $(MAKE) -C golang/xenlight install
>> +
>> +subdir-build-golang/xenlight: .phony
>> +     $(MAKE) -C golang/xenlight build
>> +
>> +subdir-distclean-golang/xenlight: .phony
>> +     $(MAKE) -C golang/xenlight distclean
>>
>
> I think I would prefer to organise this like python bindings. That is,
> to have a dedicated Makefile under $LANG (python or golang) directory.
>
> What do you think?

That's what I had in mind as well.

>
>>  subdir-clean-debugger/kdd subdir-distclean-debugger/kdd: .phony
>>       $(MAKE) -C debugger/kdd clean
>> diff --git a/tools/golang/xenlight/Makefile b/tools/golang/xenlight/Makefile
>> new file mode 100644
>> index 0000000..c723c1d
>> --- /dev/null
>> +++ b/tools/golang/xenlight/Makefile
>> @@ -0,0 +1,29 @@
>> +XEN_ROOT=$(CURDIR)/../../..
>> +include $(XEN_ROOT)/tools/Rules.mk
>> +
>> +BINARY = xenlightgo
>> +GO = go
>
> This should probably be:
>
>   GO ?= go

With an additional comment above it:

# FIXME Use autoconf to find this?

>> +
>> +.PHONY: all
>> +all: build
>> +
>> +.PHONY: build
>> +build: xenlight
>> +
>> +.PHONY: install
>> +install: build
>> +     [ -f $(BINARY) ] || $(INSTALL_PROG) xenlight.go $(DESTDIR)$(bindir)
>> +
>> +.PHONY: clean
>> +clean:
>> +     $(RM) $(BINARY)
>
> If there are other intermediate files generated, they should be deleted,
> too.

At the moment there won't be any intermediate files -- "go build"
creates a temporary directory for those and deletes them after it's
done automatically.

>> +.PHONY: distclean
>> +distclean: clean
>> +
>> +
>> +xenlight: xenlight.go
>
> xenlightgo: xenlight.go and delete BINARY
>
> or
>
> $(BINARY): xenlight.go
>
>> +     $(GO) build -o $(BINARY) xenlight.go
>
> Use $@ instead of $(BINARY).  Use $< instead of xenlight.go.
>
> But before we spend too much time on details, let's sort out some higher
> level issues first. My golang knowledge is rather rusted, please bear
> with me. :-)
>
> I have a question: how does golang build a package that has multiple
> files? Presumably it has some sort of file that acts like Makefile. If
> so, you should probably introduce that now and use that to build this
> package.

Not really -- you either hand it all the files it needs (like you
would a C compiler), or you hand it some of the files it needs and
also give it a directory to the source code for your packages, or you
do things entirely its way and just type "go build" and it figures out
what to do.  If you want Makefile-like functionality you probably want
make. :-)

In our case we'll probably end up doing the first for building the
xenlight package, and the second for building the test tool.

But there's no point in getting into the nitty-gritty now because what
Ronald has here isn't a package (meant to be linked against), but a
program (meant to be run).  So we'll have to wait until we have basic
package stuff to figure out the best way to link it.

 -George

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-11-29 22:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28 17:18 (no subject) Ronald Rojas
2016-11-28 17:18 ` [PATCH RFC] tools/xenlight: Create xenlight Makefile Ronald Rojas
2016-11-29  7:19   ` Wei Liu
2016-11-29 22:40     ` George Dunlap [this message]
2016-11-30  1:30   ` George Dunlap
2016-12-01 19:18     ` Ronald Rojas
2016-12-15 23:20 Ronald Rojas
2016-12-16  3:20 ` Doug Goldstein
2016-12-16  4:28   ` George Dunlap
2016-12-16  4:27 ` George Dunlap
2016-12-22  0:34   ` Ronald Rojas
2016-12-22 15:26 Ronald Rojas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFLBxZa4FnSTMfdbnGT816Cka=uKCjwVuKav0syaFHooe+_NUg@mail.gmail.com' \
    --to=dunlapg@umich.edu \
    --cc=ian.jackson@eu.citrix.com \
    --cc=ronladred@gmail.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.