Makefile 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # Copyright (c) 2009 Openmoko Inc.
  2. #
  3. # This program is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. # +++START_UPDATE_MAKEFILE: Start of auto included code
  16. # The text between the +++ and --- tags is copied by the
  17. # UpdateMakefiles script. Do not remove or change these tags.
  18. # ---
  19. # Autodetect root directory
  20. define FIND_ROOT_DIR
  21. while : ; do \
  22. d=$$(pwd) ; \
  23. [ -d "$${d}/samo-lib" ] && echo $${d} && exit 0 ; \
  24. [ X"/" = X"$${d}" ] && echo ROOT_DIRECTORY_NOT_FOUND && exit 1 ; \
  25. cd .. ; \
  26. done
  27. endef
  28. ROOT_DIR := $(shell ${FIND_ROOT_DIR})
  29. # Directory of Makefile includes
  30. MK_DIR := ${ROOT_DIR}/samo-lib/Mk
  31. # Include the initial Makefile setup
  32. include ${MK_DIR}/definitions.mk
  33. # ---END_UPDATE_MAKEFILE: End of auto included code
  34. LDFLAGS = -static --strip-all -s --no-gc-sections -N -L${MINI_LIBC}
  35. OBJCOPY_FLAGS = -I elf32-c33 -O binary
  36. CFLAGS += -I${SAMO_LIB_INCLUDE} -I${MINI_LIBC_INCLUDE}
  37. TARGETS = jackknife jakebrake
  38. all: $(TARGETS)
  39. jackknife.elf: jackknife.o
  40. $(GCC) -o $@ $(LDFLAGS) $< -Wl,'-Ttext=0'
  41. jakebrake.elf: jakebrake.o
  42. $(GCC) -o $@ $(LDFLAGS) -DPROGRAM_TEST_JIG=1 $< -Wl,'-Ttext=0'
  43. jackknife: jackknife.elf
  44. $(OBJCOPY) $(OBJCOPY_FLAGS) --only-section=.text --set-start=0 $< $@
  45. @c=$$(wc --bytes < "$@") ; \
  46. echo mbr size = $${c} bytes, max = 512 bytes ; \
  47. if [ "$${c}" -gt 512 ]; then $(RM) "$@"; exit 99; fi
  48. jakebrake: jakebrake.elf
  49. $(OBJCOPY) $(OBJCOPY_FLAGS) --only-section=.text --set-start=0 $< $@
  50. @c=$$(wc --bytes < "$@") ; \
  51. echo mbr size = $${c} bytes, max = 512 bytes ; \
  52. if [ "$${c}" -gt 512 ]; then $(RM) "$@"; exit 99; fi
  53. clean:
  54. rm -fr $(TARGETS) *.o *.elf *.bin *.d *.p *.asm33
  55. include ${MK_DIR}/rules.mk