Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 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 | |
| 20 | include $(TOPDIR)/config.mk |
| 21 | |
Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 22 | # Generated executable files |
| 23 | BIN_FILES-y += imls |
| 24 | |
| 25 | # Source files which exist outside the tools/imls directory |
Peter Tyser | 78acc47 | 2010-04-12 22:28:05 -0500 | [diff] [blame] | 26 | EXT_OBJ_FILES-y += lib/crc32.o |
| 27 | EXT_OBJ_FILES-y += lib/md5.o |
| 28 | EXT_OBJ_FILES-y += lib/sha1.o |
Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 29 | EXT_OBJ_FILES-y += common/image.o |
| 30 | |
| 31 | # Source files located in the tools/imls directory |
| 32 | OBJ_FILES-y += imls.o |
| 33 | |
| 34 | # Flattened device tree objects |
| 35 | LIBFDT_OBJ_FILES-y += fdt.o |
| 36 | LIBFDT_OBJ_FILES-y += fdt_ro.o |
| 37 | LIBFDT_OBJ_FILES-y += fdt_rw.o |
| 38 | LIBFDT_OBJ_FILES-y += fdt_strerror.o |
| 39 | LIBFDT_OBJ_FILES-y += fdt_wip.o |
| 40 | |
| 41 | # now $(obj) is defined |
| 42 | SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c)) |
| 43 | SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c)) |
Peter Tyser | 0de71d5 | 2010-04-12 22:28:06 -0500 | [diff] [blame] | 44 | SRCS += $(addprefix $(SRCTREE)/lib/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c)) |
Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 45 | BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y))) |
| 46 | LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y)) |
| 47 | |
| 48 | # |
Scott Wood | d984fed | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 49 | # Compile for a hosted environment on the target |
Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 50 | # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps |
| 51 | # |
Scott Wood | d984fed | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 52 | HOSTCPPFLAGS = -idirafter $(SRCTREE)/include \ |
Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 53 | -idirafter $(OBJTREE)/include2 \ |
| 54 | -idirafter $(OBJTREE)/include \ |
Peter Tyser | 0de71d5 | 2010-04-12 22:28:06 -0500 | [diff] [blame] | 55 | -I $(SRCTREE)/lib/libfdt \ |
Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 56 | -I $(SRCTREE)/tools \ |
| 57 | -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES |
Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 58 | |
| 59 | ifeq ($(MTD_VERSION),old) |
Scott Wood | d984fed | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 60 | HOSTCPPFLAGS += -DMTD_OLD |
Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 61 | endif |
| 62 | |
| 63 | all: $(BINS) |
| 64 | |
| 65 | $(obj)imls: $(obj)imls.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \ |
| 66 | $(obj)sha1.o $(LIBFDT_OBJS) |
Scott Wood | d984fed | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 67 | $(CC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ |
Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 68 | $(STRIP) $@ |
| 69 | |
Daniel Hobi | b75a2dd | 2010-10-11 18:03:35 +0200 | [diff] [blame^] | 70 | # Some files complain if compiled with -pedantic, use HOSTCFLAGS_NOPED |
Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 71 | $(obj)image.o: $(SRCTREE)/common/image.c |
Scott Wood | d984fed | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 72 | $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $< |
Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 73 | |
Scott Wood | d984fed | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 74 | $(obj)imls.o: $(SRCTREE)/tools/imls/imls.c |
| 75 | $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $< |
Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 76 | |
| 77 | # Some of the tool objects need to be accessed from outside the tools/imls directory |
| 78 | $(obj)%.o: $(SRCTREE)/common/%.c |
Scott Wood | d984fed | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 79 | $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $< |
Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 80 | |
Peter Tyser | 78acc47 | 2010-04-12 22:28:05 -0500 | [diff] [blame] | 81 | $(obj)%.o: $(SRCTREE)/lib/%.c |
Scott Wood | d984fed | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 82 | $(CC) -g $(HOSTCFLAGS) -c -o $@ $< |
Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 83 | |
Peter Tyser | 0de71d5 | 2010-04-12 22:28:06 -0500 | [diff] [blame] | 84 | $(obj)%.o: $(SRCTREE)/lib/libfdt/%.c |
Scott Wood | d984fed | 2009-11-04 18:41:41 -0600 | [diff] [blame] | 85 | $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $< |
Marco Stornelli | f578a2d | 2009-04-28 19:04:02 +0200 | [diff] [blame] | 86 | |
| 87 | clean: |
| 88 | rm -rf *.o imls |
| 89 | |
| 90 | ######################################################################### |
| 91 | |
| 92 | # defines $(obj).depend target |
| 93 | include $(SRCTREE)/rules.mk |
| 94 | |
| 95 | sinclude $(obj).depend |
| 96 | |
| 97 | ######################################################################### |