Refactor makefiles.

Change-Id: Ib06677c435eea2ff92d3b35f58e2fa7e981e0ae6
diff --git a/peripheral/bootctl/bootctl.cpp b/peripheral/bootctl/bootctl.cpp
index 4ca916f..2d07bb2 100755
--- a/peripheral/bootctl/bootctl.cpp
+++ b/peripheral/bootctl/bootctl.cpp
@@ -73,7 +73,6 @@
         setSlotAsUnbootable: bootctl_setSlotAsUnbootable,
         isSlotBootable: bootctl_isSlotBootable,
         getSuffix: bootctl_getSuffix,
-        reserved: {0}
 };
 
 static int crcCheck(TBootCtl *ptBootCtl) {
diff --git a/peripheral/wifi/bcm4339/peripheral.mk b/peripheral/wifi/bcm4339/peripheral.mk
index 6a88c80..9376140 100644
--- a/peripheral/wifi/bcm4339/peripheral.mk
+++ b/peripheral/wifi/bcm4339/peripheral.mk
@@ -14,16 +14,15 @@
 # limitations under the License.
 #
 
-BCMDHD_FIRMWARE_MK := hardware/bsp/freescale/peripheral/wifi/bcm4339/bcmdhd
-ifeq ($(BCMDHD_FIRMWARE_MK), $(wildcard $(BCMDHD_FIRMWARE_MK)))
-WLAN_FIRMWARE_SRC_FOLDER = hardware/bsp/freescale/peripheral/wifi/bcm4339/bcmdhd/firmware/ZP_BCM4339/
-FIRMWARE_DST_FOLDER = system/vendor/firmware/wlan/bcm4339
+bcmdhd_firmware_mk := hardware/bsp/freescale/peripheral/wifi/bcm4339/bcmdhd
+
+ifeq ($(bcmdhd_firmware_mk), $(wildcard $(bcmdhd_firmware_mk)))
+wlan_firmware_src_folder = hardware/bsp/freescale/peripheral/wifi/bcm4339/bcmdhd/firmware/ZP_BCM4339/
+firmware_dst_folder = system/vendor/firmware/wlan/bcm4339
 
 SRC_FILES := bcmdhd.ZP.SDIO.cal fw_bcmdhd.bin fw_bcmdhd_apsta.bin
 COPY_FILES += \
-              $(join $(patsubst %, $(WLAN_FIRMWARE_SRC_FOLDER)/%, $(SRC_FILES)), $(patsubst %, :$(FIRMWARE_DST_FOLDER)/%, $(SRC_FILES)))
+  $(join $(patsubst %, $(wlan_firmware_src_folder)/%, $(SRC_FILES)), $(patsubst %, :$(firmware_dst_folder)/%, $(SRC_FILES)))
 endif
 
 PRODUCT_COPY_FILES += $(COPY_FILES)
-WIFI_DRIVER_HAL_MODULE := wifi_driver.$(soc_name)
-WIFI_DRIVER_HAL_PERIPHERAL := bcm4339
diff --git a/soc/imx6ul/init.freescale.rc b/soc/imx6ul/init.freescale.rc
deleted file mode 100755
index b4644c6..0000000
--- a/soc/imx6ul/init.freescale.rc
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright 2015 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.
-#
-
-import init.freescale.usb.rc
-
-on init
-   mkdir /dev/block/by-name
-   symlink /dev/block/mmcblk1p1 /dev/block/by-name/boot_a
-   symlink /dev/block/mmcblk1p7 /dev/block/by-name/boot_b
-   symlink /dev/block/mmcblk1p5 /dev/block/by-name/system_a
-   symlink /dev/block/mmcblk1p8 /dev/block/by-name/system_b
-   symlink /dev/block/mmcblk1p9 /dev/block/by-name/misc
-
-on fs
-   mount_all /fstab.device
-   setprop ro.board.platform imx6ul
-
-on post-fs
-   restorecon /dev/block/mmcblk1p9
-   restorecon /dev/block/by-name/boot_a
-   restorecon /dev/block/by-name/boot_b
-   restorecon /dev/block/by-name/system_a
-   restorecon /dev/block/by-name/system_b
diff --git a/soc/imx6ul/init.freescale.usb.rc b/soc/imx6ul/init.freescale.usb.rc
deleted file mode 100644
index c0021f3..0000000
--- a/soc/imx6ul/init.freescale.usb.rc
+++ /dev/null
@@ -1,77 +0,0 @@
-# Copyright 2013 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.
-
-on init
-    write /sys/class/android_usb/android0/f_rndis/manufacturer Freescale
-    write /sys/class/android_usb/android0/f_rndis/vendorID 18D1
-    write /sys/class/android_usb/android0/f_rndis/wceis 1
-
-on boot
-    write /sys/class/android_usb/android0/iSerial $ro.serialno
-    write /sys/class/android_usb/android0/iManufacturer $ro.product.manufacturer
-    write /sys/class/android_usb/android0/iProduct $ro.product.model
-
-on fs
-    mkdir /dev/usb-ffs 0770 shell shell
-    mkdir /dev/usb-ffs/adb 0770 shell shell
-    mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
-    write /sys/class/android_usb/android0/f_ffs/aliases adb
-
-# USB RNDIS configuration.
-on property:sys.usb.config=rndis
-    stop adbd
-    write /sys/class/android_usb/android0/enable 0
-    write /sys/class/android_usb/android0/idVendor 18d1
-    write /sys/class/android_usb/android0/idProduct 4e23
-    write /sys/class/android_usb/android0/functions ${sys.usb.config}
-    write /sys/class/android_usb/android0/bDeviceClass 224
-    write /sys/class/android_usb/android0/enable 1
-    setprop sys.usb.state ${sys.usb.config}
-
-on property:sys.usb.config=mtp
-    stop adbd
-    write /sys/class/android_usb/android0/enable 0
-    write /sys/class/android_usb/android0/idVendor 18d1
-    write /sys/class/android_usb/android0/idProduct 4e41
-    write /sys/class/android_usb/android0/functions ${sys.usb.config}
-    write /sys/class/android_usb/android0/enable 1
-    setprop sys.usb.state ${sys.usb.config}
-
-on property:sys.usb.config=mtp,adb
-    write /sys/class/android_usb/android0/enable 0
-    write /sys/class/android_usb/android0/idVendor 18d1
-    write /sys/class/android_usb/android0/idProduct 4e42
-    write /sys/class/android_usb/android0/functions ${sys.usb.config}
-    write /sys/class/android_usb/android0/enable 1
-    start adbd
-    setprop sys.usb.state ${sys.usb.config}
-
-on property:sys.usb.config=ptp
-    stop adbd
-    write /sys/class/android_usb/android0/enable 0
-    write /sys/class/android_usb/android0/idVendor 18d1
-    write /sys/class/android_usb/android0/idProduct 4e43
-    write /sys/class/android_usb/android0/functions ${sys.usb.config}
-    write /sys/class/android_usb/android0/enable 1
-    setprop sys.usb.state ${sys.usb.config}
-
-on property:sys.usb.config=ptp,adb
-    write /sys/class/android_usb/android0/enable 0
-    write /sys/class/android_usb/android0/idVendor 18d1
-    write /sys/class/android_usb/android0/idProduct 4e44
-    write /sys/class/android_usb/android0/functions ${sys.usb.config}
-    write /sys/class/android_usb/android0/enable 1
-    start adbd
-    setprop sys.usb.state ${sys.usb.config}
-
diff --git a/soc/imx6ul/sepolicy/file_contexts b/soc/imx6ul/sepolicy/file_contexts
deleted file mode 100755
index d6d36c6..0000000
--- a/soc/imx6ul/sepolicy/file_contexts
+++ /dev/null
@@ -1,10 +0,0 @@
-/dev/ttymxc[0-9]*               u:object_r:tty_device:s0
-/system/bin/fsl_sensor_fusion   u:object_r:sensors_exec:s0
-/dev/FreescaleAccelerometer     u:object_r:sensors_device:s0
-/dev/FreescaleMagnetometer      u:object_r:sensors_device:s0
-/dev/FreescaleGyroscope         u:object_r:sensors_device:s0
-/dev/block/mmcblk1p9            u:object_r:misc_device:s0
-/dev/block/mmcblk1p1            u:object_r:boot_block_device:s0
-/dev/block/mmcblk1p7            u:object_r:boot_block_device:s0
-/dev/block/mmcblk1p5            u:object_r:system_block_device:s0
-/dev/block/mmcblk1p8            u:object_r:system_block_device:s0
diff --git a/soc/imx6ul/sepolicy/init.te b/soc/imx6ul/sepolicy/init.te
deleted file mode 100755
index cccd7f3..0000000
--- a/soc/imx6ul/sepolicy/init.te
+++ /dev/null
@@ -1 +0,0 @@
-allow init functionfs:dir mounton;
diff --git a/soc/imx6ul/sepolicy/mediaserver.te b/soc/imx6ul/sepolicy/mediaserver.te
deleted file mode 100644
index 72acfbb..0000000
--- a/soc/imx6ul/sepolicy/mediaserver.te
+++ /dev/null
@@ -1 +0,0 @@
-allow mediaserver debug_prop:property_service set;
diff --git a/soc/imx6ul/sepolicy/misc.te b/soc/imx6ul/sepolicy/misc.te
deleted file mode 100755
index 6fa24ba..0000000
--- a/soc/imx6ul/sepolicy/misc.te
+++ /dev/null
@@ -1 +0,0 @@
-type misc_device, dev_type;
diff --git a/soc/imx6ul/sepolicy/sensors.te b/soc/imx6ul/sepolicy/sensors.te
deleted file mode 100755
index 81fdf8a..0000000
--- a/soc/imx6ul/sepolicy/sensors.te
+++ /dev/null
@@ -1,27 +0,0 @@
-# Integrated NXP sensor process.
-type sensors, domain;
-type sensors_exec, exec_type, file_type;
-
-# Started by init.
-init_daemon_domain(sensors)
-
-# Change own perms to (nobody,nobody).
-allow sensors self:capability { setuid setgid };
-# Chown /data/misc/sensors/debug/ to nobody.
-allow sensors self:capability chown;
-dontaudit sensors self:capability fsetid;
-
-# Access /data/misc/sensors/debug and /data/system/sensors/settings.
-allow sensors self:capability dac_read_search;
-dontaudit sensors self:capability dac_override;
-
-# Access sensor nodes (/dev/msm_dsps).
-allow sensors sensors_device:chr_file rw_file_perms;
-
-# Wake lock access.
-wakelock_use(sensors)
-
-allow sensors cgroup:dir { create add_name };
-allow sensors input_device:chr_file rw_file_perms;
-allow sensors input_device:dir r_dir_perms;
-allow sensors uhid_device:chr_file rw_file_perms;
diff --git a/soc/imx6ul/sepolicy/sensorservice.te b/soc/imx6ul/sepolicy/sensorservice.te
deleted file mode 100755
index 0dc30c5..0000000
--- a/soc/imx6ul/sepolicy/sensorservice.te
+++ /dev/null
@@ -1,5 +0,0 @@
-allow sensorservice sysfs:file write;
-allow sensorservice input_device:dir r_file_perms;
-allow sensorservice input_device:chr_file r_file_perms;
-allow sensorservice self:capability net_admin;
-allow sensorservice sysfs:dir r_file_perms;
diff --git a/soc/imx6ul/sepolicy/update_engine.te b/soc/imx6ul/sepolicy/update_engine.te
deleted file mode 100755
index 470e0d6..0000000
--- a/soc/imx6ul/sepolicy/update_engine.te
+++ /dev/null
@@ -1 +0,0 @@
-allow update_engine misc_device:blk_file { open read write };
diff --git a/soc/imx6ul/sepolicy/wifi_setup.te b/soc/imx6ul/sepolicy/wifi_setup.te
deleted file mode 100644
index a3d5c63..0000000
--- a/soc/imx6ul/sepolicy/wifi_setup.te
+++ /dev/null
@@ -1 +0,0 @@
-allow wifi_setup proc:file open;
diff --git a/soc/imx6ul/soc.mk b/soc/imx6ul/soc.mk
deleted file mode 100755
index e0a69fe..0000000
--- a/soc/imx6ul/soc.mk
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright 2015 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.
-#
-
-# TODO(leecam): Make this automatic.
-LOCAL_PATH := hardware/bsp/freescale/soc/imx6ul
-
-# Arm32 device.
-TARGET_ARCH := arm
-TARGET_ARCH_VARIANT := armv7-a
-TARGET_CPU_VARIANT := generic
-TARGET_CPU_ABI := armeabi-v7a
-TARGET_CPU_ABI2 := armeabi
-TARGET_KERNEL_ARCH := $(TARGET_ARCH)
-
-TARGET_NO_BOOTLOADER := false
-TARGET_NO_KERNEL := false
-
-TARGET_KERNEL_DTB := imx6ul-14x14-evk.dtb
-BOARD_KERNEL_BASE := 0x82800000
-
-BOARD_KERNEL_CMDLINE := console=ttymxc0,115200 init=/init androidboot.console=ttymxc0 consoleblank=0 androidboot.hardware=freescale
-
-TARGET_USERIMAGES_USE_EXT4 := true
-BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
-BOARD_FLASH_BLOCK_SIZE := 131072
-
-PRODUCT_COPY_FILES += \
-  $(LOCAL_PATH)/init.freescale.rc:root/init.freescale.rc \
-  $(LOCAL_PATH)/init.freescale.usb.rc:root/init.freescale.usb.rc \
-  $(LOCAL_PATH)/ueventd.freescale.rc:root/ueventd.freescale.rc \
-  system/core/rootdir/init.usb.rc:root/init.usb.rc \
-  system/core/rootdir/ueventd.rc:root/ueventd.rc \
-  $(LOCAL_PATH)/../../peripheral/bootctl/tool/misc.img:misc.img \
-
-BOARD_SEPOLICY_DIRS += $(LOCAL_PATH)/sepolicy
-
-# Set up the local kernel.
-TARGET_KERNEL_SRC := hardware/bsp/kernel/freescale/picoimx-3.14
-TARGET_KERNEL_DEFCONFIG := imx_v7_android_defconfig
-TARGET_KERNEL_CROSS_COMPILE_PREFIX := $(ANDROID_BUILD_TOP)/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-
-
-# Lights HAL package.
-DEVICE_PACKAGES += \
-  lights.$(soc_name)
-
-# WiFi HAL package.
-DEVICE_PACKAGES += \
-  wifi_driver.$(soc_name)
diff --git a/soc/imx6ul/ueventd.freescale.rc b/soc/imx6ul/ueventd.freescale.rc
deleted file mode 100755
index 967e40a..0000000
--- a/soc/imx6ul/ueventd.freescale.rc
+++ /dev/null
@@ -1,87 +0,0 @@
-#
-# Copyright 2015 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.
-#
-
-/dev/pmem_gpu             0660   system     graphics
-/dev/ttymxc5              0660   bluetooth  bluetooth
-/dev/snd/*                0660   system     audio
-/dev/ttyUSB*              0640   radio      radio
-/dev/ttyACM*              0640   radio      radio
-/dev/video*               0660   system     camera
-/dev/video0               0660   system     camera
-/dev/video1               0660   system     camera
-/dev/video2               0660   system     camera
-/dev/video16              0660   system     graphics
-/dev/mxc_ipu              0660   media      system
-/dev/mxc_vpu              0660   media      system
-/dev/uinput               0660   system     bluetooth
-/dev/ttymxc2              0660   system     gps
-/dev/ttya0                0660   system     gps
-/dev/ptya0                0660   system     gps
-/dev/ttya1                0660   system     gps
-/dev/ptya1                0660   system     gps
-/dev/ion                  0666   media      system
-/dev/galcore              0666   system     graphics
-/dev/graphics/fb0         0660   system     graphics
-/dev/watchdog             0660   system     root
-/dev/ir                   0660   system     system
-/dev/mma8x5x              0640   compass     system
-/dev/caam_kb              0660   system     system
-
-#sensors sysfs
-/sys/class/misc/Freescale*          name        0660  root   input
-/sys/class/misc/Freescale*          max         0660  root   input
-/sys/class/misc/Freescale*          min         0660  root   input
-/sys/class/misc/Freescale*          poll        0660  root   input
-/sys/class/misc/Freescale*          enable      0660  root   input
-/sys/class/misc/Freescale*          position    0660  root   input
-/sys/class/misc/Freescale*          poll_delay  0660  root   input
-/sys/class/misc/Freescale*          fifo        0660  root   input
-/dev/FreescaleAccelerometer                     0660  system input
-/dev/FreescaleMagnetometer                      0660  system input
-/dev/FreescaleGyroscope                         0660  system input
-
-
-# sysfs properties
-/sys/devices/virtual/input/input*   name        0660  root   input
-/sys/devices/virtual/input/input*   max         0660  root   input
-/sys/devices/virtual/input/input*   min         0660  root   input
-/sys/devices/virtual/input/input*   poll        0660  root   input
-/sys/devices/virtual/input/input*   enable      0660  root   input
-/sys/devices/virtual/input/input*   position    0660  root   input
-/sys/devices/virtual/input/input*   poll_delay  0660  root   input
-/sys/devices/virtual/input/input*   fifo        0660  root   input
-/sys/devices/virtual/thermal/thermal_zone* trip_point_0_temp 0660 system system
-/sys/devices/virtual/thermal/thermal_zone* trip_point_1_temp 0660 system system
-/sys/devices/virtual/thermal/thermal_zone* trip_point_2_temp 0660 system system
-
-/sys/devices/platform/mxsdhci.2/mmc_host/mmc0/mmc0:000* boot_bus_config 0660 root root
-/sys/devices/platform/mxsdhci.2/mmc_host/mmc0/mmc0:000* boot_config 0660 root root
-# for sabresd
-/sys/devices/soc0/soc.0/2100000.aips-bus/21a8000.i2c/i2c-2/2-0044 mode 0660 system system
-/sys/devices/soc0/soc.0/2100000.aips-bus/21a8000.i2c/i2c-2/2-0044 lux 0660 system system
-/sys/devices/soc0/soc.0/2100000.aips-bus/21a8000.i2c/i2c-2/2-0044 int_lt_lux 0660 system system
-/sys/devices/soc0/soc.0/2100000.aips-bus/21a8000.i2c/i2c-2/2-0044 int_ht_lux 0660 system system
-# for sabreauto
-/sys/devices/soc0/soc.1/2100000.aips-bus/21a8000.i2c/i2c-1/1-0044 mode 0660 system system
-/sys/devices/soc0/soc.1/2100000.aips-bus/21a8000.i2c/i2c-1/1-0044 lux 0660 system system
-/sys/devices/soc0/soc.1/2100000.aips-bus/21a8000.i2c/i2c-1/1-0044 int_lt_lux 0660 system system
-/sys/devices/soc0/soc.1/2100000.aips-bus/21a8000.i2c/i2c-1/1-0044 int_ht_lux 0660 system system
-/sys/devices/platform/mxc_sdc_fb.0/graphics/fb* fsl_disp_property 0660 system graphics
-/sys/devices/platform/mxc_sdc_fb.1/graphics/fb* fsl_disp_property 0660 system graphics
-/sys/devices/platform/mxc_sdc_fb.0/graphics/fb* mode 0660 system graphics
-/sys/devices/platform/mxc_sdc_fb.1/graphics/fb* mode 0660 system graphics
-/sys/devices/platform/mxc_dvfs_core.0 enable 0660 system system
-/sys/devices/platform/busfreq.0 enable 0660 system system