make: add support for "mobile" from osmocom-bb

Allow building and installing the "mobile" application from
osmocom-bb.git's src/host/layer23 dir.

Change-Id: Ic75cca703e317eaee593b4d6c78784309c056f17
This commit is contained in:
Oliver Smith 2022-02-22 17:36:11 +01:00
parent 107f35d3da
commit 93bd52300e
2 changed files with 43 additions and 12 deletions

View File

@ -30,3 +30,7 @@ osmo-upf libosmocore libgtpnl
# can only clone these # can only clone these
docker-playground docker-playground
osmo-ttcn3-hacks osmo-ttcn3-hacks
osmocom-bb
# configure.ac not in topdir of repository
osmocom-bb_layer23 libosmocore

View File

@ -154,16 +154,35 @@ def read_configure_opts(path):
return {} return {}
return dict(read_projects_deps(path)) return dict(read_projects_deps(path))
def gen_makefile_clone(proj, src, src_proj, url, push_url):
if proj == "osmocom-bb_layer23":
return f'''
.make.{proj}.clone: .make.osmocom-bb.clone
@echo -e "\\n\\n\\n===== $@\\n"
test -L {src_proj} || ln -s osmocom-bb/src/host/layer23 {src_proj}
touch $@
'''
return f'''
.make.{proj}.clone:
@echo -e "\\n\\n\\n===== $@\\n"
test -d {src} || mkdir -p {src}
test -d {src_proj} || ( git -C {src} clone "{url}/{proj}" "{proj}" && git -C "{src}/{proj}" remote set-url --push origin "{push_url}/{proj}" )
sync
touch $@
'''
def gen_make(proj, deps, configure_opts, jobs, make_dir, src_dir, build_dir, url, push_url, sudo_make_install, no_ldconfig, ldconfig_without_sudo, make_check): def gen_make(proj, deps, configure_opts, jobs, make_dir, src_dir, build_dir, url, push_url, sudo_make_install, no_ldconfig, ldconfig_without_sudo, make_check):
src_proj = os.path.join(src_dir, proj) src_proj = os.path.join(src_dir, proj)
if proj == 'openbsc': if proj == 'openbsc':
src_proj = os.path.join(src_proj, 'openbsc') src_proj = os.path.join(src_proj, 'openbsc')
build_proj = os.path.join(build_dir, proj) build_proj = os.path.join(build_dir, proj)
make_to_src = os.path.relpath(src_dir, make_dir) src = os.path.relpath(src_dir, make_dir)
make_to_src_proj = os.path.relpath(src_proj, make_dir) src_proj = os.path.relpath(src_proj, make_dir)
make_to_build_proj = os.path.relpath(build_proj, make_dir) make_to_build_proj = os.path.relpath(build_proj, make_dir)
build_to_src = os.path.relpath(src_proj, build_proj) build_to_src = os.path.relpath(src_proj, build_proj)
push_url = push_url or url
if configure_opts: if configure_opts:
configure_opts_str = ' '.join(configure_opts) configure_opts_str = ' '.join(configure_opts)
@ -188,12 +207,7 @@ def gen_make(proj, deps, configure_opts, jobs, make_dir, src_dir, build_dir, url
\) \ \) \
-and -not -name "config.h" 2>/dev/null) -and -not -name "config.h" 2>/dev/null)
.make.{proj}.clone: {clone_rule}
@echo -e "\n\n\n===== $@\n"
test -d {src} || mkdir -p {src}
test -d {src_proj} || ( git -C {src} clone "{url}/{proj}" "{proj}" && git -C "{src}/{proj}" remote set-url --push origin "{push_url}/{proj}" )
sync
touch $@
.make.{proj}.autoconf: .make.{proj}.clone {src_proj}/configure.ac .make.{proj}.autoconf: .make.{proj}.clone {src_proj}/configure.ac
if {distclean_cond}; then $(MAKE) {proj}-distclean; fi if {distclean_cond}; then $(MAKE) {proj}-distclean; fi
@ -248,13 +262,14 @@ def gen_make(proj, deps, configure_opts, jobs, make_dir, src_dir, build_dir, url
'''.format( '''.format(
url=url, url=url,
push_url=push_url or url, push_url=push_url,
proj=proj, proj=proj,
jobs=jobs, jobs=jobs,
src=make_to_src, src=src,
src_proj=make_to_src_proj, src_proj=src_proj,
build_proj=make_to_build_proj, build_proj=make_to_build_proj,
build_to_src=build_to_src, build_to_src=build_to_src,
clone_rule=gen_makefile_clone(proj, src, src_proj, url, push_url),
deps_installed=' '.join(['.make.%s.install' % d for d in deps]), deps_installed=' '.join(['.make.%s.install' % d for d in deps]),
deps_reinstall=' '.join(['%s-reinstall' %d for d in deps]), deps_reinstall=' '.join(['%s-reinstall' %d for d in deps]),
configure_opts=configure_opts_str, configure_opts=configure_opts_str,
@ -264,7 +279,7 @@ def gen_make(proj, deps, configure_opts, jobs, make_dir, src_dir, build_dir, url
check='check' if make_check else '', check='check' if make_check else '',
docker_cmd=f'{args.docker_cmd} ' if args.docker_cmd else '', docker_cmd=f'{args.docker_cmd} ' if args.docker_cmd else '',
cflags='CFLAGS=-g ' if args.build_debug else '', cflags='CFLAGS=-g ' if args.build_debug else '',
distclean_cond=f'[ -e {make_to_src_proj}/config.status ]' if args.auto_distclean else 'false' distclean_cond=f'[ -e {src_proj}/config.status ]' if args.auto_distclean else 'false'
) )
@ -305,6 +320,9 @@ with open(output, 'w') as out:
out.write(r''' out.write(r'''
default: usrp default: usrp
#
# Convenience targets for whole networks
#
.PHONY: cn .PHONY: cn
cn: \ cn: \
osmo-ggsn \ osmo-ggsn \
@ -330,6 +348,15 @@ usrp: \
osmo-trx \ osmo-trx \
$(NULL) $(NULL)
#
# Convenience targets for components in subdirs of repositories
#
.PHONY: mobile
mobile: osmocom-bb_layer23
#
# Other convenience targets
#
.PHONY: all_debug .PHONY: all_debug
all_debug: all_debug:
$(MAKE) --dry-run -d all | grep "is newer than target" $(MAKE) --dry-run -d all | grep "is newer than target"