Lenik
Lenik

Reputation: 14458

How to include static library built from D sources in Makefile.am?

I'm writing a utility library libdog-dev for programming with D language, here is the Makefile.am:

sited2dir = /usr/include/d2/site
lib32dir = ${libdir}/i386-linux-gnu
# lib64dir = ${libdir}/x86_64-linux-gnu

lib32_LIBRARIES = \
    i386/libdog.a

# lib64_LIBRARIES = \
#     x86_64/libdog.a

i386/libdog.a:
    mkdir -p i386
    dmd -lib -m32 -of$@ -op -Hdi386/include/ `find src/ -name '*.d'`

x86_64/libdog.a:
    mkdir -p x86_64
    dmd -lib -m64 -of$@ -op -Hdx86_64/include/ `find src/ -name '*.d'`

# Since the header files for i386/x86_64 are the same, let's just pick the i386 one.
install-data-hook: 
    mkdir -p $(DESTDIR)$(sited2dir)
    rsync -av i386-linux-gnu/include/ $(DESTDIR)$(sited2dir)

it's working, however, something I'm still unclear:

Upvotes: 1

Views: 326

Answers (1)

Lenik
Lenik

Reputation: 14458

  1. Automake will try to find C/C++ sources for files listed in _LIBRARIES targets. So, just change them to _DATA targets:

    lib32_DATA = \
        i386/libdog.a
    
    lib64_DATA = \
        x86_64/libdog.a
    
  2. You can generate the name i386-linux-gnu or x86_64-linux-gnu of the host system by running:

    dpkg-architecture -qDEB_HOST_GNU_TYPE
    

    You can also get the library path from /etc/ld.so.conf and /etc/ld.so.conf.d/*.

Upvotes: 1

Related Questions