Changeset 78 for NEWT0/trunk

Show
Ignore:
Timestamp:
03/24/07 09:40:52 (20 months ago)
Author:
pguyot
Message:

Add support to install Newt/0 at a fixed location on a Unix system.
contrib/ Makefiles are now configured.
Makefiles now include install phases.
"Require" now uses a load path that is set by default based on configuration
parameters.

Location:
NEWT0/trunk
Files:
2 added
2 removed
12 modified

Legend:

Unmodified
Added
Removed
  • NEWT0/trunk/Makefile.in

    r56 r78  
    55build = ./build 
    66ext = ./ext 
     7contrib = ./contrib 
    78utils = $(srcdir)/utils 
    89parser = $(srcdir)/parser 
     
    1314docdir = $(build)/html 
    1415 
    15  
     16DESTROOT = 
    1617CC = @CC@ 
    1718YACC = @YACC@ -d 
     
    2526LDSHARED = @LIBNEWT_LDSHARED@ 
    2627 
     28prefix = @prefix@ 
     29exec_prefix = @exec_prefix@ 
     30bindir = @bindir@ 
     31sitedir = ${prefix}/lib/newt0 
    2732 
    2833VPATH = $(core) 
     
    6065                $(ext)/protoREGEX 
    6166 
     67CONTRIBLIBS   = $(contrib)/NewtObjC \ 
     68        $(contrib)/NativeCalls 
     69 
    6270OBJS          = $(MAINOBJ) $(UTILSOBJS) $(PARSEROBJS) $(COREOBJS) 
    6371 
     
    7179### all 
    7280 
    73 all: newt @MAKE_EXT@ 
    74  
     81all: newt @MAKE_EXT@ @MAKE_CONTRIB@ 
    7582 
    7683### make directory 
     
    132139    $(MAKE) -C $@ 
    133140 
     141contrib: $(CONTRIBLIBS) 
     142 
     143$(CONTRIBLIBS):: 
     144    $(MAKE) -C $@ 
    134145 
    135146### strip (for win) 
     
    160171    cd misc; doxygen doxygen.conf 
    161172 
     173### INSTALL 
     174 
     175.PHONY : install install_ext install_contrib 
     176 
     177install_ext:: 
     178    @for subdir in $(NEWTLIBS); do \ 
     179        (cd $$subdir && $(MAKE) install) || exit 1; \ 
     180    done 
     181 
     182install_contrib:: 
     183    @for subdir in $(CONTRIBLIBS); do \ 
     184        (cd $$subdir && $(MAKE) install) || exit 1; \ 
     185    done 
     186 
     187install:: 
     188    install -m 755 $(NEWT) $(DESTDIR)$(bindir) 
     189    install -d -m 755 $(DESTDIR)$(sitedir) 
     190    test "x@MAKE_EXT@" = x || $(MAKE) install_ext 
     191    test "x@MAKE_CONTRIB@" = x || $(MAKE) install_contrib 
    162192 
    163193### TEST 
  • NEWT0/trunk/configure

    r56 r78  
    312312#endif" 
    313313 
    314 ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT YACC LEX LEXLIB LEX_OUTPUT_ROOT AR ac_ct_AR RANLIB ac_ct_RANLIB build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CPP EGREP LIBOBJS NEWT_LDIMPORT NEWT_LDFLAGS LIBNEWT_LDSHARED LINK_NEWT_APP_ DLEXT MAKE_EXT LIBREGEX LTLIBOBJS' 
     314ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT YACC LEX LEXLIB LEX_OUTPUT_ROOT AR ac_ct_AR RANLIB ac_ct_RANLIB build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CPP EGREP LIBOBJS NEWT_LDIMPORT NEWT_LDFLAGS LIBNEWT_LDSHARED LINK_NEWT_APP_ DLEXT MAKE_EXT MAKE_CONTRIB BINDIR sitedir libffidir LIBREGEX LTLIBOBJS' 
    315315ac_subst_files='' 
    316316 
     
    846846   esac 
    847847  cat <<\_ACEOF 
     848 
     849Optional Packages: 
     850  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes] 
     851  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no) 
     852  --with-sitedir=DIR      site libraries in DIR [PREFIX/lib/newt0] 
     853  --with-libffidir=DIR    where libffi libraries can be found [PREFIX] 
    848854 
    849855Some influential environment variables: 
     
    48704876    LIBNEWT_LDSHARED='$(CC) -dynamic -bundle -undefined suppress -flat_namespace' 
    48714877    DLEXT='dylib' 
     4878    MAKE_CONTRIB='contrib' 
    48724879    ;; 
    48734880  cygwin*|mingw*) 
     
    49184925esac 
    49194926 
    4920  
    49214927case "$HAVE_DLOPEN" in 
    49224928  yes) 
     
    49294935esac 
    49304936 
    4931  
    4932 NEWT_LDFLAGS="$NEWT_LDFLAGS $LIBDL" 
     4937test "x$prefix" = xNONE && prefix=$ac_default_prefix 
     4938 
     4939 
     4940# Check whether --with-sitedir or --without-sitedir was given. 
     4941if test "${with_sitedir+set}" = set; then 
     4942  withval="$with_sitedir" 
     4943  sitedir=$withval 
     4944else 
     4945  sitedir='${prefix}/lib/newt0' 
     4946fi; 
     4947SITE_DIR="`eval \"echo ${sitedir}\"`" 
     4948 
     4949 
     4950# Check whether --with-libffidir or --without-libffidir was given. 
     4951if test "${with_libffidir+set}" = set; then 
     4952  withval="$with_libffidir" 
     4953  libffidir=$withval 
     4954else 
     4955  libffidir='${prefix}' 
     4956fi; 
    49334957 
    49344958cat >>confdefs.h <<_ACEOF 
     
    49404964_ACEOF 
    49414965 
    4942  
    4943  
    4944  
    4945  
    4946  
    4947  
    4948  
    4949  
    4950  
    4951  
    4952                               ac_config_files="$ac_config_files Makefile ext/protoFILE/Makefile ext/protoREGEX/Makefile" 
     4966cat >>confdefs.h <<_ACEOF 
     4967#define __LIBDIR__ "${SITE_DIR}" 
     4968_ACEOF 
     4969 
     4970 
     4971NEWT_LDFLAGS="$NEWT_LDFLAGS $LIBDL" 
     4972 
     4973 
     4974 
     4975 
     4976 
     4977 
     4978 
     4979 
     4980 
     4981 
     4982 
     4983 
     4984 
     4985 
     4986                                                  ac_config_files="$ac_config_files Makefile ext/protoFILE/Makefile ext/protoREGEX/Makefile contrib/NativeCalls/Makefile contrib/NewtObjC/Makefile" 
    49534987 
    49544988cat >confcache <<\_ACEOF 
     
    54795513  "ext/protoFILE/Makefile" ) CONFIG_FILES="$CONFIG_FILES ext/protoFILE/Makefile" ;; 
    54805514  "ext/protoREGEX/Makefile" ) CONFIG_FILES="$CONFIG_FILES ext/protoREGEX/Makefile" ;; 
     5515  "contrib/NativeCalls/Makefile" ) CONFIG_FILES="$CONFIG_FILES contrib/NativeCalls/Makefile" ;; 
     5516  "contrib/NewtObjC/Makefile" ) CONFIG_FILES="$CONFIG_FILES contrib/NewtObjC/Makefile" ;; 
    54815517  "src/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;; 
    54825518  *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 
     
    56005636s,@DLEXT@,$DLEXT,;t t 
    56015637s,@MAKE_EXT@,$MAKE_EXT,;t t 
     5638s,@MAKE_CONTRIB@,$MAKE_CONTRIB,;t t 
     5639s,@BINDIR@,$BINDIR,;t t 
     5640s,@sitedir@,$sitedir,;t t 
     5641s,@libffidir@,$libffidir,;t t 
    56025642s,@LIBREGEX@,$LIBREGEX,;t t 
    56035643s,@LTLIBOBJS@,$LTLIBOBJS,;t t 
  • NEWT0/trunk/configure.in

    r56 r78  
    103103    LIBNEWT_LDSHARED='$(CC) -dynamic -bundle -undefined suppress -flat_namespace' 
    104104    DLEXT='dylib' 
     105    MAKE_CONTRIB='contrib' 
    105106    ;; 
    106107  cygwin*|mingw*) 
     
    145146esac 
    146147 
    147  
    148148case "$HAVE_DLOPEN" in 
    149149  yes) 
     
    153153esac 
    154154 
     155test "x$prefix" = xNONE && prefix=$ac_default_prefix 
    155156 
    156 NEWT_LDFLAGS="$NEWT_LDFLAGS $LIBDL" 
     157AC_ARG_WITH(sitedir, 
     158    AS_HELP_STRING([--with-sitedir=DIR], 
     159        [site libraries in DIR [[PREFIX/lib/newt0]]]), 
     160    [sitedir=$withval], 
     161    [sitedir='${prefix}/lib/newt0']) 
     162SITE_DIR="`eval \"echo ${sitedir}\"`" 
     163 
     164AC_ARG_WITH(libffidir, 
     165    AS_HELP_STRING([--with-libffidir=DIR], 
     166        [where libffi libraries can be found [[PREFIX]]]), 
     167    [libffidir=$withval], 
     168    [libffidir='${prefix}']) 
    157169 
    158170AC_DEFINE_UNQUOTED(__PLATFORM__, "$target_os") 
    159171AC_DEFINE_UNQUOTED(__DYLIBSUFFIX__, ".$DLEXT") 
     172AC_DEFINE_UNQUOTED(__LIBDIR__, "${SITE_DIR}") 
     173 
     174NEWT_LDFLAGS="$NEWT_LDFLAGS $LIBDL" 
    160175 
    161176AC_SUBST(NEWT_LDIMPORT) 
     
    165180AC_SUBST(DLEXT) 
    166181AC_SUBST(MAKE_EXT) 
     182AC_SUBST(MAKE_CONTRIB) 
     183AC_SUBST(BINDIR) 
     184AC_SUBST(sitedir) 
     185AC_SUBST(libffidir) 
    167186 
    168187AC_SUBST(LIBREGEX) 
     
    170189AC_CONFIG_FILES([Makefile 
    171190                 ext/protoFILE/Makefile 
    172                  ext/protoREGEX/Makefile]) 
     191                 ext/protoREGEX/Makefile 
     192                 contrib/NativeCalls/Makefile 
     193                 contrib/NewtObjC/Makefile]) 
    173194AC_OUTPUT 
  • NEWT0/trunk/contrib/NativeCalls/README

    r31 r78  
    99--------- 
    1010NativeCalls can be compiled using GNU Make and libffi. 
    11 It was compiled with libffi-20030921 available from the pyobjc project. 
    12 http://prdownloads.sourceforge.net/pyobjc/libffi-src-20030921.tar.gz?download 
    13  
    14 By default, NativeCalls considers that libffi is in /opt/local (as installed 
    15 by DarwinPorts). You can select another location with LIBFFI_PREFIX variable. 
    16 For example, if libffi was installed with --prefix=/home/pguyot/unix, you can 
    17 compile NativeCalls with: 
    18 make LIBFFI_PREFIX=/home/pguyot/unix 
     11By default, configure (in trunk/) will configure the Makefile to use the libffi 
     12that exists in ${prefix}. 
    1913 
    2014Opening a library 
  • NEWT0/trunk/contrib/NewtObjC/NewtObjC.m

    r31 r78  
    4242// NEWT/0 
    4343#include "NewtCore.h" 
     44#include "config.h" 
    4445 
    4546// NewtObjC 
     
    6162{ 
    6263    // Load the objc-runtime extension dynamic library. 
    63     if (!NSAddLibraryWithSearching("@executable_path/objc-runtime-x.dylib")) 
     64    if (!NSAddLibraryWithSearching("@loader_path/objc-runtime-x.dylib") // Tiger and higher. 
     65        && !NSAddLibraryWithSearching("@executable_path/objc-runtime-x.dylib") // In-place. 
     66        && !NSAddLibraryWithSearching(__LIBDIR__ "/objc-runtime-x.dylib")) // Installed path. 
    6467    { 
    6568        (void) NewtThrow(kNErrObjCRuntimeErr, NewtMakeString("Couldn't find objc-runtime-x.dylib", true)); 
  • NEWT0/trunk/ext/protoFILE/Makefile.in

    r56 r78  
    99objdir = $(build)/obj 
    1010 
     11prefix = @prefix@ 
     12exec_prefix = @exec_prefix@ 
     13sitedir = ${prefix}/lib/newt0 
     14libdir = @libdir@ 
    1115 
    1216CC = @CC@ 
     
    5357    $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(NEWTLIBNAME).c 
    5458 
     59install:: 
     60    install -d -m 755 $(DESTDIR)$(sitedir) 
     61    install -m 644 $(NEWTEXLIB) $(DESTDIR)$(sitedir) 
     62 
    5563clean: 
    5664    rm -rf $(NEWTEXLIB) 
  • NEWT0/trunk/ext/protoREGEX/Makefile.in

    r56 r78  
    1212prefix = @prefix@ 
    1313exec_prefix = @exec_prefix@ 
     14sitedir = ${prefix}/lib/newt0 
    1415libdir = @libdir@ 
    1516 
     
    5960    $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(NEWTLIBNAME).c 
    6061 
     62install:: 
     63    install -d -m 755 $(DESTDIR)$(sitedir) 
     64    install -m 644 $(NEWTEXLIB) $(DESTDIR)$(sitedir) 
     65 
    6166clean: 
    6267    rm -rf $(NEWTEXLIB) 
  • NEWT0/trunk/src/config.h.in

    r56 r78  
    3232#undef __PLATFORM__ 
    3333#undef __DYLIBSUFFIX__ 
     34#undef __LIBDIR__ 
    3435 
    3536#undef __IPOD__ 
  • NEWT0/trunk/src/newt_core/NewtEnv.c

    r68 r78  
    220220{ 
    221221    struct { 
    222         char *      name; 
    223         newtRefVar  slot; 
    224         char *      defaultValue; 
    225         bool        ispath; 
     222        char *          name; 
     223        newtRefVar      slot; 
     224        const char *    defaultValue; 
    226225    } envs[] = { 
    227         {"NEWTLIB",     NSSYM0(NEWTLIB),    NULL,               true}, 
    228         {"PLATFORM",    NSSYM(PLATFORM),    __PLATFORM__,       false}, 
    229         {"DYLIBSUFFIX", NSSYM(DYLIBSUFFIX), __DYLIBSUFFIX__,    false}, 
    230         {NULL,          kNewtRefUnbind,     NULL,               false} 
     226        {"NEWTLIB",     NSSYM0(NEWTLIB),    __LIBDIR__ ":."}, 
     227        {"PLATFORM",    NSSYM(PLATFORM),    __PLATFORM__}, 
     228        {"DYLIBSUFFIX", NSSYM(DYLIBSUFFIX), __DYLIBSUFFIX__}, 
     229        {NULL,          kNewtRefUnbind,     NULL} 
    231230    }; 
    232231 
     
    241240    for (i = 0; envs[i].name != NULL; i++) 
    242241    { 
    243         v = NewtGetEnv(envs[i].name); 
    244  
    245         if (NewtRefIsString(v)) 
    246         { 
    247             if (envs[i].ispath) 
    248                 v = NcSplit(v, NewtMakeCharacter(':')); 
    249  
    250             NcSetSlot(proto, envs[i].slot, v); 
    251         } 
    252         else if (envs[i].defaultValue) 
    253         { 
    254             NcSetSlot(proto, envs[i].slot, NewtMakeString(envs[i].defaultValue, true)); 
    255         } 
     242        NcSetSlot(proto, envs[i].slot, NewtMakeString(envs[i].defaultValue, true)); 
     243    } 
     244 
     245    /* NEWTLIB is a special case, it can be overridden from the value in 
     246       the global variables. */ 
     247    v = NewtGetEnv("NEWTLIB"); 
     248    if (NewtRefIsString(v)) 
     249    { 
     250        v = NcSplit(v, NewtMakeCharacter(':')); 
     251        NcSetSlot(proto, NSSYM0(NEWTLIB), v); 
     252    } 
     253    else 
     254    { 
     255        newtRefVar default_newtlib_array[] = {NSSTR(__LIBDIR__), NSSTR(".")}; 
     256        newtRefVar default_newtlib = NewtMakeArray2( 
     257                kNewtRefNIL, 
     258                sizeof(default_newtlib_array) / sizeof(newtRefVar), 
     259                default_newtlib_array); 
     260        NcSetSlot(proto, NSSYM0(NEWTLIB), default_newtlib); 
    256261    } 
    257262 
  • NEWT0/trunk/src/newt_core/NewtFile.c

    r68 r78  
    537537        newtRefVar  path; 
    538538        uint32_t    len; 
     539        uint32_t    nb_suffixes; 
    539540        uint32_t    i; 
    540541        uint32_t    j; 
     
    547548        if (NewtRefIsNIL(newtlib)) 
    548549        { 
    549             newtRefVar  initPath[] = {NSSTR("."), NcGetGlobalVar(NSSYM0(_EXEDIR_))}; 
    550  
     550            newtRefVar  initPath[] = {NSSTR(__LIBDIR__), NSSTR(".")}; 
    551551            newtlib = NewtMakeArray2(kNewtRefNIL, sizeof(initPath) / sizeof(newtRefVar), initPath); 
    552552        } 
    553553 
    554554        len = NewtLength(newtlib); 
    555  
    556         for (i = 0; i < len; i++) 
     555        nb_suffixes = sizeof(lib_exts) / sizeof(lib_exts[0]); 
     556 
     557        for (j = 0; j < nb_suffixes; j++) 
    557558        { 
    558             dir = NewtGetArraySlot(newtlib, i); 
    559             NewtSetArraySlot(patharray, 0, NcJoinPath(dir, r)); 
    560  
    561             for (j = 0; j < sizeof(lib_exts) / sizeof(lib_exts[0]); j++) 
     559            NewtSetArraySlot(patharray, 1, lib_exts[j].ext); 
     560 
     561            for (i = 0; i <= len; i++) 
    562562            { 
    563                 NewtSetArraySlot(patharray, 1, lib_exts[j].ext); 
    564                 path = NcStringer(patharray); 
    565  
    566                 if (NewtFileExists(NewtRefToString(path))) 
     563                if (i == len) { 
     564                    dir = NcGetGlobalVar(NSSYM0(_EXEDIR_)); 
     565                } else { 
     566                    dir = NewtGetArraySlot(newtlib, i); 
     567                } 
     568                if (NewtRefIsString(dir)) 
    567569                { 
     570                    NewtSetArraySlot(patharray, 0, NcJoinPath(dir, r)); 
     571                    path = NcStringer(patharray); 
     572 
     573                    if (NewtFileExists(NewtRefToString(path))) 
     574                    { 
    568575#ifdef HAVE_DLOPEN 
    569                     if (lib_exts[j].type == typeDylib) 
    570                     { 
    571                         lib = NcLoadLib(path); 
    572                         NcSetSlot(requires, sym, lib); 
     576                        if (lib_exts[j].type == typeDylib) 
     577                        { 
     578                            lib = NcLoadLib(path); 
     579                            NcSetSlot(requires, sym, lib); 
     580                        } 
     581                        else 
     582#endif /* HAVE_DLOPEN */ 
     583                        { 
     584                            NcSetSlot(requires, sym, path); 
     585                            NcLoad(path); 
     586                        } 
     587     
     588                        return sym; 
    573589                    } 
    574                     else 
    575 #endif /* HAVE_DLOPEN */ 
    576                     { 
    577                         NcSetSlot(requires, sym, path); 
    578                         NcLoad(path); 
    579                     } 
    580  
    581                     return sym; 
    582590                } 
    583591            } 
  • NEWT0/trunk/src/newt_core/NewtObj.c

    r71 r78  
    3333static uint32_t     NewtObjStringLength(newtObjRef obj); 
    3434static newtObjRef   NewtObjStringSetLength(newtObjRef obj, uint32_t n); 
    35 static void         NewtMakeInitSlots(newtRefArg r, uint32_t st, uint32_t n, uint32_t step, newtRefVar v[]); 
     35static void         NewtMakeInitSlots(newtRefArg r, uint32_t st, uint32_t n, uint32_t step, const newtRefVar v[]); 
    3636static newtObjRef   NewtObjSlotsSetLength(newtObjRef obj, uint32_t n, newtRefArg v); 
    3737static int          NewtInt32Compare(newtRefArg r1, newtRefArg r2); 
     
    14331433} 
    14341434 
    1435 void NewtMakeInitSlots(newtRefArg r, uint32_t st, uint32_t n, uint32_t step, newtRefVar v[]) 
     1435void NewtMakeInitSlots(newtRefArg r, uint32_t st, uint32_t n, uint32_t step, const newtRefVar v[]) 
    14361436{ 
    14371437    if (v != NULL) 
     
    14611461 */ 
    14621462 
    1463 newtRef NewtMakeArray2(newtRefArg klass, uint32_t n, newtRefVar v[]) 
     1463newtRef NewtMakeArray2(newtRefArg klass, uint32_t n, const newtRefVar v[]) 
    14641464{ 
    14651465    newtRefVar  r; 
  • NEWT0/trunk/src/newt_core/incs/NewtObj.h

    r68 r78  
    169169newtRef     NewtMakeReal(double v); 
    170170newtRef     NewtMakeArray(newtRefArg klass, uint32_t n); 
    171 newtRef     NewtMakeArray2(newtRefArg klass, uint32_t n, newtRefVar v[]); 
     171newtRef     NewtMakeArray2(newtRefArg klass, uint32_t n, const newtRefVar v[]); 
    172172newtRef     NewtMakeMap(newtRefArg superMap, uint32_t n, newtRefVar v[]); 
    173173void        NewtSetMapFlags(newtRefArg map, int32_t bit);