I just want to develop a C app in linux with the auto(make/conf/...) stuff automatically generated. I tried generating it with ede and anjuta, but it doesn't seem to generate Makefile.am. So, I tried running automake, and it says "ltmain.sh" isn't found. Is there some easy to generate the basic build files for linux C/C++ apps. What is the standard practice? Do most people write these files themselves?
Generating a really trivial set of autotool files is pretty easy. Here's a (really basic) example. After you run these, you should get a copy of ltmain.sh in the directory, and you'll be all set to run the configure script:
$ mkdir sample $ cd sample $ echo 'int main( void ) { return 0; }' > foo.c $ echo 'bin_PROGRAMS = foo' > Makefile.am $ autoscan $ mv configure.scan configure.ac $ # edit configure.ac, add AM_INIT_AUTOMAKE([foreign]) $ # and LT_INIT, set project name and bug-report-address $ autoreconf -ivf
Note that in this example, libtool really isn't necessary since the example is just building a simple app. But you asked about ltmain.sh, and that's a libtool thing so LT_INIT is needed to address that portion of the question. If you want to build a library, change bin_PROGRAMS to lib_LTLIBRARIES.
EDE can work with your Automake files in two different ways. If you write your own automake files, it will read them, and tweak them via the UI.
If you prefer, you can have EDE do the whole thing for you. First, create your first C file, then when it is on disk, do:
M-x ede-new RET Automake RET
then from the project/project options menu, add a target, like "program".
If you fill in your C file, you can then choose Project->Build->build currentproject from the menu, and it will create and setup everything needed for Automake to do it's thing, in addition to running all the misc automake commands needed.
Lastly, there is a 'run' option somewhere to run your program.
I'd consider not using autoconf and automake at all -- their complexity outweighs their benefit, particularly if you're targeting only Linux.
Note that "git", for example, doesn't use them at all; instead it simply has a moderately-complex (but comprehensible) Makefile.
Makefile.am
) is a thing of beauty, and far simpler to write or understand (and yet much more functional), than an equivalent Makefile
. For cases where configuration isn't really necessary, the autoconf input file (configure.ac
) can be trivial, and if some configuration is necessary, autoconf is a far nicer way to do it than ad-hoc methods which seem to be the alternative. –
Rufinaruford configure
, and the resulting Makefile has all the dependencies needed to thereafter always do "the right thing" just by typing make, or (2) in a "raw" project (with no configure file), one just types autoreconf --install
first, and then does (1). The only really bad thing about autotools these days is the crufty implementation—but most people don't really have to care... –
Rufinaruford © 2022 - 2024 — McMap. All rights reserved.