Skip to content

Commit 433ef2f

Browse files
committed
Build dylib libraries and enable Mac CI
1 parent 745d7aa commit 433ef2f

File tree

4 files changed

+120
-13
lines changed

4 files changed

+120
-13
lines changed

.github/workflows/makefile.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,55 @@ jobs:
1414
./configure
1515
rm -f Makefile.local
1616
bmake clean
17+
bmake
1718
bmake regress
1819
- name: Regress with sanitiser
1920
run: |
2021
./configure
2122
echo 'CFLAGS += -fsanitize=undefined,address -fomit-frame-pointer -O0' > Makefile.local
2223
echo 'LDFLAGS += -fsanitize=undefined,address -fomit-frame-pointer -O0' >> Makefile.local
2324
bmake clean
25+
bmake
2426
bmake regress
2527
- name: Regress with valgrind
2628
run: |
2729
./configure
2830
rm -f Makefile.local
2931
bmake clean
32+
bmake
3033
bmake valgrind
3134
- name: Regress with shared
3235
run: |
3336
./configure LINK_METHOD=shared
3437
rm -f Makefile.local
3538
bmake clean
39+
bmake
40+
LD_LIBRARY_PATH="." bmake regress
41+
macos:
42+
runs-on: macos-latest
43+
steps:
44+
- uses: actions/checkout@master
45+
- name: Install dependencies
46+
run: brew install bmake
47+
- name: Regress
48+
run: |
49+
./configure
50+
rm -f Makefile.local
51+
bmake clean
52+
bmake
53+
bmake regress
54+
- name: Regress with sanitiser
55+
run: |
56+
./configure
57+
echo 'CFLAGS += -fsanitize=undefined,address -fomit-frame-pointer -O0' > Makefile.local
58+
echo 'LDFLAGS += -fsanitize=undefined,address -fomit-frame-pointer -O0' >> Makefile.local
59+
bmake clean
60+
bmake
61+
bmake regress
62+
- name: Regress with shared
63+
run: |
64+
./configure LINK_METHOD=shared
65+
rm -f Makefile.local
66+
bmake clean
67+
bmake
3668
LD_LIBRARY_PATH="." bmake regress

Makefile

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ LIB_LOWDOWN = liblowdown.a
150150
MAIN_OBJS =
151151
.ifdef LINK_METHOD
152152
.if $(LINK_METHOD) == "shared"
153-
LIB_LOWDOWN = liblowdown.so
153+
LIB_LOWDOWN = liblowdown.$(LINKER_SOSUFFIX)
154154
MAIN_OBJS = $(COMPAT_OBJS)
155155
.endif
156156
.endif
@@ -177,7 +177,7 @@ REGRESS_ARGS += "--parse-no-deflists"
177177

178178
REGRESS_ENV = LC_ALL=en_US.UTF-8
179179

180-
all: bins lowdown.pc liblowdown.so
180+
all: bins lowdown.pc liblowdown.$(LINKER_SOSUFFIX)
181181
bins: lowdown lowdown-diff
182182

183183
www: all $(HTMLS) $(PDFS) $(THUMBS) lowdown.tar.gz lowdown.tar.gz.sha512
@@ -199,8 +199,9 @@ lowdown-diff: lowdown
199199
liblowdown.a: $(OBJS) $(COMPAT_OBJS)
200200
$(AR) rs $@ $(OBJS) $(COMPAT_OBJS)
201201

202-
liblowdown.so: $(OBJS) $(COMPAT_OBJS)
203-
$(CC) -shared -o $@.$(LIBVER) $(OBJS) $(COMPAT_OBJS) $(LDFLAGS) $(LDADD_MD5) -lm -Wl,${LINKER_SONAME},$@.$(LIBVER) $(LDLIBS)
202+
liblowdown.$(LINKER_SOSUFFIX): $(OBJS) $(COMPAT_OBJS)
203+
$(CC) $(LINKER_SOFLAG) -o $@.$(LIBVER) $(OBJS) $(COMPAT_OBJS) $(LDFLAGS) $(LDADD_MD5) -lm \
204+
-Wl,${LINKER_SONAME},$@.$(LIBVER) $(LDLIBS)
204205
ln -sf $@.$(LIBVER) $@
205206

206207
uninstall:
@@ -256,11 +257,11 @@ install_lib_common: lowdown.pc
256257
done
257258

