bsd.*.mk: Fix bug when SRCS is explicitly defined empty
authorJohn Marino <draco@marino.st>
Tue, 27 Jan 2015 22:20:44 +0000 (23:20 +0100)
committerJohn Marino <draco@marino.st>
Tue, 27 Jan 2015 22:20:44 +0000 (23:20 +0100)
commitbed2cf9317ac90b133f4347a78a1e4880b6ad761
treefcd0047474f3c0b60e056ec99db01c0ee80810b4
parent2751491f2849a3be07e862044266942700086f8a
bsd.*.mk: Fix bug when SRCS is explicitly defined empty

There exists a valid possibility of setting a makefile to build a program
or library exclusively with OBJS defined.  In the case of bsd.prog.mk,
not defining SRCS will cause the definition of OBJS to be overwritten
with ${PROG}.c or ${PROG}.cc.  Defining SRCS as an empty list will stop
OBJS from being overwritten, but there's a bug.  It adds ".o" to the end
of the list.

For example:
======================
OBJS= first.o second.o
SRCS=
.include <bsd.prog.mk>
======================
make -V OBJS
first.o second.o .o

This is caused by a transformation assuming SRCS has at least one item
in the list.  It's fixed by only performing the transformation if SRCS
is not empty.  I'm adding this check to both bsd.prog.mk and bsd.lib.mk
share/mk/bsd.lib.mk
share/mk/bsd.prog.mk