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

# Useful directories

JX_ROOT := ..

DIR01 := ./01-HelloWorld
DIR02 := ./02-MenuHello
DIR03 := ./03-DialogHello
DIR04 := ./04-Widget
DIR05 := ./05-Scrolling
DIR06 := ./06-DragPainter
DIR07 := ./07-Printing
DIR08 := ./08-SimpleTable
DIR09 := ./09-DataTable
DIR10 := ./10-SelectionTable
DIR11 := ./11-EditTable
DIR12 := ./12-Clipboard
DIR13 := ./13-Undo

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

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

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

JCORELIBDIR := ${JX_ROOT}/libjcore
JXLIBDIR    := ${JX_ROOT}/libjx

# Directories to search for header files (= for J_X11_INCLUDE_DIR)

SEARCHDIRS = -I- \
             -I${DIR01} -I${DIR02} -I${DIR03} -I${DIR04} \
             -I${DIR05} -I${DIR06} -I${DIR07} -I${DIR08} \
             -I${DIR09} -I${DIR10} -I${DIR11} -I${DIR12} \
             -I${DIR13} \
             -I${JCOREDIR} \
             -I${JXDIR} \
             ${J_X11_INCLUDE_DIR}

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} ${ljx} ${ljcore} ${J_SYS_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 }
	@${shell if { test -f ${JXLIBDIR}/Makefile; } \
             then { echo "cd ${JXLIBDIR}; ${MAKE}"; } fi }

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

#
# JX source distribution (DISTR_TAR_FILE)
#

SRC_FILE_DIR := ${JX}/tutorial

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

#
# JX binary distributions (DISTR_TAR_FILE)
#

.PHONY : jxshared
jxshared: jxsource

.PHONY : jxlink
jxlink: jxsource
