#==============================================================================
# Makefile to build an executable from a single, same named, source file.
# This makefile would be used to build tests, applications, etc. where a
# single C file, test.c, having main(), possibly calls functions in other
# pre-compiled object files.
#
# The build tools, flags, include paths, etc. are taken from the platform's
# rules.make file, so PLATFORM_DIR must be set to point to the root platform
# software directory.
#
# Customization for a specific build platform is done through the inclusion
# of rules.make from the Platform directory and sysDefs.h
#
# NOTE! The JAVA_INCS variable must point to the location of the Java JDK
# installed on the system.  The default value is Java in Fedora Core5
#===============================================================================

# Make this the platform directory for testing
include $(PLATFORM_DIR)/rules.make

.SUFFIXES: .o .c


# Add any additional rules this project needs to these variables
PLATFORM_MODULES = $(PLATFORM_DIR)/Utils/Utils.obj \
                   $(PLATFORM_DIR)/AccessLayer/HdwAL.obj \
                   $(PLATFORM_DIR)/Platform/Platform.obj \
                   $(PLATFORM_DIR)/API/API.obj 


# Override previous definition to include -c for building test exe
CFLAGS :=  $(CC_OPTS) $(OPTIONS) $(CFLAGS) $(INCS) $(INCLUDE_PATH)
CXXFLAGS :=  $(CC_OPTS) $(OPTIONS) $(CXXFLAGS) $(CXXINCS) $(INCLUDE_PATH)
CXXEXEFLAGS := $(CC_OPTS) $(OPTIONS) $(CXXFLAGS) $(CXXINCS) $(INCLUDE_PATH)

JAVA_INCS = -I/usr/lib/gcc/i386-redhat-linux/4.1.0/include/ -I/usr/lib/gcc/i386-redhat-linux/4.1.0/include/linux 

#----------------------------------------------------
# build the shared library
#----------------------------------------------------

all: libdemolib.so

libdemolib.so :  demo.o Cpp_Jni.o $(PLATFORM_MODULES)
	g++ -o libCpp_Jni.so -shared -Wl,-soname,libCpp_Jni.so $(JAVA_INCS) $(CXXEXEFLAGS) demo.o Cpp_Jni.o $(PLATFORM_MODULES) -static -lc -lrt

%.o : %.cpp
	$(CXX) -c $(CXXFLAGS) $< -o $@


#------------------------------------------------------------------------
# Clean-up all .o files in the directory
#------------------------------------------------------------------------
clean :
	-rm *.o
	-rm *.so


