This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH]: Revised patch for fixinc on BeOS


This adds the BeOS specific makefile, as requested  by bruce.
It's essentially the same (besides the makefile/mkfixinc.sh change to use 
it) as the last patch, except for two things:
1. We now flush stdout before closing it in applyfix. without this, our 
output file ends up being empty.
2. Multiple fixes on the same include file work properly (involved using 
a different command on BeOS than MSDOS).

--Dan
? Makefile.BEOS
Index: fixfixes.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixfixes.c,v
retrieving revision 1.36
diff -c -3 -p -w -B -b -r1.36 fixfixes.c
*** fixfixes.c	2000/11/22 02:23:40	1.36
--- fixfixes.c	2000/11/27 21:54:45
*************** Boston, MA 02111-1307, USA.  */
*** 60,66 ****
  #include "fixlib.h"
  #define    GTYPE_SE_CT 1
  
! #ifdef __MSDOS__
  #include "fixincl.x"
  #endif
  
--- 60,66 ----
  #include "fixlib.h"
  #define    GTYPE_SE_CT 1
  
! #if defined(__MSDOS__) || defined(__BEOS__)
  #include "fixincl.x"
  #endif
  
*************** apply_fix( p_fixd, filname )
*** 729,735 ****
    (*pfe->fix_proc)( filname, buf, p_fixd );
  }
  
! #ifdef __MSDOS__
  tSCC z_usage[] =
  "USAGE: applyfix <fix-name> <file-to-fix> <file-source> <file-destination>\n";
  tSCC z_reopen[] =
--- 729,735 ----
    (*pfe->fix_proc)( filname, buf, p_fixd );
  }
  
! #if defined(__MSDOS__) || defined(__BEOS__)
  tSCC z_usage[] =
  "USAGE: applyfix <fix-name> <file-to-fix> <file-source> <file-destination>\n";
  tSCC z_reopen[] =
*************** main( argc, argv )
*** 784,789 ****
--- 783,789 ----
      strcpy( pz_tmp_dot+1, "X" ); /* nuke the original extension */
    else
      strcat( pz_tmptmp, ".X" );
+   
    if (freopen( pz_tmptmp, "w", stdout ) != stdout)
      {
        fprintf( stderr, z_reopen, errno, strerror( errno ), pz_tmptmp, "out" );
*************** main( argc, argv )
*** 791,796 ****
--- 791,797 ----
      }
  
    apply_fix( pFix, argv[1] );
+   fflush(stdout);
    close( STDOUT_FILENO );
    close( STDIN_FILENO );
    unlink( argv[4] );
Index: fixincl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixincl.c,v
retrieving revision 1.42
diff -c -3 -p -w -B -b -r1.42 fixincl.c
*** fixincl.c	2000/11/17 04:16:55	1.42
--- fixincl.c	2000/11/27 21:54:46
*************** Boston, MA 02111-1307, USA.  */
*** 30,36 ****
  #endif
  
  #include <signal.h>
! #ifndef __MSDOS__
  #include "server.h"
  #endif
  
--- 30,36 ----
  #endif
  
  #include <signal.h>
! #if !defined(__MSDOS__) && !defined(__BEOS__)
  #include "server.h"
  #endif
  
*************** Altering  %5d of them\n";
*** 181,187 ****
    }
  #endif /* DO_STATS */
  
! # ifdef __MSDOS__
    unlink( pz_temp_file );
  # endif
    return EXIT_SUCCESS;
--- 181,187 ----
    }
  #endif /* DO_STATS */
  
! # if defined(__MSDOS__) || defined(__BEOS__)
    unlink( pz_temp_file );
  # endif
    return EXIT_SUCCESS;
*************** do_version ()
*** 201,207 ****
    */
    run_compiles ();
    sprintf (zBuf, zFmt, program_id);
! #ifndef __MSDOS__
    puts (zBuf + 5);
    exit (strcmp (run_shell (zBuf), program_id));
  #else
--- 201,207 ----
    */
    run_compiles ();
    sprintf (zBuf, zFmt, program_id);
! #if !defined(__MSDOS__) && !defined(__BEOS__)
    puts (zBuf + 5);
    exit (strcmp (run_shell (zBuf), program_id));
  #else
*************** ENV_TABLE
*** 297,303 ****
        */
    run_compiles ();
  
! # ifdef __MSDOS__
    /* NULL as the first argument to `tempnam' causes it to DTRT
       wrt the temporary directory where the file will be created.  */
    pz_temp_file = tempnam( NULL, "fxinc" );
--- 297,303 ----
        */
    run_compiles ();
  
