buildone 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. # --------------------------------------------------------------------
  3. # This nifty batch script will compile one tool which is specified
  4. # on the commandline
  5. #
  6. # for example if we want to build ttpack we will call this tool:
  7. # buildone.bat ttpack
  8. #
  9. # if upx is found in the path it will pack the executables otherwise
  10. # they stay in their original form
  11. #
  12. # at the end of the batch script the final executable is moved into
  13. # the calctools bin directory
  14. # --------------------------------------------------------------------
  15. if [ -z "$CC" ] ; then
  16. echo CC environment variable not defined, assuming CC=gcc
  17. CC=gcc
  18. fi
  19. if [ -z "`$CC --version | grep mingw`" -a -z "`$CC --version | grep msys`" -a -z "`$CC --version | grep cygwin`" ] ; then
  20. out=$1
  21. else
  22. out=$1.exe
  23. fi
  24. echo compiling $1 to $out...
  25. $CC -Os -Wall -W -Wp,-D_FORTIFY_SOURCE=2 -s -o $out $1.c
  26. if [ $? -ne 0 ] ; then
  27. echo compilation failed
  28. exit 1
  29. fi
  30. if [ type upx >/dev/null 2>/dev/null ] ; then
  31. echo compressing file
  32. upx --best $out >/dev/null 2>/dev/null
  33. else
  34. echo compression skipped
  35. fi
  36. if [ -f $out ] ; then
  37. echo moving executable ...
  38. mkdir -p bin
  39. mv $out bin/
  40. fi
  41. exit 0