3 # YAFFS: Yet another FFS. A NAND-flash specific file system.
5 # Copyright (C) 2002-2010 Aleph One Ltd.
7 # Created by Charles Manning <charles@aleph1.co.uk>
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2 as
11 # published by the Free Software Foundation.
13 # Patch yaffs2 into u-boot
16 # u-boot-path : Full path to u-boot sources to be patched
18 # Inspired yaffs kernel patching script
24 # Display usage of this script
26 echo "usage: $0 u-boot-path"
31 echo "$1 does not seem to be a u-boot directory"
42 # Check it has a Makefile, common and fs sub-directories
44 if [ ! -f "$UBOOTDIR/Makefile" ]
49 if [ ! -d "$UBOOTDIR/common" ]
54 if [ ! -d "$UBOOTDIR/fs" ]
60 YAFFS_IN_MAKEFILE=`grep -s libyaffs2 <$UBOOTDIR/Makefile | head -n 1`
61 YAFFS_IN_COMMON=`grep -s yaffs2 <$UBOOTDIR/common/Makefile | head -n 1`
62 LIB_A=`grep -s libnet\.a <$UBOOTDIR/Makefile | head -n 1`
71 # Patch Makefile if it does not mention yaffs2
72 if [ ! -z "$YAFFS_IN_MAKEFILE" ]
74 echo "$UBOOTDIR/Makefile already makes yaffs library"
77 mv -f $UBOOTDIR/Makefile $UBOOTDIR/Makefile.old
78 sed -n -e "/libnet/,99999 ! p" < $UBOOTDIR/Makefile.old > $UBOOTDIR/Makefile
79 echo "LIBS += fs/yaffs2/libyaffs2.$A_OR_O" >> $UBOOTDIR/Makefile
80 sed -n -e "/libnet/,99999 p" < $UBOOTDIR/Makefile.old >> $UBOOTDIR/Makefile
83 # Patch common/Makefile if it does not mention yaffs2
84 if [ ! -z "$YAFFS_IN_COMMON" ]
86 echo "$UBOOTDIR/common/Makefile already makes yaffs commands"
89 mv -f $UBOOTDIR/common/Makefile $UBOOTDIR/common/Makefile.old
90 sed -n -e "/cmd_jffs/,99999 ! p" <$UBOOTDIR/common/Makefile.old > $UBOOTDIR/common/Makefile
91 echo "COBJS-\$(CONFIG_YAFFS2) += cmd_yaffs2.o" >> $UBOOTDIR/common/Makefile
92 sed -n -e "/cmd_jffs/,99999 p" <$UBOOTDIR/common/Makefile.old >> $UBOOTDIR/common/Makefile
97 # Ensure the direct code is up to date
102 ./handle_common.sh copy
106 # Copy in the files we need
109 cp common/* $UBOOTDIR/common/
111 mkdir -p $UBOOTDIR/fs/yaffs2
112 cp ../*.[ch] $UBOOTDIR/fs/yaffs2/
113 cp fs/yaffs2/*.[ch] $UBOOTDIR/fs/yaffs2/
115 sed -e "s/A_OR_O/$A_OR_O/" < fs/yaffs2/Makefile > $UBOOTDIR/fs/yaffs2/Makefile