Re-add Android makefiles from AOSP master

Change-Id: I6c6dbe11baa395442f4cf845ad39801f1c426129
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..5053e7d
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1 @@
+include $(call all-subdir-makefiles)
diff --git a/CleanSpec.mk b/CleanSpec.mk
new file mode 100644
index 0000000..b84e1b6
--- /dev/null
+++ b/CleanSpec.mk
@@ -0,0 +1,49 @@
+# Copyright (C) 2007 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list.  These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+#     $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+#     $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list.  E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
diff --git a/e2fsck/Android.mk b/e2fsck/Android.mk
new file mode 100644
index 0000000..4c0ff42
--- /dev/null
+++ b/e2fsck/Android.mk
@@ -0,0 +1,159 @@
+LOCAL_PATH := $(call my-dir)
+
+#########################
+# Build the libext2 profile library
+
+libext2_profile_src_files :=  \
+	prof_err.c \
+	profile.c
+
+libext2_profile_shared_libraries := \
+	libext2_com_err
+
+libext2_profile_system_shared_libraries := libc
+
+libext2_profile_c_includes := external/e2fsprogs/lib
+
+libext2_profile_cflags := -O2 -g -W -Wall \
+	-DHAVE_UNISTD_H \
+	-DHAVE_ERRNO_H \
+	-DHAVE_NETINET_IN_H \
+	-DHAVE_SYS_IOCTL_H \
+	-DHAVE_SYS_MMAN_H \
+	-DHAVE_SYS_MOUNT_H \
+	-DHAVE_SYS_PRCTL_H \
+	-DHAVE_SYS_RESOURCE_H \
+	-DHAVE_SYS_SELECT_H \
+	-DHAVE_SYS_STAT_H \
+	-DHAVE_SYS_TYPES_H \
+	-DHAVE_STDLIB_H \
+	-DHAVE_STRDUP \
+	-DHAVE_MMAP \
+	-DHAVE_UTIME_H \
+	-DHAVE_GETPAGESIZE \
+	-DHAVE_LSEEK64 \
+	-DHAVE_LSEEK64_PROTOTYPE \
+	-DHAVE_EXT2_IOCTLS \
+	-DHAVE_LINUX_FD_H \
+	-DHAVE_TYPE_SSIZE_T \
+	-DHAVE_SYS_TIME_H \
+        -DHAVE_SYS_PARAM_H \
+	-DHAVE_SYSCONF
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2_profile_src_files)
+LOCAL_SYSTEM_SHARED_LIBRARIES := $(libext2_profile_system_shared_libraries)
+LOCAL_SHARED_LIBRARIES := $(libext2_profile_shared_libraries)
+LOCAL_C_INCLUDES := $(libext2_profile_c_includes)
+LOCAL_CFLAGS := $(libext2_profile_cflags)
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libext2_profile
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2_profile_src_files)
+LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(libext2_profile_shared_libraries))
+LOCAL_C_INCLUDES := $(libext2_profile_c_includes)
+LOCAL_CFLAGS := $(libext2_profile_cflags)
+LOCAL_MODULE := libext2_profile_host
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_SHARED_LIBRARY)
+
+#########################
+# Build the e2fsck binary
+
+e2fsck_src_files :=  \
+	crc32.c \
+	e2fsck.c \
+	dict.c \
+	super.c \
+	pass1.c \
+	pass1b.c \
+	pass2.c \
+	pass3.c \
+	pass4.c \
+	pass5.c \
+	journal.c \
+	recovery.c \
+	revoke.c \
+	badblocks.c \
+	util.c \
+	unix.c \
+	dirinfo.c \
+	dx_dirinfo.c \
+	ehandler.c \
+	problem.c \
+	message.c \
+	ea_refcount.c \
+	rehash.c \
+	region.c
+
+e2fsck_shared_libraries := \
+	libext2fs \
+	libext2_blkid \
+	libext2_uuid \
+	libext2_profile \
+	libext2_com_err \
+	libext2_e2p
+e2fsck_system_shared_libraries := libc
+
+e2fsck_c_includes := external/e2fsprogs/lib
+
+e2fsck_cflags := -O2 -g -W -Wall -fno-strict-aliasing \
+	-DHAVE_DIRENT_H \
+	-DHAVE_ERRNO_H \
+	-DHAVE_INTTYPES_H \
+	-DHAVE_LINUX_FD_H \
+	-DHAVE_NETINET_IN_H \
+	-DHAVE_SETJMP_H \
+	-DHAVE_SYS_IOCTL_H \
+	-DHAVE_SYS_MMAN_H \
+	-DHAVE_SYS_MOUNT_H \
+	-DHAVE_SYS_PRCTL_H \
+	-DHAVE_SYS_RESOURCE_H \
+	-DHAVE_SYS_SELECT_H \
+	-DHAVE_SYS_STAT_H \
+	-DHAVE_SYS_TYPES_H \
+	-DHAVE_STDLIB_H \
+	-DHAVE_UNISTD_H \
+	-DHAVE_UTIME_H \
+	-DHAVE_STRDUP \
+	-DHAVE_MMAP \
+	-DHAVE_GETPAGESIZE \
+	-DHAVE_LSEEK64 \
+	-DHAVE_LSEEK64_PROTOTYPE \
+	-DHAVE_EXT2_IOCTLS \
+	-DHAVE_TYPE_SSIZE_T \
+	-DHAVE_INTPTR_T \
+	-DENABLE_HTREE=1 \
+	-DHAVE_SYS_TIME_H \
+        -DHAVE_SYS_PARAM_H \
+	-DHAVE_SYSCONF
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(e2fsck_src_files)
+LOCAL_C_INCLUDES := $(e2fsck_c_includes)
+LOCAL_CFLAGS := $(e2fsck_cflags)
+LOCAL_SYSTEM_SHARED_LIBRARIES := $(e2fsck_system_shared_libraries)
+LOCAL_SHARED_LIBRARIES := $(e2fsck_shared_libraries)
+LOCAL_MODULE := e2fsck
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(e2fsck_src_files)
+LOCAL_C_INCLUDES := $(e2fsck_c_includes)
+LOCAL_CFLAGS := $(e2fsck_cflags)
+LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(e2fsck_shared_libraries))
+LOCAL_MODULE := e2fsck_host
+LOCAL_MODULE_STEM := e2fsck
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_EXECUTABLE)
diff --git a/lib/Android.mk b/lib/Android.mk
new file mode 100644
index 0000000..5053e7d
--- /dev/null
+++ b/lib/Android.mk
@@ -0,0 +1 @@
+include $(call all-subdir-makefiles)
diff --git a/lib/blkid/Android.mk b/lib/blkid/Android.mk
new file mode 100644
index 0000000..92ef776
--- /dev/null
+++ b/lib/blkid/Android.mk
@@ -0,0 +1,78 @@
+LOCAL_PATH := $(call my-dir)
+
+libext2_blkid_src_files := \
+	cache.c \
+	dev.c \
+	devname.c \
+	devno.c \
+	getsize.c \
+	llseek.c \
+	probe.c \
+	read.c \
+	resolve.c \
+	save.c \
+	tag.c \
+	version.c \
+
+
+libext2_blkid_shared_libraries := libext2_uuid
+
+libext2_blkid_system_shared_libraries := libc
+
+libext2_blkid_c_includes := external/e2fsprogs/lib
+
+libext2_blkid_cflags := -O2 -g -W -Wall -fno-strict-aliasing \
+	-DHAVE_UNISTD_H \
+	-DHAVE_ERRNO_H \
+	-DHAVE_NETINET_IN_H \
+	-DHAVE_SYS_IOCTL_H \
+	-DHAVE_SYS_MMAN_H \
+	-DHAVE_SYS_MOUNT_H \
+	-DHAVE_SYS_RESOURCE_H \
+	-DHAVE_SYS_SELECT_H \
+	-DHAVE_SYS_STAT_H \
+	-DHAVE_SYS_TYPES_H \
+	-DHAVE_STDLIB_H \
+	-DHAVE_STRDUP \
+	-DHAVE_MMAP \
+	-DHAVE_UTIME_H \
+	-DHAVE_GETPAGESIZE \
+	-DHAVE_EXT2_IOCTLS \
+	-DHAVE_TYPE_SSIZE_T \
+	-DHAVE_SYS_TIME_H \
+        -DHAVE_SYS_PARAM_H \
+	-DHAVE_SYSCONF
+
+libext2_blkid_cflags_linux := \
+	-DHAVE_LINUX_FD_H \
+	-DHAVE_SYS_PRCTL_H \
+	-DHAVE_LSEEK64 \
+	-DHAVE_LSEEK64_PROTOTYPE
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2_blkid_src_files)
+LOCAL_SYSTEM_SHARED_LIBRARIES := $(libext2_blkid_system_shared_libraries)
+LOCAL_SHARED_LIBRARIES := $(libext2_blkid_shared_libraries)
+LOCAL_C_INCLUDES := $(libext2_blkid_c_includes)
+LOCAL_CFLAGS := $(libext2_blkid_cflags) $(libext2_blkid_cflags_linux) -fno-strict-aliasing
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libext2_blkid
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2_blkid_src_files)
+LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(libext2_blkid_shared_libraries))
+LOCAL_C_INCLUDES := $(libext2_blkid_c_includes)
+ifeq ($(HOST_OS),linux)
+LOCAL_CFLAGS := $(libext2_blkid_cflags) $(libext2_blkid_cflags_linux)
+else
+LOCAL_CFLAGS := $(libext2_blkid_cflags)
+endif
+LOCAL_MODULE := libext2_blkid_host
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_SHARED_LIBRARY)
diff --git a/lib/e2p/Android.mk b/lib/e2p/Android.mk
new file mode 100644
index 0000000..7358449
--- /dev/null
+++ b/lib/e2p/Android.mk
@@ -0,0 +1,75 @@
+LOCAL_PATH := $(call my-dir)
+
+libext2_e2p_src_files := \
+	feature.c \
+	fgetflags.c \
+	fsetflags.c \
+	fgetversion.c \
+	fsetversion.c \
+	getflags.c \
+	getversion.c \
+	hashstr.c \
+	iod.c \
+	ls.c \
+	mntopts.c \
+	parse_num.c \
+	pe.c \
+	pf.c \
+	ps.c \
+	setflags.c \
+	setversion.c \
+	uuid.c \
+	ostype.c \
+	percent.c
+
+libext2_e2p_c_includes := external/e2fsprogs/lib
+
+libext2_e2p_cflags := -O2 -g -W -Wall \
+	-DHAVE_UNISTD_H \
+	-DHAVE_ERRNO_H \
+	-DHAVE_NETINET_IN_H \
+	-DHAVE_SYS_IOCTL_H \
+	-DHAVE_SYS_MMAN_H \
+	-DHAVE_SYS_MOUNT_H \
+	-DHAVE_SYS_PRCTL_H \
+	-DHAVE_SYS_RESOURCE_H \
+	-DHAVE_SYS_SELECT_H \
+	-DHAVE_SYS_STAT_H \
+	-DHAVE_SYS_TYPES_H \
+	-DHAVE_STDLIB_H \
+	-DHAVE_STRDUP \
+	-DHAVE_MMAP \
+	-DHAVE_UTIME_H \
+	-DHAVE_GETPAGESIZE \
+	-DHAVE_LSEEK64 \
+	-DHAVE_LSEEK64_PROTOTYPE \
+	-DHAVE_EXT2_IOCTLS \
+	-DHAVE_LINUX_FD_H \
+	-DHAVE_TYPE_SSIZE_T \
+	-DHAVE_SYS_TIME_H \
+        -DHAVE_SYS_PARAM_H \
+	-DHAVE_SYSCONF
+
+libext2_e2p_system_shared_libraries := libc
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2_e2p_src_files)
+LOCAL_C_INCLUDES := $(libext2_e2p_c_includes)
+LOCAL_CFLAGS := $(libext2_e2p_cflags)
+LOCAL_SYSTEM_SHARED_LIBRARIES := $(libext2_e2p_system_shared_libraries)
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libext2_e2p
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2_e2p_src_files)
+LOCAL_C_INCLUDES := $(libext2_e2p_c_includes)
+LOCAL_CFLAGS := $(libext2_e2p_cflags)
+LOCAL_MODULE := libext2_e2p_host
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_SHARED_LIBRARY)
diff --git a/lib/et/Android.mk b/lib/et/Android.mk
new file mode 100644
index 0000000..9d6757a
--- /dev/null
+++ b/lib/et/Android.mk
@@ -0,0 +1,66 @@
+LOCAL_PATH := $(call my-dir)
+
+libext2_com_err_src_files := \
+	error_message.c \
+	et_name.c \
+	init_et.c \
+	com_err.c \
+	com_right.c
+
+libext2_com_err_c_includes := external/e2fsprogs/lib
+
+libext2_com_err_cflags := -O2 -g -W -Wall \
+	-DHAVE_UNISTD_H \
+	-DHAVE_ERRNO_H \
+	-DHAVE_NETINET_IN_H \
+	-DHAVE_SYS_IOCTL_H \
+	-DHAVE_SYS_MMAN_H \
+	-DHAVE_SYS_MOUNT_H \
+	-DHAVE_SYS_RESOURCE_H \
+	-DHAVE_SYS_SELECT_H \
+	-DHAVE_SYS_STAT_H \
+	-DHAVE_SYS_TYPES_H \
+	-DHAVE_STDLIB_H \
+	-DHAVE_STRDUP \
+	-DHAVE_MMAP \
+	-DHAVE_UTIME_H \
+	-DHAVE_GETPAGESIZE \
+	-DHAVE_EXT2_IOCTLS \
+	-DHAVE_TYPE_SSIZE_T \
+	-DHAVE_SYS_TIME_H \
+        -DHAVE_SYS_PARAM_H \
+	-DHAVE_SYSCONF
+
+libext2_com_err_cflags_linux := \
+	-DHAVE_LINUX_FD_H \
+	-DHAVE_SYS_PRCTL_H \
+	-DHAVE_LSEEK64 \
+	-DHAVE_LSEEK64_PROTOTYPE
+
+libext2_com_err_system_shared_libraries := libc
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2_com_err_src_files)
+LOCAL_C_INCLUDES := $(libext2_com_err_c_includes)
+LOCAL_CFLAGS := $(libext2_com_err_cflags) $(libext2_com_err_cflags_linux)
+LOCAL_SYSTEM_SHARED_LIBRARIES := libc
+LOCAL_MODULE := libext2_com_err
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2_com_err_src_files)
+LOCAL_C_INCLUDES := $(libext2_com_err_c_includes)
+ifeq ($(HOST_OS),linux)
+LOCAL_CFLAGS := $(libext2_com_err_cflags) $(libext2_com_err_cflags_linux)
+else
+LOCAL_CFLAGS := $(libext2_com_err_cflags)
+endif
+LOCAL_MODULE := libext2_com_err_host
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_SHARED_LIBRARY)
diff --git a/lib/ext2fs/Android.mk b/lib/ext2fs/Android.mk
new file mode 100644
index 0000000..c34efd3
--- /dev/null
+++ b/lib/ext2fs/Android.mk
@@ -0,0 +1,130 @@
+LOCAL_PATH := $(call my-dir)
+
+libext2fs_src_files := \
+	ext2_err.c \
+	alloc.c \
+	alloc_sb.c \
+	alloc_stats.c \
+	alloc_tables.c \
+	badblocks.c \
+	bb_inode.c \
+	bitmaps.c \
+	bitops.c \
+	block.c \
+	bmap.c \
+	check_desc.c \
+	crc16.c \
+	csum.c \
+	closefs.c \
+	dblist.c \
+	dblist_dir.c \
+	dirblock.c \
+	dirhash.c \
+	dir_iterate.c \
+	dupfs.c \
+	expanddir.c \
+	ext_attr.c \
+	extent.c \
+	finddev.c \
+	flushb.c \
+	freefs.c \
+	gen_bitmap.c \
+	get_pathname.c \
+	getsize.c \
+	getsectsize.c \
+	i_block.c \
+	icount.c \
+	ind_block.c \
+	initialize.c \
+	inline.c \
+	inode.c \
+	io_manager.c \
+	ismounted.c \
+	link.c \
+	llseek.c \
+	lookup.c \
+	mkdir.c \
+	mkjournal.c \
+	native.c \
+	newdir.c \
+	openfs.c \
+	read_bb.c \
+	read_bb_file.c \
+	res_gdt.c \
+	rw_bitmaps.c \
+	swapfs.c \
+	tdb.c \
+	undo_io.c \
+	unix_io.c \
+	unlink.c \
+	valid_blk.c \
+	version.c
+
+# get rid of this?!
+libext2fs_src_files += test_io.c
+
+libext2fs_shared_libraries := \
+	libext2_com_err \
+	libext2_uuid \
+	libext2_blkid \
+	libext2_e2p
+
+libext2fs_system_shared_libraries := libc
+
+libext2fs_c_includes := external/e2fsprogs/lib
+
+libext2fs_cflags := -O2 -g -W -Wall \
+	-DHAVE_UNISTD_H \
+	-DHAVE_ERRNO_H \
+	-DHAVE_NETINET_IN_H \
+	-DHAVE_SYS_IOCTL_H \
+	-DHAVE_SYS_MMAN_H \
+	-DHAVE_SYS_MOUNT_H \
+	-DHAVE_SYS_RESOURCE_H \
+	-DHAVE_SYS_SELECT_H \
+	-DHAVE_SYS_STAT_H \
+	-DHAVE_SYS_TYPES_H \
+	-DHAVE_STDLIB_H \
+	-DHAVE_STRDUP \
+	-DHAVE_MMAP \
+	-DHAVE_UTIME_H \
+	-DHAVE_GETPAGESIZE \
+	-DHAVE_EXT2_IOCTLS \
+	-DHAVE_TYPE_SSIZE_T \
+	-DHAVE_SYS_TIME_H \
+        -DHAVE_SYS_PARAM_H \
+	-DHAVE_SYSCONF
+
+libext2fs_cflags_linux := \
+	-DHAVE_LINUX_FD_H \
+	-DHAVE_SYS_PRCTL_H \
+	-DHAVE_LSEEK64 \
+	-DHAVE_LSEEK64_PROTOTYPE
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2fs_src_files)
+LOCAL_SYSTEM_SHARED_LIBRARIES := $(libext2fs_system_shared_libraries)
+LOCAL_SHARED_LIBRARIES := $(libext2fs_shared_libraries)
+LOCAL_C_INCLUDES := $(libext2fs_c_includes)
+LOCAL_CFLAGS := $(libext2fs_cflags) $(libext2fs_cflags_linux)
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libext2fs
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2fs_src_files)
+LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(libext2fs_shared_libraries))
+LOCAL_C_INCLUDES := $(libext2fs_c_includes)
+ifeq ($(HOST_OS),linux)
+LOCAL_CFLAGS := $(libext2fs_cflags) $(libext2fs_cflags_linux)
+else
+LOCAL_CFLAGS := $(libext2fs_cflags)
+endif
+LOCAL_MODULE := libext2fs_host
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_SHARED_LIBRARY)
diff --git a/lib/uuid/Android.mk b/lib/uuid/Android.mk
new file mode 100644
index 0000000..a30feb0
--- /dev/null
+++ b/lib/uuid/Android.mk
@@ -0,0 +1,67 @@
+LOCAL_PATH := $(call my-dir)
+
+libext2_uuid_src_files := \
+	clear.c \
+	compare.c \
+	copy.c \
+	gen_uuid.c \
+	isnull.c \
+	pack.c \
+	parse.c \
+	unpack.c \
+	unparse.c \
+	uuid_time.c
+
+
+libext2_uuid_c_includes := external/e2fsprogs/lib
+
+libext2_uuid_cflags := -O2 -g -W -Wall \
+	-DHAVE_INTTYPES_H \
+	-DHAVE_UNISTD_H \
+	-DHAVE_ERRNO_H \
+	-DHAVE_NETINET_IN_H \
+	-DHAVE_SYS_IOCTL_H \
+	-DHAVE_SYS_MMAN_H \
+	-DHAVE_SYS_MOUNT_H \
+	-DHAVE_SYS_PRCTL_H \
+	-DHAVE_SYS_RESOURCE_H \
+	-DHAVE_SYS_SELECT_H \
+	-DHAVE_SYS_STAT_H \
+	-DHAVE_SYS_TYPES_H \
+	-DHAVE_STDLIB_H \
+	-DHAVE_STRDUP \
+	-DHAVE_MMAP \
+	-DHAVE_UTIME_H \
+	-DHAVE_GETPAGESIZE \
+	-DHAVE_LSEEK64 \
+	-DHAVE_LSEEK64_PROTOTYPE \
+	-DHAVE_EXT2_IOCTLS \
+	-DHAVE_LINUX_FD_H \
+	-DHAVE_TYPE_SSIZE_T \
+	-DHAVE_SYS_TIME_H \
+        -DHAVE_SYS_PARAM_H \
+	-DHAVE_SYSCONF
+
+libext2_uuid_system_shared_libraries := libc
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2_uuid_src_files)
+LOCAL_C_INCLUDES := $(libext2_uuid_c_includes)
+LOCAL_CFLAGS := $(libext2_uuid_cflags)
+LOCAL_SYSTEM_SHARED_LIBRARIES := $(libext2_uuid_system_shared_libraries)
+LOCAL_MODULE := libext2_uuid
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2_uuid_src_files)
+LOCAL_C_INCLUDES := $(libext2_uuid_c_includes)
+LOCAL_CFLAGS := $(libext2_uuid_cflags)
+LOCAL_MODULE := libext2_uuid_host
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_SHARED_LIBRARY)
diff --git a/misc/Android.mk b/misc/Android.mk
new file mode 100644
index 0000000..68fee3d
--- /dev/null
+++ b/misc/Android.mk
@@ -0,0 +1,424 @@
+LOCAL_PATH := $(call my-dir)
+
+#########################################################################
+# Build mke2fs
+mke2fs_src_files := \
+	mke2fs.c \
+	util.c \
+	default_profile.c
+
+mke2fs_c_includes := \
+	external/e2fsprogs/lib \
+	external/e2fsprogs/e2fsck
+
+mke2fs_cflags := -O2 -g -W -Wall \
+	-DHAVE_UNISTD_H \
+	-DHAVE_ERRNO_H \
+	-DHAVE_NETINET_IN_H \
+	-DHAVE_SYS_IOCTL_H \
+	-DHAVE_SYS_MMAN_H \
+	-DHAVE_SYS_MOUNT_H \
+	-DHAVE_SYS_RESOURCE_H \
+	-DHAVE_SYS_SELECT_H \
+	-DHAVE_SYS_STAT_H \
+	-DHAVE_SYS_TYPES_H \
+	-DHAVE_STDLIB_H \
+	-DHAVE_STRCASECMP \
+	-DHAVE_STRDUP \
+	-DHAVE_MMAP \
+	-DHAVE_UTIME_H \
+	-DHAVE_GETPAGESIZE \
+	-DHAVE_EXT2_IOCTLS \
+	-DHAVE_TYPE_SSIZE_T \
+	-DHAVE_GETOPT_H \
+	-DHAVE_SYS_TIME_H \
+        -DHAVE_SYS_PARAM_H \
+	-DHAVE_SYSCONF
+
+mke2fs_cflags_linux := \
+	-DHAVE_LINUX_FD_H \
+	-DHAVE_SYS_PRCTL_H \
+	-DHAVE_LSEEK64 \
+	-DHAVE_LSEEK64_PROTOTYPE
+
+mke2fs_cflags += -DNO_CHECK_BB
+
+mke2fs_shared_libraries := \
+	libext2fs \
+	libext2_blkid \
+	libext2_uuid \
+	libext2_profile \
+	libext2_com_err \
+	libext2_e2p
+
+mke2fs_system_shared_libraries := libc
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(mke2fs_src_files)
+LOCAL_C_INCLUDES := $(mke2fs_c_includes)
+LOCAL_CFLAGS := $(mke2fs_cflags) $(mke2fs_cflags_linux)
+LOCAL_SYSTEM_SHARED_LIBRARIES := $(mke2fs_system_shared_libraries)
+LOCAL_SHARED_LIBRARIES := $(mke2fs_shared_libraries)
+LOCAL_MODULE := mke2fs
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(mke2fs_src_files)
+LOCAL_C_INCLUDES := $(mke2fs_c_includes)
+ifeq ($(HOST_OS),linux)
+LOCAL_CFLAGS := $(mke2fs_cflags) $(mke2fs_cflags_linux)
+else
+LOCAL_CFLAGS := $(mke2fs_cflags)
+endif
+LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(mke2fs_shared_libraries))
+LOCAL_MODULE := mke2fs_host
+LOCAL_MODULE_STEM := mke2fs
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_EXECUTABLE)
+
+###########################################################################
+# Build tune2fs
+#
+tune2fs_src_files := \
+	tune2fs.c \
+	util.c
+
+tune2fs_c_includes := \
+	external/e2fsprogs/lib \
+	external/e2fsprogs/e2fsck
+
+tune2fs_cflags := -O2 -g -W -Wall \
+	-DHAVE_UNISTD_H \
+	-DHAVE_ERRNO_H \
+	-DHAVE_NETINET_IN_H \
+	-DHAVE_SYS_IOCTL_H \
+	-DHAVE_SYS_MMAN_H \
+	-DHAVE_SYS_MOUNT_H \
+	-DHAVE_SYS_PRCTL_H \
+	-DHAVE_SYS_RESOURCE_H \
+	-DHAVE_SYS_SELECT_H \
+	-DHAVE_SYS_STAT_H \
+	-DHAVE_SYS_TYPES_H \
+	-DHAVE_STDLIB_H \
+	-DHAVE_STRCASECMP \
+	-DHAVE_STRDUP \
+	-DHAVE_MMAP \
+	-DHAVE_UTIME_H \
+	-DHAVE_GETPAGESIZE \
+	-DHAVE_LSEEK64 \
+	-DHAVE_LSEEK64_PROTOTYPE \
+	-DHAVE_EXT2_IOCTLS \
+	-DHAVE_LINUX_FD_H \
+	-DHAVE_TYPE_SSIZE_T \
+	-DHAVE_GETOPT_H \
+	-DHAVE_SYS_TIME_H \
+        -DHAVE_SYS_PARAM_H \
+	-DHAVE_SYSCONF
+
+tune2fs_cflags += -DNO_CHECK_BB
+
+tune2fs_shared_libraries := \
+	libext2fs \
+	libext2_com_err \
+	libext2_blkid \
+	libext2_uuid \
+	libext2_e2p
+
+tune2fs_system_shared_libraries := libc
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(tune2fs_src_files)
+LOCAL_C_INCLUDES := $(tune2fs_c_includes)
+LOCAL_CFLAGS := $(tune2fs_cflags)
+LOCAL_SHARED_LIBRARIES := $(tune2fs_shared_libraries)
+LOCAL_SYSTEM_SHARED_LIBRARIES := $(tune2fs_system_shared_libraries)
+LOCAL_MODULE := tune2fs
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(tune2fs_src_files)
+LOCAL_C_INCLUDES := $(tune2fs_c_includes)
+LOCAL_CFLAGS := $(tune2fs_cflags)
+LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(tune2fs_shared_libraries))
+LOCAL_MODULE := tune2fs_host
+LOCAL_MODULE_STEM := tune2fs
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_EXECUTABLE)
+
+#########################################################################
+# Build badblocks
+#
+include $(CLEAR_VARS)
+
+badblocks_src_files := \
+	badblocks.c
+
+badblocks_c_includes := \
+	external/e2fsprogs/lib
+
+badblocks_cflags := -O2 -g -W -Wall \
+	-DHAVE_UNISTD_H \
+	-DHAVE_ERRNO_H \
+	-DHAVE_NETINET_IN_H \
+	-DHAVE_SYS_IOCTL_H \
+	-DHAVE_SYS_MMAN_H \
+	-DHAVE_SYS_MOUNT_H \
+	-DHAVE_SYS_PRCTL_H \
+	-DHAVE_SYS_RESOURCE_H \
+	-DHAVE_SYS_SELECT_H \
+	-DHAVE_SYS_STAT_H \
+	-DHAVE_SYS_TYPES_H \
+	-DHAVE_STDLIB_H \
+	-DHAVE_STRCASECMP \
+	-DHAVE_STRDUP \
+	-DHAVE_MMAP \
+	-DHAVE_UTIME_H \
+	-DHAVE_GETPAGESIZE \
+	-DHAVE_LSEEK64 \
+	-DHAVE_LSEEK64_PROTOTYPE \
+	-DHAVE_EXT2_IOCTLS \
+	-DHAVE_LINUX_FD_H \
+	-DHAVE_TYPE_SSIZE_T \
+	-DHAVE_GETOPT_H \
+	-DHAVE_SYS_TIME_H \
+        -DHAVE_SYS_PARAM_H \
+	-DHAVE_SYSCONF
+
+badblocks_shared_libraries := \
+	libext2fs \
+	libext2_com_err \
+	libext2_uuid \
+	libext2_blkid \
+	libext2_e2p
+
+badblocks_system_shared_libraries := libc
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(badblocks_src_files)
+LOCAL_C_INCLUDES := $(badblocks_c_includes)
+LOCAL_CFLAGS := $(badblocks_cflags)
+LOCAL_SHARED_LIBRARIES := $(badblocks_shared_libraries)
+LOCAL_SYSTEM_SHARED_LIBRARIES := $(badblocks_system_shared_libraries)
+LOCAL_MODULE := badblocks
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(badblocks_src_files)
+LOCAL_C_INCLUDES := $(badblocks_c_includes)
+LOCAL_CFLAGS := $(badblocks_cflags)
+LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(badblocks_shared_libraries))
+LOCAL_MODULE := badblocks_host
+LOCAL_MODULE_STEM := badblocks
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_EXECUTABLE)
+
+#########################################################################
+# Build chattr
+#
+include $(CLEAR_VARS)
+
+chattr_src_files := \
+	chattr.c
+
+chattr_c_includes := \
+	external/e2fsprogs/lib
+
+chattr_cflags := -O2 -g -W -Wall \
+	-DHAVE_UNISTD_H \
+	-DHAVE_ERRNO_H \
+	-DHAVE_NETINET_IN_H \
+	-DHAVE_SYS_IOCTL_H \
+	-DHAVE_SYS_MMAN_H \
+	-DHAVE_SYS_MOUNT_H \
+	-DHAVE_SYS_PRCTL_H \
+	-DHAVE_SYS_RESOURCE_H \
+	-DHAVE_SYS_SELECT_H \
+	-DHAVE_SYS_STAT_H \
+	-DHAVE_SYS_TYPES_H \
+	-DHAVE_STDLIB_H \
+	-DHAVE_STRCASECMP \
+	-DHAVE_STRDUP \
+	-DHAVE_MMAP \
+	-DHAVE_UTIME_H \
+	-DHAVE_GETPAGESIZE \
+	-DHAVE_LSEEK64 \
+	-DHAVE_LSEEK64_PROTOTYPE \
+	-DHAVE_EXT2_IOCTLS \
+	-DHAVE_LINUX_FD_H \
+	-DHAVE_TYPE_SSIZE_T \
+	-DHAVE_GETOPT_H \
+	-DHAVE_SYS_TIME_H \
+        -DHAVE_SYS_PARAM_H \
+	-DHAVE_SYSCONF
+
+chattr_shared_libraries := \
+	libext2_com_err \
+	libext2_e2p
+
+chattr_system_shared_libraries := libc
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(chattr_src_files)
+LOCAL_C_INCLUDES := $(chattr_c_includes)
+LOCAL_CFLAGS := $(chattr_cflags)
+LOCAL_SHARED_LIBRARIES := $(chattr_shared_libraries)
+LOCAL_SYSTEM_SHARED_LIBRARIES := $(chattr_system_shared_libraries)
+LOCAL_MODULE := chattr
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(chattr_src_files)
+LOCAL_C_INCLUDES := $(chattr_c_includes)
+LOCAL_CFLAGS := $(chattr_cflags)
+LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(chattr_shared_libraries))
+LOCAL_MODULE := chattr_host
+LOCAL_MODULE_STEM := chattr
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_EXECUTABLE)
+
+#########################################################################
+# Build lsattr
+#
+include $(CLEAR_VARS)
+
+lsattr_src_files := \
+	lsattr.c
+
+lsattr_c_includes := \
+	external/e2fsprogs/lib
+
+lsattr_cflags := -O2 -g -W -Wall \
+	-DHAVE_UNISTD_H \
+	-DHAVE_ERRNO_H \
+	-DHAVE_NETINET_IN_H \
+	-DHAVE_SYS_IOCTL_H \
+	-DHAVE_SYS_MMAN_H \
+	-DHAVE_SYS_MOUNT_H \
+	-DHAVE_SYS_PRCTL_H \
+	-DHAVE_SYS_RESOURCE_H \
+	-DHAVE_SYS_SELECT_H \
+	-DHAVE_SYS_STAT_H \
+	-DHAVE_SYS_TYPES_H \
+	-DHAVE_STDLIB_H \
+	-DHAVE_STRCASECMP \
+	-DHAVE_STRDUP \
+	-DHAVE_MMAP \
+	-DHAVE_UTIME_H \
+	-DHAVE_GETPAGESIZE \
+	-DHAVE_LSEEK64 \
+	-DHAVE_LSEEK64_PROTOTYPE \
+	-DHAVE_EXT2_IOCTLS \
+	-DHAVE_LINUX_FD_H \
+	-DHAVE_TYPE_SSIZE_T \
+	-DHAVE_GETOPT_H \
+	-DHAVE_SYS_TIME_H \
+        -DHAVE_SYS_PARAM_H \
+	-DHAVE_SYSCONF
+
+lsattr_shared_libraries := \
+	libext2_com_err \
+	libext2_e2p
+
+lsattr_system_shared_libraries := libc
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(lsattr_src_files)
+LOCAL_C_INCLUDES := $(lsattr_c_includes)
+LOCAL_CFLAGS := $(lsattr_cflags)
+LOCAL_SHARED_LIBRARIES := $(lsattr_shared_libraries)
+LOCAL_SYSTEM_SHARED_LIBRARIES := $(lsattr_system_shared_libraries)
+LOCAL_MODULE := lsattr
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(lsattr_src_files)
+LOCAL_C_INCLUDES := $(lsattr_c_includes)
+LOCAL_CFLAGS := $(lsattr_cflags)
+LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(lsattr_shared_libraries))
+LOCAL_MODULE := lsattr_host
+LOCAL_MODULE_STEM := lsattr
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_EXECUTABLE)
+
+#########################################################################
+# Build blkid
+#
+include $(CLEAR_VARS)
+
+blkid_src_files := \
+    blkid.c
+
+blkid_c_includes := \
+    external/e2fsprogs/lib
+
+lsattr_cflags := -O2 -g -W -Wall \
+    -DHAVE_UNISTD_H \
+    -DHAVE_ERRNO_H \
+    -DHAVE_NETINET_IN_H \
+    -DHAVE_SYS_IOCTL_H \
+    -DHAVE_SYS_MMAN_H \
+    -DHAVE_SYS_MOUNT_H \
+    -DHAVE_SYS_PRCTL_H \
+    -DHAVE_SYS_RESOURCE_H \
+    -DHAVE_SYS_SELECT_H \
+    -DHAVE_SYS_STAT_H \
+    -DHAVE_SYS_TYPES_H \
+    -DHAVE_STDLIB_H \
+    -DHAVE_STRCASECMP \
+    -DHAVE_STRDUP \
+    -DHAVE_MMAP \
+    -DHAVE_UTIME_H \
+    -DHAVE_GETPAGESIZE \
+    -DHAVE_LSEEK64 \
+    -DHAVE_LSEEK64_PROTOTYPE \
+    -DHAVE_EXT2_IOCTLS \
+    -DHAVE_LINUX_FD_H \
+    -DHAVE_TYPE_SSIZE_T \
+    -DHAVE_GETOPT_H \
+    -DHAVE_SYS_TIME_H \
+    -DHAVE_SYS_PARAM_H \
+    -DHAVE_SYSCONF
+
+blkid_shared_libraries := \
+    libext2fs \
+    libext2_blkid \
+    libext2_com_err \
+    libext2_e2p
+
+blkid_system_shared_libraries := libc
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(blkid_src_files)
+LOCAL_C_INCLUDES := $(blkid_c_includes)
+LOCAL_CFLAGS := $(blkid_cflags)
+LOCAL_SHARED_LIBRARIES := $(blkid_shared_libraries)
+LOCAL_SYSTEM_SHARED_LIBRARIES := $(blkid_system_shared_libraries)
+LOCAL_MODULE := blkid
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_EXECUTABLE)
diff --git a/resize/Android.mk b/resize/Android.mk
new file mode 100644
index 0000000..e6352a9
--- /dev/null
+++ b/resize/Android.mk
@@ -0,0 +1,68 @@
+LOCAL_PATH := $(call my-dir)
+
+resize2fs_src_files := \
+	extent.c \
+	resize2fs.c \
+	main.c \
+	online.c \
+	sim_progress.c
+
+resize2fs_c_includes := external/e2fsprogs/lib
+
+resize2fs_cflags := -O2 -g -W -Wall \
+	-DHAVE_UNISTD_H \
+	-DHAVE_ERRNO_H \
+	-DHAVE_NETINET_IN_H \
+	-DHAVE_SYS_IOCTL_H \
+	-DHAVE_SYS_MMAN_H \
+	-DHAVE_SYS_MOUNT_H \
+	-DHAVE_SYS_PRCTL_H \
+	-DHAVE_SYS_RESOURCE_H \
+	-DHAVE_SYS_SELECT_H \
+	-DHAVE_SYS_STAT_H \
+	-DHAVE_SYS_TYPES_H \
+	-DHAVE_STDLIB_H \
+	-DHAVE_STRDUP \
+	-DHAVE_MMAP \
+	-DHAVE_UTIME_H \
+	-DHAVE_GETPAGESIZE \
+	-DHAVE_LSEEK64 \
+	-DHAVE_LSEEK64_PROTOTYPE \
+	-DHAVE_EXT2_IOCTLS \
+	-DHAVE_LINUX_FD_H \
+	-DHAVE_TYPE_SSIZE_T \
+	-DHAVE_SYS_TIME_H \
+        -DHAVE_SYS_PARAM_H \
+	-DHAVE_SYSCONF
+
+resize2fs_shared_libraries := \
+	libext2fs \
+	libext2_com_err \
+	libext2_e2p \
+	libext2_uuid \
+	libext2_blkid
+
+resize2fs_system_shared_libraries := libc
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(resize2fs_src_files)
+LOCAL_C_INCLUDES := $(resize2fs_c_includes)
+LOCAL_CFLAGS := $(resize2fs_cflags)
+LOCAL_SHARED_LIBRARIES := $(resize2fs_shared_libraries)
+LOCAL_SYSTEM_SHARED_LIBRARIES := $(resize2fs_system_shared_libraries)
+LOCAL_MODULE := resize2fs
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(resize2fs_src_files)
+LOCAL_C_INCLUDES := $(resize2fs_c_includes)
+LOCAL_CFLAGS := $(resize2fs_cflags)
+LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(resize2fs_shared_libraries))
+LOCAL_MODULE := resize2fs_host
+LOCAL_MODULE_STEM := resize2fs
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_EXECUTABLE)