#
#
# Copyright 2016-2018 Broadcom.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#
#

#
# We need to set and export OPEN_ROOT to point to the
# root directory of the OpEN ADK installation, and then
# bring in the common.mak settings.
# 
# Include target package output settings.

export OPEN_ROOT = ../..
export PYTHON_H = ./python2.7.10
export SWIGVER=3.0.0

# Override headers to use defaults for following distros

ifeq (1,$(BLD_L7_TARGETOS_LINUX_UB16))
export PYTHON_H = ./python2.7.12
endif

ifeq (1,$(BLD_L7_TARGETOS_LINUX_COS71))
export PYTHON_H = ./python2.7.5
endif

include $(OPEN_ROOT)/swig/make/make.swig

#
# Simple rule for compiling our applications, no
# incremental steps.
#
all: _OpEN.so
	$(NOOP)

openswig: _OpEN.so
	$(NOOP)

_OpEN.so: openwrap.i getwrappers.sh createstub.pl
	$(DBG) swig -DL7_NO_PRINTF_FMT=1 -python -o openwrap.c openwrap.i
	$(DBG) sh getwrappers.sh
	$(DBG) perl createstub.pl
	$(DBG) sh updatepymethods.sh
	$(DBG) $(CROSS_COMPILE)$(CC) -I$(PYTHON_H) -fPIC $(CFLAGS) $(CFLAGSEXTRA) -c openwrap.c
	$(DBG) $(CROSS_COMPILE)$(CC) -shared openwrap.o -o $@ $(LDFLAGS) $(LFLAGSEXTRA)
	$(DBG) sh appendpywrappers.sh

openwrap.i: genifile.pl
	$(DBG) perl genifile.pl

clean:
	$(DBG) rm -f *.o _OpEN.so openwrap.c openwrapbase.c openwraptmp.c append.txt  pyresult.txt  result.txt OpEN_py.py OpEN.py openwrap.i
