mach 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #/bin/bash
  2. set -x #echo on
  3. # == | Setup | ========================================================================================================
  4. # XXXTobin: Make this read in from a seperate config file
  5. OBJECT_DIRECTORY=".obj"
  6. FINAL_TARGET="dist/bin"
  7. APP_BIN_NAME="basic-c-program"
  8. # XXXTobin: Make this a bash array when more than one source is added
  9. C_SOURCES="../nsMain.c"
  10. # ---------------------------------------------------------------------------------------------------------------------
  11. if [[ -z "$1" ]]; then
  12. printf "${0} Usage: clobber | build | run"
  13. exit 1
  14. fi
  15. # =====================================================================================================================
  16. # == | Functions | ====================================================================================================
  17. # XXXTobin: Quote paths when that starts to matter.
  18. xmach_cmd_clobber() {
  19. rm -vrf $OBJECT_DIRECTORY
  20. }
  21. xmach_cmd_configure() {
  22. rm -rf $OBJECT_DIRECTORY/$FINAL_TARGET
  23. mkdir -pv $OBJECT_DIRECTORY/$FINAL_TARGET
  24. }
  25. xmach_cmd_build() {
  26. xmach_cmd_configure
  27. cd $OBJECT_DIRECTORY
  28. gcc -v $C_SOURCES -o $FINAL_TARGET/$APP_BIN_NAME
  29. }
  30. xmach_cmd_run() {
  31. exec $OBJECT_DIRECTORY/$FINAL_TARGET/$APP_BIN_NAME
  32. }
  33. # =====================================================================================================================
  34. # == | Main | =========================================================================================================
  35. "xmach_cmd_${@:1}"
  36. exit 0
  37. # =====================================================================================================================