Change in osmo-dev[master]: gen_makefile.py: add --auto-distclean

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

osmith gerrit-no-reply at lists.osmocom.org
Mon Oct 11 06:14:54 UTC 2021


osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-dev/+/25738 )


Change subject: gen_makefile.py: add --auto-distclean
......................................................................

gen_makefile.py: add --auto-distclean

Add a new option that avoids stopping the build with:
  configure: error: source directory already configured; run "make distclean" there first

I run into this frequently, when e.g. running './configure; make release'
inside Osmocom repositories and then attempting to build them with
osmo-dev. It is annoying as it does not fail immediatelly, and I need to
manually go to the source directories where it failed, run 'make
distclean' and then attempt to build again. Then it may fail on another
directory with the same problem.

Check for config.status, as that is also what ./configure checks for
before printing the error.

Change-Id: Iac71333e8c5da8dee4e8f34e2af8db12d2c08021
---
M gen_makefile.py
1 file changed, 16 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/38/25738/1

diff --git a/gen_makefile.py b/gen_makefile.py
index 5fa3e26..58d6024 100755
--- a/gen_makefile.py
+++ b/gen_makefile.py
@@ -107,6 +107,9 @@
 parser.add_argument('--docker-cmd',
     help='''prefix configure/make/make install calls with this command (used by ttcn3.sh)''')
 
+parser.add_argument('-a', '--auto-distclean', action='store_true',
+    help='''run "make distclean" automatically if source directory already configured''')
+
 args = parser.parse_args()
 
 class listdict(dict):
@@ -190,6 +193,7 @@
 	touch $@
 
 .make.{proj}.autoconf: .make.{proj}.clone {src_proj}/configure.ac
+	if {distclean_cond}; then $(MAKE) {proj}-distclean; fi
 	@echo -e "\n\n\n===== $@\n"
 	-rm -f {src_proj}/.version
 	cd {src_proj}; autoreconf -fi
@@ -197,6 +201,7 @@
 	touch $@
 	
 .make.{proj}.configure: .make.{proj}.autoconf {deps_installed} $({proj}_configure_files)
+	if {distclean_cond}; then $(MAKE) {proj}-distclean .make.{proj}.autoconf; fi
 	@echo -e "\n\n\n===== $@\n"
 	-chmod -R ug+w {build_proj}
 	-rm -rf {build_proj}
@@ -206,6 +211,7 @@
 	touch $@
 
 .make.{proj}.build: .make.{proj}.configure $({proj}_files)
+	if {distclean_cond}; then $(MAKE) {proj}-distclean .make.{proj}.configure; fi
 	@echo -e "\n\n\n===== $@\n"
 	{docker_cmd}$(MAKE) -C {build_proj} -j {jobs} {check}
 	sync
@@ -231,6 +237,12 @@
 	-chmod -R ug+w {build_proj}
 	-rm -rf {build_proj}
 	-rm -rf .make.{proj}.*
+
+.PHONY: {proj}-distclean
+{proj}-distclean: {proj}-clean
+	@echo -e "\n\n\n===== $@\n"
+	$(MAKE) -C {src_proj} distclean
+
 '''.format(
     url=url,
     push_url=push_url or url,
@@ -248,6 +260,7 @@
     sudo_ldconfig='' if ldconfig_without_sudo else 'sudo ',
     check='check' if make_check else '',
     docker_cmd=f'{args.docker_cmd} ' if args.docker_cmd else '',
+    distclean_cond=f'[ -e {make_to_src_proj}/config.status ]' if args.auto_distclean else 'false'
     )
 
 
@@ -324,7 +337,7 @@
 		-o {makefile} \
 		-s {src_dir} \
 		-b {build_dir} \
-		-u "{url}"{push_url}{sudo_make_install}{no_ldconfig}{ldconfig_without_sudo}{make_check}{docker_cmd}
+		-u "{url}"{push_url}{sudo_make_install}{no_ldconfig}{ldconfig_without_sudo}{make_check}{docker_cmd}{auto_distclean}
 
 '''.format(
     script=os.path.relpath(sys.argv[0], make_dir),
@@ -339,7 +352,8 @@
     no_ldconfig=' \\\n\t\t-L' if args.no_ldconfig else '',
     ldconfig_without_sudo=' \\\n\t\t--ldconfig-without-sudo' if args.ldconfig_without_sudo else '',
     make_check='' if args.make_check else " \\\n\t\t--no-make-check",
-    docker_cmd=f' \\\n\t\t--docker-cmd "{args.docker_cmd}"' if args.docker_cmd else ''
+    docker_cmd=f' \\\n\t\t--docker-cmd "{args.docker_cmd}"' if args.docker_cmd else '',
+    auto_distclean=' \\\n\t\t--auto-distclean' if args.auto_distclean else ''
     ))
 
   # convenience target: clone all repositories first

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

Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-Change-Id: Iac71333e8c5da8dee4e8f34e2af8db12d2c08021
Gerrit-Change-Number: 25738
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211011/18c5c27d/attachment.htm>


More information about the gerrit-log mailing list