Makefile review

Started by
0 comments, last by KulSeran 12 years, 12 months ago
Here's a copy of one of my makefiles:

CC=g++
AR=ar
LIBS=-L./ -L/usr/lib

all: libhome.a cmwAmbassador direct

account_info.o: account_info.hh
cmwa_config_data.o: cmwa_config_data.hh
common_functions.o: common_functions.hh
local_messages.cg.o: local_messages.cg.hh
remote_messages.cg.o: remote_messages.cg.hh
quicklz.o: quicklz.h
Counter.o: Counter.hh
IO.o : IO.hh
SendBuffer.o: SendBuffer.hh
SendCompressedBuffer.o: SendCompressedBuffer.hh
File.o: File.hh
marshalling_integer.o: marshalling_integer.hh

objects = account_info.o cmwa_config_data.o common_functions.o local_messages.cg.o quicklz.o Counter.o IO.o SendBuffer.o SendCompressedBuffer.o File.o marshalling_integer.o

libhome.a: $(objects)
ar r libhome.a $(objects)

cmwAmbassador: cmwAmbassador.cc libhome.a remote_messages.cg.o
g++ -o cmwAmbassador $(CPPFLAGS) cmwAmbassador.cc remote_messages.cg.o libhome.a
ls -l cmwAmbassador

direct: direct.cc libhome.a
g++ -o direct $(CPPFLAGS) direct.cc libhome.a
ls -l direct

clean:
rm -f $(objects) remote_messages.cg.o libhome.a cmwAmbassador direct

-------------------------------- end of file --------------------------------------------------------------------

Can you give me some ideas on improving it? I'm probably going to change the name of the library, but haven't figured out what to call it yet.

There's a Windows version of the file here --http://webEbenezer.n...sc/makefile.mcr.
Thanks in advance.

Brian Wood
Ebenezer Enterprises
http://webEbenezer.net
Advertisement
I'd suggest switching to a build tool like CMake (http://www.cmake.org/). It takes a lot of the tedium out of creating makefiles, and it has the added benefits of also being able to produce project files for most IDEs, and for most compilers. And, since it supports out-of-source building you can run your builds from another directory and not clutter your source tree with object files. The out-of-source building also makes it easy to integrate with continuous integration tools like CruiseControl(http://cruisecontrol.sourceforge.net/).

This topic is closed to new replies.

Advertisement