All pastes #994564 Raw Edit

Miscellany

public text v1 · immutable
#994564 ·published 2008-04-23 14:19 UTC
rendered paste body
#!/bin/bash

# Options.
RELEASE="v0.1"
CFLAGS="-fomit-frame-pointer -falign-jumps=2 -falign-loops=2 -mpreferred-stack-boundary=2 -s"

# Message.
echo "Bit $release programming language."
echo "(if it were Ada we would simply doc it as erroneous (Larry Wall)"
echo "Compiling Bit can be done by using several C compilers"
echo "as the code is fully portable. By default we will use the gnu gcc compiler."
echo "(Notice: You can change CFLAGS and when invoking bit-makefile)"
echo ""

# Options.
echo "Bit is by default compiled with generic compiler options that"
echo "are set to generate optimized code, but you can change it to optimize"
echo "for size."
echo "Optimize for size ? [y/n]"

# Compiling Bit.
read inst
for i in ./source/*.c;
do 
echo :: Building... $i;
if [ $inst = "y" ]; then
    cc -Os -c $i;
else
    cc -O3 -c $i;
fi
done;

# Linking Bit.
mv *.o ./objects;
echo :: Linking Bit into binary form...;
cc -s -lm ./objects/*.o -o ./binaries/bit;

# Cleaning.
echo :: Cleaning object files....;
rm -rf ./objects/*.o

# Message.
echo "Done."
echo "Bit can be found in `pwd`/binaries/bit"
echo "Install on /usr/local/bin ? [y/n]"
echo "(Notice: this needs root privileges)"

# Installing bit.
read inst
if [ $inst = "y" ]; then
  echo :: Installing bit...;
  su -c "cp ./binaries/bit /usr/local/bin"
fi

# Message.
echo "Done."
echo "Generate HTML documentation for bit source code? [y/n]"
echo "Resulting files will be found at `pwd`/documentation"
echo "(Notice: Requires GNU source-highlight installed)"

# Generating documentation.
read inst
if [ $inst = "y" ]; then
    if [ -x /usr/bin/source-highlight ]; then
	 echo :: Generating html documentation...;
	 source-highlight -n --style style2.style source/*.c source/*.h 
	 mv source/*.html documentation
    else
	echo "Source highlight was not found on your system."
        echo "Get it from GNU and run this script again if you wish"
        echo "to generate documentation for Bit."
    fi
fi

# End of script.
echo "Done."