! # if defined(__MSDOS__) || defined(__BEOS__)
    /* NULL as the first argument to `tempnam' causes it to DTRT
       wrt the temporary directory where the file will be created.  */
    pz_temp_file = tempnam( NULL, "fxinc" );
*************** int
*** 380,386 ****
  machine_matches( p_fixd )
    tFixDesc *p_fixd;
          {
! # ifndef __MSDOS__
            tSCC case_fmt[] = "case %s in\n";     /*  9 bytes, plus string */
            tSCC esac_fmt[] =
                 " )\n    echo %s ;;\n* ) echo %s ;;\nesac";/*  4 bytes */
--- 380,386 ----
  machine_matches( p_fixd )
    tFixDesc *p_fixd;
          {
! # if !defined(__MSDOS__) && !defined(__BEOS__)
            tSCC case_fmt[] = "case %s in\n";     /*  9 bytes, plus string */
            tSCC esac_fmt[] =
                 " )\n    echo %s ;;\n* ) echo %s ;;\nesac";/*  4 bytes */
*************** create_file ()
*** 610,616 ****
            the name of the file that we might want to fix
    Result: APPLY_FIX or SKIP_FIX, depending on the result of the
            shell script we run.  */
! #ifndef __MSDOS__
  int
  test_test (p_test, pz_test_file)
       tTestDesc *p_test;
--- 610,616 ----
            the name of the file that we might want to fix
    Result: APPLY_FIX or SKIP_FIX, depending on the result of the
            shell script we run.  */
! #if !defined(__MSDOS__) && !defined(__BEOS__)
  int
  test_test (p_test, pz_test_file)
       tTestDesc *p_test;
*************** extract_quoted_files (pz_data, pz_fixed_
*** 805,811 ****
  
      Somebody wrote a *_fix subroutine that we must call.
      */
! #ifndef __MSDOS__
  int
  internal_fix (read_fd, p_fixd)
    int read_fd;
--- 805,811 ----
  
      Somebody wrote a *_fix subroutine that we must call.
      */
! #if !defined(__MSDOS__) && !defined(__BEOS__)
  int
  internal_fix (read_fd, p_fixd)
    int read_fd;
*************** internal_fix (read_fd, p_fixd)
*** 874,880 ****
  #endif /* !__MSDOS__ */
  
  
! #ifdef __MSDOS__
  static void
  fix_with_system (p_fixd, pz_fix_file, pz_file_source, pz_temp_file)
    tFixDesc* p_fixd;
--- 874,880 ----
  #endif /* !__MSDOS__ */
  
  
! #if defined(__MSDOS__) || defined(__BEOS__)
  static void
  fix_with_system (p_fixd, pz_fix_file, pz_file_source, pz_temp_file)
    tFixDesc* p_fixd;
*************** fix_with_system (p_fixd, pz_fix_file, pz
*** 923,929 ****
--- 923,936 ----
           The following bizarre use of 'cat' only works on DOS boxes.
           It is causing the file to be dropped into a temporary file for
           'cat' to read (pipes do not work on DOS).  */
+ #ifdef __MSDOS__
        tSCC   z_cmd_fmt[] = " %s | cat > %s";
+ #else
+       /* Positional printf arguments don't seem to work for some reason, which
+        * makes this more work than it should be, because we have to #ifdef
+        * below as well.  */
+       tSCC   z_cmd_fmt[] = " %s > %sX ; rm -f %s; mv -f %sX %s"; 
+ #endif
        tCC**  ppArgs = p_fixd->patch_args;
  
        argsize = sizeof( z_cmd_fmt ) + strlen( pz_temp_file )
*************** fix_with_system (p_fixd, pz_fix_file, pz
*** 998,1004 ****
--- 1005,1015 ----
        /*
         *  add the file machinations.
         */
+ #ifdef __BEOS__
+       sprintf( pz_scan, z_cmd_fmt, pz_file_source, pz_temp_file, pz_temp_file, pz_temp_file, pz_temp_file);
+ #else
        sprintf( pz_scan, z_cmd_fmt, pz_file_source, pz_temp_file );
+ #endif
      }
    system( pz_cmd );
    free( (void*)pz_cmd );
*************** fix_applies (p_fixd)
*** 1095,1101 ****
    int test_ct;
    tTestDesc *p_test;
  
! # ifdef __MSDOS__
    /*
     *  There is only one fix that uses a shell script as of this writing.
     *  I hope to nuke it anyway, it does not apply to DOS and it would
--- 1106,1112 ----
    int test_ct;
    tTestDesc *p_test;
  
! # if defined(__MSDOS__) || defined(__BEOS__)
    /*
     *  There is only one fix that uses a shell script as of this writing.
     *  I hope to nuke it anyway, it does not apply to DOS and it would
*************** process ()
*** 1302,1308 ****
    tFixDesc *p_fixd = fixDescList;
    int todo_ct = FIX_COUNT;
    int read_fd = -1;
! # ifndef __MSDOS__
    int num_children = 0;
  # else /* is __MSDOS__ */
    char* pz_file_source = pz_curr_file;
--- 1313,1319 ----
    tFixDesc *p_fixd = fixDescList;
    int todo_ct = FIX_COUNT;
    int read_fd = -1;
! # if !defined(__MSDOS__) && !defined(__BEOS__)
    int num_children = 0;
  # else /* is __MSDOS__ */
    char* pz_file_source = pz_curr_file;
*************** process ()
*** 1327,1333 ****
    if (VLEVEL( VERB_PROGRESS ) && have_tty)
      fprintf (stderr, "%6d %-50s   \r", data_map_size, pz_curr_file );
  
! # ifndef __MSDOS__
    process_chain_head = NOPROCESS;
  
    /* For every fix in our fix list, ...  */
--- 1338,1344 ----
    if (VLEVEL( VERB_PROGRESS ) && have_tty)
      fprintf (stderr, "%6d %-50s   \r", data_map_size, pz_curr_file );
  
! # if !defined(__MSDOS__) && !defined(__BEOS__)
    process_chain_head = NOPROCESS;
  
    /* For every fix in our fix list, ...  */
*************** process ()
*** 1410,1421 ****
      }
  
    read_fd = open( pz_temp_file, O_RDONLY );
    test_for_changes( read_fd );
    /* Unlinking a file while it is still open is a Bad Idea on
       DOS/Windows.  */
    close( read_fd );
    unlink( pz_temp_file );
! 
  # endif
    UNLOAD_DATA();
  }
--- 1421,1434 ----
      }
  
    read_fd = open( pz_temp_file, O_RDONLY );
+   if (read_fd > 0)
+   {
  	  test_for_changes( read_fd );
  	  /* Unlinking a file while it is still open is a Bad Idea on
  	     DOS/Windows.  */
  	  close( read_fd );
  	  unlink( pz_temp_file );
!   }
  # endif
    UNLOAD_DATA();
  }
