# Copyright (c) 1999, 2022 Tanuki Software, Ltd.
# http://www.tanukisoftware.com
# All rights reserved.
#
# This software is the proprietary information of Tanuki Software.
# You shall use it only in accordance with the terms of the
# license agreement you entered into with Tanuki Software.
# http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html

# gcc - The JNI library generated with gcc does not work on 64-bit x86 systems
#  due to a bug or simply a configuration problem.   We need to use cc here.
#  see Bug #1992039 for details.
# https://sourceforge.net/tracker/index.php?func=detail&aid=1992039&group_id=39428&atid=425187
#COMPILE = gcc -m64 -O3 -Wall --pedantic -DSOLARIS -DJSW64
COMPILE = /opt/SUNWspro/bin/cc -m64 -mt -Kpic -O -DSOLARIS -DJSW64 -DUNICODE -D_UNICODE -D_REENTRANT

INCLUDE=$(JAVA_HOME)/include

DEFS = -I$(INCLUDE) -I$(INCLUDE)/solaris

wrapper_SOURCE = wrapper.c wrapperinfo.c wrappereventloop.c wrapper_unix.c property.c logger.c logger_file.c wrapper_file.c wrapper_i18n.c wrapper_hashmap.c wrapper_ulimit.c wrapper_encoding.c wrapper_jvminfo.c

libwrapper_so_OBJECTS = wrapper_i18n.o wrapperjni_unix.o wrapperinfo.o wrapperjni.o loggerjni.o

BIN = ../../bin
LIB = ../../lib

all: init wrapper libwrapper.so

clean:
	rm -f *.o

cleanall: clean
	rm -rf *~ .deps
	rm -f $(BIN)/wrapper $(LIB)/libwrapper.so

init:
	if test ! -d .deps; then mkdir .deps; fi

wrapper: $(wrapper_SOURCE)
	$(COMPILE) $(wrapper_SOURCE) -lsocket -lpthread -lnsl -lm -lposix4 -o $(BIN)/wrapper

#libwrapper.so: $(libwrapper_so_OBJECTS)
#	${COMPILE} -G -fPIC -lposix4 $(libwrapper_so_OBJECTS) -o $(LIB)/libwrapper.so
libwrapper.so: $(libwrapper_so_OBJECTS)
	${COMPILE} -G -fPIC -lposix4 -lpthread $(libwrapper_so_OBJECTS) -o $(LIB)/libwrapper.so

%.o: %.c
	${COMPILE} -c ${DEFS} $<
