Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7637701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:00:26+00:00 2026-05-31T08:00:26+00:00

I have a C project that has the following structure Main/ Makefile.am bin/ src/

  • 0

I have a C project that has the following structure

Main/
  Makefile.am
  bin/
  src/
     Makefile.am
     main.c
     SomeLibrarySource/
         SomeFuncs.c
         SomeFuncs.h

The main.c contains the main function that uses functions defined in the SomeFuncs.{h/c} files.

I want to use autotools for this project. I read a couple of resources on autotools. But, I was only able to manage using autotools for a single level project where all source, object and other files reside in the same directory.

Then I got some links that talked about using autotools for deep projects like this one and then I got confused.

Right now I have two Makefile.am as follows

Makefile.am

SUBDIRS=src

src/Makefile.am

mainprgdir=../
mainprg_PROGRAMS=main
main_SOURCES=main.c

I am pretty sure that these files should not be as I have them now 😛

How do I use autotools for the above project structure? (At least what should be there in those Makefile.am(s) and where should I place them.

EDIT:
One more thing! At the end I would like to have the object files created in the bin directory.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:00:27+00:00Added an answer on May 31, 2026 at 8:00 am

    There are two main approaches. If the functions in SomeLibrarySource are used only by main, then there’s no need to build a separate library and you can simply specify the source files in src/Makefile.am

    main_SOURCES = main.c SomeLibrarySource/SomeFuncs.c
    

    However, if you actually want to use the functions in other code in your tree, you do not want to compile SomeFuncs.c multiple times but should use a convenience library.

    # Assigning main_SOURCES is redundant
    main_SOURCES = main.c
    main_LDADD = SomeLibrarySource/libSomeFuncs.a
    noinst_LIBRARIES = SomeLibrarySource/libSomeFuncs.a
    AM_CPPFLAGS = -I$(srcdir)/SomeLibrarySource
    

    (You’ll need AC_PROG_RANLIB in configure.ac to use convenience libraries.)
    If the source file is named SomeFuncs.c, automake will not need Makefile.am to specify SomeLibrarySource_libSomeFuncs_a_SOURCES, but if the name of the source code file does not match the name specified in noinst_LIBRARIES, SomeLibrarySource_libSomeFuncs_a_SOURCES should be set to the list of files used to build the library. Note that you do not need to specify main_SOURCES, since main.c is the default value if left unspecified (but it’s not a bad idea to be explicit.) (In all of this, I am not comfortable use CamlCase names, but the system I’m using uses a case insensitive file system (biggest mistake apple ever made) and the examples I give here are working for me. YMMV)

    You could of course do a recursive make, or build the library as a separate project and install it. (I like the final option. Libraries with useful features should exist on their own.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Python project that has the following structure: package1 class.py class2.py ...
I have a software project that has the following structure. - Library A -
I have a project that has the following line in the additional includes section:
I have a project that has a makefile with broken dependencies. Is there any
I have a project under my management. It has the following structure: $/Code/MainSolution $/Code/Branches
I have a (custom) php framework that contains following structure: app |-classes |-settings core
I have a windows phone 7 project with a page that has the following
I have a project which has the following directory structure. root --include ----module1 ----module2
I have a project that has a revision number of 3960. But unfortunately it
I have a project that has several build configurations (FREE version, male-only, female-only, etc.).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.