Skip to content

Commit

Permalink
Add a dummy file, to make sure the library is non-empty
Browse files Browse the repository at this point in the history
Should fix the macOS build.
  • Loading branch information
kleisauke committed Oct 16, 2019
1 parent ad86ab8 commit 8cea2b3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ noinst_LTLIBRARIES = librsvg_c_api.la
# This is empty, because automake wants to have a C sources list for
# the LTLIBRARIES. See LIBRSVG_INTERNALS_SRC below for the real list
# of Rust sources.
librsvg_c_api_la_SOURCES =
librsvg_c_api_la_SOURCES = librsvg/dummy.c

bin_PROGRAMS = rsvg-convert

Expand Down Expand Up @@ -182,7 +182,7 @@ dist-hook:
mkdir .cargo && \
cp cargo-vendor-config .cargo/config)

librsvg_c_api.la: $(LIBRSVG_INTERNALS_SRC) $(LIBRSVG_C_API_SRC)
librsvg_c_api.la: $(librsvg_c_api_la_OBJECTS) $(LIBRSVG_INTERNALS_SRC) $(LIBRSVG_C_API_SRC)
+cd $(top_srcdir)/librsvg && \
PKG_CONFIG_ALLOW_CROSS=1 \
PKG_CONFIG='$(PKG_CONFIG)' \
Expand All @@ -191,7 +191,7 @@ librsvg_c_api.la: $(LIBRSVG_INTERNALS_SRC) $(LIBRSVG_C_API_SRC)
&& if [[ $$($(NM) -g $(RUST_LIB) | grep "T __*clzsi2" -c) -gt 1 ]] ; then \
$(AR) d $(RUST_LIB) clzsi2.o; \
fi \
&& cd $(LIBRSVG_BUILD_DIR) && $(LINK) && mv $(RUST_LIB) .libs/librsvg_c_api.a
&& cd $(LIBRSVG_BUILD_DIR) && $(LINK) $< && mv $(RUST_LIB) .libs/librsvg_c_api.a

librsvg_@RSVG_API_MAJOR_VERSION@_la_CPPFLAGS = \
-I$(top_srcdir) \
Expand Down
30 changes: 30 additions & 0 deletions librsvg/dummy.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* A dummy file, to prevent empty libraries from breaking builds.
This file is in the public domain. -- Bruno Haible */

/* Some systems, reportedly OpenBSD and Mac OS X, refuse to create
libraries without any object files. You might get an error like:
> ar cru .libs/libgl.a
> ar: no archive members specified
Compiling this file, and adding its object file to the library, will
prevent the library from being empty. */

/* Some systems, such as Solaris with cc 5.0, refuse to work with libraries
that don't export any symbol. You might get an error like:
> cc ... libgnu.a
> ild: (bad file) garbled symbol table in archive ../gllib/libgnu.a
Compiling this file, and adding its object file to the library, will
prevent the library from exporting no symbols. */

#ifdef __sun
/* This declaration ensures that the library will export at least 1 symbol. */
int gl_dummy_symbol;
#else
/* This declaration is solely to ensure that after preprocessing
this file is never empty. */
typedef int dummy;
#endif

0 comments on commit 8cea2b3

Please sign in to comment.