Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build mlterm with either Cocoa or X11 #2

Merged
merged 1 commit into from May 3, 2016
Merged

Build mlterm with either Cocoa or X11 #2

merged 1 commit into from May 3, 2016

Conversation

lucafavatella
Copy link

@lucafavatella lucafavatella commented Apr 17, 2016

Please refer to commit message for details.

Following discussion on #1.

Having to build mlterm with either Cocoa or X11, as Cocoa require no
dependency to be installed while X11 do, require the user to
explicitly specify X11 if preferred and leave the lack of formula
options (hence default) to mean Cocoa.  Hence `depends_on :x11 =>
:optional` - not `:recommended`.

BTW had mutually exclusive formula options needed to be checked, an
example would have been
https://github.com/Homebrew/homebrew-core/blob/375a03fb3d9e960bf7b86bc8c43c08e136120890/Formula/infer.rb#L23-L25
@lucafavatella
Copy link
Author

--with-x looks like undocumented option - see https://bitbucket.org/arakiken/mlterm/src/rel-3_7_0/README - hence avoided.

@lucafavatella
Copy link
Author

41d4af2 used to have also:

depends_on 'gdk-pixbuf'
depends_on 'cairo'
depends_on 'gtk+'

...

... "--with-imagelib=gdk-pixbuf", "--with-type-engines=cairo" ...

I am not sure whether they apply to both cocoa and X11.

Also, I am not sure about relationship among deps and options - in particular why gtk+?

Reducing number of options simplifies formula.

New options could be added in later commits.

@lucafavatella
Copy link
Author

@saitoha Can you test X11 please?

@saitoha
Copy link
Owner

saitoha commented Apr 27, 2016

@lucafavatella Thanks, I'll test it tomorrow.

@saitoha
Copy link
Owner

saitoha commented Apr 27, 2016

@lucafavatella (CC: @arakiken, @seiichi)

$ brew options https://raw.githubusercontent.com/lucafavatella/homebrew-sixel/mlterm-x-ci/mlterm.rb
######################################################################## 100.0%
--with-x11
    Build with x11 support

