Lack of Libtool, double building?

In my project, the modules are organized in sub-layers for convenience.

My project hierarchy hierarchy:

$ ls -R
.:         configure.in Makefile.am  Makefile.cvs  src
./src:     log          Makefile.am  main.cpp
./src/log: log.cpp      Makefile.am

configure.in:

AC_INIT(configure.in)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(myapp, 0.1)
AC_LANG_CPLUSPLUS
AC_PROG_CXX
AM_PROG_LIBTOOL
AC_OUTPUT(Makefile src/Makefile src/log/Makefile)

Makefile.am:

AUTOMAKE_OPTIONS = foreign
SUBDIRS = src

Makefile.cvs:

default:
    aclocal
    libtoolize --force --copy
    autoheader
    automake --add-missing --copy
    autoconf

Src / makefile.am

bin_PROGRAMS = myapp
myapp_SOURCES = main.cpp
SUBDIRS = log
myapp_LDADD = $(top_builddir)/src/log/liblog.la

CSI / Magazine / Makefile.am:

INCLUDES = $(all_includes)
METASOURCES = AUTO
noinst_LTLIBRARIES = liblog.la
liblog_la_SOURCES = log.cpp

src / main.cpp: contains int main(){}, src / log / log.cpp contains void f(){}.

The call makeproduces (edited for brevity):

libtool --mode=compile g++     -MT log.lo -MD -MP -MF .deps/log.Tpo -c -o log.lo log.cpp
libtool: compile:  g++ -MT log.lo -MD -MP -MF .deps/log.Tpo -c log.cpp  -fPIC -DPIC -o .libs/log.o
libtool: compile:  g++ -MT log.lo -MD -MP -MF .deps/log.Tpo -c log.cpp -o log.o >/dev/null 2>&1
mv -f .deps/log.Tpo .deps/log.Plo
libtool --mode=link g++    -o liblog.la  log.lo  
libtool: link: ar cru .libs/liblog.a .libs/log.o 
libtool: link: ranlib .libs/liblog.a
libtool: link: ( cd ".libs" && rm -f "liblog.la" && ln -s "../liblog.la" "liblog.la" )
g++ -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.cpp
mv -f .deps/main.Tpo .deps/main.Po
libtool --mode=link g++    -o myapp main.o ../src/log/liblog.la 
libtool: link: g++ -o myapp main.o  ../src/log/.libs/liblog.a

The problem is in the first three lines: log.cpp compiled twice!

Question: why does it not just compile once - takes half the time?

note: I have no idea what I'm doing - autotools is black magic for me, but we have to use it in our place. I don’t understand the documents.

+3
1

Libtool : static shared. (aka libfoo.a libfoo.so)

. - gcc:

-fPIC -DPIC

- . ,

./configure --disable-shared

./configure --disable-static

, , - , , . , . (aka libfoo_XYZ.deb)

(aka libfoo-dev_XYZ.deb) , , .

UNIX. , libtool .

+3

Source: https://habr.com/ru/post/1703613/


All Articles