Quick help in rebuilding an automake project - c++

I got the source code of a project (which I can't reach the author any more), that uses automake. I'm not familiar with system and all I want to do is rebuild the project.
I have the following files in the project:
Makefile.am
Makefile.in
Makefile
I've modified the Makefile.am file to fit the paths on my system, but how should I run it regenerate the Makefile.
Note: I'm not currently interested in learning automake, just recompiling this project.

to bootstrap an autoconf build-system, you might use
$ autoreconf -fiv
which will call automake, aclocal, autoheaders as needed, and generate the configure script. after that ou can do the usual
$ ./configure && make && make install
as proposed by milos_ladni
but you will definitely need configure.ac (or configure.in if it's an older project), else the project is simply missing some core parts.
if those are missing, you could go and try to modify Makefile directly (good luck), but it might be easier to just recreate a configure.ac from scratch (and hope that the project doesn't have too many dependencies)

$ ./configure --prefix=some_directory
$ make
$ make install
http://inti.sourceforge.net/tutorial/libinti/autotoolsproject.html#AP05

Related

What is the job of autogen.sh when building a c++ package on Linux [duplicate]

This question already has answers here:
Confused about configure script and Makefile.in
(2 answers)
Closed 4 years ago.
I saw a common pattern when installing a c/c++ package from source on Linux (Ubuntu 16.04):
./autogen.sh
./configure
make
make install
I understand make and make install, and I guess configure creates a Makefile based on user preferences, but I don't see why autogen.sh is necessary.
Does anyone know what it is there for?
The steps:
The autogen.sh script generates the configure script (from configure.ac, using autoconf) and any files it needs (like creating Makefile.in from Makefile.am using automake). This requires autotools to be installed on your system, and it must be run when checking out the project from source control (if configure isn’t checked in). People who download source tarballs can usually skip this step, because output of this step is included in source tarballs.
Note This is usually equivalent to autoreconf --install. If there is not autogen.sh file, then just run autoreconf --install instead. If you have inherited a project with an autogen.sh, consider deleting it if you can use autoreconf --install.
The configure script generates Makefile and other files needed to build. Typically Makefile.in is used as a template to generate Makefile (and config.h.in to generate config.h). This process happens using only standard tools installed on your system, like sed and awk, and doesn't require autotools to be installed.
The make command builds the software.
The make install command installs it.
These are broken into different steps because they are often run at different times. The autogen.sh step is traditionally run by people who are developing the software, since they are expected to install autoconf on their systems and they make changes to configure.ac. End-users are not expected to have autotools installed.
These expectations have been changed a bit now that end-users are more likely to check a project out of source control instead of downloading source releases.
This applies only to programs / libraries, which are built using the autotools build chain. It generates the files, which are configured by the configure script. The configure script then populates .in files and generates Makefiles from Makefile.am templates. Which can finally be used to compile, link and install the program / library.
It's becoming slowly obsolete with the move to multi platform packages. CMake and more modern tool chains are state of the art.

./Configure for non-boost ASIO

I take a look inside the asio folder there are
asio.manifest
autogen.sh
boost_asio.manifest
boostify.pl
configure.ac
include/
INSTALL
src/ (there are asio_ssl.cpp and asio.cpp)
I didn't see any configure script where I can execute. How do I build this asio?
I read asio is a header only library.
So, what I can make out of those files in the asio folder?
If you got it from a tarball, you should already have a configure script ready to be executed. If you checked from the repository, you probably need to run ./autogen.sh to generate the configure script for you, using configure.ac as input.
The convention is:
./bootstrap: it invokes autoconf to process configure.ac and spit out configure. Often it also invokes automake to process all Makefile.am files and turn them into Makefile.in. Many moons ago, the name autogen.sh was used instead of bootstrap. And configure.in was used instead of configure.ac.
./configure: detects everything on the system and creates config.status, then executes it.
./config.status: processes all *.in files into versions without the .in suffix. That includes Makefile.in -> Makefile. You don't have to run this script by hand.
INSTALL: this SHOULD contain build instructions, such as "run ./autogen.sh if you checked out a copy from the repository". Shame on the ASIO developers, they just point the user to look for a non-existing "doc" directory.
You need autoconf (and friends) installed to transform configure.ac into configure. Once that is done, the build system becomes self-contained. That is, you can do a make dist-gzip to pack all the sources (and the configure script), transfer the tar.gz it to another system, and follow from the ./configure step, even if autoconf is not installed there.
So, Here are the steps I've followed just now.
I went to http://think-async.com, which is the website that hosts the non-boost asio.
Their download link led me to sourceforge, and version 1.4.8 of the software.
I then extracted the folder, and looking inside, I see the usual layout.
So the following steps include ./configure, make, and probably sudo make install.

Building c++ project in Ubuntu Linux with Makefile.am/Makefile.in

I am new in Ubuntu/Linux and I've been working with java using the NetBeans IDE, so I don't have much experience with building c++ projects. But now I have to provide a proof of concept and I need to connect a C++ client with my ActiveMQ server. I downloaded The ActiveMQ-CPP API from this link, but I can't build/run it.
The download came with the files: Maklefile.am and Makefile.in. I searched it and I found that I need automake/autoconf to build it. I tried running ./configure but it says that it couldn't find such file or directory. I tried
sudo apt-get update
sudo apt-get install automake
sudo apt-get install autoconf
and a lot of other commands that I found on the Internet. None of then worked. I know that this question is really basic and it seems to be already answered somewhere else, but every attempt I've made failed. I think I'm missing something. I even tried the solution provided in the last message in this topic but it didn't work either.
Can anyone help me install autoconf/automake, or tell me how to use Makefile.am / Makefile.in to build the project I downloaded, or even suggest me some other way of building it?
Since you're open to other methods of building your project, I'm going to suggest CMake. It is a far better build system than autotools (at least from where I stand).
#CMakeLists.txt
project(MyProject CXX)
set_minimum_required(VERSION 2.8)
add_executable(foobar foo.cpp bar.cpp)
That example will build an executable called "foobar" by compiling and linking foo.cpp and bar.cpp. Put the above code in a file called CMakeLists.txt, then run the following commands:
cmake <path to project> #run in the folder you want to build in
make #this does the actual work
The really cool thing about CMake is that it generates a build system (Makefiles by default) but you can use it to generate project files for Eclipse, a Visual Studio solution, and a bunch of other things. If you want more information, I'd check out their documentation.
The "configure" script should be in your ActiveMQ-cpp source directory. From the Linux command line, you should be able to:
1) "cd" into your ActiveMQ* directory
2) "ls -l" to see the "configure" script
3) "./configure" to set things up for building the library\
4) "make" to actually build the library
This is mentioned in comments, but this particular point of confusion has been common for well over a decade and I think needs to be clarified as often as possible. You DO NOT need to have autoconf or automake installed to build a project that used those tools. The entire point of the autotools is to generate a build system that will build on a system using only the standard tools (make, a c compiler, sh, and few others.) Unfortunately, many developers release tarballs that do not build cleanly. If you unpack the tarball and it does not contain a configure script, or if the configure script is broken, that is a bug in the package. The solution is absolutely not to install autoconf/automake/libtool and try to produce a working configure script. The solution is to report the build error as a bug to the package maintainer.
The world would be a better place if Linux distributions stopped installing multiple versions of the autotools by default as less than .002% of the population needs those tools, and anyone who actually needs to have the tools should be capable of installing it themselves. Anyone incapable of acquiring and installing the tools has no business using them.

