8

I am trying to get libtool working on my MacOS 10.8.3 machine. Because everything Apple ships is out of date, I'm using macports. I have up-to-date versions:

libtool (GNU libtool) 2.4.2
automake (GNU automake) 1.13.1
autoconf (GNU Autoconf) 2.69

It's all installed in /opt.

Here is configure.ac:

AC_INIT([Hello], [0.1], [bug-report@hello.example.com], [hello], [http://hello.example.com/])
AC_PREREQ([2.59])
AM_INIT_AUTOMAKE([1.10 no-define])
LT_INIT
AC_CONFIG_HEADERS([config.h])
AC_PROG_CXX
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

Here is Makefile.am:

lib_LTLIBRARIES = libsomething-1.0.la
libsomething_1_0_la_SOURCES = something.cc


bin_PROGRAMS = hello
hello_SOURCES = hello.h hello.cc main.cc

Running glibtoolize produces this error:

glibtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.ac and
glibtoolize: rerunning glibtoolize, to keep the correct libtool macros in-tree.
glibtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.

When I add this line to Makefile.am: ACLOCAL_AMFLAGS="-I m4" I get this error;

glibtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.

If I change it to this: ACLOCAL_AMFLAGS="-Im4"

I get the same error: glibtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.

The second error I get is:

 configure.ac:5: error: required file '../ltmain.sh' not found

How do I make these errors go away?

vy32
  • 28,461
  • 37
  • 122
  • 246

2 Answers2

11

It needs to be:

ACLOCAL_AMFLAGS = -I m4

in Makefile.am and:

AC_CONFIG_MACRO_DIR([m4])

in configure.ac. You do have an m4 directory, at $(top_srcdir) right?

ldav1s
  • 15,885
  • 2
  • 53
  • 56
  • The spaces worked! How odd. How unusual. Now I just have this error: ``configure.ac:5: error: required file '../ltmain.sh' not found` `autoreconf: automake failed with exit status: 1` – vy32 May 21 '13 at 03:55
  • `autoreconf -fvi` should take care of that. – ldav1s May 21 '13 at 17:24
  • The system was corrupt! I'm not having this problem on another mac. Time to nuke `/opt/` – vy32 May 21 '13 at 19:05
  • Whenever I would build stuff with autotools on the Mac, I always compiled and installed autotools from the latest GNU sources, since the ones shipped on the Mac were _always_ too old to build for the Mac. – ldav1s May 21 '13 at 19:05
  • I did that! I'm using macports. But macports doesn't build consistently, it seems. – vy32 May 21 '13 at 19:18
  • this is like buried treasure, took me forever to find but helped me to solve a very similar problem in building xenial sudo for ubuntu 12.04 because reasons. You sir or ma'am are a gentleman or gentlewoman and a scholar. – svenwinkle Feb 26 '21 at 16:57
0

Maybe I'm late to the part, the answer of @ldav1s is the solution, BUT I still had issues. After some Googling, I found this: https://pete.akeo.ie/2010/12/that-darn-libtoolize-acconfigmacrodirm4.html

So, ldav1's answer + this worked for me:

dos2unix Makefile.am

And now it works!

Ali Alwash
  • 533
  • 1
  • 6
  • 23
  • I’m glad you got this to work, but dos2unix changes line-endings, so it seems that you probably downloaded the file on a Windows computer and then moved it to a Mac or something... – vy32 Jun 09 '19 at 00:23
  • It sounds logical, but I did git clone https://github.com/dashesy/cc-tool.git So they probably used a wrong CRLF? Anyway, maybe it could help someone else on Mac or Linux – Ali Alwash Jun 11 '19 at 07:31