[comp.windows.x] Bug with imake

mrp@UCS.Adelaide.EDU.AU (Mark Prior) (07/31/90)

In my continuous quest to make X happily live in /usr/local/... (and
to install the various fixes) I have run into what looks like a bug.

In mit/clients/xdm/Imakefile there is a section of "code"

/**/#
/**/# Special definitions for compiling default resources; these parameters
/**/# should be set in util/imake.includes/site.def or the appropriate .macros
/**/# file in that directory.  The lack of initial spaces is to prevent imake
/**/# from accidently turning the lines into rules by putting a leading tab.
/**/#
/**/# Do NOT change these lines!
/**/#
DEF_SERVER = $(BINDIR)/X
DEF_USER_PATH = DefaultUserPath         /* no leading spaces or imake will */
DEF_SYSTEM_PATH = DefaultSystemPath     /* indent as rule */
BOURNE_SHELL = DefaultSystemShell
CPP_PROGRAM = CppCmd

When you try adding #define's to site.def to set these values, such as

#ifndef DEF_USER_PATH
#define DEF_USER_PATH ":/usr/bin:/usr/local/bin/X11:/usr/ucb:/usr/local/bin"
#endif
#ifndef DEF_SYSTEM_PATH
#define DEF_SYSTEM_PATH
"/etc:/usr/bin:/usr/local/bin/X11:/usr/ucb:/usr/local/bin"
#endif

The resulting Makefile (after make World) gives

#
# Special definitions for compiling default resources; these parameters
# should be set in util/imake.includes/site.def or the appropriate .macros
# file in that directory.  The lack of initial spaces is to prevent imake
# from accidently turning the lines into rules by putting a leading tab.
#
# Do NOT change these lines!
#
DEF_SERVER = $(BINDIR)/X
":/usr/bin:/usr/local/bin/X11:/usr/ucb:/usr/local/bin" =
:/bin:/usr/bin:$(BINDIR):/usr/ucb
"/etc:/usr/bin:/usr/local/bin/X11:/usr/ucb:/usr/local/bin" =
/etc:/bin:/usr/bin:$(BINDIR):/usr/ucb
BOURNE_SHELL = /bin/sh
CPP_PROGRAM = /lib/cpp

Which doesn't work (strangely enough). Since DEF_*_PATH are only used in
resource.c (in that directory) I removed the definitions from site.def,
but it means that I can't modify the default paths this way which is a pain.

Any suggestions?

