On Sat, May 3, 2014 at 3:02 AM, Marc Espie <es...@nerim.net> wrote:

> On Sat, May 03, 2014 at 10:23:58AM +0200, Roberto E. Vargas Caballero
> wrote:
> > I have the following simple Makefile:
> >
> >       CPPFLAGS = -I../inc
> >
> >       all: libcc.a
> >
> >       libcc.a: libcc.a(die.o) libcc.a(xcalloc.o) libcc.a(xmalloc.o)
> >
> >       clean:
> >               rm -f *.o *.a
> >
> > which should generate a static library using a default rule. This
> Makefile
> > works in another systems, and it is accepted by POSIX standards [1]. The
> > rule in /usr/share/mk/sys.mk is:
> >
> >       .c.a:
> >               ${COMPILE.c} ${.IMPSRC}
> >               ${AR} ${ARFLAGS} $@ $*.o
> >               rm -f $*.o
> >
> > but when I run make I get this output:
> >
> >       $ make
> >       cc -O2 -pipe  -I../inc -c die.c
> >       cc -O2 -pipe  -I../inc -c xcalloc.c
> >       cc -O2 -pipe  -I../inc -c xmalloc.c
> >
> > Anyone could point me what is the problem?
>
> We don't have any rules that actually handles archive members in the
> default setup.
>
> The rule you quote would only work for creating an archive based on a
> single c file.
>
> There is nothing in the posix description that says anything about default
> rules to recreate archives.

...

(Finally took at look at this)

I must disagree, Marc.  POSIX smacks some additional, completely
non-orthogonal requirements on rules for targets with the .a suffix:
----
If a target or prerequisite contains parentheses, it shall be treated as a
member of an archive
library. For the lib(member.o) expression lib refers to the name of the
archive library and member.o
to the member name. The application shall ensure that the member is an
object file with the .o
suffix. The modification time of the expression is the modification time
for the member as kept
in the archive library; see ar. The .a suffix shall refer to an archive
library. The .s2.a rule shall be
used to update a member in the library from a file with a suffix .s2.
----

I.e., that .c.a rule could sorta be called a .c.a(.o) rule, as it's
supposed to match *.a(*.o) targets.


Philip Guenther

Reply via email to