Chuck> I am trying to build executables for different target
Chuck> architectures (sparc, ppc) and would like to use the same
Chuck> source file directories and most likely the same Makefile (if
Chuck> possible) via providing the Makefile a TARGET variable.
Get yourself a copy of GNU Autoconf.
You can do it with GNU make, since it has pattern rules in addition to
crufty old suffix rules, but it does make your makefiles a little
crufty.
I use GNU make, and set up my makefiles so if make is invoked in the
source directory it immediately cd's to the objects directory and
re-invokes itself there. I use VPATH to find the sources.
That way you get the best of all possible worlds: your makefiles are
simple and straightforward; you can do things like "make foo.o", and not
have to remember to run "make targ/foo.o"; you use the same sources and
makefiles for all architectures, etc.
The only downside is the extra make invocation, but if you do it right
this won't slow things down much.
--
-------------------------------------------------------------------------------
Paul D. Smith <psm...@baynetworks.com> Network Management Development
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
These are my opinions--Bay Networks takes no responsibility for them.
I seem to have missed the original article also. However,
you might also want to look into IMAKE. O'Reilly has published
a good description of what it does and how it works. (It is
based on running makefile precursors thru the C preprocessor.)
IIRC, the IMAKE facility is distributed with X-windows. The
main purpose of it is to ease the task of targetting multiple
platforms. The platform adaptations for IMAKE are already
available for most Unix platforms. (If it has X-windows, it
probably has a set of IMAKE config files.)
--
--Larry
work: (425)557-1670 lar...@SsPqAiM.com
home: (206)236-2121 lar...@eaSrtPhlAinMk.net
Aforementioned views are likely mine alone.
(Remove "SPAM" from address for an email reply.)
>You cannot do this with normal make, AFAIK.
>You can do it with GNU make, since it has pattern rules in addition to
>crufty old suffix rules, but it does make your makefiles a little
>crufty.
>I use GNU make, and set up my makefiles so if make is invoked in the
>source directory it immediately cd's to the objects directory and
>re-invokes itself there. I use VPATH to find the sources.
>That way you get the best of all possible worlds: your makefiles are
>simple and straightforward; you can do things like "make foo.o", and not
>have to remember to run "make targ/foo.o"; you use the same sources and
>makefiles for all architectures, etc.
>The only downside is the extra make invocation, but if you do it right
>this won't slow things down much.
I have missed the orginal article, however, the intent of the followup
suggests you might want to look at "makeit". This is provided with OSE.
It is a series of makefiles which in conjunction with GNU make gives
cross platform portability (UNIX/UNIX and UNIX/Win32) as well as
portability between different vendors C++ compilers for your makefiles.
The results of builds on different platforms (and different compilers
if you desire) are kept in different subdirectories. The system even
allows for cross compilation to be carried out if you have the appropriate
compilers. Included below is what makefiles typically look like:
# Makeit Initialisation.
MODULES := c cc ose
include makeit/init.mk
# Module Initialisation/Definitions.
SUBDIRS :=
PROGRAMS :=
EXCLUDE :=
NONLIBSRC :=
CPPFLAGS :=
CFLAGS :=
C++FLAGS :=
LDFLAGS :=
LDLIBS :=
include makeit/modules.mk
# Additional Dependencies/Rules.
Ie., very simple. What functionality is brought in by specifying the
modules you want. There are modules for C and C++ code, lex, yacc, rpcgen,
shell script management, installation etc.
To have programs built, just list the name of the program in the PROGRAMS
variable. Makeit is smart enough to look at what you have in the directory
and work out how to build it. Ie., if it ain't a program code file, compile
it and stick it in a library. If it is a program code file, compile it and
link it against the library.
Anyway, this is a simplistic description. You can read the documentation
for makeit online at:
OSE is freely available for non commercial and commercial use. The only
main restriction is that you use it as a package and don't go modifying
it or carving it up etc. License details are on the site.
--
Graham Dumpleton (gra...@nms.otc.com.au)
--
Graham Dumpleton (gra...@nms.otc.com.au)