$ brew install --with-x11 https://raw.githubusercontent.com/lucafavatella/homebrew-sixel/mlterm-x-ci/mlterm.rb
######################################################################## 100.0%
==> Downloading https://downloads.sourceforge.net/project/mlterm/01release/mlterm-3.7.0/mlterm-3.7.0.tar.gz
Already downloaded: /Library/Caches/Homebrew/mlterm-3.7.0.tar.gz
==> ./configure --prefix=/usr/local/Cellar/mlterm/3.7.0 --with-gui=xlib
==> make install
Last 15 lines from /Users/hsaito/Library/Logs/Homebrew/mlterm/02.make:
flag during linking and do at least one of the following:
   - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
     during execution

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
make[1]: Nothing to be done for `install'.
mkdir -p /usr/local/Cellar/mlterm/3.7.0/bin
../libtool --mode=install /usr/bin/install -c -m 2755 -g utmp mlterm /usr/local/Cellar/mlterm/3.7.0/bin
/usr/bin/install -c -m 2755 -g utmp .libs/mlterm /usr/local/Cellar/mlterm/3.7.0/bin/mlterm
install: /usr/local/Cellar/mlterm/3.7.0/bin/mlterm: chown/chgrp: Operation not permitted
make[1]: *** [install] Error 71
/bin/sh: line 0: exit: BUILD_SUCCESS: numeric argument required
make: *** [install] Error 255
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.

READ THIS: https://git.io/brew-troubleshooting

The install process failed by the argument "-g utmp" which is enabled by revision 2528.

$ hg diff -c 2528 configure.in |grep ^@@\ -661 -A10
@@ -661,8 +661,8 @@
 AC_SUBST(ML_PTY_OBJ)

 AC_ARG_ENABLE(utmp,
-   [  --enable-utmp           utmp (Experimental) @<:@default=disabled@:>@],
-   utmp=$enable_utmp, utmp="no")
+   [  --disable-utmp          utmp @<:@default=enabled@:>@],
+   utmp=$enable_utmp, utmp="yes")
 AC_ARG_ENABLE(pty_helper,
    [  --enable-pty-helper     use pty helper @<:@default=disabled@:>@],
    pty_helper=$enable_pty_helper)

So I added --enable-utmp=no to ./configure.

$ curl -s https://raw.githubusercontent.com/lucafavatella/homebrew-sixel/mlterm-x-ci/mlterm.rb | sed -e '14a\      args << "--enable-utmp=no"' > mlterm.rb
$ brew install --with-x11 mlterm.rb 
==> Downloading https://downloads.sourceforge.net/project/mlterm/01release/mlterm-3.7.0/mlterm-3.7.0.tar.gz
Already downloaded: /Library/Caches/Homebrew/mlterm-3.7.0.tar.gz
==> ./configure --prefix=/usr/local/Cellar/mlterm/3.7.0 --with-gui=xlib --enable-utmp=no
==> make install
🍺  /usr/local/Cellar/mlterm/3.7.0: 84 files, 9.4M, built in 1 minute 57 seconds
$ mlterm
dyld: Symbol not found: _kCFAllocatorDefault
  Referenced from: /usr/local/Cellar/mlterm/3.7.0/lib/libmlterm_core.dylib
  Expected in: flat namespace
 in /usr/local/Cellar/mlterm/3.7.0/lib/libmlterm_core.dylib
Trace/BPT trap: 5
$ otool -L /usr/local/bin/mlterm
/usr/local/bin/mlterm:
    /usr/local/Cellar/mlterm/3.7.0/lib/libmlterm_core.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/local/Cellar/mlterm/3.7.0/lib/libkik.16.dylib (compatibility version 17.0.0, current version 17.0.0)
    /usr/local/Cellar/mlterm/3.7.0/lib/libmkf.17.dylib (compatibility version 18.0.0, current version 18.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
    /opt/X11/lib/libX11.6.dylib (compatibility version 10.0.0, current version 10.0.0)
$ nm -a /usr/local/Cellar/mlterm/3.7.0/lib/libmlterm_core.dylib | grep _CF
                 U _CFStringAppendCharacters
                 U _CFStringCreateMutable
                 U _CFStringDelete
                 U _CFStringGetCharacters
                 U _CFStringGetLength
                 U _CFStringNormalize

Build succeeded. but a runtime error occured. I'll try it again tomorrow.

@saitoha
Copy link
Owner

saitoha commented Apr 29, 2016

@lucafavatella A patch for ml_char.c is needed.

class Mlterm < Formula
  homepage "http://mlterm.sourceforge.net/"
  url "https://downloads.sourceforge.net/project/mlterm/01release/mlterm-3.7.0/mlterm-3.7.0.tar.gz"
  sha256 "4a81d9e1957e4f0b8f8e0838ddad0cf4776fabc73465d886f2211bb8d990c339"

  depends_on "pkg-config" => :build
  depends_on :x11 => :optional

  patch :DATA

  def install
    args = ["--prefix=#{prefix}",
           ]

    if build.with? "x11"
      args << "--with-gui=xlib"
      args << "--enable-utmp=no"

      system "./configure", *args
      system "make", "install"
    else # Cocoa
      args << "--with-gui=quartz"

      system "./configure", *args
      system "make", "install"

      inreplace "cocoa/install.sh", "$HOME", "#{buildpath}/cocoa"
      system "cocoa/install.sh", "#{prefix}"
      prefix.install "cocoa/mlterm.app"

      (bin/"mlterm").unlink # Kill the existing symlink
      (bin/"mlterm").write <<-EOS.undent
          #!/bin/bash
          exec #{prefix}/mlterm.app/Contents/MacOS/mlterm "$@"
        EOS
    end

  end

end

__END__
diff -r 61224c609927 mlterm/ml_char.c
--- a/mlterm/ml_char.c  Thu Apr 28 02:09:38 2016 +0900
+++ b/mlterm/ml_char.c  Sat Apr 30 03:59:42 2016 +0900
@@ -189,7 +189,7 @@
    return  multi_ch + comb_size ;
 }

-#ifdef  __APPLE__
+#ifdef  USE_QUARTZ
 static void
 normalize(
    ml_char_t *  ch ,
@@ -465,7 +465,7 @@
    }
 }

-#ifdef  __APPLE__
+#ifdef  USE_QUARTZ
 #include  <kiklib/kik_mem.h>
 int  ml_normalize( u_int16_t *  str , int  num) ;
 #endif
@@ -521,7 +521,7 @@
        return  NULL ;
    }

-#ifdef  __APPLE__
+#ifdef  USE_QUARTZ
    normalize( ch , comb_size) ;
 #endif

@@ -557,7 +557,7 @@
    *comb = *src ;
    UNSET_COMB_TRAILING(comb->u.ch.attr) ;

-#ifdef  __APPLE__
+#ifdef  USE_QUARTZ
    normalize( ch , comb_size) ;
 #endif

@lucafavatella
Copy link
Author

@saitoha How do you prefer to proceed on this pull request? I am happy to add a commit to this pull request adding the documented option --disable-utmp. I am less happy to add the patch (wrt USE_QUARTZ) as I feel I do not understand it fully.

@saitoha saitoha merged commit 0063f80 into saitoha:master May 3, 2016
@saitoha
Copy link
Owner

saitoha commented May 3, 2016

OK, I have pulled this PR just as it is. I'll do the rest.
(USE_QUARTZ patch is needed to get rid of dependency of CoreFoundation, to fix a runtime error. I reported it to mlterm author. now it is fixed in hg HEAD. so that patch should be removed when mlterm 3.7.1 will be released.)
Thanks for your great works!

@lucafavatella lucafavatella deleted the mlterm-x branch May 4, 2016 07:33
jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Jun 21, 2016
Changes noted in doc/en/ReleaseNote:

ver 3.7.1
* Add "vt_color_mode" to OSC 5380 and 5381.
* Support SKK (--im skk) as an input method plugin.
* Support input method plugins (canna, wnn and skk) on MacOSX/Cocoa.
* Show the number of each conversion candidate on an input method window of wnn.
* Bug fixes:
  Fix compiling error of registobmp. (Enbugged at 3.7.0) (Thanks to Amadeusz)
  Fix https://sourceforge.net/p/mlterm/mailman/message/34992704/
  Fix saitoha/homebrew-sixel#2 (Thanks to @kefir_)
  Fix a bug which dropped almost all glyph complementary fonts.
duran pushed a commit to duran/mlterm that referenced this pull request Oct 6, 2019
* quartz/x_window.c: x_window_translate_coordinates() is implemented by using
  window_get_position().
* cocoa.[hm]:
  - window_get_position() is added.
  - NSShiftMask isn't ignored in insertText().
  - x_display_t::width and x_display_t::height are set in viewDidMoveToWindow.
* im_skk.c, im_wnn.c: dha dhi dhu dhe and dho are supported.
* skk/dict.c: input_method option accepts whether skk dictionary or skk server
  uses utf8 instead of eucjp.
  (e.g. --im skk:localhost:utf8)
* wnn/Makefile.in, canna/Makefile.in, skk/Makefile.in: TARGET_quartz is added.
* configure.in: skk, wnn and canna are available on MacOSX/Cocoa.
* configure.in, ml_char.c:
  Fix saitoha/homebrew-sixel#2
  (Merge https://bitbucket.org/arakiken/mlterm/pull-requests/2/ml_charc-strip-the-dependency-of with some fixes.)
* README, doc/ja/README.ja: Updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants