Makefile 2.6 KB

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