commit:     f96ec2c52aba64d486ad54327cf245eeda097a41
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 26 17:14:19 2025 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Sep 26 17:14:58 2025 +0000
URL:        
https://gitweb.gentoo.org/proj/blas-lapack-aux-wrapper.git/commit/?id=f96ec2c5

Convert into a meson package generator

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .gitignore     |  2 ++
 Makefile       | 61 +++++++++++++++++++++++++++++++++++++++++++++
 meson.build    | 78 ----------------------------------------------------------
 meson.build.in | 36 +++++++++++++++++++++++++++
 meson.options  | 11 +--------
 5 files changed, 100 insertions(+), 88 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d5fb613
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/blas-lapack-aux-wrapper-*
+*.tar.xz

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..60d940b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,61 @@
+FLEXIBLAS_DIR ?= $(error Specify FLEXIBLAS_DIR as path to FlexiBLAS sourcess)
+VERSION ?= $(error Specify VERSION as package version)
+LAPACK_VER ?= $(error Specify LAPACK_VER as LAPACK API version)
+
+CP = cp
+MKDIR_P = mkdir -p
+PYTHON ?= python
+RM_F = rm -f
+SED = sed
+TAR_CF = tar -c -f
+XZ = xz -9 -e -f
+
+PKG = blas-lapack-aux-wrapper-$(VERSION)
+PKGTAR = $(PKG).tar
+PKGTARXZ = $(PKGTAR).xz
+OUTPUT = $(PKG)/meson.build
+OUTPUT += $(PKG)/meson.options
+OUTPUT += $(PKG)/COPYING
+OUTPUT += $(PKG)/blas.o
+OUTPUT += $(PKG)/cblas.o
+OUTPUT += $(PKG)/lapack.o
+OUTPUT += $(PKG)/lapacke.o
+
+.PHONY: all clean
+
+all: $(PKG).tar.xz
+
+clean:
+       $(RM_F) $(OUTPUT) $(PKGTAR) $(PKGTARXZ)
+
+$(PKGTAR): $(OUTPUT)
+       $(TAR_CF) $@ $^
+
+$(PKGTARXZ): $(PKGTAR)
+       $(XZ) $<
+
+$(PKG)/meson.build: meson.build.in
+       $(MKDIR_P) $(PKG)
+       $(SED) -e 's:@VERSION@:$(VERSION):' -e 's:@LAPACK_VER@:$(LAPACK_VER):' 
$< > $@
+
+$(PKG)/meson.options: meson.options
+       $(CP) $< $@
+
+$(PKG)/COPYING: COPYING
+       $(CP) $< $@
+
+$(PKG)/blas.o: $(FLEXIBLAS_DIR)/tools/codegen/blas/yaml.yaml
+       $(MKDIR_P) $(PKG)
+       $(PYTHON) blas-lapack-aux-gen.py --fortran $< > $@
+
+$(PKG)/cblas.o: $(FLEXIBLAS_DIR)/tools/codegen/cblas/yaml.yaml
+       $(MKDIR_P) $(PKG)
+       $(PYTHON) blas-lapack-aux-gen.py $< > $@
+
+$(PKG)/lapack.o: $(FLEXIBLAS_DIR)/tools/codegen/lapack/yaml/$(LAPACK_VER).yaml
+       $(MKDIR_P) $(PKG)
+       $(PYTHON) blas-lapack-aux-gen.py --fortran $< > $@
+
+$(PKG)/lapacke.o: 
$(FLEXIBLAS_DIR)/tools/codegen/lapacke/yaml/$(LAPACK_VER).yaml
+       $(MKDIR_P) $(PKG)
+       $(PYTHON) blas-lapack-aux-gen.py $< > $@