258259
uninstall_shared: uninstall_lib_common
259-
rm -f $(LIBDIR)/liblowdown.so.$(LIBVER) $(LIBDIR)/liblowdown.so
260+
rm -f $(LIBDIR)/liblowdown.$(LINKER_SOSUFFIX).$(LIBVER) $(LIBDIR)/liblowdown.$(LINKER_SOSUFFIX)
260261

261-
install_shared: liblowdown.so install_lib_common
262-
$(INSTALL_LIB) liblowdown.so.$(LIBVER) $(DESTDIR)$(LIBDIR)
263-
( cd $(DESTDIR)$(LIBDIR) && ln -sf liblowdown.so.$(LIBVER) liblowdown.so )
262+
install_shared: liblowdown.$(LINKER_SOSUFFIX) install_lib_common
263+
$(INSTALL_LIB) liblowdown.$(LINKER_SOSUFFIX).$(LIBVER) $(DESTDIR)$(LIBDIR)
264+
( cd $(DESTDIR)$(LIBDIR) && ln -sf liblowdown.$(LINKER_SOSUFFIX).$(LIBVER) liblowdown.$(LINKER_SOSUFFIX) )
264265

265266
uninstall_static: uninstall_lib_common
266267
rm -f $(LIBDIR)/liblowdown.a
@@ -392,7 +393,8 @@ main.o: lowdown.h
392393

393394
clean:
394395
rm -f $(OBJS) $(COMPAT_OBJS) main.o
395-
rm -f lowdown lowdown-diff liblowdown.a liblowdown.so liblowdown.so.$(LIBVER) lowdown.pc
396+
rm -f lowdown lowdown-diff lowdown.pc
397+
rm -f liblowdown.a liblowdown.$(LINKER_SOSUFFIX) liblowdown.$(LINKER_SOSUFFIX).$(LIBVER)
396398
rm -f index.xml diff.xml diff.diff.xml README.xml lowdown.tar.gz.sha512 lowdown.tar.gz
397399
rm -f $(PDFS) $(HTMLS) $(THUMBS)
398400
rm -f index.latex.aux index.latex.latex index.latex.log index.latex.out

configure

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1616
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1717

18-
OCONFIGURE_VERSION="0.5.1"
18+
OCONFIGURE_VERSION="1.0.0"
1919

2020
#
2121
# This script outputs two files: config.h and Makefile.configure.
@@ -131,7 +131,9 @@ LDADD_SCAN_SCALED=
131131
LDADD_STATIC=
132132
CPPFLAGS=
133133
LDFLAGS=
134+
LINKER_SOFLAG=
134135
LINKER_SONAME=
136+
LINKER_SOSUFFIX=
135137
DESTDIR=
136138
PREFIX="/usr/local"
137139
BINDIR=
@@ -192,8 +194,12 @@ do
192194
LDLIBS="$val" ;;
193195
LDFLAGS)
194196
LDFLAGS="$val" ;;
197+
LINKER_SOFLAG)
198+
LINKER_SOFLAG="$val" ;;
195199
LINKER_SONAME)
196200
LINKER_SONAME="$val" ;;
201+
LINKER_SOSUFFIX)
202+
LINKER_SOSUFFIX="$val" ;;
197203
CPPFLAGS)
198204
CPPFLAGS="$val" ;;
199205
DESTDIR)
@@ -217,6 +223,57 @@ do
217223
esac
218224
done
219225

