## This file uses GNU make syntax ($(shell ...) and ifeq) so we need
## to have "SystemRequirements: GNU make" in the DESCRIPTION file.
## See "Writing portable packages" in the "Writing R Extensions" manual:
##   https://cran.r-project.org/doc/manuals/r-release/R-exts.html

include Makevars.common

TWOBIT_MAKEFILE=Makefile.Rtwobitlib

## Linker options. Make sure the Rtwobitlib::pkgconfig() function (defined
## in R/zzz.R) produces the same PKG_LIBS value.
## We will need -lcrypto only if we decide to support the
## twoBitOpenExternalBptIndex functionality. See README.txt
## in Rtwobitlib/inst/unused_but_kept_just_in_case/
#PKG_LIBS+=-lcrypto

## Even though we should try to avoid using GNU 'make' extensions (for por-
## tability), we use one here to detect the platform :-/ Is there a more
## portable way to do this?
platform := $(shell uname -s)

ifeq (${platform},Darwin)

populate-usrlib-dir: kent mk-usrlib-dir
	cd "${TWOBIT_SOURCE_DIR}" && cp libtwobit.a "${USRLIB_DIR}"

else

populate-usrlib-dir: kent mk-usrlib-dir
	cd "${TWOBIT_SOURCE_DIR}" && cp libtwobit.so libtwobit.a "${USRLIB_DIR}"
	cd "${USRLIB_DIR}" && ln -s libtwobit.so libtwobit.so.2

endif
