[dwm] Re: Nmake

From: Anselm R. Garbe <arg_AT_10kloc.org>
Date: Fri, 4 Aug 2006 11:14:52 +0200

Hi Icarus,

I really like how nmake does all the ugly job, but after
following the link you pointed to and looking into what the AST
project is all about, I came to the conclusion, that it is too
much overhead to depend on such beast. All this stuff looks
somewhat huge and designed for big cross-platform projects to
have an unique development environment. I actually think that
plan9ports is much smaller than this AST stuff.

That's why I stick to those Makefiles, also because no one would
understand to install AST to compile dwm. It might also confuse
people having two Makefiles in the tarball. And I didn't found
any packages including nmake, for example for Ubuntu. Besides
this, doesn't Microsoft calls its make utility also nmake?

Regards,
        Anselm

On Fri, Aug 04, 2006 at 05:56:31AM -0000, Icarus Sparry wrote:
> This is what nmake does, given the Nmakefile I gave you.
> Firstly I get rid of everything under /tmp/dwm, and then I do a 'namke install'.
>
> $ rm -rf /tmp/dwn/
> $ nmake install
> + cmp -s config.default.h config.h
> + rm -f config.h
> + cp config.default.h config.h
> + cc -O -O3 -I. -I- -c client.c
> + cc -O -O3 -I. -I- -c draw.c
> + cc -O -O3 -I. -I- -c event.c
> + cc -O -O3 -I. -I- '-DVERSION="0.7"' -c main.c
> + cc -O -O3 -I. -I- -c tag.c
> + cc -O -O3 -I. -I- -c util.c
> + cc -O -O3 -Wl,-z,origin '-Wl,-R,$ORIGIN/../lib' -o dwm client.o draw.o event.o main.o tag.o util.o -lXext -lX11 -lnsl -ldl
> + mkdir -p /tmp/dwn/bin
> + ignore cp dwm /tmp/dwn/bin/dwm
> + mkdir -p /tmp/dwn/man/man1
> + ignore cp dwm.1 /tmp/dwn/man/man1/dwm.1
>
> Things worth noting.
> It worked out that main.o depended on the value of the VERSION variable. It converted the VERSION
> variable into a define.
> I still have the 'time based' rule for config.h, so it looks to see if the config.h differs from
> the default, and only copies it if it does,
> It is not applicable here, but it sets up the runtime search path for libraries to be the ../lib
> directory relative to the place the binary is found. This makes it much simpler to ship a tar of
> a program to a remote site - all they need to do is unpack the tar and type the full name of the
> binary for it to be able to find its libraries.
> You are correct that I don't need the '-lsocket'. nmake worked this out and didn't use it.
> The 'ignore' are references to a shell function, which just ignores the return code of the function.
> I listed "dwm.1" as one of the prerequsites of dwm, and it created a manual tree under /tmp/dwm, and
> installed it.
> It is not obvious, but everything is set up to have seperate source and object files, which makes
> it easy to build for say sparc/solaris in one object tree and i686/linux in another object tree,
> but keeping just one source tree.
> If I recover a file, perhaps from a tar archive, so that its timestamp is older than its '.o', then
> nmake will notice and remake the '.o' even though the '.o' is newer than the '.c'. This contrasts
> with normal make, which is strictly timestamp driven.
>
> If I now type 'nmake VERSION=\"test\" install' I get the following.
> $ nmake VERSION=\"test\" install
> + cc -O -O3 -I. -I- '-DVERSION="test"' -c main.c
> + cc -O -O3 -Wl,-z,origin '-Wl,-R,$ORIGIN/../lib' -o dwm client.o draw.o event.o main.o tag.o util.o -lXext -lX11 -lnsl -ldl
> + mv -f /tmp/dwn/bin/dwm /tmp/dwn/bin/dwm.old
> + ignore cp dwm /tmp/dwn/bin/dwm
>
> So you see it only recompiles main.o, with the correct value for VERSION, and then nicely moves
> any running dwm out of the way and copies the new dwm into place. Nothing that could not be
> done with 'make, but you don't need to write it for nmake as it is in the base rules.
>
> Thank you for the pointer to "mk", although I was already aware of it. The nice thing about nmake
> is that it does a lot of the complicated portability work for you. Clearly it is not a simple
> program, but it does enable you to make simple Nmakefiles which are very portable and have a
> lot of functionality in them. For example
>
> $ nmake pax
> + pax -d -w -f dwm-0.7.pax LICENSE Makefile Nmakefile README client.c config.default.h config.mk \
> draw.c dwm.1 dwm.h dwm.html dwm.png event.c main.c tag.c util.c
>
> (Yes, I do not mention config.*.h, just config.default.h in the Nmakefile I sent you).
> Icarus

-- 
 Anselm R. Garbe  ><><  www.ebrag.de  ><><  GPG key: 0D73F361
Received on Fri Aug 04 2006 - 11:14:52 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:29:56 UTC