Makefile 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. # Copyright (c) 2009 Openmoko Inc.
  2. #
  3. # Authors Daniel Mack <daniel@caiaq.de>
  4. # Holger Hans Peter Freyther <zecke@openmoko.org>
  5. # 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. # (de)activate profiling
  20. #PROFILER_ON = -DPROFILER_ON
  21. FATFS_MODE = read-write
  22. # +++START_UPDATE_MAKEFILE: Start of auto included code
  23. # The text between the +++ and --- tags is copied by the
  24. # UpdateMakefiles script. Do not remove or change these tags.
  25. # ---
  26. # Autodetect root directory
  27. define FIND_ROOT_DIR
  28. while : ; do \
  29. d=$$(pwd) ; \
  30. [ -d "$${d}/samo-lib" ] && echo $${d} && exit 0 ; \
  31. [ X"/" = X"$${d}" ] && echo ROOT_DIRECTORY_NOT_FOUND && exit 1 ; \
  32. cd .. ; \
  33. done
  34. endef
  35. ROOT_DIR := $(shell ${FIND_ROOT_DIR})
  36. # Directory of Makefile includes
  37. MK_DIR := ${ROOT_DIR}/samo-lib/Mk
  38. # Include the initial Makefile setup
  39. include ${MK_DIR}/definitions.mk
  40. # ---END_UPDATE_MAKEFILE: End of auto included code
  41. INCLUDES += -I$(MINI_LIBC_INCLUDE)
  42. INCLUDES += -I${DRIVERS_INCLUDE}
  43. INCLUDES += -I${FATFS_CONFIG_INCLUDE} -I${FATFS_INCLUDE}
  44. INCLUDES += -I${SAMO_LIB_INCLUDE}
  45. INCLUDES += -I$(LZMA_INCLUDE)
  46. INCLUDES += -I$(WIKI_APP_INCLUDE)
  47. LIBS += ${FATFS_LIB}
  48. LIBS += ${DRIVERS_LIB}
  49. LIBS += ${MINI_LIBC_LIB}
  50. LIBS += $(shell $(CC) -print-libgcc-file-name)
  51. BUILD_PREFIX := build/
  52. INCLUDES += -I$(BUILD_PREFIX)
  53. vpath %.c $(WIKI_APP_SRC):$(LZMA_SRC)
  54. vpath %.png $(WIKI_APP_SRC)
  55. GUILIB_COBJS = guilib.o
  56. GUILIB_COBJS += bmf.o
  57. GUILIB_COBJS += lcd_buf_draw.o
  58. GUILIB_COBJS += bigram.o
  59. GUILIB_COBJS += glyph.o
  60. GUILIB_COBJS += restricted.o
  61. GUILIB_COBJS += sha1.o
  62. GUILIB_COBJS += wiki_info.o
  63. WIKIAPP_COBJS = file-io-libfat.o
  64. WIKIAPP_COBJS += wikilib.o
  65. WIKIAPP_COBJS += malloc-simple.o
  66. WIKIAPP_COBJS += keyboard.o
  67. # used for panic in traps.c
  68. WIKIAPP_COBJS += hexdump.o
  69. WIKIAPP_COBJS += misc.o
  70. # searching
  71. WIKIAPP_COBJS += search.o
  72. WIKIAPP_COBJS += search_hash.o
  73. WIKIAPP_COBJS += history.o
  74. # lzma
  75. LZMA_COBJS = LzmaDec.o
  76. LZMA_COBJS += Alloc.o
  77. LZMA_COBJS += Bra.o
  78. LZMA_COBJS += LzFind.o
  79. # convert the image files
  80. IMAGES = keyboard_abc keyboard_abc2 keyboard_123 nls
  81. CFLAGS+=-DINCLUDED_FROM_KERNEL $(PROFILER_ON)
  82. LDFLAGS=-static --strip-all -s --no-gc-sections -N -L$(MINI_LIBC)
  83. OBJECTS = mahatma.o
  84. OBJECTS += touchscreen.o
  85. OBJECTS += msg-output.o
  86. OBJECTS += gui.o
  87. OBJECTS += gpio.o
  88. OBJECTS += serial.o
  89. OBJECTS += traps.o
  90. OBJECTS += input.o
  91. OBJECTS += profile.o
  92. OBJECTS += $(GUILIB_COBJS)
  93. OBJECTS += $(WIKIAPP_COBJS)
  94. OBJECTS += $(LZMA_COBJS)
  95. BUILD_OBJECTS = $(addprefix ${BUILD_PREFIX},${OBJECTS})
  96. ALL_IMAGES = $(addprefix ${BUILD_PREFIX},all_images.h)
  97. TARGETS = ${ALL_IMAGES}
  98. TARGETS += mahatma.elf
  99. .PHONY: all
  100. all: ${TARGETS}
  101. lib/libmahatma.a: lib build ${BUILD_OBJECTS}
  102. ${AR} r "$@" ${BUILD_OBJECTS}
  103. mahatma.elf: build build/mahatma.o lib/libmahatma.a mahatma.lds ${LIBS}
  104. $(LD) -o $@ ${LDFLAGS} build/mahatma.o lib/libmahatma.a ${LIBS} -T ${@:.elf=.lds} -Map ${@:.elf=.map}
  105. ${OBJDUMP} --section-headers "$@"
  106. ${OBJDUMP} -D "$@" > "${@:.elf=.dump}"
  107. IMAGE_HEADERS = $(addsuffix .h,$(addprefix ${BUILD_PREFIX},$(strip ${IMAGES})))
  108. CLEAN_FILES += ${IMAGE_HEADERS}
  109. ${ALL_IMAGES}: build ${IMAGE_HEADERS}
  110. @${RM} "$@"
  111. @for f in ${IMAGE_HEADERS}; \
  112. do \
  113. echo Keyboard: $$(basename "$${f}") ; \
  114. echo '#include "'$$(basename "$${f}")'"' >> "$@"; \
  115. done
  116. build:
  117. ${MKDIR} "$@"
  118. lib:
  119. ${MKDIR} "$@"
  120. .PHONY: install
  121. install: all
  122. @if [ ! -d "${DESTDIR}" ] ; then echo DESTDIR: "'"${DESTDIR}"'" is not a directory ; exit 1; fi
  123. ${COPY} mahatma.elf "${DESTDIR}"/kernel.elf
  124. .PHONY: clean
  125. clean:
  126. ${RM} ${TARGETS}
  127. ${RM} -r build lib
  128. ${RM} *.o *.elf *.d *.map *.asm33 *.dump
  129. ${RM} ${CLEAN_FILES}
  130. include ${MK_DIR}/rules.mk