Skip to content

Commit b4a1f0a

Browse files
authored
Merge pull request #2 from hmenke/libtool
Add support for libtool to build shared libraries
2 parents 9c584e7 + 0d498da commit b4a1f0a

20 files changed

+267
-163
lines changed

.github/workflows/linux.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Linux
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
11+
- name: Add historical Ubuntu repository for robodoc
12+
run: |
13+
# Ubuntu 11.10 (Oneiric Ocelot) is the last release to contain robodoc
14+
# The keys are long expired, so we need to use [trusted=yes]
15+
echo "deb [trusted=yes] http://old-releases.ubuntu.com/ubuntu/ oneiric universe" | sudo tee /etc/apt/sources.list.d/precise.list
16+
sudo apt-get update
17+
18+
- name: Install dependencies
19+
run: >-
20+
sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y
21+
build-essential
22+
autoconf
23+
automake
24+
libtool
25+
gcc
26+
gfortran
27+
libnetcdff-dev
28+
python-is-python3
29+
robodoc
30+
31+
- name: Configure etsf-io
32+
run: |
33+
bash -e autogen.sh
34+
mkdir build/
35+
cd build/
36+
../configure
37+
make -j V=1
38+
env:
39+
FFLAGS: "-O0 -g3 -fno-omit-frame-pointer -fsanitize=address"
40+
LDFLAGS: "-fsanitize=address"
41+
42+
- name: Compile etsf-io
43+
working-directory: build/
44+
run: |
45+
make -j V=1
46+
47+
- name: Test etsf-io
48+
working-directory: build/
49+
run: |
50+
make -j check V=1
51+
52+
- uses: actions/upload-artifact@v4
53+
if: always()
54+
with:
55+
path: build/config.log

.github/workflows/macos.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: macOS
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
runs-on: macos-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
11+
- name: Install dependencies
12+
run: >-
13+
brew install
14+
autoconf
15+
automake
16+
libtool
17+
gcc@14
18+
netcdf-fortran
19+
pkg-config
20+
robodoc
21+
22+
- name: Add gnubin to PATH
23+
run: |
24+
echo PATH="/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" >> $GITHUB_ENV
25+
echo FC=gfortran-14 >> $GITHUB_ENV
26+
27+
- name: Configure etsf-io
28+
run: |
29+
mkdir src/group_level/
30+
bash -e autogen.sh
31+
mkdir build/
32+
cd build/
33+
../configure --with-netcdf-incs="$(pkg-config --cflags netcdf-fortran)" --with-netcdf-libs="$(pkg-config --libs netcdf-fortran)"
34+
env:
35+
FFLAGS: "-O0 -g3 -fno-omit-frame-pointer -fsanitize=address"
36+
LDFLAGS: "-fsanitize=address"
37+
38+
- name: Compile etsf-io
39+
working-directory: build/
40+
run: |
41+
make -j V=1
42+
43+
# - name: Test etsf-io
44+
# working-directory: build/
45+
# run: |
46+
# make -j check V=1
47+
48+
- uses: actions/upload-artifact@v4
49+
if: always()
50+
with:
51+
path: build/config.log

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Build-system files
2+
/aclocal.m4
3+
/autom4te.cache/
4+
/configure
5+
/configure~
6+
/config/gnu/
7+
/config/m4/libtool.m4
8+
/config/m4/ltoptions.m4
9+
/config/m4/ltsugar.m4
10+
/config/m4/ltversion.m4
11+
/config/m4/lt~obsolete.m4
12+
Makefile.in
13+
14+
# Generated source files
15+
/src/group_level/
16+
/src/low_level/read_routines_auto.f90
17+
/src/low_level/write_routines_auto.f90
18+
/src/utils/Makefile.am
19+
/src/utils/etsf_io_file.f90
20+
/src/utils/etsf_io_file_check_crystallographic_data.f90
21+
/src/utils/etsf_io_file_check_dielectric_function_data.f90
22+
/src/utils/etsf_io_file_check_scalar_field_data.f90
23+
/src/utils/etsf_io_file_check_wavefunctions_data.f90
24+
/src/utils/etsf_io_file_contents.f90
25+
26+
# Generated tests
27+
/tests/group_level/tests_copy.f90
28+
/tests/group_level/tests_init.f90
29+
/tests/group_level/tests_read.f90
30+
/tests/group_level/tests_write.f90
31+
32+
# Documentation
33+
/robodoc.log

autogen.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ echo
2222
echo "== Generate build system =="
2323
echo "Listing known macro with 'aclocal'."
2424
aclocal -I config/m4
25+
echo "Prepare package to use libtool."
26+
libtoolize
2527
echo "Creating configure script with 'autoconf'."
2628
autoconf
2729
echo "Creating required files for autotools."

