Makefile 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. HOST_CFLAGS = -Wall -pedantic
  21. # Generated executable files
  22. BIN_FILES-y += imls
  23. # Source files which exist outside the tools/imls directory
  24. EXT_OBJ_FILES-y += lib_generic/crc32.o
  25. EXT_OBJ_FILES-y += lib_generic/md5.o
  26. EXT_OBJ_FILES-y += lib_generic/sha1.o
  27. EXT_OBJ_FILES-y += common/image.o
  28. # Source files located in the tools/imls directory
  29. OBJ_FILES-y += imls.o
  30. # Flattened device tree objects
  31. LIBFDT_OBJ_FILES-y += fdt.o
  32. LIBFDT_OBJ_FILES-y += fdt_ro.o
  33. LIBFDT_OBJ_FILES-y += fdt_rw.o
  34. LIBFDT_OBJ_FILES-y += fdt_strerror.o
  35. LIBFDT_OBJ_FILES-y += fdt_wip.o
  36. # now $(obj) is defined
  37. SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
  38. SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
  39. SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
  40. BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
  41. LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
  42. #
  43. # Use native tools and options
  44. # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
  45. #
  46. CPPFLAGS = -idirafter $(SRCTREE)/include \
  47. -idirafter $(OBJTREE)/include2 \
  48. -idirafter $(OBJTREE)/include \
  49. -I $(SRCTREE)/libfdt \
  50. -I $(SRCTREE)/tools \
  51. -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES
  52. CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
  53. # No -pedantic switch to avoid libfdt compilation warnings
  54. FIT_CFLAGS = -Wall $(CPPFLAGS) -O
  55. CC = $(CROSS_COMPILER)gcc
  56. STRIP = $(CROSS_COMPILER)strip
  57. ifeq ($(MTD_VERSION),old)
  58. CPPFLAGS += -DMTD_OLD
  59. endif
  60. all: $(BINS)
  61. $(obj)imls: $(obj)imls.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \
  62. $(obj)sha1.o $(LIBFDT_OBJS)
  63. $(CC) $(CFLAGS) -o $@ $^
  64. $(STRIP) $@
  65. # Some files complain if compiled with -pedantic, use FIT_CFLAGS
  66. $(obj)image.o: $(SRCTREE)/common/image.c
  67. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  68. $(obj)imls.o: imls.c
  69. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  70. # Some of the tool objects need to be accessed from outside the tools/imls directory
  71. $(obj)%.o: $(SRCTREE)/common/%.c
  72. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  73. $(obj)%.o: $(SRCTREE)/lib_generic/%.c
  74. $(CC) -g $(CFLAGS) -c -o $@ $<
  75. $(obj)%.o: $(SRCTREE)/libfdt/%.c
  76. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  77. clean:
  78. rm -rf *.o imls
  79. #########################################################################
  80. # defines $(obj).depend target
  81. include $(SRCTREE)/rules.mk
  82. sinclude $(obj).depend
  83. #########################################################################