blob: e371983275433f8a1cc155701dd8836c7aca96ca [file] [log] [blame]
Marco Stornelli11d0dbd2009-04-28 19:04:02 +02001#
2# (C) Copyright 2009 Marco Stornelli <marco.stornelli@gmail.com>
3#
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004# SPDX-License-Identifier: GPL-2.0+
Marco Stornelli11d0dbd2009-04-28 19:04:02 +02005#
6
7include $(TOPDIR)/config.mk
8
Marco Stornelli11d0dbd2009-04-28 19:04:02 +02009# Generated executable files
10BIN_FILES-y += imls
11
12# Source files which exist outside the tools/imls directory
Peter Tyser685b7f52010-04-12 22:28:05 -050013EXT_OBJ_FILES-y += lib/crc32.o
14EXT_OBJ_FILES-y += lib/md5.o
15EXT_OBJ_FILES-y += lib/sha1.o
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020016EXT_OBJ_FILES-y += common/image.o
17
18# Source files located in the tools/imls directory
19OBJ_FILES-y += imls.o
20
21# Flattened device tree objects
22LIBFDT_OBJ_FILES-y += fdt.o
23LIBFDT_OBJ_FILES-y += fdt_ro.o
24LIBFDT_OBJ_FILES-y += fdt_rw.o
25LIBFDT_OBJ_FILES-y += fdt_strerror.o
26LIBFDT_OBJ_FILES-y += fdt_wip.o
27
28# now $(obj) is defined
29SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
30SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
Peter Tyser8e7788f2010-04-12 22:28:06 -050031SRCS += $(addprefix $(SRCTREE)/lib/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020032BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
33LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
34
35#
Scott Wood16c91a12009-11-04 18:41:41 -060036# Compile for a hosted environment on the target
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020037# Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
38#
Scott Wood16c91a12009-11-04 18:41:41 -060039HOSTCPPFLAGS = -idirafter $(SRCTREE)/include \
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020040 -idirafter $(OBJTREE)/include2 \
41 -idirafter $(OBJTREE)/include \
Wolfgang Denkec7fbf52013-10-04 17:43:24 +020042 -I $(SRCTREE)/lib/libfdt \
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020043 -I $(SRCTREE)/tools \
44 -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020045
46ifeq ($(MTD_VERSION),old)
Scott Wood16c91a12009-11-04 18:41:41 -060047HOSTCPPFLAGS += -DMTD_OLD
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020048endif
49
50all: $(BINS)
51
52$(obj)imls: $(obj)imls.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \
53 $(obj)sha1.o $(LIBFDT_OBJS)
Scott Wood16c91a12009-11-04 18:41:41 -060054 $(CC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020055 $(STRIP) $@
56
Daniel Hobidff54fd2010-10-11 18:03:35 +020057# Some files complain if compiled with -pedantic, use HOSTCFLAGS_NOPED
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020058$(obj)image.o: $(SRCTREE)/common/image.c
Scott Wood16c91a12009-11-04 18:41:41 -060059 $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020060
Scott Wood16c91a12009-11-04 18:41:41 -060061$(obj)imls.o: $(SRCTREE)/tools/imls/imls.c
62 $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020063
64# Some of the tool objects need to be accessed from outside the tools/imls directory
65$(obj)%.o: $(SRCTREE)/common/%.c
Scott Wood16c91a12009-11-04 18:41:41 -060066 $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020067
Peter Tyser685b7f52010-04-12 22:28:05 -050068$(obj)%.o: $(SRCTREE)/lib/%.c
Scott Wood16c91a12009-11-04 18:41:41 -060069 $(CC) -g $(HOSTCFLAGS) -c -o $@ $<
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020070
Peter Tyser8e7788f2010-04-12 22:28:06 -050071$(obj)%.o: $(SRCTREE)/lib/libfdt/%.c
Scott Wood16c91a12009-11-04 18:41:41 -060072 $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
Marco Stornelli11d0dbd2009-04-28 19:04:02 +020073
74clean:
75 rm -rf *.o imls
76
77#########################################################################
78
79# defines $(obj).depend target
80include $(SRCTREE)/rules.mk
81
82sinclude $(obj).depend
83
84#########################################################################