# ************************************************************************** # Makefile # # Makefile for creating MS Windows installers for the Coin binary SDK for # MS Windows. # # Prerequisites: # Cygwin system. # makensis - the nullsoft installer system # # Authors: # Lars J. Aas # ************************************************************************** project = coin Project = Coin major = @COIN_MAJOR_VERSION@ sdk_prefix = /tmp/coin3d/coin #sdk_prefix = ${prefix} top_srcdir = @top_srcdir@ # default c library option libc = md ALLCFLAGS = /noBool /WX DBGCFLAGS = $(ALLCFLAGS) /GZ /Zi /Yd OPTCFLAGS = $(ALLCFLAGS) /Oitgb1 /Gs DLLCFLAGS = /GD CONFIGUREOPTIONS = --enable-threads # --enable-threadsafe is disabled for performance reasons # --enable-3ds-import is disabled for stability (untested code) reasons BUILDOPTIONS = --disable-dependency-tracking --disable-libtool-lock BUILDS = buildfiles docs shared-release shared-debug # static-release static-debug # ************************************************************************** all:: $(BUILDS) $(project)-v$(VERSION)-install.exe # ************************************************************************** extract.sed: Makefile @echo -e "2,\$$ {\n/GENERAL PUBLIC LICENSE/,/END OF TERMS/ {\ns/\f//;\np;\n};\n};" >extract.sed unix2dos.sed: Makefile @echo -e "s/\$$/\r/;\np;" >unix2dos.sed LICENSE.TXT: extract.sed unix2dos.sed @cp $(top_srcdir)/LICENSE.GPL LICENSE.TXT; @for process in extract unix2dos; do \ sed -n -f $${process}.sed LICENSE.TMP; \ rm -f LICENSE.TXT; \ mv -f LICENSE.TMP LICENSE.TXT; \ rm -f $${process}.sed; \ done # FIXME: use full makensis path (and support spaces in the path)... # something like ac_subst $(sim_ac_makensis_exe) $(project)-v$(VERSION)-install.exe: $(project).nsi LICENSE.TXT $(project)-sdk.html makensis $(project).nsi $(Project)-$(VERSION): $(Project)-$(VERSION).tar.gz tar zxf $(Project)-$(VERSION).tar.gz # Note: Making the distdir target in the Makefile.in files, genereated # by automake, can cause two kinds of problems on cygwin. # Both problems are fixed below by modifying the Makefile.in files. # #### Problem 1 # # The first problem is that if $(DISTFILES) is too big (around 30502 # bytes on my system), the make aborts with the following error: # # mkdir -p -- ../../Coin-2.2.0a/src/elements/../../include/Inventor/elements # c:\cygwin\bin\bash.exe: *** fork: can't reserve memory for stack 0x40000 - # 0x240000, Win32 error 487 # 4 [main] bash 2220 sync_with_child: child 3112(0x6DC) died before # initialization with status code 0x1 # 438 [main] bash 2220 sync_with_child: *** child state waiting for # longjmp # /bin/bash: fork: Resource temporarily unavailable # make[2]: *** [distdir] Error 128 # # # Simplified case: # The following command line will fail with the error message mantioned # above: # # [1] # list='$(somevar)'; foo=`pwd` # # If I rewrite the line to (note change of quoting) : # # [2] # list='$(somevar)'; foo='pwd' # # list is set correctly, but foo, of course, isn't. # # If I replace this with the following, everything is OK (note the # non-existent semicollon on the first line) # # [3] # echo $(somevar) > somevar.txt # list=`cat somevar.txt`; foo=`pwd` # # This was the only fix I was able to come up with. I do not know why # [1] fails and [2] doesn't. I think it has to do with the maximum # command line size for bash when bash forks a sub-process. The first # error message comes from /winsup/cygwin/dcrt0.cc, # called from fork.c. # # A similar bug report can be found here: # http://savannah.gnu.org/bugs/?func=detailbug&bug_id=3467&group_id=353 # # # And another one (with a suggested solution): # http://www.cs.mu.oz.au/research/mercury/mailing-lists/mercury-reviews/mercury-reviews.0202/0162.html # # The fix will be removed when we've start using makefiles in the include # directories. # #### problem 2 # # The dist target in Makefile.in, generated by automake, is incompatible with # filesystems mounted in textmode under cygwin. A slight rewrite of the # offending line fixes the problem: # # Change # # $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz # # into # # GZIP=$(GZIP_ENV) $(AMTAR) czhof $(distdir).tar.gz $(distdir) # # Alternative fixes # - Abort make process if source directory is mounted in textmode # - Let the makefile mount the source directory in binary mode # - Try to convince the automake guys to change automake # (this will probably fail, see note in # autotool/devel/share/automake-1.7/am/distdir.am regarding this) # # 2003-11-19 thammer. $(Project)-$(VERSION).tar.gz: @( cd ..; \ itemlist=`find . -name Makefile`; \ for item in $$itemlist ; do \ cp $$item $$item.org; \ cat $$item.org | sed -e 's/distdir: \$$(DISTFILES)/distdir: \$$(DISTFILES)\n\techo \$$(DISTFILES)>distfiles.txt/' -e "s/list='\$$(DISTFILES)'/list=\`cat distfiles.txt\`/" >$$item; \ done; \ cp Makefile Makefile.org; \ cat Makefile.org | sed -e 's/$$(AMTAR) chof - $$(distdir) | GZIP=$$(GZIP_ENV) gzip -c >$$(distdir).tar.gz/GZIP=$$(GZIP_ENV) $$(AMTAR) czhof $$(distdir).tar.gz $$(distdir)/g' > Makefile; \ $(MAKE) dist; mv $(Project)-$(VERSION).tar.gz windows/ ) headerlist.nsi: $(project)_include.txt Makefile winpath=`CYGWIN= cygpath -w "$(sdk_prefix)"`; \ ( prevdir=; for path in `cat $(project)_include.txt`; do \ dir=`echo $$path | sed 's/\/[^\/]*$$//'`; \ if test x"$$dir" != x"$$prevdir"; then \ prevdir=$$dir; \ file=`echo $$path | sed 's/^.*\///g'`; \ dir=`echo $$dir | sed 's/\//\\\\/g'`; \ echo "SetOutPath \$$INSTDIR\\$$dir"; \ echo "File $$winpath\\$$dir\\*.h"; \ fi; \ done ) >headerlist.nsi $(project)_include.txt: Makefile (cd $(sdk_prefix); \ find include -type f -name *.h) \ > $(project)_include.txt sourcelist.nsi: $(project)_source.txt Makefile ( prevdir=""; for path in `cat $(project)_source.txt`; do \ dir=`echo $$path | sed 's/\/[^\/]*$$//'`; \ if test x"$$dir" != x"$$prevdir"; then \ prevdir=$$dir; \ file=`echo $$path | sed 's/^.*\///g'`; \ dir=`echo $$dir | sed 's/\//\\\\/g'`; \ echo "SetOutPath \$$INSTDIR\\source\\$$dir"; \ echo "File $$dir\\*"; \ fi; \ done ) >sourcelist.nsi $(project)_source.txt: $(Project)-$(VERSION) Makefile find $(Project)-$(VERSION) -type f \ > $(project)_source.txt buildfileslist.nsi: $(project)_build.txt Makefile ( prevdir=; for path in `cat $(project)_build.txt`; do \ dir=`echo $$path | sed 's/\/[^\/]*$$//'`; \ if test x"$$dir" != x"$$prevdir"; then \ prevdir=$$dir; \ file=`echo $$path | sed 's/^.*\///g'`; \ dir=`echo $$dir | sed 's/\//\\\\/g' | cut -c2-`; \ echo "SetOutPath \$$INSTDIR\\build$$dir"; \ echo "File .\\build-files$$dir\\$$file"; \ else \ dir=`echo $$dir | sed 's/\//\\\\/g' | cut -c2-`; \ file=`echo $$path | sed 's/^.*\///g'`; \ echo "File .\\build-files$$dir\\$$file"; \ fi; \ done ) >buildfileslist.nsi $(project)_build.txt: buildfiles (cd build-files; \ echo "./$(project)$(major).dsp"; \ echo "./$(project)$(major).dsw"; \ find . -type f -name "*.h") > $(project)_build.txt uninstall.nsi: Makefile ( cd $(sdk_prefix); \ for file in `find . -type f -depth`; do \ file=`echo $$file | sed 's/^.\///; s/\//\\\\/g'`; \ echo "Delete \$$INSTDIR\\$$file"; \ done; \ for dir in `find . -type d -depth`; do \ dir=`echo $$dir | sed 's/^.\///; s/\//\\\\/g'`; \ echo "RMDir \$$INSTDIR\\$$dir"; \ done ) >uninstall.nsi $(project).nsi: heading.nsi headerlist.nsi middle.nsi sourcelist.nsi bfheader.nsi buildfileslist.nsi post.nsi uninstall.nsi footer.nsi unix2dos.sed Makefile cat heading.nsi headerlist.nsi middle.nsi sourcelist.nsi bfheader.nsi buildfileslist.nsi post.nsi uninstall.nsi footer.nsi >$(project).tmp winpath=`CYGWIN= cygpath -w "$(sdk_prefix)"`; \ winpath=`echo $$winpath | sed -e 's/\\\\/\\\\\\\\/g'`; \ sed -e 's/@win_prefix@/'$$winpath'/g' \ -e 's/@sdk_version@/$(VERSION)/g' <$(project).tmp >$(project).tmp2 sed -n -f unix2dos.sed <$(project).tmp2 >$(project).nsi rm -f $(project).tmp $(project).tmp2 # ************************************************************************** build-docs/html/index.html: $(Project)-$(VERSION) @if test -d build-docs; then :; else mkdir build-docs; fi cd build-docs; \ ../$(Project)-$(VERSION)/configure \ --disable-build \ --enable-html htmldir=html/$(Project) \ --enable-html-help htmlhelpdir=htmlhelp \ --enable-man \ --prefix=$(sdk_prefix) cd build-docs/; \ $(MAKE) cd build-docs/; \ $(MAKE) install if test -d "$(top_srcdir)/docs/images"; then \ mkdir -p build-docs/html/images; \ cp -R "$(top_srcdir)/docs/images/Coin" build-docs/html/images; \ cp -R "$(top_srcdir)/docs/images/SoGuiExamples" build-docs/html/images; \ for file in `find "build-docs/html" -name "*.html"`; do \ sed -i -e 's%http://doc.coin3d.org/images/%images/%g' $$file; \ done; \ fi -if test -d "$(top_srcdir)/docs/images"; then \ cd "build-docs/html"; \ hhc index.hhp; \ fi docs: build-docs/html/index.html build-shared-release/src/$(project)$(major).dll: $(Project)-$(VERSION) @if test -d build-shared-release; then :; else mkdir build-shared-release; fi cd build-shared-release; \ ../$(Project)-$(VERSION)/configure \ CFLAGS="$(OPTCFLAGS) $(DLLCFLAGS)" \ CXXFLAGS="$(OPTCFLAGS) $(DLLCFLAGS)" \ $(CONFIGUREOPTIONS) \ $(BUILDOPTIONS) \ --disable-debug \ --disable-symbols \ --with-msvcrt=$(libc) \ --prefix=$(sdk_prefix) cd build-shared-release; \ $(MAKE) cd build-shared-release; \ $(MAKE) install shared-release: build-shared-release/src/$(project)$(major).dll build-shared-debug/src/$(project)$(major)d.dll: $(Project)-$(VERSION) @if test -d build-shared-debug; then :; else mkdir build-shared-debug; fi cd build-shared-debug; \ ../$(Project)-$(VERSION)/configure \ CFLAGS="$(DBGCFLAGS)" \ CXXFLAGS="$(DBGCFLAGS)" \ $(CONFIGUREOPTIONS) \ $(BUILDOPTIONS) \ --enable-debug \ --enable-symbols \ --with-msvcrt=$(libc)d \ --with-alternate=debug \ --with-suffix=d \ --prefix=$(sdk_prefix) cd build-shared-debug; \ $(MAKE) cd build-shared-debug; \ $(MAKE) install shared-debug: build-shared-debug/src/$(project)$(major)d.dll build-static-release/src/$(project)$(major)d.dll: $(Project)-$(VERSION) @if test -d build-static-release; then :; else mkdir build-static-release; fi cd build-static-release; \ ../$(Project)-$(VERSION)/configure \ CFLAGS="$(OPTCFLAGS)" \ CXXFLAGS="$(OPTCFLAGS)" \ $(CONFIGUREOPTIONS) \ $(BUILDOPTIONS) \ --disable-shared \ --disable-debug \ --disable-symbols \ --with-msvcrt=$(libc) \ --with-alternate=static \ --with-suffix=s \ --prefix=$(sdk_prefix) cd build-static-release; \ $(MAKE) cd build-static-release; \ $(MAKE) install static-release: build-static-release/src/$(project)$(major)d.dll build-static-debug/src/$(project)$(major)d.dll: $(Project)-$(VERSION) @if test -d build-static-debug; then :; else mkdir build-static-debug; fi cd build-static-debug; \ ../$(Project)-$(VERSION)/configure \ CFLAGS="$(DBGCFLAGS)" \ CXXFLAGS="$(DBGCFLAGS)" \ $(CONFIGUREOPTIONS) \ $(BUILDOPTIONS) \ --disable-shared \ --enable-debug \ --enable-symbols \ --with-msvcrt=$(libc)d \ --with-alternate=static-debug \ --with-suffix=sd \ --prefix=$(sdk_prefix) cd build-static-debug; \ $(MAKE) cd build-static-debug; \ $(MAKE) install static-debug: build-static-debug/src/$(project)$(major)d.dll buildfiles: build-files/$(project)$(major).dsp build-files/$(project)$(major).dsp: $(Project)-$(VERSION) @if test -d build-files; then :; else mkdir build-files; fi builddir=`pwd`; \ cd build-files; \ ../$(Project)-$(VERSION)/configure \ $(CONFIGUREOPTIONS) \ $(BUILDOPTIONS) \ --enable-msvcdsp; \ $(MAKE) clean && $(MAKE); \ wbuilddir=`cygpath -w $$builddir | sed -e 's%\\\\%\\\\\\\\%g'`; \ version=`echo "@VERSION@" | sed -e 's%\.%\\\.%g'`; \ cp $(project)$(major).dsp $(project)$(major).dsp.orig; \ cat $(project)$(major).dsp.orig | \ sed -e "s%$$wbuilddir%\.\.\\\\\.\.%g" \ -e "s%\.\.\\\\source\\\\$(Project)-$$version%\.\.\\\\\.\.\\\\source\\\\$(Project)-$(major)%g" \ -e "s%\\\\$(Project)-$$version%%g" \ -e "s%/out:\"%/out:\"\.\.\\\\\.\.\\\\bin\\\\%g" \ -e "s%$(project)$(major)d\.dll\"%$(project)$(major)d\.dll\" /pdb:\"\.\.\\\\\.\.\\\\bin\\\\$(project)$(major)d.pdb\" /implib:\"\.\.\\\\\.\.\\\\lib\\\\$(project)$(major)d.lib\"%g" \ -e "s%$(project)$(major)\.dll\"%$(project)$(major)\.dll\" /implib:\"\.\.\\\\\.\.\\\\lib\\\\$(project)$(major).lib\"%g" \ > $(project)$(major).dsp; \ rm $(project)$(major).dsp.orig .PHONY: docs shared-release shared-debug static-release static-debug buildfiles # **************************************************************************