[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Are makefiles intended to be portable across platforms?
From: |
Paul D. Smith |
Subject: |
Re: Are makefiles intended to be portable across platforms? |
Date: |
Thu, 30 Jun 2005 17:13:23 -0400 |
%% "Angel Tsankov" <address@hidden> writes:
at> Am I taking a bad path if I try to write one makefile to manage
at> (e.g., build & clean) a project on a couple of platforms? I'm
at> asking this question, 'casue makefiles seem not to be very
at> portable, right? For example, to define a clean target one might
at> have to write:
at> clean: ; if exist OutputFiles rmdir /S /Q OutputFiles
at> or
at> clean: ; if exist OutputFiles rmdir OutputFiles -R
at> depending on the platform that make is run on.
GNU make is portable, and makefiles themselves are portable (that is,
the same makefile will be read in and interpreted the same way on
different platforms).
But, make does much of its work by invoking a shell to run the actual
command scripts. In this way make is not portable, unless you have the
same shell on all your different platforms.
You can, of course, get Bourne-compatible shells and UNIX-style commands
for Windows, and use those. If you don't want to do that you'll need to
put some effort into making sure your makefile is portable: for example
maybe you include a different makefile segment defining make variables
for different things. In UNIX you might have:
RMDIR = rm -rf
On Windows you might have:
RMDIR = rmdir
then you just use $(RMDIR) in your command scripts.
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist