# To use this file, first run "makemake" and then run "make".
# (makemake is part of the JX distribution)

# Useful directories

JX_ROOT := ../..

CODEDIR := ./code

JCOREDIR := ${JX_ROOT}/include/jcore
JCOREDIR := ${shell if { test -d ${JCOREDIR}; } \
                    then { echo ${JCOREDIR}; } \
                    else { echo /usr/include/jcore; } fi }

JLIBDIR := ${JX_ROOT}/lib
JLIBDIR := ${shell if { test -d ${JLIBDIR}; } \
                   then { echo ${JLIBDIR}; } \
                   else { echo /usr/lib; } fi }

JCORELIBDIR := ${JX_ROOT}/libjcore

# Directories to search for header files

SEARCHDIRS := -I- \
              -I${CODEDIR} \
              -I${JCOREDIR}

ifdef ACE_ROOT
SEARCHDIRS += -I${ACE_ROOT}
endif

# makemake variables

MAKE_INCLUDE_DIR := ${JX_ROOT}/include/make
MAKE_INCLUDE_DIR := ${shell if { test -d ${MAKE_INCLUDE_DIR}; } \
                            then { echo ${MAKE_INCLUDE_DIR}; } \
                            else { echo /usr/lib/jx/make; } fi }

include ${MAKE_INCLUDE_DIR}/jx_constants
include ${MAKE_INCLUDE_DIR}/jx_config

DEPENDFLAGS := ${J_COMPILER_DEPEND_FLAGS} \
               -g ${SEARCHDIRS}

# make variables

LOADLIBES := -L${JLIBDIR} ${ljcore} ${J_ACE_LIBS} ${J_GCC_LIBS}
LDFLAGS   := 

#####

.PHONY : default
default: libs all

.PHONY : Makefiles
Makefiles:

#
# required libraries
#

.PHONY : libs
libs:
	@${shell if { test -f ${JCORELIBDIR}/Makefile; } \
             then { echo "cd ${JCORELIBDIR}; ${MAKE}"; } fi }

.PHONY : touch
touch::
	@${shell if { test -f ${JCORELIBDIR}/Makefile; } \
             then { echo "cd ${JCORELIBDIR}; \
                    ${MAKE} TOUCHSTRING=${TOUCHSTRING} touch"; } fi }

#
# JX source distribution (DISTR_TAR_FILE)
#

SRC_FILE_DIR := ${JX}/libjcore/test

.PHONY : jxsource
jxsource:
	@cd ${J_DISTR_TAR_DIR}; \
     tar -rf ${DISTR_TAR_FILE} ${filter-out %.o %~, \
                                 ${shell cd ${J_DISTR_TAR_DIR}; echo \
             ${addprefix ${SRC_FILE_DIR}/, Make.* *jmm* *.dat} \
             ${SRC_FILE_DIR}/code/* }}

#
# JX binary distributions (DISTR_TAR_FILE)
#

.PHONY : jxshared
jxshared: jxsource

.PHONY : jxlink
jxlink: jxsource
