Ticket #1029: boost-tools.patch

File boost-tools.patch, 29.7 KB (added by ssolie, 10 years ago)

patch to add AmigaOS support to bjam and build

  • tools/build/v2/build-system.jam

    diff -N -r -u -b boost_1_34_0/tools/build/v2/build-system.jam boost_1_34_0_amiga/tools/build/v2/build-system.jam
    old new  
    113113    site-path = [ modules.peek : SystemRoot ] $(user-path) ;   
    114114}
    115115
     116if [ os.name ] = AMIGA
     117{
     118    site-path = /SDK/Local/Data $(user-path) ;
     119}
     120
    116121load-config site-config : $(site-path) ;
    117122
    118123#
  • tools/build/v2/tools/amiga.jam

    diff -N -r -u -b boost_1_34_0/tools/build/v2/tools/amiga.jam boost_1_34_0_amiga/tools/build/v2/tools/amiga.jam
    old new  
     1# Copyright 2007 Steven Solie
     2# Distributed under the Boost Software License, Version 1.0.
     3# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
     4
     5#  AmigaOS amiga.jam
     6#
     7
     8import toolset : flags ;
     9import property ;
     10import generators ;
     11import os ;
     12import type ;
     13import feature ;
     14import set ;
     15import common ;
     16import errors ;
     17import property-set ;
     18
     19toolset.register amiga ;
     20
     21import unix ;
     22toolset.inherit-generators amiga : unix ;
     23toolset.inherit-flags amiga : unix ;
     24toolset.inherit-rules amiga : unix ;
     25
     26
     27# Declare generators
     28generators.override amiga.searched-lib-generator : searched-lib-generator ;
     29generators.register-c-compiler amiga.compile.c : C : OBJ : <toolset>amiga ;
     30generators.register-c-compiler amiga.compile.c++ : CPP : OBJ : <toolset>amiga ;
     31
     32
     33rule init ( version ? : command * : options * )
     34{
     35    local condition = [ common.check-init-parameters amiga : version $(version) ] ;   
     36    local command = [ common.get-invocation-command amiga : g++ : $(command) ] ;
     37
     38    common.handle-options amiga : $(condition) : $(command) : $(options) ;
     39
     40    flags amiga.link NEED_STRIP $(condition)/<debug-symbols>off : "" ;
     41}
     42
     43
     44# Declare flags and actions
     45flags amiga.compile OPTIONS <optimization>off : -O0 ;
     46flags amiga.compile OPTIONS <optimization>speed : -O3 ;
     47flags amiga.compile OPTIONS <optimization>space : -Os ;
     48flags amiga.compile OPTIONS <inlining>off : -fno-inline ;
     49flags amiga.compile OPTIONS <inlining>on : -Wno-inline ;
     50flags amiga.compile OPTIONS <inlining>full : -finline-functions -Wno-inline ;
     51flags amiga.compile OPTIONS <warnings>off : -w ;
     52flags amiga.compile OPTIONS <warnings>on : -Wall -Wwrite-strings ;
     53flags amiga.compile OPTIONS <warnings>all : -Wall -Wwrite-strings -pedantic ;
     54flags amiga.compile OPTIONS <warnings-as-errors>on : -Werror ;
     55flags amiga.compile OPTIONS <debug-symbols>on : -ggdb ;
     56flags amiga.compile OPTIONS <profiling>on : -pg ;
     57flags amiga.compile DEFINES <define> ;
     58flags amiga.compile INCLUDES <include> ;
     59
     60flags amiga.link OPTIONS <debug-symbols>on : -ggdb ;
     61flags amiga.link OPTIONS <profiling>on : -pg ;
     62flags amiga.link LINKPATH <library-path> ;
     63flags amiga.link LIBRARIES <library-file> ;
     64
     65
     66actions compile.c
     67{
     68    "$(CONFIG_COMMAND)" -mcrt=clib2 $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
     69}
     70
     71
     72actions compile.c++
     73{
     74    "$(CONFIG_COMMAND)" -mcrt=clib2 -ftemplate-depth-128 $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
     75}
     76
     77
     78actions link bind LIBRARIES
     79{
     80    $(CONFIG_COMMAND) -mcrt=clib2 $(OPTIONS) -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -lstdc++ -lm -lunix
     81    $(NEED_STRIP)strip $(NEED_STRIP)-R.comment $(NEED_STRIP)"$(<)"
     82}
     83
     84
     85actions piecemeal archive
     86{
     87    ar -crs "$(<:T)" "$(>:T)"
     88}
  • tools/build/v2/tools/builtin.jam

    diff -N -r -u -b boost_1_34_0/tools/build/v2/tools/builtin.jam boost_1_34_0_amiga/tools/build/v2/tools/builtin.jam
    old new  
    6161            case MACOSX : host-os = darwin ;
    6262            case KFREEBSD : host-os = freebsd ;
    6363            case LINUX : host-os = linux ;
     64            case AMIGA : host-os = amiga ;
    6465            case * : host-os = unix ;
    6566        }
    6667    }
  • tools/build/v2/tools/common.jam

    diff -N -r -u -b boost_1_34_0/tools/build/v2/tools/common.jam boost_1_34_0_amiga/tools/build/v2/tools/common.jam
    old new  
    697697        case cw : tag += cw ;
    698698        case darwin* : tag += ;
    699699        case edg* : tag += edg ;
     700        case amiga* : tag += amiga ;
    700701        case gcc* :
    701702        {
    702703            switch [ $(property-set).get <toolset-gcc:flavor> ]
  • tools/build/v2/util/os.jam

    diff -N -r -u -b boost_1_34_0/tools/build/v2/util/os.jam boost_1_34_0_amiga/tools/build/v2/util/os.jam
    old new  
    9494    local home = [ environ HOMEDRIVE HOMEPATH ] ;
    9595    .home-directories = $(home[1])$(home[2]) [ environ HOME ] [ environ USERPROFILE ] ;
    9696}
     97else if $(.name) = AMIGA
     98{
     99    .home-directories = ;  # AmigaOS is single user only
     100}
    97101else
    98102{
    99103    .home-directories = [ environ HOME ] ;
  • tools/build/v2/util/path.jam

    diff -N -r -u -b boost_1_34_0/tools/build/v2/util/path.jam boost_1_34_0_amiga/tools/build/v2/util/path.jam
    old new  
    490490    return [ native-UNIX $(result) ] ;
    491491}
    492492
     493rule native-AMIGA ( path )
     494{
     495    return $(path) ;
     496}
     497
     498rule make-AMIGA ( native )
     499{
     500    return [ native-UNIX $(native) ] ;
     501}
     502
    493503#
    494504# split-VMS: splits input native path into
    495505# device dir file (each part is optional),
  • tools/jam/src/build.jam

    diff -N -r -u -b boost_1_34_0/tools/jam/src/build.jam boost_1_34_0_amiga/tools/jam/src/build.jam
    old new  
    164164    [ opt --debug : -s -O3 -fno-inline -pg ]
    165165    -I$(--python-include)
    166166    : -L$(--python-lib[1]) -l$(--python-lib[2]) ;
     167## GCC 4.x on AmigaOS
     168toolset amiga gcc : "-mcrt=clib2 -o " : -D
     169    :
     170    [ opt --release : -O3 ]
     171    [ opt --debug : -ggdb -O0 ] :
     172    -lunix ;
    167173## Intel C/C++ for Linux
    168174toolset intel-linux icc : "-o " : -D
    169175    :
     
    402408{
    403409    jam.source += execmac.c filemac.c pathmac.c ;
    404410}
     411else if $(AMIGA)
     412{
     413        jam.source += execamiga.c fileamiga.c pathamiga.c ;
     414}
    405415else
    406416{
    407417    jam.source += execunix.c fileunix.c pathunix.c ;
     
    455465if $(NT) { actions piecemeal together existing [DELETE] {
    456466    del /F /Q $(>)
    457467} }
    458 if $(UNIX) { actions piecemeal together existing [DELETE] {
     468if $(UNIX) || $(AMIGA) { actions piecemeal together existing [DELETE] {
    459469    rm -f $(>)
    460470} }
    461471if $(VMS) { actions piecemeal together existing [DELETE] {
     
    464474if $(NT) {
    465475    --chmod+w = "attrib -r " ;
    466476}
    467 if $(UNIX) {
     477if $(UNIX) || $(AMIGA) {
    468478    --chmod+w = "chmod +w " ;
    469479}
    470480if $(VMS) {
     
    480490if $(NT) { actions [MKDIR] {
    481491    md $(<)
    482492} }
    483 if $(UNIX) { actions [MKDIR] {
     493if $(UNIX) || $(AMIGA) { actions [MKDIR] {
    484494    mkdir $(<)
    485495} }
    486496if $(VMS) { actions [MKDIR] {
     
    526536    return $(exe) ;
    527537}
    528538if ! $(--def[2]) { actions [COMPILE] {
    529     "$(--cc)" $(--bin)$(<:D=) $(--dir)$(<:D) $(--out)$(<) $(--def)$(--defs) $(--flags) "$(--libs)" $(>)
     539    "$(--cc)" $(--bin)$(<:D=) $(--dir)$(<:D) $(--out)$(<) $(--def)$(--defs) $(--flags) $(>) "$(--libs)"
    530540} }
    531541else { actions [COMPILE] {
    532     "$(--cc)" $(--bin)$(<:D=) $(--dir)$(<:D) $(--out)$(<) $(--def[1])$(--defs:J=$(--def[2]))$(--def[3]) $(--flags) "$(--libs)" $(>)
     542    "$(--cc)" $(--bin)$(<:D=) $(--dir)$(<:D) $(--out)$(<) $(--def[1])$(--defs:J=$(--def[2]))$(--def[3]) $(--flags) $(>) "$(--libs)"
    533543} }
    534544if $(VMS) { actions [COMPILE.LINK] {
    535545    "$(--link)" $(--link-bin)$(<:D=) $(--link-dir)$(<:D) $(--link-out)$(<) $(--link-def)$(--link-defs) $(--link-flags) "$(--link-libs)" $(>J=", ")
     
    548558if $(NT) { actions [LINK] {
    549559    copy $(>) $(<)
    550560} }
    551 if $(UNIX) { actions [LINK] {
     561if $(UNIX) || $(AMIGA) { actions [LINK] {
    552562    ln -fs $(>) $(<)
    553563} }
    554564if $(VMS) { actions [LINK] {
     
    564574    del /f $(<)
    565575    rename $(>) $(<)
    566576} }
    567 if $(UNIX) { actions [MOVE] {
     577if $(UNIX) || $(AMIGA) { actions [MOVE] {
    568578    mv -f $(>) $(<)
    569579} }
    570580if $(VMS) { actions [MOVE] {
     
    635645        rename y.tab$(<[2]:S) $(<[2])
    636646    ) else set _error_ =
    637647} }
    638 if $(UNIX) { actions [YACC] {
     648if $(UNIX) || $(AMIGA) { actions [YACC] {
    639649    if ` "$(yacc)" $(>) ` ; then
    640650        mv -f y.tab$(<[1]:S) $(<[1])
    641651        mv -f y.tab$(<[2]:S) $(<[2])
     
    782792    copy /Y "$(>)" "$(<)" >NUL:
    783793    }
    784794}
    785 if $(UNIX)
     795if $(UNIX) || $(AMIGA)
    786796{
    787797    actions [PACK] {
    788798    tar zcf "$(<)" "$(>)"
     
    800810{
    801811    local zip = ;
    802812    if $(NT) { zip = $($(<).exe:S=.zip) ; }
    803     if $(UNIX) { zip = $($(<).exe:S=.tgz) ; }
     813    if $(UNIX) || $(AMIGA) { zip = $($(<).exe:S=.tgz) ; }
    804814    zip = $(zip:S=)-$(VERSION)-$(RELEASE)-$(platform)$(zip:S) ;
    805815    DEPENDS $(zip) : $($(<).exe) ;
    806816    DEPENDS dist : $(zip) ;
    807817    #~ LOCATE on $(zip) = $(locate-target) ;
    808818    if $(NT) { [ZIP] $(zip) : $($(<).exe) ; }
    809     if $(UNIX) { [PACK] $(zip) : $($(<).exe) ; }
     819    if $(UNIX) || $(AMIGA) { [PACK] $(zip) : $($(<).exe) ; }
    810820    .clean $(zip) ;
    811821}
    812822
     
    828838   
    829839    local pack = ;
    830840    if $(NT) { pack = $(dst-dir).zip ; }
    831     if $(UNIX) { pack = $(dst-dir).tgz ; }
     841    if $(UNIX) || $(AMIGA) { pack = $(dst-dir).tgz ; }
    832842   
    833843    DEPENDS dist : $(pack) ;
    834844    DEPENDS $(pack) : $(dst-files) ;
  • tools/jam/src/build.sh

    diff -N -r -u -b boost_1_34_0/tools/jam/src/build.sh boost_1_34_0_amiga/tools/jam/src/build.sh
    old new  
    2929    echo "###     ./build.sh gcc"
    3030    echo "###"
    3131    echo "### Toolsets supported by this script are:"
    32     echo "###     acc, como, darwin, gcc, intel-linux, kcc, kylix, mipspro,"
    33     echo "###     mingw(msys), qcc, sunpro, tru64cxx, vacpp"
     32    echo "###     acc, amiga, como, darwin, gcc, intel-linux, kcc, kylix,"
     33    echo "###     mipspro, mingw(msys), qcc, sunpro, tru64cxx, vacpp"
    3434    echo "###"
    3535    echo "### A special toolset; cc, is available which is used as a fallback"
    3636    echo "### when a more specific toolset is not found and the cc command is"
     
    6464    if test -r /mingw/bin/gcc ; then
    6565        BOOST_JAM_TOOLSET=mingw
    6666        BOOST_JAM_TOOLSET_ROOT=/mingw/
     67    elif test_uname AmigaOS; then BOOST_JAM_TOOLSET=amiga
    6768    elif test_uname Darwin ; then BOOST_JAM_TOOLSET=darwin
    6869    elif test_uname IRIX ; then BOOST_JAM_TOOLSET=mipspro
    6970    elif test_uname IRIX64 ; then BOOST_JAM_TOOLSET=mipspro
     
    134135    BOOST_JAM_CC=cc
    135136    ;;
    136137   
     138    amiga)
     139    BOOST_JAM_CC="gcc -mcrt=clib2"
     140    BOOST_JAM_LIBS=-lunix
     141    ;;
     142
    137143    intel-linux)
    138144    if test -r /opt/intel/cc/9.0/bin/iccvars.sh ; then
    139145        BOOST_JAM_TOOLSET_ROOT=/opt/intel/cc/9.0/
     
    233239 strings.c filesys.c builtins.c pwd.c class.c native.c w32_getreg.c\
    234240 modules/set.c modules/path.c modules/regex.c modules/property-set.c\
    235241 modules/sequence.c modules/order.c\
    236  execnt.c filent.c"
     242 execnt.c filent.c execamiga.c fileamiga.c pathamiga.c"
    237243
    238244BJAM_UPDATE=
    239245if test "$1" = "--update" -o "$2" = "--update" -o "$3" = "--update" -o "$4" = "--update"  ; then
     
    247253    echo_run rm -rf bootstrap
    248254    echo_run mkdir bootstrap
    249255    if test ! -r jamgram.y -o ! -r jamgramtab.h ; then
    250         echo_run ${BOOST_JAM_CC} ${BOOST_JAM_OPT_YYACC} ${YYACC_SOURCES}
     256        echo_run ${BOOST_JAM_CC} ${BOOST_JAM_OPT_YYACC} ${YYACC_SOURCES} ${BOOST_JAM_LIBS}
    251257        if test -x "./bootstrap/yyacc0" ; then
    252258            echo_run ./bootstrap/yyacc0 jamgram.y jamgramtab.h jamgram.yy
    253259        fi
     
    261267        mv -f y.tab.h jamgram.h
    262268    fi
    263269    if test ! -r jambase.c ; then
    264         echo_run ${BOOST_JAM_CC} ${BOOST_JAM_OPT_MKJAMBASE} ${MKJAMBASE_SOURCES}
     270        echo_run ${BOOST_JAM_CC} ${BOOST_JAM_OPT_MKJAMBASE} ${MKJAMBASE_SOURCES} ${BOOST_JAM_LIBS}
    265271        if test -x "./bootstrap/mkjambase0" ; then
    266272            echo_run ./bootstrap/mkjambase0 jambase.c Jambase
    267273        fi
    268274    fi
    269     echo_run ${BOOST_JAM_CC} ${BOOST_JAM_OPT_JAM} ${BJAM_SOURCES}
     275    echo_run ${BOOST_JAM_CC} ${BOOST_JAM_OPT_JAM} ${BJAM_SOURCES} ${BOOST_JAM_LIBS}
    270276fi
    271277if test -x "./bootstrap/jam0" ; then
    272278    if test "${BJAM_UPDATE}" != "update" ; then
  • tools/jam/src/execamiga.c

    diff -N -r -u -b boost_1_34_0/tools/jam/src/execamiga.c boost_1_34_0_amiga/tools/jam/src/execamiga.c
    old new  
     1/*
     2 * This file is part of Jam - see jam.c for Copyright information.
     3 */
     4
     5#include "jam.h"
     6
     7#if defined(OS_AMIGA)
     8
     9#include "lists.h"
     10#include "execcmd.h"
     11#include "patchlevel.h"
     12
     13#include <string.h>
     14#include <stdlib.h>
     15
     16#include <proto/exec.h>
     17#include <proto/dos.h>
     18
     19#include <utility/hooks.h>
     20#include <dos/dos.h>
     21#include <dos/var.h>
     22
     23#define MAX_ENV_SIZE 1024  /* maximum number of environ entries */
     24
     25
     26/* clib2 specific controls */
     27int __minimum_os_lib_version = 52;
     28char * __minimum_os_lib_error = "Requires AmigaOS 4.0";
     29BOOL __open_locale = FALSE;
     30BOOL __disable_dos_requesters = TRUE;
     31
     32
     33static const char* version __attribute__((used)) =
     34  "$VER: bjam "VERSION"-1 (2.6.2007)";  /* dd.mm.yyyy */
     35
     36
     37/*
     38 * execamiga.c - execute a shell script
     39 *
     40 * Uses the abc-shell to execute all commands synchronously.
     41 */
     42void execcmd
     43(
     44  char *string,
     45  void (*func)(void *closure, int status, timing_info*),
     46  void *closure,
     47  LIST *shell
     48)
     49{
     50    timing_info time = {0, 0};
     51
     52    static char tmpbuf[128];
     53    tmpbuf[0] = '\0';
     54    strlcpy(tmpbuf, "/t/bjamXXXXXX", sizeof(tmpbuf));
     55
     56    int fd = mkstemp(tmpbuf);
     57    if ( fd == -1 )
     58    {
     59        printf("can't open command file\n");
     60        (*func)(closure, EXEC_CMD_FAIL, &time);
     61        return;
     62    }
     63
     64    int len = strlen(string);
     65    if ( write(fd, string, len) != len )
     66    {
     67        printf("can't write command file\n");
     68        (*func)(closure, EXEC_CMD_FAIL, &time);
     69        unlink(tmpbuf);
     70        close(fd);
     71        return;
     72    }
     73
     74    static char cmdbuf[128];
     75    cmdbuf[0] = '\0';
     76    snprintf(cmdbuf, sizeof(cmdbuf), "/sdk/c/sh %s", tmpbuf);
     77
     78    if ( DEBUG_EXECCMD )
     79    {
     80        printf("string = '%s'\n", string);
     81        printf("cmdbuf = '%s'\n", cmdbuf);
     82    }
     83
     84    int status = system(cmdbuf);
     85
     86    unlink(tmpbuf);
     87    close(fd);
     88
     89    if ( status == 0 )
     90    {
     91        (*func)(closure, EXEC_CMD_OK, &time);
     92    }
     93    else
     94    {
     95        (*func)(closure, EXEC_CMD_FAIL, &time);
     96    }
     97}
     98
     99
     100int execwait()
     101{
     102    return 0;
     103}
     104
     105
     106/*
     107 * environ - AmigaOS environment support
     108 *
     109 * The following code implements environ support for AmigaOS.
     110 */
     111void make_environ() __attribute__((constructor));
     112void free_environ() __attribute__((destructor));
     113
     114char **environ = NULL;
     115
     116
     117int is_ascii_string(char* str)
     118{
     119  while ( *str != '\0' )
     120  {
     121    if ( !isascii(*str) )
     122    {
     123      return 0;
     124    }
     125
     126    ++str;
     127  }
     128
     129  return 1;
     130}
     131
     132
     133uint32 copy_env(struct Hook *hook, APTR data, struct ScanVarsMsg *msg)
     134{
     135    static uint32 env_size = 1;  /* environ is null terminated */
     136
     137    if ( env_size == MAX_ENV_SIZE )
     138    {
     139        return 0;
     140    }
     141
     142    if ( msg->sv_Name == 0 ||
     143         msg->sv_Var == 0 ||
     144         strlen(msg->sv_GDir) > 4 ||  /* excludes ENVARC: sub-directories */
     145         !is_ascii_string(msg->sv_Name) ||
     146         !is_ascii_string(msg->sv_Var) ||
     147         strstr(msg->sv_Name, ".prefs") != 0 ||
     148         strstr(msg->sv_Name, ".xml") != 0 ||
     149         strstr(msg->sv_Name, ".cfg") != 0 )
     150
     151    {
     152        return 0;
     153    }
     154
     155    uint32 var_size = strlen(msg->sv_Name) + 1 + msg->sv_VarLen + 1;
     156    char* var_buf = malloc(var_size);
     157    if ( var_buf == 0 )
     158    {
     159        return 0;
     160    }
     161
     162    snprintf(var_buf, var_size, "%s=%s", msg->sv_Name, msg->sv_Var);
     163
     164    char **env = hook->h_Data;
     165    env[env_size - 1] = var_buf;
     166    ++env_size;
     167
     168    return 0;
     169}
     170
     171
     172void make_environ()
     173{
     174    size_t environ_size = MAX_ENV_SIZE * sizeof(char*);
     175
     176    environ = (char**)malloc(environ_size);
     177    if ( environ == 0 )
     178    {
     179        return;
     180    }
     181
     182    memset(environ, 0, environ_size);
     183
     184    struct Hook hook;
     185    memset(&hook, 0, sizeof(struct Hook));
     186    hook.h_Entry = copy_env;
     187    hook.h_Data = environ;
     188    (void) IDOS->ScanVars(&hook, 0, 0);
     189}
     190
     191
     192void free_environ()
     193{
     194    char **i;
     195    for ( i = environ; *i != 0; ++i )
     196    {
     197        free(*i);
     198    }
     199
     200    free(environ);
     201}
     202
     203
     204#endif
  • tools/jam/src/execnt.c

    diff -N -r -u -b boost_1_34_0/tools/jam/src/execnt.c boost_1_34_0_amiga/tools/jam/src/execnt.c
    old new  
    4040 * If $(JAMSHELL) is defined, uses that to formulate execvp()/spawnvp().
    4141 * The default is:
    4242 *
    43  *      /bin/sh -c %            [ on UNIX/AmigaOS ]
     43 *      /bin/sh -c %            [ on UNIX ]
    4444 *      cmd.exe /c %            [ on Windows NT ]
    4545 *
    4646 * Each word must be an individual element in a jam variable value.
  • tools/jam/src/execunix.c

    diff -N -r -u -b boost_1_34_0/tools/jam/src/execunix.c boost_1_34_0_amiga/tools/jam/src/execunix.c
    old new  
    2323# endif
    2424
    2525/*
    26  * execunix.c - execute a shell script on UNIX/WinNT/OS2/AmigaOS
     26 * execunix.c - execute a shell script on UNIX/WinNT/OS2
    2727 *
    2828 * If $(JAMSHELL) is defined, uses that to formulate execvp()/spawnvp().
    2929 * The default is:
    3030 *
    31  *      /bin/sh -c %            [ on UNIX/AmigaOS ]
     31 *      /bin/sh -c %            [ on UNIX ]
    3232 *      cmd.exe /c %            [ on OS2/WinNT ]
    3333 *
    3434 * Each word must be an individual element in a jam variable value.
  • tools/jam/src/fileamiga.c

    diff -N -r -u -b boost_1_34_0/tools/jam/src/fileamiga.c boost_1_34_0_amiga/tools/jam/src/fileamiga.c
    old new  
     1/*
     2 * This file is part of Jam - see jam.c for Copyright information.
     3 */
     4
     5#include "jam.h"
     6
     7#if defined(OS_AMIGA)
     8
     9#include "filesys.h"
     10#include "strings.h"
     11#include "pathsys.h"
     12
     13#include <stdio.h>
     14#include <dirent.h>
     15#include <sys/types.h>
     16#include <sys/stat.h>
     17
     18/*
     19 * fileamiga.c - manipulate file names and scan directories on AmigaOS
     20 *
     21 * External routines:
     22 *
     23 *  file_dirscan() - scan a directory for files
     24 *  file_time() - get timestamp of file, if not done by file_dirscan()
     25 *  file_archscan() - scan an archive for files
     26 *
     27 * File_dirscan() and file_archscan() call back a caller provided function
     28 * for each file found. A flag to this callback function lets file_dirscan()
     29 * and file_archscan() indicate that a timestamp is being provided with the
     30 * file. If file_dirscan() or file_archscan() do not provide the file's
     31 * timestamp, interested parties may later call file_time().
     32 */
     33
     34/*
     35 * file_dirscan() - scan a directory for files
     36 */
     37void file_dirscan(char *dir, scanback func, void *closure)
     38{
     39    PATHNAME f;
     40    DIR *d;
     41    struct dirent *dirent;
     42    string filename[1];
     43
     44    /* First enter directory itself */
     45    memset((char*)&f, '\0', sizeof(f));
     46    f.f_dir.ptr = dir;
     47    f.f_dir.len = strlen(dir);
     48
     49    dir = *dir ? dir : ".";
     50
     51    /* Special case / : enter it */
     52    if ( f.f_dir.len == 1 && f.f_dir.ptr[0] == '/' )
     53    {
     54        (*func)(closure, dir, 0 /* not stat()'ed */, (time_t)0);
     55    }
     56
     57    /* Now enter contents of directory */
     58    if ( !(d = opendir(dir)) )
     59    {
     60        return;
     61    }
     62
     63    if ( DEBUG_BINDSCAN )
     64    {
     65        printf("scan directory %s\n", dir);
     66    }
     67
     68    string_new(filename);
     69
     70    while ( dirent = readdir(d) )
     71    {
     72        f.f_base.ptr = dirent->d_name;
     73        f.f_base.len = strlen(f.f_base.ptr);
     74
     75        string_truncate(filename, 0);
     76        path_build(&f, filename, 0);
     77
     78        (*func)(closure, filename->value, 0 /* not stat()'ed */, (time_t)0);
     79    }
     80
     81    string_free(filename);
     82
     83    closedir(d);
     84}
     85
     86
     87/*
     88 * file_time() - get timestamp of file, if not done by file_dirscan()
     89 */
     90int file_time(char *filename, time_t *time)
     91{
     92    struct stat statbuf;
     93
     94    if ( stat(filename, &statbuf) < 0 )
     95    {
     96        return -1;
     97    }
     98
     99    *time = statbuf.st_mtime;
     100
     101    return 0;
     102}
     103
     104
     105int file_is_file(char* filename)
     106{
     107    struct stat statbuf;
     108
     109    if( stat( filename, &statbuf ) < 0 )
     110    {
     111        return -1;
     112    }
     113
     114    if (S_ISREG(statbuf.st_mode))
     115    {
     116        return 1;
     117    }
     118    else
     119    {
     120        return 0;
     121    }
     122}
     123
     124
     125/*
     126 * file_archscan() - scan an archive for files
     127 */
     128void file_archscan(char *archive, scanback func, void *closure )
     129{
     130}
     131
     132#endif
  • tools/jam/src/fileunix.c

    diff -N -r -u -b boost_1_34_0/tools/jam/src/fileunix.c boost_1_34_0_amiga/tools/jam/src/fileunix.c
    old new  
    9999# endif
    100100
    101101/*
    102  * fileunix.c - manipulate file names and scan directories on UNIX/AmigaOS
     102 * fileunix.c - manipulate file names and scan directories on UNIX
    103103 *
    104104 * External routines:
    105105 *
  • tools/jam/src/jam.h

    diff -N -r -u -b boost_1_34_0/tools/jam/src/jam.h boost_1_34_0_amiga/tools/jam/src/jam.h
    old new  
    205205# endif
    206206
    207207/*
     208 * AmigaOS SDK
     209 */
     210# if defined(__amigaos__)
     211
     212# include <stdlib.h>
     213# include <stdio.h>
     214# include <string.h>
     215# include <time.h>
     216
     217# define OSMAJOR "AMIGA=true"
     218# define OSMINOR "OS=AMIGA"
     219# define OS_AMIGA
     220# define PATH_DELIM '/'
     221
     222# endif
     223
     224/*
    208225 * God fearing UNIX
    209226 */
    210227
     
    222239# define OS_AIX
    223240# define NO_VFORK
    224241# endif
    225 # ifdef AMIGA
    226 # define OSMINOR "OS=AMIGA"
    227 # define OS_AMIGA
    228 # endif
    229242# ifdef __BEOS__
    230243# define unix
    231244# define OSMINOR "OS=BEOS"
  • tools/jam/src/Jambase

    diff -N -r -u -b boost_1_34_0/tools/jam/src/Jambase boost_1_34_0_amiga/tools/jam/src/Jambase
    old new  
    854854    NOARSCAN    ?= true ;
    855855    STDHDRS     ?= /boot/develop/headers/posix ;
    856856}
     857else if $(OS) = AMIGA
     858{
     859    BINDIR      ?= /sdk/local/c ;
     860    C++         ?= g++ ;
     861    C++FLAGS    ?= -mcrt=clib2 ;
     862    CC          ?= gcc ;
     863    CCFLAGS     ?= -mcrt=clib2 ;
     864    EXEMODE     ?= ;
     865    FILEMODE    ?= ;
     866    LIBDIR      ?= /sdk/local/clib2/lib ;
     867    LINKLIBS    ?= -lunix ;
     868    NOARSCAN    ?= true ;
     869    YACC        ?= yacc ;
     870    YACCFILES   ?= y.tab ;
     871    YACCFLAGS   ?= -d ;
     872}
    857873else if $(UNIX)
    858874{
    859875    switch $(OS)
     
    861877    case AIX :
    862878    LINKLIBS    ?= -lbsd ;
    863879
    864     case AMIGA :
    865     CC          ?= gcc ;
    866     YACC        ?= "bison -y" ;
    867 
    868880    case CYGWIN :   
    869881    CC          ?= gcc ;
    870882    CCFLAGS     += -D__cygwin__ ;
     
    24332445}
    24342446
    24352447#
     2448# AmigaOS specific actions
     2449#
     2450
     2451else if $(AMIGA)
     2452{
     2453    actions Link bind NEEDLIBS
     2454    {
     2455    $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS) -lunix
     2456    }
     2457}
     2458
     2459#
    24362460# Backwards compatibility with jam 1, where rules were uppercased.
    24372461#
    24382462
  • tools/jam/src/jambase.c

    diff -N -r -u -b boost_1_34_0/tools/jam/src/jambase.c boost_1_34_0_amiga/tools/jam/src/jambase.c
    old new  
    555555"NOARSCAN    ?= true ;\n",
    556556"STDHDRS     ?= /boot/develop/headers/posix ;\n",
    557557"}\n",
     558"else if $(OS) = AMIGA\n",
     559"{\n",
     560"BINDIR      ?= /sdk/local/c ;\n",
     561"C++         ?= g++ ;\n",
     562"C++FLAGS    ?= -mcrt=clib2 ;\n",
     563"CC          ?= gcc ;\n",
     564"CCFLAGS     ?= -mcrt=clib2 ;\n",
     565"EXEMODE     ?= ;\n",
     566"FILEMODE    ?= ;\n",
     567"LIBDIR      ?= /sdk/local/clib2/lib ;\n",
     568"LINKLIBS    ?= -lunix ;\n",
     569"NOARSCAN    ?= true ;\n",
     570"YACC        ?= yacc ;\n",
     571"YACCFILES   ?= y.tab ;\n",
     572"YACCFLAGS   ?= -d ;\n",
     573"}\n",
    558574"else if $(UNIX)\n",
    559575"{\n",
    560576"switch $(OS)\n",
    561577"{\n",
    562578"case AIX :\n",
    563579"LINKLIBS    ?= -lbsd ;\n",
    564 "case AMIGA :\n",
    565 "CC          ?= gcc ;\n",
    566 "YACC        ?= \"bison -y\" ;\n",
    567580"case CYGWIN :   \n",
    568581"CC          ?= gcc ;\n",
    569582"CCFLAGS     += -D__cygwin__ ;\n",
     
    16601673"$(LINK) -o $(<) $(LINKFLAGS) $(>) $(NEEDLIBS) \"$(LINKLIBS)\"\n",
    16611674"}\n",
    16621675"}\n",
     1676"else if $(AMIGA)\n",
     1677"{\n",
     1678"actions Link bind NEEDLIBS\n",
     1679"{\n",
     1680"$(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS) -lunix\n",
     1681"}\n",
     1682"}\n",
    16631683"rule BULK { Bulk $(<) : $(>) ; }\n",
    16641684"rule FILE { File $(<) : $(>) ; }\n",
    16651685"rule HDRRULE { HdrRule $(<) : $(>) ; }\n",
  • tools/jam/src/pathamiga.c

    diff -N -r -u -b boost_1_34_0/tools/jam/src/pathamiga.c boost_1_34_0_amiga/tools/jam/src/pathamiga.c
    old new  
     1/*
     2 * This file is part of Jam - see jam.c for Copyright information.
     3 */
     4
     5#include "jam.h"
     6
     7#if defined(OS_AMIGA)
     8
     9#include "pathsys.h"
     10#include "strings.h"
     11#include "newstr.h"
     12#include "filesys.h"
     13
     14#include <dos/dosextens.h>
     15#include <proto/exec.h>
     16
     17
     18/*
     19 * pathamiga.c - manipulate file names on AmigaOS
     20 *
     21 * External routines:
     22 *
     23 *  path_parse() - split a file name into dir/base/suffix/member
     24 *  path_build() - build a filename given dir/base/suffix/member
     25 *  path_parent() - make a PATHNAME point to its parent dir
     26 *
     27 * file_parse() and path_build() just manipuate a string and a structure;
     28 * they do not make system calls.
     29 */
     30
     31
     32/*
     33 * path_parse() - split a file name into dir/base/suffix/member
     34 */
     35void path_parse(char *file, PATHNAME *f)
     36{
     37    char *p, *q;
     38    char *end;
     39   
     40    memset( (char *)f, 0, sizeof( *f ) );
     41
     42    /* Look for <grist> */
     43    if( file[0] == '<' && ( p = strchr( file, '>' ) ) )
     44    {
     45        f->f_grist.ptr = file;
     46        f->f_grist.len = p - file;
     47        file = p + 1;
     48    }
     49
     50    /* Look for dir/ */
     51    p = strrchr( file, '/' );
     52
     53    if( p )
     54    {
     55        f->f_dir.ptr = file;
     56        f->f_dir.len = p - file;
     57   
     58        /* Special case for / - dirname is /, not "" */
     59        if( !f->f_dir.len )
     60        f->f_dir.len = 1;
     61
     62        file = p + 1;
     63    }
     64
     65    end = file + strlen( file );
     66
     67    /* Look for (member) */
     68    if( ( p = strchr( file, '(' ) ) && end[-1] == ')' )
     69    {
     70        f->f_member.ptr = p + 1;
     71        f->f_member.len = end - p - 2;
     72        end = p;
     73    }
     74
     75    /* Look for .suffix */
     76    /* This would be memrchr() */
     77    p = 0;
     78    q = file;
     79
     80    while( q = (char *)memchr( q, '.', end - q ) )
     81        p = q++;
     82
     83    if( p )
     84    {
     85        f->f_suffix.ptr = p;
     86        f->f_suffix.len = end - p;
     87        end = p;
     88    }
     89
     90    /* Leaves base */
     91    f->f_base.ptr = file;
     92    f->f_base.len = end - file;
     93}
     94
     95
     96/*
     97 * is_path_delim() - true iff c is a path delimiter
     98 */
     99static int is_path_delim(char c)
     100{
     101    return c == PATH_DELIM;
     102}
     103
     104
     105/*
     106 * as_path_delim() - convert c to a path delimiter if it isn't one
     107 * already
     108 */
     109static char as_path_delim( char c )
     110{
     111    return is_path_delim(c) ? c : PATH_DELIM;
     112}
     113
     114
     115/*
     116 * path_build() - build a filename given dir/base/suffix/member
     117 */
     118void path_build(PATHNAME *f, string *file, int binding)
     119{
     120    file_build1( f, file );
     121   
     122    /* Don't prepend root if it's . or directory is rooted */
     123    if( f->f_root.len
     124        && !( f->f_root.len == 1 && f->f_root.ptr[0] == '.' )
     125        && !( f->f_dir.len && f->f_dir.ptr[0] == '/' ) )
     126    {
     127        string_append_range( file, f->f_root.ptr, f->f_root.ptr + f->f_root.len  );
     128        /* If 'root' already ends with path delimeter, don't add yet another one. */
     129        if( ! is_path_delim( f->f_root.ptr[f->f_root.len-1] ) )
     130            string_push_back( file, as_path_delim( f->f_root.ptr[f->f_root.len] ) );
     131    }
     132
     133    if( f->f_dir.len )
     134    {
     135        string_append_range( file, f->f_dir.ptr, f->f_dir.ptr + f->f_dir.len  );
     136    }
     137
     138    /* Put / between dir and file */
     139    if( f->f_dir.len && ( f->f_base.len || f->f_suffix.len ) )
     140    {
     141        /* Special case for dir / : don't add another / */
     142        if( !( f->f_dir.len == 1 && is_path_delim( f->f_dir.ptr[0] ) ) )
     143            string_push_back( file, as_path_delim( f->f_dir.ptr[f->f_dir.len] ) );
     144    }
     145
     146    if( f->f_base.len )
     147    {
     148        string_append_range( file, f->f_base.ptr, f->f_base.ptr + f->f_base.len );
     149    }
     150
     151    if( f->f_suffix.len )
     152    {
     153        string_append_range( file, f->f_suffix.ptr, f->f_suffix.ptr + f->f_suffix.len );
     154    }
     155
     156    if( f->f_member.len )
     157    {
     158        string_push_back( file, '(' );
     159        string_append_range( file, f->f_member.ptr, f->f_member.ptr + f->f_member.len );
     160        string_push_back( file, ')' );
     161    }
     162}
     163
     164
     165/*
     166 * path_parent() - make a PATHNAME point to its parent dir
     167 */
     168void path_parent(PATHNAME *f)
     169{
     170    f->f_base.ptr = "";
     171    f->f_suffix.ptr = "";
     172    f->f_member.ptr = "";
     173
     174    f->f_base.len = 0;
     175    f->f_suffix.len = 0;
     176    f->f_member.len = 0;
     177}
     178
     179
     180const char * path_tmpdir()
     181{
     182    return "\t";
     183}
     184
     185
     186const char * path_tmpnam(void)
     187{
     188    static char tmpbuf[64];
     189    uint32 pid = ((struct Process*)IExec->FindTask(0))->pr_ProcessID;
     190    snprintf(tmpbuf, sizeof(tmpbuf), "jam.%u.XXXXXX", pid);
     191    (void) mktemp(tmpbuf);
     192
     193    return newstr(tmpbuf);
     194}
     195
     196
     197const char * path_tmpfile(void)
     198{
     199    const char * result = 0;
     200
     201    static char pathbuf[4096];
     202    snprintf(pathbuf, sizeof(pathbuf), "%s%c%s",
     203        path_tmpdir(), PATH_DELIM, path_tmpnam());
     204   
     205    return newstr(pathbuf);
     206}
     207
     208#endif
  • tools/jam/src/pathunix.c

    diff -N -r -u -b boost_1_34_0/tools/jam/src/pathunix.c boost_1_34_0_amiga/tools/jam/src/pathunix.c
    old new  
    2525# ifdef USE_PATHUNIX
    2626
    2727/*
    28  * pathunix.c - manipulate file names on UNIX, NT, OS2, AmigaOS
     28 * pathunix.c - manipulate file names on UNIX, NT, OS2
    2929 *
    3030 * External routines:
    3131 *
     
    458458}
    459459
    460460
    461 # endif /* unix, NT, OS/2, AmigaOS */
     461# endif /* unix, NT, OS/2 */