Can't run Makefile.am, what should I do?

I got a C project to compile and run in Linux. It is a very big project with many subdirectories. Inside the parent directory there are files Makefile.am and Makefile.in.
I tried running make -f Makefile.am, and got the following error:
make: Nothing to be done for `Makefile.am'.
What does it mean? How do I accomplish my task?
These files are used with the Autotools suite. Makefile.am files are compiled to Makefiles using automake.
Have a look to see if there is a configure script in the directory. If there is, then type:
./configure
If not, then run:
autoreconf
in the directory, which should create the configure script (you will need to have the Autotools suite installed to run this).
After that, you should have a configure script that you can run.
After the configure is complete, you should have a normal Makefile in the directory, and will be able to run
make
What has been left out:
Makefile.am are transformed to Makefile.in using automake.
Makefile.in are transformed to Makefile by running configure.
Neither of these (Makefile.{am,in}) are supposed to be used with make -f.
If the tarball already ships with configure, just run that and make. If it does not, run ./autogen.sh or bootstrap(*). If that does not exist, use autoreconf instead.
(*) autogen/bootstrap: A convenience script added by developers that should just call autoreconf. Unfortunately there are some people that eschew autoreconf and unnecessarily call all the lowlevel commands themselves.
To supplement what has already been said:
Search for a script called configure in the project directory. If it is there, building the project will be:
./configure
make
and optionally, to install:
sudo make install
or su -c "make install"
Even if there is no configure script. there might be one autogen.sh. Run this script to generate the configure script and do as above.
Makefile.am is probably to be used with automake.
try:
automake
you might also just want to try
make -f Makefile.in
Since this is the product of running automake

Can CMake generate build scripts which do *not* use cmake?

Question: Can CMake generate build scripts that do not, in any way, use CMake? If not, how hard is it to gut a CMake generated automake script to not make any checks against CMake?
I am a big fan of CMake to the point where I am championing the idea that we transition to it in my current work environment. One thing that could ease this transition from our current build system to CMake would be if I could demonstrate that CMake can generate automake files that do not require cmake themselves.
Clearly, I would never want to do this for day to day use, but having the ability to easily create a branch of our code that can be built from source without requiring cmake would go a long way in helping me make my case.
The ability to do this depends on your OS, I'm presuming Unix/Makefile or Windows/MSVC. If you're using MSVC, the cmake dependency should be eliminated by declaring the CMAKE_SUPPRESS_REGENERATION option at the start of your cmake script.
SET(CMAKE_SUPPRESS_REGENERATION TRUE)
On Unix-based systems, however, the Makefiles are tied explicitly to the cmake build files (CMakeFiles, etc). I suspect that this dependency could be bypassed by the strategic commenting out of Makefile directives although, I cannot say what they might be.
No, CMake cannot do this. It doesn't really make sense, either, since without any CMake-support at build-time, there would be no way to check or update the makefiles/project-files themselves when the CMakeLists.txt files have changed.
If you are moving from Visual Studio to CMake, you may want to take a look at vcproj2cmake.
CMake generated files depend on cmake for various commands such as create / remove / etc... not just to regenerate the makefiles on a change so removing cmake is not going to work.
As someone who has taken a large complex piece of software and recently pulled out its existing build system, installing a new build system in its place. I can tell you that it's not easy, but I would definitely not want shell scripts as part of my build process, if they can be avoided. More and more systems will find themselves with CMake on them anyway, as more big name software packages like LLVM and KDE start using it—This is an area where it really accels, large projects.
One of the nice things about CMake is it builds things quicker. Resorting to have to fork shell instances to interpret a script really slows down the build process.
What about the 'atomic solution' ?
EX- auto-generate a "QT moc" file from CMakeLists.txt, then build project that depends on the .cpp file being generated
# inside project level CMakeLists.txt
# run shell script to create the "moc_GUICreator.cpp" auto-generated source file
if(UNIX)
execute_process(COMMAND "sh" ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_moc.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/scripts )
endif(UNIX)
Where the .sh file contains:
# generate_moc.sh
echo "generating moc file: moc ../include/GUICreator.h -o ../src/moc_GUICreator.cpp "
moc ../include/GUICreator.h -o ../src/moc_GUICreator.cpp
Equivalent windows batch file, "moc_creator_win.bat":
moc "GUICreator.h" -o "moc_GUICreator.cpp"
Haven't tried this last bit in windows, but it or something very close should work, just after the if(UNIX) block in CMakeLists.txt:
if(WIN32)
execute_process(COMMAND "cmd" ${CMAKE_CURRENT_SOURCE_DIR}/scripts/moc_creator_win.bat WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/scripts )
endif(WIN32)
So, basically if you're clever you can do whatever you want from a script and use CMake variables as args to it, I'm not sure if you can ask for more...
the point is to avoid 'non-portable build types' unless you really need to hack it into a specialized compiler, or don't feel like using QT Designer to place the widgets ;-)