Index: fixincl.sh
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixincl.sh,v
retrieving revision 1.33
diff -c -3 -p -w -B -b -r1.33 fixincl.sh
Index: fixlib.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixlib.c,v
retrieving revision 1.14
diff -c -3 -p -w -B -b -r1.14 fixlib.c
*** fixlib.c	2000/11/17 04:16:55	1.14
--- fixlib.c	2000/11/27 21:54:47
*************** mn_get_regexps( label_re, name_re, who )
*** 244,250 ****
  #endif
  
  
! #ifdef __MSDOS__
  
  char*
  make_raw_shell_str( pz_d, pz_s, smax )
--- 244,250 ----
  #endif
  
  
! #if defined(__MSDOS__) || defined(__BEOS__)
  
  char*
  make_raw_shell_str( pz_d, pz_s, smax )
Index: fixlib.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixlib.h,v
retrieving revision 1.18
diff -c -3 -p -w -B -b -r1.18 fixlib.h
*** fixlib.h	2000/09/12 14:28:27	1.18
--- fixlib.h	2000/11/27 21:54:47
*************** void   apply_fix   PARAMS(( tFixDesc* p_
*** 209,215 ****
  apply_fix_p_t
         run_test    PARAMS(( tCC* t_name, tCC* f_name, tCC* text ));
  
! #ifdef __MSDOS__
  char*  make_raw_shell_str
                     PARAMS(( char* pz_d, tCC* pz_s, size_t smax ));
  #endif
--- 209,215 ----
  apply_fix_p_t
         run_test    PARAMS(( tCC* t_name, tCC* f_name, tCC* text ));
  
! #if defined(__MSDOS__) || defined(__BEOS__)
  char*  make_raw_shell_str
                     PARAMS(( char* pz_d, tCC* pz_s, size_t smax ));
  #endif
Index: mkfixinc.sh
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/mkfixinc.sh,v
retrieving revision 1.28
diff -c -3 -p -w -B -b -r1.28 mkfixinc.sh
*** mkfixinc.sh	2000/11/17 23:48:15	1.28
--- mkfixinc.sh	2000/11/27 21:54:48
*************** case $machine in
*** 35,40 ****
--- 35,43 ----
  	i?86-*-openbsd*)
  		fixincludes=fixinc.wrap
  		;;
+ 	*-*-beos*)
+ 		MAKE="${MAKE} -f ${srcdir}/Makefile.BEOS"
+ 		;;
  
  	alpha*-*-winnt* | \
  	i?86-*-winnt3*)
