Package: src:android-tools
Followup-For: Bug #738119

Although the android-tools packaging is indeed rather bad, I've made an
attempt to update it for 5.0.1. (Integrating it with
android-platform-system-core was beyond my skill.)

I'm attaching updates of the three custom makefiles supplied under
debian/makefiles. Some comments on the changes I made:

- AndroidConfig.h is no more, so the build-dep on android-system-dev is
  no longer needed.

- adb doesn't appear to use libzipfile any longer.

- adb is currently built with -DWORKAROUND_BUG6558362 by upstream, so I
  did likewise.

- fastboot now depends on f2fs_utils, i.e., extras/f2fs_utils and
  externals/f2fs-tools. (Debian has an f2fs-tools package, but
  apparently no dev package to go with it.) f2fs_utils in turn pulls in
  core/include/log and core/include/android.

- fastboot (or one of its deps, I forgot which) needs
  core/include/utils.

- ext4_utils now needs the selinux headers from external/libselinux, as
  Debian's libselinux1-dev doesn't contain android.h.

- ext4_utils needs -DANDROID and -DHOST to compile correctly.

There were also some problems with the actual source files, which will
need patches:

- libzipfile/centraldir.c needs an explicit #define _FILE_OFFSET_BITS 64
  to compile.

- extras/f2fs_utils/f2fs_sparseblock.c is missing includes for stdlib.h,
  string.h, and errno.h.

- extras/f2fs_utils/f2fs_utils.c is missing an include of string.h.

As the internal deps continue to grow, it's even more true that the
current build method of this package is a problem. However, since there
are multiple deps on source files outside of the platform/core repo,
integration with android-platform-system-core also feels wrong. Upstream
doesn't make this easy.

-- System Information:
Debian Release: 8.0
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
# Makefile for adb; from https://heiher.info/2227.html

SRCDIR ?= $(CURDIR)

VPATH+= $(SRCDIR)/core/adb
SRCS+= adb.c
SRCS+= adb_client.c
SRCS+= adb_auth_host.c
SRCS+= commandline.c
SRCS+= console.c
SRCS+= file_sync_client.c
SRCS+= fdevent.c
SRCS+= get_my_path_linux.c
SRCS+= services.c
SRCS+= sockets.c
SRCS+= transport.c
SRCS+= transport_local.c
SRCS+= transport_usb.c
SRCS+= usb_linux.c
SRCS+= usb_vendors.c

VPATH+= $(SRCDIR)/core/libcutils
SRCS+= socket_inaddr_any_server.c
SRCS+= socket_local_client.c
SRCS+= socket_local_server.c
SRCS+= socket_loopback_client.c
SRCS+= socket_loopback_server.c
SRCS+= socket_network_client.c
SRCS+= load_file.c

CPPFLAGS+= -D_XOPEN_SOURCE -D_GNU_SOURCE
CPPFLAGS+= -DADB_HOST=1
CPPFLAGS+= -DWORKAROUND_BUG6558362
CPPFLAGS+= -I$(SRCDIR)/core/adb
CPPFLAGS+= -I$(SRCDIR)/core/include

LIBS+= -lc -lpthread -lz -lcrypto

OBJS= $(SRCS:.c=.o)

all: adb

adb: $(OBJS)
	$(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)

clean:
	rm -rf $(OBJS) adb
# Makefile for fastboot; from https://heiher.info/2227.html

SRCDIR ?= $(CURDIR)

VPATH+= $(SRCDIR)/core/fastboot
SRCS+= bootimg.c
SRCS+= engine.c
SRCS+= fastboot.c
SRCS+= fs.c
SRCS+= protocol.c
SRCS+= usb_linux.c
SRCS+= util.c
SRCS+= util_linux.c

VPATH+= $(SRCDIR)/core/libzipfile
SRCS+= centraldir.c
SRCS+= zipfile.c

VPATH+= $(SRCDIR)/core/libsparse
SRCS+= backed_block.c
SRCS+= sparse_crc32.c
SRCS+= sparse.c
SRCS+= sparse_read.c
SRCS+= sparse_err.c
SRCS+= output_file.c

