Lazy Programmer

tips for open source software

Parrot: build parrot on cygwin

Building parrot on cygwin is not as straightforward as on other platforms. You have to add path of libparrot.dll into PATH environment variable. For example,

PATH=/path/to/parrot/blib/lib:$PATH

It’s better to add this line into your .bashrc file so that you do not need to run it every time you start a console.

After that, you can follow basic building steps to build parrot.

$ perl Configure.PL
$ make

To test parrot, write a hello.pir

.sub main
    print "Hello world!\n"
.end

And then run it

$ parrot hello.pir

If everything is ok, you should get a string as output.

September 29, 2007 Posted by Wang Liang | Cygwin, Parrot | | No Comments Yet

Makefile: whitespace in path

I hates whitespace in path. I wrote a Perl script which uses a resource file and several template files. So I created a makefile to copy them to user’s HOME directory. It looks like:

$(HOME)/a: a
      cp -f $< $@

Unfortunately, it doesn’t work when there are whitespaces in $(HOME) string, such as /abc/d e/. That happens on Cygwin default installation.

You can double-qoute path, but there are whitespaces in target and target can not be double-qouted. Finally, I find a workaround after diving into `make' info page for a long time. Here is the trick.

nullstring :=
space := $(nullstring) # a space at the end
QUOTED_HOME=$(subst $(space),\ ,$(HOME))
$(QUOTED_HOME)/a:a
      cp -f $< $(subst $(space),\ ,$@)

September 29, 2007 Posted by Wang Liang | Makefile | | 1 Comment

Emacs: Do what I mean when commenting

I should know this command earlier. It’s so convenient.

M-x comment-dwim

I always run M-x comment-region and M-x uncomment-region manually except when using C Mode since I can use C-c C-c when commenting.

Don’t do it that way any more. And even fortunately, M-x comment-dwim is bound to M-; by default.

According to help, this command runs different commenting command on different situation. For example, if you mark a region, this command comments code in the region. If you mark comments, this command uncomments them. Read more on help, and read now.

September 17, 2007 Posted by Wang Liang | Emacs | | No Comments Yet