Skip to navigation
How to create a configure script what get used by compiling a c program
30.10.19
1. install the autoconf tools: # OSX $ brew install autoconf automake libtool # Ubuntu/Debian $ sudo apt-get install autoconf automake libtool # RHEL/CentOS $ sudo yum install autoconf automake libtool 2. create a sample c source code like hello.c: #include "stdio.h" int main( int argc, char *argv[] ) { char s[] = "Hello"; printf("you said %s",s); return 0 } 3. create the file configure.ac: # Must init the autoconf setup # The first parameter is project name # second is version number # third is bug report address AC_INIT([hello], [1.0]) # Safety checks in case user overwritten --srcdir AC_CONFIG_SRCDIR([hello.c]) # Store the auxiliary build tools (e.g., install-sh, config.sub, config.guess) # in this dir (build-aux) AC_CONFIG_AUX_DIR([build-aux]) # Init automake, and specify this program use relaxed structures. # i.e. this program doesn't follow the gnu coding standards, and doesn't have # ChangeLog, COPYING, AUTHORS, INSTALL, README etc. files. AM_INIT_AUTOMAKE([-Wall -Werror foreign]) # Check for C compiler AC_PROG_CC # We can add more checks in this section # Tells automake to create a Makefile # See https://www.gnu.org/software/automake/manual/html_node/Requirements.html AC_CONFIG_FILES([Makefile]) # Generate the output AC_OUTPUT 4. create the file Makefile.am: bin_PROGRAMS = hello hello_SOURCES = hello.c 5. create the configure script: autoreconf --verbose --install --force 6. create the make file: ./configure 7. create the executable file with: make
https://www.idryman.org/blog/2016/03/10/autoconf-tutorial-1/
Reply
Anonymous
Information Epoch 1745995136
Live free or die.
Home
Notebook
Contact us