<commit_before># $Id$
# %ISC_START_LICENSE%
# ---------------------------------------------------------------------
# Copyright 2006-2018, Pittsburgh Supercomputing Center
# All rights reserved.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the
# above copyright notice and this permission notice appear in all
# copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
# PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# --------------------------------------------------------------------
# %END_LICENSE%

CROOTDIR=		$(realpath ${ROOTDIR})

STRIPROOTDIR=		$(subst ${CROOTDIR}/,,$1)
PATH_NAMIFY=		$(subst .,_,$(subst -,_,$(subst /,_,$1)))
FILE_CFLAGS_VARNAME=	$(call PATH_NAMIFY,$(call STRIPROOTDIR,$(abspath $1)))_CFLAGS
FILE_PCPP_FLAGS_VARNAME=$(call PATH_NAMIFY,$(call STRIPROOTDIR,$(abspath $1)))_PCPP_FLAGS
FILE_CFLAGS=		${$(call PATH_NAMIFY,$(call STRIPROOTDIR,$(realpath $1)))_CFLAGS}
FILE_PCPP_FLAGS=	${$(call PATH_NAMIFY,$(call STRIPROOTDIR,$(realpath $1)))_PCPP_FLAGS}
ADD_FILE_CFLAGS=	$(shell if ! [ -f "$(abspath $1)" ]; then echo "ADD_FILE_CFLAGS: no such file: $(abspath $1)" >&2; fi )\
			$(eval $(call FILE_CFLAGS_VARNAME,$1)+=$2)

FORCE_INST?=		0

RELCURDIR=		$(call STRIPROOTDIR,${CURDIR}/)
OBJDIR?=		${OBJBASE}/psc.obj/${HOST}${CURDIR}
DEPEND_FILE=		${OBJDIR}/.depend

HOST=			$(word 1,$(subst ., ,$(shell hostname)))

-include ${ROOTDIR}/mk/local.${HOST}.mk
include ${ROOTDIR}/mk/defs.mk
include ${ROOTDIR}/mk/pickle.mk
-include ${ROOTDIR}/mk/local-post.${HOST}.mk

_TSRCS=			$(sort $(foreach fn,${SRCS},$(realpath ${fn})))
_TSRC_PATH=		$(shell perl -Wle 'my @a; push @a, shift; for my $$t (sort @ARGV) {	\
			  next if grep { $$t =~ /^\Q$$_\E/ } @a; print $$t; push @a, $$t } '	\
			  $(foreach dir,. ${SRC_PATH},$(realpath ${dir})))

_TOBJS=			$(patsubst %.c,%.o,$(filter %.c,${_TSRCS}))
_TOBJS+=		$(patsubst %.cc,%.o,$(filter %.cc,${_TSRCS}))
_TOBJS+=		$(patsubst %.y,%.o,$(filter %.y,${_TSRCS}))
_TOBJS+=		$(patsubst %.l,%.o,$(filter %.l,${_TSRCS}))
OBJS=			$(addprefix ${OBJDIR}/,$(notdir ${_TOBJS}))

_LEXINTM=		$(patsubst %.l,%.c,$(addprefix ${OBJDIR}/,$(notdir $(filter %.l,${_TSRCS}))))
_YACCINTM=		$(patsubst %.y,%.c,$(addprefix ${OBJDIR}/,$(notdir $(filter %.y,${_TSRCS}))))
_C_SRCS=		$(filter %.c,${_TSRCS}) ${_YACCINTM} ${_LEXINTM}

LNET_SOCKLND_SRCS+=	${LNET_BASE}/ulnds/socklnd/conn.c
LNET_SOCKLND_SRCS+=	${LNET_BASE}/ulnds/socklnd/handlers.c
LNET_SOCKLND_SRCS+=	${LNET_BASE}/ulnds/socklnd/poll.c
LNET_SOCKLND_SRCS+=	${LNET_BASE}/ulnds/socklnd/usocklnd.c
LNET_SOCKLND_SRCS+=	${LNET_BASE}/ulnds/socklnd/usocklnd_cb.c

