PKGDIR     ?= ../../..
CONTRIB    ?= ${PKGDIR}/contrib
SRC_DIR    ?= ${PKGDIR}/lib/src

PRIVATE_INCDIR +=  $(CONTRIB)/drivers/usb/core

#DDELINUX26DIR is to be set
DDELINUX26DIR ?= ${PKGDIR}
.include <${DDELINUX26DIR}/mk/minix.dde.mk>

LIB = ddelinux26_usb_core
LIBDIR=${PREFIX}/lib
MKPROFILE=no
NOGCCERROR=no

#
#    During packaging we spent some time figuring out why usbd was
#    crashing. Usbd was crashing with the followin backtrace.
#    1  0x0808ae33 in ddekit_lock_deinit ()       
#    2  0x0807770e in complete ()
#    3  0x080674aa in usb_api_blocking_completion ()
#    4  0x0806503b in usb_hcd_giveback_urb ()
#    5  0x0804b97c in uhci_giveback_urb (uhci=0x800784cc, qh=0x800a8420,
#                     urb=0x800807c0, status=0)    
#       at ../common/contrib/drivers/usb/host/uhci-q.c:1529
#    6  0x0804bafc in uhci_scan_qh (uhci=0x800784cc, qh=0x800a8420)    
#       at ../common/contrib/drivers/usb/host/uhci-q.c:1574
#    7  0x0804bf52 in uhci_scan_schedule (uhci=0x800784cc)  
#       at ../common/contrib/drivers/usb/host/uhci-q.c:1741
#    8  0x0804dc95 in uhci_irq (hcd=0x8007840c)
#       at ../common/contrib/drivers/usb/host/uhci-hcd.c:461
#    9  0x080656a9 in usb_hcd_irq ()
#    10 0x08075341 in irq_handler ()      
#    11 0x0808b594 in ?? ()     
#    12 0x080bd0e0 in ?? ()
#    
#    We managed to isolate the problem in dde-linux26 build/usb/common and
#    figured that if that part of the code was compiled *without* the -O
#    flag it would crash. More research is need to understand if this is
#    a compiler problem or something in the dde linux code.
CFLAGS+=-O


VPATH = ${SRC_DIR}:${CONTRIB}

SRCS =       \
             drivers/usb/core/buffer.c      \
             drivers/usb/core/driver.c      \
             drivers/usb/core/file.c        \
             drivers/usb/core/hcd.c         \
             drivers/usb/core/notify.c      \
             drivers/usb/core/urb.c         \
             drivers/usb/core/config.c      \
             drivers/usb/core/endpoint.c    \
             drivers/usb/core/generic.c     \
             drivers/usb/core/hcd-pci.c     \
             drivers/usb/core/message.c     \
             drivers/usb/core/sysfs.c       \
             drivers/usb/core/quirks.c      \
             drivers/usb/core/hub.c         \
             drivers/usb/core/devio.c       \
             drivers/usb/core/usb.c         \

distclean:
	rm -rf .depend usb


.include <bsd.lib.mk>
_MKTARGET_CREATE := ${_MKTARGET_CREATE}; mkdir -p ${.TARGET:H};

