Practical Problems with distribution D projects

FreeSlave freeslave93 at gmail.com
Mon Feb 24 17:59:45 PST 2014


You can use hack in Makefile to find out whether the current 
platform is Windows or not. Check for SystemRoot environment 
variable in this way:

ifdef SystemRoot
	SYSTEM=Windows
else ifdef SYSTEMROOT
	SYSTEM=Windows
else
	SYSTEM=Other
endif

In non-Windows case use Unix uname command to determine current 
platform (Linux, Darwin, etc).

If you don't want to force user to install MSys or Cygwin, use 
Windows-shell commands instead Unix ones. Example:

ifeq ($(SYSTEM), Windows)
	RM=cmd //C del
	CP=cmd //C copy
else
	RM=rm -f
	CP=cp
endif

So you can achieve some flexibility here.
Sometimes developers write separate makefiles named windows.mak 
and posix.mak, but those ones still can share common parts via 
include directive.


Also you can write small build-system for your project in D 
itself. Derelict uses this approach. It also allows to ensure 
that D compiler was installed and works properly.


More information about the Digitalmars-d mailing list