*************** case $machine in
*** 55,61 ****
  	hppa1.1-*-bsd* | \
  	hppa1.0-*-bsd* | \
  	hppa*-*-lites* | \
! 	*-*-beos* | \
  	*-*-gnu* | \
  	i?86-moss-msdos* | i?86-*-moss* | \
  	i?86-*-osf1* | \
--- 58,64 ----
  	hppa1.1-*-bsd* | \
  	hppa1.0-*-bsd* | \
  	hppa*-*-lites* | \
! 	*-*-linux* | \
  	*-*-gnu* | \
  	i?86-moss-msdos* | i?86-*-moss* | \
  	i?86-*-osf1* | \
# Generated automatically from Makefile.in by configure.
# Makefile for GNU compilers.
#   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.

#This file is part of GNU CC.

#GNU CC 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.

#GNU CC 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 GNU CC; see the file COPYING.  If not, write to
#the Free Software Foundation, 59 Temple Place - Suite 330,
#Boston, MA 02111-1307, USA.

# The makefile built from this file lives in the fixinc subdirectory.
# Its purpose is to build the any-platforms fixinc.sh script.

CFLAGS = -g  
FIXINC_DEFS = -DIN_GCC $(CFLAGS) $(CPPFLAGS) $(INCLUDES)

CC = gcc
SHELL = /bin/sh

target=i586-pc-beos
# Directory where sources are, from where we are.
srcdir = ../../../gcc/fixinc
VPATH = ../../../gcc/fixinc
subdir = fixinc

# End of variables for you to override.

default : all

# Now figure out from those variables how to compile and link.

# Specify the directories to be searched for header files.
# Both . and srcdir are used, in that order.
#
INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. \
-I$(srcdir)/../config -I$(srcdir)/../../include

# Always use -I$(srcdir)/config when compiling.
.c.o:
	$(CC) -c $(FIXINC_DEFS) $<

# The only suffixes we want for implicit rules are .c and .o.
.SUFFIXES:
.SUFFIXES: .c .o

#

## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
##
##  Makefile for constructing the "best" include fixer we can
##
## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

LIBERTY = ../../libiberty/libiberty.a
OBJ = fixincl.o fixtests.o server.o procopen.o \
      gnu-regex.o fixlib.o 

APPLY_OBJ = fixfixes.o fixlib.o gnu-regex.o

applyfix: $(APPLY_OBJ) $(LIBERTY)
	$(CC) $(FIXINC_DEFS) -o $@ $(APPLY_OBJ) $(LIBERTY)

HDR = server.h gnu-regex.h fixlib.h machname.h

TARGETS = fixincl applyfix
all : $(TARGETS)
gen : fixincl.x

fixincl: $(OBJ) $(LIBERTY)
	$(CC) $(FIXINC_DEFS) $(LDFLAGS) -o $@ $(OBJ) $(LIBERTY)

$(OBJ)      : $(HDR)
$(APPLY_OBJ) : $(HDR)
fixincl.o   : fixincl.x fixincl.c
fixtests.o  : fixtests.c
fixfixes.o  : fixfixes.c
server.o    : server.c
procopen.o  : procopen.c
gnu-regex.o : gnu-regex.c
fixlib.o    : fixlib.c

#  'machname.h' is built in the build directory.
#  'fixincl.x' in the source dir.
#
machname.h: ../specs
	$(SHELL) $(srcdir)/genfixes $@

fixincl.x: fixincl.tpl inclhack.def
	cd $(srcdir) ; $(SHELL) ./genfixes $@

clean:
	rm -f *.o $(TARGETS) fixincl.x machname.h *~

#  Build the executable and copy up into gcc dir.
#  We still copy the script because we still have alternative scripts.
#
install-bin : $(TARGETS)
	./fixincl -v
	@if [ -f ../fixinc.sh ] ; then rm -f ../fixinc.sh || \
	    mv -f ../fixinc.sh ../fixinc.sh.$$ || exit 1 ; fi
	@if [ -f ./fixincl.sh ] ; \
	then echo cp ./fixincl.sh ../fixinc.sh ; \
		cp ./fixincl.sh ../fixinc.sh ; \
	else echo cp $(srcdir)/fixincl.sh ../fixinc.sh ; \
		cp $(srcdir)/fixincl.sh ../fixinc.sh ; fi
	chmod 755 ../fixinc.sh

Makefile: Makefile.in ../config.status
	cd .. \
	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \
	  $(SHELL) ./config.status

check : fixincl
	autogen -T $(srcdir)/check.tpl $(srcdir)/inclhack.def
	$(SHELL) ./check.sh $(srcdir)/tests/base
	@rm -f ./check.sh

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]