VPATH+= $(SRCDIR)/extras/ext4_utils
SRCS+= make_ext4fs.c
SRCS+= crc16.c
SRCS+= ext4_sb.c
SRCS+= ext4_utils.c
SRCS+= indirect.c
SRCS+= allocate.c
SRCS+= contents.c
SRCS+= uuid.c
SRCS+= extent.c
SRCS+= wipe.c
SRCS+= sha1.c

VPATH+= $(SRCDIR)/extras/f2fs_utils
SRCS+= f2fs_dlutils.c
SRCS+= f2fs_ioutils.c
SRCS+= f2fs_utils.c

CPPFLAGS+= -std=gnu99 -DUSE_F2FS
CPPFLAGS+= -I$(SRCDIR)/core/fastboot
CPPFLAGS+= -I$(SRCDIR)/core/include
CPPFLAGS+= -I$(SRCDIR)/core/mkbootimg
CPPFLAGS+= -I$(SRCDIR)/extras/ext4_utils
CPPFLAGS+= -I$(SRCDIR)/extras/f2fs_utils
CPPFLAGS+= -I$(SRCDIR)/core/libsparse/include
CPPFLAGS+= -I$(SRCDIR)/external/libselinux/include
CPPFLAGS+= -I$(SRCDIR)/external/f2fs-tools/include
CPPFLAGS+= -I$(SRCDIR)/external/f2fs-tools/mkfs

LIBS+= -lz -lselinux -ldl

OBJS= $(SRCS:.c=.o)

all: fastboot

fastboot: $(OBJS)
	$(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)

clean:
	rm -rf $(OBJS) fastboot
# Makefile for ext4_utils; based on https://heiher.info/2227.html
# Author: Dmitrijs Ledkovs <x...@ubuntu.com>

SRCDIR ?= $(CURDIR)

VPATH+= $(SRCDIR)/extras/ext4_utils
SRCS+=make_ext4fs.c
SRCS+=ext4fixup.c
SRCS+=ext4_utils.c
SRCS+=allocate.c
SRCS+=contents.c
SRCS+=extent.c
SRCS+=indirect.c
SRCS+=uuid.c
SRCS+=sha1.c
SRCS+=wipe.c
SRCS+=crc16.c
SRCS+=ext4_sb.c
SRCS+=canned_fs_config.c

VPATH+= $(SRCDIR)/core/libsparse
SRCS+= backed_block.c
SRCS+= sparse_crc32.c
SRCS+= sparse.c
SRCS+= sparse_read.c
SRCS+= sparse_err.c
SRCS+= output_file.c

OBJS_SHARED:= $(SRCS:.c=.o)

SRCS+=make_ext4fs_main.c
SRCS+=ext4fixup_main.c
SRCS+=setup_fs.c
SRCS+=ext2simg.c
SRCS+=img2simg.c
SRCS+=simg2img.c
SRCS+=simg2simg.c

CPPFLAGS+= -DHOST -DANDROID
CPPFLAGS+= -I$(SRCDIR)/extras/ext4_utils
CPPFLAGS+= -I/usr/include
CPPFLAGS+= -I$(SRCDIR)/core/include
CPPFLAGS+= -I$(SRCDIR)/core/libsparse/include
CPPFLAGS+= -I$(SRCDIR)/external/libselinux/include

LIBS+= -lz -lselinux

OBJS= $(SRCS:.c=.o)

all: make_ext4fs ext4fixup ext2simg img2simg simg2img simg2simg

make_ext4fs ext4fixup: $(OBJS)
	$(CC) -o $@ $(LDFLAGS) $(OBJS_SHARED) $@_main.o $(LIBS)

ext2simg img2simg simg2img simg2simg: $(OBJS)
	$(CC) -o $@ $(LDFLAGS) $(OBJS_SHARED) $@.o $(LIBS)

clean:
	rm -rf $(OBJS) ext2simg ext4fixup make_ext4fs img2simg simg2img simg2simg

Reply via email to