# ******************************************************************************
#  INTEL CONFIDENTIAL
#
#  Copyright 2003 Intel Corporation All Rights Reserved.
#
#  The source code contained or described herein and all documents related to
#  the source code ("Material") are owned by Intel Corporation or its
#  suppliers or licensors.
#
#  Title to the Material #ains with Intel Corporation or its suppliers and
#  licensors. The Material contains trade secrets and proprietary and
#  confidential information of Intel or its suppliers and licensors.
#  The Material is protected by worldwide copyright and trade secret laws and
#  treaty provisions. No part of the Material may be used, copied, reproduced,
#  modified, published, uploaded, posted, transmitted, distributed,
#  or disclosed in any way without Intel's prior express written permission.
#
#  No license under any patent, copyright, trade secret or other intellectual
#  property right is granted to or conferred upon you by disclosure
#  or delivery of the Materials, either expressly, by implication, inducement,
#  estoppel or otherwise. Any license under such intellectual property rights
#  must be express and approved by Intel in writing.
#
# ******************************************************************************

# ******************************************************************************
# ============================================================================
#
# = PRODUCT
#      Intel(r) IXA SDK for the IXP2400 Network Processor
#
# = FILENAME
#      Makefile-linux
#
# = DESCRIPTION
#
# ============================================================================
# ******************************************************************************

#
# Path to xscale_be-gcc is needed in your environment
#
GCC=xscale_be-gcc

#
# The root to IXA SDK tree
#
IXA_SDK_DIR=$(shell cd ../../../../../../.. && pwd)

ME_TOOLS_DIR=$(IXA_SDK_DIR)/me_tools/bin_linux_be

BRD_DRV_DIR=$(IXA_SDK_DIR)/Firmware/IXDP2401/Linux/drivers/ixd4bb

#
# Directory of common files for VxWorks and Linux
#
COMMON_FILES_DIR=$(IXA_SDK_DIR)/src/applications/ipv4_forwarder/quad_gbeth_2401/wbench_project/xscale_init

#
# Header directories for ethernet_project
#
INCLUDE_DIRS=-I$(IXA_SDK_DIR)/linux/include

INCLUDE_DIRS+=-I$(IXA_SDK_DIR)/src/include

INCLUDE_DIRS+=-I$(IXA_SDK_DIR)/src/applications/ipv4_forwarder/quad_gbeth_2401/wbench_project

INCLUDE_DIRS+=-I$(COMMON_FILES_DIR)

INCLUDE_DIRS+=-I$(IXA_SDK_DIR)/src/building_blocks/

INCLUDE_DIRS+=-I.

INCLUDE_DIRS+=-I$(IXA_SDK_DEV)/src/building_blocks/tx/core/ethernet_tx/include

#
# Target file directory. The executable file will be placed there.
#
TARGET_DIR=target

#
# Flags for GCC for ethernet_project
#
CFLAGS = -Wall -Wstrict-prototypes -O3 -fomit-frame-pointer -fno-strict-aliasing -pipe -I. -DLINUX  -mbig-endian $(INCLUDES)


#
# Header files for ethernet driver
#

DRV_INCLUDE_DIRS=-I$(IXA_SDK_DIR)/Firmware/IXDP2401/common/drivers/ixd4gea1f/include
DRV_INCLUDE_DIRS+=-I$(IXA_SDK_DIR)/Firmware/IXDP2401/common/drivers/ixd4bb/h
DRV_INCLUDE_DIRS+=-I$(IXA_SDK_DIR)/Firmware/IXDP2401/Linux/drivers/ixd4bb/h

#
# Path to ixf1104drv_user.o
#
GBETH_OBJ_DIR=$(IXA_SDK_DIR)/Firmware/IXDP2401/Linux/drivers/ixd4gea1f

BRD_DRV_DIR=$(IXA_SDK_DIR)/Firmware/IXDP2401/Linux/drivers/ixd4bb

#
# Flags for GCC for ethernet driver config file
#
# To configure front copper ports define:
# ETH_DEF_FLAGS=-DGIGE_FRONT_COPPER
ETH_DEF_FLAGS=
GCCFLAGS=-g -Wall -Wstrict-prototypes -O3 -mbig-endian -D__LINUX_USER__ $(ETH_DEF_FLAGS) $(DRV_INCLUDE_DIRS)

ADD_FLAGS=-DETH_TX_MODE_GIGA_FULL_DUPLEX -DETH_TX_PARITY_EVEN -DETH_TX_MODE_4_8 -DETH_TX_FLOW_CTRL

ADD_FLAGS+=-DUSE_BB_DRV_CONFIG

#
# Definitions
#
DEFS = -DXSCALE_INIT_FOR_LINUX

#
# Files creation
#
all: dirs ethernet_project eth_drv_cfg install

dirs:
	@mkdir -p $(TARGET_DIR)

ethernet_project:
	$(GCC) $(CFLAGS) $(INCLUDE_DIRS) $(DEFS) $(COMMON_FILES_DIR)/ethernet_rtm_routes.c quad_gbeth_2401_linux_init.c linux_mmap_lib.c $(COMMON_FILES_DIR)/l2_encap_init.c -o $(TARGET_DIR)/ethernet_project

eth_drv_cfg:
	$(GCC) $(GCCFLAGS) $(ADD_FLAGS) -static $(GBETH_OBJ_DIR)/ixf1104drv_user.o -static $(BRD_DRV_DIR)/bb_media_lib.o eth_drv_cfg.c $(BRD_DRV_DIR)/bb_media_lib.o -o $(TARGET_DIR)/eth_drv_cfg

install:
	cp -v $(BRD_DRV_DIR)/bb_linux_drv $(TARGET_DIR)/.
	cp -v start_qbeth $(TARGET_DIR)/.
	chmod 777 $(TARGET_DIR)/*

clean:
	rm -rf $(TARGET_DIR)

