#
# Make rules common to all target platforms.
# This file is included by the individual target makefiles in the
# lower level platform build directories.
#

# Common definition of how to build libp2p.a
# for platforms that do or do not use RM shim layer
# (i.e., rvl, sc, gba, ppc   vs.   linux, cygwin, win32).

TARGETS = libp2p.a

default: $(TARGETS)

CFILES = p2p_s.c

ifdef USES_RM
    CFILES += p2p.c voice.c
else

    include $(VPATH)/api/Make.api_cfiles

    APIOBJS = $(API_CFILES:.c=.o)
       
    APILIB = $(LIBDIR)/libp2pint.a
    
    APILIBOBJS = $(APIOBJS:%.o=$(APILIB)(%.o))
    
    $(APILIBOBJS): api
	
    $(APIOBJS): %.o: $(APILIB)(%.o)
	ar xo  $(APILIB) $@
    
    # These dependency rules do the right thing for all cases.
    # Individual objects are replaced in libp2p.a with objects
    # from libp2pint.a only if they changed after building in the
    # api subdir.  If you try to simplify, you will problably
    # break something. So if you do make a change to the
    # dependency rules, test all platforms and all variations
    # of modified and deleted targets and dependencies. 
endif


$(TARGETS): %: %($(OBJECTS)) $(APIOBJS)
	ar cru $@ $?