config/etsf/template.Makefile.am

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
lib_LIBRARIES = libetsf_io.a
1+
lib_LTLIBRARIES = libetsf_io.la
22

33
EXTRA_DIST = \
44
@INCLUDED_FILES@
@@ -19,13 +19,13 @@ endif
1919

2020
AM_FCFLAGS = -I$(top_builddir)/src/low_level -I$(srcdir) @NETCDF_INCLUDES@
2121

22-
libetsf_io_a_SOURCES = etsf_io.f90
22+
libetsf_io_la_SOURCES = etsf_io.f90
2323

24-
libetsf_io_a_LIBADD = $(top_builddir)/src/low_level/etsf_io_low_level.o \
24+
libetsf_io_la_LIBADD = $(top_builddir)/src/low_level/libetsf_io_low_level.la \
2525
$(NETCDF_WRAPPERS)
2626

2727
#dependencies
28-
etsf_io.o: etsf_io.f90 \
28+
$(libetsf_io_la_OBJECTS): etsf_io.f90 \
2929
@INCLUDED_FILES@
3030

31-
ETSF_IO.@MODULE_EXT@ etsf_io.@MODULE_EXT@: etsf_io.o
31+
ETSF_IO.@MODULE_EXT@ etsf_io.@MODULE_EXT@: $(libetsf_io_la_OBJECTS)
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
vpath %.a $(top_builddir)/src/group_level
1+
vpath %.la $(top_builddir)/src/group_level
22

33
bin_PROGRAMS = etsf_io
44

5-
lib_LIBRARIES = libetsf_io_utils.a
5+
lib_LTLIBRARIES = libetsf_io_utils.la
66

77
EXTRA_DIST = \
88
@SPEC_CHECK_LIST@
@@ -20,27 +20,25 @@ CLEANFILES = $(module_DATA)
2020

2121
AM_FCFLAGS = -I$(top_builddir)/src/low_level -I$(top_builddir)/src/group_level @NETCDF_INCLUDES@
2222

23-
libetsf_io_utils_a_SOURCES = etsf_io_file.f90 \
23+
libetsf_io_utils_la_SOURCES = etsf_io_file.f90 \
2424
etsf_io_tools.f90
2525

2626
etsf_io_SOURCES = etsf_io.f90
2727
etsf_io_LDFLAGS = -L$(top_builddir)/src/group_level -L.
28-
etsf_io_LDADD = -letsf_io_utils -letsf_io
28+
etsf_io_LDADD = libetsf_io_utils.la $(top_builddir)/src/group_level/libetsf_io.la
2929

3030

3131
#dependencies
32-
etsf_io_file.o: libetsf_io.a \
32+
$(libetsf_io_utils_la_OBJECTS): libetsf_io.la \
3333
@SPEC_CHECK_LIST@
3434
etsf_io_file_contents.f90 \
3535
etsf_io_file_private.f90 \
3636
etsf_io_file_public.f90
3737

38-
etsf_io_tools.o: libetsf_io.a
39-
40-
etsf_io.o: libetsf_io_utils.a
38+
$(etsf_io_OBJECTS): libetsf_io_utils.la
4139

4240
ETSF_IO_FILE.@MODULE_EXT@ etsf_io_file.@MODULE_EXT@: \
43-
etsf_io_file.o
41+
libetsf_io_utils.la
4442

4543
ETSF_IO_TOOLS.@MODULE_EXT@ etsf_io_tools.@MODULE_EXT@: \
46-
etsf_io_tools.o
44+
libetsf_io_utils.la

config/scripts/autogen_low_level.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from time import gmtime,strftime
1212

13-
import commands
13+
import subprocess
1414
import os
1515
import re
1616
import sys
@@ -27,17 +27,17 @@
2727

2828
# Check if we are in the top of the ETSF_IO source tree
2929
if ( not os.path.exists("configure.ac") ):
30-
print "%s: You must be in the top of the library source tree." % my_name
31-
print "%s: Aborting now." % my_name
30+
print("%s: You must be in the top of the library source tree." % my_name)
31+
print("%s: Aborting now." % my_name)
3232
sys.exit(1)
3333

3434
# Read config file(s)
3535
for cnf in my_configs:
3636
if ( os.path.exists(cnf) ):
37-
execfile(cnf)
37+
exec(compile(open(cnf, "rb").read(), cnf, 'exec'))
3838
else:
39-
print "%s: Could not find config file (%s)." % (my_name,cnf)
40-
print "%s: Aborting now." % my_name
39+
print("%s: Could not find config file (%s)." % (my_name,cnf))
40+
print("%s: Aborting now." % my_name)
4141
sys.exit(2)
4242