LNET_CFS_SRCS+=		${LNET_BASE}/libcfs/debug.c
LNET_CFS_SRCS+=		${LNET_BASE}/libcfs/user-lock.c
LNET_CFS_SRCS+=		${LNET_BASE}/libcfs/user-prim.c
LNET_CFS_SRCS+=		${LNET_BASE}/libcfs/user-tcpip.c
LNET_CFS_SRCS+=		${LNET_BASE}/libcfs/user-tcpip-ssl.c

LNET_LIB_SRCS+=		${LNET_BASE}/lnet/acceptor.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/api-errno.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/api-ni.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/config.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/lib-eq.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/lib-md.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/lib-me.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/lib-move.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/lib-msg.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/lo.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/peer.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/router.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/router_proc.c

LNET_PTLLND_SRCS+=	${LNET_BASE}/ulnds/ptllnd/ptllnd.c
LNET_PTLLND_SRCS+=	${LNET_BASE}/ulnds/ptllnd/ptllnd_cb.c

PSCRPC_SRCS+=		${PFL_BASE}/completion.c
PSCRPC_SRCS+=		${PFL_BASE}/connection.c
PSCRPC_SRCS+=		${PFL_BASE}/events.c
PSCRPC_SRCS+=		${PFL_BASE}/export.c
PSCRPC_SRCS+=		${PFL_BASE}/import.c
PSCRPC_SRCS+=		${PFL_BASE}/nb.c
PSCRPC_SRCS+=		${PFL_BASE}/niobuf.c
PSCRPC_SRCS+=		${PFL_BASE}/packgeneric.c
PSCRPC_SRCS+=		${PFL_BASE}/pool.c
PSCRPC_SRCS+=		${PFL_BASE}/rpc_util.c
PSCRPC_SRCS+=		${PFL_BASE}/rpcclient.c
PSCRPC_SRCS+=		${PFL_BASE}/rsx.c
PSCRPC_SRCS+=		${PFL_BASE}/service.c

PSCRPC_SRCS+=		${PFL_BASE}/eqpollthr.c
PSCRPC_SRCS+=		${PFL_BASE}/usklndthr.c

LDFLAGS_DIRS=		$(filter -L%,${LDFLAGS})

_TINCLUDES=		$(filter-out -I%,${INCLUDES}) $(patsubst %,-I%/,$(foreach \
			dir,$(patsubst -I%,%,$(filter -I%,${INCLUDES})), $(realpath ${dir})))

_EXCLUDES=		$(filter-out -I%,${EXCLUDES}) $(patsubst %,-I%/,$(foreach \
			dir,$(patsubst -I%,%,$(filter -I%,${EXCLUDES})), $(realpath ${dir})))

_TPROG=			$(shell echo ${PROG} | sed 's/:[^:]*//g')
_TSHLIB=		$(shell echo ${SHLIB} | sed 's/:[^:]*//g')

CFLAGS+=		${DEFINES} $(filter-out ${_EXCLUDES},${_TINCLUDES})
TARGET?=		$(sort ${_TPROG} ${LIBRARY} ${TEST} ${DOCGEN} ${_TSHLIB})
PROG?=			${TEST}

EXTRACT_INCLUDES=	perl -ne 'print $$& while /-I\S+\s?/gc'
EXTRACT_DEFINES=	perl -ne 'print $$& while /-D\S+\s?/gc'
EXTRACT_CFLAGS=		perl -ne 'print $$& while /-[^ID]\S+\s?/gc'

# Process modules

ifdef PICKLE_HAVE_FSANITIZE
  FSANITIZE_CFLAGS=	-fsanitize=address -fno-optimize-sibling-calls
  FSANITIZE_LDFLAGS=	-fsanitize=address
endif

LIBPFL=		-lpfl

