Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 1 | # |
| 2 | # (C) Copyright 2009 Marco Stornelli <marco.stornelli@gmail.com> |
| 3 | # |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | # SPDX-License-Identifier: GPL-2.0+ |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 5 | # |
| 6 | |
| 7 | include $(TOPDIR)/config.mk |
| 8 | |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 9 | # Generated executable files |
| 10 | BIN_FILES-y += imls |
| 11 | |
| 12 | # Source files which exist outside the tools/imls directory |
Peter Tyser | 685b7f5 | 2010-04-12 22:28:05 -0500 | [diff] [blame] | 13 | EXT_OBJ_FILES-y += lib/crc32.o |
| 14 | EXT_OBJ_FILES-y += lib/md5.o |
| 15 | EXT_OBJ_FILES-y += lib/sha1.o |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 16 | EXT_OBJ_FILES-y += common/image.o |
| 17 | |
| 18 | # Source files located in the tools/imls directory |
| 19 | OBJ_FILES-y += imls.o |
| 20 | |
| 21 | # Flattened device tree objects |
| 22 | LIBFDT_OBJ_FILES-y += fdt.o |
| 23 | LIBFDT_OBJ_FILES-y += fdt_ro.o |
| 24 | LIBFDT_OBJ_FILES-y += fdt_rw.o |
| 25 | LIBFDT_OBJ_FILES-y += fdt_strerror.o |
| 26 | LIBFDT_OBJ_FILES-y += fdt_wip.o |
| 27 | |
| 28 | # now $(obj) is defined |
| 29 | SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c)) |
| 30 | SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c)) |
Peter Tyser | 8e7788f | 2010-04-12 22:28:06 -0500 | [diff] [blame] | 31 | SRCS += $(addprefix $(SRCTREE)/lib/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c)) |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 32 | BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y))) |
| 33 | LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y)) |
| 34 | |
| 35 | # |
Scott Wood | 16c91a1 | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 36 | # Compile for a hosted environment on the target |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 37 | # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps |
| 38 | # |
Scott Wood | 16c91a1 | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 39 | HOSTCPPFLAGS = -idirafter $(SRCTREE)/include \ |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 40 | -idirafter $(OBJTREE)/include2 \ |
| 41 | -idirafter $(OBJTREE)/include \ |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 42 | -I $(SRCTREE)/lib/libfdt \ |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 43 | -I $(SRCTREE)/tools \ |
| 44 | -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 45 | |
| 46 | ifeq ($(MTD_VERSION),old) |
Scott Wood | 16c91a1 | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 47 | HOSTCPPFLAGS += -DMTD_OLD |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 48 | endif |
| 49 | |
| 50 | all: $(BINS) |
| 51 | |
| 52 | $(obj)imls: $(obj)imls.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \ |
| 53 | $(obj)sha1.o $(LIBFDT_OBJS) |
Scott Wood | 16c91a1 | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 54 | $(CC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 55 | $(STRIP) $@ |
| 56 | |
Daniel Hobi | dff54fd | 2010-10-11 18:03:35 +0200 | [diff] [blame] | 57 | # Some files complain if compiled with -pedantic, use HOSTCFLAGS_NOPED |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 58 | $(obj)image.o: $(SRCTREE)/common/image.c |
Scott Wood | 16c91a1 | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 59 | $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $< |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 60 | |
Scott Wood | 16c91a1 | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 61 | $(obj)imls.o: $(SRCTREE)/tools/imls/imls.c |
| 62 | $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $< |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 63 | |
| 64 | # Some of the tool objects need to be accessed from outside the tools/imls directory |
| 65 | $(obj)%.o: $(SRCTREE)/common/%.c |
Scott Wood | 16c91a1 | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 66 | $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $< |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 67 | |
Peter Tyser | 685b7f5 | 2010-04-12 22:28:05 -0500 | [diff] [blame] | 68 | $(obj)%.o: $(SRCTREE)/lib/%.c |
Scott Wood | 16c91a1 | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 69 | $(CC) -g $(HOSTCFLAGS) -c -o $@ $< |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 70 | |
Peter Tyser | 8e7788f | 2010-04-12 22:28:06 -0500 | [diff] [blame] | 71 | $(obj)%.o: $(SRCTREE)/lib/libfdt/%.c |
Scott Wood | 16c91a1 | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 72 | $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $< |
Marco Stornelli | 11d0dbd | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 73 | |
| 74 | clean: |
| 75 | rm -rf *.o imls |
| 76 | |
| 77 | ######################################################################### |
| 78 | |
| 79 | # defines $(obj).depend target |
| 80 | include $(SRCTREE)/rules.mk |
| 81 | |
| 82 | sinclude $(obj).depend |
| 83 | |
| 84 | ######################################################################### |