blob: 9b2afb07624252240a84414d5277b4ac422b14e0 [file] [log] [blame]
Marco Stornelli11d0dbd2009-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
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020022# Generated executable files
23BIN_FILES-y += imls
24
25# Source files which exist outside the tools/imls directory
26EXT_OBJ_FILES-y += lib_generic/crc32.o
27EXT_OBJ_FILES-y += lib_generic/md5.o
28EXT_OBJ_FILES-y += lib_generic/sha1.o
29EXT_OBJ_FILES-y += common/image.o
30
31# Source files located in the tools/imls directory
32OBJ_FILES-y += imls.o
33
34# Flattened device tree objects
35LIBFDT_OBJ_FILES-y += fdt.o
36LIBFDT_OBJ_FILES-y += fdt_ro.o
37LIBFDT_OBJ_FILES-y += fdt_rw.o
38LIBFDT_OBJ_FILES-y += fdt_strerror.o
39LIBFDT_OBJ_FILES-y += fdt_wip.o
40
41# now $(obj) is defined
42SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
43SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
44SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
45BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
46LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
47
48#
Scott Wood16c91a12009-11-04 18:41:41 -060049# Compile for a hosted environment on the target
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020050# Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
51#
Scott Wood16c91a12009-11-04 18:41:41 -060052HOSTCPPFLAGS = -idirafter $(SRCTREE)/include \
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020053 -idirafter $(OBJTREE)/include2 \
54 -idirafter $(OBJTREE)/include \
55 -I $(SRCTREE)/libfdt \
56 -I $(SRCTREE)/tools \
57 -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020058
59ifeq ($(MTD_VERSION),old)
Scott Wood16c91a12009-11-04 18:41:41 -060060HOSTCPPFLAGS += -DMTD_OLD
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020061endif
62
63all: $(BINS)
64
65$(obj)imls: $(obj)imls.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \
66 $(obj)sha1.o $(LIBFDT_OBJS)
Scott Wood16c91a12009-11-04 18:41:41 -060067 $(CC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020068 $(STRIP) $@
69
70# Some files complain if compiled with -pedantic, use FIT_CFLAGS
71$(obj)image.o: $(SRCTREE)/common/image.c
Scott Wood16c91a12009-11-04 18:41:41 -060072 $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020073
Scott Wood16c91a12009-11-04 18:41:41 -060074$(obj)imls.o: $(SRCTREE)/tools/imls/imls.c
75 $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020076
77# Some of the tool objects need to be accessed from outside the tools/imls directory
78$(obj)%.o: $(SRCTREE)/common/%.c
Scott Wood16c91a12009-11-04 18:41:41 -060079 $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020080
81$(obj)%.o: $(SRCTREE)/lib_generic/%.c
Scott Wood16c91a12009-11-04 18:41:41 -060082 $(CC) -g $(HOSTCFLAGS) -c -o $@ $<
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020083
84$(obj)%.o: $(SRCTREE)/libfdt/%.c
Scott Wood16c91a12009-11-04 18:41:41 -060085 $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020086
87clean:
88 rm -rf *.o imls
89
90#########################################################################
91
92# defines $(obj).depend target
93include $(SRCTREE)/rules.mk
94
95sinclude $(obj).depend
96
97#########################################################################