I've search other posts and I apologize if this is a stupid question...but I have some source code I'm wanting to compile. One folder has a Makefile.am and Makefile.in that I'm assuming I need to use, but cannot figure out how. Any recommendations?
Thanks
You need some version of GNU Automake
An introduction to automake is found in wikipedia.
http://en.wikipedia.org/wiki/Automake
Automake can be installed in windows.
Simple Summary:
Makefile.am , Makefile.in and config.h.in all combine through the magic of Perl and the M4 macro preprocessor.
Course of attack:
get a perl installation
get the autotools for windows installation
once it's all installed , invoke ./configure and bob's your uncle, you get a makefile.
This is the historical source of this stanza of unix script activity
{if no configure.in}
#.autoscan
{if no ./configure}
#.autoconf
#./configure
#make
#make install
And once you have all the tools installed , you can do it too.
Related
A user of xnec2c was trying to build on OSX and had autoconf issues because PKG_CHECK_MODULES could not be found since MacPorts puts it in a funny spot.
The user made autoconf work like so:
ACLOCAL_PATH=/opt/local/share/aclocal ./autogen.sh
ACLOCAL_PATH=/opt/local/share/aclocal ./configure
I would like to make it build on OSX without special user path hacks for ACLOCAL_PATH. Can that be done?
I started writing a possible fix below and realized it could an xyproblem so posed the question just above. However, if this starts any gears turning, then I would be open to a bit of special-casing for OSX:
For example, would it be possible (if not advisable) to detect:
Is PKG_CHECK_MODULES missing?
If so:
is it OSX?
Is [ -d /opt/local/share/aclocal ] true?
Does the macro exist there?
While aclocal has a few ways of appending to its search path (see https://www.gnu.org/software/automake/manual/html_node/Macro-Search-Path.html), you cannot modify that macro search path using code in configure.ac:
When the shell code in configure is run, it is too late, as the available macros have already been expanded. When autoconf (is it autoconf or something else? anyway, m4 called from autoreconf) generates configure from configure.ac by having m4 expand the macros it is also too late: aclocal has already collected the m4 macros it could find.
So what you would need is a step before the autoreconf run - which is beyond what I would consider a buildsystem needs to do.
What you can do: Put static strings into the top level Makefile.am file like e.g.
ACLOCAL_AMFLAGS = -I auto-m4 -I project-m4 -I /opt/local/share/aclocal
(this example uses auto-m4/ with AC_CONFIG_MACRO_DIR([auto-m4]) for the *.m4 files automatically put there by autoreconf/autopoint/libtoolize and project-m4/ for the project specific *.m4 files).
Of course, you should already have
m4_pattern_forbid([PKG_CHECK_MODULES])dnl
before invoking PKG_CHECK_MODULES for the first time so that the problem of the missing *.m4 file will be detected at the earliest possible time, i.e. when autoconf is about to generate a configure file with PKG_CHECK_MODULES unexpanded.
You could use some m4 code to print a lengthy error message if PKG_CHECK_MODULES is not defined. Something along the lines of (untested)
m4_ifndef([PKG_CHECK_MODULES], [dnl
m4_fatal([Could not find the PKG_CHECK_MODULES macro. Check that the pkg.m4 file is available and aclocal finds it (e.g. set ACLOCAL_PATH=/opt/local/share/aclocal).
])dnl
PKG_CHECK_MODULES([FOO], [foo])
Personally, I would go with m4_pattern_forbid and make sure OSX builds with homebrew work OOTB, and then document idiosyncrasies for building on rare and buggy systems like OSX with macports or SunOS without GNU tools in the INSTALL file.
Isn't it a bug in macports/OSX that aclocal there cannot find its *.m4 files? Shouldn't there be a dirlist file pointing to /opt/local/share/aclocal? Or perhaps they macports users should have an aclocal in their PATH which actually finds the macports macro files?
In any case, I would not consider it my build systems's job to fix a buggy system. You need to draw the line somewhere.
I am on a Windows computer but working with the cygwin subsystem.
I have followed some manuals on how to download gmp. I have therefor downloaded, unzipped and configured the gmp-6.2.1 file, but i come onto problems in the "make" step.
In the gmp-6.2.1 file there are two makefiles, and when i try to use "make" on them i get:
$ make -f Makefile.in
Makefile.in:15: *** missing separator. Stop.
Where line 15 in Makefile.in is
#SET_MAKE#
and
$ make -f Makefile.am
Makefile.am:126: *** missing separator. Stop.
Where line 126-130 in Makefile.am is
if WANT_CXX
GMPXX_HEADERS_OPTION = gmpxx.h
pkgconfig_DATA += gmpxx.pc
endif
Do you know if I need to change anything in the makefiles, or something else?
Thanks for the help.
Makefile.in and Makefile.am are not makefiles. It is erroneous to use make -f to try to interpret them as such. These are contributors to building a makefile for the project.
You're looking at a project with a GNU build system. The standard procedure for building such a project is to
run the ./configure script to generate one or more makefiles and perhaps other files, then
run make in the same working directory to build the project, then
run make install in that directory to install the built result to the system.
There are variations and embellishments that can be made, but that's the basic pattern. Nowhere should you need to use make's -f option.
If the instructions you're following are any good then they will have covered this at least briefly.
My OCaml program uses some functions in the OCaml standard library that were only introduced in version 4.01.0. How can I arrange that when my user compiles my code, the compiler emits an error if the OCaml compiler's version is not 4.01.0 or higher? I feel that this error would be more helpful than just a generic "unbound variable" error.
I see that ocaml -vnum emits "4.01.0" so I guess I could try to check that in my Makefile, but perhaps there is a proper way to do this already? I'm using OCamlBuild, if that helps.
My current Makefile looks like this, by the way:
all:
# echo "Attention: requires OCaml version >= 4.01.0."
ocamlbuild -cflag -annot -lib str -lib unix name_of_my_project.native
mv name_of_my_project.native name_of_my_project
clean:
ocamlbuild -clean
rm -f name_of_my_project
If you already have a Makefile, inserting a check there would probably be the most pragmatic way to achieve this. Can be done using either Makefile expressions or shell. Here's a shell version of a similar check: https://github.com/alavrik/piqi/blob/master/configure#L144
Somewhat related, I was looking for conditional compilation for OCaml and ended up using optcomp. Here's an example.
There is always more than one proper way :) My proper way would be to use oasis. Others would probably use Autotool AC_PROG_OCAML with the specified version. There are other build systems, that probably have their own methods. When you will release your package to opam (it is also very easy), you will add the constraints to the opam file, so that the package manager will not even try to build it.
So, to summarize my personal advice is to use oasis. It is very simple, but still quite versatile. In your case the _oasis control file should looks something like this:
OASISFormat: 0.4
Name: name
Version: 0.0.1
OCamlVersion: >= 4.01.0
Synopsis: Cool package
Authors: Myself
Maintainers: Myself
License: MIT
Copyrights: (C) Myself
Plugins: META (0.4), DevFiles (0.4)
BuildTools: ocamlbuild
Executable "project"
Path: src
MainIs: project.ml
CompiledObject: best
BuildDepends: str, unix
Once the file is created, you can create a configure script with
oasis setup
And after it is ready (it will also create the setup.ml file), you can use the common:
./configure
make
make install
I'm working on a Windows 7 computer at work and want to use the libpostal package. Unfortunately, it's apparently not available for Windows, so I'm trying to configure it through Cygwin and I'm SO close. The last step is to install snappy from Google. Again, not available on Windows...
My assumption (based on nothing) is that I can just download the tarball and build it from source, right? I tried that, and I think it worked? But a) I don't know how to tell, and b) if it did, I don't know how to tell ./configure in libpostal to find it.
In order to build it from source, I downloaded the tarball and saved it in the folder that Cygwin reads as my home, which is C:\cygwin64\home\brittenb\. From there, I ran bash autogen.sh, which created the ./configure that I needed. So I ran that and while some responses to the checks were no, it seemed to run fine. I then ran make and make install. Nothing seemed out of place, so my assumption is that it did what it was supposed to do. I just have no idea where to go from here.
Here is the output from ls after I run everything:
aclocal.m4 snappy.cc
AUTHORS snappy.h
autogen.sh snappy.lo
autom4te.cache snappy.o
ChangeLog snappy.pc
compile snappy.pc.in
config.guess snappy_unittest.cc
config.h snappy_unittest.exe
config.h.in snappy_unittest-snappy_unittest.o
config.log snappy_unittest-snappy-test.o
config.status snappy-c.cc
config.sub snappy-c.h
configure snappy-c.lo
configure.ac snappy-c.o
COPYING snappy-internal.h
depcomp snappy-sinksource.cc
format_description.txt snappy-sinksource.h
framing_format.txt snappy-sinksource.lo
INSTALL snappy-sinksource.o
install-sh snappy-stubs-internal.cc
libsnappy.la snappy-stubs-internal.h
libtool snappy-stubs-internal.lo
ltmain.sh snappy-stubs-internal.o
m4 snappy-stubs-public.h
Makefile snappy-stubs-public.h.in
Makefile.am snappy-test.cc
Makefile.in snappy-test.h
missing stamp-h1
NEWS testdata
README test-driver
ls /usr/local/bin shows nothing, but ls /usr/local/include shows:
snappy.h snappy-c.h snappy-sinksource.h snappy-stubs-public.h
So... my question: did it work? Why does ./configure in libpostal say it can't find snappy? Thanks in advance.
The snappy dependency has been removed as of release 1.0.0. I made changes to the source and make and config so that it will build on MinGW.
Get it in my repository:
https://github.com/BenK10/libpostal_windows
Note that this is not the complete source since not everything had to be changed. I would suggest merging my changes with the official libpostal distribution to make sure you've got everything. Also, there are some extra DLLEXPORTs in some source files that I haven't removed yet, and the part in the Makefile that builds the executables like address_parser.exe was removed because some porting is necessary to build those programs on Windows. You can write your own using the DLL you'll get in the Windows build and the original source as a reference.
Check the return code from make install ($?). If it is zero, make install succeeded.
snappy looks like a library, so maybe it doesn't install anything in /usr/local/bin. The library is probably installed into /usr/local/lib.
I'm currently learning how to use the autoconf/automake toolchain. I seem to have a general understanding of the workflow here - basically you have a configure.ac script which generates an executable configure file. The generated configure script is then executed by the end user to generate Makefiles, so the program can be built/installed.
So the installation for a typical end-user is basically:
./configure
make
make install
make clean
Okay, now here's where I'm confused:
As a developer, I've noticed that the auto-generated configure script sometimes won't run, and will error with:
config.status: error: cannot find input file: `somedir/Makefile.in'
This confuses me, because I thought the configure script is supposed to generate the Makefile.in. So Googling around for some answers, I've discovered that this can be fixed with an autogen.sh script, which basically "resets" the state of the autoconf environment. A typical autogen.sh script would be something like:
aclocal \
&& automake --add-missing \
&& autoconf
Okay fine. But as an end-user who's downloaded countless tarballs throughout my life, I've never had to use an autogen.sh script. All I did was uncompress the tarball, and do the usual configure/make/make install/make clean routine.
But as a developer who's now using autoconf, it seems that configure doesn't actually run unless you run autogen.sh first. So I find this very confusing, because I thought the end-user shouldn't have to run autogen.sh.
So why do I have to run autogen.sh first - in order for the configure script to find Makefile.in? Why doesn't the configure script simply generate it?
In order to really understand the autotools utilities you have to remember where they come from: they come from an open source world where there are (a) developers who are working from a source code repository (CVS, Git, etc.) and creating a tar file or similar containing source code and putting that tar file up on a download site, and (b) end-users who are getting the source code tar file, compiling that source code on their system and using the resulting binary. Obviously the folks in group (a) also compile the code and use the resulting binary, but the folks in group (b) don't have or need, often, all the tools for development that the folks in group (a) need.
So the use of the tools is geared towards this split, where the people in group (b) don't have access to autoconf, automake, etc.
When using autoconf, people generally check in the configure.ac file (input to autoconf) into source control but do not check in the output of autoconf, the configure script (some projects do check in the configure script of course: it's up to you).
When using automake, people generally check in the Makefile.am file (input to automake) but do not check in the output of automake: Makefile.in.
The configure script basically looks at your system for various optional elements that the package may or may not need, where they can be found, etc. Once it finds this information, it can use it to convert various XXX.in files (typically, but not solely, Makefile.in) into XXX files (for example, Makefile).
So the steps generally go like this: write configure.ac and Makefile.am and check them in. To build the project from source code control checkout, run autoconf to generate configure from configure.ac. Run automake to generate Makefile.in from Makefile.am. Run configure to generate Makefile from Makefile.in. Run make to build the product.
When you want to release the source code (if you're developing an open source product that makes source code releases) you run autoconf and automake, then bundle up the source code with the configure and Makefile.in files, so that people building your source code release just need make and a compiler and don't need any autotools.
Because the order of running autoconf and automake (and libtool if you use it) can be tricky there are scripts like autogen.sh and autoreconf, etc. which are checked into source control to be used by developers building from source control, but these are not needed/used by people building from the source code release tar file etc.
Autoconf and automake are often used together but you can use autoconf without automake, if you want to write your own Makefile.in.
For this error:
config.status: error: cannot find input file: `somedir/Makefile.in'
In the directory where the configure.ac is located in the Makefile.am add a line with the subdirectory somedir
SUBDIRS = somedir
Inside somedir put a Makefile.am with all the description. then run automaker --add-missing
A better description can be found in 7.1 Recursing subdirectories automake manual.
https://www.gnu.org/software/automake/manual/automake.html