ifneq ($(filter pfl,${MODULES}),)
  MODULES+=	pfl-hdrs str clock pthread
  LDFLAGS+=	-L${PFL_BASE} ${LIBPFL} -lm
  ifdef PICKLE_HAVE_BACKTRACE
    LDFLAGS+=	-rdynamic
  endif
  DEPLIST+=	${PFL_BASE}:libpfl.a
  SRCS+=	${QSORT_R_SRCS}

  ifneq ($(filter pthread,${MODULES}),)
    MODULES+=	numa
  endif
endif

ifneq ($(filter pscfs,${MODULES}),)
  MODULES+=	pscfs-hdrs
  SHLIB_FLAGS=	${BUNDLE_FLAGS}
  SRCS+=	${PFL_BASE}/fs.c
  SRCS+=	${PSCFS_SRCS}

  ifdef PICKLE_HAVE_FUSE
    MODULES+=	fuse
  else ifdef PICKLE_HAVE_DOKAN
    MODULES+=	dokan
  else
    $(error pscfs was not able to find a suitable backend -- check FUSE installation)
  endif
endif

ifneq ($(filter pscfs-hdrs,${MODULES}),)
  ifdef PICKLE_HAVE_FUSE
    MODULES+=	fuse-hdrs
  else ifdef PICKLE_HAVE_DOKAN
    MODULES+=	dokan-hdrs
  else
    $(error pscfs was not able to find a suitable backend -- check FUSE installation)
  endif
endif

ifneq ($(filter fuse,${MODULES}),)
  CFLAGS+=	${FUSE_CFLAGS}
  LDFLAGS+=	${FUSE_LIBS}
  MODULES+=	fuse-hdrs
endif

ifneq ($(filter fuse-hdrs,${MODULES}),)
  DEFINES+=	-DFUSE_USE_VERSION=${FUSE_VERSION} ${FUSE_DEFINES}<commit_msg>pscfs modules should all be compiled similarly<commit_after># $Id$
# %ISC_START_LICENSE%
# ---------------------------------------------------------------------
# Copyright 2006-2018, Pittsburgh Supercomputing Center
# All rights reserved.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the
# above copyright notice and this permission notice appear in all
# copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
# PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# --------------------------------------------------------------------
# %END_LICENSE%

CROOTDIR=		$(realpath ${ROOTDIR})

STRIPROOTDIR=		$(subst ${CROOTDIR}/,,$1)
PATH_NAMIFY=		$(subst .,_,$(subst -,_,$(subst /,_,$1)))
FILE_CFLAGS_VARNAME=	$(call PATH_NAMIFY,$(call STRIPROOTDIR,$(abspath $1)))_CFLAGS
FILE_PCPP_FLAGS_VARNAME=$(call PATH_NAMIFY,$(call STRIPROOTDIR,$(abspath $1)))_PCPP_FLAGS
FILE_CFLAGS=		${$(call PATH_NAMIFY,$(call STRIPROOTDIR,$(realpath $1)))_CFLAGS}
FILE_PCPP_FLAGS=	${$(call PATH_NAMIFY,$(call STRIPROOTDIR,$(realpath $1)))_PCPP_FLAGS}
ADD_FILE_CFLAGS=	$(shell if ! [ -f "$(abspath $1)" ]; then echo "ADD_FILE_CFLAGS: no such file: $(abspath $1)" >&2; fi )\
			$(eval $(call FILE_CFLAGS_VARNAME,$1)+=$2)

FORCE_INST?=		0

RELCURDIR=		$(call STRIPROOTDIR,${CURDIR}/)
OBJDIR?=		${OBJBASE}/psc.obj/${HOST}${CURDIR}
DEPEND_FILE=		${OBJDIR}/.depend

HOST=			$(word 1,$(subst ., ,$(shell hostname)))

-include ${ROOTDIR}/mk/local.${HOST}.mk
include ${ROOTDIR}/mk/defs.mk
include ${ROOTDIR}/mk/pickle.mk
-include ${ROOTDIR}/mk/local-post.${HOST}.mk