diff --git a/meson.build b/meson.build
deleted file mode 100644
index 87161f7..0000000
--- a/meson.build
+++ /dev/null
@@ -1,78 +0,0 @@
-project(
-  'blas-lapack-aux-wrapper',
-  'c',
-  license : 'GPL-2.0-or-later',
-  meson_version : '>=1.1',
-  version : '0',
-)
-
-flexiblas_dir = get_option('flexiblas_dir')
-if flexiblas_dir == ''
-  error('Please set flexiblas_dir to FlexiBLAS source tree')
-endif
-lapack_ver = get_option('lapack_ver')
-if lapack_ver == ''
-  error('Please set lapack_ver to LAPACK API version')
-endif
-
-fs = import('fs')
-pkg = import('pkgconfig')
-py = import('python').find_installation()
-
-sover = get_option('soversion')
-
-suffixes = ['']
-if get_option('ilp64')
-  suffixes += ['64']
-endif
-
-libs = {
-  'blas' : 'blas/yaml.yaml',
-  'cblas' : 'cblas/yaml.yaml',
-  'lapack' : f'lapack/yaml/@[email protected]',
-  'lapacke' : f'lapacke/yaml/@[email protected]',
-}
-fortran_libs = ['blas', 'lapack']
-ldscripts = {}
-
-foreach lib, source : libs
-  cmd = [
-    py,
-    '@SOURCE_ROOT@/blas-lapack-aux-gen.py',
-    '@INPUT@',
-  ]
-  if lib in fortran_libs
-    cmd += ['--fortran']
-  endif
-
-  ldscript = custom_target(
-    f'@lib@-ldscript',
-    input : [f'@flexiblas_dir@/tools/codegen/@source@'],
-    # Note: we're naming the output .o, so that meson doesn't ignore it
-    # as unknown file.  Sigh.
-    output : [f'@[email protected]'],
-    capture : true,
-    command : cmd,
-  )
-  ldscripts += {lib : ldscript}
-endforeach
-
-foreach suffix : suffixes
-  # TODO: get proper prefix and suffix?
-  flexiblas_lib = f'libflexiblas@[email protected].@sover@'
-
-  foreach lib, _ : libs
-    lib_tgt = shared_library(
-      f'@lib@@suffix@',
-      ldscripts[lib],
-      soversion : sover,
-      link_args : [f'-Wl,--auxiliary,@flexiblas_lib@'],
-      install : true,
-    )
-
-    pkg.generate(
-      lib_tgt,
-      description : f'@lib@@suffix@ wrapper for FlexiBLAS',
-    )
-  endforeach
-endforeach

diff --git a/meson.build.in b/meson.build.in
new file mode 100644
index 0000000..37cfca0
--- /dev/null
+++ b/meson.build.in
@@ -0,0 +1,36 @@
+project(
+  'blas-lapack-aux-wrapper',
+  'c',
+  license : 'GPL-2.0-or-later',
+  version : '@VERSION@',
+)
+
+pkg = import('pkgconfig')
+lapack_ver = '@LAPACK_VER@'
+sover = lapack_ver.split('.')[0]
+
+suffixes = ['']
+if get_option('ilp64')
+  suffixes += ['64']
+endif
+
+foreach suffix : suffixes
+  # TODO: get proper prefix and suffix?
+  flexiblas_lib = f'libflexiblas@[email protected].@sover@'
+
+  foreach lib : ['blas', 'cblas', 'lapack', 'lapacke']
+    lib_tgt = shared_library(
+      f'@lib@@suffix@',
+      objects : [f'@[email protected]'],
+      soversion : sover,
+      link_args : [f'-Wl,--auxiliary,@flexiblas_lib@'],
+      install : true,
+    )
+
+    pkg.generate(
+      lib_tgt,
+      version : lapack_ver,
+      description : f'@lib@@suffix@ wrapper for FlexiBLAS',
+    )
+  endforeach
+endforeach

diff --git a/meson.options b/meson.options
index f76a0da..9429857 100644
--- a/meson.options
+++ b/meson.options
@@ -1,13 +1,4 @@
-option('flexiblas_dir',
-       type : 'string',
-       description : 'Path to FlexiBLAS source tree')
-option('lapack_ver',
-       type : 'string',
-       description : 'LAPACK API version')
-option('soversion',
-       type : 'string',
-       value : '3',
-       description : 'SOVERSION to use')
 option('ilp64',
        type : 'boolean',
+       value : false,
        description : 'Whether to build ILP64 libraries as well')

Reply via email to