Skip to content

Commit

Permalink
detect native libotr during installation
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaamani committed Jun 2, 2013
1 parent a1a166a commit 47acec6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
23 changes: 23 additions & 0 deletions build.sh
@@ -0,0 +1,23 @@
#!/bin/bash
export otr_version=`./check-otr-version.sh`

if [ "${otr_version}" == '' ]
then
echo "No libotr found on the system."
echo "On Debian/Ubuntu you can install it with the following command:"
echo "sudo apt-get install libotr2 libotr2-dev"
exit
fi

echo "Found local version of libotr: ${otr_version}"

if [ "${otr_version}" == '3' ]
then
make module
fi

if [ "${otr_version}" == '4' ]
then
echo "module 'otr3' requires native libotr 3.2.1 on the system."
fi

19 changes: 19 additions & 0 deletions check-otr-version.sh
@@ -0,0 +1,19 @@
#!/bin/bash

# use the C pre-processor to get the version of libotr on the system

cat >tmp.h <<EOF
#include <libotr/version.h>
#ifdef OTRL_VERSION_MAJOR
otrl-version OTRL_VERSION_MAJOR OTRL_VERSION_MINOR OTRL_VERSION_SUB
#else
otrl-version 0 0 0
#endif
EOF

if [ -e tmp.h ]
then
#prints the major version or 0 if libotr dev headers not found
cc -E tmp.h 2>/dev/null | grep "otrl-version" | awk '{print $2}'
rm tmp.h
fi
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -13,6 +13,6 @@
"url":"git@github.com:mnaamani/node-otr-v2.git"
},
"scripts":{
"preinstall":"make module"
"preinstall":"./build.sh"
}
}

0 comments on commit 47acec6

Please sign in to comment.