tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Improvement for bmake: boolean values

In both 4.4BSD bsd.*.mk files and pkgsrc mk files boolean variables are
widely used: MKMAN, MKCATPAGES, USE_LIBTOOL and tons of others.

One traditional way to represent boolean values is to use YES/NO strings
for representing true/false respectively. Another widely used practice
is to use 1/0 values.

In my view YES/NO looks better/easier than 1/0 for human.
On the other hand 1/0 values make mk code much easier and cleaner.

1) there are two incompatible way to represent boolean values.
   In pkgsrc there is a special secret table (ask tnn@)
   listing variables and their true/false values
2) empty{MKCATPAGES:M[Nn][Oo]} looks very ugly and make the code dirty
3) empty{MKCATPAGES:M[Nn][Oo]} is not equivalent to
   (other/bad values are treated as either true or false)

To solve these problems I propose to implement new function for
bmake, say "yesno", treating 1 and [Yy][Ee][Ss] as logical true,
and 0 and [Nn][Oo] as logical false.

   MKMAN = yes # or YES|...|NO|No|nO|1|0
   .if yesno(MKMAN)
       # make man pages here
       # do not make man pages here

In my view this can make mk code cleaner and boolean values in bmake
much easier to understand and use.
I think this approach closes the problem once and forever.

Best regards, Aleksey Cheusov.

Home | Main Index | Thread Index | Old Index