Makefile 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. FATFS_MODE = read-write
  20. # +++START_UPDATE_MAKEFILE: Start of auto included code
  21. # The text between the +++ and --- tags is copied by the
  22. # UpdateMakefiles script. Do not remove or change these tags.
  23. # ---
  24. # Autodetect root directory
  25. define FIND_ROOT_DIR
  26. while : ; do \
  27. d=$$(pwd) ; \
  28. [ -d "$${d}/samo-lib" ] && echo $${d} && exit 0 ; \
  29. [ X"/" = X"$${d}" ] && echo ROOT_DIRECTORY_NOT_FOUND && exit 1 ; \
  30. cd .. ; \
  31. done
  32. endef
  33. ROOT_DIR := $(shell ${FIND_ROOT_DIR})
  34. # Directory of Makefile includes
  35. MK_DIR := ${ROOT_DIR}/samo-lib/Mk
  36. # Include the initial Makefile setup
  37. include ${MK_DIR}/definitions.mk
  38. # ---END_UPDATE_MAKEFILE: End of auto included code
  39. $(call REQUIRED_BINARY, guile, guile-1.8)
  40. INCLUDES += -Isrc
  41. INCLUDES += -I-
  42. INCLUDES += -I${SAMO_LIB_INCLUDE}
  43. INCLUDES += -I${FATFS_INCLUDE} -I${FATFS_CONFIG_INCLUDE}
  44. INCLUDES += -I${DRIVERS_INCLUDE}
  45. INCLUDES += -I${MINI_LIBC_INCLUDE}
  46. INCLUDES += -Ibuild
  47. LIBS += build/libinternal.a
  48. LIBS += ${FATFS_LIB}
  49. LIBS += ${MINI_LIBC_LIB}
  50. LIBS += ${DRIVERS_LIB}
  51. LIBS += $(shell $(CC) -print-libgcc-file-name)
  52. BUILD_PREFIX := build/
  53. MAKE_SYSCALL := scripts/MakeSystemCalls
  54. vpath %.c :src
  55. TARGETS = build/syscall.table
  56. TARGETS += build/libinternal.a
  57. TARGETS += grifo.elf
  58. TARGETS += lib/libgrifo.a
  59. # list of modules for creating libinternal.a
  60. OBJECTS += analog.o
  61. OBJECTS += button.o
  62. OBJECTS += CMU.o
  63. OBJECTS += CTP.o
  64. OBJECTS += delay.o
  65. OBJECTS += elf32.o
  66. OBJECTS += event.o
  67. OBJECTS += file.o
  68. OBJECTS += LCD.o
  69. OBJECTS += main.o
  70. OBJECTS += memory.o
  71. OBJECTS += serial.o
  72. OBJECTS += suspend.o
  73. OBJECTS += syscall.o
  74. OBJECTS += system.o
  75. OBJECTS += timer.o
  76. OBJECTS += vector.o
  77. OBJECTS += watchdog.o
  78. #OBJECTS +=
  79. BUILD_OBJECTS = $(addprefix ${BUILD_PREFIX},${OBJECTS})
  80. .PHONY: all
  81. all: ${TARGETS}
  82. ${MAKE} -C examples
  83. build/libinternal.a: stamp-build ${BUILD_OBJECTS}
  84. ${RM} "$@"
  85. ${AR} r "$@" ${BUILD_OBJECTS}
  86. include/grifo.h stubs/stamp-source build/syscall.table: stamp-include stamp-build stamp-stubs src/syscall.list ${MAKE_SYSCALL} src/*.h
  87. ${MAKE_SYSCALL} --prefix=stubs/ \
  88. --header=include/grifo.h \
  89. --list=src/syscall.list \
  90. --table=build/syscall.table \
  91. --verbose
  92. ${TOUCH} stubs/stamp-source
  93. stubs/stamp-objects: $(addsuffix .o, $(basename $(wildcard stubs/*.s)))
  94. ${TOUCH} "$@"
  95. stubs/stamp: stamp-stubs
  96. ${MAKE} stubs/stamp-objects
  97. ${TOUCH} "$@"
  98. # this should depend on lib, but make always rebuilds in that case; why?
  99. lib/libgrifo.a: stamp-lib stubs/stamp stubs/stamp-source
  100. ${RM} "$@"
  101. ${AR} r "$@" stubs/*.o
  102. ${TOUCH} "$@"
  103. grifo.elf: build/main.o lds/grifo.lds ${LIBS}
  104. $(LD) -o $@ ${LDFLAGS} build/main.o ${LIBS} -T lds/${@:.elf=.lds} -Map ${@:.elf=.map}
  105. ${STRIP} --strip-unneeded --strip-debug \
  106. --remove-section=.internal --remove-section=.lcd \
  107. --remove-section=.user_area --remove-section=.descriptor "$@"
  108. ${OBJDUMP} --section-headers "$@"
  109. ${OBJDUMP} -D "$@" > "${@:.elf=.dump}"
  110. stamp-build:
  111. ${MKDIR} "${@:stamp-%=%}"
  112. ${TOUCH} "$@"
  113. stamp-lib:
  114. ${MKDIR} "${@:stamp-%=%}"
  115. ${TOUCH} "$@"
  116. stamp-stubs:
  117. ${MKDIR} "${@:stamp-%=%}"
  118. ${TOUCH} "$@"
  119. stamp-include:
  120. ${MKDIR} "${@:stamp-%=%}"
  121. ${TOUCH} "$@"
  122. .PHONY: install
  123. install: all
  124. @if [ ! -d "${DESTDIR}" ] ; then echo DESTDIR: "'"${DESTDIR}"'" is not a directory ; exit 1; fi
  125. ${COPY} grifo.elf "${DESTDIR}"/kernel.elf
  126. ${COPY} init.ini "${DESTDIR}"/
  127. ${MAKE} -C examples install
  128. .PHONY: clean
  129. clean:
  130. ${RM} -r ${TARGETS} build include lib stubs
  131. ${RM} -r *.o *.elf *.d *.map *.asm33 *.dump *.ico stamp-*
  132. ${MAKE} -C examples clean
  133. include ${MK_DIR}/rules.mk