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

# Useful directories

JX_ROOT := ..

JCOREDIR := ./code
REGEXDIR := ${JX_ROOT}/misc/regex
GIFDIR   := ${JX_ROOT}/misc/gif
PNGDIR   := ${JX_ROOT}/misc/png

# Directories to search for header files

SEARCHDIRS := -I- \
              -I${JCOREDIR} \
              -I${ACE_ROOT} \
              -I${GIFDIR} \
              -I${PNGDIR}

# 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}

# GIF files (libgd_gif)

ifdef J_HAS_GIF
  GIF_FILES := ${addprefix ${GIFDIR}/, \
                 gd.o gdfontt.o gdfonts.o gdfontmb.o gdfontl.o gdfontg.o}
else
  GIF_FILES :=
endif

# PNG files (libgd)

ifdef J_HAS_PNG
  PNG_FILES := ${addprefix ${PNGDIR}/, \
                 gd.o gd_io.o gd_io_file.o gd_io_dp.o gd_io_ss.o \
                 gd_png.o gd_ss.o gd_gd.o gd_gd2.o \
                 gdfontt.o gdfonts.o gdfontmb.o gdfontl.o gdfontg.o \
                 gdttf.o gdcache.o}
else
  PNG_FILES :=
endif

# JMemoryManager files (remember to update fake_JMM_target.a in Make.files)

ifdef J_ARRAY_NEW_OVERRIDABLE
  JMM_FILES := ${addprefix ${DJ_MM_DIR}/, \
                 jNew.o JMemoryManager.o JMMTable.o JMMArrayTable.o \
                 JMMHashTable.o JMMMonitor.o JMMErrorPrinter.o \
                 JMMRecord.o JArray-JMMRecord.o JHashTable-JMMRecord.o}
else
  JMM_FILES :=
endif

#####

LIB_NAME_ROOT := libjcore-${JX_LIB_VERSION}
OTHER_DEPS    := regex

ifdef J_HAS_GIF
  OTHER_DEPS += gif
endif
ifdef J_HAS_PNG
  OTHER_DEPS += png
endif

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 have eaten
#

.PHONY : regex
regex:
	@cd ${REGEXDIR}; ${MAKE} for_jcore

.PHONY : gif
gif:
	@cd ${GIFDIR}; ${MAKE} for_jcore

.PHONY : png
png:
	@cd ${PNGDIR}; ./configure > /dev/null; ${MAKE} for_jcore

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

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