Skip to content

Instantly share code, notes, and snippets.

@kou1okada
Last active October 12, 2015 14:07
Show Gist options
  • Save kou1okada/4037863 to your computer and use it in GitHub Desktop.
Save kou1okada/4037863 to your computer and use it in GitHub Desktop.
Build htsengine package for cygwin
#!/usr/bin/env bash
#-----------------------------------------------------------------------------
PKGNAME=htsengine
VERSION=1.07
SRCURL=http://downloads.sourceforge.net/hts-engine/hts_engine_API-${VERSION}.tar.gz
SRCARC=${SRCURL##*/}
SRCDIR=${SRCARC%.tar.gz}
CONFIGUREOPT=""
REQUIRES=( )
HINT="\
@ $PKGNAME\n\
sdesc: \"hts_engine API. frontend of HMM-based speech synthesis engine.\"\n\
ldesc: \"hts_engine API. frontend of HMM-based speech synthesis engine.\"\n\
category: Audio\n\
requires: cygwin\n\
version: $VERSION\n\
"
prebuild () {
true # If you have something to do at prebuild phase, write it here.
}
#-----------------------------------------------------------------------------
BUILDDIR=$PKGNAME
PKGDIR=$PKGNAME
PKGFILE=$PKGNAME-$VERSION.tar.bz2
for i in "${REQUIRES[@]}"; do
if [ ! -e "$i" ]; then
echo "Error: $i is not found."
echo
exit
fi
done
mkdir -p $BUILDDIR $BUILDDIR/$PKGDIR
echo -e "$HINT" > $BUILDDIR/$PKGDIR/setup.hint
cat << 'EOD' > $BUILDDIR/$SRCDIR.cygwin.patch
*** hts_engine_API-1.07.orig/lib/HTS_misc.c 2012-12-20 17:35:56.000000000 +0900
--- hts_engine_API-1.07/lib/HTS_misc.c 2013-11-12 19:33:33.640684300 +0900
***************
*** 245,255 ****
} else if (fp->type == HTS_FILE) {
fpos_t pos;
fgetpos((FILE *) fp->pointer, &pos);
! #if defined(_WIN32) || defined(__APPLE__)
return (size_t) pos;
#else
return (size_t) pos.__pos;
! #endif /* _WIN32 || __APPLE__ */
}
HTS_error(0, "HTS_ftell: Unknown file type.\n");
return 0;
--- 245,255 ----
} else if (fp->type == HTS_FILE) {
fpos_t pos;
fgetpos((FILE *) fp->pointer, &pos);
! #if defined(_WIN32) || defined(__CYGWIN__)|| defined(__APPLE__)
return (size_t) pos;
#else
return (size_t) pos.__pos;
! #endif /* _WIN32 || __CYGWIN__ || __APPLE__ */
}
HTS_error(0, "HTS_ftell: Unknown file type.\n");
return 0;
EOD
cat <<EOD > $BUILDDIR/Makefile
PKGNAME=$PKGNAME
SRCURL="$SRCURL"
SRCARC=$SRCARC
SRCDIR=$SRCDIR
PKGDIR=$PKGDIR
PKGFILE=\$(PKGDIR)/$PKGFILE
all: download \$(PKGFILE)
@echo =========================================
@echo "Following cygwin package files are built."
@ls -l \$(PKGFILE)
patch:
if [ -e \$(SRCDIR).cygwin.patch ]; then patch -d \$(SRCDIR) -p 1 < \$(SRCDIR).cygwin.patch; fi
touch \$@
download: \$(SRCARC)
\$(SRCARC):
wget -c --content-disposition "\$(SRCURL)"
extract: \$(SRCDIR)/extract
\$(SRCDIR)/extract: \$(SRCARC)
ifeq (\$(patsubst %.tar.gz,.tar.gz,\$(SRCARC)),.tar.gz)
tar zxvf \$(SRCARC)
endif
ifeq (\$(suffix \$(SRCARC)),.tgz)
tar zxvf \$(SRCARC)
endif
ifeq (\$(suffix \$(SRCARC)),.zip)
unzip \$(SRCARC)
endif
touch \$@
\$(SRCDIR)/Makefile: extract patch
cd \$(SRCDIR) && ./configure --prefix=/usr $CONFIGUREOPT
build: \$(SRCDIR)/Makefile
cd \$(SRCDIR) && make DESTDIR="\`pwd\`/tmp" install
touch \$@
\$(PKGFILE): build
mkdir -p \$(PKGDIR)
cd \$(SRCDIR)/tmp && tar jcvf ../../\$(PKGFILE) *
buildclean:
-rm build patch extract
clean: buildclean
cd \$(SRCDIR) && make clean
distclean: buildclean
cd \$(SRCDIR) && make distclean
distcleanall: buildclean
-rm -r \$(SRCDIR) \$(PKGDIR)
EOD
prebuild
cd $BUILDDIR && make "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment