LinuxQuestions.org
Visit Jeremy's Blog.
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 12-31-2009, 12:27 PM   #31
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723

Quote:
Originally Posted by Sergei Steshenko View Post
As I already wrote, complexity of tutorials reflects real world mess.
What is that supposed to mean?
 
Old 01-01-2010, 03:11 PM   #32
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
here's one of my autogenerating makefiles...

Code:
#       ---------------------------------
#       Standard (GNU) makefile template
#       will take each source file as a 
#       single source stand-alone
#       ---------------------------------

# use this for setting variables e.g CFLAGS LDLIBS
# rather than editing this file
USER_FILE = user.mk
-include ${USER_FILE}

ECHO = @echo

ifndef EXT
ERROR: tidy
        @echo  
        @echo  "        you need to define  the filetype: 'EXT'"
        @echo
        @echo  "        i.e 'EXT = .c'"
        @echo  "        or  'EXT = .cc'"
        @echo  "        or  'EXT = .cpp'"
        @echo  
        @echo  "        you can do it in '$(USER_FILE)'" 
        @echo  
        exit
endif

ifneq ($(EXT),.c)
CC = g++
endif

VARFILE = var.mk
DEPENDFILE = depend.mk


# if EXT is not defined we need to make it something silly so
# that ls doesn't pick up spurious stuff (see the VARFILE target)
EXT ?= EXT_file_extension_type_not_defined 
-include ${VARFILE}

INCLUDES += -I${HOME}/include -I/usr/local/include
CFLAGS += -Wall ${INCLUDES}
CXXFLAGS += ${CFLAGS}

OBJFILES = ${SRC_FILES:${EXT}=.o}
TARGETS = ${SRC_FILES:${EXT}=} 


.IGNORE:
ALL:${TARGETS}  tidy


help: tidy
        ${ECHO} EXT = ${EXT}
        ${ECHO} CC = ${CC}
        ${ECHO} TARGETS = ${TARGETS}
        ${ECHO} OBJFILES = ${OBJFILES}
        ${ECHO} SRC_FILES = ${SRC_FILES}

RCS:
        mkdir RCS

safe: RCS tidy 
        echo auto generated | ci -t/dev/null -l ${SRC_FILES}  *.h

tidy:
ifeq (${MAKE_GZIPS},yes)
        gzip -f  ${DEPENDFILE} ${VARFILE}
endif
        @rm -f  ${DEPENDFILE} ${VARFILE} 

clean: tidy
        rm -f *.o  ${RCSMESSAGE}
        ${ECHO} use 'purge' to get rid of programs

purge:clean
        rm -f ${TARGETS} 
        rm -f ${DEPENDFILE}.gz ${VARFILE}.gz


${DEPENDFILE}:
        @${CC} -M ${INCLUDES} *${EXT} > $@

${VARFILE}:
        -@ls *${EXT}   | xargs echo SRC_FILES= > $@

# generated dependencies (Needs to go late in the file)
-include ${DEPENDFILE}
 
Old 01-01-2010, 07:55 PM   #33
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by MTK358 View Post
What is that supposed to mean?
Read the official GNU autotools documentation - it begins with detailed explanation of the above.

Also, consider carefully my simple example earlier in this thread:

http://www.linuxquestions.org/questi...73#post3808073
 
Old 01-01-2010, 08:46 PM   #34
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
The real-world mess is that there are so many different implementations of POSIX that writing a build chain to work on more than one of them can be more work than the rest of the development process. Autotools is an attempt to offload those portability problems so that the developer can concentrate on programming, not on porting the build chain.
Kevin Barry
 
Old 01-02-2010, 02:32 AM   #35
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by ta0kira View Post
The real-world mess is that there are so many different implementations of POSIX that writing a build chain to work on more than one of them can be more work than the rest of the development process. Autotools is an attempt to offload those portability problems so that the developer can concentrate on programming, not on porting the build chain.
Kevin Barry
Yep.
 
  


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
LXer: Automatically writing makefiles with Automake LXer Syndicated Linux News 0 06-04-2008 04:11 PM
LXer: Automatically generate PHP documentation from Subversion with phpDocumentor LXer Syndicated Linux News 0 11-05-2007 11:41 AM
How to generate Prerequisites automatically for makefile Greatrebel Programming 1 03-07-2007 09:32 AM
(bash) echo "#!/bin/bash" event not found - trying to generate profiles automatically jimieee Programming 9 05-03-2006 10:24 AM
Dynamically generate a webage and update it automatically using RSS xbaez Programming 7 01-31-2006 10:47 PM

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

All times are GMT -5. The time now is 01:58 AM.

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