Revert "Convert external/hyphenation-patterns to Android.bp"

This reverts commit 39e53fef3540e2559f0608fc2dbc567014af16bf.

Reason for revert: need to include license metadata and resubmit.

Change-Id: Ia480999e6f53d76b95db66f0d0bba24f0270034b
diff --git a/Android.bp b/Android.bp
deleted file mode 100644
index 6bc30ac..0000000
--- a/Android.bp
+++ /dev/null
@@ -1,157 +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.
-
-filegroup {
-    name: "hyph-hyb-data",
-    srcs: [
-        "**/*.pat.txt",
-        "**/*.chr.txt",
-        "**/*.hyp.txt",
-    ],
-}
-
-gensrcs {
-    name: "gen-hyph-hyb",
-
-    srcs: [
-        "rekenaar/af/hyph-af.pat.txt",
-        "TeX/am/hyph-mul-ethi.pat.txt",
-        "TeX/as/hyph-as.pat.txt",
-        "TeX/be/hyph-be.pat.txt",
-        "TeX/bn/hyph-bn.pat.txt",
-        "TeX/bg/hyph-bg.pat.txt",
-        "tensojka/cs/hyph-cs.pat.txt",
-        "TeX/cu/hyph-cu.pat.txt",
-        "TeX/cy/hyph-cy.pat.txt",
-        "TeX/da/hyph-da.pat.txt",
-        "TeX/de/hyph-de-1901.pat.txt",
-        "TeX/de/hyph-de-1996.pat.txt",
-        "TeX/de/hyph-de-ch-1901.pat.txt",
-        "TeX/el/hyph-el.pat.txt",
-        "TeX/en-GB/hyph-en-gb.pat.txt",
-        "TeX/en-US/hyph-en-us.pat.txt",
-        "TeX/es/hyph-es.pat.txt",
-        "TeX/et/hyph-et.pat.txt",
-        "TeX/eu/hyph-eu.pat.txt",
-        "TeX/Ethi/hyph-und-ethi.pat.txt",
-        "TeX/fr/hyph-fr.pat.txt",
-        "TeX/ga/hyph-ga.pat.txt",
-        "TeX/gl/hyph-gl.pat.txt",
-        "TeX/gu/hyph-gu.pat.txt",
-        "TeX/hi/hyph-hi.pat.txt",
-        "TeX/hr/hyph-hr.pat.txt",
-        "TeX/hu/hyph-hu.pat.txt",
-        "TeX/hy/hyph-hy.pat.txt",
-        "TeX/it/hyph-it.pat.txt",
-        "TeX/ka/hyph-ka.pat.txt",
-        "TeX/kn/hyph-kn.pat.txt",
-        "TeX/la/hyph-la.pat.txt",
-        "TeX/lt/hyph-lt.pat.txt",
-        "TeX/lv/hyph-lv.pat.txt",
-        "TeX/ml/hyph-ml.pat.txt",
-        "TeX/mn/hyph-mn-cyrl.pat.txt",
-        "TeX/mr/hyph-mr.pat.txt",
-        "TeX/nb/hyph-nb.pat.txt",
-        "OpenTaal/nl/hyph-nl.pat.txt",
-        "TeX/nn/hyph-nn.pat.txt",
-        "TeX/or/hyph-or.pat.txt",
-        "TeX/pa/hyph-pa.pat.txt",
-        "TeX/pl/hyph-pl.pat.txt",
-        "TeX/pt/hyph-pt.pat.txt",
-        "laboratory50/ru/hyph-ru.pat.txt",
-        "TeX/sk/hyph-sk.pat.txt",
-        "TeX/sl/hyph-sl.pat.txt",
-        "TeX/sq/hyph-sq.pat.txt",
-        "LibreOffice/sv/hyph-sv.pat.txt",
-        "TeX/ta/hyph-ta.pat.txt",
-        "TeX/te/hyph-te.pat.txt",
-        "TeX/tk/hyph-tk.pat.txt",
-        "TeX/uk/hyph-uk.pat.txt",
-    ],
-
-    tools: [
-        "mk_hyb_file",
-    ],
-
-    tool_files: [
-        ":hyph-hyb-data",
-    ],
-
-    cmd: "mkdir -p $(genDir) " +
-        "&& cp $(locations :hyph-hyb-data) $(genDir)" +
-        "&& $(location mk_hyb_file) $(genDir)/$$$$(basename $(in)) $(out)",
-
-    trim_extension: ".pat.txt",
-    output_extension: "hyb",
-}
-
-prebuilt_usr_hyphendata {
-    name: "hyph-data",
-    srcs: [
-        ":gen-hyph-hyb",
-        "rekenaar/af/hyph-af.lic.txt",
-        "TeX/am/hyph-mul-ethi.lic.txt",
-        "TeX/as/hyph-as.lic.txt",
-        "TeX/be/hyph-be.lic.txt",
-        "TeX/bn/hyph-bn.lic.txt",
-        "TeX/bg/hyph-bg.lic.txt",
-        "tensojka/cs/hyph-cs.lic.txt",
-        "TeX/cu/hyph-cu.lic.txt",
-        "TeX/cy/hyph-cy.lic.txt",
-        "TeX/da/hyph-da.lic.txt",
-        "TeX/de/hyph-de-1901.lic.txt",
-        "TeX/de/hyph-de-1996.lic.txt",
-        "TeX/de/hyph-de-ch-1901.lic.txt",
-        "TeX/el/hyph-el.lic.txt",
-        "TeX/en-GB/hyph-en-gb.lic.txt",
-        "TeX/en-US/hyph-en-us.lic.txt",
-        "TeX/es/hyph-es.lic.txt",
-        "TeX/et/hyph-et.lic.txt",
-        "TeX/eu/hyph-eu.lic.txt",
-        "TeX/Ethi/hyph-und-ethi.lic.txt",
-        "TeX/fr/hyph-fr.lic.txt",
-        "TeX/ga/hyph-ga.lic.txt",
-        "TeX/gl/hyph-gl.lic.txt",
-        "TeX/gu/hyph-gu.lic.txt",
-        "TeX/hi/hyph-hi.lic.txt",
-        "TeX/hr/hyph-hr.lic.txt",
-        "TeX/hu/hyph-hu.lic.txt",
-        "TeX/hy/hyph-hy.lic.txt",
-        "TeX/it/hyph-it.lic.txt",
-        "TeX/ka/hyph-ka.lic.txt",
-        "TeX/kn/hyph-kn.lic.txt",
-        "TeX/la/hyph-la.lic.txt",
-        "TeX/lt/hyph-lt.lic.txt",
-        "TeX/lv/hyph-lv.lic.txt",
-        "TeX/ml/hyph-ml.lic.txt",
-        "TeX/mn/hyph-mn-cyrl.lic.txt",
-        "TeX/mr/hyph-mr.lic.txt",
-        "TeX/nb/hyph-nb.lic.txt",
-        "OpenTaal/nl/hyph-nl.lic.txt",
-        "TeX/nn/hyph-nn.lic.txt",
-        "TeX/or/hyph-or.lic.txt",
-        "TeX/pa/hyph-pa.lic.txt",
-        "TeX/pl/hyph-pl.lic.txt",
-        "TeX/pt/hyph-pt.lic.txt",
-        "laboratory50/ru/hyph-ru.lic.txt",
-        "TeX/sk/hyph-sk.lic.txt",
-        "TeX/sl/hyph-sl.lic.txt",
-        "TeX/sq/hyph-sq.lic.txt",
-        "LibreOffice/sv/hyph-sv.lic.txt",
-        "TeX/ta/hyph-ta.lic.txt",
-        "TeX/te/hyph-te.lic.txt",
-        "TeX/tk/hyph-tk.lic.txt",
-        "TeX/uk/hyph-uk.lic.txt",
-    ],
-}
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..dc55c2e
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,112 @@
+# Copyright (C) 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.
+
+#disable build in PDK
+ifneq ($(TARGET_BUILD_PDK),true)
+
+LOCAL_PATH := $(call my-dir)
+
+pattern_locales := \
+    rekenaar/af/af \
+    TeX/am/mul-ethi \
+    TeX/as/as \
+    TeX/be/be \
+    TeX/bn/bn \
+    TeX/bg/bg \
+    tensojka/cs/cs \
+    TeX/cu/cu \
+    TeX/cy/cy \
+    TeX/da/da \
+    TeX/de/de-1901 \
+    TeX/de/de-1996 \
+    TeX/de/de-ch-1901 \
+    TeX/el/el \
+    TeX/en-GB/en-gb \
+    TeX/en-US/en-us \
+    TeX/es/es \
+    TeX/et/et \
+    TeX/eu/eu \
+    TeX/Ethi/und-ethi \
+    TeX/fr/fr \
+    TeX/ga/ga \
+    TeX/gl/gl \
+    TeX/gu/gu \
+    TeX/hi/hi \
+    TeX/hr/hr \
+    TeX/hu/hu \
+    TeX/hy/hy \
+    TeX/it/it \
+    TeX/ka/ka \
+    TeX/kn/kn \
+    TeX/la/la \
+    TeX/lt/lt \
+    TeX/lv/lv \
+    TeX/ml/ml \
+    TeX/mn/mn-cyrl \
+    TeX/mr/mr \
+    TeX/nb/nb \
+    OpenTaal/nl/nl \
+    TeX/nn/nn \
+    TeX/or/or \
+    TeX/pa/pa \
+    TeX/pl/pl \
+    TeX/pt/pt \
+    laboratory50/ru/ru \
+    TeX/sk/sk \
+    TeX/sl/sl \
+    TeX/sq/sq \
+    LibreOffice/sv/sv \
+    TeX/ta/ta \
+    TeX/te/te \
+    TeX/tk/tk \
+    TeX/uk/uk
+
+# TODO: we have data for sa/sa, but it requires special case handling for case
+# folding and normalization, so don't build it until that's fixed.
+#
+# TODO: we have data for Liturgical Latin, but there is no standard BCP 47 tag
+# for it, so we don't build it.
+
+BUILD_HYB := $(LOCAL_PATH)/build-hyb.mk
+
+#############################################################################
+# $(1): The subdirectory where the source files live.
+$ $(2): The file name fragment.
+#       It is used to find source files, and also generate the resulting binary.
+#############################################################################
+define build-one-pattern-module
+$(eval include $(CLEAR_VARS))\
+$(eval LOCAL_MODULE := $(addprefix hyph-, $(2)))\
+$(eval LOCAL_SRC_FILES := $(addprefix $(1)/hyph-, $(addprefix $(2), .pat.txt .chr.txt .hyp.txt)))\
+$(eval LOCAL_LICENSE_KINDS := SPDX-license-identifier-MIT SPDX-license-identifier-BSD-3-Clause SPDX-license-identifier-FSFAP SPDX-license-identifier-Unicode-DFS SPDX-license-identifier-LGPL-2.1 SPDX-license-identifier-MPL)\
+$(eval LOCAL_LICENSE_CONDITIONS := notice reciprocal restricted)\
+$(eval LOCAL_NOTICE_FILE := $(wildcard $(addprefix $(LOCAL_PATH)/$(1), /NOTICE /LICENSE)))\
+$(eval include $(BUILD_HYB))\
+$(eval include $(CLEAR_VARS))\
+$(eval LOCAL_MODULE := $(addprefix $(addprefix hyph-, $(2)), .lic.txt))\
+$(eval LOCAL_SRC_FILES := $(addprefix $(1)/hyph-, $(addprefix $(2), .lic.txt)))\
+$(eval LOCAL_MODULE_CLASS := ETC)\
+$(eval LOCAL_MODULE_TAGS := optional)\
+$(eval LOCAL_MODULE_PATH := $(TARGET_OUT)/usr/hyphen-data)\
+$(eval LOCAL_LICENSE_KINDS := SPDX-license-identifier-MIT SPDX-license-identifier-BSD-3-Clause SPDX-license-identifier-FSFAP SPDX-license-identifier-Unicode-DFS SPDX-license-identifier-LGPL-2.1 SPDX-license-identifier-MPL)\
+$(eval LOCAL_LICENSE_CONDITIONS := notice reciprocal restricted)\
+$(eval LOCAL_NOTICE_FILE := $(wildcard $(addprefix $(LOCAL_PATH)/$(1), /NOTICE /LICENSE)))\
+$(eval include $(BUILD_PREBUILT))
+endef
+
+$(foreach l, $(pattern_locales), $(call build-one-pattern-module,$(dir $(l)),$(notdir $l)))
+build-one-pattern-module :=
+pattern_locales :=
+
+endif #TARGET_BUILD_PDK
diff --git a/patterns.mk b/patterns.mk
index cf07a00..6a41de5 100644
--- a/patterns.mk
+++ b/patterns.mk
@@ -71,6 +71,7 @@
     uk \
     und-ethi
 
-PRODUCT_PACKAGES := hyph-data
+PRODUCT_PACKAGES := $(addprefix hyph-,$(pattern_locales)) \
+    $(addsuffix .lic.txt,$(addprefix hyph-,$(pattern_locales)))
 
 pattern_locales :=