Last change: $Date: 2004/08/12 15:30:18 $ GMT

Compiling the great GWM in the post 1996 world

GWM hasn't changed much since 1996 (sob). Compilers, however, do have changed, and if you want to give gwm a try starting from the sources, this may throw you into trouble.

Glenelg Smith (thanks to him !) told me that he had that kind of trouble with RedHat 7.1 and Fedora, and I had the same with RedHat 7.2, so here's what I did:

First the symptoms: you're trying to compile gwm, and here's what happens:

$ make
gcc -m32 -O2  -pipe -march=i386 -mcpu=i686 -fno-strict-aliasing
-pipe     -I/usr/X11R6/include/extensions -I/usr/X11R6/include   
-Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L                          
-D_POSIX_SOURCE -D_XOPEN_SOURCE                          -D_BSD_SOURCE
-DWOOL_APP_NAME=\"GWM\"   -DWOOL_APP_name=\"gwm\" -DGWM
-DDEFAULT_DEFAULT_WLPATH=\"/usr/local/lib/gwm\"       -c -o

In file included from wool.yac:95:
lex.yy.c:20: error: initializer element is not constant
lex.yy.c:20: error: (near initialization for `yyin')
lex.yy.c:20: error: initializer element is not constant
lex.yy.c:20: error: (near initialization for `yyout')
make: *** [] Error 1

Bad, bad, bad. The problem lies in the flex generated file lex.yy.c. Ok, I recompile from a dist clean with:
$ xmkmf -a
$ make
C prescribes that you can't write FILE *stuff = thing if your compiler can't determine statically that thing is constant (that is, something with a value at the time of the assignment).

Semantically however, the incriminated lines meaning is clear:

FILE *yyin = {stdin}, *yyout = {stdout}; This can be interpreted as "every time I write yyin in this file, I really mean stdin" (assuming that yyin is never affected a value, which is the case). Same for stdout.

So I rewrote the line as follows:

/*FILE *yyin = {stdin}, *yyout = {stdout};*/ #define yyin (stdin) #define yyout (stdout) (admittedly a quick-and-dirty hack) and it passed.

Later on, I went into another problem, and so could you:

$ cd /tmp/gwm-1.8c/
gcc -O2 -march=i386 -mcpu=i686 -pipe     -I/usr/X11R6/include/extensions 
-I/usr/X11R6/include    -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L 
-DWOOL_APP_NAME=\"GWM\"          -DWOOL_APP_name=\"gwm\" -DGWM 
-DINSTALL_PATH=\"/usr/local/lib/gwm\"   -DINSTALL_DIR=\"/usr/local/lib/gwm\" 
-DDEFAULT_DEFAULT_WLPATH=\"/usr/local/lib/gwm\"       -c -o bar.o bar.c
In file included from bar.c:14:
wool.h:42:9: warning: extra tokens at end of #endif directive
bar.c:34:26: shape.h: No such file or directory
bar.c: In function `UpdateBarShape':
bar.c:622: `ShapeBounding' undeclared (first use in this function)
bar.c:622: (Each undeclared identifier is reported only once
bar.c:622: for each function it appears in.)
bar.c:624: `ShapeSet' undeclared (first use in this function)
bar.c:633: `ShapeSubtract' undeclared (first use in this function)
bar.c:646: `ShapeUnion' undeclared (first use in this function)
bar.c:669: `ShapeIntersect' undeclared (first use in this function)
make: *** [bar.o] Error 1
This comes from the shape.h file, from an X extension for having non rectangular windows. In my (standard RH 7.2) installation, the file's in /usr/X11R6/include/X11/extensions, while only /usr/X11R6/include/extensions is defined by the Makefile.

So I changed line 897 of the Makefile from: EXTRA_INCLUDES=-I$(INCDIR)/extensions to EXTRA_INCLUDES=-I$(INCDIR)/extensions -I/usr/X11R6/include/X11/extensions and bingo ! It's compiling to the end.

To run gwm, you need many configuration files, so the simplest way to test it is to

$ cd data
$ ../gwm
(don't forget to stop your previous window manager before).

And it runs... Wow, nice. It wasn't looking that good and full featured last time I tried it.

Christophe Tronche,