_TSRCS=			$(sort $(foreach fn,${SRCS},$(realpath ${fn})))
_TSRC_PATH=		$(shell perl -Wle 'my @a; push @a, shift; for my $$t (sort @ARGV) {	\
			  next if grep { $$t =~ /^\Q$$_\E/ } @a; print $$t; push @a, $$t } '	\
			  $(foreach dir,. ${SRC_PATH},$(realpath ${dir})))

_TOBJS=			$(patsubst %.c,%.o,$(filter %.c,${_TSRCS}))
_TOBJS+=		$(patsubst %.cc,%.o,$(filter %.cc,${_TSRCS}))
_TOBJS+=		$(patsubst %.y,%.o,$(filter %.y,${_TSRCS}))
_TOBJS+=		$(patsubst %.l,%.o,$(filter %.l,${_TSRCS}))
OBJS=			$(addprefix ${OBJDIR}/,$(notdir ${_TOBJS}))

_LEXINTM=		$(patsubst %.l,%.c,$(addprefix ${OBJDIR}/,$(notdir $(filter %.l,${_TSRCS}))))
_YACCINTM=		$(patsubst %.y,%.c,$(addprefix ${OBJDIR}/,$(notdir $(filter %.y,${_TSRCS}))))
_C_SRCS=		$(filter %.c,${_TSRCS}) ${_YACCINTM} ${_LEXINTM}

LNET_SOCKLND_SRCS+=	${LNET_BASE}/ulnds/socklnd/conn.c
LNET_SOCKLND_SRCS+=	${LNET_BASE}/ulnds/socklnd/handlers.c
LNET_SOCKLND_SRCS+=	${LNET_BASE}/ulnds/socklnd/poll.c
LNET_SOCKLND_SRCS+=	${LNET_BASE}/ulnds/socklnd/usocklnd.c
LNET_SOCKLND_SRCS+=	${LNET_BASE}/ulnds/socklnd/usocklnd_cb.c

LNET_CFS_SRCS+=		${LNET_BASE}/libcfs/debug.c
LNET_CFS_SRCS+=		${LNET_BASE}/libcfs/user-lock.c
LNET_CFS_SRCS+=		${LNET_BASE}/libcfs/user-prim.c
LNET_CFS_SRCS+=		${LNET_BASE}/libcfs/user-tcpip.c
LNET_CFS_SRCS+=		${LNET_BASE}/libcfs/user-tcpip-ssl.c

LNET_LIB_SRCS+=		${LNET_BASE}/lnet/acceptor.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/api-errno.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/api-ni.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/config.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/lib-eq.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/lib-md.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/lib-me.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/lib-move.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/lib-msg.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/lo.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/peer.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/router.c
LNET_LIB_SRCS+=		${LNET_BASE}/lnet/router_proc.c

LNET_PTLLND_SRCS+=	${LNET_BASE}/ulnds/ptllnd/ptllnd.c
LNET_PTLLND_SRCS+=	${LNET_BASE}/ulnds/ptllnd/ptllnd_cb.c

PSCRPC_SRCS+=		${PFL_BASE}/completion.c
PSCRPC_SRCS+=		${PFL_BASE}/connection.c
PSCRPC_SRCS+=		${PFL_BASE}/events.c
PSCRPC_SRCS+=		${PFL_BASE}/export.c
PSCRPC_SRCS+=		${PFL_BASE}/import.c
PSCRPC_SRCS+=		${PFL_BASE}/nb.c
PSCRPC_SRCS+=		${PFL_BASE}/niobuf.c
PSCRPC_SRCS+=		${PFL_BASE}/packgeneric.c
PSCRPC_SRCS+=		${PFL_BASE}/pool.c
PSCRPC_SRCS+=		${PFL_BASE}/rpc_util.c
PSCRPC_SRCS+=		${PFL_BASE}/rpcclient.c
PSCRPC_SRCS+=		${PFL_BASE}/rsx.c
PSCRPC_SRCS+=		${PFL_BASE}/service.c

