#636 Fixes for Mac OS X

None
closed-accepted
nobody
None
5
2013-09-24
2013-09-16
Per Persson
No

I've attached a patch that solves the problems of compiling gnuplot on OS X (for me, and with Aquaterm as the target terminal)

Related to patch #572 https://sourceforge.net/p/gnuplot/patches/572/ I guess.

Changes

  1. Configure can't find malloc.h: added sys/malloc.h to list
  2. Properly detecting frameworks on OS X: Updated the m4/apple.m4 file[1]
  3. Changed HAVE_LIBAQUATERM to HAVE_FRAMEWORK_AQUATERM

Tested on Mac OS X 10.8 with either clang/llvm or gcc 4.2.1

Regards,
Per


[1] There has never been a stand-alone libaquaterm, so the changes are fully backwards compatible.

1 Attachments

Discussion

  • Per Persson
    Per Persson
    2013-09-17

    (Follow up on my own post)

    Actually, the first hunk in the patch is unrelated to the rest.

    The problem:

    ./configure
    ...
    checking malloc.h usability... no
    checking malloc.h presence... no
    ...
    

    => Lots of conflicts during make (due to some fallback malloc?)

    According to man malloc on Mac OS X 10.8, malloc is declared in stdlib.h and the question is why configure requires malloc.h and fails to appreciate stdlib.h?

    So, while adding sys/malloc.h to the list in configure.in seems to work around the problem it doesn't address the root of the problem.

     
    • Lots of conflicts during make (due to some fallback malloc?)

      We'll see about that once you show some concrete details (compiler error messages, config.log, ...)

      he question is why configure requires malloc.h

      Because it doesn't. ;-)

      and fails to appreciate stdlib.h?

      Because it doesn't fail to.

       
      Last edit: Hans-Bernhard Broeker 2013-09-17
      • Per Persson
        Per Persson
        2013-09-18

        Embarrassingly enough, you are clearly right since I cannot reproduce the problem today. (Which I guess is good news ;-)

        Rest of the patch is still valid though?!

        FWIW I'm attaching config.log anyhow

        /Per

         
        Attachments
  • Ethan Merritt
    Ethan Merritt
    2013-09-17

    Could you upload a copy of the config.log file for the configuration run that got confused about malloc.h? Maybe I can spot the source of the problem.

     
  • Ethan Merritt
    Ethan Merritt
    2013-09-20

    I've added the framework/m4 changes to CVS for 4.7

    By the way, do you have any insight into the apparently unresolved issue reported in Bug #1188?
    https://sourceforge.net/p/gnuplot/bugs/1188/

     
  • Ethan Merritt
    Ethan Merritt
    2013-09-24

    • status: open --> closed-accepted
    • Group: -->
     
  • Per Persson
    Per Persson
    2013-10-02

    On 20 sep 2013, at 22:42, Ethan Merritt sfeam@users.sf.net wrote:

    I've added the framework/m4 changes to CVS for 4.7

    By the way, do you have any insight into the apparently unresolved issue reported in Bug #1188?
    https://sourceforge.net/p/gnuplot/bugs/1188/

    I can't reproduce it.

    I ended up finding a different bug (in AquaTerm) but from my point of view the changes from 2012-04-24 should be OK (although redundant if rect_clip == rect_image).

    I've pasted my notes below in case anyone digs further.

    /Per

    Debug notes

    Some API docs below.

    Problem

    Original code

    // rect_image = NSMakeRect(xPos, yPos, width, height) [adapter addImageWithBitmap:bitmap size:NSMakeSize(M, N) bounds:rect_image];
    This code uses the convenience function and scales the image to fit the destination bounds.

    Failed(?) code

    // NB. in test case rect_clip == rect_image // Image transform is unity [adapter setClipRect:rect_clip]; [adapter addImageWithBitmap:bitmap size:NSMakeSize(M, N) bounds:rect_image]; free(bitmap); [adapter setDefaultClipRect];
    I cannot reproduce the problem reported in gnuplot bug #1188, and since the example code snippet to demonstrate the bug will leave rect_clip == rect_image it should be identical to the original code.

    Generic (right?) code

    This is unfortunately thoroughly broken (in AquaTerm 1.1.x) on 64bit machines. A fix has been submitted to AquaTerm project.
    ```
    float m11 = rect_image.size.width/M; / scale x-axis /
    float m22 = rect_image.size.height/N; / scale y-axis /
    float tx = rect_image.origin.x; / translate x-origin /
    float ty = rect_image.origin.y; / translate y-origin /

    [adapter setImageTransformM11:m11 m12:m12 m21:m21 m22:m22 tX:tX tY:tY];
    [adapter setClipRect:rect_clip]; / Required /
    [adapter addImageWithBitmap:bitmap
    size:NSMakeSize(M, N)]
    ;
    free(bitmap);
    [adapter setDefaultClipRect];
    [adapter resetImageTransform];
    `` This would be the generic form where the original bitmap is freely transformed and clipped byrect_clip`.

    Examples/tests

    As above, but `rect_clip != rect_image produces the expected result,
    [adapter setClipRect:NSInsetRect(rect_clip, 100, 50)]; [adapter addImageWithBitmap:bitmap size:NSMakeSize(M, N) bounds:rect_image]; free(bitmap); [adapter setDefaultClipRect];

    as does a more general transform:
    ```
    // Draw two images, the first as expected and then draw a rotated image
    // inside a small clip on top of the first image.

    float m11 = rect_image.size.width/M; / scale x-axis /
    float m22 = rect_image.size.height/N; / scale y-axis /
    float tx = rect_image.origin.x; / translate x-origin /
    float ty = rect_image.origin.y; / translate y-origin /

    [adapter setClipRect:rect_image]; / Required non-zero /
    [adapter setImageTransformM11:m11 m12:0 m21:0 m22:m22 tX:tx tY:ty];
    [adapter addTransformedImageWithBitmap:bitmap
    size:NSMakeSize(M, N)]
    ;

    // Rotated image and slightly smaller clip rect
    [adapter setClipRect:NSInsetRect(rect_clip, 100, 50)];
    float cos_a = 0.707; / approx 1/sqrt(2) /
    float sin_a = cos_a;
    m11 = cos_a * rect_image.size.width/M;
    m22 = cos_a * rect_image.size.height/N;
    float m12 = sin_a * rect_image.size.width/M;
    float m21 = -sin_a * rect_image.size.height/N;
    [adapter setImageTransformM11:m11 m12:m12 m21:m21 m22:m22 tX:tx tY:ty];
    [adapter addTransformedImageWithBitmap:bitmap
    size:NSMakeSize(M, N)]
    ;

    free(bitmap);
    [adapter resetImageTransform];
    [adapter setDefaultClipRect];
    ```

    Aquaterm image API docs

    Transforms and clips

    ```
    / Set a transformation matrix for subsequent images.
    Transform matrix =
    / m11 m12 0 \ | m21 m22 0 |
    \ tX tY 1 /
    /
    - (void)setImageTransformM11:(float)m11 m12:(float)m12 m21:(float)m21 m22:(float)m22 tX:(float)tX tY:(float)tY;
    / Set transformation matrix to unity, i.e. no transform. /
    - (void)resetImageTransform;

    / Set a clipping region (rectangular) to apply to all subsequent operations, until changed again by -setClipRect: or -setDefaultClipRect. /
    - (void)setClipRect:(NSRect)clip;

    / Restore clipping region to the default (object bounds), i.e. no clipping performed. /
    - (void)setDefaultClipRect;
    ```

    Images

    - (void)addImageWithBitmap:(const void *)bitmap size:(NSSize)bitmapSize bounds:(NSRect)destBounds;
    Add a bitmap image of size bitmapSize (M, N) automatically scaled to fit destBounds. Bitmap format is 24bits per pixel in sequence RGBRGB... with 8 bits per color.
    This is a convenience function that scales the bitmap to fit the destination bound, it does not apply transform to the bitmap.

    - (void)addTransformedImageWithBitmap:(const void *)bitmap size:(NSSize)bitmapSize;
    Add a bitmap image of size (M, N) bitmapSize and apply current transform. Bitmap format is 24bits per pixel in sequence RGBRGB... with 8 bits per color. The transformed image will by clipped to the current clipRect, see -setClipRect:.

    - (void)addTransformedImageWithBitmap:(const void *)bitmap size:(NSSize)bitmapSize clipRect:(NSRect)destBounds;
    This form is deprecated. It changes the current clip rect to destBounds.