For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > October 2004 > Looking for Makefile example/help









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Looking for Makefile example/help
Billy N. Patton

2004-10-18, 4:00 pm

man make on my linux box is not much help.
Don't have a make book.

This directory is getting too crowded.
I would like to have it seperated out into the following directories

src
include
obj/Linux
obj/Solaris
bin/Linux
bin/Solaris
test/Linux
test/Solaris

The method below takes me a lot of time to maintain dependancies
makedepend does not recognize that some of the files are in a .a

Everything is currently in RCS


I don't use any ide, just a shell, nedit and a makefile.

Need example please.
Here's what I'd like to see. I know I'm close but syntax errors are
killing me:
define Cpu_type
if [ `/bin/uname -s` = 'SunOS' ] ; then echo SunOS ; \
elif [ `/bin/uname -s` = 'Linux' ] ; then echo Linux ; \
fi
endef

define Inst
if [ `/bin/uname -s` = 'SunOS' ] ; then echo
/usr/local/bin/install ; \
elif [ `/bin/uname -s` = 'Linux' ] ; then echo /usr/bin/install ; \
fi
endef

define Date_time
/bin/date '+%d%h%y/%H:%M\(%Z\)'
endef



CPP = purify -windows=no -log-file=purify.log g++
CPP = purify g++
CPP = g++
INC = -Iinclude
CPPFLAGS = -g3 -Wall -DDEBUG_LAFFREAD $(INC)
CPPFLAGS = -O3 -Wall $(INC)
CPPFLAGS = -g3 -O2 -Wall $(INC)
CPPFLAGS = -g3 -Wall $(INC)
OS = $(shell $(Cpu_type))
INSTALL = $(shell $(Inst))
OLIBS =
MKDIR = /bin/mkdir -p
PREFIX = .
MAKE_SH = /data/cdmg/dev/cdmg_toolbox/programs/make_sh
INS_DIR = $(PREFIX)/bin/$(OS)
LIBS = $(OS)/libcdmg.a $(OS)/lib/libpcre.a
LIB = $(OS)/libcdmg.a
TLIB = $(OS)/libcdmgT.a
AR = ar
AR_OPT = rv
AR_CREATE_OPT = cr
SRCDIR = src

# no syntax error to there
OBJ_FILES = \
$(LIB)(break_pyr.o) \
$(LIB)(ControlFile.o) \

T_OBJ_FILES = \
$(TLIB)(t_ListDirectory.o) \
$(TLIB)(t_MakePath.o) \
$(TLIB)(t_ExCommand.o) \
$(TLIB)(t_Ui.o) \

PROGRAMS = \
BreakPyrName \
CleanLaff \
FigsOnLayer \


..SUFFIXES:
..SUFFIXES: .cxx .cpp .c .a

all : $(LIB) \
$(addprefix $(OS)/,$(PROGRAMS)) <<<<< MISSING SPPERATOR HERE

..cxx.a : $(LIB)
$(CPP) -c $(CPPFLAGS) $<
$(AR) $(AR_OPT) $@ $*.o > /dev/null
rm $*.o

$(OS)/% : %.cxx
@if [ ! -d $(OS) ]; then \
$(MKDIR) $(OS) ; \
fi;
$(CPP) $(CPPFLAGS) $< -o $@ $(OLIBS) $(LIBS)

TEST : $(LIB) $(TLIB) TEST.cxx
$(CPP) $(CPPFLAGS) -o $(OS)/$@ TEST.cxx $(OLIBS) $(TLIB) $(LIBS) -lm

test : TEST
$(OS)/TEST 1> /dev/null

$(LIB) : $(OBJ_FILES)
$(AR) $(AR_CREATE_OPT) $(LIB)

$(TLIB) : $(T_OBJ_FILES)
$(AR) $(AR_CREATE_OPT) $(TLIB)


--
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodlogy Group
Dallas, Texas, 214-480-4455, b-patton@ti.com
Heiko

2004-10-18, 4:00 pm

Billy N. Patton wrote:

> man make on my linux box is not much help.
> Don't have a make book.


I don't know enough about make to answer your question, but "info make"
provides more complete information than "man make".

> This directory is getting too crowded.
> I would like to have it seperated out into the following directories


Have a look at "info make recursion".

Hope I could help (a little),

Heiko
Martin Carpenter

2004-10-19, 9:05 am


"Heiko" <heiko.noordhof_A_xs4all.nl> wrote:

> Have a look at "info make recursion".


Ha. Have a look at:

http://www.tip.net.au/~millerp/rmch...-cons-harm.html

Peter Miller's "Recursive Make Considered Harmful".

Even if you don't agree with the author's points - and it's a well written
paper IMHO - there are some interesting insights into make for the
intermediate user.



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com