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