#
# USB Remote Download Makefile - Host linux user mode driver
#
#
# Copyright (C) 2009, Broadcom Corporation
# All Rights Reserved.
# 
# This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
# the contents of this file may not be disclosed to third parties, copied
# or duplicated in any form, in whole or in part, without the prior
# written permission of Broadcom Corporation.
#
# $Id: Makefile,v 1.14.32.2 2009/05/08 00:48:10 Exp $


SRCBASE = ../..
include $(SRCBASE)/Makerules

vpath %.c $(SRCBASE)/shared

CFLAGS= -Wall -Wstrict-prototypes -g -O2 -I$(SRCBASE)/include -I$(SRCBASE)/shared/zlib
LIBS     := -lusb
BINARIES = bcmdl
TARGET = bcmdl
OBJECTS = bcmdl.o adler32.o inffast.o inflate.o infcodes.o infblock.o inftrees.o infutil.o zutil.o crc32.o bcmutils.o

VPATH := $(SRCBASE)/shared/zlib

ifeq ($(TARGETENV), linux)
	OBJECTS += usb_linux.o
	COMPILE = gcc
	CLEAN = clean_linux



endif

ifeq ($(TARGETENV), linuxmips_be) 
	OBJECTS += usb_linux.o
	COMPILE = mips-linux-gcc 
	LIBS := -L$(LIBUSB_PATH)/.libs $(LIBS)
	CFLAGS += -I$(LIBUSB_PATH) -DIL_BIGENDIAN
endif


ifeq ($(TARGETENV), linuxmips)
	TARGET_PREFIX := mipsel-uclibc-
	OBJECTS += usb_linux.o
	COMPILE = mipsel-uclibc-gcc 
	CLEAN = clean_linux
	LIBS := -L$(LIBUSB_PATH)/.libs $(LIBS)
	CFLAGS += -I$(LIBUSB_PATH)
	LDFLAGS += -L$(LIBUSB_PATH)/.libs
install: 
	cp bcmdl $(SRCBASE)/router/mipsel-uclibc/target/bin
endif

ifeq ($(TARGETENV), macos)
	TARGET = bcmdl_macos
	CLEAN = clean_macos
	COMPILE = xcodebuild
	PROJECT = bcmdl.xcodeproj
endif

ifeq ($(BCMQT),1)
CFLAGS += -DBCMQT
endif

all: $(TARGET)

bcmdl: $(OBJECTS)
	$(COMPILE)  $(OBJECTS)  $(CFLAGS) $(LIBS)  -o $@

# Executable is located in build/Debug/bcmdl
#
bcmdl_macos:
	$(COMPILE) -project $(PROJECT) -target $(BINARIES) -configuration Debug build

clean_macos:
	$(COMPILE) -project $(PROJECT) -target $(BINARIES) -configuration Debug clean

clean_linux:
	rm -rf $(BINARIES) $(OBJECTS)

clean: $(CLEAN)
