LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-02-2012, 08:57 AM   #1
RudraB
Member
 
Registered: Mar 2007
Distribution: Fedora
Posts: 264

Rep: Reputation: 23
help with automake


Dear Friends, My Project has a structure

$ tree
.
|-- callbk_list.h
|-- cwlst.h
|-- files
| |-- HELP.c
| |-- prop_A.c
| |-- prop_B.c
| |-- prop_C.c
| |-- ( And 100 more)
| `-- prop_Zr.c
|-- help.c
|-- Makefile
`-- table.c

which will be linked to main.c to create the executable. So, there will be *NO* executable in files/.
For this goal, my manually created Makefile is:
Code:
exe=ptbl 
CC=gcc 
CFLAGS =-O3 
SUBDIR=files 
PCONF1=pkg-config --cflags --libs gtk+-2.0 
sources := $(wildcard $(SUBDIR)/*.c) 
objects := $(sources:.c=.o) 
$(exe): $(objects) help.c  table.c  callbk_list.h  cwlst.h
         $(CC) `$(PCONF1)` $(objects) help.c  table.c -o $(exe)  
$(SUBDIR)/%.o: $(SUBDIR)/%.c
         $(CC) -c `$(PCONF1)` $<
         mv $(*F).o $(SUBDIR)/$(*D)  
clean:         rm -vf $(SUBDIR)/*.o $(exe)
I would like to achieve the same goal using autotools.
I googled, but all seems to assume there is a executable in each directory, like each, for me, files/Makefile.am *MUST* have a bin_PROGRAM, which is *NOT* what I am looking for. Can you kindly help me?

Last edited by RudraB; 10-02-2012 at 09:11 AM.
 
Old 10-02-2012, 09:02 AM   #2
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 647

Rep: Reputation: 189Reputation: 189
How can you expect one to read that unreadable mess, while even TABs matter in Makefiles?
Please edit your first post using [code][/code] tags around source code/commands output to make it readable.
 
Old 10-02-2012, 09:17 AM   #3
RudraB
Member
 
Registered: Mar 2007
Distribution: Fedora
Posts: 264

Original Poster
Rep: Reputation: 23
Edited, and viewable now.
Please have a look.
 
Old 10-02-2012, 09:30 AM   #4
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 647

Rep: Reputation: 189Reputation: 189
Thanks, that's so much better.
I'm not too fluent with autotools (having written only one project with them), but I didn't have to specify a bin_PROGRAM when compiling some source files to be later linked into the executable. What I had to do, however, was to specify a lib_LIBRARIES variable containing the name of the static library I was gonna use thereon.
This is my Makefile.am for that small library (just a parser for a 3D mesh specification text file):
Code:
GRAMMAR_PREFIX=mfile_
SUBDIRS=m_files
noinst_PROGRAMS=parseTest
lib_LIBRARIES=libmfile.a

## Had to add the autogenerated lexer and parser to LDADD... O_o

AM_YFLAGS=-d -p $(GRAMMAR_PREFIX)
AM_CFLAGS=-Im_files/ -I..
libmfile_a_SOURCES=m_files/m_lexer.l m_files/m_parser.y m_parsing_util.c m_print_visitor.c m_stats_visitor.c m_toMeshDescriptor.c ../meshUtil.c libmfile_wrapper.c
parseTest_LDADD=libmfile.a
parseTest_SOURCES=test_m_parsing.c
You can safely ignore those AM_YFLAGS (automake flags for yacc) and things regarding parseTest, as it just was a test program to see if the parsing went smooth with some example files.
To use the code compiled as a static library, you'll add to modify your top level binary LDADD flags, eg:
Code:
bin_PROGRAMS=foo

foo_LDADD=dir/libbar.a
Hope this is helpful.
 
Old 10-02-2012, 09:40 AM   #5
RudraB
Member
 
Registered: Mar 2007
Distribution: Fedora
Posts: 264

Original Poster
Rep: Reputation: 23
Thanks,
I will try.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
About Automake vddmanikanta Programming 2 08-02-2009 06:10 AM
automake Sc0pE Linux - Software 2 05-13-2005 10:11 AM
Scribus installation problem, sez I need automake 1.6 when automake 1.9 is istalled Rockgod2099 Linux - Software 13 11-14-2004 06:37 PM
slackware 9 asking for automake 1.6 while i have automake 1.7 gtgoku Slackware 1 10-19-2003 08:59 AM
automake verigoth Programming 0 09-16-2002 12:36 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration