fixeria has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-dev/+/40770?usp=email )

Change subject: gen_makefile: support new Osmocom erlang makefiles
......................................................................

gen_makefile: support new Osmocom erlang makefiles

osmo-s1gw has a new install target that creates a complete release
package instead of running escriptize, which means different files will
need to be installed. From now on let's call the "install" target in the
Makefile if it exists.

Other erlang projects that osmo-dev supports:
* osmo-dia2gsup: "make install" works after adjusting it to support
  REBAR_BASE_DIR (see patch mentioned below).
* osmo-epdg: doesn't have an "install" target in the Makefile yet, so it
  will use the existing logic.

Depends: osmo-s1gw I5681ca103daf1c497218b4513b0ca97b1aae03d3
Depends: osmo-dia2gsup I9511341bced7d658eacb34250569dfbfe37c084c
Change-Id: I92d6fc6eb5a11068d4b3baca55dfb3abdedbbbf1
---
M gen_makefile.py
1 file changed, 18 insertions(+), 5 deletions(-)

Approvals:
  fixeria: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/gen_makefile.py b/gen_makefile.py
index a118392..e06dbd2 100755
--- a/gen_makefile.py
+++ b/gen_makefile.py
@@ -340,7 +340,7 @@
   else:
     assert False, f"unknown buildsystem: {buildsystem}"

-def gen_makefile_install(proj, build_proj):
+def gen_makefile_install(proj, build_proj, src_proj):
   no_ldconfig = '#' if args.no_ldconfig else ''
   sudo_ldconfig = '' if args.ldconfig_without_sudo else 'sudo '
   sudo_make_install = "sudo " if args.sudo_make_install else ""
@@ -364,12 +364,24 @@
   touch $@
     '''
   elif buildsystem == "erlang":
+    # Use the "install" target if it exists, otherwise fall back to installing
+    # files generated by escriptize in default/bin. The fallback method can be
+    # removed once osmo-epdg has an install target.
     return f'''
 .make.{proj}.install: .make.{proj}.build
   @echo "\\n\\n\\n===== $@\\n"
-  for i in {build_proj}/default/bin/*; do \\
-    install -v -Dm755 "$$i" -t {shlex.quote(args.install_prefix)}/bin/; \\
-  done
+  set -ex; \\
+    if grep -q "^install:" {shlex.quote(src_proj)}/Makefile; then \\
+      {sudo_make_install}$(MAKE) \\
+        -C {shlex.quote(src_proj)} \\
+        install \\
+        DESTDIR={shlex.quote(args.install_prefix)} \\
+        REBAR_BASE_DIR="$$PWD"/{shlex.quote(build_proj)}; \\
+    else \\
+      for i in {build_proj}/default/bin/*; do \\
+        install -v -Dm755 "$$i" -t {shlex.quote(args.install_prefix)}/bin/; \\
+      done; \\
+    fi
   sync
   touch $@
     '''
@@ -486,7 +498,8 @@
                     update_src_copy_cmd)}

 {gen_makefile_install(proj,
-                      build_proj)}
+                      build_proj,
+                      src_proj)}

 {gen_makefile_reinstall(proj,
                         deps_reinstall,

--
To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/40770?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-Change-Id: I92d6fc6eb5a11068d4b3baca55dfb3abdedbbbf1
Gerrit-Change-Number: 40770
Gerrit-PatchSet: 2
Gerrit-Owner: osmith <osm...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>

Reply via email to