Makefile 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #
  2. # (C) Copyright 2009 Marco Stornelli <marco.stornelli@gmail.com>
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License as
  6. # published by the Free Software Foundation; either version 2 of
  7. # the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  17. # MA 02111-1307 USA
  18. #
  19. include $(TOPDIR)/config.mk
  20. # Generated executable files
  21. BIN_FILES-y += imls
  22. # Source files which exist outside the tools/imls directory
  23. EXT_OBJ_FILES-y += lib_generic/crc32.o
  24. EXT_OBJ_FILES-y += lib_generic/md5.o
  25. EXT_OBJ_FILES-y += lib_generic/sha1.o
  26. EXT_OBJ_FILES-y += common/image.o
  27. # Source files located in the tools/imls directory
  28. OBJ_FILES-y += imls.o
  29. # Flattened device tree objects
  30. LIBFDT_OBJ_FILES-y += fdt.o
  31. LIBFDT_OBJ_FILES-y += fdt_ro.o
  32. LIBFDT_OBJ_FILES-y += fdt_rw.o
  33. LIBFDT_OBJ_FILES-y += fdt_strerror.o
  34. LIBFDT_OBJ_FILES-y += fdt_wip.o
  35. # now $(obj) is defined
  36. SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
  37. SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
  38. SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
  39. BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
  40. LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
  41. #
  42. # Compile for a hosted environment on the target
  43. # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
  44. #
  45. HOSTCPPFLAGS = -idirafter $(SRCTREE)/include \
  46. -idirafter $(OBJTREE)/include2 \
  47. -idirafter $(OBJTREE)/include \
  48. -I $(SRCTREE)/libfdt \
  49. -I $(SRCTREE)/tools \
  50. -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES
  51. ifeq ($(MTD_VERSION),old)
  52. HOSTCPPFLAGS += -DMTD_OLD
  53. endif
  54. all: $(BINS)
  55. $(obj)imls: $(obj)imls.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \
  56. $(obj)sha1.o $(LIBFDT_OBJS)
  57. $(CC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
  58. $(STRIP) $@
  59. # Some files complain if compiled with -pedantic, use FIT_CFLAGS
  60. $(obj)image.o: $(SRCTREE)/common/image.c
  61. $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
  62. $(obj)imls.o: $(SRCTREE)/tools/imls/imls.c
  63. $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
  64. # Some of the tool objects need to be accessed from outside the tools/imls directory
  65. $(obj)%.o: $(SRCTREE)/common/%.c
  66. $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
  67. $(obj)%.o: $(SRCTREE)/lib_generic/%.c
  68. $(CC) -g $(HOSTCFLAGS) -c -o $@ $<
  69. $(obj)%.o: $(SRCTREE)/libfdt/%.c
  70. $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
  71. clean:
  72. rm -rf *.o imls
  73. #########################################################################
  74. # defines $(obj).depend target
  75. include $(SRCTREE)/rules.mk
  76. sinclude $(obj).depend
  77. #########################################################################