Skip to content

Commit 2363cc1

Browse files
committed
Added meson build system.
1 parent f3cd41a commit 2363cc1

File tree

7 files changed

+202
-0
lines changed

7 files changed

+202
-0
lines changed

configure/install-mod.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python3
2+
3+
from os import environ, listdir, makedirs
4+
from os.path import join, isdir, exists
5+
from sys import argv
6+
from shutil import copy
7+
8+
build_dir = environ["MESON_BUILD_ROOT"]
9+
if "MESON_INSTALL_DESTDIR_PREFIX" in environ:
10+
install_dir = environ["MESON_INSTALL_DESTDIR_PREFIX"]
11+
else:
12+
install_dir = environ["MESON_INSTALL_PREFIX"]
13+
14+
include_dir = argv[1] if len(argv) > 1 else "include"
15+
module_dir = join(install_dir, include_dir)
16+
17+
modules = []
18+
for d in listdir(build_dir):
19+
bd = join(build_dir, d)
20+
if isdir(bd):
21+
for f in listdir(bd):
22+
if f.endswith(".mod"):
23+
modules.append(join(bd, f))
24+
25+
if not exists(module_dir):
26+
makedirs(module_dir)
27+
28+
for mod in modules:
29+
print("Installing", mod, "to", module_dir)
30+
copy(mod, module_dir)

configure/meson.build

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
os = host_machine.system()
2+
fc = meson.get_compiler('fortran')
3+
cc = fc
4+
fc_id = fc.get_id()
5+
6+
if fc_id == 'gcc'
7+
add_project_arguments(
8+
'-ffree-line-length-none',
9+
'-fbacktrace',
10+
language: 'fortran',
11+
)
12+
elif fc_id == 'intel'
13+
add_project_arguments(
14+
'-traceback',
15+
language: 'fortran',
16+
)
17+
elif fc_id == 'pgi' or fc_id == 'nvidia_hpc'
18+
add_project_arguments(
19+
'-Mbackslash',
20+
'-Mallocatable=03',
21+
'-traceback',
22+
language: 'fortran',
23+
)
24+
endif

meson.build

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
project(
2+
'fftpack',
3+
'fortran',
4+
version: '4.0.0',
5+
meson_version: '>=0.57',
6+
default_options: [
7+
'buildtype=debugoptimized',
8+
'default_library=both',
9+
'c_std=c11',
10+
],
11+
)
12+
13+
install = not (meson.is_subproject() and get_option('default_library') == 'static')
14+
15+
# Collect source of the project
16+
srcs = []
17+
subdir('src')
18+
19+
# General configuration information
20+
inc_dirs = []
21+
lib_deps = []
22+
subdir('configure')
23+
24+
# Library target
25+
fftpack_lib = library(
26+
meson.project_name(),
27+
sources: srcs,
28+
version: meson.project_version(),
29+
dependencies: lib_deps,
30+
include_directories: inc_dirs,
31+
install: install,
32+
)
33+
34+
# Export dependency for other projects and test suite
35+
fftpack_dep = declare_dependency(
36+
link_with: fftpack_lib,
37+
dependencies: lib_deps,
38+
variables: {'includedir': meson.current_source_dir() / 'include'},
39+
)
40+
41+
# add the testsuite
42+
subdir('test')
43+
44+
if install
45+
module_id = meson.project_name() / fc_id + '-' + fc.version()
46+
meson.add_install_script(
47+
find_program(files('configure'/'install-mod.py')),
48+
get_option('includedir') / module_id,
49+
)
50+
51+
pkg = import('pkgconfig')
52+
pkg.generate(
53+
fftpack_lib,
54+
description: 'fftpack',
55+
subdirs: ['', module_id],
56+
)
57+
endif

src/meson.build

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
srcs += files(
2+
'cfftb1.f90',
3+
'dsinqi.f90',
4+
'fftpack_utils.f90',
5+
'radbg.f90',
6+
'cfftf1.f90',
7+
'dsint.f90',
8+
'passb2.f90',
9+
'radf2.f90',
10+
'cffti1.f90',
11+
'dsinti.f90',
12+
'passb3.f90',
13+
'radf3.f90',
14+
'cosqb1.f90',
15+
'dzfftb.f90',
16+
'passb4.f90',
17+
'radf4.f90',
18+
'cosqf1.f90',
19+
'dzfftf.f90',
20+
'passb5.f90',
21+
'radf5.f90',
22+
'dcosqb.f90',
23+
'dzffti.f90',
24+
'passb.f90',
25+
'radfg.f90',
26+
'dcosqf.f90',
27+
'ezfft1.f90',
28+
'passf2.f90',
29+
'rfftb1.f90',
30+
'dcosqi.f90',
31+
'fftpack_dct.f90',
32+
'passf3.f90',
33+
'rfftf1.f90',
34+
'dcost.f90',
35+
'fftpack.f90',
36+
'passf4.f90',
37+
'rffti1.f90',
38+
'dcosti.f90',
39+
'fftpack_fft.f90',
40+
'passf5.f90',
41+
'rk.f90',
42+
'dfftb.f90',
43+
'fftpack_fftshift.f90',
44+
'passf.f90',
45+
'sint1.f90',
46+
'dfftf.f90',
47+
'fftpack_ifft.f90',
48+
'radb2.f90',
49+
'zfftb.f90',
50+
'dffti.f90',
51+
'fftpack_ifftshift.f90',
52+
'radb3.f90',
53+
'zfftf.f90',
54+
'dsinqb.f90',
55+
'fftpack_irfft.f90',
56+
'radb4.f90',
57+
'zffti.f90',
58+
'dsinqf.f90',
59+
'fftpack_rfft.f90',
60+
'radb5.f90'
61+
)

subprojects/test-drive

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 9c3401e30dbd2da1add77aaa252a4c6928fe39a1

subprojects/test-drive.wrap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[wrap-git]
2+
directory = test-drive
3+
url = https://github.com/fortran-lang/test-drive
4+
revision = v0.4.0

test/meson.build

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
testdrive_dep = dependency('test-drive', fallback: ['test-drive', 'testdrive_dep'])
2+
3+
tests = [
4+
'fft',
5+
'rfft',
6+
'dct',
7+
'utils'
8+
]
9+
10+
test_srcs = files(
11+
'test_fftpack.f90'
12+
)
13+
foreach t : tests
14+
test_srcs += files('test_fftpack_@[email protected]'.format(t.underscorify()))
15+
endforeach
16+
17+
tester = executable(
18+
'tester',
19+
sources: test_srcs,
20+
dependencies: [fftpack_dep, testdrive_dep]
21+
)
22+
23+
foreach t : tests
24+
test(t, tester, args: t)
25+
endforeach

0 commit comments

Comments
 (0)