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 | |
| 22 | HOST_CFLAGS = -Wall -pedantic |
| 23 | |
| 24 | # Generated executable files |
| 25 | BIN_FILES-y += imls |
| 26 | |
| 27 | # Source files which exist outside the tools/imls directory |
| 28 | EXT_OBJ_FILES-y += lib_generic/crc32.o |
| 29 | EXT_OBJ_FILES-y += lib_generic/md5.o |
| 30 | EXT_OBJ_FILES-y += lib_generic/sha1.o |
| 31 | EXT_OBJ_FILES-y += common/image.o |
| 32 | |
| 33 | # Source files located in the tools/imls directory |
| 34 | OBJ_FILES-y += imls.o |
| 35 | |
| 36 | # Flattened device tree objects |
| 37 | LIBFDT_OBJ_FILES-y += fdt.o |
| 38 | LIBFDT_OBJ_FILES-y += fdt_ro.o |
| 39 | LIBFDT_OBJ_FILES-y += fdt_rw.o |
| 40 | LIBFDT_OBJ_FILES-y += fdt_strerror.o |
| 41 | LIBFDT_OBJ_FILES-y += fdt_wip.o |
| 42 | |
| 43 | # now $(obj) is defined |
| 44 | SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c)) |
| 45 | SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c)) |
| 46 | SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c)) |
| 47 | BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y))) |
| 48 | LIBFDT_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 | # |
| 54 | CPPFLAGS = -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 |
| 60 | CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O |
| 61 | |
| 62 | # No -pedantic switch to avoid libfdt compilation warnings |
| 63 | FIT_CFLAGS = -Wall $(CPPFLAGS) -O |
| 64 | |
| 65 | CC = $(CROSS_COMPILER)gcc |
| 66 | STRIP = $(CROSS_COMPILER)strip |
| 67 | |
| 68 | ifeq ($(MTD_VERSION),old) |
| 69 | CPPFLAGS += -DMTD_OLD |
| 70 | endif |
| 71 | |
| 72 | all: $(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 | |
| 96 | clean: |
| 97 | rm -rf *.o imls |
| 98 | |
| 99 | ######################################################################### |
| 100 | |
| 101 | # defines $(obj).depend target |
| 102 | include $(SRCTREE)/rules.mk |
| 103 | |
| 104 | sinclude $(obj).depend |
| 105 | |
| 106 | ######################################################################### |