226+
#----------------------------------------------------------------------
227+
# If the user doesn't specify how to link shared libraries, try
228+
# "-shared" or "-dynamiclib", the latter of which is Mac OS X only at
229+
# the moment. Also set the proper shared library suffix.
230+
#
231+
# This is for link-time shared library generation only: the "-shared"
232+
# should be used for creating dynamically-loaded libraries on all
233+
# Unix-like systems.
234+
235+
if [ -z "$LINKER_SOFLAG" ]
236+
then
237+
test_soname="`mktemp`" || {
238+
echo "mktemp: failed" 1>&2
239+
echo "mktemp: failed" 1>&3
240+
exit 1
241+
}
242+
echo "int foo(void) { return 1; }" > "${test_soname}.c"
243+
${CC} -fPIC -o ${test_soname}.o -c ${test_soname}.c || {
244+
echo "${CC} -fPIC -o ${test_soname}.o -c ${test_soname}.c: failed" 1>&2
245+
echo "${CC} -fPIC -o ${test_soname}.o -c ${test_soname}.c: failed" 1>&3
246+
}
247+
LINKER_SOFLAG="-dynamiclib"
248+
LINKER_SOSUFFIX="dylib"
249+
echo "LINKER_SOSUFFIX: testing ${LINKER_SOFLAG}" 1>&3
250+
${CC} ${LINKER_SOFLAG} -o ${test_soname}.${LINKER_SOSUFFIX}.0 \
251+
${test_soname}.o 2>/dev/null || {
252+
LINKER_SOFLAG="-shared"
253+
LINKER_SOSUFFIX="so"
254+
echo "LINKER_SOFLAG: testing ${LINKER_SOFLAG}" 1>&3
255+
${CC} ${LINKER_SOFLAG} -o ${test_soname}.${LINKER_SOSUFFIX}.0 \
256+
${test_soname}.o || {
257+
echo "LINKER_SOFLAG: cannot determine: default to -shared" 1>&2
258+
echo "LINKER_SOFLAG: cannot determine: default to -shared" 1>&3
259+
}
260+
}
261+
echo "LINKER_SOFLAG: $LINKER_SOFLAG" 1>&3
262+
echo "LINKER_SOSUFFIX: $LINKER_SOSUFFIX" 1>&3
263+
rm -f "$test_soname" "${test_soname}.*"
264+
fi
265+
266+
if [ -z "$LINKER_SOSUFFIX" ]
267+
then
268+
if [ "$LINKER_SOFLAG" = "-shared" ]
269+
then
270+
LINKER_SOSUFFIX="so"
271+
else
272+
LINKER_SOSUFFIX="dylib"
273+
fi
274+
echo "LINKER_SOSUFFIX: $LINKER_SOSUFFIX" 1>&3
275+
fi
276+
220277
#----------------------------------------------------------------------
221278
# If the user doesn't specify whether we want "-soname" or
222279
# "-install_name" for the linker option to generate shared libraries,
@@ -237,10 +294,12 @@ then
237294
}
238295
LINKER_SONAME="-soname"
239296
echo "LINKER_SONAME: testing -soname" 1>&3
240-
${CC} -shared -o ${test_soname}.so.0 ${test_soname}.o -Wl,${LINKER_SONAME},${test_soname}.so.0 || {
297+
${CC} -shared -o ${test_soname}.so.0 ${test_soname}.o \
298+
-Wl,${LINKER_SONAME},${test_soname}.so.0 2>/dev/null || {
241299
LINKER_SONAME="-install_name"
242300
echo "LINKER_SONAME: testing -install_name" 1>&3
243-
${CC} -shared -o ${test_soname}.so.0 ${test_soname}.o -Wl,-install_name,${test_soname}.so.0 || {
301+
${CC} -shared -o ${test_soname}.so.0 ${test_soname}.o \
302+
-Wl,-install_name,${test_soname}.so.0 || {
244303
echo "LINKER_SONAME: cannot determine: default to -soname" 1>&2
245304
echo "LINKER_SONAME: cannot determine: default to -soname" 1>&3
246305
LINKER_SONAME="-soname"
@@ -2559,8 +2618,9 @@ LDADD_SHA2 = ${LDADD_SHA2}
25592618
LDADD_SCAN_SCALED= ${LDADD_SCAN_SCALED}
25602619
LDADD_STATIC = ${LDADD_STATIC}
25612620
LDFLAGS = ${LDFLAGS}
2621+
LINKER_SOFLAG = ${LINKER_SOFLAG}
25622622
LINKER_SONAME = ${LINKER_SONAME}
2563-
STATIC = ${STATIC}
2623+
LINKER_SOSUFFIX = ${LINKER_SOSUFFIX}
25642624
PREFIX = ${PREFIX}
25652625
BINDIR = ${BINDIR}
25662626
SHAREDIR = ${SHAREDIR}

versions.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,4 +1812,17 @@
18121812
</p>
18131813
</aside>
18141814
</article>
1815+
<article data-sblg-article="1" data-sblg-tags="version">
1816+
<header>
1817+
<h1>x.x.x</h1>
1818+
<address>Kristaps Dzonsons</address>
1819+
<time datetime="2025-02-16">2025-02-16</time>
1820+
</header>
1821+
<aside>
1822+
<p>
1823+
Automatically create the correct shared library type (<q>dylib</q>)
1824+
on Mac OS X.
1825+
</p>
1826+
</aside>
1827+
</article>
18151828
</articles>

0 commit comments

Comments
 (0)