## Process this file with automake to produce Makefile.in

# require automake 1.4
# gnu strictness chokes on README being autogenerated
AUTOMAKE_OPTIONS = 1.4 foreign

AM_CFLAGS = -g -Werror

configincludedir = $(pkglibdir)/include

EXTRA_DIST = linux.c linux.h bsd.c darwin.c darwin.h sunos.c sunos.h

libopenusb_la_CFLAGS = $(LIBUSB_CFLAGS)

lib_LTLIBRARIES = libopenusb.la

usblibdir = $(libdir)/openusb_backend

if LINUX_API
usblib_LTLIBRARIES = linux.la
linux_la_CFLAGS = $(UDEV_CFLAGS)
linux_la_SOURCES = linux.c linux.h
linux_la_LDFLAGS = -avoid-version -module -L.libs
linux_la_LIBADD = -lopenusb $(UDEV_LIBS)
endif

if BSD_API
usblib_LTLIBRARIES = bsd.la

bsd_la_SOURCES = bsd.c
bsd_la_LDFLAGS = -avoid-version -module
endif

if DARWIN_API
usblib_LTLIBRARIES = darwin.la

darwin_xcode_skd = 10.6

darwin_la_SOURCES = darwin.c darwin.h
darwin_la_CFLAGS = -isysroot /Developer/SDKs/MacOSX$(darwin_xcode_sdk).sdk -mmacosx-version-min=$(darwin_xcode_sdk) -arch i386 -arch x86_64
darwin_la_LDADDS = -lIOKit -framework "CoreFoundation"
darwin_la_LDFLAGS = -module -avoid-version -mmacosx-version-min=$(darwin_xcode_sdk) -syslibroot /Developer/SDKs/MacOSX$(darwin_xcode_sdk).sdk -arch i386 -arch x86_64
endif

if SUNOS_API
usblib_LTLIBRARIES = sunos.la

sunos_la_SOURCES = sunos.c sunos.h
sunos_la_LDFLAGS =  -avoid-version -module
sunos_la_LIBADD = -ldevinfo -ldbus-1 -lhal -ldbus-glib-1 -lglib-2.0 -lgthread-2.0 -lopenusb

#to use hal for hotplug event support
sunos_la_CFLAGS = -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/hal

libopenusb_la_CFLAGS += -I/usr/sfw/include

# add libopenusb.so as a dependency for sunos.so, to avoid parallel building errors
sunos_la_DEPENDENCIES = $(lib_LTLIBRARIES)

endif

libopenusb_la_SOURCES = usb.c devices.c usbi.h list.c descriptors.c api.c io.c emulation.c list.h descr.h
libopenusb_la_CFLAGS += -DDRIVER_PATH=\"$(libdir)/openusb_backend\"

include_HEADERS = openusb.h

libopenusb_la_LIBADD = -ldl

if DARWIN_API

libopenusb_la_CFLAGS += \
	-mmacosx-version-min=$(darwin_xcode_sdk) \
	-isysroot /Developer/SDKs/MacOSX$(darwin_xcode_sdk).sdk \
	-arch i386 -arch x86_64

libopenusb_la_LDFLAGS = \
	-mmacosx-version-min=$(darwin_xcode_sdk) \
	-syslibroot /Developer/SDKs/MacOSX$(darwin_xcode_sdk).sdk \
	-arch i386 -arch x86_64 \
	-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
	-dynamiclib \
	-lpthread \
	$(LDADDS)

else

libopenusb_la_LDFLAGS = \
	-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
	-export-dynamic \
	-lpthread \
	$(LDADDS)

endif

.PHONY: files release snapshot

files:
	@files=`ls $(DISTFILES) 2> /dev/null `; for p in $$files; do \
	  echo $$p; \
	done

release:
	rm -rf .deps */.deps
	$(MAKE) distcheck

