octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MacOSX: ismac() implementation


From: Thomas Treichl
Subject: Re: MacOSX: ismac() implementation
Date: Fri, 05 Oct 2007 23:39:28 +0200
User-agent: Thunderbird 2.0.0.6 (Macintosh/20070728)

On  6-Sep-2007, John W. Eaton wrote:
Sorry, I meant to put

  function retval = ismac ()

    if (nargin == 0)
      retval = octave_config_info ("mac");
    else
      print_usage ();
    endif

  endfunction

here.

| plus the copyright notice and doc string.
| | To make octave_config_info handle "mac", we need to change the
| following lines in the DEFUN for octave_config_info in toplev.cc
| | bool unix_system = true;
|       bool windows_system = false;
| | #if defined (WIN32)
|       windows_system = true;
|   #if !defined (__CYGWIN__)
|       unix_system = false;
|   #endif
|   #endif
| | m.assign ("unix", octave_value (unix_system));
|       m.assign ("windows", octave_value (windows_system));
| | to be something like | | bool unix_system = true;
|       bool mac_system = false;
|       bool windows_system = false;
| | #if defined (WIN32)
|       windows_system = true;
|   #if !defined (__CYGWIN__)
|       unix_system = false;
|   #endif
|   #endif
| | #if defined (???)
|       mac_system = true;
|   #endif
| | m.assign ("unix", octave_value (unix_system));
|       m.assign ("mac", octave_value (mac_system));
|       m.assign ("windows", octave_value (windows_system));
| | but I'm not sure what macro we should test. If there is nothing
| predefined, then we will need some kind of change in configure.in as
| well.
| | jwe

Hallo John,

I was working on this implementation and I had the idea to check for the compiler macros that come with the XCode Mac developer tools (ie. the macro __APPLE__) and to further check if we are running a Darwin kernel (producing __MACH__ executables). Both #defines are set by gcc for Mac.

If you say we better should use a test for this then the only check I could imagine is that we are again looking for a *darwin* canonical_host_type. So I hope that the implementation that I send with this email is ok?

Should Changelog descriptions normally also be part of a patch?

  Thomas


2007-10-05  Thomas Treichl  <address@hidden>

        * configure.in: Added '#define MACOS' for Apple Mac OS.

2007-10-05  Thomas Treichl  <address@hidden>

        * toplev.cc: Added field for Mac OS in DEFUN octave_config_info.

2007-10-05  Thomas Treichl  <address@hidden>

        * Makefile.in: Added ismac.m.
        * ismac.m: New function.
        * ispc.m: Added @seealso{ismac, isunix} in help text.
        * isunix.m: Added @seealso{ismac, ispc} in help text.
--- configure.in.~1.578.~       2007-10-05 17:51:25.000000000 +0200
+++ configure.in        2007-10-05 18:43:45.000000000 +0200
@@ -1909,6 +1909,10 @@
 typedef int sig_atomic_t;
 #endif
 
+#if defined (__APPLE__) && defined (__MACH__)
+#define MACOS 1
+#endif
+
 #if defined (_MSC_VER)
 #define __WIN32__
 #define WIN32
--- scripts/miscellaneous/Makefile.in.~1.28.~   2007-09-10 19:41:19.000000000 
+0200
+++ scripts/miscellaneous/Makefile.in   2007-10-05 18:32:27.000000000 +0200
@@ -24,7 +24,7 @@
   compare_versions.m computer.m copyfile.m cputime.m \
   delete.m dir.m doc.m dos.m dump_prefs.m \
   fileattrib.m fileparts.m flops.m fullfile.m getfield.m gunzip.m \
-  gzip.m inputname.m ispc.m isunix.m license.m list_primes.m ls.m \
+  gzip.m inputname.m ismac.m ispc.m isunix.m license.m list_primes.m ls.m \
   ls_command.m menu.m mex.m mexext.m mkoctfile.m movefile.m \
   news.m orderfields.m pack.m paren.m parseparams.m \
   run.m semicolon.m setfield.m single.m substruct.m swapbytes.m tar.m \
--- scripts/miscellaneous/ispc.m.~1.3.~ 2006-10-10 18:10:27.000000000 +0200
+++ scripts/miscellaneous/ispc.m        2007-10-05 17:56:30.000000000 +0200
@@ -20,6 +20,7 @@
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} ispc ()
 ## Return 1 if Octave is running on a Windows system and 0 otherwise.
+## @seealso{ismac, isunix}
 ## @end deftypefn
 
 function retval = ispc ()
--- scripts/miscellaneous/isunix.m.~1.3.~       2006-10-10 18:10:27.000000000 
+0200
+++ scripts/miscellaneous/isunix.m      2007-10-05 17:56:53.000000000 +0200
@@ -20,6 +20,7 @@
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} isunix ()
 ## Return 1 if Octave is running on a Unix-like system and 0 otherwise.
+## @seealso{ismac, ispc}
 ## @end deftypefn
 
 function retval = isunix ()
--- src/toplev.cc.~1.201.~      2007-07-30 19:51:57.000000000 +0200
+++ src/toplev.cc       2007-10-05 18:31:56.000000000 +0200
@@ -921,6 +921,7 @@
        }
 
       bool unix_system = true;
+      bool macos_system = false;
       bool windows_system = false;
 
 #if defined (WIN32)
@@ -930,7 +931,12 @@
 #endif
 #endif
 
+#if defined (MACOS)
+      macos_system = true; // Define true if we have a Mac-like system
+#endif
+
       m.assign ("unix", octave_value (unix_system));
+      m.assign ("macos", octave_value (macos_system));
       m.assign ("windows", octave_value (windows_system));
 
       initialized = true;
## Copyright (C) 2007 Thomas Treichl
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.
##
## Octave is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING.  If not, write to the Free
## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.

## -*- texinfo -*-
## @deftypefn {Function File} {} ismac ()
## Return 1 if Octave is running on a Mac-like system and 0 otherwise.
## @seealso{ispc, isunix}
## @end deftypefn

function retval = ismac ()

  if (nargin == 0)
    retval = octave_config_info ("macos");
  else
    print_usage ();
  endif

endfunction


reply via email to

[Prev in Thread] Current Thread [Next in Thread]