Makefile 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # Makefile
  2. #
  3. # Copyright (c) 2009 Openmoko Inc.
  4. #
  5. # Authors Christopher Hall <hsw@openmoko.com>
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. # +++START_UPDATE_MAKEFILE: Start of auto included code
  20. # The text between the +++ and --- tags is copied by the
  21. # UpdateMakefiles script. Do not remove or change these tags.
  22. # ---
  23. # Autodetect root directory
  24. define FIND_ROOT_DIR
  25. while : ; do \
  26. d=$$(pwd) ; \
  27. [ -d "$${d}/samo-lib" ] && echo $${d} && exit 0 ; \
  28. [ X"/" = X"$${d}" ] && echo ROOT_DIRECTORY_NOT_FOUND && exit 1 ; \
  29. cd .. ; \
  30. done
  31. endef
  32. ROOT_DIR := $(shell ${FIND_ROOT_DIR})
  33. # Directory of Makefile includes
  34. MK_DIR := ${ROOT_DIR}/samo-lib/Mk
  35. # Include the initial Makefile setup
  36. include ${MK_DIR}/definitions.mk
  37. # ---END_UPDATE_MAKEFILE: End of auto included code
  38. INCLUDES += -I${SAMO_LIB_INCLUDE}
  39. INCLUDES += -I${GRIFO_INCLUDE}
  40. INCLUDES += -I${MINI_LIBC_INCLUDE}
  41. LIBS += lib/libexamples.a
  42. LIBS += ${GRIFO_LIB}
  43. LIBS += ${MINI_LIBC_LIB}
  44. LIBS += $(shell $(CC) -print-libgcc-file-name)
  45. BUILD_PREFIX := build/
  46. vpath %.c :src
  47. TARGETS = init.app
  48. # list of modules
  49. OBJECTS += init.o
  50. BUILD_OBJECTS = $(addprefix ${BUILD_PREFIX},${OBJECTS})
  51. .PHONY: all
  52. all: ${TARGETS}
  53. lib/libexamples.a: lib ${BUILD_OBJECTS}
  54. ${RM} "$@"
  55. ${AR} r "$@" ${BUILD_OBJECTS}
  56. init.app: build build/init.o ${GRIFO_APPLICATION_LDS} ${LIBS}
  57. $(LD) -o $@ ${LDFLAGS} build/init.o ${LIBS} -T ${GRIFO_APPLICATION_LDS} -Map ${@:.app=.map}
  58. ${OBJDUMP} -D "$@" > "${@:.app=.dump}"
  59. build:
  60. ${MKDIR} "$@"
  61. lib:
  62. ${MKDIR} "$@"
  63. .PHONY: install
  64. install: all
  65. @if [ ! -d "${DESTDIR}" ] ; then echo DESTDIR: "'"${DESTDIR}"'" is not a directory ; exit 1; fi
  66. ${COPY} ${TARGETS} "${DESTDIR}"/
  67. .PHONY: clean
  68. clean:
  69. ${RM} -r ${TARGETS} build lib
  70. ${RM} -r *.o *.app *.d *.map *.asm33 *.dump *.ico
  71. include ${MK_DIR}/rules.mk