Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Oct 2018 17:52:33 -0400
From:      William Parsons <gyliamos@gmail.com>
To:        freebsd-questions@freebsd.org
Subject:   old Makefile for building library no longer works
Message-ID:  <86bm7n9dcu.fsf@anukis.local.i-did-not-set--mail-host-address--so-tickle-me>

Next in thread | Raw E-Mail | Index | Archive | Help
I haven't been doing a lot of C programming lately, but recently I
revisited an old project and found the old Makefile to build a library
under FreeBSD no longer works.  (I've verified that this still worked as
of FreeBSD 9.3 and will still work if gmake is used.)  Here's a much
simplified version of the Makefile that used to work:

--8<---------------cut here---------------start------------->8---
LIBTEST	= libTest.a

.PRECIOUS: $(LIBTEST)

all: $(LIBTEST)

LIBSRC  = test.c

# Do not automatically delete library source files
.SECONDARY: $(LIBSRC)

LIBOBJ	= $(LIBSRC:%.c=%.o)

$(LIBTEST): $(LIBTEST)($(LIBOBJ))
	$(AR) $(ARFLAGS) $@ $?
	rm -f $?

clean:
	@rm -f *.o $(LIBTEST)
--8<---------------cut here---------------end--------------->8---

And here's a trivial C source file to go with it:

--8<---------------cut here---------------start------------->8---
/* test.c */
#include <stdio.h>

int
test(char const *text)
{
    printf("%s\n", text);
    return 1;
}
--8<---------------cut here---------------end--------------->8---

It looks like the Makefile directive dependency:

$(LIBTEST): $(LIBTEST)($(LIBOBJ))

no longer works and claims the target is up to date when it doesn't even
exist.

I've been perusing 'man make' without success.

One thing that puzzles me is that 'man make' says "For a more thorough
description of make and makefiles, please refer to PMake - A Tutorial."

Is this accurate?  I was under the impression that pmake was replaced by
bsdmake in recent versions of FreeBSD - is this the source of my
problems?

-- 
Will



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?86bm7n9dcu.fsf>