4343
# This script auto generate the read method for the nD dimensional arrays.
@@ -58,8 +58,8 @@
5858
banner += "!================================================================\n"
5959

6060
# We load the template and replace in it.
61-
var_template = file("config/etsf/template.low_level_var", "r").read()
62-
att_template = file("config/etsf/template.low_level_att", "r").read()
61+
var_template = open("config/etsf/template.low_level_var", "r").read()
62+
att_template = open("config/etsf/template.low_level_att", "r").read()
6363

6464
for (action, tgt_file) in NC_ACTION:
6565
if (action == "read"):
@@ -132,7 +132,7 @@
132132
ret += sub_src + "\n"
133133

134134
# We create the file
135-
out = file("%s/%s_routines_auto.f90" % (etsf_low_level_file_srcdir, action), "w")
135+
out = open("%s/%s_routines_auto.f90" % (etsf_low_level_file_srcdir, action), "w")
136136
out.write(banner + "\n" + ret)
137137
out.close()
138138

@@ -258,7 +258,7 @@
258258
ret += sub_src + "\n"
259259

260260
# We create the file
261-
out = file("%s/%s_routines_auto.f90" % (etsf_low_level_file_srcdir, action), "w")
261+
out = open("%s/%s_routines_auto.f90" % (etsf_low_level_file_srcdir, action), "w")
262262
out.write(banner + "\n" + ret)
263263
out.close()
264264

config/scripts/autogen_module.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from time import gmtime,strftime
1212

13-
import commands
13+
import subprocess
1414
import os
1515
import re
1616
import sys
@@ -30,22 +30,22 @@
3030

3131
# Check if we are in the top of the ETSF_IO source tree
3232
if ( not os.path.exists("configure.ac") ):
33-
print "%s: You must be in the top of the library source tree." % my_name
34-
print "%s: Aborting now." % my_name
33+
print("%s: You must be in the top of the library source tree." % my_name)
34+
print("%s: Aborting now." % my_name)
3535
sys.exit(1)
3636

3737
# Read config file(s)
3838
for cnf in my_configs:
3939
if ( os.path.exists(cnf) ):
40-
execfile(cnf)
40+
exec(compile(open(cnf, "rb").read(), cnf, 'exec'))
4141
else:
42-
print "%s: Could not find config file (%s)." % (my_name,cnf)
43-
print "%s: Aborting now." % my_name
42+
print("%s: Could not find config file (%s)." % (my_name,cnf))
43+
print("%s: Aborting now." % my_name)
4444
sys.exit(2)
4545

4646
# Global attributes
4747
ead = " ! Global attributes"
48-
for att in etsf_attributes.keys():
48+
for att in list(etsf_attributes.keys()):
4949
att_desc = etsf_attributes[att]
5050

5151
if ( att in etsf_properties ):
@@ -236,7 +236,7 @@
236236
ivlf = 0
237237
vlf += " integer, parameter :: etsf_%-30s = 0\n" % "specs_none"
238238
vlf_id = " character(len = *), parameter :: etsf_specs_names(%d) = (/ &\n" % len(etsf_specifications_files)
239-
for id in etsf_specifications_files.keys():
239+
for id in list(etsf_specifications_files.keys()):
240240
vlf += " integer, parameter :: etsf_%-30s = %d\n" % (id, 2 ** ivlf)
241241
vlf_id += " & \"%-25s\", &\n" % id
242242
ivlf += 1
@@ -246,7 +246,7 @@
246246

247247

248248
# Import template
249-
src = file("config/etsf/template.%s" % (etsf_modules["etsf_io"]),"r").read()
249+
src = open("config/etsf/template.%s" % (etsf_modules["etsf_io"]),"r").read()
250250
src = re.sub("@SCRIPT@",my_name,src)
251251
src = re.sub("@CONSTANTS@",ead,src)
252252
src = re.sub("@FLAGS_GROUPS@",egc,src)
@@ -260,6 +260,9 @@
260260
src = re.sub("@SPLIT_NAME_GROUP@",vsn,src)
261261

262262
# Write module
263-
mod = file(etsf_file_module,"w")
263+
etsf_file_srcdir = os.path.dirname(etsf_file_module)
264+
if not os.path.exists(etsf_file_srcdir):
265+
os.mkdir(etsf_file_srcdir)
266+
mod = open(etsf_file_module,"w")
264267
mod.write(src)
265268
mod.close()

0 commit comments

Comments
 (0)