bin/67236: file(1) does a poor job of recognizing Makefiles

Ronald F.Guilmette rfg at monkeys.com
Wed May 26 14:21:06 PDT 2004


>Number:         67236
>Category:       bin
>Synopsis:       file(1) does a poor job of recognizing Makefiles
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 26 14:20:14 PDT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Ronald F. Guilmette
>Release:        FreeBSD 5.2.1-RELEASE i386
>Organization:
infinite Monkeys & Co.
>Environment:
System: FreeBSD segfault.monkeys.com 5.2.1-RELEASE FreeBSD 5.2.1-RELEASE #0: Sat Mar 13 19:19:29 PST 2004 root at segfault.monkeys.com:/usr/src/sys/i386/compile/rfg20040313-4 i386

>Description:

The file(1) command does a poor job of differentiating Makefiles from
ASCII English text files.  Just having as little as one English language
comment line (starting with #) in the Makefile can be enough to cause
file(1) to incorrectly identify the file as an ASCII English text file,
rather than as a Makefile.

>How-To-Repeat:

Run the file(1) command on the Makefile included below:
===========================================================================
SHELL = /bin/sh

# 	Copyright (c) 2003 Ronald F. Guilmette; All rights reserved.  The

CC = gcc
OPT = -O
INCLUDES =
CFLAGS = -Wall -Wmissing-prototypes -pedantic -fno-common -g $(OPT) $(INCLUDES)
LDFLAGS = -L/usr/local/bind/lib
LIBBIND = -lbind

# Use the following for Solaris
#LIBS = -lsocket -lnsl -lresolv

INSTALL = install -c
TROFF = groff
MKDIR = mkdir

BASEDIR = /usr/local/local
BINDIR = $(BASEDIR)/bin
MANDIR = $(BASEDIR)/man

PROGS = nbanner
MAN_PAGES = nbanner.1
POSTSCRIPT_MANPAGES = nbanner.ps

all:	$(PROGS) $(MAN_PAGES)

postscript:	$(POSTSCRIPT_MANPAGES)

nbanner:	nbanner.o errors.o syslog-names.o io-errors.o utils.o \
		args.o
	$(CC) $(LDFLAGS) -o nbanner nbanner.o errors.o syslog-names.o io-errors.o \
		utils.o args.o $(LIBBIND) $(LIBS)

nbanner.o:	nbanner.c common.h errors.h io-errors.h utils.h \
		args.h
	$(CC) $(CFLAGS) -c nbanner.c

args.o:	args.c common.h errors.h utils.h args.h
	$(CC) $(CFLAGS) -c args.c

errors.o:	errors.c common.h syslog-names.h errors.h
	$(CC) $(CFLAGS) -c errors.c

io-errors.o:	io-errors.c common.h errors.h
	$(CC) $(CFLAGS) -c io-errors.c

utils.o:	utils.c utils.h common.h errors.h
	$(CC) $(CFLAGS) -c utils.c

syslog-names.o:	syslog-names.c syslog-names.h
	$(CC) $(CFLAGS) -c syslog-names.c

nbanner.ps:	nbanner.1
	$(TROFF) -t -mdoc nbanner.1 > $@

nbanner.x75:	nbanner.1
	$(TROFF) -t -mdoc -TX75 nbanner.1

install: all
	-$(MKDIR) -p $(BINDIR) 2> /dev/null
	$(INSTALL) nbanner $(BINDIR)
	-$(MKDIR) -p $(MANDIR)/man1 2> /dev/null
	$(INSTALL) nbanner.1 $(MANDIR)/man1

clean:
	-rm -f *.o

clobber:	clean
	-rm -f $(PROGS) $(POSTSCRIPT_MANPAGES)

.PHONY:	all postscript nbanner.x75 clean clobber
===========================================================================

>Fix:

I personally don't know what the proper fix will be.  As a workaround, it
may be sufficient to either (a) eliminate all comment lines from Makefiles
or else (b) limit the number of English words in such comments.  (Note that
in the example makefile above, just eliminating the word "The" from the end
of the comment line seems to be sufficient to prevent file(1) from incorrectly
identifying the type of the file.)
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list