Skip to content

Commit a0a622c

Browse files
committed
refactor configuration
1 parent e88c279 commit a0a622c

9 files changed

+98
-47
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ README.html
2121
## docs
2222
inst/doc
2323
/src/Makevars
24+
/src/Makevars.win

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: vcfppR
22
Title: Rapid Manipulation of the Variant Call Format (VCF)
3-
Version: 0.7.7
3+
Version: 0.8.0
44
Authors@R: c(
55
person("Zilong", "Li", , "[email protected]", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0001-5859-2078")),

cleanup.win

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
22

33
HTSLIB_DIR="src/htslib-1.21"
4-
rm -f ${HTSLIB_DIR}/config.h src/*.o src/*.so src/*.dll src/*.dylib
4+
rm -f ${HTSLIB_DIR}/config.h src/*.o src/*.dll src/*.so src/*.dylib
55
cd $HTSLIB_DIR && make clean && cd -

configure

+29-16
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,43 @@
11
#!/bin/sh
22

3-
# Exit on any error
43
set -e
54

5+
MAKE=`"${R_HOME}/bin/R" CMD config MAKE`
6+
CC=`"${R_HOME}/bin/R" CMD config CC`
7+
AR=`"${R_HOME}/bin/R" CMD config AR`
8+
RANLIB=`"${R_HOME}/bin/R" CMD config RANLIB`
9+
R_CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
10+
R_CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS`
11+
R_CPICFLAGS=`"${R_HOME}/bin/R" CMD config CPICFLAGS`
12+
13+
# -fPIC is ensential for shared lib
14+
# CFLAGS="${R_CFLAGS} ${R_CPICFLAGS} -fPIC -D_FILE_OFFSET_BITS=64"
15+
CFLAGS="-Wall -g -O2 -fvisibility=hidden -fPIC -D_FILE_OFFSET_BITS=64"
16+
# remove assert by defining NDEBUG
17+
CPPFLAGS="${R_CPPFLAGS} -DNDEBUG"
18+
619
HTSLIB_DIR="htslib-1.21"
720

821
echo "Configuring HTSlib in $HTSLIB_DIR"
922
cd src/$HTSLIB_DIR
23+
./configure \
24+
CFLAGS="${CFLAGS}"
25+
1026
## copy file instead of symbolic linking
11-
cp htscodecs_bundled.mk htscodecs.mk
12-
./configure CFLAGS="-g -O2 -fPIC -D_FILE_OFFSET_BITS=64 -DNDEBUG"
27+
rm -f htscodecs.mk && cp htscodecs_bundled.mk htscodecs.mk
28+
29+
${MAKE} libhts.a CC="${CC}" CPPFLAGS="${CPPFLAGS}" AR="${AR}" RANLIB="${RANLIB}"
30+
31+
EXTRA_LIBS="-lz -lm -lbz2 -llzma -lcurl"
1332

14-
hasdeflate="no"
1533
if grep -wq "#define HAVE_LIBDEFLATE 1" config.h;then
16-
hasdeflate="yes"
34+
EXTRA_LIBS="${EXTRA_LIBS} -ldeflate"
1735
fi
1836

19-
make libhts.a
20-
2137
echo "Create Makevar file"
22-
cd ../../
23-
SRC_MAKEVAR="src/Makevars"
24-
echo "PKG_CPPFLAGS=-I${HTSLIB_DIR} -I../inst/include" >$SRC_MAKEVAR
25-
26-
if [ $hasdeflate = "no" ]; then
27-
echo "PKG_LIBS=${HTSLIB_DIR}/libhts.a -lz -lm -lbz2 -llzma -lcurl" >>$SRC_MAKEVAR
28-
else
29-
echo "PKG_LIBS=${HTSLIB_DIR}/libhts.a -ldeflate -lz -lm -lbz2 -llzma -lcurl" >>$SRC_MAKEVAR
30-
fi
38+
cd ..
39+
sed \
40+
-e "s|@EXTRA_CPPFLAGS@|${CPPFLAGS}|g" \
41+
-e "s|@EXTRA_LIBS@|${EXTRA_LIBS}|g" \
42+
Makevars.in > Makevars
43+

configure.win

+41-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,46 @@
11
#!/bin/sh
22

3-
HTSLIB_DIR="src/htslib-1.21"
3+
set -e
4+
5+
MAKE=`"${R_HOME}/bin/R" CMD config MAKE`
6+
CC=`"${R_HOME}/bin/R" CMD config CC`
7+
AR=`"${R_HOME}/bin/R" CMD config AR`
8+
RANLIB=`"${R_HOME}/bin/R" CMD config RANLIB`
9+
R_CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
10+
R_CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS`
11+
R_CPICFLAGS=`"${R_HOME}/bin/R" CMD config CPICFLAGS`
12+
13+
# -fPIC is ensential for shared lib
14+
CFLAGS="-Wall -g -O2 -fvisibility=hidden -fPIC -D_FILE_OFFSET_BITS=64"
15+
# CFLAGS="${R_CFLAGS} ${R_CPICFLAGS} -fPIC -D_FILE_OFFSET_BITS=64"
16+
# remove assert by defining NDEBUG
17+
CPPFLAGS="${R_CPPFLAGS} -DNDEBUG"
18+
19+
HTSLIB_DIR="htslib-1.21"
20+
421
echo "Configuring HTSlib in $HTSLIB_DIR"
5-
cd $HTSLIB_DIR
6-
## fix symbolic linking error
7-
cp htscodecs_bundled.mk htscodecs.mk
8-
./configure --without-libdeflate CFLAGS="-g -O2 -fPIC -D_FILE_OFFSET_BITS=64 -DNDEBUG"
22+
cd src/$HTSLIB_DIR
23+
# ./configure --without-libdeflate
24+
./configure \
25+
--without-libdeflate \
26+
CFLAGS="${CFLAGS}"
27+
28+
## copy file instead of symbolic linking
29+
rm -f htscodecs.mk && cp htscodecs_bundled.mk htscodecs.mk
30+
31+
${MAKE} libhts.a CC="${CC}" CPPFLAGS="${CPPFLAGS}" AR="${AR}" RANLIB="${RANLIB}"
32+
33+
EXTRA_LIBS="-lz"
34+
35+
if grep -wq "#define HAVE_LIBDEFLATE 1" config.h;then
36+
EXTRA_LIBS="${EXTRA_LIBS} -ldeflate"
37+
fi
38+
39+
echo "Create Makevar file"
40+
cd ..
41+
sed \
42+
-e "s|@EXTRA_CPPFLAGS@|${CPPFLAGS}|g" \
43+
-e "s|@EXTRA_LIBS@|${EXTRA_LIBS}|g" \
44+
Makevars.win.in > Makevars.win
945

10-
make libhts.a
1146

src/Makevars.in

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
HTSLIB_DIR='./htslib-1.21'
2+
PKG_CPPFLAGS=-I$(HTSLIB_DIR) -I../inst/include @EXTRA_CPPFLAGS@
3+
PKG_LIBS=-L$(HTSLIB_DIR) -lhts @EXTRA_LIBS@
4+
5+
.PHONY: all
6+
7+
all: $(SHLIB)

src/Makevars.win

-23
This file was deleted.

src/Makevars.win.in

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
HTSLIB_DIR='./htslib-1.21'
2+
PKG_CPPFLAGS=-I$(HTSLIB_DIR) -I../inst/include @EXTRA_CPPFLAGS@
3+
PKG_LIBS=-L$(HTSLIB_DIR) -lhts @EXTRA_LIBS@
4+
5+
ifeq (,$(shell pkg-config --version 2>/dev/null))
6+
LIBPSL = $(or $(and $(wildcard $(R_TOOLS_SOFT)/lib/libpsl.a),-lpsl),)
7+
LIBBROTLI = $(or $(and $(wildcard $(R_TOOLS_SOFT)/lib/libbrotlidec.a),-lbrotlidec -lbrotlicommon),)
8+
PKG_LIBS += -lm -llzma -lbz2 -lcurl $(LIBPSL) $(LIBBROTLI) -lbcrypt -lidn2 -lunistring -liconv -lssl -lcrypto -lcrypt32 -lwsock32 -lwldap32 -lssh2 -lgcrypt -lgpg-error -lws2_32 -lzstd -lregex
9+
else
10+
PKG_LIBS += -lm -llzma -lbz2 -lregex $(shell pkg-config --libs libcurl)
11+
PKG_CPPFLAGS += $(shell pkg-config --cflags libcurl)
12+
endif
13+
14+
.PHONY: all
15+
16+
all: $(SHLIB)
17+

src/install.libs.R

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ files <- c(files, dir("htslib-1.21/", pattern="a$", full.names=TRUE))
33
dest <- file.path(R_PACKAGE_DIR, paste0('libs', R_ARCH))
44
dir.create(dest, recursive = TRUE, showWarnings = FALSE)
55
file.copy(files, dest, overwrite = TRUE)
6+

0 commit comments

Comments
 (0)