HEADS UP: fix Makefiles where portlint argues "FATAL [...] use a tab (not space) after a variable name"

Ryan Thompson ryan at sasknow.com
Sun Jul 6 18:43:25 PDT 2003

Oliver Lehmann wrote to ports at freebsd.org:

> Hi,

Hi Oliver,

> I'm going to commit http://people.freebsd.org/~oliver/ports.diff (630kB).
> I attached the Script which does the job.
> It will replace spaces after variable names in Makefiles with tabs or just
> remove them if they are not needed (because there is allready a tab which
> fits).

Overall, the output looks correct in all the cases I looked at. However,
you don't appear to be matching digits and modifiers with your regexp,
so you'll miss variables like MAN1= and XARGS?=.

Also, there are the modifiers like ?= and +=.

I tried this two-stepper on a 4.7-RELEASE ports tree:

$ rm Makefile.vars ; for dir in `ls`; do egrep -h \
  '^[[:space:]]*[[:alnum:]_$][^[:space:]]+[:space:]*=' \
  $dir/*/Makefile 2>/dev/null >> Makefile.vars ; done

$ cut -d = -f 1 Makefile.vars | sort | uniq | \
  egrep '[^_[:alnum:]]' > Makefile.vars.funny

The above isn't meant to provide totally robust matching, but it should
be very close, and, on my system, produces ~1700 lines of output. It
should help you strengthen your search. Here's the output I collected:


> Objections against it?

No, but you made me think of something else that might be of interest.

It would improve cosmetics if we could automatically format the column
width to be as long as the longest variable in the block, with a
reasonable upper bound. I'm thinking of cases like:

+++ archivers/mscompress/Makefile	6 Jul 2003 12:38:24 -0000
@@ -9,7 +9,7 @@
 CATEGORIES=	archivers
-MASTER_SITE_SUBDIR= utils/compress
+MASTER_SITE_SUBDIR=	utils/compress

 MAINTAINER=	ports at FreeBSD.org
 COMMENT=	Microsoft "compress.exe/expand.exe" compatible (de)compressor

So, MASTER_SITE_SUBDIR= being the longest variable, expand other columns
in the same block to align. Expected output for the above:

CATEGORIES=	    archivers
MASTER_SITE_SUBDIR= utils/compress

MAINTAINER= ports at FreeBSD.org
COMMENT=    Microsoft "compress.exe/expand.exe" compatible (de)compressor

More readable, IMO. One could do this Makefile-wide just as easily, but
that could potentially generate a *huge* diff, and do little to improve

I'm just not sure if even the block-level approach be worth the CVS
spam. I suppose if there was some interest (or at least morbid curiosity
:-), I'd be willing to code this up and see how big the changes would
be. And Oliver, I'd be willing to work with you to put our changes
together to be done in a single pass. There are a bunch of things like
this that could be fixed.


- Ryan

  Ryan Thompson <ryan at sasknow.com>

  SaskNow Technologies - http://www.sasknow.com
  901-1st Avenue North - Saskatoon, SK - S7K 1Y4

        Tel: 306-664-3600   Fax: 306-244-7037   Saskatoon
  Toll-Free: 877-727-5669     (877-SASKNOW)     North America

More information about the freebsd-ports mailing list