top_builddir=../
libdir=${exec_prefix}/lib
includedir=${prefix}/include

SHELL=/bin/bash
AR=ar crs
CC=gcc
CCLD=gcc
LN_S=ln -s -f
INSTALL=/usr/bin/install -c
INSTALL_DATA=${INSTALL} -m 644
RM=rm -rf
LIBTOOL=$(SHELL) $(top_builddir)/libtool
CFLAGS=-framework CoreFoundation -DHAVE_LIBGEN_H -DHAVE_USLEEP -Wall -Wmissing-prototypes
CPPFLAGS=
#
# Tack on something like -version-info 1:0:0 to the LDFLAGS
# below the day we change the interface.
#
# This is the version of the *library interface*, not the revision
# of libnjb itself. Do not change this unless you're absolutely 
# certain of what the difference is. (See the libtool manual,
# section 6.4 (http://www.gnu.org/software/libtool/manual.html)
#
LDFLAGS= -release 1.1
LDLIBS=-lusb 

COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LTLINK = $(LIBTOOL) --mode=link $(CCLD) -rpath $(libdir) $(LDFLAGS) $(LDLIBS) -o $@
LTINSTALL=$(LIBTOOL) --mode=install $(INSTALL)
LTFINISH=$(LIBTOOL) --mode=finish

TARGET=libnjb.la
SRCS=base.c ioutil.c protocol.c procedure.c byteorder.c \
	playlist.c usb_io.c njb_error.c datafile.c songid.c \
	eax.c time.c protocol3.c unicode.c
PICOBJS=$(SRCS:.c=.lo)

.SUFFIXES: .lo .c

.c.lo:
	$(LTCOMPILE) -c $<

all: $(TARGET)

$(TARGET): $(PICOBJS)
	$(LTLINK) $(PICOBJS)

install:
	$(INSTALL) -d $(libdir) $(includedir)
	$(LTINSTALL) libnjb.la $(libdir)
	$(LTFINISH) $(libdir)
	$(INSTALL_DATA) libnjb.h $(includedir)

clean:
	$(RM) *.o
	$(RM) $(PICOBJS) $(TARGET)

distclean: clean
	$(RM) Makefile libnjb.h
	$(RM) .libs