PSCRPC_SRCS+=		${PFL_BASE}/eqpollthr.c
PSCRPC_SRCS+=		${PFL_BASE}/usklndthr.c

LDFLAGS_DIRS=		$(filter -L%,${LDFLAGS})

_TINCLUDES=		$(filter-out -I%,${INCLUDES}) $(patsubst %,-I%/,$(foreach \
			dir,$(patsubst -I%,%,$(filter -I%,${INCLUDES})), $(realpath ${dir})))

_EXCLUDES=		$(filter-out -I%,${EXCLUDES}) $(patsubst %,-I%/,$(foreach \
			dir,$(patsubst -I%,%,$(filter -I%,${EXCLUDES})), $(realpath ${dir})))

_TPROG=			$(shell echo ${PROG} | sed 's/:[^:]*//g')
_TSHLIB=		$(shell echo ${SHLIB} | sed 's/:[^:]*//g')

CFLAGS+=		${DEFINES} $(filter-out ${_EXCLUDES},${_TINCLUDES})
TARGET?=		$(sort ${_TPROG} ${LIBRARY} ${TEST} ${DOCGEN} ${_TSHLIB})
PROG?=			${TEST}

EXTRACT_INCLUDES=	perl -ne 'print $$& while /-I\S+\s?/gc'
EXTRACT_DEFINES=	perl -ne 'print $$& while /-D\S+\s?/gc'
EXTRACT_CFLAGS=		perl -ne 'print $$& while /-[^ID]\S+\s?/gc'

# Process modules

ifdef PICKLE_HAVE_FSANITIZE
  FSANITIZE_CFLAGS=	-fsanitize=address -fno-optimize-sibling-calls
  FSANITIZE_LDFLAGS=	-fsanitize=address
endif

LIBPFL=		-lpfl

ifneq ($(filter pfl,${MODULES}),)
  MODULES+=	pfl-hdrs str clock pthread
  LDFLAGS+=	-L${PFL_BASE} ${LIBPFL} -lm
  ifdef PICKLE_HAVE_BACKTRACE
    LDFLAGS+=	-rdynamic
  endif
  DEPLIST+=	${PFL_BASE}:libpfl.a
  SRCS+=	${QSORT_R_SRCS}

  ifneq ($(filter pthread,${MODULES}),)
    MODULES+=	numa
  endif
endif

ifneq ($(filter pscfs,${MODULES}),)
  MODULES+=	pscfs-hdrs pthread
  SHLIB_FLAGS=	${BUNDLE_FLAGS}
  SRCS+=	${PFL_BASE}/fs.c
  SRCS+=	${PSCFS_SRCS}

  ifdef PICKLE_HAVE_FUSE
    MODULES+=	fuse
  else ifdef PICKLE_HAVE_DOKAN
    MODULES+=	dokan
  else
    $(error pscfs was not able to find a suitable backend -- check FUSE installation)
  endif
endif

ifneq ($(filter pscfs-hdrs,${MODULES}),)
  ifdef PICKLE_HAVE_FUSE
    MODULES+=	fuse-hdrs
  else ifdef PICKLE_HAVE_DOKAN
    MODULES+=	dokan-hdrs
  else
    $(error pscfs was not able to find a suitable backend -- check FUSE installation)
  endif
endif

ifneq ($(filter fuse,${MODULES}),)
  CFLAGS+=	${FUSE_CFLAGS}
  LDFLAGS+=	${FUSE_LIBS}
  MODULES+=	fuse-hdrs
endif

ifneq ($(filter fuse-hdrs,${MODULES}),)
  DEFINES+=	-DFUSE_USE_VERSION=${FUSE_VERSION} ${FUSE_DEFINES}
{'fraction_non_alphanumeric': 0.20603506659643314, 'fraction_numerical': 0.0031605086913989015, 'mean_word_length': 4.664961636828645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5339210', 'n_tokens_mistral': 6059, 'n_tokens_neox': 5835, 'n_words': 1068}