boneyard/mapserver-64.rb
# TODO: audit and comapare against `mapserver` in core
audit and comapare against `mapserver` in core
audit and comapare against ` mapserver ` in core
def install
    (prefix/"msautotest").install resource("unittests") if build.with? "unit-tests"
    ENV.prepend_path "CMAKE_PREFIX_PATH", freetype_prefix
    ENV.prepend_path "CMAKE_PREFIX_PATH", png_prefix
    args = std_cmake_args
    if MacOS.prefer_64_bit?
      args << "-DCMAKE_OSX_ARCHITECTURES=#{Hardware::CPU.arch_64_bit}"
    else
      args << "-DCMAKE_OSX_ARCHITECTURES=i386"
    end
    args.concat %W[
      -DWITH_KML=ON
      -DWITH_CURL=ON
      -DWITH_CLIENT_WMS=ON
      -DWITH_CLIENT_WFS=ON
      -DWITH_SOS=ON
    ]
    args << "-DWITH_XMLMAPFILE=ON" if build.with? "xml-mapfile"
    args << "-DWITH_MYSQL=ON" if build.with? "mysql"
    args << "-DWITH_GD=ON" if build.with? "gd" && !build.head?
    args << "-DWITH_RSVG=ON" if build.with? "librsvg"
    mapscr_dir = prefix/"mapscript"
    mapscr_dir.mkpath
    rpath = %Q{-Wl,-rpath,"#{opt_prefix/"lib"}"}
    use_rpath = build.with? "rpath"
    cd "mapscript" do
      args << "-DWITH_PYTHON=ON"
      inreplace "python/CMakeLists.txt" do |s|
        s.gsub! "${PYTHON_SITE_PACKAGES}", %Q{"#{lib/which_python/"site-packages"}"}
        s.sub! "${MAPSERVER_LIBMAPSERVER}",
               "#{rpath} ${MAPSERVER_LIBMAPSERVER}" if use_rpath
      end
      args << "-DWITH_RUBY=ON"
      (mapscr_dir/"ruby").mkpath
      inreplace "ruby/CMakeLists.txt" do |s|
        s.gsub! "${RUBY_SITEARCHDIR}", %Q{"#{mapscr_dir}/ruby"}
        s.sub! "${MAPSERVER_LIBMAPSERVER}",
               "#{rpath} ${MAPSERVER_LIBMAPSERVER}" if use_rpath
      end
      if build.with? "php"
        args << "-DWITH_PHP=ON"
        (mapscr_dir/"php").mkpath
        inreplace "php/CMakeLists.txt" do |s|
          s.gsub! "${PHP5_EXTENSION_DIR}", %Q{"#{mapscr_dir}/php"}
          s.sub! "${MAPSERVER_LIBMAPSERVER}",
                 "#{rpath} ${MAPSERVER_LIBMAPSERVER}" if use_rpath
        end
      end
      args << "-DWITH_PERL=ON"
      (mapscr_dir/"perl").mkpath
      args << "-DCUSTOM_PERL_SITE_ARCH_DIR=#{mapscr_dir}/perl"
      inreplace "perl/CMakeLists.txt", "${MAPSERVER_LIBMAPSERVER}",
                "#{rpath} ${MAPSERVER_LIBMAPSERVER}" if use_rpath
      if build.with? "java"
        args << "-DWITH_JAVA=ON"
        ENV["JAVA_HOME"] = JavaJDK.home
        (mapscr_dir/"java").mkpath
        inreplace "java/CMakeLists.txt" do |s|
          s.gsub! "DESTINATION ${CMAKE_INSTALL_LIBDIR}",
                  %Q|${CMAKE_CURRENT_BINARY_DIR}/mapscript.jar DESTINATION "#{mapscr_dir}/java"|
          s.sub! "${MAPSERVER_LIBMAPSERVER}",
                 "#{rpath} ${MAPSERVER_LIBMAPSERVER}" if use_rpath
        end
      end
    end
    mkdir "build" do
      system "cmake", "..", *args
      system "make", "install"
    end
    (include/"mapserver").install Dir["*.h"]
    prefix.install "tests"
    (mapscr_dir/"python").install "mapscript/python/tests"
    cd "mapscript" do
      %w[python ruby perl].each {|x|(mapscr_dir/"#{x}").install "#{x}/examples"}
      (mapscr_dir/"php").install "php/examples" if build.with? "php"
      (mapscr_dir/"java").install "java/examples" if build.with? "java"
    end
    s = ""
    mapscr_opt_dir = opt_prefix/"mapscript"
    if build.with? "php"
      s += <<~EOS
        Using the built PHP module:
          * Add the following line to php.ini:
            extension="#{mapscr_opt_dir}/php/php_mapscript.so"
          * Execute "php -m"
          * You should see MapScript in the module list
      EOS
    end
    %w[ruby perl java].each do |m|
      if m != "java" or build.with? m
        cmd = []
        case m
        when "ruby"
          ruby_site = %x[ruby -r rbconfig -e 'puts RbConfig::CONFIG["sitearchdir"]'].chomp
          cmd << "sudo cp -f mapscript.bundle #{ruby_site}/"
        when "perl"
          perl_site = %x[perl -MConfig -e 'print $Config{"sitearch"};'].chomp
          cmd << "sudo cp -f mapscript.pm #{perl_site}/"
          cmd << "sudo cp -fR auto/mapscript #{perl_site}/auto/"
        when "java"
          cmd << "sudo cp -f libjavamapscript.jnilib mapscript.jar /Library/Java/Extensions/"
        else
        end
        s += <<~EOS
          Install the built #{m.upcase} module with:
            cd #{mapscr_opt_dir}/#{m}
            #{cmd[0]}
            #{cmd[1] + "\n" if cmd[1]}
        EOS
      end
    end
    (mapscr_dir/"Install_Modules.txt").write s
    if build.with? "docs"
      unless which("sphinx-build")
        sphinx_site = libexec/"lib/python2.7/site-packages"
        ENV.prepend_create_path "PYTHONPATH", sphinx_site
        resource("sphinx").stage {quiet_system "python2.7", "setup.py", "install", "--prefix=#{libexec}"}
        ENV.prepend_path "PATH", libexec/"bin"
      end
      resource("docs").stage do
        inreplace "Makefile", "$(TRANSLATIONS_I18N) $(TRANSLATIONS_STATIC)", ""
        system "make", "html"
        doc.install "build/html" => "html"
      end
    end
  end
