[Bf-committers] Re: Compiling under Windows with MinGW

Ray Fonk sh484090 at 12move.nl
Sat Oct 23 18:56:37 CEST 2004

Martin Middleton <martin.middleton at verizon.net> wrote:
> I did this same thing in guess.config. My vote is for this solution.


Building on your and Hans' comments, I did a little more work to generalize
my mingw hacks to a proposal that hopefully won't break anything and could
be used by others.
It needs checking by jesterking (for buildinfo.c) and others though. See
attached file for description. Hope this is helpful.



12move ADSL nu de eerste maand voor maar € 8,95! GRATIS modem, 
GEEN aansluitkosten en GEEN datalimiet! Ga nu naar http://adsl.12move.nl

-------------- next part --------------

Following tested on Win98SE using mingw, msys 1.0.10 and GCC 3.4.
bf-blender directory assumed to be the root of the source tree,

Proposed code changes

1) Patch bf-blender/source/tools/guess/guessconfig by adding the following 
lines after line 83: 

    if [ "$OS" = "mingw" ]; then

This ensures that OS='windows' on mingw.
Note: With this solution make cannot distinguish between cygwin and mingw build platforms.
Don't know at this point whether this would be needed, but note for future reference.

2) In bf-blender/source/blender/makesdna/intern/Makefile: change as follows

$(DIR)/$(DEBUG_DIR)DNA.c: $(DIR)/$(DEBUG_DIR)makesdna
    ifeq ($(OS),windows)
      ifeq( $(FREE_WINDOWS),true)
<TAB>$(DIR)/$(DEBUG_DIR)makesdna $(DIR)/$(DEBUG_DIR)DNA.c
<TAB>$(SRCHOME)/tools/cygwin/cl_wrapper.pl - $(DIR)/$(DEBUG_DIR)makesdna \
<TAB>$(DIR)/$(DEBUG_DIR)makesdna $(DIR)/$(DEBUG_DIR)DNA.c
Reason: The cl_wrapper.pl perl script generates a VC++ style compiler call 
which we don't need on FREE_WINDOWS.
NOTE: Needs to be verified for other platforms (cygwin).

3) Remove trailing slashes end of CPPFLAGS include directives:
In bf-blender/blender/source/blender/blenlib/intern/Makefile: 
    CPPFLAGS += -I../../include/
In bf-blender/blender/source/blender/blenloader/intern/Makefile: 
    CPPFLAGS += -I../../render/extern/include/
Reason: GCC 3.4 doesn't seem to like the trailing slash and fails to find 
include files in this path, and makes these conform all other -I lines.

4) In bf-blender/source/blender/creator/buildinfo.c: 

This one is tricky: currently the buildinfo.h file is only generated by the SConstruct file under windows.
See bf-blender/blender/SConstruct lines 1040 ff:

	if user_options_dict['USE_BUILDINFO'] == 1:
		if sys.platform=='win32':
			build_info_file = open("source/creator/winbuildinfo.h", 'w')
			build_info_file.write("char *build_date=\"%s\";\n"%build_date)
			build_info_file.write("char *build_time=\"%s\";\n"%build_time)
			build_info_file.write("char *build_platform=\"win32\";\n")
			build_info_file.write("char *build_type=\"%s\";\n"%build_type)
			env.Append (CPPDEFINES = ['BUILD_TIME=\'"%s"\''%(build_time),

Jesterking added this back in March (rev 1.24), probably for good reason, but unfortunately 
the CVS log doesn't say why the original version (else: clause) didn't work. 
If possible, I would vote to always use the else: clause so that buildinfo.c can simply be

char * build_date=BUILD_DATE;
char * build_time=BUILD_TIME;
char * build_platform=BUILD_PLATFORM;
char * build_type=BUILD_TYPE;

Probably, jesterking should have a look at this. 
As a minimum, I think SCons and make should be doing the same thing...

It appears to me that after (2) and (4) have been checked by cygwin and SCons
teams respectively and not shown to break anything else, these changes should be robust.

Building blender
After applying above changes, steps are simply:

A) Create clean source tree in bf-blender/blender 
and have all libraries in bf-blender/lib/windows.

B) Add "user-def.mk" file to bf-blender/blender with following line:

    export FREE_WINDOWS=true

and one should be in good shape.

More information about the Bf-committers mailing list