Also if anyone has a list of places I should have modified to make X work
in another tree could you let me know (the sym links work but it's ugly).

Thanks,
Mark.
--
Mark Prior                              Phone : +61 8 228 5680
University Computing Services           Telex : UNIVAD AA89141
University of Adelaide                  Fax   : +61 8 223 6245
GPO Box 498 Adelaide S.AUSTRALIA 5001   E-mail: mrp@ucs.adelaide.edu.au

bin@primate.wisc.edu (Brain in Neutral) (07/31/90)

From article <1244@sirius.ucs.adelaide.edu.au>, by mrp@UCS.Adelaide.EDU.AU (Mark Prior):
> /**/#
> /**/# Special definitions for compiling default resources; these parameters
> /**/# should be set in util/imake.includes/site.def or the appropriate .macros
> /**/# file in that directory.  The lack of initial spaces is to prevent imake
> /**/# from accidently turning the lines into rules by putting a leading tab.

These comments look like they were originally written for the R3
configuration file architecture.  There are no imake config files under
util anymore and the .macros files are now .cf files.

Aside from that, the "lack of initial spaces" comment looks specious.
You should be able to put spaces before any make variable definition...

> DEF_SERVER = $(BINDIR)/X
> DEF_USER_PATH = DefaultUserPath         /* no leading spaces or imake will */
> DEF_SYSTEM_PATH = DefaultSystemPath     /* indent as rule */
> BOURNE_SHELL = DefaultSystemShell
> CPP_PROGRAM = CppCmd
> 
> When you try adding #define's to site.def to set these values, such as
> 
> #ifndef DEF_USER_PATH
> #define DEF_USER_PATH ":/usr/bin:/usr/local/bin/X11:/usr/ucb:/usr/local/bin"
> #endif
> #ifndef DEF_SYSTEM_PATH
> #define DEF_SYSTEM_PATH "/etc:/usr/bin:/usr/local/bin/X11:/usr/ucb:/usr/local/bin"
> #endif

You are confusing make variables with cpp symbols.  The first set of lines
above define make variables by equating them to something.  The second set
of lines #define cpp symbols.  But you have used the same names for both,
with, not surprisingly, unfortunate consequences.  Put this in site.def
instead:

#ifndef DefaultUserPath
#define DefaultUserPath ":/usr/bin:/usr/local/bin/X11:/usr/ucb:/usr/local/bin"
#endif
#ifndef DefaultSystemPath
#define DefaultSystemPath "/etc:/usr/bin:/usr/local/bin/X11:/usr/ucb:/usr/local/bin"
#endif

This will override the values of the cpp symbols DefaultUserPath and
DefaultSystemPath to replace whatever values they might otherwise get.
DEF_USER_PATH and DEF_SYSTEM_PATH are eventually equated to those
symbols, which should then have the values you want.

(disclaimer: This response is speculation, I haven't tried it out.)

Paul DuBois
dubois@primate.wisc.edu

paulsh@denali.wv.tek.COM (Paul Shearer) (08/01/90)

This is NOT an imake bug.

The mistake made below is a common one.  The user should remember the 
general rule that Make macros are all capitals and the cpp macros have
only the first letter capitalized.  Thus the convention is:

ALL_CAPITALS		this is a Makefile macro
FirstLetterCapital	this is a cpp macro to be set in configuration files

Remember that the Makefile is built from Imake.tmpl which expands the
following files in this order:

machine.cf
site.def
Project.tmpl
Imake.rules
Imakefile

The file that contains the defalut cpp macro "DefaultUserPath" is Project.tmpl.

The correct fix is to set the cpp macro in either your machine.cf file if
you want to change it only on your platform, or in site.def if you want to
change it in all platforms you are building at your site.

Thus see the fix below:

> In my continuous quest to make X happily live in /usr/local/... (and
> to install the various fixes) I have run into what looks like a bug.
> 
> In mit/clients/xdm/Imakefile there is a section of "code"
> 
> /**/#
> /**/# Special definitions for compiling default resources; these parameters
> /**/# should be set in util/imake.includes/site.def or the appropriate .macros
> /**/# file in that directory.  The lack of initial spaces is to prevent imake
> /**/# from accidently turning the lines into rules by putting a leading tab.
> /**/#
> /**/# Do NOT change these lines!
> /**/#
> DEF_SERVER = $(BINDIR)/X
> DEF_USER_PATH = DefaultUserPath         /* no leading spaces or imake will */
> DEF_SYSTEM_PATH = DefaultSystemPath     /* indent as rule */
> BOURNE_SHELL = DefaultSystemShell
> CPP_PROGRAM = CppCmd
> 
> When you try adding #define's to site.def to set these values, such as
> 
> #ifndef DEF_USER_PATH
> #define DEF_USER_PATH ":/usr/bin:/usr/local/bin/X11:/usr/ucb:/usr/local/bin"
> #endif
> #ifndef DEF_SYSTEM_PATH
> #define DEF_SYSTEM_PATH "/etc:/usr/bin:/usr/local/bin/X11:/usr/ucb:/usr/local/bin"
> #endif
> 

No, the correct fix is to define the cpp macro, not the Makefile macro.
If you do this in site.def it will override the MIT defaults provided in
the file Project.tmpl which is expanded after site.def.  If someone on a 
platform at your site defines them differently in their machine.cf file
they will get their definitions, since machine.cf is expanded before
site.def.

#ifndef DefaultUserPath
#define DefaultUserPath ":/usr/bin:/usr/local/bin/X11:/usr/ucb:/usr/local/bin"
#endif
#ifndef DefaultSystemPath
#define DefaultSystemPath "/etc:/usr/bin:/usr/local/bin/X11:/usr/ucb:/usr/local/bin"
#endif


The Makefile below gave the following results because the real default 
cpp macros on the right of the = were defined in Project.tmpl and you
incorrectly defined the Makefile Macro on the left of the = in your
site.def.

> The resulting Makefile (after make World) gives
> 
> #
> # Special definitions for compiling default resources; these parameters
> # should be set in util/imake.includes/site.def or the appropriate .macros
> # file in that directory.  The lack of initial spaces is to prevent imake
> # from accidently turning the lines into rules by putting a leading tab.
> #
> # Do NOT change these lines!
> #
> DEF_SERVER = $(BINDIR)/X
> ":/usr/bin:/usr/local/bin/X11:/usr/ucb:/usr/local/bin" =
> :/bin:/usr/bin:$(BINDIR):/usr/ucb
> "/etc:/usr/bin:/usr/local/bin/X11:/usr/ucb:/usr/local/bin" =
> /etc:/bin:/usr/bin:$(BINDIR):/usr/ucb
> BOURNE_SHELL = /bin/sh
> CPP_PROGRAM = /lib/cpp
> 
> Which doesn't work (strangely enough). Since DEF_*_PATH are only used in
> resource.c (in that directory) I removed the definitions from site.def,
> but it means that I can't modify the default paths this way which is a pain.
> 
> Any suggestions?
> 
> Also if anyone has a list of places I should have modified to make X work
> Mark Prior                              Phone : +61 8 228 5680
> University Computing Services           Telex : UNIVAD AA89141
> University of Adelaide                  Fax   : +61 8 223 6245
> GPO Box 498 Adelaide S.AUSTRALIA 5001   E-mail: mrp@ucs.adelaide.edu.au



Paul Shearer
M.S. 61-049
Tektronix, Inc.
P.O. Box 1000
Wilsonville, OR
	 97070-1000

W (503) 685-2137
FAX (503) 682-1500
paulsh@orca.wv.tek.com
tektronix!orca!paulsh

bin@primate.wisc.edu (Brain in Neutral) (08/01/90)

From article <9007311753.AA01310@denali.WV.TEK.COM>, by paulsh@denali.wv.tek.COM (Paul Shearer):
> The mistake made below is a common one.  The user should remember the 
> general rule that Make macros are all capitals and the cpp macros have
> only the first letter capitalized.  Thus the convention is:
> 
> ALL_CAPITALS		this is a Makefile macro
> FirstLetterCapital	this is a cpp macro to be set in configuration files

As a general rule, yes.  A better rule is: look at the configuration
files and find out how the symbol is actually used.  There are numerous
exceptions to the makevar=ALLCAPS, cppsymbol=UpperLower rule, unfortunately.
For example:
	Imake.tmpl:
		YES NO UNCOMPRESSPATH TOPDIR CURDIR INCLUDE_IMAKEFILE
	Project.tmpl:
		UNCOMPRESSFILT BDFTOSNFFILT SHELLPATH ZBDFTOSNFFILT

Paul DuBois
dubois@primate.wisc.edu