sdm845: commonize device

The only difference between beryllium, enchilada and sdm845 is
naming of various modules and fstabs.

Allow to override the fstab target of sdm845 and switch to use
`TARGET_BOOTLOADER_BOARD_NAME` for naming files.

This slims down the differences of beryllium, enchilada and
sdm845 device makefiles to a minimum.

Change-Id: Icfa0b0c1b1729e4e071b33c31d522f14679cdc0e
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
diff --git a/beryllium/device.mk b/beryllium/device.mk
index 4c899d8..8c72142 100644
--- a/beryllium/device.mk
+++ b/beryllium/device.mk
@@ -14,34 +14,5 @@
 # limitations under the License.
 #
 
-PRODUCT_SOONG_NAMESPACES += \
-    device/generic/sdm845
-
-# copied from crosshatch
-# setup dalvik vm configs
-$(call inherit-product, frameworks/native/build/phone-xhdpi-2048-dalvik-heap.mk)
-
-
-PRODUCT_COPY_FILES := \
-    $(LOCAL_PATH)/fstab.ramdisk:$(TARGET_COPY_OUT_RAMDISK)/fstab.beryllium \
-    $(LOCAL_PATH)/fstab.ramdisk:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.beryllium \
-    device/generic/sdm845/init.common.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.beryllium.rc \
-    device/generic/sdm845/init.common.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.beryllium.usb.rc \
-    device/generic/sdm845/common.kl:$(TARGET_COPY_OUT_VENDOR)/usr/keylayout/beryllium.kl
-
-# Build generic Audio HAL
-PRODUCT_PACKAGES := audio.primary.beryllium
-
-# Build generic lights HAL
-PRODUCT_PACKAGES += lights.beryllium
-
-PRODUCT_PACKAGES += \
-    pd-mapper \
-    qrtr-ns \
-    qrtr-cfg \
-    qrtr-lookup \
-    rmtfs \
-    tqftpserv
-
-PRODUCT_COPY_FILES += \
-    device/generic/sdm845/qcom/init.qcom.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.qcom.rc
+RAMDISK_FSTAB_TARGET := $(LOCAL_PATH)/fstab.ramdisk
+$(call inherit-product, device/generic/sdm845/sdm845/device.mk)
diff --git a/enchilada/device.mk b/enchilada/device.mk
index f453cd5..8c72142 100644
--- a/enchilada/device.mk
+++ b/enchilada/device.mk
@@ -14,34 +14,5 @@
 # limitations under the License.
 #
 
-PRODUCT_SOONG_NAMESPACES += \
-    device/generic/sdm845
-
-# copied from crosshatch
-# setup dalvik vm configs
-$(call inherit-product, frameworks/native/build/phone-xhdpi-2048-dalvik-heap.mk)
-
-
-PRODUCT_COPY_FILES := \
-    $(LOCAL_PATH)/fstab.ramdisk:$(TARGET_COPY_OUT_RAMDISK)/fstab.enchilada \
-    $(LOCAL_PATH)/fstab.ramdisk:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.enchilada \
-    device/generic/sdm845/init.common.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.enchilada.rc \
-    device/generic/sdm845/init.common.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.enchilada.usb.rc \
-    device/generic/sdm845/common.kl:$(TARGET_COPY_OUT_VENDOR)/usr/keylayout/enchilada.kl
-
-# Build generic Audio HAL
-PRODUCT_PACKAGES := audio.primary.enchilada
-
-# Build generic lights HAL
-PRODUCT_PACKAGES += lights.enchilada
-
-PRODUCT_PACKAGES += \
-    pd-mapper \
-    qrtr-ns \
-    qrtr-cfg \
-    qrtr-lookup \
-    rmtfs \
-    tqftpserv
-
-PRODUCT_COPY_FILES += \
-    device/generic/sdm845/qcom/init.qcom.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.qcom.rc
+RAMDISK_FSTAB_TARGET := $(LOCAL_PATH)/fstab.ramdisk
+$(call inherit-product, device/generic/sdm845/sdm845/device.mk)
diff --git a/sdm845/device.mk b/sdm845/device.mk
index 3349e9d..4c320b3 100644
--- a/sdm845/device.mk
+++ b/sdm845/device.mk
@@ -21,10 +21,12 @@
 # setup dalvik vm configs
 $(call inherit-product, frameworks/native/build/phone-xhdpi-2048-dalvik-heap.mk)
 
+# Allow to override ramdisk until we can produce fully generic builds
+RAMDISK_FSTAB_TARGET ?= $(LOCAL_PATH)/fstab.ramdisk
 
 PRODUCT_COPY_FILES := \
-    $(LOCAL_PATH)/fstab.ramdisk:$(TARGET_COPY_OUT_RAMDISK)/fstab.sdm845 \
-    $(LOCAL_PATH)/fstab.ramdisk:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.sdm845 \
+    $(RAMDISK_FSTAB_TARGET):$(TARGET_COPY_OUT_RAMDISK)/fstab.sdm845 \
+    $(RAMDISK_FSTAB_TARGET):$(TARGET_COPY_OUT_VENDOR)/etc/fstab.sdm845 \
     device/generic/sdm845/init.common.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.sdm845.rc \
     device/generic/sdm845/init.common.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.sdm845.usb.rc \
     device/generic/sdm845/common.kl:$(TARGET_COPY_OUT_VENDOR)/usr/keylayout/sdm845.kl