# Constants used in all Makefiles

#
# version numbers
#

JX_VERSION  := 1.5.3
ACE_VERSION := 5.0.2

JX_LIB_VERSION  := 1_5_3
ACE_LIB_VERSION := 5_0_2

JX := JX-${JX_VERSION}

#
# useful directories
#

J_DISTR_TAR_DIR := ${JX_ROOT}/..

JX_ROOT_BIN_DIRECTORY := /usr/bin
JX_ROOT_LIB_DIRECTORY := /usr/lib

ifdef JX_INSTALL_ROOT
  override JX_INSTALL_ROOT := \
    ${shell if { test -d ${JX_INSTALL_ROOT} -a -w ${JX_INSTALL_ROOT} } \
            then { echo ${JX_INSTALL_ROOT} } \
            else { echo } fi; }
endif

ifndef JX_INSTALL_ROOT
  ifeq ($(shell whoami),root)
    override JX_INSTALL_ROOT := ${JX_ROOT_BIN_DIRECTORY}
  else
    override JX_INSTALL_ROOT := \
      ${shell if { test -d ${HOME}/bin -a -w ${HOME}/bin } \
              then { echo ${HOME}/bin } \
              else { test -d ${JX_ROOT}/bin || mkdir ${JX_ROOT}/bin; \
                     echo ${JX_ROOT}/bin } fi; }
  endif
endif

ifndef JX_LIB_ROOT
  JX_LIB_ROOT := ${JX_ROOT_LIB_DIRECTORY}
endif

#
# library names
#

ljcore := -ljcore-${JX_LIB_VERSION}
ljx    := -ljx-${JX_LIB_VERSION}

#
# flex
#

LEX    := flex
LFLAGS := 

# Change rule from .c to .cc

%.c : %.l

%.cc : %.l
	${LEX} ${LFLAGS} -o$@ $<

#
# bison
#

YACC   := bison
YFLAGS := -d

# Change rule from .c to .cc

%.c : %.y

%.cc : %.y
	${YACC} ${YFLAGS} $<
	@mv $*.tab.c $*.cc

#
# RPM
#

RPM_SRC_DIR  := /usr/src/redhat/SOURCES
RPM_SPEC_DIR := /usr/src/redhat/SPECS
RPM_BIN_DIR  := /usr/src/redhat/RPMS/i386
RPM_SRPM_DIR := /usr/src/redhat/SRPMS

RPM := rpm -ba --quiet --clean

#
# for use by Dustin Laurence
#

DJ_REGEX_DIR := ${JX_ROOT}/include/jcore
#SEARCHDIRS   := -I- -I${DJ_REGEX_DIR} ${filter-out -I-, ${SEARCHDIRS}}

DJ_HASH_DIR := ${JX_ROOT}/include/jcore
#SEARCHDIRS  := -I- -I${DJ_HASH_DIR} ${filter-out -I-, ${SEARCHDIRS}}

DJ_RAND_DIR := ${JX_ROOT}/include/jcore
#SEARCHDIRS  := -I- -I${DJ_RAND_DIR} ${filter-out -I-, ${SEARCHDIRS}}

DJ_MM_DIR  := ${JX_ROOT}/include/jcore
#SEARCHDIRS := -I- -I${DJ_MM_DIR} ${filter-out -I-, ${SEARCHDIRS}}