def install ( prefix / "msautotest" ) . install resource ( "unittests" ) if build . with? "unit-tests" ENV . prepend_path "CMAKE_PREFIX_PATH" , freetype_prefix ENV . prepend_path "CMAKE_PREFIX_PATH" , png_prefix args = std_cmake_args if MacOS . prefer_64_bit? args << "-DCMAKE_OSX_ARCHITECTURES=#{Hardware::CPU.arch_64_bit}" else args << "-DCMAKE_OSX_ARCHITECTURES=i386" end args . concat %W[ -DWITH_KML=ON -DWITH_CURL=ON -DWITH_CLIENT_WMS=ON -DWITH_CLIENT_WFS=ON -DWITH_SOS=ON ] args << "-DWITH_XMLMAPFILE=ON" if build . with? "xml-mapfile" args << "-DWITH_MYSQL=ON" if build . with? "mysql" args << "-DWITH_GD=ON" if build . with? "gd" && ! build . head? args << "-DWITH_RSVG=ON" if build . with? "librsvg" mapscr_dir = prefix / "mapscript" mapscr_dir . mkpath rpath = %Q{-Wl,-rpath,"#{opt_prefix/"lib"}"} use_rpath = build . with? "rpath" cd "mapscript" do args << "-DWITH_PYTHON=ON" inreplace "python/CMakeLists.txt" do | s | s . gsub! "${PYTHON_SITE_PACKAGES}" , %Q{"#{lib/which_python/"site-packages"}"} s . sub! "${MAPSERVER_LIBMAPSERVER}" , "#{rpath} ${MAPSERVER_LIBMAPSERVER}" if use_rpath end args << "-DWITH_RUBY=ON" ( mapscr_dir / "ruby" ) . mkpath inreplace "ruby/CMakeLists.txt" do | s | s . gsub! "${RUBY_SITEARCHDIR}" , %Q{"#{mapscr_dir}/ruby"} s . sub! "${MAPSERVER_LIBMAPSERVER}" , "#{rpath} ${MAPSERVER_LIBMAPSERVER}" if use_rpath end if build . with? "php" args << "-DWITH_PHP=ON" ( mapscr_dir / "php" ) . mkpath inreplace "php/CMakeLists.txt" do | s | s . gsub! "${PHP5_EXTENSION_DIR}" , %Q{"#{mapscr_dir}/php"} s . sub! "${MAPSERVER_LIBMAPSERVER}" , "#{rpath} ${MAPSERVER_LIBMAPSERVER}" if use_rpath end end args << "-DWITH_PERL=ON" ( mapscr_dir / "perl" ) . mkpath args << "-DCUSTOM_PERL_SITE_ARCH_DIR=#{mapscr_dir}/perl" inreplace "perl/CMakeLists.txt" , "${MAPSERVER_LIBMAPSERVER}" , "#{rpath} ${MAPSERVER_LIBMAPSERVER}" if use_rpath if build . with? "java" args << "-DWITH_JAVA=ON" ENV [ "JAVA_HOME" ] = JavaJDK . home ( mapscr_dir / "java" ) . mkpath inreplace "java/CMakeLists.txt" do | s | s . gsub! "DESTINATION ${CMAKE_INSTALL_LIBDIR}" , %Q|${CMAKE_CURRENT_BINARY_DIR}/mapscript.jar DESTINATION "#{mapscr_dir}/java"| s . sub! "${MAPSERVER_LIBMAPSERVER}" , "#{rpath} ${MAPSERVER_LIBMAPSERVER}" if use_rpath end end end mkdir "build" do system "cmake" , ".." , * args system "make" , "install" end ( include / "mapserver" ) . install Dir [ "*.h" ] prefix . install "tests" ( mapscr_dir / "python" ) . install "mapscript/python/tests" cd "mapscript" do %w[ python ruby perl ] . each { | x | ( mapscr_dir / "#{x}" ) . install "#{x}/examples" } ( mapscr_dir / "php" ) . install "php/examples" if build . with? "php" ( mapscr_dir / "java" ) . install "java/examples" if build . with? "java" end s = "" mapscr_opt_dir = opt_prefix / "mapscript" if build . with? "php" s += <<~EOS 
        Using the built PHP module:
          * Add the following line to php.ini:
            extension=" #{ mapscr_opt_dir } /php/php_mapscript.so"
          * Execute "php -m"
          * You should see MapScript in the module list

       EOS end %w[ ruby perl java ] . each do | m | if m != "java" or build . with? m cmd = [ ] case m when "ruby" ruby_site = %x[ ruby -r rbconfig -e 'puts RbConfig::CONFIG["sitearchdir"]' ] . chomp cmd << "sudo cp -f mapscript.bundle #{ruby_site}/" when "perl" perl_site = %x[ perl -MConfig -e 'print $Config{"sitearch"};' ] . chomp cmd << "sudo cp -f mapscript.pm #{perl_site}/" cmd << "sudo cp -fR auto/mapscript #{perl_site}/auto/" when "java" cmd << "sudo cp -f libjavamapscript.jnilib mapscript.jar /Library/Java/Extensions/" else end s += <<~EOS 
          Install the built  #{ m . upcase }  module with:
            cd  #{ mapscr_opt_dir } / #{ m } #{ cmd [ 0 ] } #{ cmd [ 1 ] + "\n" if cmd [ 1 ] } EOS end end ( mapscr_dir / "Install_Modules.txt" ) . write s if build . with? "docs" unless which ( "sphinx-build" ) sphinx_site = libexec / "lib/python2.7/site-packages" ENV . prepend_create_path "PYTHONPATH" , sphinx_site resource ( "sphinx" ) . stage { quiet_system "python2.7" , "setup.py" , "install" , "--prefix=#{libexec}" } ENV . prepend_path "PATH" , libexec / "bin" end resource ( "docs" ) . stage do inreplace "Makefile" , "$(TRANSLATIONS_I18N) $(TRANSLATIONS_STATIC)" , "" system "make" , "html" doc . install "build/html" => "html" end end end
TODO: audit and comapare against `mapserver` in core
TODO : audit and comapare against ` mapserver ` in core
# install unit tests # defaults different than CMakeLists.txt (they don't incur extra dependencies) # override language extension install locations, e.g. install to prefix/"mapscript/lang" # install devel headers # write install instructions for modules # vendor a local sphinx install # just build the en docs