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

# Useful directories

JX_ROOT := ..

JXDIR    := ./code
JCOREDIR := ${JX_ROOT}/include/jcore
XPMDIR   := ${JX_ROOT}/misc/xpm
IMAGEDIR := ./menu_image

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

SEARCHDIRS = -I- \
             -I${JXDIR} \
             -I${JCOREDIR} \
             -I${ACE_ROOT} \
             -I${XPMDIR}/lib \
             -I${IMAGEDIR} \
             ${J_X11_INCLUDE_DIR}

# makemake variables

include ${JX_ROOT}/include/make/jx_constants
include ${JX_ROOT}/include/make/jx_config

DEPENDFLAGS := ${J_COMPILER_DEPEND_FLAGS} \
               ${J_COMPILE_DEBUG} ${J_BUILD_SHARED_LIB} \
               ${SEARCHDIRS}

# make variables

LOADLIBES := 
LDFLAGS   := ${J_SHARED_LIB_LINK_OPTION}

#####

LIB_NAME_ROOT := libjx-${JX_LIB_VERSION}
OTHER_DEPS    := xpm
include ${JX_ROOT}/include/make/default_lib_target

.PHONY : Makefiles
Makefiles:
	@cd test; makemake; ${MAKE} Makefiles

#
# remove binaries
#

.PHONY : tidy
tidy::
	@cd test; ${MAKE} tidy

.PHONY : clean
clean::
	@cd test; ${MAKE} clean

#
# libraries we require
#

.PHONY : xpm
xpm:
  ifdef JX_INCLUDE_LIBXPM
	@-cd ${XPMDIR}; \
      xmkmf -a > /dev/null; \
      sed -e '/^[ ][ ]*MAKE =/d' < Makefile > Makefile.fixed; \
      mv Makefile.fixed Makefile; \
      ${MAKE} > /dev/null
  endif

#
# JX source distribution  (DISTR_TAR_FILE)
# JX binary distributions (DISTR_TAR_FILE)
#

JLIB := jx
include ${JX_ROOT}/include/make/jx_targets

.PHONY : jxsource
jxsource::
	@cd ${J_DISTR_TAR_DIR}; \
     tar -rf ${DISTR_TAR_FILE} ${filter-out %~, \
                                 ${shell cd ${J_DISTR_TAR_DIR}; echo \
             ${JX}/libjx/*.fd \
             ${JX}/libjx/menu_image/* \
             ${JX}/include/menu_image }}
