Skip to content

Commit

Permalink
Merge pull request #134 from ludopulles/master
Browse files Browse the repository at this point in the history
Similar to fpylll changes: refactor bootstrap
  • Loading branch information
malb authored Dec 21, 2024
2 parents c7aa4ef + a9aae78 commit 88fdac1
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 274 deletions.
46 changes: 24 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,45 @@
# Specific Files #
##################

/g6k/siever.cpp
/g6k/siever_params.cpp
/svpchallenge/*
/g6k-fplll
/g6k-fpylll
/g6k-env
/activate
/build/
/dist/
/G6K.egg-info/
*.lo
*~
/Makefile
/Makefile.in
/aclocal.m4
/activate
/autom4te.cache/
/build/
/compile
/config.guess
/config.log
/config.status
/config.sub
/configure
/depcomp
/dist/
/g6k-env
/g6k-fplll
/g6k-fpylll
/g6k.egg-info/
/g6k.pc
/g6k/siever.cpp
/g6k/siever_params.cpp
/install-sh
/kernel/.deps/
/kernel/.libs/
*.lo
*~
/kernel/libg6k.la
stamp-h1
/kernel/g6k_config.h
/kernel/Makefile.in
/kernel/Makefile
/m4/lt~obsolete.m4
/m4/ltversion.m4
/m4/ltsugar.m4
/m4/ltoptions.m4
/kernel/Makefile.in
/kernel/g6k_config.h
/kernel/g6k_config.h.in
/kernel/libg6k.la
/libtool
/ltmain.sh
/m4/libtool.m4
/m4/ltoptions.m4
/m4/ltsugar.m4
/m4/ltversion.m4
/m4/lt~obsolete.m4
/missing
/ltmain.sh
/libtool
/svpchallenge/*
/test-driver
stamp-h1
83 changes: 40 additions & 43 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ if [ "$1" = "-j" ]; then
jobs="-j $2 "
fi

# Create Virtual Environment

if [ "$PYTHON" = "" ]; then PYTHON=python; export PYTHON; fi
PIP="$PYTHON -m pip"

Expand All @@ -20,20 +18,36 @@ echo "Using python version: $PYVER"
echo "Using $jobs"
sleep 1

rm -rf g6k-env
# Create Virtual Environment

rm -rf g6k-env activate
$PYTHON -m virtualenv g6k-env -p $PYTHON
if [ ! -d g6k-env ]; then
echo "Failed to create virtual environment in 'g6k-env'!"
echo "Is '$PYTHON -m virtualenv' working?"
echo "Try '$PIP install virtualenv' otherwise."
exit 1 # 1 is the exit value if creating virtualenv fails
fi

cat <<EOF >>g6k-env/bin/activate
### LD_LIBRARY_HACK
_OLD_LD_LIBRARY_PATH="\$LD_LIBRARY_PATH"
LD_LIBRARY_PATH="\$VIRTUAL_ENV/lib:\$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH
### END_LD_LIBRARY_HACK
CFLAGS="\$CFLAGS -O3 -march=native -Wp,-U_FORTIFY_SOURCE"
CXXFLAGS="\$CXXFLAGS -O3 -march=native -Wp,-U_FORTIFY_SOURCE"
export CFLAGS
export CXXFLAGS
### PKG_CONFIG_HACK
_OLD_PKG_CONFIG_PATH="\$PKG_CONFIG_PATH"
PKG_CONFIG_PATH="\$VIRTUAL_ENV/lib/pkgconfig:\$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH
### END_PKG_CONFIG_HACK
PYTHON="$PYTHON"
export PYTHON
unalias python 2>/dev/null
Expand All @@ -42,59 +56,34 @@ alias python=$PYTHON
alias pip="$PYTHON -m pip"
EOF

if [ ! -d g6k-env ]; then
echo "Failed to create virtual environment in 'g6k-env' !"
echo "Is '$PYTHON -m virtualenv' working?"
echo "Try '$PYTHON -m pip install virtualenv' otherwise."
exit 1
fi


ln -s g6k-env/bin/activate ./
source ./activate

$PIP install -U pip

cat <<EOF >>g6k-env/bin/activate
CFLAGS="\$CFLAGS -O3 -march=native -Wp,-U_FORTIFY_SOURCE"
CXXFLAGS="\$CXXFLAGS -O3 -march=native -Wp,-U_FORTIFY_SOURCE"
export CFLAGS
export CXXFLAGS
EOF

deactivate
source ./activate

$PIP install -U pip -r requirements.txt

# Install FPLLL

git clone https://github.com/fplll/fplll g6k-fplll
cd g6k-fplll || exit
git pull # Update if it was checked-out before
./autogen.sh
./configure --prefix="$VIRTUAL_ENV" $CONFIGURE_FLAGS
make clean
retval=$?
if [ $retval -ne 0 ]; then

if ! make clean; then
echo "Make clean failed in fplll. This is usually because there was an error with either autogen.sh or configure."
echo "Check the logs above - they'll contain more information."
exit 1 # 1 is the exit value if building fplll fails via configure or autogen
exit 2 # 2 is the exit value if building fplll fails via configure or autogen
fi

make $jobs
retval=$?
if [ $retval -ne 0 ]; then
if ! make $jobs; then
echo "Making fplll failed."
echo "Check the logs above - they'll contain more information."
exit 2 # 2 is the exit value if building fplll fails as a result of make $jobs.
exit 3 # 3 is the exit value if building fplll fails as a result of make $jobs.
fi

make install
retval=$?

if [ $retval -ne 0 ]; then
if ! make install; then
echo "Make install failed for fplll."
echo "Check the logs above - they'll contain more information."
exit 3 # 3 is the exit value if installing fplll failed.
exit 4 # 4 is the exit value if installing fplll failed.
fi

cd ..
Expand All @@ -103,18 +92,27 @@ cd ..

git clone https://github.com/fplll/fpylll g6k-fpylll
cd g6k-fpylll || exit
$PIP install -r requirements.txt
$PIP install -r suggestions.txt
git pull # Update if it was checked-out before
$PIP install -r requirements.txt -r suggestions.txt

$PYTHON setup.py clean
$PYTHON setup.py build_ext $jobs || $PYTHON setup.py build_ext
if ! ( $PYTHON setup.py build_ext $jobs || $PYTHON setup.py build_ext ); then
echo "Failed to build FPyLLL!"
echo "Check the logs above - they'll contain more information."
exit 5
fi
$PYTHON setup.py install

cd ..

# Build G6K

$PIP install -r requirements.txt
$PYTHON setup.py clean
$PYTHON setup.py build_ext $jobs --inplace || $PYTHON setup.py build_ext --inplace
if ! ( $PYTHON setup.py build_ext $jobs --inplace || $PYTHON setup.py build_ext --inplace ); then
echo "Failed to build G6K!"
echo "Check the logs above - they'll contain more information."
exit 6
fi

# Fin

Expand All @@ -123,4 +121,3 @@ echo "Don't forget to activate environment each time:"
echo " source ./activate"
echo "This will also add the following aliases:"
grep "^alias" activate

Loading

0 comments on commit 88fdac1

Please sign in to comment.