KOB
KOB

Reputation: 4545

Trouble with learning how to use GNU Autotools to package my program

I am attepting to use GNU Autotools for the first time to package my C program called MyShell. I have tried twice but have failed both times. I followed this simple tutorial, but where my program differs and what is causing the problem (I think) is that there is 1 .h file and 5 .c files, whereas this tutorial uses just a single .c file.

Here is the file structure of my program:

MyShell/

src/

Any guidance on how to write the Makefile.am files, the configure.ac file, etc. would be much appreciated, or else any more detailed tutorial on using Autotools for a more complex program.

EDIT

These are the files I used:

MyShell/src/Makefile.am

bin_PROGRAMS = MyShell
MyShell_SOURCES = Main.c

MyShell/Makefile.am

SUBDIRS = src
dist_doc_DATA = README

MyShell/configure.ac

AC_INIT([MyShell], [1.0], [<my email address>])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
 Makefile
 src/Makefile
])
AC_OUTPUT

In the tutorial I have linked, the configure.ac file has the line

AC_CONFIG_HEADERS([config.h])

Should I have replaced config.h with MyShell.h?

Upvotes: 2

Views: 184

Answers (1)

Daniel Jour
Daniel Jour

Reputation: 16156

MyShell_SOURCES = Main.c

This seems to be wrong. You need to list all source files, including header files.

Should I have replaced config.h with MyShell.h?

No. config.h should be generated by the configure script from a config.h.in file. "How" can be pretty complex.

Upvotes: 2

Related Questions