Updated w32 external tools, including source code and build scripts.
git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@62 0109f412-320b-0410-ab79-c3e0c5ffbbe6
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
# $Id: Makefile 3105 2006-01-11 11:14:10 -0700 (Wed, 11 Jan 2006) ahodgkinson $
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
# Sample Usage:
|
||||
@@ -377,7 +376,7 @@ ifeq ($(host_os_family),win)
|
||||
allprereqs = $(subst /,\,$+)
|
||||
copycmd = copy /Y $(subst /,\,$(1)) $(subst /,\,$(2)) >NUL
|
||||
rmcmd = del /Q $(subst /,\,$(1))
|
||||
rmdircmd = cmd /C "rmdir /q /s $(subst /,\,$(1))"
|
||||
rmdircmd = if exist $(subst /,\,$(1)) rmdir /q /s $(subst /,\,$(1))
|
||||
mkdircmd = -if not exist $(subst /,\,$(1)) mkdir $(subst /,\,$(1)) >NUL
|
||||
runtest = cmd /C "cd $(subst /,\,$(test_dir)) && $(1) -d"
|
||||
else
|
||||
|
||||
1
flaim/external/w32/make/VERSION
vendored
Normal file
1
flaim/external/w32/make/VERSION
vendored
Normal file
@@ -0,0 +1 @@
|
||||
3.80
|
||||
504
flaim/external/w32/make/alloca.c
vendored
Normal file
504
flaim/external/w32/make/alloca.c
vendored
Normal file
@@ -0,0 +1,504 @@
|
||||
/* alloca.c -- allocate automatically reclaimed memory
|
||||
(Mostly) portable public-domain implementation -- D A Gwyn
|
||||
|
||||
This implementation of the PWB library alloca function,
|
||||
which is used to allocate space off the run-time stack so
|
||||
that it is automatically reclaimed upon procedure exit,
|
||||
was inspired by discussions with J. Q. Johnson of Cornell.
|
||||
J.Otto Tennant <jot@cray.com> contributed the Cray support.
|
||||
|
||||
There are some preprocessor constants that can
|
||||
be defined when compiling for your specific system, for
|
||||
improved efficiency; however, the defaults should be okay.
|
||||
|
||||
The general concept of this implementation is to keep
|
||||
track of all alloca-allocated blocks, and reclaim any
|
||||
that are found to be deeper in the stack than the current
|
||||
invocation. This heuristic does not reclaim storage as
|
||||
soon as it becomes invalid, but it will do so eventually.
|
||||
|
||||
As a special case, alloca(0) reclaims storage without
|
||||
allocating any. It is a good idea to use alloca(0) in
|
||||
your main control loop, etc. to force garbage collection. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef emacs
|
||||
#include "blockinput.h"
|
||||
#endif
|
||||
|
||||
/* If compiling with GCC 2, this file's not needed. */
|
||||
#if !defined (__GNUC__) || __GNUC__ < 2
|
||||
|
||||
/* If someone has defined alloca as a macro,
|
||||
there must be some other way alloca is supposed to work. */
|
||||
#ifndef alloca
|
||||
|
||||
#ifdef emacs
|
||||
#ifdef static
|
||||
/* actually, only want this if static is defined as ""
|
||||
-- this is for usg, in which emacs must undefine static
|
||||
in order to make unexec workable
|
||||
*/
|
||||
#ifndef STACK_DIRECTION
|
||||
you
|
||||
lose
|
||||
-- must know STACK_DIRECTION at compile-time
|
||||
#endif /* STACK_DIRECTION undefined */
|
||||
#endif /* static */
|
||||
#endif /* emacs */
|
||||
|
||||
/* If your stack is a linked list of frames, you have to
|
||||
provide an "address metric" ADDRESS_FUNCTION macro. */
|
||||
|
||||
#if defined (CRAY) && defined (CRAY_STACKSEG_END)
|
||||
long i00afunc ();
|
||||
#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
|
||||
#else
|
||||
#define ADDRESS_FUNCTION(arg) &(arg)
|
||||
#endif
|
||||
|
||||
#if __STDC__
|
||||
typedef void *pointer;
|
||||
#else
|
||||
typedef char *pointer;
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
/* Different portions of Emacs need to call different versions of
|
||||
malloc. The Emacs executable needs alloca to call xmalloc, because
|
||||
ordinary malloc isn't protected from input signals. On the other
|
||||
hand, the utilities in lib-src need alloca to call malloc; some of
|
||||
them are very simple, and don't have an xmalloc routine.
|
||||
|
||||
Non-Emacs programs expect this to call use xmalloc.
|
||||
|
||||
Callers below should use malloc. */
|
||||
|
||||
#ifndef emacs
|
||||
#define malloc xmalloc
|
||||
#endif
|
||||
extern pointer malloc ();
|
||||
|
||||
/* Define STACK_DIRECTION if you know the direction of stack
|
||||
growth for your system; otherwise it will be automatically
|
||||
deduced at run-time.
|
||||
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
|
||||
#ifndef STACK_DIRECTION
|
||||
#define STACK_DIRECTION 0 /* Direction unknown. */
|
||||
#endif
|
||||
|
||||
#if STACK_DIRECTION != 0
|
||||
|
||||
#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */
|
||||
|
||||
#else /* STACK_DIRECTION == 0; need run-time code. */
|
||||
|
||||
static int stack_dir; /* 1 or -1 once known. */
|
||||
#define STACK_DIR stack_dir
|
||||
|
||||
static void
|
||||
find_stack_direction ()
|
||||
{
|
||||
static char *addr = NULL; /* Address of first `dummy', once known. */
|
||||
auto char dummy; /* To get stack address. */
|
||||
|
||||
if (addr == NULL)
|
||||
{ /* Initial entry. */
|
||||
addr = ADDRESS_FUNCTION (dummy);
|
||||
|
||||
find_stack_direction (); /* Recurse once. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Second entry. */
|
||||
if (ADDRESS_FUNCTION (dummy) > addr)
|
||||
stack_dir = 1; /* Stack grew upward. */
|
||||
else
|
||||
stack_dir = -1; /* Stack grew downward. */
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* STACK_DIRECTION == 0 */
|
||||
|
||||
/* An "alloca header" is used to:
|
||||
(a) chain together all alloca'ed blocks;
|
||||
(b) keep track of stack depth.
|
||||
|
||||
It is very important that sizeof(header) agree with malloc
|
||||
alignment chunk size. The following default should work okay. */
|
||||
|
||||
#ifndef ALIGN_SIZE
|
||||
#define ALIGN_SIZE sizeof(double)
|
||||
#endif
|
||||
|
||||
typedef union hdr
|
||||
{
|
||||
char align[ALIGN_SIZE]; /* To force sizeof(header). */
|
||||
struct
|
||||
{
|
||||
union hdr *next; /* For chaining headers. */
|
||||
char *deep; /* For stack depth measure. */
|
||||
} h;
|
||||
} header;
|
||||
|
||||
static header *last_alloca_header = NULL; /* -> last alloca header. */
|
||||
|
||||
/* Return a pointer to at least SIZE bytes of storage,
|
||||
which will be automatically reclaimed upon exit from
|
||||
the procedure that called alloca. Originally, this space
|
||||
was supposed to be taken from the current stack frame of the
|
||||
caller, but that method cannot be made to work for some
|
||||
implementations of C, for example under Gould's UTX/32. */
|
||||
|
||||
pointer
|
||||
alloca (size)
|
||||
unsigned size;
|
||||
{
|
||||
auto char probe; /* Probes stack depth: */
|
||||
register char *depth = ADDRESS_FUNCTION (probe);
|
||||
|
||||
#if STACK_DIRECTION == 0
|
||||
if (STACK_DIR == 0) /* Unknown growth direction. */
|
||||
find_stack_direction ();
|
||||
#endif
|
||||
|
||||
/* Reclaim garbage, defined as all alloca'd storage that
|
||||
was allocated from deeper in the stack than currently. */
|
||||
|
||||
{
|
||||
register header *hp; /* Traverses linked list. */
|
||||
|
||||
#ifdef emacs
|
||||
BLOCK_INPUT;
|
||||
#endif
|
||||
|
||||
for (hp = last_alloca_header; hp != NULL;)
|
||||
if ((STACK_DIR > 0 && hp->h.deep > depth)
|
||||
|| (STACK_DIR < 0 && hp->h.deep < depth))
|
||||
{
|
||||
register header *np = hp->h.next;
|
||||
|
||||
free ((pointer) hp); /* Collect garbage. */
|
||||
|
||||
hp = np; /* -> next header. */
|
||||
}
|
||||
else
|
||||
break; /* Rest are not deeper. */
|
||||
|
||||
last_alloca_header = hp; /* -> last valid storage. */
|
||||
|
||||
#ifdef emacs
|
||||
UNBLOCK_INPUT;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
return NULL; /* No allocation required. */
|
||||
|
||||
/* Allocate combined header + user data storage. */
|
||||
|
||||
{
|
||||
register pointer new = malloc (sizeof (header) + size);
|
||||
/* Address of header. */
|
||||
|
||||
if (new == 0)
|
||||
abort();
|
||||
|
||||
((header *) new)->h.next = last_alloca_header;
|
||||
((header *) new)->h.deep = depth;
|
||||
|
||||
last_alloca_header = (header *) new;
|
||||
|
||||
/* User storage begins just after header. */
|
||||
|
||||
return (pointer) ((char *) new + sizeof (header));
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (CRAY) && defined (CRAY_STACKSEG_END)
|
||||
|
||||
#ifdef DEBUG_I00AFUNC
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifndef CRAY_STACK
|
||||
#define CRAY_STACK
|
||||
#ifndef CRAY2
|
||||
/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
|
||||
struct stack_control_header
|
||||
{
|
||||
long shgrow:32; /* Number of times stack has grown. */
|
||||
long shaseg:32; /* Size of increments to stack. */
|
||||
long shhwm:32; /* High water mark of stack. */
|
||||
long shsize:32; /* Current size of stack (all segments). */
|
||||
};
|
||||
|
||||
/* The stack segment linkage control information occurs at
|
||||
the high-address end of a stack segment. (The stack
|
||||
grows from low addresses to high addresses.) The initial
|
||||
part of the stack segment linkage control information is
|
||||
0200 (octal) words. This provides for register storage
|
||||
for the routine which overflows the stack. */
|
||||
|
||||
struct stack_segment_linkage
|
||||
{
|
||||
long ss[0200]; /* 0200 overflow words. */
|
||||
long sssize:32; /* Number of words in this segment. */
|
||||
long ssbase:32; /* Offset to stack base. */
|
||||
long:32;
|
||||
long sspseg:32; /* Offset to linkage control of previous
|
||||
segment of stack. */
|
||||
long:32;
|
||||
long sstcpt:32; /* Pointer to task common address block. */
|
||||
long sscsnm; /* Private control structure number for
|
||||
microtasking. */
|
||||
long ssusr1; /* Reserved for user. */
|
||||
long ssusr2; /* Reserved for user. */
|
||||
long sstpid; /* Process ID for pid based multi-tasking. */
|
||||
long ssgvup; /* Pointer to multitasking thread giveup. */
|
||||
long sscray[7]; /* Reserved for Cray Research. */
|
||||
long ssa0;
|
||||
long ssa1;
|
||||
long ssa2;
|
||||
long ssa3;
|
||||
long ssa4;
|
||||
long ssa5;
|
||||
long ssa6;
|
||||
long ssa7;
|
||||
long sss0;
|
||||
long sss1;
|
||||
long sss2;
|
||||
long sss3;
|
||||
long sss4;
|
||||
long sss5;
|
||||
long sss6;
|
||||
long sss7;
|
||||
};
|
||||
|
||||
#else /* CRAY2 */
|
||||
/* The following structure defines the vector of words
|
||||
returned by the STKSTAT library routine. */
|
||||
struct stk_stat
|
||||
{
|
||||
long now; /* Current total stack size. */
|
||||
long maxc; /* Amount of contiguous space which would
|
||||
be required to satisfy the maximum
|
||||
stack demand to date. */
|
||||
long high_water; /* Stack high-water mark. */
|
||||
long overflows; /* Number of stack overflow ($STKOFEN) calls. */
|
||||
long hits; /* Number of internal buffer hits. */
|
||||
long extends; /* Number of block extensions. */
|
||||
long stko_mallocs; /* Block allocations by $STKOFEN. */
|
||||
long underflows; /* Number of stack underflow calls ($STKRETN). */
|
||||
long stko_free; /* Number of deallocations by $STKRETN. */
|
||||
long stkm_free; /* Number of deallocations by $STKMRET. */
|
||||
long segments; /* Current number of stack segments. */
|
||||
long maxs; /* Maximum number of stack segments so far. */
|
||||
long pad_size; /* Stack pad size. */
|
||||
long current_address; /* Current stack segment address. */
|
||||
long current_size; /* Current stack segment size. This
|
||||
number is actually corrupted by STKSTAT to
|
||||
include the fifteen word trailer area. */
|
||||
long initial_address; /* Address of initial segment. */
|
||||
long initial_size; /* Size of initial segment. */
|
||||
};
|
||||
|
||||
/* The following structure describes the data structure which trails
|
||||
any stack segment. I think that the description in 'asdef' is
|
||||
out of date. I only describe the parts that I am sure about. */
|
||||
|
||||
struct stk_trailer
|
||||
{
|
||||
long this_address; /* Address of this block. */
|
||||
long this_size; /* Size of this block (does not include
|
||||
this trailer). */
|
||||
long unknown2;
|
||||
long unknown3;
|
||||
long link; /* Address of trailer block of previous
|
||||
segment. */
|
||||
long unknown5;
|
||||
long unknown6;
|
||||
long unknown7;
|
||||
long unknown8;
|
||||
long unknown9;
|
||||
long unknown10;
|
||||
long unknown11;
|
||||
long unknown12;
|
||||
long unknown13;
|
||||
long unknown14;
|
||||
};
|
||||
|
||||
#endif /* CRAY2 */
|
||||
#endif /* not CRAY_STACK */
|
||||
|
||||
#ifdef CRAY2
|
||||
/* Determine a "stack measure" for an arbitrary ADDRESS.
|
||||
I doubt that "lint" will like this much. */
|
||||
|
||||
static long
|
||||
i00afunc (long *address)
|
||||
{
|
||||
struct stk_stat status;
|
||||
struct stk_trailer *trailer;
|
||||
long *block, size;
|
||||
long result = 0;
|
||||
|
||||
/* We want to iterate through all of the segments. The first
|
||||
step is to get the stack status structure. We could do this
|
||||
more quickly and more directly, perhaps, by referencing the
|
||||
$LM00 common block, but I know that this works. */
|
||||
|
||||
STKSTAT (&status);
|
||||
|
||||
/* Set up the iteration. */
|
||||
|
||||
trailer = (struct stk_trailer *) (status.current_address
|
||||
+ status.current_size
|
||||
- 15);
|
||||
|
||||
/* There must be at least one stack segment. Therefore it is
|
||||
a fatal error if "trailer" is null. */
|
||||
|
||||
if (trailer == 0)
|
||||
abort ();
|
||||
|
||||
/* Discard segments that do not contain our argument address. */
|
||||
|
||||
while (trailer != 0)
|
||||
{
|
||||
block = (long *) trailer->this_address;
|
||||
size = trailer->this_size;
|
||||
if (block == 0 || size == 0)
|
||||
abort ();
|
||||
trailer = (struct stk_trailer *) trailer->link;
|
||||
if ((block <= address) && (address < (block + size)))
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set the result to the offset in this segment and add the sizes
|
||||
of all predecessor segments. */
|
||||
|
||||
result = address - block;
|
||||
|
||||
if (trailer == 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (trailer->this_size <= 0)
|
||||
abort ();
|
||||
result += trailer->this_size;
|
||||
trailer = (struct stk_trailer *) trailer->link;
|
||||
}
|
||||
while (trailer != 0);
|
||||
|
||||
/* We are done. Note that if you present a bogus address (one
|
||||
not in any segment), you will get a different number back, formed
|
||||
from subtracting the address of the first block. This is probably
|
||||
not what you want. */
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
#else /* not CRAY2 */
|
||||
/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
|
||||
Determine the number of the cell within the stack,
|
||||
given the address of the cell. The purpose of this
|
||||
routine is to linearize, in some sense, stack addresses
|
||||
for alloca. */
|
||||
|
||||
static long
|
||||
i00afunc (long address)
|
||||
{
|
||||
long stkl = 0;
|
||||
|
||||
long size, pseg, this_segment, stack;
|
||||
long result = 0;
|
||||
|
||||
struct stack_segment_linkage *ssptr;
|
||||
|
||||
/* Register B67 contains the address of the end of the
|
||||
current stack segment. If you (as a subprogram) store
|
||||
your registers on the stack and find that you are past
|
||||
the contents of B67, you have overflowed the segment.
|
||||
|
||||
B67 also points to the stack segment linkage control
|
||||
area, which is what we are really interested in. */
|
||||
|
||||
stkl = CRAY_STACKSEG_END ();
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
|
||||
/* If one subtracts 'size' from the end of the segment,
|
||||
one has the address of the first word of the segment.
|
||||
|
||||
If this is not the first segment, 'pseg' will be
|
||||
nonzero. */
|
||||
|
||||
pseg = ssptr->sspseg;
|
||||
size = ssptr->sssize;
|
||||
|
||||
this_segment = stkl - size;
|
||||
|
||||
/* It is possible that calling this routine itself caused
|
||||
a stack overflow. Discard stack segments which do not
|
||||
contain the target address. */
|
||||
|
||||
while (!(this_segment <= address && address <= stkl))
|
||||
{
|
||||
#ifdef DEBUG_I00AFUNC
|
||||
fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
|
||||
#endif
|
||||
if (pseg == 0)
|
||||
break;
|
||||
stkl = stkl - pseg;
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
size = ssptr->sssize;
|
||||
pseg = ssptr->sspseg;
|
||||
this_segment = stkl - size;
|
||||
}
|
||||
|
||||
result = address - this_segment;
|
||||
|
||||
/* If you subtract pseg from the current end of the stack,
|
||||
you get the address of the previous stack segment's end.
|
||||
This seems a little convoluted to me, but I'll bet you save
|
||||
a cycle somewhere. */
|
||||
|
||||
while (pseg != 0)
|
||||
{
|
||||
#ifdef DEBUG_I00AFUNC
|
||||
fprintf (stderr, "%011o %011o\n", pseg, size);
|
||||
#endif
|
||||
stkl = stkl - pseg;
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
size = ssptr->sssize;
|
||||
pseg = ssptr->sspseg;
|
||||
result += size;
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
#endif /* not CRAY2 */
|
||||
#endif /* CRAY */
|
||||
|
||||
#endif /* no alloca */
|
||||
#endif /* not GCC version 2 */
|
||||
22
flaim/external/w32/make/amiga.h
vendored
Normal file
22
flaim/external/w32/make/amiga.h
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/* Definitions for amiga specific things
|
||||
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA. */
|
||||
|
||||
extern int MyExecute PARAMS ((char ** argv));
|
||||
extern char * wildcard_expansion PARAMS ((char * wc, char * o));
|
||||
|
||||
329
flaim/external/w32/make/ar.c
vendored
Normal file
329
flaim/external/w32/make/ar.c
vendored
Normal file
@@ -0,0 +1,329 @@
|
||||
/* Interface to `ar' archives for GNU Make.
|
||||
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1997,
|
||||
2002 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "make.h"
|
||||
|
||||
#ifndef NO_ARCHIVES
|
||||
|
||||
#include "filedef.h"
|
||||
#include "dep.h"
|
||||
#include <fnmatch.h>
|
||||
|
||||
/* Defined in arscan.c. */
|
||||
extern long int ar_scan PARAMS ((char *archive, long int (*function) (), long int arg));
|
||||
extern int ar_name_equal PARAMS ((char *name, char *mem, int truncated));
|
||||
#ifndef VMS
|
||||
extern int ar_member_touch PARAMS ((char *arname, char *memname));
|
||||
#endif
|
||||
|
||||
/* Return nonzero if NAME is an archive-member reference, zero if not.
|
||||
An archive-member reference is a name like `lib(member)'.
|
||||
If a name like `lib((entry))' is used, a fatal error is signaled at
|
||||
the attempt to use this unsupported feature. */
|
||||
|
||||
int
|
||||
ar_name (name)
|
||||
char *name;
|
||||
{
|
||||
char *p = strchr (name, '(');
|
||||
char *end;
|
||||
|
||||
if (p == 0 || p == name)
|
||||
return 0;
|
||||
|
||||
end = p + strlen (p) - 1;
|
||||
if (*end != ')')
|
||||
return 0;
|
||||
|
||||
if (p[1] == '(' && end[-1] == ')')
|
||||
fatal (NILF, _("attempt to use unsupported feature: `%s'"), name);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Parse the archive-member reference NAME into the archive and member names.
|
||||
Put the malloc'd archive name in *ARNAME_P if ARNAME_P is non-nil;
|
||||
put the malloc'd member name in *MEMNAME_P if MEMNAME_P is non-nil. */
|
||||
|
||||
void
|
||||
ar_parse_name (name, arname_p, memname_p)
|
||||
char *name, **arname_p, **memname_p;
|
||||
{
|
||||
char *p = strchr (name, '('), *end = name + strlen (name) - 1;
|
||||
|
||||
if (arname_p != 0)
|
||||
*arname_p = savestring (name, p - name);
|
||||
|
||||
if (memname_p != 0)
|
||||
*memname_p = savestring (p + 1, end - (p + 1));
|
||||
}
|
||||
|
||||
static long int ar_member_date_1 PARAMS ((int desc, char *mem, int truncated, long int hdrpos,
|
||||
long int datapos, long int size, long int date, int uid, int gid, int mode, char *name));
|
||||
|
||||
/* Return the modtime of NAME. */
|
||||
|
||||
time_t
|
||||
ar_member_date (name)
|
||||
char *name;
|
||||
{
|
||||
char *arname;
|
||||
int arname_used = 0;
|
||||
char *memname;
|
||||
long int val;
|
||||
|
||||
ar_parse_name (name, &arname, &memname);
|
||||
|
||||
/* Make sure we know the modtime of the archive itself because we are
|
||||
likely to be called just before commands to remake a member are run,
|
||||
and they will change the archive itself.
|
||||
|
||||
But we must be careful not to enter_file the archive itself if it does
|
||||
not exist, because pattern_search assumes that files found in the data
|
||||
base exist or can be made. */
|
||||
{
|
||||
struct file *arfile;
|
||||
arfile = lookup_file (arname);
|
||||
if (arfile == 0 && file_exists_p (arname))
|
||||
{
|
||||
arfile = enter_file (arname);
|
||||
arname_used = 1;
|
||||
}
|
||||
|
||||
if (arfile != 0)
|
||||
(void) f_mtime (arfile, 0);
|
||||
}
|
||||
|
||||
val = ar_scan (arname, ar_member_date_1, (long int) memname);
|
||||
|
||||
if (!arname_used)
|
||||
free (arname);
|
||||
free (memname);
|
||||
|
||||
return (val <= 0 ? (time_t) -1 : (time_t) val);
|
||||
}
|
||||
|
||||
/* This function is called by `ar_scan' to find which member to look at. */
|
||||
|
||||
/* ARGSUSED */
|
||||
static long int
|
||||
ar_member_date_1 (desc, mem, truncated,
|
||||
hdrpos, datapos, size, date, uid, gid, mode, name)
|
||||
int desc;
|
||||
char *mem;
|
||||
int truncated;
|
||||
long int hdrpos, datapos, size, date;
|
||||
int uid, gid, mode;
|
||||
char *name;
|
||||
{
|
||||
return ar_name_equal (name, mem, truncated) ? date : 0;
|
||||
}
|
||||
|
||||
/* Set the archive-member NAME's modtime to now. */
|
||||
|
||||
#ifdef VMS
|
||||
int
|
||||
ar_touch (name)
|
||||
char *name;
|
||||
{
|
||||
error (NILF, _("touch archive member is not available on VMS"));
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
int
|
||||
ar_touch (name)
|
||||
char *name;
|
||||
{
|
||||
char *arname, *memname;
|
||||
int arname_used = 0;
|
||||
register int val;
|
||||
|
||||
ar_parse_name (name, &arname, &memname);
|
||||
|
||||
/* Make sure we know the modtime of the archive itself before we
|
||||
touch the member, since this will change the archive itself. */
|
||||
{
|
||||
struct file *arfile;
|
||||
arfile = lookup_file (arname);
|
||||
if (arfile == 0)
|
||||
{
|
||||
arfile = enter_file (arname);
|
||||
arname_used = 1;
|
||||
}
|
||||
|
||||
(void) f_mtime (arfile, 0);
|
||||
}
|
||||
|
||||
val = 1;
|
||||
switch (ar_member_touch (arname, memname))
|
||||
{
|
||||
case -1:
|
||||
error (NILF, _("touch: Archive `%s' does not exist"), arname);
|
||||
break;
|
||||
case -2:
|
||||
error (NILF, _("touch: `%s' is not a valid archive"), arname);
|
||||
break;
|
||||
case -3:
|
||||
perror_with_name ("touch: ", arname);
|
||||
break;
|
||||
case 1:
|
||||
error (NILF,
|
||||
_("touch: Member `%s' does not exist in `%s'"), memname, arname);
|
||||
break;
|
||||
case 0:
|
||||
val = 0;
|
||||
break;
|
||||
default:
|
||||
error (NILF,
|
||||
_("touch: Bad return code from ar_member_touch on `%s'"), name);
|
||||
}
|
||||
|
||||
if (!arname_used)
|
||||
free (arname);
|
||||
free (memname);
|
||||
|
||||
return val;
|
||||
}
|
||||
#endif /* !VMS */
|
||||
|
||||
/* State of an `ar_glob' run, passed to `ar_glob_match'. */
|
||||
|
||||
struct ar_glob_state
|
||||
{
|
||||
char *arname;
|
||||
char *pattern;
|
||||
unsigned int size;
|
||||
struct nameseq *chain;
|
||||
unsigned int n;
|
||||
};
|
||||
|
||||
/* This function is called by `ar_scan' to match one archive
|
||||
element against the pattern in STATE. */
|
||||
|
||||
static long int
|
||||
ar_glob_match (desc, mem, truncated,
|
||||
hdrpos, datapos, size, date, uid, gid, mode,
|
||||
state)
|
||||
int desc;
|
||||
char *mem;
|
||||
int truncated;
|
||||
long int hdrpos, datapos, size, date;
|
||||
int uid, gid, mode;
|
||||
struct ar_glob_state *state;
|
||||
{
|
||||
if (fnmatch (state->pattern, mem, FNM_PATHNAME|FNM_PERIOD) == 0)
|
||||
{
|
||||
/* We have a match. Add it to the chain. */
|
||||
struct nameseq *new = (struct nameseq *) xmalloc (state->size);
|
||||
new->name = concat (state->arname, mem, ")");
|
||||
new->next = state->chain;
|
||||
state->chain = new;
|
||||
++state->n;
|
||||
}
|
||||
|
||||
return 0L;
|
||||
}
|
||||
|
||||
/* Return nonzero if PATTERN contains any metacharacters.
|
||||
Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
|
||||
static int
|
||||
glob_pattern_p (pattern, quote)
|
||||
const char *pattern;
|
||||
const int quote;
|
||||
{
|
||||
register const char *p;
|
||||
int open = 0;
|
||||
|
||||
for (p = pattern; *p != '\0'; ++p)
|
||||
switch (*p)
|
||||
{
|
||||
case '?':
|
||||
case '*':
|
||||
return 1;
|
||||
|
||||
case '\\':
|
||||
if (quote)
|
||||
++p;
|
||||
break;
|
||||
|
||||
case '[':
|
||||
open = 1;
|
||||
break;
|
||||
|
||||
case ']':
|
||||
if (open)
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Glob for MEMBER_PATTERN in archive ARNAME.
|
||||
Return a malloc'd chain of matching elements (or nil if none). */
|
||||
|
||||
struct nameseq *
|
||||
ar_glob (arname, member_pattern, size)
|
||||
char *arname, *member_pattern;
|
||||
unsigned int size;
|
||||
{
|
||||
struct ar_glob_state state;
|
||||
char **names;
|
||||
struct nameseq *n;
|
||||
unsigned int i;
|
||||
|
||||
if (! glob_pattern_p (member_pattern, 1))
|
||||
return 0;
|
||||
|
||||
/* Scan the archive for matches.
|
||||
ar_glob_match will accumulate them in STATE.chain. */
|
||||
i = strlen (arname);
|
||||
state.arname = (char *) alloca (i + 2);
|
||||
bcopy (arname, state.arname, i);
|
||||
state.arname[i] = '(';
|
||||
state.arname[i + 1] = '\0';
|
||||
state.pattern = member_pattern;
|
||||
state.size = size;
|
||||
state.chain = 0;
|
||||
state.n = 0;
|
||||
(void) ar_scan (arname, ar_glob_match, (long int) &state);
|
||||
|
||||
if (state.chain == 0)
|
||||
return 0;
|
||||
|
||||
/* Now put the names into a vector for sorting. */
|
||||
names = (char **) alloca (state.n * sizeof (char *));
|
||||
i = 0;
|
||||
for (n = state.chain; n != 0; n = n->next)
|
||||
names[i++] = n->name;
|
||||
|
||||
/* Sort them alphabetically. */
|
||||
qsort ((char *) names, i, sizeof (*names), alpha_compare);
|
||||
|
||||
/* Put them back into the chain in the sorted order. */
|
||||
i = 0;
|
||||
for (n = state.chain; n != 0; n = n->next)
|
||||
n->name = names[i++];
|
||||
|
||||
return state.chain;
|
||||
}
|
||||
|
||||
#endif /* Not NO_ARCHIVES. */
|
||||
861
flaim/external/w32/make/arscan.c
vendored
Normal file
861
flaim/external/w32/make/arscan.c
vendored
Normal file
@@ -0,0 +1,861 @@
|
||||
/* Library function for scanning an archive file.
|
||||
Copyright (C) 1987,89,91,92,93,94,95,97 Free Software Foundation, Inc.
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#include "make.h"
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#include <sys/file.h>
|
||||
#endif
|
||||
|
||||
#ifndef NO_ARCHIVES
|
||||
|
||||
#ifdef VMS
|
||||
#include <lbrdef.h>
|
||||
#include <mhddef.h>
|
||||
#include <credef.h>
|
||||
#include <descrip.h>
|
||||
#include <ctype.h>
|
||||
#if __DECC
|
||||
#include <unixlib.h>
|
||||
#include <lbr$routines.h>
|
||||
#endif
|
||||
|
||||
static void *VMS_lib_idx;
|
||||
|
||||
static char *VMS_saved_memname;
|
||||
|
||||
static time_t VMS_member_date;
|
||||
|
||||
static long int (*VMS_function) ();
|
||||
|
||||
static int
|
||||
VMS_get_member_info (module, rfa)
|
||||
struct dsc$descriptor_s *module;
|
||||
unsigned long *rfa;
|
||||
{
|
||||
int status, i;
|
||||
long int fnval;
|
||||
|
||||
time_t val;
|
||||
|
||||
static struct dsc$descriptor_s bufdesc =
|
||||
{ 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL };
|
||||
|
||||
struct mhddef *mhd;
|
||||
char filename[128];
|
||||
|
||||
bufdesc.dsc$a_pointer = filename;
|
||||
bufdesc.dsc$w_length = sizeof (filename);
|
||||
|
||||
status = lbr$set_module (&VMS_lib_idx, rfa, &bufdesc,
|
||||
&bufdesc.dsc$w_length, 0);
|
||||
if (! (status & 1))
|
||||
{
|
||||
error (NILF, _("lbr$set_module failed to extract module info, status = %d"),
|
||||
status);
|
||||
|
||||
lbr$close (&VMS_lib_idx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
mhd = (struct mhddef *) filename;
|
||||
|
||||
#ifdef __DECC
|
||||
/* John Fowler <jfowler@nyx.net> writes this is needed in his environment,
|
||||
* but that decc$fix_time() isn't documented to work this way. Let me
|
||||
* know if this causes problems in other VMS environments.
|
||||
*/
|
||||
val = decc$fix_time (&mhd->mhd$l_datim) + timezone - daylight*3600;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < module->dsc$w_length; i++)
|
||||
filename[i] = _tolower ((unsigned char)module->dsc$a_pointer[i]);
|
||||
|
||||
filename[i] = '\0';
|
||||
|
||||
VMS_member_date = (time_t) -1;
|
||||
|
||||
fnval =
|
||||
(*VMS_function) (-1, filename, 0, 0, 0, 0, val, 0, 0, 0,
|
||||
VMS_saved_memname);
|
||||
|
||||
if (fnval)
|
||||
{
|
||||
VMS_member_date = fnval;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Takes three arguments ARCHIVE, FUNCTION and ARG.
|
||||
|
||||
Open the archive named ARCHIVE, find its members one by one,
|
||||
and for each one call FUNCTION with the following arguments:
|
||||
archive file descriptor for reading the data,
|
||||
member name,
|
||||
member name might be truncated flag,
|
||||
member header position in file,
|
||||
member data position in file,
|
||||
member data size,
|
||||
member date,
|
||||
member uid,
|
||||
member gid,
|
||||
member protection mode,
|
||||
ARG.
|
||||
|
||||
NOTE: on VMS systems, only name, date, and arg are meaningful!
|
||||
|
||||
The descriptor is poised to read the data of the member
|
||||
when FUNCTION is called. It does not matter how much
|
||||
data FUNCTION reads.
|
||||
|
||||
If FUNCTION returns nonzero, we immediately return
|
||||
what FUNCTION returned.
|
||||
|
||||
Returns -1 if archive does not exist,
|
||||
Returns -2 if archive has invalid format.
|
||||
Returns 0 if have scanned successfully. */
|
||||
|
||||
long int
|
||||
ar_scan (archive, function, arg)
|
||||
char *archive;
|
||||
long int (*function) ();
|
||||
long int arg;
|
||||
{
|
||||
char *p;
|
||||
|
||||
static struct dsc$descriptor_s libdesc =
|
||||
{ 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL };
|
||||
|
||||
unsigned long func = LBR$C_READ;
|
||||
unsigned long type = LBR$C_TYP_UNK;
|
||||
unsigned long index = 1;
|
||||
|
||||
int status;
|
||||
|
||||
status = lbr$ini_control (&VMS_lib_idx, &func, &type, 0);
|
||||
|
||||
if (! (status & 1))
|
||||
{
|
||||
error (NILF, _("lbr$ini_control failed with status = %d"),status);
|
||||
return -2;
|
||||
}
|
||||
|
||||
libdesc.dsc$a_pointer = archive;
|
||||
libdesc.dsc$w_length = strlen (archive);
|
||||
|
||||
status = lbr$open (&VMS_lib_idx, &libdesc, 0, 0, 0, 0, 0);
|
||||
|
||||
if (! (status & 1))
|
||||
{
|
||||
error (NILF, _("unable to open library `%s' to lookup member `%s'"),
|
||||
archive, (char *)arg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
VMS_saved_memname = (char *)arg;
|
||||
|
||||
/* For comparison, delete .obj from arg name. */
|
||||
|
||||
p = strrchr (VMS_saved_memname, '.');
|
||||
if (p)
|
||||
*p = '\0';
|
||||
|
||||
VMS_function = function;
|
||||
|
||||
VMS_member_date = (time_t) -1;
|
||||
lbr$get_index (&VMS_lib_idx, &index, VMS_get_member_info, 0);
|
||||
|
||||
/* Undo the damage. */
|
||||
if (p)
|
||||
*p = '.';
|
||||
|
||||
lbr$close (&VMS_lib_idx);
|
||||
|
||||
return VMS_member_date > 0 ? VMS_member_date : 0;
|
||||
}
|
||||
|
||||
#else /* !VMS */
|
||||
|
||||
/* SCO Unix's compiler defines both of these. */
|
||||
#ifdef M_UNIX
|
||||
#undef M_XENIX
|
||||
#endif
|
||||
|
||||
/* On the sun386i and in System V rel 3, ar.h defines two different archive
|
||||
formats depending upon whether you have defined PORTAR (normal) or PORT5AR
|
||||
(System V Release 1). There is no default, one or the other must be defined
|
||||
to have a nonzero value. */
|
||||
|
||||
#if (!defined (PORTAR) || PORTAR == 0) && (!defined (PORT5AR) || PORT5AR == 0)
|
||||
#undef PORTAR
|
||||
#ifdef M_XENIX
|
||||
/* According to Jim Sievert <jas1@rsvl.unisys.com>, for SCO XENIX defining
|
||||
PORTAR to 1 gets the wrong archive format, and defining it to 0 gets the
|
||||
right one. */
|
||||
#define PORTAR 0
|
||||
#else
|
||||
#define PORTAR 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* On AIX, define these symbols to be sure to get both archive formats.
|
||||
AIX 4.3 introduced the "big" archive format to support 64-bit object
|
||||
files, so on AIX 4.3 systems we need to support both the "normal" and
|
||||
"big" archive formats. An archive's format is indicated in the
|
||||
"fl_magic" field of the "FL_HDR" structure. For a normal archive,
|
||||
this field will be the string defined by the AIAMAG symbol. For a
|
||||
"big" archive, it will be the string defined by the AIAMAGBIG symbol
|
||||
(at least on AIX it works this way).
|
||||
|
||||
Note: we'll define these symbols regardless of which AIX version
|
||||
we're compiling on, but this is okay since we'll use the new symbols
|
||||
only if they're present. */
|
||||
#ifdef _AIX
|
||||
# define __AR_SMALL__
|
||||
# define __AR_BIG__
|
||||
#endif
|
||||
|
||||
#ifndef WINDOWS32
|
||||
# ifndef __BEOS__
|
||||
# include <ar.h>
|
||||
# else
|
||||
/* BeOS 5 doesn't have <ar.h> but has archives in the same format
|
||||
* as many other Unices. This was taken from GNU binutils for BeOS.
|
||||
*/
|
||||
# define ARMAG "!<arch>\n" /* String that begins an archive file. */
|
||||
# define SARMAG 8 /* Size of that string. */
|
||||
# define ARFMAG "`\n" /* String in ar_fmag at end of each header. */
|
||||
struct ar_hdr
|
||||
{
|
||||
char ar_name[16]; /* Member file name, sometimes / terminated. */
|
||||
char ar_date[12]; /* File date, decimal seconds since Epoch. */
|
||||
char ar_uid[6], ar_gid[6]; /* User and group IDs, in ASCII decimal. */
|
||||
char ar_mode[8]; /* File mode, in ASCII octal. */
|
||||
char ar_size[10]; /* File size, in ASCII decimal. */
|
||||
char ar_fmag[2]; /* Always contains ARFMAG. */
|
||||
};
|
||||
# endif
|
||||
#else
|
||||
/* These should allow us to read Windows (VC++) libraries (according to Frank
|
||||
* Libbrecht <frankl@abzx.belgium.hp.com>)
|
||||
*/
|
||||
# include <windows.h>
|
||||
# include <windef.h>
|
||||
# include <io.h>
|
||||
# define ARMAG IMAGE_ARCHIVE_START
|
||||
# define SARMAG IMAGE_ARCHIVE_START_SIZE
|
||||
# define ar_hdr _IMAGE_ARCHIVE_MEMBER_HEADER
|
||||
# define ar_name Name
|
||||
# define ar_mode Mode
|
||||
# define ar_size Size
|
||||
# define ar_date Date
|
||||
# define ar_uid UserID
|
||||
# define ar_gid GroupID
|
||||
#endif
|
||||
|
||||
/* Cray's <ar.h> apparently defines this. */
|
||||
#ifndef AR_HDR_SIZE
|
||||
# define AR_HDR_SIZE (sizeof (struct ar_hdr))
|
||||
#endif
|
||||
|
||||
/* Takes three arguments ARCHIVE, FUNCTION and ARG.
|
||||
|
||||
Open the archive named ARCHIVE, find its members one by one,
|
||||
and for each one call FUNCTION with the following arguments:
|
||||
archive file descriptor for reading the data,
|
||||
member name,
|
||||
member name might be truncated flag,
|
||||
member header position in file,
|
||||
member data position in file,
|
||||
member data size,
|
||||
member date,
|
||||
member uid,
|
||||
member gid,
|
||||
member protection mode,
|
||||
ARG.
|
||||
|
||||
The descriptor is poised to read the data of the member
|
||||
when FUNCTION is called. It does not matter how much
|
||||
data FUNCTION reads.
|
||||
|
||||
If FUNCTION returns nonzero, we immediately return
|
||||
what FUNCTION returned.
|
||||
|
||||
Returns -1 if archive does not exist,
|
||||
Returns -2 if archive has invalid format.
|
||||
Returns 0 if have scanned successfully. */
|
||||
|
||||
long int
|
||||
ar_scan (archive, function, arg)
|
||||
char *archive;
|
||||
long int (*function) ();
|
||||
long int arg;
|
||||
{
|
||||
#ifdef AIAMAG
|
||||
FL_HDR fl_header;
|
||||
#ifdef AIAMAGBIG
|
||||
int big_archive = 0;
|
||||
FL_HDR_BIG fl_header_big;
|
||||
#endif
|
||||
#else
|
||||
int long_name = 0;
|
||||
#endif
|
||||
char *namemap = 0;
|
||||
register int desc = open (archive, O_RDONLY, 0);
|
||||
if (desc < 0)
|
||||
return -1;
|
||||
#ifdef SARMAG
|
||||
{
|
||||
char buf[SARMAG];
|
||||
register int nread = read (desc, buf, SARMAG);
|
||||
if (nread != SARMAG || bcmp (buf, ARMAG, SARMAG))
|
||||
{
|
||||
(void) close (desc);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#ifdef AIAMAG
|
||||
{
|
||||
register int nread = read (desc, (char *) &fl_header, FL_HSZ);
|
||||
|
||||
if (nread != FL_HSZ)
|
||||
{
|
||||
(void) close (desc);
|
||||
return -2;
|
||||
}
|
||||
#ifdef AIAMAGBIG
|
||||
/* If this is a "big" archive, then set the flag and
|
||||
re-read the header into the "big" structure. */
|
||||
if (!bcmp (fl_header.fl_magic, AIAMAGBIG, SAIAMAG))
|
||||
{
|
||||
big_archive = 1;
|
||||
|
||||
/* seek back to beginning of archive */
|
||||
if (lseek (desc, 0, 0) < 0)
|
||||
{
|
||||
(void) close (desc);
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* re-read the header into the "big" structure */
|
||||
nread = read (desc, (char *) &fl_header_big, FL_HSZ_BIG);
|
||||
if (nread != FL_HSZ_BIG)
|
||||
{
|
||||
(void) close (desc);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
/* Check to make sure this is a "normal" archive. */
|
||||
if (bcmp (fl_header.fl_magic, AIAMAG, SAIAMAG))
|
||||
{
|
||||
(void) close (desc);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
#ifndef M_XENIX
|
||||
int buf;
|
||||
#else
|
||||
unsigned short int buf;
|
||||
#endif
|
||||
register int nread = read(desc, &buf, sizeof (buf));
|
||||
if (nread != sizeof (buf) || buf != ARMAG)
|
||||
{
|
||||
(void) close (desc);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Now find the members one by one. */
|
||||
{
|
||||
#ifdef SARMAG
|
||||
register long int member_offset = SARMAG;
|
||||
#else
|
||||
#ifdef AIAMAG
|
||||
long int member_offset;
|
||||
long int last_member_offset;
|
||||
|
||||
#ifdef AIAMAGBIG
|
||||
if ( big_archive )
|
||||
{
|
||||
sscanf (fl_header_big.fl_fstmoff, "%20ld", &member_offset);
|
||||
sscanf (fl_header_big.fl_lstmoff, "%20ld", &last_member_offset);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
sscanf (fl_header.fl_fstmoff, "%12ld", &member_offset);
|
||||
sscanf (fl_header.fl_lstmoff, "%12ld", &last_member_offset);
|
||||
}
|
||||
|
||||
if (member_offset == 0)
|
||||
{
|
||||
/* Empty archive. */
|
||||
close (desc);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#ifndef M_XENIX
|
||||
register long int member_offset = sizeof (int);
|
||||
#else /* Xenix. */
|
||||
register long int member_offset = sizeof (unsigned short int);
|
||||
#endif /* Not Xenix. */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
register int nread;
|
||||
struct ar_hdr member_header;
|
||||
#ifdef AIAMAGBIG
|
||||
struct ar_hdr_big member_header_big;
|
||||
#endif
|
||||
#ifdef AIAMAG
|
||||
char name[256];
|
||||
int name_len;
|
||||
long int dateval;
|
||||
int uidval, gidval;
|
||||
long int data_offset;
|
||||
#else
|
||||
char namebuf[sizeof member_header.ar_name + 1];
|
||||
char *name;
|
||||
int is_namemap; /* Nonzero if this entry maps long names. */
|
||||
#endif
|
||||
long int eltsize;
|
||||
int eltmode;
|
||||
long int fnval;
|
||||
|
||||
if (lseek (desc, member_offset, 0) < 0)
|
||||
{
|
||||
(void) close (desc);
|
||||
return -2;
|
||||
}
|
||||
|
||||
#ifdef AIAMAG
|
||||
#define AR_MEMHDR_SZ(x) (sizeof(x) - sizeof (x._ar_name))
|
||||
|
||||
#ifdef AIAMAGBIG
|
||||
if (big_archive)
|
||||
{
|
||||
nread = read (desc, (char *) &member_header_big,
|
||||
AR_MEMHDR_SZ(member_header_big) );
|
||||
|
||||
if (nread != AR_MEMHDR_SZ(member_header_big))
|
||||
{
|
||||
(void) close (desc);
|
||||
return -2;
|
||||
}
|
||||
|
||||
sscanf (member_header_big.ar_namlen, "%4d", &name_len);
|
||||
nread = read (desc, name, name_len);
|
||||
|
||||
if (nread != name_len)
|
||||
{
|
||||
(void) close (desc);
|
||||
return -2;
|
||||
}
|
||||
|
||||
name[name_len] = 0;
|
||||
|
||||
sscanf (member_header_big.ar_date, "%12ld", &dateval);
|
||||
sscanf (member_header_big.ar_uid, "%12d", &uidval);
|
||||
sscanf (member_header_big.ar_gid, "%12d", &gidval);
|
||||
sscanf (member_header_big.ar_mode, "%12o", &eltmode);
|
||||
sscanf (member_header_big.ar_size, "%20ld", &eltsize);
|
||||
|
||||
data_offset = (member_offset + AR_MEMHDR_SZ(member_header_big)
|
||||
+ name_len + 2);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
nread = read (desc, (char *) &member_header,
|
||||
AR_MEMHDR_SZ(member_header) );
|
||||
|
||||
if (nread != AR_MEMHDR_SZ(member_header))
|
||||
{
|
||||
(void) close (desc);
|
||||
return -2;
|
||||
}
|
||||
|
||||
sscanf (member_header.ar_namlen, "%4d", &name_len);
|
||||
nread = read (desc, name, name_len);
|
||||
|
||||
if (nread != name_len)
|
||||
{
|
||||
(void) close (desc);
|
||||
return -2;
|
||||
}
|
||||
|
||||
name[name_len] = 0;
|
||||
|
||||
sscanf (member_header.ar_date, "%12ld", &dateval);
|
||||
sscanf (member_header.ar_uid, "%12d", &uidval);
|
||||
sscanf (member_header.ar_gid, "%12d", &gidval);
|
||||
sscanf (member_header.ar_mode, "%12o", &eltmode);
|
||||
sscanf (member_header.ar_size, "%12ld", &eltsize);
|
||||
|
||||
data_offset = (member_offset + AR_MEMHDR_SZ(member_header)
|
||||
+ name_len + 2);
|
||||
}
|
||||
data_offset += data_offset % 2;
|
||||
|
||||
fnval =
|
||||
(*function) (desc, name, 0,
|
||||
member_offset, data_offset, eltsize,
|
||||
dateval, uidval, gidval,
|
||||
eltmode, arg);
|
||||
|
||||
#else /* Not AIAMAG. */
|
||||
nread = read (desc, (char *) &member_header, AR_HDR_SIZE);
|
||||
if (nread == 0)
|
||||
/* No data left means end of file; that is OK. */
|
||||
break;
|
||||
|
||||
if (nread != AR_HDR_SIZE
|
||||
#if defined(ARFMAG) || defined(ARFZMAG)
|
||||
|| (
|
||||
# ifdef ARFMAG
|
||||
bcmp (member_header.ar_fmag, ARFMAG, 2)
|
||||
# else
|
||||
1
|
||||
# endif
|
||||
&&
|
||||
# ifdef ARFZMAG
|
||||
bcmp (member_header.ar_fmag, ARFZMAG, 2)
|
||||
# else
|
||||
1
|
||||
# endif
|
||||
)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
(void) close (desc);
|
||||
return -2;
|
||||
}
|
||||
|
||||
name = namebuf;
|
||||
bcopy (member_header.ar_name, name, sizeof member_header.ar_name);
|
||||
{
|
||||
register char *p = name + sizeof member_header.ar_name;
|
||||
do
|
||||
*p = '\0';
|
||||
while (p > name && *--p == ' ');
|
||||
|
||||
#ifndef AIAMAG
|
||||
/* If the member name is "//" or "ARFILENAMES/" this may be
|
||||
a list of file name mappings. The maximum file name
|
||||
length supported by the standard archive format is 14
|
||||
characters. This member will actually always be the
|
||||
first or second entry in the archive, but we don't check
|
||||
that. */
|
||||
is_namemap = (!strcmp (name, "//")
|
||||
|| !strcmp (name, "ARFILENAMES/"));
|
||||
#endif /* Not AIAMAG. */
|
||||
/* On some systems, there is a slash after each member name. */
|
||||
if (*p == '/')
|
||||
*p = '\0';
|
||||
|
||||
#ifndef AIAMAG
|
||||
/* If the member name starts with a space or a slash, this
|
||||
is an index into the file name mappings (used by GNU ar).
|
||||
Otherwise if the member name looks like #1/NUMBER the
|
||||
real member name appears in the element data (used by
|
||||
4.4BSD). */
|
||||
if (! is_namemap
|
||||
&& (name[0] == ' ' || name[0] == '/')
|
||||
&& namemap != 0)
|
||||
{
|
||||
name = namemap + atoi (name + 1);
|
||||
long_name = 1;
|
||||
}
|
||||
else if (name[0] == '#'
|
||||
&& name[1] == '1'
|
||||
&& name[2] == '/')
|
||||
{
|
||||
int namesize = atoi (name + 3);
|
||||
|
||||
name = (char *) alloca (namesize + 1);
|
||||
nread = read (desc, name, namesize);
|
||||
if (nread != namesize)
|
||||
{
|
||||
close (desc);
|
||||
return -2;
|
||||
}
|
||||
name[namesize] = '\0';
|
||||
|
||||
long_name = 1;
|
||||
}
|
||||
#endif /* Not AIAMAG. */
|
||||
}
|
||||
|
||||
#ifndef M_XENIX
|
||||
sscanf (member_header.ar_mode, "%o", &eltmode);
|
||||
eltsize = atol (member_header.ar_size);
|
||||
#else /* Xenix. */
|
||||
eltmode = (unsigned short int) member_header.ar_mode;
|
||||
eltsize = member_header.ar_size;
|
||||
#endif /* Not Xenix. */
|
||||
|
||||
fnval =
|
||||
(*function) (desc, name, ! long_name, member_offset,
|
||||
member_offset + AR_HDR_SIZE, eltsize,
|
||||
#ifndef M_XENIX
|
||||
atol (member_header.ar_date),
|
||||
atoi (member_header.ar_uid),
|
||||
atoi (member_header.ar_gid),
|
||||
#else /* Xenix. */
|
||||
member_header.ar_date,
|
||||
member_header.ar_uid,
|
||||
member_header.ar_gid,
|
||||
#endif /* Not Xenix. */
|
||||
eltmode, arg);
|
||||
|
||||
#endif /* AIAMAG. */
|
||||
|
||||
if (fnval)
|
||||
{
|
||||
(void) close (desc);
|
||||
return fnval;
|
||||
}
|
||||
|
||||
#ifdef AIAMAG
|
||||
if (member_offset == last_member_offset)
|
||||
/* End of the chain. */
|
||||
break;
|
||||
|
||||
#ifdef AIAMAGBIG
|
||||
if (big_archive)
|
||||
sscanf (member_header_big.ar_nxtmem, "%20ld", &member_offset);
|
||||
else
|
||||
#endif
|
||||
sscanf (member_header.ar_nxtmem, "%12ld", &member_offset);
|
||||
|
||||
if (lseek (desc, member_offset, 0) != member_offset)
|
||||
{
|
||||
(void) close (desc);
|
||||
return -2;
|
||||
}
|
||||
#else
|
||||
|
||||
/* If this member maps archive names, we must read it in. The
|
||||
name map will always precede any members whose names must
|
||||
be mapped. */
|
||||
if (is_namemap)
|
||||
{
|
||||
char *clear;
|
||||
char *limit;
|
||||
|
||||
namemap = (char *) alloca (eltsize);
|
||||
nread = read (desc, namemap, eltsize);
|
||||
if (nread != eltsize)
|
||||
{
|
||||
(void) close (desc);
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* The names are separated by newlines. Some formats have
|
||||
a trailing slash. Null terminate the strings for
|
||||
convenience. */
|
||||
limit = namemap + eltsize;
|
||||
for (clear = namemap; clear < limit; clear++)
|
||||
{
|
||||
if (*clear == '\n')
|
||||
{
|
||||
*clear = '\0';
|
||||
if (clear[-1] == '/')
|
||||
clear[-1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
is_namemap = 0;
|
||||
}
|
||||
|
||||
member_offset += AR_HDR_SIZE + eltsize;
|
||||
if (member_offset % 2 != 0)
|
||||
member_offset++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
close (desc);
|
||||
return 0;
|
||||
}
|
||||
#endif /* !VMS */
|
||||
|
||||
/* Return nonzero iff NAME matches MEM.
|
||||
If TRUNCATED is nonzero, MEM may be truncated to
|
||||
sizeof (struct ar_hdr.ar_name) - 1. */
|
||||
|
||||
int
|
||||
ar_name_equal (name, mem, truncated)
|
||||
char *name, *mem;
|
||||
int truncated;
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = strrchr (name, '/');
|
||||
if (p != 0)
|
||||
name = p + 1;
|
||||
|
||||
#ifndef VMS
|
||||
if (truncated)
|
||||
{
|
||||
#ifdef AIAMAG
|
||||
/* TRUNCATED should never be set on this system. */
|
||||
abort ();
|
||||
#else
|
||||
struct ar_hdr hdr;
|
||||
#if !defined (__hpux) && !defined (cray)
|
||||
return strneq (name, mem, sizeof(hdr.ar_name) - 1);
|
||||
#else
|
||||
return strneq (name, mem, sizeof(hdr.ar_name) - 2);
|
||||
#endif /* !__hpux && !cray */
|
||||
#endif /* !AIAMAG */
|
||||
}
|
||||
#endif /* !VMS */
|
||||
|
||||
return !strcmp (name, mem);
|
||||
}
|
||||
|
||||
#ifndef VMS
|
||||
/* ARGSUSED */
|
||||
static long int
|
||||
ar_member_pos (desc, mem, truncated,
|
||||
hdrpos, datapos, size, date, uid, gid, mode, name)
|
||||
int desc;
|
||||
char *mem;
|
||||
int truncated;
|
||||
long int hdrpos, datapos, size, date;
|
||||
int uid, gid, mode;
|
||||
char *name;
|
||||
{
|
||||
if (!ar_name_equal (name, mem, truncated))
|
||||
return 0;
|
||||
return hdrpos;
|
||||
}
|
||||
|
||||
/* Set date of member MEMNAME in archive ARNAME to current time.
|
||||
Returns 0 if successful,
|
||||
-1 if file ARNAME does not exist,
|
||||
-2 if not a valid archive,
|
||||
-3 if other random system call error (including file read-only),
|
||||
1 if valid but member MEMNAME does not exist. */
|
||||
|
||||
int
|
||||
ar_member_touch (arname, memname)
|
||||
char *arname, *memname;
|
||||
{
|
||||
register long int pos = ar_scan (arname, ar_member_pos, (long int) memname);
|
||||
register int fd;
|
||||
struct ar_hdr ar_hdr;
|
||||
register int i;
|
||||
struct stat statbuf;
|
||||
|
||||
if (pos < 0)
|
||||
return (int) pos;
|
||||
if (!pos)
|
||||
return 1;
|
||||
|
||||
fd = open (arname, O_RDWR, 0666);
|
||||
if (fd < 0)
|
||||
return -3;
|
||||
/* Read in this member's header */
|
||||
if (lseek (fd, pos, 0) < 0)
|
||||
goto lose;
|
||||
if (AR_HDR_SIZE != read (fd, (char *) &ar_hdr, AR_HDR_SIZE))
|
||||
goto lose;
|
||||
/* Write back the header, thus touching the archive file. */
|
||||
if (lseek (fd, pos, 0) < 0)
|
||||
goto lose;
|
||||
if (AR_HDR_SIZE != write (fd, (char *) &ar_hdr, AR_HDR_SIZE))
|
||||
goto lose;
|
||||
/* The file's mtime is the time we we want. */
|
||||
if (fstat (fd, &statbuf) < 0)
|
||||
goto lose;
|
||||
#if defined(ARFMAG) || defined(ARFZMAG) || defined(AIAMAG) || defined(WINDOWS32)
|
||||
/* Advance member's time to that time */
|
||||
for (i = 0; i < sizeof ar_hdr.ar_date; i++)
|
||||
ar_hdr.ar_date[i] = ' ';
|
||||
sprintf (ar_hdr.ar_date, "%ld", (long int) statbuf.st_mtime);
|
||||
#ifdef AIAMAG
|
||||
ar_hdr.ar_date[strlen(ar_hdr.ar_date)] = ' ';
|
||||
#endif
|
||||
#else
|
||||
ar_hdr.ar_date = statbuf.st_mtime;
|
||||
#endif
|
||||
/* Write back this member's header */
|
||||
if (lseek (fd, pos, 0) < 0)
|
||||
goto lose;
|
||||
if (AR_HDR_SIZE != write (fd, (char *) &ar_hdr, AR_HDR_SIZE))
|
||||
goto lose;
|
||||
close (fd);
|
||||
return 0;
|
||||
|
||||
lose:
|
||||
i = errno;
|
||||
close (fd);
|
||||
errno = i;
|
||||
return -3;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
long int
|
||||
describe_member (desc, name, truncated,
|
||||
hdrpos, datapos, size, date, uid, gid, mode)
|
||||
int desc;
|
||||
char *name;
|
||||
int truncated;
|
||||
long int hdrpos, datapos, size, date;
|
||||
int uid, gid, mode;
|
||||
{
|
||||
extern char *ctime ();
|
||||
|
||||
printf (_("Member `%s'%s: %ld bytes at %ld (%ld).\n"),
|
||||
name, truncated ? _(" (name might be truncated)") : "",
|
||||
size, hdrpos, datapos);
|
||||
printf (_(" Date %s"), ctime (&date));
|
||||
printf (_(" uid = %d, gid = %d, mode = 0%o.\n"), uid, gid, mode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
ar_scan (argv[1], describe_member);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* TEST. */
|
||||
|
||||
#endif /* NO_ARCHIVES. */
|
||||
33
flaim/external/w32/make/build.bat
vendored
Normal file
33
flaim/external/w32/make/build.bat
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
@echo off
|
||||
|
||||
REM -------------------------------------------------------------------------
|
||||
REM Desc: Batch file for building GNU make on Windows platforms
|
||||
REM Tabs: 3
|
||||
REM
|
||||
REM Copyright (c) 2006 Novell, Inc. All Rights Reserved.
|
||||
REM
|
||||
REM This program is free software; you can redistribute it and/or
|
||||
REM modify it under the terms of version 2 of the GNU General Public
|
||||
REM License as published by the Free Software Foundation.
|
||||
REM
|
||||
REM This program is distributed in the hope that it will be useful,
|
||||
REM but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
REM GNU General Public License for more details.
|
||||
REM
|
||||
REM You should have received a copy of the GNU General Public License
|
||||
REM along with this program; if not, contact Novell, Inc.
|
||||
REM
|
||||
REM To contact Novell about this file by physical or electronic mail,
|
||||
REM you may find current contact information at www.novell.com
|
||||
REM
|
||||
REM $Id$
|
||||
REM -------------------------------------------------------------------------
|
||||
|
||||
setlocal
|
||||
if exist build-dir rd /s /q build-dir
|
||||
mkdir build-dir
|
||||
cd build-dir
|
||||
cl /nologo /W0 /MT -I. -DWINDOWS32 -DHAVE_STRING_H -DHAVE_DIRENT_H -DHAVE_FCNTL_H -I.. advapi32.lib user32.lib ../*.c /Femake.exe
|
||||
cd ..
|
||||
endlocal
|
||||
584
flaim/external/w32/make/commands.c
vendored
Normal file
584
flaim/external/w32/make/commands.c
vendored
Normal file
@@ -0,0 +1,584 @@
|
||||
/* Command processing for GNU Make.
|
||||
Copyright (C) 1988,89,91,92,93,94,95,96,97 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "make.h"
|
||||
#include "dep.h"
|
||||
#include "filedef.h"
|
||||
#include "variable.h"
|
||||
#include "job.h"
|
||||
#include "commands.h"
|
||||
|
||||
#if VMS
|
||||
# define FILE_LIST_SEPARATOR ','
|
||||
#else
|
||||
# define FILE_LIST_SEPARATOR ' '
|
||||
#endif
|
||||
|
||||
extern int remote_kill PARAMS ((int id, int sig));
|
||||
|
||||
#ifndef HAVE_UNISTD_H
|
||||
extern int getpid ();
|
||||
#endif
|
||||
|
||||
/* Set FILE's automatic variables up. */
|
||||
|
||||
static void
|
||||
set_file_variables (file)
|
||||
register struct file *file;
|
||||
{
|
||||
char *at, *percent, *star, *less;
|
||||
|
||||
#ifndef NO_ARCHIVES
|
||||
/* If the target is an archive member `lib(member)',
|
||||
then $@ is `lib' and $% is `member'. */
|
||||
|
||||
if (ar_name (file->name))
|
||||
{
|
||||
unsigned int len;
|
||||
char *p;
|
||||
|
||||
p = strchr (file->name, '(');
|
||||
at = (char *) alloca (p - file->name + 1);
|
||||
bcopy (file->name, at, p - file->name);
|
||||
at[p - file->name] = '\0';
|
||||
len = strlen (p + 1);
|
||||
percent = (char *) alloca (len);
|
||||
bcopy (p + 1, percent, len - 1);
|
||||
percent[len - 1] = '\0';
|
||||
}
|
||||
else
|
||||
#endif /* NO_ARCHIVES. */
|
||||
{
|
||||
at = file->name;
|
||||
percent = "";
|
||||
}
|
||||
|
||||
/* $* is the stem from an implicit or static pattern rule. */
|
||||
if (file->stem == 0)
|
||||
{
|
||||
/* In Unix make, $* is set to the target name with
|
||||
any suffix in the .SUFFIXES list stripped off for
|
||||
explicit rules. We store this in the `stem' member. */
|
||||
register struct dep *d;
|
||||
char *name;
|
||||
unsigned int len;
|
||||
|
||||
#ifndef NO_ARCHIVES
|
||||
if (ar_name (file->name))
|
||||
{
|
||||
name = strchr (file->name, '(') + 1;
|
||||
len = strlen (name) - 1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
name = file->name;
|
||||
len = strlen (name);
|
||||
}
|
||||
|
||||
for (d = enter_file (".SUFFIXES")->deps; d != 0; d = d->next)
|
||||
{
|
||||
unsigned int slen = strlen (dep_name (d));
|
||||
if (len > slen && strneq (dep_name (d), name + (len - slen), slen))
|
||||
{
|
||||
file->stem = savestring (name, len - slen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (d == 0)
|
||||
file->stem = "";
|
||||
}
|
||||
star = file->stem;
|
||||
|
||||
/* $< is the first dependency. */
|
||||
less = file->deps != 0 ? dep_name (file->deps) : "";
|
||||
|
||||
if (file->cmds == default_file->cmds)
|
||||
/* This file got its commands from .DEFAULT.
|
||||
In this case $< is the same as $@. */
|
||||
less = at;
|
||||
|
||||
#define DEFINE_VARIABLE(name, len, value) \
|
||||
(void) define_variable_for_file (name,len,value,o_automatic,0,file)
|
||||
|
||||
/* Define the variables. */
|
||||
|
||||
DEFINE_VARIABLE ("<", 1, less);
|
||||
DEFINE_VARIABLE ("*", 1, star);
|
||||
DEFINE_VARIABLE ("@", 1, at);
|
||||
DEFINE_VARIABLE ("%", 1, percent);
|
||||
|
||||
/* Compute the values for $^, $+, $?, and $|. */
|
||||
|
||||
{
|
||||
unsigned int qmark_len, plus_len, bar_len;
|
||||
char *caret_value, *plus_value;
|
||||
char *cp;
|
||||
char *qmark_value;
|
||||
char *bar_value;
|
||||
char *qp;
|
||||
char *bp;
|
||||
struct dep *d;
|
||||
unsigned int len;
|
||||
|
||||
/* Compute first the value for $+, which is supposed to contain
|
||||
duplicate dependencies as they were listed in the makefile. */
|
||||
|
||||
plus_len = 0;
|
||||
for (d = file->deps; d != 0; d = d->next)
|
||||
if (! d->ignore_mtime)
|
||||
plus_len += strlen (dep_name (d)) + 1;
|
||||
if (plus_len == 0)
|
||||
plus_len++;
|
||||
|
||||
cp = plus_value = (char *) alloca (plus_len);
|
||||
|
||||
qmark_len = plus_len + 1; /* Will be this or less. */
|
||||
for (d = file->deps; d != 0; d = d->next)
|
||||
if (! d->ignore_mtime)
|
||||
{
|
||||
char *c = dep_name (d);
|
||||
|
||||
#ifndef NO_ARCHIVES
|
||||
if (ar_name (c))
|
||||
{
|
||||
c = strchr (c, '(') + 1;
|
||||
len = strlen (c) - 1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
len = strlen (c);
|
||||
|
||||
bcopy (c, cp, len);
|
||||
cp += len;
|
||||
*cp++ = FILE_LIST_SEPARATOR;
|
||||
if (! d->changed)
|
||||
qmark_len -= len + 1; /* Don't space in $? for this one. */
|
||||
}
|
||||
|
||||
/* Kill the last space and define the variable. */
|
||||
|
||||
cp[cp > plus_value ? -1 : 0] = '\0';
|
||||
DEFINE_VARIABLE ("+", 1, plus_value);
|
||||
|
||||
/* Make sure that no dependencies are repeated. This does not
|
||||
really matter for the purpose of updating targets, but it
|
||||
might make some names be listed twice for $^ and $?. */
|
||||
|
||||
uniquize_deps (file->deps);
|
||||
|
||||
bar_len = 0;
|
||||
for (d = file->deps; d != 0; d = d->next)
|
||||
if (d->ignore_mtime)
|
||||
bar_len += strlen (dep_name (d)) + 1;
|
||||
if (bar_len == 0)
|
||||
bar_len++;
|
||||
|
||||
/* Compute the values for $^, $?, and $|. */
|
||||
|
||||
cp = caret_value = plus_value; /* Reuse the buffer; it's big enough. */
|
||||
qp = qmark_value = (char *) alloca (qmark_len);
|
||||
bp = bar_value = (char *) alloca (bar_len);
|
||||
|
||||
for (d = file->deps; d != 0; d = d->next)
|
||||
{
|
||||
char *c = dep_name (d);
|
||||
|
||||
#ifndef NO_ARCHIVES
|
||||
if (ar_name (c))
|
||||
{
|
||||
c = strchr (c, '(') + 1;
|
||||
len = strlen (c) - 1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
len = strlen (c);
|
||||
|
||||
if (d->ignore_mtime)
|
||||
{
|
||||
bcopy (c, bp, len);
|
||||
bp += len;
|
||||
*bp++ = FILE_LIST_SEPARATOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
bcopy (c, cp, len);
|
||||
cp += len;
|
||||
*cp++ = FILE_LIST_SEPARATOR;
|
||||
if (d->changed)
|
||||
{
|
||||
bcopy (c, qp, len);
|
||||
qp += len;
|
||||
*qp++ = FILE_LIST_SEPARATOR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Kill the last spaces and define the variables. */
|
||||
|
||||
cp[cp > caret_value ? -1 : 0] = '\0';
|
||||
DEFINE_VARIABLE ("^", 1, caret_value);
|
||||
|
||||
qp[qp > qmark_value ? -1 : 0] = '\0';
|
||||
DEFINE_VARIABLE ("?", 1, qmark_value);
|
||||
|
||||
bp[bp > bar_value ? -1 : 0] = '\0';
|
||||
DEFINE_VARIABLE ("|", 1, bar_value);
|
||||
}
|
||||
|
||||
#undef DEFINE_VARIABLE
|
||||
}
|
||||
|
||||
/* Chop CMDS up into individual command lines if necessary.
|
||||
Also set the `lines_flags' and `any_recurse' members. */
|
||||
|
||||
void
|
||||
chop_commands (cmds)
|
||||
register struct commands *cmds;
|
||||
{
|
||||
register char *p;
|
||||
unsigned int nlines, idx;
|
||||
char **lines;
|
||||
|
||||
/* If we don't have any commands,
|
||||
or we already parsed them, never mind. */
|
||||
|
||||
if (!cmds || cmds->command_lines != 0)
|
||||
return;
|
||||
|
||||
/* Chop CMDS->commands up into lines in CMDS->command_lines.
|
||||
Also set the corresponding CMDS->lines_flags elements,
|
||||
and the CMDS->any_recurse flag. */
|
||||
|
||||
nlines = 5;
|
||||
lines = (char **) xmalloc (5 * sizeof (char *));
|
||||
idx = 0;
|
||||
p = cmds->commands;
|
||||
while (*p != '\0')
|
||||
{
|
||||
char *end = p;
|
||||
find_end:;
|
||||
end = strchr (end, '\n');
|
||||
if (end == 0)
|
||||
end = p + strlen (p);
|
||||
else if (end > p && end[-1] == '\\')
|
||||
{
|
||||
int backslash = 1;
|
||||
register char *b;
|
||||
for (b = end - 2; b >= p && *b == '\\'; --b)
|
||||
backslash = !backslash;
|
||||
if (backslash)
|
||||
{
|
||||
++end;
|
||||
goto find_end;
|
||||
}
|
||||
}
|
||||
|
||||
if (idx == nlines)
|
||||
{
|
||||
nlines += 2;
|
||||
lines = (char **) xrealloc ((char *) lines,
|
||||
nlines * sizeof (char *));
|
||||
}
|
||||
lines[idx++] = savestring (p, end - p);
|
||||
p = end;
|
||||
if (*p != '\0')
|
||||
++p;
|
||||
}
|
||||
|
||||
if (idx != nlines)
|
||||
{
|
||||
nlines = idx;
|
||||
lines = (char **) xrealloc ((char *) lines,
|
||||
nlines * sizeof (char *));
|
||||
}
|
||||
|
||||
cmds->ncommand_lines = nlines;
|
||||
cmds->command_lines = lines;
|
||||
|
||||
cmds->any_recurse = 0;
|
||||
cmds->lines_flags = (char *) xmalloc (nlines);
|
||||
for (idx = 0; idx < nlines; ++idx)
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
for (p = lines[idx];
|
||||
isblank ((unsigned char)*p) || *p == '-' || *p == '@' || *p == '+';
|
||||
++p)
|
||||
switch (*p)
|
||||
{
|
||||
case '+':
|
||||
flags |= COMMANDS_RECURSE;
|
||||
break;
|
||||
case '@':
|
||||
flags |= COMMANDS_SILENT;
|
||||
break;
|
||||
case '-':
|
||||
flags |= COMMANDS_NOERROR;
|
||||
break;
|
||||
}
|
||||
if (!(flags & COMMANDS_RECURSE))
|
||||
{
|
||||
unsigned int len = strlen (p);
|
||||
if (sindex (p, len, "$(MAKE)", 7) != 0
|
||||
|| sindex (p, len, "${MAKE}", 7) != 0)
|
||||
flags |= COMMANDS_RECURSE;
|
||||
}
|
||||
|
||||
cmds->lines_flags[idx] = flags;
|
||||
cmds->any_recurse |= flags & COMMANDS_RECURSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Execute the commands to remake FILE. If they are currently executing,
|
||||
return or have already finished executing, just return. Otherwise,
|
||||
fork off a child process to run the first command line in the sequence. */
|
||||
|
||||
void
|
||||
execute_file_commands (file)
|
||||
struct file *file;
|
||||
{
|
||||
register char *p;
|
||||
|
||||
/* Don't go through all the preparations if
|
||||
the commands are nothing but whitespace. */
|
||||
|
||||
for (p = file->cmds->commands; *p != '\0'; ++p)
|
||||
if (!isspace ((unsigned char)*p) && *p != '-' && *p != '@')
|
||||
break;
|
||||
if (*p == '\0')
|
||||
{
|
||||
/* If there are no commands, assume everything worked. */
|
||||
set_command_state (file, cs_running);
|
||||
file->update_status = 0;
|
||||
notice_finished_file (file);
|
||||
return;
|
||||
}
|
||||
|
||||
/* First set the automatic variables according to this file. */
|
||||
|
||||
initialize_file_variables (file, 0);
|
||||
|
||||
set_file_variables (file);
|
||||
|
||||
/* Start the commands running. */
|
||||
new_job (file);
|
||||
}
|
||||
|
||||
/* This is set while we are inside fatal_error_signal,
|
||||
so things can avoid nonreentrant operations. */
|
||||
|
||||
int handling_fatal_signal = 0;
|
||||
|
||||
/* Handle fatal signals. */
|
||||
|
||||
RETSIGTYPE
|
||||
fatal_error_signal (sig)
|
||||
int sig;
|
||||
{
|
||||
#ifdef __MSDOS__
|
||||
extern int dos_status, dos_command_running;
|
||||
|
||||
if (dos_command_running)
|
||||
{
|
||||
/* That was the child who got the signal, not us. */
|
||||
dos_status |= (sig << 8);
|
||||
return;
|
||||
}
|
||||
remove_intermediates (1);
|
||||
exit (EXIT_FAILURE);
|
||||
#else /* not __MSDOS__ */
|
||||
#ifdef _AMIGA
|
||||
remove_intermediates (1);
|
||||
if (sig == SIGINT)
|
||||
fputs (_("*** Break.\n"), stderr);
|
||||
|
||||
exit (10);
|
||||
#else /* not Amiga */
|
||||
handling_fatal_signal = 1;
|
||||
|
||||
/* Set the handling for this signal to the default.
|
||||
It is blocked now while we run this handler. */
|
||||
signal (sig, SIG_DFL);
|
||||
|
||||
/* A termination signal won't be sent to the entire
|
||||
process group, but it means we want to kill the children. */
|
||||
|
||||
if (sig == SIGTERM)
|
||||
{
|
||||
register struct child *c;
|
||||
for (c = children; c != 0; c = c->next)
|
||||
if (!c->remote)
|
||||
(void) kill (c->pid, SIGTERM);
|
||||
}
|
||||
|
||||
/* If we got a signal that means the user
|
||||
wanted to kill make, remove pending targets. */
|
||||
|
||||
if (sig == SIGTERM || sig == SIGINT
|
||||
#ifdef SIGHUP
|
||||
|| sig == SIGHUP
|
||||
#endif
|
||||
#ifdef SIGQUIT
|
||||
|| sig == SIGQUIT
|
||||
#endif
|
||||
)
|
||||
{
|
||||
register struct child *c;
|
||||
|
||||
/* Remote children won't automatically get signals sent
|
||||
to the process group, so we must send them. */
|
||||
for (c = children; c != 0; c = c->next)
|
||||
if (c->remote)
|
||||
(void) remote_kill (c->pid, sig);
|
||||
|
||||
for (c = children; c != 0; c = c->next)
|
||||
delete_child_targets (c);
|
||||
|
||||
/* Clean up the children. We don't just use the call below because
|
||||
we don't want to print the "Waiting for children" message. */
|
||||
while (job_slots_used > 0)
|
||||
reap_children (1, 0);
|
||||
}
|
||||
else
|
||||
/* Wait for our children to die. */
|
||||
while (job_slots_used > 0)
|
||||
reap_children (1, 1);
|
||||
|
||||
/* Delete any non-precious intermediate files that were made. */
|
||||
|
||||
remove_intermediates (1);
|
||||
|
||||
#ifdef SIGQUIT
|
||||
if (sig == SIGQUIT)
|
||||
/* We don't want to send ourselves SIGQUIT, because it will
|
||||
cause a core dump. Just exit instead. */
|
||||
exit (EXIT_FAILURE);
|
||||
#endif
|
||||
|
||||
/* Signal the same code; this time it will really be fatal. The signal
|
||||
will be unblocked when we return and arrive then to kill us. */
|
||||
if (kill (getpid (), sig) < 0)
|
||||
pfatal_with_name ("kill");
|
||||
#endif /* not Amiga */
|
||||
#endif /* not __MSDOS__ */
|
||||
}
|
||||
|
||||
/* Delete FILE unless it's precious or not actually a file (phony),
|
||||
and it has changed on disk since we last stat'd it. */
|
||||
|
||||
static void
|
||||
delete_target (file, on_behalf_of)
|
||||
struct file *file;
|
||||
char *on_behalf_of;
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (file->precious || file->phony)
|
||||
return;
|
||||
|
||||
#ifndef NO_ARCHIVES
|
||||
if (ar_name (file->name))
|
||||
{
|
||||
time_t file_date = (file->last_mtime == NONEXISTENT_MTIME
|
||||
? (time_t) -1
|
||||
: (time_t) FILE_TIMESTAMP_S (file->last_mtime));
|
||||
if (ar_member_date (file->name) != file_date)
|
||||
{
|
||||
if (on_behalf_of)
|
||||
error (NILF, _("*** [%s] Archive member `%s' may be bogus; not deleted"),
|
||||
on_behalf_of, file->name);
|
||||
else
|
||||
error (NILF, _("*** Archive member `%s' may be bogus; not deleted"),
|
||||
file->name);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (stat (file->name, &st) == 0
|
||||
&& S_ISREG (st.st_mode)
|
||||
&& FILE_TIMESTAMP_STAT_MODTIME (file->name, st) != file->last_mtime)
|
||||
{
|
||||
if (on_behalf_of)
|
||||
error (NILF, _("*** [%s] Deleting file `%s'"), on_behalf_of, file->name);
|
||||
else
|
||||
error (NILF, _("*** Deleting file `%s'"), file->name);
|
||||
if (unlink (file->name) < 0
|
||||
&& errno != ENOENT) /* It disappeared; so what. */
|
||||
perror_with_name ("unlink: ", file->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Delete all non-precious targets of CHILD unless they were already deleted.
|
||||
Set the flag in CHILD to say they've been deleted. */
|
||||
|
||||
void
|
||||
delete_child_targets (child)
|
||||
struct child *child;
|
||||
{
|
||||
struct dep *d;
|
||||
|
||||
if (child->deleted)
|
||||
return;
|
||||
|
||||
/* Delete the target file if it changed. */
|
||||
delete_target (child->file, (char *) 0);
|
||||
|
||||
/* Also remove any non-precious targets listed in the `also_make' member. */
|
||||
for (d = child->file->also_make; d != 0; d = d->next)
|
||||
delete_target (d->file, child->file->name);
|
||||
|
||||
child->deleted = 1;
|
||||
}
|
||||
|
||||
/* Print out the commands in CMDS. */
|
||||
|
||||
void
|
||||
print_commands (cmds)
|
||||
register struct commands *cmds;
|
||||
{
|
||||
register char *s;
|
||||
|
||||
fputs (_("# commands to execute"), stdout);
|
||||
|
||||
if (cmds->fileinfo.filenm == 0)
|
||||
puts (_(" (built-in):"));
|
||||
else
|
||||
printf (_(" (from `%s', line %lu):\n"),
|
||||
cmds->fileinfo.filenm, cmds->fileinfo.lineno);
|
||||
|
||||
s = cmds->commands;
|
||||
while (*s != '\0')
|
||||
{
|
||||
char *end;
|
||||
|
||||
while (isspace ((unsigned char)*s))
|
||||
++s;
|
||||
|
||||
end = strchr (s, '\n');
|
||||
if (end == 0)
|
||||
end = s + strlen (s);
|
||||
|
||||
printf ("\t%.*s\n", (int) (end - s), s);
|
||||
|
||||
s = end;
|
||||
}
|
||||
}
|
||||
42
flaim/external/w32/make/commands.h
vendored
Normal file
42
flaim/external/w32/make/commands.h
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/* Definition of data structures describing shell commands for GNU Make.
|
||||
Copyright (C) 1988, 1989, 1991, 1993 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Structure that gives the commands to make a file
|
||||
and information about where these commands came from. */
|
||||
|
||||
struct commands
|
||||
{
|
||||
struct floc fileinfo; /* Where commands were defined. */
|
||||
char *commands; /* Commands text. */
|
||||
unsigned int ncommand_lines;/* Number of command lines. */
|
||||
char **command_lines; /* Commands chopped up into lines. */
|
||||
char *lines_flags; /* One set of flag bits for each line. */
|
||||
int any_recurse; /* Nonzero if any `lines_recurse' elt has */
|
||||
/* the COMMANDS_RECURSE bit set. */
|
||||
};
|
||||
|
||||
/* Bits in `lines_flags'. */
|
||||
#define COMMANDS_RECURSE 1 /* Recurses: + or $(MAKE). */
|
||||
#define COMMANDS_SILENT 2 /* Silent: @. */
|
||||
#define COMMANDS_NOERROR 4 /* No errors: -. */
|
||||
|
||||
extern void execute_file_commands PARAMS ((struct file *file));
|
||||
extern void print_commands PARAMS ((struct commands *cmds));
|
||||
extern void delete_child_targets PARAMS ((struct child *child));
|
||||
extern void chop_commands PARAMS ((struct commands *cmds));
|
||||
399
flaim/external/w32/make/config.h
vendored
Normal file
399
flaim/external/w32/make/config.h
vendored
Normal file
@@ -0,0 +1,399 @@
|
||||
/* config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
|
||||
/* Define if on AIX 3.
|
||||
System headers sometimes define this.
|
||||
We just want to avoid a redefinition error message. */
|
||||
#ifndef _ALL_SOURCE
|
||||
/* #undef _ALL_SOURCE */
|
||||
#endif
|
||||
|
||||
/* Define if using alloca.c. */
|
||||
/* #undef C_ALLOCA */
|
||||
|
||||
/* Define if the closedir function returns void instead of int. */
|
||||
/* #undef CLOSEDIR_VOID */
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
|
||||
This function is required for alloca.c support on those systems. */
|
||||
/* #undef CRAY_STACKSEG_END */
|
||||
|
||||
/* Define for DGUX with <sys/dg_sys_info.h>. */
|
||||
/* #undef DGUX */
|
||||
|
||||
/* Define if the `getloadavg' function needs to be run setuid or setgid. */
|
||||
/* #undef GETLOADAVG_PRIVILEGED */
|
||||
|
||||
/* Define to `unsigned long' or `unsigned long long'
|
||||
if <inttypes.h> doesn't define. */
|
||||
#define uintmax_t unsigned long
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef gid_t
|
||||
#define gid_t int
|
||||
|
||||
/* Define if you have alloca, as a function or macro. */
|
||||
#undef HAVE_ALLOCA
|
||||
#define HAVE_ALLOCA 1
|
||||
|
||||
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
|
||||
/* #undef HAVE_ALLOCA_H */
|
||||
|
||||
/* Define if you don't have vprintf but do have _doprnt. */
|
||||
/* #undef HAVE_DOPRNT */
|
||||
|
||||
/* Define if your system has a working fnmatch function. */
|
||||
/* #undef HAVE_FNMATCH */
|
||||
|
||||
/* Define if your system has its own `getloadavg' function. */
|
||||
/* #undef HAVE_GETLOADAVG */
|
||||
|
||||
/* Define if you have the getmntent function. */
|
||||
/* #undef HAVE_GETMNTENT */
|
||||
|
||||
/* Define if the `long double' type works. */
|
||||
/* #undef HAVE_LONG_DOUBLE */
|
||||
|
||||
/* Define if you support file names longer than 14 characters. */
|
||||
#undef HAVE_LONG_FILE_NAMES
|
||||
#define HAVE_LONG_FILE_NAMES 1
|
||||
|
||||
/* Define if you have a working `mmap' system call. */
|
||||
/* #undef HAVE_MMAP */
|
||||
|
||||
/* Define if system calls automatically restart after interruption
|
||||
by a signal. */
|
||||
/* #undef HAVE_RESTARTABLE_SYSCALLS */
|
||||
|
||||
/* Define if your struct stat has st_blksize. */
|
||||
/* #undef HAVE_ST_BLKSIZE */
|
||||
|
||||
/* Define if your struct stat has st_blocks. */
|
||||
/* #undef HAVE_ST_BLOCKS */
|
||||
|
||||
/* Define if you have the strcoll function and it is properly defined. */
|
||||
#undef HAVE_STRCOLL
|
||||
#define HAVE_STRCOLL 1
|
||||
|
||||
/* Define if your struct stat has st_rdev. */
|
||||
#undef HAVE_ST_RDEV
|
||||
#define HAVE_ST_RDEV 1
|
||||
|
||||
/* Define if you have the strftime function. */
|
||||
#undef HAVE_STRFTIME
|
||||
#define HAVE_STRFTIME 1
|
||||
|
||||
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
/* #undef HAVE_SYS_WAIT_H */
|
||||
|
||||
/* Define if your struct tm has tm_zone. */
|
||||
/* #undef HAVE_TM_ZONE */
|
||||
|
||||
/* Define if you don't have tm_zone but do have the external array
|
||||
tzname. */
|
||||
#undef HAVE_TZNAME
|
||||
#define HAVE_TZNAME 1
|
||||
|
||||
/* Define if you have <unistd.h>. */
|
||||
/* #undef HAVE_UNISTD_H */
|
||||
|
||||
/* Define if utime(file, NULL) sets file's timestamp to the present. */
|
||||
#undef HAVE_UTIME_NULL
|
||||
#define HAVE_UTIME_NULL 1
|
||||
|
||||
/* Define if you have <vfork.h>. */
|
||||
/* #undef HAVE_VFORK_H */
|
||||
|
||||
/* Define if you have the vprintf function. */
|
||||
#undef HAVE_VPRINTF
|
||||
#define HAVE_VPRINTF 1
|
||||
|
||||
/* Define if you have the wait3 system call. */
|
||||
/* #undef HAVE_WAIT3 */
|
||||
|
||||
/* Define if on MINIX. */
|
||||
/* #undef _MINIX */
|
||||
|
||||
/* Define if your struct nlist has an n_un member. */
|
||||
/* #undef NLIST_NAME_UNION */
|
||||
|
||||
/* Define if you have <nlist.h>. */
|
||||
/* #undef NLIST_STRUCT */
|
||||
|
||||
/* Define if your C compiler doesn't accept -c and -o together. */
|
||||
/* #undef NO_MINUS_C_MINUS_O */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef pid_t
|
||||
#define pid_t int
|
||||
|
||||
/* Define if the system does not provide POSIX.1 features except
|
||||
with this defined. */
|
||||
/* #undef _POSIX_1_SOURCE */
|
||||
|
||||
/* Define if you need to in order for stat and other things to work. */
|
||||
#undef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE 1
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define if the setvbuf function takes the buffering type as its second
|
||||
argument and the buffer pointer as the third, as on System V
|
||||
before release 3. */
|
||||
/* #undef SETVBUF_REVERSED */
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at run-time.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown
|
||||
*/
|
||||
/* #undef STACK_DIRECTION */
|
||||
|
||||
/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
|
||||
/* #undef STAT_MACROS_BROKEN */
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define on System V Release 4. */
|
||||
/* #undef SVR4 */
|
||||
|
||||
/* Define if `sys_siglist' is declared by <signal.h>. */
|
||||
/* #undef SYS_SIGLIST_DECLARED */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef uid_t
|
||||
#define uid_t int
|
||||
|
||||
/* Define for Encore UMAX. */
|
||||
/* #undef UMAX */
|
||||
|
||||
/* Define for Encore UMAX 4.3 that has <inq_status/cpustats.h>
|
||||
instead of <sys/cpustats.h>. */
|
||||
/* #undef UMAX4_3 */
|
||||
|
||||
/* Define vfork as fork if vfork does not work. */
|
||||
/* #undef vfork */
|
||||
|
||||
/* Name of this package (needed by automake) */
|
||||
#define PACKAGE "make"
|
||||
|
||||
/* Version of this package (needed by automake) */
|
||||
#define VERSION "3.80"
|
||||
|
||||
/* Define to the name of the SCCS `get' command. */
|
||||
#undef SCCS_GET
|
||||
#define SCCS_GET "echo no sccs get"
|
||||
|
||||
/* Define to 1 if NLS is requested. */
|
||||
/* #undef ENABLE_NLS */
|
||||
|
||||
/* Define as 1 if you have dcgettext. */
|
||||
/* #undef HAVE_DCGETTEXT */
|
||||
|
||||
/* Define as 1 if you have gettext and don't want to use GNU gettext. */
|
||||
/* #undef HAVE_GETTEXT */
|
||||
|
||||
/* Define if your locale.h file contains LC_MESSAGES. */
|
||||
/* #undef HAVE_LC_MESSAGES */
|
||||
|
||||
/* Define to the installation directory for locales. */
|
||||
#define LOCALEDIR ""
|
||||
|
||||
/* Define this if the SCCS `get' command understands the `-G<file>' option. */
|
||||
/* #undef SCCS_GET_MINUS_G */
|
||||
|
||||
/* Define this to enable job server support in GNU make. */
|
||||
/* #undef MAKE_JOBSERVER */
|
||||
|
||||
/* Define to be the nanoseconds member of struct stat's st_mtim,
|
||||
if it exists. */
|
||||
/* #undef ST_MTIM_NSEC */
|
||||
|
||||
/* Define this if the C library defines the variable `sys_siglist'. */
|
||||
/* #undef HAVE_SYS_SIGLIST */
|
||||
|
||||
/* Define this if the C library defines the variable `_sys_siglist'. */
|
||||
/* #undef HAVE__SYS_SIGLIST */
|
||||
|
||||
/* Define this if you have the `union wait' type in <sys/wait.h>. */
|
||||
/* #undef HAVE_UNION_WAIT */
|
||||
|
||||
/* Define if you have the dup2 function. */
|
||||
#undef HAVE_DUP2
|
||||
#define HAVE_DUP2 1
|
||||
|
||||
/* Define if you have the getcwd function. */
|
||||
#undef HAVE_GETCWD
|
||||
#define HAVE_GETCWD 1
|
||||
|
||||
/* Define if you have the getgroups function. */
|
||||
/* #undef HAVE_GETGROUPS */
|
||||
|
||||
/* Define if you have the gethostbyname function. */
|
||||
/* #undef HAVE_GETHOSTBYNAME */
|
||||
|
||||
/* Define if you have the gethostname function. */
|
||||
/* #undef HAVE_GETHOSTNAME */
|
||||
|
||||
/* Define if you have the getloadavg function. */
|
||||
/* #undef HAVE_GETLOADAVG */
|
||||
|
||||
/* Define if you have the memmove function. */
|
||||
#undef HAVE_MEMMOVE
|
||||
#define HAVE_MEMMOVE 1
|
||||
|
||||
/* Define if you have the mktemp function. */
|
||||
#undef HAVE_MKTEMP
|
||||
#define HAVE_MKTEMP 1
|
||||
|
||||
/* Define if you have the psignal function. */
|
||||
/* #undef HAVE_PSIGNAL */
|
||||
|
||||
/* Define if you have the pstat_getdynamic function. */
|
||||
/* #undef HAVE_PSTAT_GETDYNAMIC */
|
||||
|
||||
/* Define if you have the setegid function. */
|
||||
/* #undef HAVE_SETEGID */
|
||||
|
||||
/* Define if you have the seteuid function. */
|
||||
/* #undef HAVE_SETEUID */
|
||||
|
||||
/* Define if you have the setlinebuf function. */
|
||||
/* #undef HAVE_SETLINEBUF */
|
||||
|
||||
/* Define if you have the setregid function. */
|
||||
/* #undef HAVE_SETREGID */
|
||||
|
||||
/* Define if you have the setreuid function. */
|
||||
/* #undef HAVE_SETREUID */
|
||||
|
||||
/* Define if you have the sigsetmask function. */
|
||||
/* #undef HAVE_SIGSETMASK */
|
||||
|
||||
/* Define if you have the socket function. */
|
||||
/* #undef HAVE_SOCKET */
|
||||
|
||||
/* Define if you have the strcasecmp function. */
|
||||
/* #undef HAVE_STRCASECMP */
|
||||
|
||||
/* Define if you have the strerror function. */
|
||||
#undef HAVE_STRERROR
|
||||
#define HAVE_STRERROR 1
|
||||
|
||||
/* Define if you have the strsignal function. */
|
||||
/* #undef HAVE_STRSIGNAL */
|
||||
|
||||
/* Define if you have the wait3 function. */
|
||||
/* #undef HAVE_WAIT3 */
|
||||
|
||||
/* Define if you have the waitpid function. */
|
||||
/* #undef HAVE_WAITPID */
|
||||
|
||||
/* Define if you have the <dirent.h> header file. */
|
||||
#undef HAVE_DIRENT_H
|
||||
#define HAVE_DIRENT_H 1
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define if you have the <mach/mach.h> header file. */
|
||||
/* #undef HAVE_MACH_MACH_H */
|
||||
|
||||
/* Define if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define if you have the <ndir.h> header file. */
|
||||
/* #undef HAVE_NDIR_H */
|
||||
|
||||
/* Define if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define if you have the <sys/dir.h> header file. */
|
||||
/* #undef HAVE_SYS_DIR_H */
|
||||
|
||||
/* Define if you have the <sys/ndir.h> header file. */
|
||||
/* #undef HAVE_SYS_NDIR_H */
|
||||
|
||||
/* Define if you have the <sys/param.h> header file. */
|
||||
/* #undef HAVE_SYS_PARAM_H */
|
||||
|
||||
/* Define if you have the <sys/timeb.h> header file. */
|
||||
#undef HAVE_SYS_TIMEB_H
|
||||
#define HAVE_SYS_TIMEB_H 1
|
||||
|
||||
/* Define if you have the <sys/wait.h> header file. */
|
||||
/* #undef HAVE_SYS_WAIT_H */
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
/* #undef HAVE_UNISTD_H */
|
||||
|
||||
/* Define if you have the dgc library (-ldgc). */
|
||||
/* #undef HAVE_LIBDGC */
|
||||
|
||||
/* Define if you have the kstat library (-lkstat). */
|
||||
/* #undef HAVE_LIBKSTAT */
|
||||
|
||||
/* Define if you have the sun library (-lsun). */
|
||||
/* #undef HAVE_LIBSUN */
|
||||
|
||||
/* Use high resolution file timestamps if nonzero. */
|
||||
#define FILE_TIMESTAMP_HI_RES 0
|
||||
|
||||
/* Build host information. */
|
||||
#define MAKE_HOST "Windows32"
|
||||
|
||||
/* Grok DOS paths (drive specs and backslash path element separators) */
|
||||
#define HAVE_DOS_PATHS
|
||||
|
||||
/*
|
||||
* Refer to README.W32 for info on the following settings
|
||||
*/
|
||||
|
||||
/*
|
||||
* If you have a shell that does not grok 'sh -c quoted-command-line'
|
||||
* correctly, you need this setting. Please see below for specific
|
||||
* shell support.
|
||||
*/
|
||||
#undef BATCH_MODE_ONLY_SHELL
|
||||
#define BATCH_MODE_ONLY_SHELL 1
|
||||
|
||||
/*
|
||||
* Define if you have the Cygnus "Cygwin" GNU Windows32 tool set.
|
||||
* Do NOT define BATCH_MODE_ONLY_SHELL if you define HAVE_CYGWIN_SHELL
|
||||
*/
|
||||
#undef HAVE_CYGWIN_SHELL
|
||||
|
||||
/*
|
||||
* Define if you have the MKS tool set or shell. Do NOT define
|
||||
* BATCH_MODE_ONLY_SHELL if you define HAVE_MKS_SHELL
|
||||
*/
|
||||
#undef HAVE_MKS_SHELL
|
||||
|
||||
/*
|
||||
* Enforce the mutual exclusivity restriction.
|
||||
*/
|
||||
#ifdef HAVE_MKS_SHELL
|
||||
#undef BATCH_MODE_ONLY_SHELL
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CYGWIN_SHELL
|
||||
#undef BATCH_MODE_ONLY_SHELL
|
||||
#endif
|
||||
|
||||
/* Define if you prefer Case Insensitive behavior */
|
||||
#undef HAVE_CASE_INSENSITIVE_FS
|
||||
41
flaim/external/w32/make/debug.h
vendored
Normal file
41
flaim/external/w32/make/debug.h
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/* Debugging macros and interface.
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
#define DB_NONE (0x000)
|
||||
#define DB_BASIC (0x001)
|
||||
#define DB_VERBOSE (0x002)
|
||||
#define DB_JOBS (0x004)
|
||||
#define DB_IMPLICIT (0x008)
|
||||
#define DB_MAKEFILES (0x100)
|
||||
|
||||
#define DB_ALL (0xfff)
|
||||
|
||||
extern int db_level;
|
||||
|
||||
#define ISDB(_l) ((_l)&db_level)
|
||||
|
||||
#define DBS(_l,_x) do{ if(ISDB(_l)) {print_spaces (depth); \
|
||||
printf _x; fflush (stdout);} }while(0)
|
||||
|
||||
#define DBF(_l,_x) do{ if(ISDB(_l)) {print_spaces (depth); \
|
||||
printf (_x, file->name); \
|
||||
fflush (stdout);} }while(0)
|
||||
|
||||
#define DB(_l,_x) do{ if(ISDB(_l)) {printf _x; fflush (stdout);} }while(0)
|
||||
585
flaim/external/w32/make/default.c
vendored
Normal file
585
flaim/external/w32/make/default.c
vendored
Normal file
@@ -0,0 +1,585 @@
|
||||
/* Data base of default implicit rules for GNU Make.
|
||||
Copyright (C) 1988,89,90,91,92,93,94,95,96 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "make.h"
|
||||
#include "rule.h"
|
||||
#include "dep.h"
|
||||
#include "filedef.h"
|
||||
#include "job.h"
|
||||
#include "commands.h"
|
||||
#include "variable.h"
|
||||
|
||||
/* Define GCC_IS_NATIVE if gcc is the native development environment on
|
||||
your system (gcc/bison/flex vs cc/yacc/lex). */
|
||||
#ifdef __MSDOS__
|
||||
#define GCC_IS_NATIVE
|
||||
#endif
|
||||
|
||||
|
||||
/* This is the default list of suffixes for suffix rules.
|
||||
`.s' must come last, so that a `.o' file will be made from
|
||||
a `.c' or `.p' or ... file rather than from a .s file. */
|
||||
|
||||
static char default_suffixes[]
|
||||
#ifdef VMS
|
||||
= ".exe .olb .ln .obj .c .cxx .cc .pas .p .for .f .r .y .l .mar \
|
||||
.s .ss .i .ii .mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \
|
||||
.w .ch .cweb .web .com .sh .elc .el";
|
||||
#else
|
||||
= ".out .a .ln .o .c .cc .C .cpp .p .f .F .r .y .l .s .S \
|
||||
.mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \
|
||||
.w .ch .web .sh .elc .el";
|
||||
#endif
|
||||
|
||||
static struct pspec default_pattern_rules[] =
|
||||
{
|
||||
{ "(%)", "%",
|
||||
"$(AR) $(ARFLAGS) $@ $<" },
|
||||
|
||||
/* The X.out rules are only in BSD's default set because
|
||||
BSD Make has no null-suffix rules, so `foo.out' and
|
||||
`foo' are the same thing. */
|
||||
#ifdef VMS
|
||||
{ "%.exe", "%",
|
||||
"copy $< $@" },
|
||||
#else
|
||||
{ "%.out", "%",
|
||||
"@rm -f $@ \n cp $< $@" },
|
||||
#endif
|
||||
/* Syntax is "ctangle foo.w foo.ch foo.c". */
|
||||
{ "%.c", "%.w %.ch",
|
||||
"$(CTANGLE) $^ $@" },
|
||||
{ "%.tex", "%.w %.ch",
|
||||
"$(CWEAVE) $^ $@" },
|
||||
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
static struct pspec default_terminal_rules[] =
|
||||
{
|
||||
#ifdef VMS
|
||||
/* RCS. */
|
||||
{ "%", "%$$5lv", /* Multinet style */
|
||||
"if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
|
||||
{ "%", "[.$$rcs]%$$5lv", /* Multinet style */
|
||||
"if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
|
||||
{ "%", "%_v", /* Normal style */
|
||||
"if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
|
||||
{ "%", "[.rcs]%_v", /* Normal style */
|
||||
"if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
|
||||
|
||||
/* SCCS. */
|
||||
/* ain't no SCCS on vms */
|
||||
#else
|
||||
/* RCS. */
|
||||
{ "%", "%,v",
|
||||
"$(CHECKOUT,v)" },
|
||||
{ "%", "RCS/%,v",
|
||||
"$(CHECKOUT,v)" },
|
||||
{ "%", "RCS/%",
|
||||
"$(CHECKOUT,v)" },
|
||||
|
||||
/* SCCS. */
|
||||
{ "%", "s.%",
|
||||
"$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" },
|
||||
{ "%", "SCCS/s.%",
|
||||
"$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" },
|
||||
#endif /* !VMS */
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
static char *default_suffix_rules[] =
|
||||
{
|
||||
#ifdef VMS
|
||||
".obj.exe",
|
||||
"$(LINK.obj) $^ $(LOADLIBES) $(LDLIBS) $(CRT0) /exe=$@",
|
||||
".mar.exe",
|
||||
"$(COMPILE.mar) $^ \n $(LINK.obj) $(subst .mar,.obj,$^) $(LOADLIBES) $(LDLIBS) $(CRT0) /exe=$@",
|
||||
".s.exe",
|
||||
"$(COMPILE.s) $^ \n $(LINK.obj) $(subst .s,.obj,$^) $(LOADLIBES) $(LDLIBS) $(CRT0) /exe=$@",
|
||||
".c.exe",
|
||||
"$(COMPILE.c) $^ \n $(LINK.obj) $(subst .c,.obj,$^) $(LOADLIBES) $(LDLIBS) $(CRT0) /exe=$@",
|
||||
".cc.exe",
|
||||
#ifdef GCC_IS_NATIVE
|
||||
"$(COMPILE.cc) $^ \n $(LINK.obj) $(CXXSTARTUP),sys$$disk:[]$(subst .cc,.obj,$^) $(LOADLIBES) $(LXLIBS) $(LDLIBS) $(CXXRT0) /exe=$@",
|
||||
#else
|
||||
"$(COMPILE.cc) $^ \n $(CXXLINK.obj) $(subst .cc,.obj,$^) $(LOADLIBES) $(LXLIBS) $(LDLIBS) $(CXXRT0) /exe=$@",
|
||||
".cxx.exe",
|
||||
"$(COMPILE.cxx) $^ \n $(CXXLINK.obj) $(subst .cxx,.obj,$^) $(LOADLIBES) $(LXLIBS) $(LDLIBS) $(CXXRT0) /exe=$@",
|
||||
#endif
|
||||
".for.exe",
|
||||
"$(COMPILE.for) $^ \n $(LINK.obj) $(subst .for,.obj,$^) $(LOADLIBES) $(LDLIBS) /exe=$@",
|
||||
".pas.exe",
|
||||
"$(COMPILE.pas) $^ \n $(LINK.obj) $(subst .pas,.obj,$^) $(LOADLIBES) $(LDLIBS) /exe=$@",
|
||||
|
||||
".com",
|
||||
"copy $< >$@",
|
||||
|
||||
".mar.obj",
|
||||
"$(COMPILE.mar) /obj=$@ $<",
|
||||
".s.obj",
|
||||
"$(COMPILE.s) /obj=$@ $<",
|
||||
".ss.obj",
|
||||
"$(COMPILE.s) /obj=$@ $<",
|
||||
".c.i",
|
||||
"$(COMPILE.c)/prep /list=$@ $<",
|
||||
".c.s",
|
||||
"$(COMPILE.c)/noobj/machine /list=$@ $<",
|
||||
".i.s",
|
||||
"$(COMPILE.c)/noprep/noobj/machine /list=$@ $<",
|
||||
".c.obj",
|
||||
"$(COMPILE.c) /obj=$@ $<",
|
||||
".cc.ii",
|
||||
"$(COMPILE.cc)/prep /list=$@ $<",
|
||||
".cc.ss",
|
||||
"$(COMPILE.cc)/noobj/machine /list=$@ $<",
|
||||
".ii.ss",
|
||||
"$(COMPILE.cc)/noprep/noobj/machine /list=$@ $<",
|
||||
".cc.obj",
|
||||
"$(COMPILE.cc) /obj=$@ $<",
|
||||
".for.obj",
|
||||
"$(COMPILE.for) /obj=$@ $<",
|
||||
".pas.obj",
|
||||
"$(COMPILE.pas) /obj=$@ $<",
|
||||
|
||||
".y.c",
|
||||
"$(YACC.y) $< \n rename y_tab.c $@",
|
||||
".l.c",
|
||||
"$(LEX.l) $< \n rename lexyy.c $@",
|
||||
|
||||
".texinfo.info",
|
||||
"$(MAKEINFO) $<",
|
||||
|
||||
".tex.dvi",
|
||||
"$(TEX) $<",
|
||||
|
||||
#else /* ! VMS */
|
||||
|
||||
".o",
|
||||
"$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@",
|
||||
".s",
|
||||
"$(LINK.s) $^ $(LOADLIBES) $(LDLIBS) -o $@",
|
||||
".S",
|
||||
"$(LINK.S) $^ $(LOADLIBES) $(LDLIBS) -o $@",
|
||||
".c",
|
||||
"$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@",
|
||||
".cc",
|
||||
"$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@",
|
||||
".C",
|
||||
"$(LINK.C) $^ $(LOADLIBES) $(LDLIBS) -o $@",
|
||||
".cpp",
|
||||
"$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@",
|
||||
".f",
|
||||
"$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@",
|
||||
".p",
|
||||
"$(LINK.p) $^ $(LOADLIBES) $(LDLIBS) -o $@",
|
||||
".F",
|
||||
"$(LINK.F) $^ $(LOADLIBES) $(LDLIBS) -o $@",
|
||||
".r",
|
||||
"$(LINK.r) $^ $(LOADLIBES) $(LDLIBS) -o $@",
|
||||
".mod",
|
||||
"$(COMPILE.mod) -o $@ -e $@ $^",
|
||||
|
||||
".def.sym",
|
||||
"$(COMPILE.def) -o $@ $<",
|
||||
|
||||
".sh",
|
||||
"cat $< >$@ \n chmod a+x $@",
|
||||
|
||||
".s.o",
|
||||
"$(COMPILE.s) -o $@ $<",
|
||||
".S.o",
|
||||
"$(COMPILE.S) -o $@ $<",
|
||||
".c.o",
|
||||
"$(COMPILE.c) $(OUTPUT_OPTION) $<",
|
||||
".cc.o",
|
||||
"$(COMPILE.cc) $(OUTPUT_OPTION) $<",
|
||||
".C.o",
|
||||
"$(COMPILE.C) $(OUTPUT_OPTION) $<",
|
||||
".cpp.o",
|
||||
"$(COMPILE.cpp) $(OUTPUT_OPTION) $<",
|
||||
".f.o",
|
||||
"$(COMPILE.f) $(OUTPUT_OPTION) $<",
|
||||
".p.o",
|
||||
"$(COMPILE.p) $(OUTPUT_OPTION) $<",
|
||||
".F.o",
|
||||
"$(COMPILE.F) $(OUTPUT_OPTION) $<",
|
||||
".r.o",
|
||||
"$(COMPILE.r) $(OUTPUT_OPTION) $<",
|
||||
".mod.o",
|
||||
"$(COMPILE.mod) -o $@ $<",
|
||||
|
||||
".c.ln",
|
||||
"$(LINT.c) -C$* $<",
|
||||
".y.ln",
|
||||
#ifndef __MSDOS__
|
||||
"$(YACC.y) $< \n $(LINT.c) -C$* y.tab.c \n $(RM) y.tab.c",
|
||||
#else
|
||||
"$(YACC.y) $< \n $(LINT.c) -C$* y_tab.c \n $(RM) y_tab.c",
|
||||
#endif
|
||||
".l.ln",
|
||||
"@$(RM) $*.c\n $(LEX.l) $< > $*.c\n$(LINT.c) -i $*.c -o $@\n $(RM) $*.c",
|
||||
|
||||
".y.c",
|
||||
#ifndef __MSDOS__
|
||||
"$(YACC.y) $< \n mv -f y.tab.c $@",
|
||||
#else
|
||||
"$(YACC.y) $< \n mv -f y_tab.c $@",
|
||||
#endif
|
||||
".l.c",
|
||||
"@$(RM) $@ \n $(LEX.l) $< > $@",
|
||||
|
||||
".F.f",
|
||||
"$(PREPROCESS.F) $(OUTPUT_OPTION) $<",
|
||||
".r.f",
|
||||
"$(PREPROCESS.r) $(OUTPUT_OPTION) $<",
|
||||
|
||||
/* This might actually make lex.yy.c if there's no %R%
|
||||
directive in $*.l, but in that case why were you
|
||||
trying to make $*.r anyway? */
|
||||
".l.r",
|
||||
"$(LEX.l) $< > $@ \n mv -f lex.yy.r $@",
|
||||
|
||||
".S.s",
|
||||
"$(PREPROCESS.S) $< > $@",
|
||||
|
||||
".texinfo.info",
|
||||
"$(MAKEINFO) $(MAKEINFO_FLAGS) $< -o $@",
|
||||
|
||||
".texi.info",
|
||||
"$(MAKEINFO) $(MAKEINFO_FLAGS) $< -o $@",
|
||||
|
||||
".txinfo.info",
|
||||
"$(MAKEINFO) $(MAKEINFO_FLAGS) $< -o $@",
|
||||
|
||||
".tex.dvi",
|
||||
"$(TEX) $<",
|
||||
|
||||
".texinfo.dvi",
|
||||
"$(TEXI2DVI) $(TEXI2DVI_FLAGS) $<",
|
||||
|
||||
".texi.dvi",
|
||||
"$(TEXI2DVI) $(TEXI2DVI_FLAGS) $<",
|
||||
|
||||
".txinfo.dvi",
|
||||
"$(TEXI2DVI) $(TEXI2DVI_FLAGS) $<",
|
||||
|
||||
".w.c",
|
||||
"$(CTANGLE) $< - $@", /* The `-' says there is no `.ch' file. */
|
||||
|
||||
".web.p",
|
||||
"$(TANGLE) $<",
|
||||
|
||||
".w.tex",
|
||||
"$(CWEAVE) $< - $@", /* The `-' says there is no `.ch' file. */
|
||||
|
||||
".web.tex",
|
||||
"$(WEAVE) $<",
|
||||
|
||||
#endif /* !VMS */
|
||||
|
||||
0, 0,
|
||||
};
|
||||
|
||||
static char *default_variables[] =
|
||||
{
|
||||
#ifdef VMS
|
||||
#ifdef __ALPHA
|
||||
"ARCH", "ALPHA",
|
||||
#else
|
||||
"ARCH", "VAX",
|
||||
#endif
|
||||
"AR", "library/obj",
|
||||
"ARFLAGS", "/replace",
|
||||
"AS", "macro",
|
||||
"MACRO", "macro",
|
||||
#ifdef GCC_IS_NATIVE
|
||||
"CC", "gcc",
|
||||
#else
|
||||
"CC", "cc",
|
||||
#endif
|
||||
"CD", "builtin_cd",
|
||||
"MAKE", "make",
|
||||
"ECHO", "write sys$$output \"",
|
||||
#ifdef GCC_IS_NATIVE
|
||||
"C++", "gcc/plus",
|
||||
"CXX", "gcc/plus",
|
||||
#else
|
||||
"C++", "cxx",
|
||||
"CXX", "cxx",
|
||||
"CXXLD", "cxxlink",
|
||||
#endif
|
||||
"CO", "co",
|
||||
"CPP", "$(CC) /preprocess_only",
|
||||
"FC", "fortran",
|
||||
/* System V uses these, so explicit rules using them should work.
|
||||
However, there is no way to make implicit rules use them and FC. */
|
||||
"F77", "$(FC)",
|
||||
"F77FLAGS", "$(FFLAGS)",
|
||||
"LD", "link",
|
||||
"LEX", "lex",
|
||||
"PC", "pascal",
|
||||
"YACC", "bison/yacc",
|
||||
"YFLAGS", "/Define/Verbose",
|
||||
"BISON", "bison",
|
||||
"MAKEINFO", "makeinfo",
|
||||
"TEX", "tex",
|
||||
"TEXINDEX", "texindex",
|
||||
|
||||
"RM", "delete/nolog",
|
||||
|
||||
"CSTARTUP", "",
|
||||
#ifdef GCC_IS_NATIVE
|
||||
"CRT0", ",sys$$library:vaxcrtl.olb/lib,gnu_cc_library:crt0.obj",
|
||||
"CXXSTARTUP", "gnu_cc_library:crtbegin.obj",
|
||||
"CXXRT0", ",sys$$library:vaxcrtl.olb/lib,gnu_cc_library:crtend.obj,gnu_cc_library:gxx_main.obj",
|
||||
"LXLIBS", ",gnu_cc_library:libstdcxx.olb/lib,gnu_cc_library:libgccplus.olb/lib",
|
||||
"LDLIBS", ",gnu_cc_library:libgcc.olb/lib",
|
||||
#else
|
||||
"CRT0", "",
|
||||
"CXXSTARTUP", "",
|
||||
"CXXRT0", "",
|
||||
"LXLIBS", "",
|
||||
"LDLIBS", "",
|
||||
#endif
|
||||
|
||||
"LINK.obj", "$(LD) $(LDFLAGS)",
|
||||
#ifndef GCC_IS_NATIVE
|
||||
"CXXLINK.obj", "$(CXXLD) $(LDFLAGS)",
|
||||
"COMPILE.cxx", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
|
||||
#endif
|
||||
"COMPILE.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
|
||||
"COMPILE.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
|
||||
"YACC.y", "$(YACC) $(YFLAGS)",
|
||||
"LEX.l", "$(LEX) $(LFLAGS)",
|
||||
"COMPILE.for", "$(FC) $(FFLAGS) $(TARGET_ARCH)",
|
||||
"COMPILE.pas", "$(PC) $(PFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
|
||||
"COMPILE.mar", "$(MACRO) $(MACROFLAGS)",
|
||||
"COMPILE.s", "$(AS) $(ASFLAGS) $(TARGET_MACH)",
|
||||
"LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
|
||||
|
||||
"MV", "rename/new_version",
|
||||
"CP", "copy",
|
||||
|
||||
#else /* !VMS */
|
||||
|
||||
"AR", "ar",
|
||||
"ARFLAGS", "rv",
|
||||
"AS", "as",
|
||||
#ifdef GCC_IS_NATIVE
|
||||
"CC", "gcc",
|
||||
# ifdef __MSDOS__
|
||||
"CXX", "gpp", /* g++ is an invalid name on MSDOS */
|
||||
# else
|
||||
"CXX", "gcc",
|
||||
# endif /* __MSDOS__ */
|
||||
#else
|
||||
"CC", "cc",
|
||||
"CXX", "g++",
|
||||
#endif
|
||||
|
||||
/* This expands to $(CO) $(COFLAGS) $< $@ if $@ does not exist,
|
||||
and to the empty string if $@ does exist. */
|
||||
"CHECKOUT,v", "+$(if $(wildcard $@),,$(CO) $(COFLAGS) $< $@)",
|
||||
"CO", "co",
|
||||
"COFLAGS", "",
|
||||
|
||||
"CPP", "$(CC) -E",
|
||||
#ifdef CRAY
|
||||
"CF77PPFLAGS", "-P",
|
||||
"CF77PP", "/lib/cpp",
|
||||
"CFT", "cft77",
|
||||
"CF", "cf77",
|
||||
"FC", "$(CF)",
|
||||
#else /* Not CRAY. */
|
||||
#ifdef _IBMR2
|
||||
"FC", "xlf",
|
||||
#else
|
||||
#ifdef __convex__
|
||||
"FC", "fc",
|
||||
#else
|
||||
"FC", "f77",
|
||||
#endif /* __convex__ */
|
||||
#endif /* _IBMR2 */
|
||||
/* System V uses these, so explicit rules using them should work.
|
||||
However, there is no way to make implicit rules use them and FC. */
|
||||
"F77", "$(FC)",
|
||||
"F77FLAGS", "$(FFLAGS)",
|
||||
#endif /* Cray. */
|
||||
"GET", SCCS_GET,
|
||||
"LD", "ld",
|
||||
#ifdef GCC_IS_NATIVE
|
||||
"LEX", "flex",
|
||||
#else
|
||||
"LEX", "lex",
|
||||
#endif
|
||||
"LINT", "lint",
|
||||
"M2C", "m2c",
|
||||
#ifdef pyr
|
||||
"PC", "pascal",
|
||||
#else
|
||||
#ifdef CRAY
|
||||
"PC", "PASCAL",
|
||||
"SEGLDR", "segldr",
|
||||
#else
|
||||
"PC", "pc",
|
||||
#endif /* CRAY. */
|
||||
#endif /* pyr. */
|
||||
#ifdef GCC_IS_NATIVE
|
||||
"YACC", "bison -y",
|
||||
#else
|
||||
"YACC", "yacc", /* Or "bison -y" */
|
||||
#endif
|
||||
"MAKEINFO", "makeinfo",
|
||||
"TEX", "tex",
|
||||
"TEXI2DVI", "texi2dvi",
|
||||
"WEAVE", "weave",
|
||||
"CWEAVE", "cweave",
|
||||
"TANGLE", "tangle",
|
||||
"CTANGLE", "ctangle",
|
||||
|
||||
"RM", "rm -f",
|
||||
|
||||
"LINK.o", "$(CC) $(LDFLAGS) $(TARGET_ARCH)",
|
||||
"COMPILE.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
|
||||
"LINK.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
|
||||
"COMPILE.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
|
||||
"COMPILE.C", "$(COMPILE.cc)",
|
||||
"COMPILE.cpp", "$(COMPILE.cc)",
|
||||
"LINK.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
|
||||
"LINK.C", "$(LINK.cc)",
|
||||
"LINK.cpp", "$(LINK.cc)",
|
||||
"YACC.y", "$(YACC) $(YFLAGS)",
|
||||
"LEX.l", "$(LEX) $(LFLAGS) -t",
|
||||
"COMPILE.f", "$(FC) $(FFLAGS) $(TARGET_ARCH) -c",
|
||||
"LINK.f", "$(FC) $(FFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
|
||||
"COMPILE.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
|
||||
"LINK.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
|
||||
"COMPILE.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -c",
|
||||
"LINK.r", "$(FC) $(FFLAGS) $(RFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
|
||||
"COMPILE.def", "$(M2C) $(M2FLAGS) $(DEFFLAGS) $(TARGET_ARCH)",
|
||||
"COMPILE.mod", "$(M2C) $(M2FLAGS) $(MODFLAGS) $(TARGET_ARCH)",
|
||||
"COMPILE.p", "$(PC) $(PFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
|
||||
"LINK.p", "$(PC) $(PFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
|
||||
"LINK.s", "$(CC) $(ASFLAGS) $(LDFLAGS) $(TARGET_MACH)",
|
||||
"COMPILE.s", "$(AS) $(ASFLAGS) $(TARGET_MACH)",
|
||||
"LINK.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_MACH)",
|
||||
"COMPILE.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c",
|
||||
"PREPROCESS.S", "$(CC) -E $(CPPFLAGS)",
|
||||
"PREPROCESS.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -F",
|
||||
"PREPROCESS.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -F",
|
||||
"LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
|
||||
|
||||
#ifndef NO_MINUS_C_MINUS_O
|
||||
"OUTPUT_OPTION", "-o $@",
|
||||
#endif
|
||||
|
||||
#ifdef SCCS_GET_MINUS_G
|
||||
"SCCS_OUTPUT_OPTION", "-G$@",
|
||||
#endif
|
||||
|
||||
#ifdef _AMIGA
|
||||
".LIBPATTERNS", "%.lib",
|
||||
#else
|
||||
#ifdef __MSDOS__
|
||||
".LIBPATTERNS", "lib%.a $(DJDIR)/lib/lib%.a",
|
||||
#else
|
||||
".LIBPATTERNS", "lib%.so lib%.a",
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* !VMS */
|
||||
0, 0
|
||||
};
|
||||
|
||||
/* Set up the default .SUFFIXES list. */
|
||||
|
||||
void
|
||||
set_default_suffixes ()
|
||||
{
|
||||
suffix_file = enter_file (".SUFFIXES");
|
||||
|
||||
if (no_builtin_rules_flag)
|
||||
(void) define_variable ("SUFFIXES", 8, "", o_default, 0);
|
||||
else
|
||||
{
|
||||
char *p = default_suffixes;
|
||||
suffix_file->deps = (struct dep *)
|
||||
multi_glob (parse_file_seq (&p, '\0', sizeof (struct dep), 1),
|
||||
sizeof (struct dep));
|
||||
(void) define_variable ("SUFFIXES", 8, default_suffixes, o_default, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Enter the default suffix rules as file rules. This used to be done in
|
||||
install_default_implicit_rules, but that loses because we want the
|
||||
suffix rules installed before reading makefiles, and thee pattern rules
|
||||
installed after. */
|
||||
|
||||
void
|
||||
install_default_suffix_rules ()
|
||||
{
|
||||
register char **s;
|
||||
|
||||
if (no_builtin_rules_flag)
|
||||
return;
|
||||
|
||||
for (s = default_suffix_rules; *s != 0; s += 2)
|
||||
{
|
||||
register struct file *f = enter_file (s[0]);
|
||||
/* Don't clobber cmds given in a makefile if there were any. */
|
||||
if (f->cmds == 0)
|
||||
{
|
||||
f->cmds = (struct commands *) xmalloc (sizeof (struct commands));
|
||||
f->cmds->fileinfo.filenm = 0;
|
||||
f->cmds->commands = s[1];
|
||||
f->cmds->command_lines = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Install the default pattern rules. */
|
||||
|
||||
void
|
||||
install_default_implicit_rules ()
|
||||
{
|
||||
register struct pspec *p;
|
||||
|
||||
if (no_builtin_rules_flag)
|
||||
return;
|
||||
|
||||
for (p = default_pattern_rules; p->target != 0; ++p)
|
||||
install_pattern_rule (p, 0);
|
||||
|
||||
for (p = default_terminal_rules; p->target != 0; ++p)
|
||||
install_pattern_rule (p, 1);
|
||||
}
|
||||
|
||||
void
|
||||
define_default_variables ()
|
||||
{
|
||||
register char **s;
|
||||
|
||||
if (no_builtin_variables_flag)
|
||||
return;
|
||||
|
||||
for (s = default_variables; *s != 0; s += 2)
|
||||
(void) define_variable (s[0], strlen (s[0]), s[1], o_default, 1);
|
||||
}
|
||||
78
flaim/external/w32/make/dep.h
vendored
Normal file
78
flaim/external/w32/make/dep.h
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
/* Definitions of dependency data structures for GNU Make.
|
||||
Copyright (C) 1988, 1989, 1991, 1992, 1993, 1996 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Flag bits for the second argument to `read_makefile'.
|
||||
These flags are saved in the `changed' field of each
|
||||
`struct dep' in the chain returned by `read_all_makefiles'. */
|
||||
|
||||
#define RM_NO_DEFAULT_GOAL (1 << 0) /* Do not set default goal. */
|
||||
#define RM_INCLUDED (1 << 1) /* Search makefile search path. */
|
||||
#define RM_DONTCARE (1 << 2) /* No error if it doesn't exist. */
|
||||
#define RM_NO_TILDE (1 << 3) /* Don't expand ~ in file name. */
|
||||
#define RM_NOFLAG 0
|
||||
|
||||
/* Structure representing one dependency of a file.
|
||||
Each struct file's `deps' points to a chain of these,
|
||||
chained through the `next'.
|
||||
|
||||
Note that the first two words of this match a struct nameseq. */
|
||||
|
||||
struct dep
|
||||
{
|
||||
struct dep *next;
|
||||
char *name;
|
||||
struct file *file;
|
||||
unsigned int changed : 8;
|
||||
unsigned int ignore_mtime : 1;
|
||||
};
|
||||
|
||||
|
||||
/* Structure used in chains of names, for parsing and globbing. */
|
||||
|
||||
struct nameseq
|
||||
{
|
||||
struct nameseq *next;
|
||||
char *name;
|
||||
};
|
||||
|
||||
|
||||
extern struct nameseq *multi_glob PARAMS ((struct nameseq *chain, unsigned int size));
|
||||
#ifdef VMS
|
||||
extern struct nameseq *parse_file_seq ();
|
||||
#else
|
||||
extern struct nameseq *parse_file_seq PARAMS ((char **stringp, int stopchar, unsigned int size, int strip));
|
||||
#endif
|
||||
extern char *tilde_expand PARAMS ((char *name));
|
||||
|
||||
#ifndef NO_ARCHIVES
|
||||
extern struct nameseq *ar_glob PARAMS ((char *arname, char *member_pattern, unsigned int size));
|
||||
#endif
|
||||
|
||||
#ifndef iAPX286
|
||||
#define dep_name(d) ((d)->name == 0 ? (d)->file->name : (d)->name)
|
||||
#else
|
||||
/* Buggy compiler can't hack this. */
|
||||
extern char *dep_name ();
|
||||
#endif
|
||||
|
||||
extern struct dep *copy_dep_chain PARAMS ((struct dep *d));
|
||||
extern struct dep *read_all_makefiles PARAMS ((char **makefiles));
|
||||
extern int eval_buffer PARAMS ((char *buffer));
|
||||
extern int update_goal_chain PARAMS ((struct dep *goals, int makefiles));
|
||||
extern void uniquize_deps PARAMS ((struct dep *));
|
||||
1212
flaim/external/w32/make/dir.c
vendored
Normal file
1212
flaim/external/w32/make/dir.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
188
flaim/external/w32/make/dirent.c
vendored
Normal file
188
flaim/external/w32/make/dirent.c
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "dirent.h"
|
||||
|
||||
|
||||
DIR*
|
||||
opendir(const char* pDirName)
|
||||
{
|
||||
struct stat sb;
|
||||
DIR* pDir;
|
||||
char* pEndDirName;
|
||||
int nBufferLen;
|
||||
|
||||
/* sanity checks */
|
||||
if (!pDirName) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
if (stat(pDirName, &sb) != 0) {
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
if ((sb.st_mode & S_IFMT) != S_IFDIR) {
|
||||
errno = ENOTDIR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* allocate a DIR structure to return */
|
||||
pDir = (DIR *) malloc(sizeof (DIR));
|
||||
|
||||
if (!pDir)
|
||||
return NULL;
|
||||
|
||||
/* input directory name length */
|
||||
nBufferLen = strlen(pDirName);
|
||||
|
||||
/* copy input directory name to DIR buffer */
|
||||
strcpy(pDir->dir_pDirectoryName, pDirName);
|
||||
|
||||
/* point to end of the copied directory name */
|
||||
pEndDirName = &pDir->dir_pDirectoryName[nBufferLen - 1];
|
||||
|
||||
/* if directory name did not end in '/' or '\', add '/' */
|
||||
if ((*pEndDirName != '/') && (*pEndDirName != '\\')) {
|
||||
pEndDirName++;
|
||||
*pEndDirName = '/';
|
||||
}
|
||||
|
||||
/* now append the wildcard character to the buffer */
|
||||
pEndDirName++;
|
||||
*pEndDirName = '*';
|
||||
pEndDirName++;
|
||||
*pEndDirName = '\0';
|
||||
|
||||
/* other values defaulted */
|
||||
pDir->dir_nNumFiles = 0;
|
||||
pDir->dir_hDirHandle = INVALID_HANDLE_VALUE;
|
||||
pDir->dir_ulCookie = __DIRENT_COOKIE;
|
||||
|
||||
return pDir;
|
||||
}
|
||||
|
||||
void
|
||||
closedir(DIR *pDir)
|
||||
{
|
||||
/* got a valid pointer? */
|
||||
if (!pDir) {
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
|
||||
/* sanity check that this is a DIR pointer */
|
||||
if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
|
||||
/* close the WINDOWS32 directory handle */
|
||||
if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE)
|
||||
FindClose(pDir->dir_hDirHandle);
|
||||
|
||||
free(pDir);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
struct dirent *
|
||||
readdir(DIR* pDir)
|
||||
{
|
||||
WIN32_FIND_DATA wfdFindData;
|
||||
|
||||
if (!pDir) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* sanity check that this is a DIR pointer */
|
||||
if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pDir->dir_nNumFiles == 0) {
|
||||
pDir->dir_hDirHandle = FindFirstFile(pDir->dir_pDirectoryName, &wfdFindData);
|
||||
if (pDir->dir_hDirHandle == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
} else if (!FindNextFile(pDir->dir_hDirHandle, &wfdFindData))
|
||||
return NULL;
|
||||
|
||||
/* bump count for next call to readdir() or telldir() */
|
||||
pDir->dir_nNumFiles++;
|
||||
|
||||
/* fill in struct dirent values */
|
||||
pDir->dir_sdReturn.d_ino = -1;
|
||||
strcpy(pDir->dir_sdReturn.d_name, wfdFindData.cFileName);
|
||||
|
||||
return &pDir->dir_sdReturn;
|
||||
}
|
||||
|
||||
void
|
||||
rewinddir(DIR* pDir)
|
||||
{
|
||||
if (!pDir) {
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
|
||||
/* sanity check that this is a DIR pointer */
|
||||
if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
|
||||
/* close the WINDOWS32 directory handle */
|
||||
if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE)
|
||||
if (!FindClose(pDir->dir_hDirHandle))
|
||||
errno = EBADF;
|
||||
|
||||
/* reset members which control readdir() */
|
||||
pDir->dir_hDirHandle = INVALID_HANDLE_VALUE;
|
||||
pDir->dir_nNumFiles = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
telldir(DIR* pDir)
|
||||
{
|
||||
if (!pDir) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* sanity check that this is a DIR pointer */
|
||||
if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* return number of times readdir() called */
|
||||
return pDir->dir_nNumFiles;
|
||||
}
|
||||
|
||||
void
|
||||
seekdir(DIR* pDir, long nPosition)
|
||||
{
|
||||
if (!pDir)
|
||||
return;
|
||||
|
||||
/* sanity check that this is a DIR pointer */
|
||||
if (pDir->dir_ulCookie != __DIRENT_COOKIE)
|
||||
return;
|
||||
|
||||
/* go back to beginning of directory */
|
||||
rewinddir(pDir);
|
||||
|
||||
/* loop until we have found position we care about */
|
||||
for (--nPosition; nPosition && readdir(pDir); nPosition--);
|
||||
|
||||
/* flag invalid nPosition value */
|
||||
if (nPosition)
|
||||
errno = EINVAL;
|
||||
|
||||
return;
|
||||
}
|
||||
37
flaim/external/w32/make/dirent.h
vendored
Normal file
37
flaim/external/w32/make/dirent.h
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef _DIRENT_H
|
||||
#define _DIRENT_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <windows.h>
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef NAME_MAX
|
||||
#define NAME_MAX 255
|
||||
#endif
|
||||
|
||||
#define __DIRENT_COOKIE 0xfefeabab
|
||||
|
||||
|
||||
struct dirent
|
||||
{
|
||||
ino_t d_ino; /* unused - no equivalent on WINDOWS32 */
|
||||
char d_name[NAME_MAX+1];
|
||||
};
|
||||
|
||||
typedef struct dir_struct {
|
||||
ULONG dir_ulCookie;
|
||||
HANDLE dir_hDirHandle;
|
||||
DWORD dir_nNumFiles;
|
||||
char dir_pDirectoryName[NAME_MAX+1];
|
||||
struct dirent dir_sdReturn;
|
||||
} DIR;
|
||||
|
||||
DIR *opendir(const char *);
|
||||
struct dirent *readdir(DIR *);
|
||||
void rewinddir(DIR *);
|
||||
void closedir(DIR *);
|
||||
int telldir(DIR *);
|
||||
void seekdir(DIR *, long);
|
||||
|
||||
#endif
|
||||
566
flaim/external/w32/make/expand.c
vendored
Normal file
566
flaim/external/w32/make/expand.c
vendored
Normal file
@@ -0,0 +1,566 @@
|
||||
/* Variable expansion functions for GNU Make.
|
||||
Copyright (C) 1988, 89, 91, 92, 93, 95 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "make.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "filedef.h"
|
||||
#include "job.h"
|
||||
#include "commands.h"
|
||||
#include "variable.h"
|
||||
#include "rule.h"
|
||||
|
||||
/* The next two describe the variable output buffer.
|
||||
This buffer is used to hold the variable-expansion of a line of the
|
||||
makefile. It is made bigger with realloc whenever it is too small.
|
||||
variable_buffer_length is the size currently allocated.
|
||||
variable_buffer is the address of the buffer.
|
||||
|
||||
For efficiency, it's guaranteed that the buffer will always have
|
||||
VARIABLE_BUFFER_ZONE extra bytes allocated. This allows you to add a few
|
||||
extra chars without having to call a function. Note you should never use
|
||||
these bytes unless you're _sure_ you have room (you know when the buffer
|
||||
length was last checked. */
|
||||
|
||||
#define VARIABLE_BUFFER_ZONE 5
|
||||
|
||||
static unsigned int variable_buffer_length;
|
||||
char *variable_buffer;
|
||||
|
||||
/* Subroutine of variable_expand and friends:
|
||||
The text to add is LENGTH chars starting at STRING to the variable_buffer.
|
||||
The text is added to the buffer at PTR, and the updated pointer into
|
||||
the buffer is returned as the value. Thus, the value returned by
|
||||
each call to variable_buffer_output should be the first argument to
|
||||
the following call. */
|
||||
|
||||
char *
|
||||
variable_buffer_output (ptr, string, length)
|
||||
char *ptr, *string;
|
||||
unsigned int length;
|
||||
{
|
||||
register unsigned int newlen = length + (ptr - variable_buffer);
|
||||
|
||||
if ((newlen + VARIABLE_BUFFER_ZONE) > variable_buffer_length)
|
||||
{
|
||||
unsigned int offset = ptr - variable_buffer;
|
||||
variable_buffer_length = (newlen + 100 > 2 * variable_buffer_length
|
||||
? newlen + 100
|
||||
: 2 * variable_buffer_length);
|
||||
variable_buffer = (char *) xrealloc (variable_buffer,
|
||||
variable_buffer_length);
|
||||
ptr = variable_buffer + offset;
|
||||
}
|
||||
|
||||
bcopy (string, ptr, length);
|
||||
return ptr + length;
|
||||
}
|
||||
|
||||
/* Return a pointer to the beginning of the variable buffer. */
|
||||
|
||||
static char *
|
||||
initialize_variable_output ()
|
||||
{
|
||||
/* If we don't have a variable output buffer yet, get one. */
|
||||
|
||||
if (variable_buffer == 0)
|
||||
{
|
||||
variable_buffer_length = 200;
|
||||
variable_buffer = (char *) xmalloc (variable_buffer_length);
|
||||
variable_buffer[0] = '\0';
|
||||
}
|
||||
|
||||
return variable_buffer;
|
||||
}
|
||||
|
||||
/* Recursively expand V. The returned string is malloc'd. */
|
||||
|
||||
static char *allocated_variable_append PARAMS ((const struct variable *v));
|
||||
|
||||
char *
|
||||
recursively_expand_for_file (v, file)
|
||||
struct variable *v;
|
||||
struct file *file;
|
||||
{
|
||||
char *value;
|
||||
struct variable_set_list *save = 0;
|
||||
|
||||
if (v->expanding)
|
||||
{
|
||||
if (!v->exp_count)
|
||||
/* Expanding V causes infinite recursion. Lose. */
|
||||
fatal (reading_file,
|
||||
_("Recursive variable `%s' references itself (eventually)"),
|
||||
v->name);
|
||||
--v->exp_count;
|
||||
}
|
||||
|
||||
if (file)
|
||||
{
|
||||
save = current_variable_set_list;
|
||||
current_variable_set_list = file->variables;
|
||||
}
|
||||
|
||||
v->expanding = 1;
|
||||
if (v->append)
|
||||
value = allocated_variable_append (v);
|
||||
else
|
||||
value = allocated_variable_expand (v->value);
|
||||
v->expanding = 0;
|
||||
|
||||
if (file)
|
||||
current_variable_set_list = save;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/* Expand a simple reference to variable NAME, which is LENGTH chars long. */
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#endif
|
||||
static char *
|
||||
reference_variable (o, name, length)
|
||||
char *o;
|
||||
char *name;
|
||||
unsigned int length;
|
||||
{
|
||||
register struct variable *v;
|
||||
char *value;
|
||||
|
||||
v = lookup_variable (name, length);
|
||||
|
||||
if (v == 0)
|
||||
warn_undefined (name, length);
|
||||
|
||||
if (v == 0 || *v->value == '\0')
|
||||
return o;
|
||||
|
||||
value = (v->recursive ? recursively_expand (v) : v->value);
|
||||
|
||||
o = variable_buffer_output (o, value, strlen (value));
|
||||
|
||||
if (v->recursive)
|
||||
free (value);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
/* Scan STRING for variable references and expansion-function calls. Only
|
||||
LENGTH bytes of STRING are actually scanned. If LENGTH is -1, scan until
|
||||
a null byte is found.
|
||||
|
||||
Write the results to LINE, which must point into `variable_buffer'. If
|
||||
LINE is NULL, start at the beginning of the buffer.
|
||||
Return a pointer to LINE, or to the beginning of the buffer if LINE is
|
||||
NULL. */
|
||||
|
||||
char *
|
||||
variable_expand_string (line, string, length)
|
||||
register char *line;
|
||||
char *string;
|
||||
long length;
|
||||
{
|
||||
register struct variable *v;
|
||||
register char *p, *o, *p1;
|
||||
char save_char = '\0';
|
||||
unsigned int line_offset;
|
||||
|
||||
if (!line)
|
||||
line = initialize_variable_output();
|
||||
|
||||
p = string;
|
||||
o = line;
|
||||
line_offset = line - variable_buffer;
|
||||
|
||||
if (length >= 0)
|
||||
{
|
||||
save_char = string[length];
|
||||
string[length] = '\0';
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
/* Copy all following uninteresting chars all at once to the
|
||||
variable output buffer, and skip them. Uninteresting chars end
|
||||
at the next $ or the end of the input. */
|
||||
|
||||
p1 = strchr (p, '$');
|
||||
|
||||
o = variable_buffer_output (o, p, p1 != 0 ? p1 - p : strlen (p) + 1);
|
||||
|
||||
if (p1 == 0)
|
||||
break;
|
||||
p = p1 + 1;
|
||||
|
||||
/* Dispatch on the char that follows the $. */
|
||||
|
||||
switch (*p)
|
||||
{
|
||||
case '$':
|
||||
/* $$ seen means output one $ to the variable output buffer. */
|
||||
o = variable_buffer_output (o, p, 1);
|
||||
break;
|
||||
|
||||
case '(':
|
||||
case '{':
|
||||
/* $(...) or ${...} is the general case of substitution. */
|
||||
{
|
||||
char openparen = *p;
|
||||
char closeparen = (openparen == '(') ? ')' : '}';
|
||||
register char *beg = p + 1;
|
||||
int free_beg = 0;
|
||||
char *op, *begp;
|
||||
char *end, *colon;
|
||||
|
||||
op = o;
|
||||
begp = p;
|
||||
if (handle_function (&op, &begp))
|
||||
{
|
||||
o = op;
|
||||
p = begp;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Is there a variable reference inside the parens or braces?
|
||||
If so, expand it before expanding the entire reference. */
|
||||
|
||||
end = strchr (beg, closeparen);
|
||||
if (end == 0)
|
||||
/* Unterminated variable reference. */
|
||||
fatal (reading_file, _("unterminated variable reference"));
|
||||
p1 = lindex (beg, end, '$');
|
||||
if (p1 != 0)
|
||||
{
|
||||
/* BEG now points past the opening paren or brace.
|
||||
Count parens or braces until it is matched. */
|
||||
int count = 0;
|
||||
for (p = beg; *p != '\0'; ++p)
|
||||
{
|
||||
if (*p == openparen)
|
||||
++count;
|
||||
else if (*p == closeparen && --count < 0)
|
||||
break;
|
||||
}
|
||||
/* If COUNT is >= 0, there were unmatched opening parens
|
||||
or braces, so we go to the simple case of a variable name
|
||||
such as `$($(a)'. */
|
||||
if (count < 0)
|
||||
{
|
||||
beg = expand_argument (beg, p); /* Expand the name. */
|
||||
free_beg = 1; /* Remember to free BEG when finished. */
|
||||
end = strchr (beg, '\0');
|
||||
}
|
||||
}
|
||||
else
|
||||
/* Advance P to the end of this reference. After we are
|
||||
finished expanding this one, P will be incremented to
|
||||
continue the scan. */
|
||||
p = end;
|
||||
|
||||
/* This is not a reference to a built-in function and
|
||||
any variable references inside are now expanded.
|
||||
Is the resultant text a substitution reference? */
|
||||
|
||||
colon = lindex (beg, end, ':');
|
||||
if (colon)
|
||||
{
|
||||
/* This looks like a substitution reference: $(FOO:A=B). */
|
||||
char *subst_beg, *subst_end, *replace_beg, *replace_end;
|
||||
|
||||
subst_beg = colon + 1;
|
||||
subst_end = strchr (subst_beg, '=');
|
||||
if (subst_end == 0)
|
||||
/* There is no = in sight. Punt on the substitution
|
||||
reference and treat this as a variable name containing
|
||||
a colon, in the code below. */
|
||||
colon = 0;
|
||||
else
|
||||
{
|
||||
replace_beg = subst_end + 1;
|
||||
replace_end = end;
|
||||
|
||||
/* Extract the variable name before the colon
|
||||
and look up that variable. */
|
||||
v = lookup_variable (beg, colon - beg);
|
||||
if (v == 0)
|
||||
warn_undefined (beg, colon - beg);
|
||||
|
||||
if (v != 0 && *v->value != '\0')
|
||||
{
|
||||
char *value = (v->recursive ? recursively_expand (v)
|
||||
: v->value);
|
||||
char *pattern, *percent;
|
||||
if (free_beg)
|
||||
{
|
||||
*subst_end = '\0';
|
||||
pattern = subst_beg;
|
||||
}
|
||||
else
|
||||
{
|
||||
pattern = (char *) alloca (subst_end - subst_beg
|
||||
+ 1);
|
||||
bcopy (subst_beg, pattern, subst_end - subst_beg);
|
||||
pattern[subst_end - subst_beg] = '\0';
|
||||
}
|
||||
percent = find_percent (pattern);
|
||||
if (percent != 0)
|
||||
{
|
||||
char *replace;
|
||||
if (free_beg)
|
||||
{
|
||||
*replace_end = '\0';
|
||||
replace = replace_beg;
|
||||
}
|
||||
else
|
||||
{
|
||||
replace = (char *) alloca (replace_end
|
||||
- replace_beg
|
||||
+ 1);
|
||||
bcopy (replace_beg, replace,
|
||||
replace_end - replace_beg);
|
||||
replace[replace_end - replace_beg] = '\0';
|
||||
}
|
||||
|
||||
o = patsubst_expand (o, value, pattern, replace,
|
||||
percent, (char *) 0);
|
||||
}
|
||||
else
|
||||
o = subst_expand (o, value,
|
||||
pattern, replace_beg,
|
||||
strlen (pattern),
|
||||
end - replace_beg,
|
||||
0, 1);
|
||||
if (v->recursive)
|
||||
free (value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (colon == 0)
|
||||
/* This is an ordinary variable reference.
|
||||
Look up the value of the variable. */
|
||||
o = reference_variable (o, beg, end - beg);
|
||||
|
||||
if (free_beg)
|
||||
free (beg);
|
||||
}
|
||||
break;
|
||||
|
||||
case '\0':
|
||||
break;
|
||||
|
||||
default:
|
||||
if (isblank ((unsigned char)p[-1]))
|
||||
break;
|
||||
|
||||
/* A $ followed by a random char is a variable reference:
|
||||
$a is equivalent to $(a). */
|
||||
{
|
||||
/* We could do the expanding here, but this way
|
||||
avoids code repetition at a small performance cost. */
|
||||
char name[5];
|
||||
name[0] = '$';
|
||||
name[1] = '(';
|
||||
name[2] = *p;
|
||||
name[3] = ')';
|
||||
name[4] = '\0';
|
||||
p1 = allocated_variable_expand (name);
|
||||
o = variable_buffer_output (o, p1, strlen (p1));
|
||||
free (p1);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (*p == '\0')
|
||||
break;
|
||||
else
|
||||
++p;
|
||||
}
|
||||
|
||||
if (save_char)
|
||||
string[length] = save_char;
|
||||
|
||||
(void)variable_buffer_output (o, "", 1);
|
||||
return (variable_buffer + line_offset);
|
||||
}
|
||||
|
||||
/* Scan LINE for variable references and expansion-function calls.
|
||||
Build in `variable_buffer' the result of expanding the references and calls.
|
||||
Return the address of the resulting string, which is null-terminated
|
||||
and is valid only until the next time this function is called. */
|
||||
|
||||
char *
|
||||
variable_expand (line)
|
||||
char *line;
|
||||
{
|
||||
return variable_expand_string(NULL, line, (long)-1);
|
||||
}
|
||||
|
||||
/* Expand an argument for an expansion function.
|
||||
The text starting at STR and ending at END is variable-expanded
|
||||
into a null-terminated string that is returned as the value.
|
||||
This is done without clobbering `variable_buffer' or the current
|
||||
variable-expansion that is in progress. */
|
||||
|
||||
char *
|
||||
expand_argument (str, end)
|
||||
char *str, *end;
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
if (str == end)
|
||||
return xstrdup("");
|
||||
|
||||
if (!end || *end == '\0')
|
||||
tmp = str;
|
||||
else
|
||||
{
|
||||
tmp = (char *) alloca (end - str + 1);
|
||||
bcopy (str, tmp, end - str);
|
||||
tmp[end - str] = '\0';
|
||||
}
|
||||
|
||||
return allocated_variable_expand (tmp);
|
||||
}
|
||||
|
||||
/* Expand LINE for FILE. Error messages refer to the file and line where
|
||||
FILE's commands were found. Expansion uses FILE's variable set list. */
|
||||
|
||||
static char *
|
||||
variable_expand_for_file (line, file)
|
||||
char *line;
|
||||
register struct file *file;
|
||||
{
|
||||
char *result;
|
||||
struct variable_set_list *save;
|
||||
|
||||
if (file == 0)
|
||||
return variable_expand (line);
|
||||
|
||||
save = current_variable_set_list;
|
||||
current_variable_set_list = file->variables;
|
||||
if (file->cmds && file->cmds->fileinfo.filenm)
|
||||
reading_file = &file->cmds->fileinfo;
|
||||
else
|
||||
reading_file = 0;
|
||||
result = variable_expand (line);
|
||||
current_variable_set_list = save;
|
||||
reading_file = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Like allocated_variable_expand, but for += target-specific variables.
|
||||
First recursively construct the variable value from its appended parts in
|
||||
any upper variable sets. Then expand the resulting value. */
|
||||
|
||||
static char *
|
||||
variable_append (name, length, set)
|
||||
const char *name;
|
||||
unsigned int length;
|
||||
const struct variable_set_list *set;
|
||||
{
|
||||
const struct variable *v;
|
||||
char *buf = 0;
|
||||
|
||||
/* If there's nothing left to check, return the empty buffer. */
|
||||
if (!set)
|
||||
return initialize_variable_output ();
|
||||
|
||||
/* Try to find the variable in this variable set. */
|
||||
v = lookup_variable_in_set (name, length, set->set);
|
||||
|
||||
/* If there isn't one, look to see if there's one in a set above us. */
|
||||
if (!v)
|
||||
return variable_append (name, length, set->next);
|
||||
|
||||
/* If this variable type is append, first get any upper values.
|
||||
If not, initialize the buffer. */
|
||||
if (v->append)
|
||||
buf = variable_append (name, length, set->next);
|
||||
else
|
||||
buf = initialize_variable_output ();
|
||||
|
||||
/* Append this value to the buffer, and return it.
|
||||
If we already have a value, first add a space. */
|
||||
if (buf > variable_buffer)
|
||||
buf = variable_buffer_output (buf, " ", 1);
|
||||
|
||||
return variable_buffer_output (buf, v->value, strlen (v->value));
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
allocated_variable_append (v)
|
||||
const struct variable *v;
|
||||
{
|
||||
char *val, *retval;
|
||||
|
||||
/* Construct the appended variable value. */
|
||||
|
||||
char *obuf = variable_buffer;
|
||||
unsigned int olen = variable_buffer_length;
|
||||
|
||||
variable_buffer = 0;
|
||||
|
||||
val = variable_append (v->name, strlen (v->name), current_variable_set_list);
|
||||
variable_buffer_output (val, "", 1);
|
||||
val = variable_buffer;
|
||||
|
||||
variable_buffer = obuf;
|
||||
variable_buffer_length = olen;
|
||||
|
||||
/* Now expand it and return that. */
|
||||
|
||||
retval = allocated_variable_expand (val);
|
||||
|
||||
free (val);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Like variable_expand_for_file, but the returned string is malloc'd.
|
||||
This function is called a lot. It wants to be efficient. */
|
||||
|
||||
char *
|
||||
allocated_variable_expand_for_file (line, file)
|
||||
char *line;
|
||||
struct file *file;
|
||||
{
|
||||
char *value;
|
||||
|
||||
char *obuf = variable_buffer;
|
||||
unsigned int olen = variable_buffer_length;
|
||||
|
||||
variable_buffer = 0;
|
||||
|
||||
value = variable_expand_for_file (line, file);
|
||||
|
||||
#if 0
|
||||
/* Waste a little memory and save time. */
|
||||
value = xrealloc (value, strlen (value))
|
||||
#endif
|
||||
|
||||
variable_buffer = obuf;
|
||||
variable_buffer_length = olen;
|
||||
|
||||
return value;
|
||||
}
|
||||
827
flaim/external/w32/make/file.c
vendored
Normal file
827
flaim/external/w32/make/file.c
vendored
Normal file
@@ -0,0 +1,827 @@
|
||||
/* Target file hash table management for GNU Make.
|
||||
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
|
||||
2002 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "make.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "dep.h"
|
||||
#include "filedef.h"
|
||||
#include "job.h"
|
||||
#include "commands.h"
|
||||
#include "variable.h"
|
||||
#include "debug.h"
|
||||
#include "hash.h"
|
||||
|
||||
|
||||
/* Hash table of files the makefile knows how to make. */
|
||||
|
||||
static unsigned long
|
||||
file_hash_1 (key)
|
||||
const void *key;
|
||||
{
|
||||
return_ISTRING_HASH_1 (((struct file const *) key)->hname);
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
file_hash_2 (key)
|
||||
const void *key;
|
||||
{
|
||||
return_ISTRING_HASH_2 (((struct file const *) key)->hname);
|
||||
}
|
||||
|
||||
static int
|
||||
file_hash_cmp (x, y)
|
||||
const void *x;
|
||||
const void *y;
|
||||
{
|
||||
return_ISTRING_COMPARE (((struct file const *) x)->hname,
|
||||
((struct file const *) y)->hname);
|
||||
}
|
||||
|
||||
#ifndef FILE_BUCKETS
|
||||
#define FILE_BUCKETS 1007
|
||||
#endif
|
||||
static struct hash_table files;
|
||||
|
||||
/* Whether or not .SECONDARY with no prerequisites was given. */
|
||||
static int all_secondary = 0;
|
||||
|
||||
/* Access the hash table of all file records.
|
||||
lookup_file given a name, return the struct file * for that name,
|
||||
or nil if there is none.
|
||||
enter_file similar, but create one if there is none. */
|
||||
|
||||
struct file *
|
||||
lookup_file (name)
|
||||
char *name;
|
||||
{
|
||||
register struct file *f;
|
||||
struct file file_key;
|
||||
#if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
|
||||
register char *lname, *ln;
|
||||
#endif
|
||||
|
||||
assert (*name != '\0');
|
||||
|
||||
/* This is also done in parse_file_seq, so this is redundant
|
||||
for names read from makefiles. It is here for names passed
|
||||
on the command line. */
|
||||
#ifdef VMS
|
||||
# ifndef WANT_CASE_SENSITIVE_TARGETS
|
||||
{
|
||||
register char *n;
|
||||
lname = (char *) malloc (strlen (name) + 1);
|
||||
for (n = name, ln = lname; *n != '\0'; ++n, ++ln)
|
||||
*ln = isupper ((unsigned char)*n) ? tolower ((unsigned char)*n) : *n;
|
||||
*ln = '\0';
|
||||
name = lname;
|
||||
}
|
||||
# endif
|
||||
|
||||
while (name[0] == '[' && name[1] == ']' && name[2] != '\0')
|
||||
name += 2;
|
||||
#endif
|
||||
while (name[0] == '.' && name[1] == '/' && name[2] != '\0')
|
||||
{
|
||||
name += 2;
|
||||
while (*name == '/')
|
||||
/* Skip following slashes: ".//foo" is "foo", not "/foo". */
|
||||
++name;
|
||||
}
|
||||
|
||||
if (*name == '\0')
|
||||
/* It was all slashes after a dot. */
|
||||
#ifdef VMS
|
||||
name = "[]";
|
||||
#else
|
||||
#ifdef _AMIGA
|
||||
name = "";
|
||||
#else
|
||||
name = "./";
|
||||
#endif /* AMIGA */
|
||||
#endif /* VMS */
|
||||
|
||||
file_key.hname = name;
|
||||
f = (struct file *) hash_find_item (&files, &file_key);
|
||||
#if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
|
||||
free (lname);
|
||||
#endif
|
||||
return f;
|
||||
}
|
||||
|
||||
struct file *
|
||||
enter_file (name)
|
||||
char *name;
|
||||
{
|
||||
register struct file *f;
|
||||
register struct file *new;
|
||||
register struct file **file_slot;
|
||||
struct file file_key;
|
||||
#if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
|
||||
char *lname, *ln;
|
||||
#endif
|
||||
|
||||
assert (*name != '\0');
|
||||
|
||||
#if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
|
||||
{
|
||||
register char *n;
|
||||
lname = (char *) malloc (strlen (name) + 1);
|
||||
for (n = name, ln = lname; *n != '\0'; ++n, ++ln)
|
||||
{
|
||||
if (isupper ((unsigned char)*n))
|
||||
*ln = tolower ((unsigned char)*n);
|
||||
else
|
||||
*ln = *n;
|
||||
}
|
||||
|
||||
*ln = 0;
|
||||
/* Creates a possible leak, old value of name is unreachable, but I
|
||||
currently don't know how to fix it. */
|
||||
name = lname;
|
||||
}
|
||||
#endif
|
||||
|
||||
file_key.hname = name;
|
||||
file_slot = (struct file **) hash_find_slot (&files, &file_key);
|
||||
f = *file_slot;
|
||||
if (! HASH_VACANT (f) && !f->double_colon)
|
||||
{
|
||||
#if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
|
||||
free(lname);
|
||||
#endif
|
||||
return f;
|
||||
}
|
||||
|
||||
new = (struct file *) xmalloc (sizeof (struct file));
|
||||
bzero ((char *) new, sizeof (struct file));
|
||||
new->name = new->hname = name;
|
||||
new->update_status = -1;
|
||||
|
||||
if (HASH_VACANT (f))
|
||||
hash_insert_at (&files, new, file_slot);
|
||||
else
|
||||
{
|
||||
/* There is already a double-colon entry for this file. */
|
||||
new->double_colon = f;
|
||||
while (f->prev != 0)
|
||||
f = f->prev;
|
||||
f->prev = new;
|
||||
}
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
/* Rename FILE to NAME. This is not as simple as resetting
|
||||
the `name' member, since it must be put in a new hash bucket,
|
||||
and possibly merged with an existing file called NAME. */
|
||||
|
||||
void
|
||||
rename_file (from_file, to_hname)
|
||||
register struct file *from_file;
|
||||
char *to_hname;
|
||||
{
|
||||
rehash_file (from_file, to_hname);
|
||||
while (from_file)
|
||||
{
|
||||
from_file->name = from_file->hname;
|
||||
from_file = from_file->prev;
|
||||
}
|
||||
}
|
||||
|
||||
/* Rehash FILE to NAME. This is not as simple as resetting
|
||||
the `hname' member, since it must be put in a new hash bucket,
|
||||
and possibly merged with an existing file called NAME. */
|
||||
|
||||
void
|
||||
rehash_file (from_file, to_hname)
|
||||
register struct file *from_file;
|
||||
char *to_hname;
|
||||
{
|
||||
struct file file_key;
|
||||
struct file **file_slot;
|
||||
struct file *to_file;
|
||||
struct file *deleted_file;
|
||||
struct file *f;
|
||||
|
||||
file_key.hname = to_hname;
|
||||
if (0 == file_hash_cmp (from_file, &file_key))
|
||||
return;
|
||||
|
||||
file_key.hname = from_file->hname;
|
||||
while (from_file->renamed != 0)
|
||||
from_file = from_file->renamed;
|
||||
if (file_hash_cmp (from_file, &file_key))
|
||||
/* hname changed unexpectedly */
|
||||
abort ();
|
||||
|
||||
deleted_file = hash_delete (&files, from_file);
|
||||
if (deleted_file != from_file)
|
||||
/* from_file isn't the one stored in files */
|
||||
abort ();
|
||||
|
||||
file_key.hname = to_hname;
|
||||
file_slot = (struct file **) hash_find_slot (&files, &file_key);
|
||||
to_file = *file_slot;
|
||||
|
||||
from_file->hname = to_hname;
|
||||
for (f = from_file->double_colon; f != 0; f = f->prev)
|
||||
f->hname = to_hname;
|
||||
|
||||
if (HASH_VACANT (to_file))
|
||||
hash_insert_at (&files, from_file, file_slot);
|
||||
else
|
||||
{
|
||||
/* TO_FILE already exists under TO_HNAME.
|
||||
We must retain TO_FILE and merge FROM_FILE into it. */
|
||||
|
||||
if (from_file->cmds != 0)
|
||||
{
|
||||
if (to_file->cmds == 0)
|
||||
to_file->cmds = from_file->cmds;
|
||||
else if (from_file->cmds != to_file->cmds)
|
||||
{
|
||||
/* We have two sets of commands. We will go with the
|
||||
one given in the rule explicitly mentioning this name,
|
||||
but give a message to let the user know what's going on. */
|
||||
if (to_file->cmds->fileinfo.filenm != 0)
|
||||
error (&from_file->cmds->fileinfo,
|
||||
_("Commands were specified for file `%s' at %s:%lu,"),
|
||||
from_file->name, to_file->cmds->fileinfo.filenm,
|
||||
to_file->cmds->fileinfo.lineno);
|
||||
else
|
||||
error (&from_file->cmds->fileinfo,
|
||||
_("Commands for file `%s' were found by implicit rule search,"),
|
||||
from_file->name);
|
||||
error (&from_file->cmds->fileinfo,
|
||||
_("but `%s' is now considered the same file as `%s'."),
|
||||
from_file->name, to_hname);
|
||||
error (&from_file->cmds->fileinfo,
|
||||
_("Commands for `%s' will be ignored in favor of those for `%s'."),
|
||||
to_hname, from_file->name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Merge the dependencies of the two files. */
|
||||
|
||||
if (to_file->deps == 0)
|
||||
to_file->deps = from_file->deps;
|
||||
else
|
||||
{
|
||||
register struct dep *deps = to_file->deps;
|
||||
while (deps->next != 0)
|
||||
deps = deps->next;
|
||||
deps->next = from_file->deps;
|
||||
}
|
||||
|
||||
merge_variable_set_lists (&to_file->variables, from_file->variables);
|
||||
|
||||
if (to_file->double_colon && from_file->is_target && !from_file->double_colon)
|
||||
fatal (NILF, _("can't rename single-colon `%s' to double-colon `%s'"),
|
||||
from_file->name, to_hname);
|
||||
if (!to_file->double_colon && from_file->double_colon)
|
||||
{
|
||||
if (to_file->is_target)
|
||||
fatal (NILF, _("can't rename double-colon `%s' to single-colon `%s'"),
|
||||
from_file->name, to_hname);
|
||||
else
|
||||
to_file->double_colon = from_file->double_colon;
|
||||
}
|
||||
|
||||
if (from_file->last_mtime > to_file->last_mtime)
|
||||
/* %%% Kludge so -W wins on a file that gets vpathized. */
|
||||
to_file->last_mtime = from_file->last_mtime;
|
||||
|
||||
to_file->mtime_before_update = from_file->mtime_before_update;
|
||||
|
||||
#define MERGE(field) to_file->field |= from_file->field
|
||||
MERGE (precious);
|
||||
MERGE (tried_implicit);
|
||||
MERGE (updating);
|
||||
MERGE (updated);
|
||||
MERGE (is_target);
|
||||
MERGE (cmd_target);
|
||||
MERGE (phony);
|
||||
MERGE (ignore_vpath);
|
||||
#undef MERGE
|
||||
|
||||
from_file->renamed = to_file;
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove all nonprecious intermediate files.
|
||||
If SIG is nonzero, this was caused by a fatal signal,
|
||||
meaning that a different message will be printed, and
|
||||
the message will go to stderr rather than stdout. */
|
||||
|
||||
void
|
||||
remove_intermediates (sig)
|
||||
int sig;
|
||||
{
|
||||
register struct file **file_slot;
|
||||
register struct file **file_end;
|
||||
int doneany = 0;
|
||||
|
||||
/* If there's no way we will ever remove anything anyway, punt early. */
|
||||
if (question_flag || touch_flag || all_secondary)
|
||||
return;
|
||||
|
||||
if (sig && just_print_flag)
|
||||
return;
|
||||
|
||||
file_slot = (struct file **) files.ht_vec;
|
||||
file_end = file_slot + files.ht_size;
|
||||
for ( ; file_slot < file_end; file_slot++)
|
||||
if (! HASH_VACANT (*file_slot))
|
||||
{
|
||||
register struct file *f = *file_slot;
|
||||
if (f->intermediate && (f->dontcare || !f->precious)
|
||||
&& !f->secondary && !f->cmd_target)
|
||||
{
|
||||
int status;
|
||||
if (f->update_status == -1)
|
||||
/* If nothing would have created this file yet,
|
||||
don't print an "rm" command for it. */
|
||||
continue;
|
||||
if (just_print_flag)
|
||||
status = 0;
|
||||
else
|
||||
{
|
||||
status = unlink (f->name);
|
||||
if (status < 0 && errno == ENOENT)
|
||||
continue;
|
||||
}
|
||||
if (!f->dontcare)
|
||||
{
|
||||
if (sig)
|
||||
error (NILF, _("*** Deleting intermediate file `%s'"), f->name);
|
||||
else
|
||||
{
|
||||
if (! doneany)
|
||||
DB (DB_BASIC, (_("Removing intermediate files...\n")));
|
||||
if (!silent_flag)
|
||||
{
|
||||
if (! doneany)
|
||||
{
|
||||
fputs ("rm ", stdout);
|
||||
doneany = 1;
|
||||
}
|
||||
else
|
||||
putchar (' ');
|
||||
fputs (f->name, stdout);
|
||||
fflush (stdout);
|
||||
}
|
||||
}
|
||||
if (status < 0)
|
||||
perror_with_name ("unlink: ", f->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (doneany && !sig)
|
||||
{
|
||||
putchar ('\n');
|
||||
fflush (stdout);
|
||||
}
|
||||
}
|
||||
|
||||
/* For each dependency of each file, make the `struct dep' point
|
||||
at the appropriate `struct file' (which may have to be created).
|
||||
|
||||
Also mark the files depended on by .PRECIOUS, .PHONY, .SILENT,
|
||||
and various other special targets. */
|
||||
|
||||
void
|
||||
snap_deps ()
|
||||
{
|
||||
register struct file *f;
|
||||
register struct file *f2;
|
||||
register struct dep *d;
|
||||
register struct file **file_slot_0;
|
||||
register struct file **file_slot;
|
||||
register struct file **file_end;
|
||||
|
||||
/* Enter each dependency name as a file. */
|
||||
/* We must use hash_dump (), because within this loop
|
||||
we might add new files to the table, possibly causing
|
||||
an in-situ table expansion. */
|
||||
file_slot_0 = (struct file **) hash_dump (&files, 0, 0);
|
||||
file_end = file_slot_0 + files.ht_fill;
|
||||
for (file_slot = file_slot_0; file_slot < file_end; file_slot++)
|
||||
for (f2 = *file_slot; f2 != 0; f2 = f2->prev)
|
||||
for (d = f2->deps; d != 0; d = d->next)
|
||||
if (d->name != 0)
|
||||
{
|
||||
d->file = lookup_file (d->name);
|
||||
if (d->file == 0)
|
||||
d->file = enter_file (d->name);
|
||||
else
|
||||
free (d->name);
|
||||
d->name = 0;
|
||||
}
|
||||
free (file_slot_0);
|
||||
|
||||
for (f = lookup_file (".PRECIOUS"); f != 0; f = f->prev)
|
||||
for (d = f->deps; d != 0; d = d->next)
|
||||
for (f2 = d->file; f2 != 0; f2 = f2->prev)
|
||||
f2->precious = 1;
|
||||
|
||||
for (f = lookup_file (".LOW_RESOLUTION_TIME"); f != 0; f = f->prev)
|
||||
for (d = f->deps; d != 0; d = d->next)
|
||||
for (f2 = d->file; f2 != 0; f2 = f2->prev)
|
||||
f2->low_resolution_time = 1;
|
||||
|
||||
for (f = lookup_file (".PHONY"); f != 0; f = f->prev)
|
||||
for (d = f->deps; d != 0; d = d->next)
|
||||
for (f2 = d->file; f2 != 0; f2 = f2->prev)
|
||||
{
|
||||
/* Mark this file as phony and nonexistent. */
|
||||
f2->phony = 1;
|
||||
f2->last_mtime = NONEXISTENT_MTIME;
|
||||
f2->mtime_before_update = NONEXISTENT_MTIME;
|
||||
}
|
||||
|
||||
for (f = lookup_file (".INTERMEDIATE"); f != 0; f = f->prev)
|
||||
{
|
||||
/* .INTERMEDIATE with deps listed
|
||||
marks those deps as intermediate files. */
|
||||
for (d = f->deps; d != 0; d = d->next)
|
||||
for (f2 = d->file; f2 != 0; f2 = f2->prev)
|
||||
f2->intermediate = 1;
|
||||
/* .INTERMEDIATE with no deps does nothing.
|
||||
Marking all files as intermediates is useless
|
||||
since the goal targets would be deleted after they are built. */
|
||||
}
|
||||
|
||||
for (f = lookup_file (".SECONDARY"); f != 0; f = f->prev)
|
||||
{
|
||||
/* .SECONDARY with deps listed
|
||||
marks those deps as intermediate files
|
||||
in that they don't get rebuilt if not actually needed;
|
||||
but unlike real intermediate files,
|
||||
these are not deleted after make finishes. */
|
||||
if (f->deps)
|
||||
for (d = f->deps; d != 0; d = d->next)
|
||||
for (f2 = d->file; f2 != 0; f2 = f2->prev)
|
||||
f2->intermediate = f2->secondary = 1;
|
||||
/* .SECONDARY with no deps listed marks *all* files that way. */
|
||||
else
|
||||
all_secondary = 1;
|
||||
}
|
||||
|
||||
f = lookup_file (".EXPORT_ALL_VARIABLES");
|
||||
if (f != 0 && f->is_target)
|
||||
export_all_variables = 1;
|
||||
|
||||
f = lookup_file (".IGNORE");
|
||||
if (f != 0 && f->is_target)
|
||||
{
|
||||
if (f->deps == 0)
|
||||
ignore_errors_flag = 1;
|
||||
else
|
||||
for (d = f->deps; d != 0; d = d->next)
|
||||
for (f2 = d->file; f2 != 0; f2 = f2->prev)
|
||||
f2->command_flags |= COMMANDS_NOERROR;
|
||||
}
|
||||
|
||||
f = lookup_file (".SILENT");
|
||||
if (f != 0 && f->is_target)
|
||||
{
|
||||
if (f->deps == 0)
|
||||
silent_flag = 1;
|
||||
else
|
||||
for (d = f->deps; d != 0; d = d->next)
|
||||
for (f2 = d->file; f2 != 0; f2 = f2->prev)
|
||||
f2->command_flags |= COMMANDS_SILENT;
|
||||
}
|
||||
|
||||
f = lookup_file (".POSIX");
|
||||
if (f != 0 && f->is_target)
|
||||
posix_pedantic = 1;
|
||||
|
||||
f = lookup_file (".NOTPARALLEL");
|
||||
if (f != 0 && f->is_target)
|
||||
not_parallel = 1;
|
||||
}
|
||||
|
||||
/* Set the `command_state' member of FILE and all its `also_make's. */
|
||||
|
||||
void
|
||||
set_command_state (file, state)
|
||||
struct file *file;
|
||||
int state;
|
||||
{
|
||||
struct dep *d;
|
||||
|
||||
file->command_state = state;
|
||||
|
||||
for (d = file->also_make; d != 0; d = d->next)
|
||||
d->file->command_state = state;
|
||||
}
|
||||
|
||||
/* Convert an external file timestamp to internal form. */
|
||||
|
||||
FILE_TIMESTAMP
|
||||
file_timestamp_cons (fname, s, ns)
|
||||
char const *fname;
|
||||
time_t s;
|
||||
int ns;
|
||||
{
|
||||
int offset = ORDINARY_MTIME_MIN + (FILE_TIMESTAMP_HI_RES ? ns : 0);
|
||||
FILE_TIMESTAMP product = (FILE_TIMESTAMP) s << FILE_TIMESTAMP_LO_BITS;
|
||||
FILE_TIMESTAMP ts = product + offset;
|
||||
|
||||
if (! (s <= FILE_TIMESTAMP_S (ORDINARY_MTIME_MAX)
|
||||
&& product <= ts && ts <= ORDINARY_MTIME_MAX))
|
||||
{
|
||||
char buf[FILE_TIMESTAMP_PRINT_LEN_BOUND + 1];
|
||||
ts = s <= OLD_MTIME ? ORDINARY_MTIME_MIN : ORDINARY_MTIME_MAX;
|
||||
file_timestamp_sprintf (buf, ts);
|
||||
error (NILF, _("%s: Timestamp out of range; substituting %s"),
|
||||
fname ? fname : _("Current time"), buf);
|
||||
}
|
||||
|
||||
return ts;
|
||||
}
|
||||
|
||||
/* Return the current time as a file timestamp, setting *RESOLUTION to
|
||||
its resolution. */
|
||||
FILE_TIMESTAMP
|
||||
file_timestamp_now (resolution)
|
||||
int *resolution;
|
||||
{
|
||||
int r;
|
||||
time_t s;
|
||||
int ns;
|
||||
|
||||
/* Don't bother with high-resolution clocks if file timestamps have
|
||||
only one-second resolution. The code below should work, but it's
|
||||
not worth the hassle of debugging it on hosts where it fails. */
|
||||
#if FILE_TIMESTAMP_HI_RES
|
||||
# if HAVE_CLOCK_GETTIME && defined CLOCK_REALTIME
|
||||
{
|
||||
struct timespec timespec;
|
||||
if (clock_gettime (CLOCK_REALTIME, ×pec) == 0)
|
||||
{
|
||||
r = 1;
|
||||
s = timespec.tv_sec;
|
||||
ns = timespec.tv_nsec;
|
||||
goto got_time;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
# if HAVE_GETTIMEOFDAY
|
||||
{
|
||||
struct timeval timeval;
|
||||
if (gettimeofday (&timeval, 0) == 0)
|
||||
{
|
||||
r = 1000;
|
||||
s = timeval.tv_sec;
|
||||
ns = timeval.tv_usec * 1000;
|
||||
goto got_time;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
r = 1000000000;
|
||||
s = time ((time_t *) 0);
|
||||
ns = 0;
|
||||
|
||||
got_time:
|
||||
*resolution = r;
|
||||
return file_timestamp_cons (0, s, ns);
|
||||
}
|
||||
|
||||
/* Place into the buffer P a printable representation of the file
|
||||
timestamp TS. */
|
||||
void
|
||||
file_timestamp_sprintf (p, ts)
|
||||
char *p;
|
||||
FILE_TIMESTAMP ts;
|
||||
{
|
||||
time_t t = FILE_TIMESTAMP_S (ts);
|
||||
struct tm *tm = localtime (&t);
|
||||
|
||||
if (tm)
|
||||
sprintf (p, "%04d-%02d-%02d %02d:%02d:%02d",
|
||||
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
else if (t < 0)
|
||||
sprintf (p, "%ld", (long) t);
|
||||
else
|
||||
sprintf (p, "%lu", (unsigned long) t);
|
||||
p += strlen (p);
|
||||
|
||||
/* Append nanoseconds as a fraction, but remove trailing zeros.
|
||||
We don't know the actual timestamp resolution, since clock_getres
|
||||
applies only to local times, whereas this timestamp might come
|
||||
from a remote filesystem. So removing trailing zeros is the
|
||||
best guess that we can do. */
|
||||
sprintf (p, ".%09d", FILE_TIMESTAMP_NS (ts));
|
||||
p += strlen (p) - 1;
|
||||
while (*p == '0')
|
||||
p--;
|
||||
p += *p != '.';
|
||||
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
/* Print the data base of files. */
|
||||
|
||||
static void
|
||||
print_file (f)
|
||||
struct file *f;
|
||||
{
|
||||
struct dep *d;
|
||||
struct dep *ood = 0;
|
||||
|
||||
putchar ('\n');
|
||||
if (!f->is_target)
|
||||
puts (_("# Not a target:"));
|
||||
printf ("%s:%s", f->name, f->double_colon ? ":" : "");
|
||||
|
||||
/* Print all normal dependencies; note any order-only deps. */
|
||||
for (d = f->deps; d != 0; d = d->next)
|
||||
if (! d->ignore_mtime)
|
||||
printf (" %s", dep_name (d));
|
||||
else if (! ood)
|
||||
ood = d;
|
||||
|
||||
/* Print order-only deps, if we have any. */
|
||||
if (ood)
|
||||
{
|
||||
printf (" | %s", dep_name (ood));
|
||||
for (d = ood->next; d != 0; d = d->next)
|
||||
if (d->ignore_mtime)
|
||||
printf (" %s", dep_name (d));
|
||||
}
|
||||
|
||||
putchar ('\n');
|
||||
|
||||
if (f->precious)
|
||||
puts (_("# Precious file (prerequisite of .PRECIOUS)."));
|
||||
if (f->phony)
|
||||
puts (_("# Phony target (prerequisite of .PHONY)."));
|
||||
if (f->cmd_target)
|
||||
puts (_("# Command-line target."));
|
||||
if (f->dontcare)
|
||||
puts (_("# A default or MAKEFILES makefile."));
|
||||
puts (f->tried_implicit
|
||||
? _("# Implicit rule search has been done.")
|
||||
: _("# Implicit rule search has not been done."));
|
||||
if (f->stem != 0)
|
||||
printf (_("# Implicit/static pattern stem: `%s'\n"), f->stem);
|
||||
if (f->intermediate)
|
||||
puts (_("# File is an intermediate prerequisite."));
|
||||
if (f->also_make != 0)
|
||||
{
|
||||
fputs (_("# Also makes:"), stdout);
|
||||
for (d = f->also_make; d != 0; d = d->next)
|
||||
printf (" %s", dep_name (d));
|
||||
putchar ('\n');
|
||||
}
|
||||
if (f->last_mtime == UNKNOWN_MTIME)
|
||||
puts (_("# Modification time never checked."));
|
||||
else if (f->last_mtime == NONEXISTENT_MTIME)
|
||||
puts (_("# File does not exist."));
|
||||
else if (f->last_mtime == OLD_MTIME)
|
||||
puts (_("# File is very old."));
|
||||
else
|
||||
{
|
||||
char buf[FILE_TIMESTAMP_PRINT_LEN_BOUND + 1];
|
||||
file_timestamp_sprintf (buf, f->last_mtime);
|
||||
printf (_("# Last modified %s\n"), buf);
|
||||
}
|
||||
puts (f->updated
|
||||
? _("# File has been updated.") : _("# File has not been updated."));
|
||||
switch (f->command_state)
|
||||
{
|
||||
case cs_running:
|
||||
puts (_("# Commands currently running (THIS IS A BUG)."));
|
||||
break;
|
||||
case cs_deps_running:
|
||||
puts (_("# Dependencies commands running (THIS IS A BUG)."));
|
||||
break;
|
||||
case cs_not_started:
|
||||
case cs_finished:
|
||||
switch (f->update_status)
|
||||
{
|
||||
case -1:
|
||||
break;
|
||||
case 0:
|
||||
puts (_("# Successfully updated."));
|
||||
break;
|
||||
case 1:
|
||||
assert (question_flag);
|
||||
puts (_("# Needs to be updated (-q is set)."));
|
||||
break;
|
||||
case 2:
|
||||
puts (_("# Failed to be updated."));
|
||||
break;
|
||||
default:
|
||||
puts (_("# Invalid value in `update_status' member!"));
|
||||
fflush (stdout);
|
||||
fflush (stderr);
|
||||
abort ();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
puts (_("# Invalid value in `command_state' member!"));
|
||||
fflush (stdout);
|
||||
fflush (stderr);
|
||||
abort ();
|
||||
}
|
||||
|
||||
if (f->variables != 0)
|
||||
print_file_variables (f);
|
||||
|
||||
if (f->cmds != 0)
|
||||
print_commands (f->cmds);
|
||||
}
|
||||
|
||||
void
|
||||
print_file_data_base ()
|
||||
{
|
||||
puts (_("\n# Files"));
|
||||
|
||||
hash_map (&files, print_file);
|
||||
|
||||
fputs (_("\n# files hash-table stats:\n# "), stdout);
|
||||
hash_print_stats (&files, stdout);
|
||||
}
|
||||
|
||||
#define EXPANSION_INCREMENT(_l) ((((_l) / 500) + 1) * 500)
|
||||
|
||||
char *
|
||||
build_target_list (value)
|
||||
char *value;
|
||||
{
|
||||
static unsigned long last_targ_count = 0;
|
||||
|
||||
if (files.ht_fill != last_targ_count)
|
||||
{
|
||||
unsigned long max = EXPANSION_INCREMENT (strlen (value));
|
||||
unsigned long len;
|
||||
char *p;
|
||||
struct file **fp = (struct file **) files.ht_vec;
|
||||
struct file **end = &fp[files.ht_size];
|
||||
|
||||
/* Make sure we have at least MAX bytes in the allocated buffer. */
|
||||
value = xrealloc (value, max);
|
||||
|
||||
p = value;
|
||||
len = 0;
|
||||
for (; fp < end; ++fp)
|
||||
if (!HASH_VACANT (*fp) && (*fp)->is_target)
|
||||
{
|
||||
struct file *f = *fp;
|
||||
int l = strlen (f->name);
|
||||
|
||||
len += l + 1;
|
||||
if (len > max)
|
||||
{
|
||||
unsigned long off = p - value;
|
||||
|
||||
max += EXPANSION_INCREMENT (l + 1);
|
||||
value = xrealloc (value, max);
|
||||
p = &value[off];
|
||||
}
|
||||
|
||||
bcopy (f->name, p, l);
|
||||
p += l;
|
||||
*(p++) = ' ';
|
||||
}
|
||||
*(p-1) = '\0';
|
||||
|
||||
last_targ_count = files.ht_fill;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void
|
||||
init_hash_files ()
|
||||
{
|
||||
hash_init (&files, 1000, file_hash_1, file_hash_2, file_hash_cmp);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
199
flaim/external/w32/make/filedef.h
vendored
Normal file
199
flaim/external/w32/make/filedef.h
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
/* Definition of target file data structures for GNU Make.
|
||||
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1997,
|
||||
2002 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
/* Structure that represents the info on one file
|
||||
that the makefile says how to make.
|
||||
All of these are chained together through `next'. */
|
||||
|
||||
#include "hash.h"
|
||||
|
||||
struct file
|
||||
{
|
||||
char *name;
|
||||
char *hname; /* Hashed filename */
|
||||
char *vpath; /* VPATH/vpath pathname */
|
||||
struct dep *deps; /* all dependencies, including duplicates */
|
||||
struct commands *cmds; /* Commands to execute for this target. */
|
||||
int command_flags; /* Flags OR'd in for cmds; see commands.h. */
|
||||
char *stem; /* Implicit stem, if an implicit
|
||||
rule has been used */
|
||||
struct dep *also_make; /* Targets that are made by making this. */
|
||||
FILE_TIMESTAMP last_mtime; /* File's modtime, if already known. */
|
||||
FILE_TIMESTAMP mtime_before_update; /* File's modtime before any updating
|
||||
has been performed. */
|
||||
struct file *prev; /* Previous entry for same file name;
|
||||
used when there are multiple double-colon
|
||||
entries for the same file. */
|
||||
|
||||
/* File that this file was renamed to. After any time that a
|
||||
file could be renamed, call `check_renamed' (below). */
|
||||
struct file *renamed;
|
||||
|
||||
/* List of variable sets used for this file. */
|
||||
struct variable_set_list *variables;
|
||||
|
||||
/* Pattern-specific variable reference for this target, or null if there
|
||||
isn't one. Also see the pat_searched flag, below. */
|
||||
struct variable_set_list *pat_variables;
|
||||
|
||||
/* Immediate dependent that caused this target to be remade,
|
||||
or nil if there isn't one. */
|
||||
struct file *parent;
|
||||
|
||||
/* For a double-colon entry, this is the first double-colon entry for
|
||||
the same file. Otherwise this is null. */
|
||||
struct file *double_colon;
|
||||
|
||||
short int update_status; /* Status of the last attempt to update,
|
||||
or -1 if none has been made. */
|
||||
|
||||
enum /* State of the commands. */
|
||||
{ /* Note: It is important that cs_not_started be zero. */
|
||||
cs_not_started, /* Not yet started. */
|
||||
cs_deps_running, /* Dep commands running. */
|
||||
cs_running, /* Commands running. */
|
||||
cs_finished /* Commands finished. */
|
||||
} command_state ENUM_BITFIELD (2);
|
||||
|
||||
unsigned int precious:1; /* Non-0 means don't delete file on quit */
|
||||
unsigned int low_resolution_time:1; /* Nonzero if this file's time stamp
|
||||
has only one-second resolution. */
|
||||
unsigned int tried_implicit:1; /* Nonzero if have searched
|
||||
for implicit rule for making
|
||||
this file; don't search again. */
|
||||
unsigned int updating:1; /* Nonzero while updating deps of this file */
|
||||
unsigned int updated:1; /* Nonzero if this file has been remade. */
|
||||
unsigned int is_target:1; /* Nonzero if file is described as target. */
|
||||
unsigned int cmd_target:1; /* Nonzero if file was given on cmd line. */
|
||||
unsigned int phony:1; /* Nonzero if this is a phony file
|
||||
i.e., a dependency of .PHONY. */
|
||||
unsigned int intermediate:1;/* Nonzero if this is an intermediate file. */
|
||||
/* Nonzero, for an intermediate file,
|
||||
means remove_intermediates should not delete it. */
|
||||
unsigned int secondary:1;
|
||||
unsigned int dontcare:1; /* Nonzero if no complaint is to be made if
|
||||
this target cannot be remade. */
|
||||
unsigned int ignore_vpath:1;/* Nonzero if we threw out VPATH name. */
|
||||
unsigned int pat_searched:1;/* Nonzero if we already searched for
|
||||
pattern-specific variables. */
|
||||
unsigned int considered:1; /* equal to `considered' if file has been
|
||||
considered on current scan of goal chain */
|
||||
};
|
||||
|
||||
|
||||
extern struct file *default_goal_file, *suffix_file, *default_file;
|
||||
|
||||
|
||||
extern struct file *lookup_file PARAMS ((char *name));
|
||||
extern struct file *enter_file PARAMS ((char *name));
|
||||
extern void remove_intermediates PARAMS ((int sig));
|
||||
extern void snap_deps PARAMS ((void));
|
||||
extern void rename_file PARAMS ((struct file *file, char *name));
|
||||
extern void rehash_file PARAMS ((struct file *file, char *name));
|
||||
extern void set_command_state PARAMS ((struct file *file, int state));
|
||||
extern void notice_finished_file PARAMS ((struct file *file));
|
||||
extern void init_hash_files PARAMS ((void));
|
||||
extern char *build_target_list PARAMS ((char *old_list));
|
||||
|
||||
#if FILE_TIMESTAMP_HI_RES
|
||||
# define FILE_TIMESTAMP_STAT_MODTIME(fname, st) \
|
||||
file_timestamp_cons (fname, (st).st_mtime, (st).st_mtim.ST_MTIM_NSEC)
|
||||
#else
|
||||
# define FILE_TIMESTAMP_STAT_MODTIME(fname, st) \
|
||||
file_timestamp_cons (fname, (st).st_mtime, 0)
|
||||
#endif
|
||||
|
||||
/* If FILE_TIMESTAMP is 64 bits (or more), use nanosecond resolution.
|
||||
(Multiply by 2**30 instead of by 10**9 to save time at the cost of
|
||||
slightly decreasing the number of available timestamps.) With
|
||||
64-bit FILE_TIMESTAMP, this stops working on 2514-05-30 01:53:04
|
||||
UTC, but by then uintmax_t should be larger than 64 bits. */
|
||||
#define FILE_TIMESTAMPS_PER_S (FILE_TIMESTAMP_HI_RES ? 1000000000 : 1)
|
||||
#define FILE_TIMESTAMP_LO_BITS (FILE_TIMESTAMP_HI_RES ? 30 : 0)
|
||||
|
||||
#define FILE_TIMESTAMP_S(ts) (((ts) - ORDINARY_MTIME_MIN) \
|
||||
>> FILE_TIMESTAMP_LO_BITS)
|
||||
#define FILE_TIMESTAMP_NS(ts) ((int) (((ts) - ORDINARY_MTIME_MIN) \
|
||||
& ((1 << FILE_TIMESTAMP_LO_BITS) - 1)))
|
||||
|
||||
/* Upper bound on length of string "YYYY-MM-DD HH:MM:SS.NNNNNNNNN"
|
||||
representing a file timestamp. The upper bound is not necessarily 19,
|
||||
since the year might be less than -999 or greater than 9999.
|
||||
|
||||
Subtract one for the sign bit if in case file timestamps can be negative;
|
||||
subtract FLOOR_LOG2_SECONDS_PER_YEAR to yield an upper bound on how many
|
||||
file timestamp bits might affect the year;
|
||||
302 / 1000 is log10 (2) rounded up;
|
||||
add one for integer division truncation;
|
||||
add one more for a minus sign if file timestamps can be negative;
|
||||
add 4 to allow for any 4-digit epoch year (e.g. 1970);
|
||||
add 25 to allow for "-MM-DD HH:MM:SS.NNNNNNNNN". */
|
||||
#define FLOOR_LOG2_SECONDS_PER_YEAR 24
|
||||
#define FILE_TIMESTAMP_PRINT_LEN_BOUND \
|
||||
(((sizeof (FILE_TIMESTAMP) * CHAR_BIT - 1 - FLOOR_LOG2_SECONDS_PER_YEAR) \
|
||||
* 302 / 1000) \
|
||||
+ 1 + 1 + 4 + 25)
|
||||
|
||||
extern FILE_TIMESTAMP file_timestamp_cons PARAMS ((char const *,
|
||||
time_t, int));
|
||||
extern FILE_TIMESTAMP file_timestamp_now PARAMS ((int *));
|
||||
extern void file_timestamp_sprintf PARAMS ((char *p, FILE_TIMESTAMP ts));
|
||||
|
||||
/* Return the mtime of file F (a struct file *), caching it.
|
||||
The value is NONEXISTENT_MTIME if the file does not exist. */
|
||||
#define file_mtime(f) file_mtime_1 ((f), 1)
|
||||
/* Return the mtime of file F (a struct file *), caching it.
|
||||
Don't search using vpath for the file--if it doesn't actually exist,
|
||||
we don't find it.
|
||||
The value is NONEXISTENT_MTIME if the file does not exist. */
|
||||
#define file_mtime_no_search(f) file_mtime_1 ((f), 0)
|
||||
extern FILE_TIMESTAMP f_mtime PARAMS ((struct file *file, int search));
|
||||
#define file_mtime_1(f, v) \
|
||||
((f)->last_mtime == UNKNOWN_MTIME ? f_mtime ((f), v) : (f)->last_mtime)
|
||||
|
||||
/* Special timestamp values. */
|
||||
|
||||
/* The file's timestamp is not yet known. */
|
||||
#define UNKNOWN_MTIME 0
|
||||
|
||||
/* The file does not exist. */
|
||||
#define NONEXISTENT_MTIME 1
|
||||
|
||||
/* The file does not exist, and we assume that it is older than any
|
||||
actual file. */
|
||||
#define OLD_MTIME 2
|
||||
|
||||
/* The smallest and largest ordinary timestamps. */
|
||||
#define ORDINARY_MTIME_MIN (OLD_MTIME + 1)
|
||||
#define ORDINARY_MTIME_MAX ((FILE_TIMESTAMP_S (NEW_MTIME) \
|
||||
<< FILE_TIMESTAMP_LO_BITS) \
|
||||
+ ORDINARY_MTIME_MIN + FILE_TIMESTAMPS_PER_S - 1)
|
||||
|
||||
/* Modtime value to use for `infinitely new'. We used to get the current time
|
||||
from the system and use that whenever we wanted `new'. But that causes
|
||||
trouble when the machine running make and the machine holding a file have
|
||||
different ideas about what time it is; and can also lose for `force'
|
||||
targets, which need to be considered newer than anything that depends on
|
||||
them, even if said dependents' modtimes are in the future. */
|
||||
#define NEW_MTIME INTEGER_TYPE_MAXIMUM (FILE_TIMESTAMP)
|
||||
|
||||
#define check_renamed(file) \
|
||||
while ((file)->renamed != 0) (file) = (file)->renamed /* No ; here. */
|
||||
488
flaim/external/w32/make/fnmatch.c
vendored
Normal file
488
flaim/external/w32/make/fnmatch.c
vendored
Normal file
@@ -0,0 +1,488 @@
|
||||
/* Copyright (C) 1991, 92, 93, 96, 97, 98, 99 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Enable GNU extensions in fnmatch.h. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <fnmatch.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if HAVE_STRING_H || defined _LIBC
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#if defined STDC_HEADERS || defined _LIBC
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/* For platform which support the ISO C amendement 1 functionality we
|
||||
support user defined character classes. */
|
||||
#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
|
||||
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
|
||||
# include <wchar.h>
|
||||
# include <wctype.h>
|
||||
#endif
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object files,
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#if defined _LIBC || !defined __GNU_LIBRARY__
|
||||
|
||||
|
||||
# if defined STDC_HEADERS || !defined isascii
|
||||
# define ISASCII(c) 1
|
||||
# else
|
||||
# define ISASCII(c) isascii(c)
|
||||
# endif
|
||||
|
||||
# ifdef isblank
|
||||
# define ISBLANK(c) (ISASCII (c) && isblank (c))
|
||||
# else
|
||||
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
|
||||
# endif
|
||||
# ifdef isgraph
|
||||
# define ISGRAPH(c) (ISASCII (c) && isgraph (c))
|
||||
# else
|
||||
# define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
|
||||
# endif
|
||||
|
||||
# define ISPRINT(c) (ISASCII (c) && isprint (c))
|
||||
# define ISDIGIT(c) (ISASCII (c) && isdigit (c))
|
||||
# define ISALNUM(c) (ISASCII (c) && isalnum (c))
|
||||
# define ISALPHA(c) (ISASCII (c) && isalpha (c))
|
||||
# define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
|
||||
# define ISLOWER(c) (ISASCII (c) && islower (c))
|
||||
# define ISPUNCT(c) (ISASCII (c) && ispunct (c))
|
||||
# define ISSPACE(c) (ISASCII (c) && isspace (c))
|
||||
# define ISUPPER(c) (ISASCII (c) && isupper (c))
|
||||
# define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
|
||||
|
||||
# define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
|
||||
|
||||
# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
|
||||
/* The GNU C library provides support for user-defined character classes
|
||||
and the functions from ISO C amendement 1. */
|
||||
# ifdef CHARCLASS_NAME_MAX
|
||||
# define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
|
||||
# else
|
||||
/* This shouldn't happen but some implementation might still have this
|
||||
problem. Use a reasonable default value. */
|
||||
# define CHAR_CLASS_MAX_LENGTH 256
|
||||
# endif
|
||||
|
||||
# ifdef _LIBC
|
||||
# define IS_CHAR_CLASS(string) __wctype (string)
|
||||
# else
|
||||
# define IS_CHAR_CLASS(string) wctype (string)
|
||||
# endif
|
||||
# else
|
||||
# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
|
||||
|
||||
# define IS_CHAR_CLASS(string) \
|
||||
(STREQ (string, "alpha") || STREQ (string, "upper") \
|
||||
|| STREQ (string, "lower") || STREQ (string, "digit") \
|
||||
|| STREQ (string, "alnum") || STREQ (string, "xdigit") \
|
||||
|| STREQ (string, "space") || STREQ (string, "print") \
|
||||
|| STREQ (string, "punct") || STREQ (string, "graph") \
|
||||
|| STREQ (string, "cntrl") || STREQ (string, "blank"))
|
||||
# endif
|
||||
|
||||
/* Avoid depending on library functions or files
|
||||
whose names are inconsistent. */
|
||||
|
||||
# if !defined _LIBC && !defined getenv
|
||||
extern char *getenv ();
|
||||
# endif
|
||||
|
||||
# ifndef errno
|
||||
extern int errno;
|
||||
# endif
|
||||
|
||||
/* This function doesn't exist on most systems. */
|
||||
|
||||
# if !defined HAVE___STRCHRNUL && !defined _LIBC
|
||||
static char *
|
||||
__strchrnul (s, c)
|
||||
const char *s;
|
||||
int c;
|
||||
{
|
||||
char *result = strchr (s, c);
|
||||
if (result == NULL)
|
||||
result = strchr (s, '\0');
|
||||
return result;
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifndef internal_function
|
||||
/* Inside GNU libc we mark some function in a special way. In other
|
||||
environments simply ignore the marking. */
|
||||
# define internal_function
|
||||
# endif
|
||||
|
||||
/* Match STRING against the filename pattern PATTERN, returning zero if
|
||||
it matches, nonzero if not. */
|
||||
static int internal_fnmatch __P ((const char *pattern, const char *string,
|
||||
int no_leading_period, int flags))
|
||||
internal_function;
|
||||
static int
|
||||
internal_function
|
||||
internal_fnmatch (pattern, string, no_leading_period, flags)
|
||||
const char *pattern;
|
||||
const char *string;
|
||||
int no_leading_period;
|
||||
int flags;
|
||||
{
|
||||
register const char *p = pattern, *n = string;
|
||||
register unsigned char c;
|
||||
|
||||
/* Note that this evaluates C many times. */
|
||||
# ifdef _LIBC
|
||||
# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
|
||||
# else
|
||||
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
|
||||
# endif
|
||||
|
||||
while ((c = *p++) != '\0')
|
||||
{
|
||||
c = FOLD (c);
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '?':
|
||||
if (*n == '\0')
|
||||
return FNM_NOMATCH;
|
||||
else if (*n == '/' && (flags & FNM_FILE_NAME))
|
||||
return FNM_NOMATCH;
|
||||
else if (*n == '.' && no_leading_period
|
||||
&& (n == string
|
||||
|| (n[-1] == '/' && (flags & FNM_FILE_NAME))))
|
||||
return FNM_NOMATCH;
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
if (!(flags & FNM_NOESCAPE))
|
||||
{
|
||||
c = *p++;
|
||||
if (c == '\0')
|
||||
/* Trailing \ loses. */
|
||||
return FNM_NOMATCH;
|
||||
c = FOLD (c);
|
||||
}
|
||||
if (FOLD ((unsigned char) *n) != c)
|
||||
return FNM_NOMATCH;
|
||||
break;
|
||||
|
||||
case '*':
|
||||
if (*n == '.' && no_leading_period
|
||||
&& (n == string
|
||||
|| (n[-1] == '/' && (flags & FNM_FILE_NAME))))
|
||||
return FNM_NOMATCH;
|
||||
|
||||
for (c = *p++; c == '?' || c == '*'; c = *p++)
|
||||
{
|
||||
if (*n == '/' && (flags & FNM_FILE_NAME))
|
||||
/* A slash does not match a wildcard under FNM_FILE_NAME. */
|
||||
return FNM_NOMATCH;
|
||||
else if (c == '?')
|
||||
{
|
||||
/* A ? needs to match one character. */
|
||||
if (*n == '\0')
|
||||
/* There isn't another character; no match. */
|
||||
return FNM_NOMATCH;
|
||||
else
|
||||
/* One character of the string is consumed in matching
|
||||
this ? wildcard, so *??? won't match if there are
|
||||
less than three characters. */
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
if (c == '\0')
|
||||
/* The wildcard(s) is/are the last element of the pattern.
|
||||
If the name is a file name and contains another slash
|
||||
this does mean it cannot match. */
|
||||
return ((flags & FNM_FILE_NAME) && strchr (n, '/') != NULL
|
||||
? FNM_NOMATCH : 0);
|
||||
else
|
||||
{
|
||||
const char *endp;
|
||||
|
||||
endp = __strchrnul (n, (flags & FNM_FILE_NAME) ? '/' : '\0');
|
||||
|
||||
if (c == '[')
|
||||
{
|
||||
int flags2 = ((flags & FNM_FILE_NAME)
|
||||
? flags : (flags & ~FNM_PERIOD));
|
||||
|
||||
for (--p; n < endp; ++n)
|
||||
if (internal_fnmatch (p, n,
|
||||
(no_leading_period
|
||||
&& (n == string
|
||||
|| (n[-1] == '/'
|
||||
&& (flags
|
||||
& FNM_FILE_NAME)))),
|
||||
flags2)
|
||||
== 0)
|
||||
return 0;
|
||||
}
|
||||
else if (c == '/' && (flags & FNM_FILE_NAME))
|
||||
{
|
||||
while (*n != '\0' && *n != '/')
|
||||
++n;
|
||||
if (*n == '/'
|
||||
&& (internal_fnmatch (p, n + 1, flags & FNM_PERIOD,
|
||||
flags) == 0))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int flags2 = ((flags & FNM_FILE_NAME)
|
||||
? flags : (flags & ~FNM_PERIOD));
|
||||
|
||||
if (c == '\\' && !(flags & FNM_NOESCAPE))
|
||||
c = *p;
|
||||
c = FOLD (c);
|
||||
for (--p; n < endp; ++n)
|
||||
if (FOLD ((unsigned char) *n) == c
|
||||
&& (internal_fnmatch (p, n,
|
||||
(no_leading_period
|
||||
&& (n == string
|
||||
|| (n[-1] == '/'
|
||||
&& (flags
|
||||
& FNM_FILE_NAME)))),
|
||||
flags2) == 0))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we come here no match is possible with the wildcard. */
|
||||
return FNM_NOMATCH;
|
||||
|
||||
case '[':
|
||||
{
|
||||
/* Nonzero if the sense of the character class is inverted. */
|
||||
static int posixly_correct;
|
||||
register int not;
|
||||
char cold;
|
||||
|
||||
if (posixly_correct == 0)
|
||||
posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
|
||||
|
||||
if (*n == '\0')
|
||||
return FNM_NOMATCH;
|
||||
|
||||
if (*n == '.' && no_leading_period && (n == string
|
||||
|| (n[-1] == '/'
|
||||
&& (flags
|
||||
& FNM_FILE_NAME))))
|
||||
return FNM_NOMATCH;
|
||||
|
||||
if (*n == '/' && (flags & FNM_FILE_NAME))
|
||||
/* `/' cannot be matched. */
|
||||
return FNM_NOMATCH;
|
||||
|
||||
not = (*p == '!' || (posixly_correct < 0 && *p == '^'));
|
||||
if (not)
|
||||
++p;
|
||||
|
||||
c = *p++;
|
||||
for (;;)
|
||||
{
|
||||
unsigned char fn = FOLD ((unsigned char) *n);
|
||||
|
||||
if (!(flags & FNM_NOESCAPE) && c == '\\')
|
||||
{
|
||||
if (*p == '\0')
|
||||
return FNM_NOMATCH;
|
||||
c = FOLD ((unsigned char) *p);
|
||||
++p;
|
||||
|
||||
if (c == fn)
|
||||
goto matched;
|
||||
}
|
||||
else if (c == '[' && *p == ':')
|
||||
{
|
||||
/* Leave room for the null. */
|
||||
char str[CHAR_CLASS_MAX_LENGTH + 1];
|
||||
size_t c1 = 0;
|
||||
# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
|
||||
wctype_t wt;
|
||||
# endif
|
||||
const char *startp = p;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (c1 == CHAR_CLASS_MAX_LENGTH)
|
||||
/* The name is too long and therefore the pattern
|
||||
is ill-formed. */
|
||||
return FNM_NOMATCH;
|
||||
|
||||
c = *++p;
|
||||
if (c == ':' && p[1] == ']')
|
||||
{
|
||||
p += 2;
|
||||
break;
|
||||
}
|
||||
if (c < 'a' || c >= 'z')
|
||||
{
|
||||
/* This cannot possibly be a character class name.
|
||||
Match it as a normal range. */
|
||||
p = startp;
|
||||
c = '[';
|
||||
goto normal_bracket;
|
||||
}
|
||||
str[c1++] = c;
|
||||
}
|
||||
str[c1] = '\0';
|
||||
|
||||
# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
|
||||
wt = IS_CHAR_CLASS (str);
|
||||
if (wt == 0)
|
||||
/* Invalid character class name. */
|
||||
return FNM_NOMATCH;
|
||||
|
||||
if (__iswctype (__btowc ((unsigned char) *n), wt))
|
||||
goto matched;
|
||||
# else
|
||||
if ((STREQ (str, "alnum") && ISALNUM ((unsigned char) *n))
|
||||
|| (STREQ (str, "alpha") && ISALPHA ((unsigned char) *n))
|
||||
|| (STREQ (str, "blank") && ISBLANK ((unsigned char) *n))
|
||||
|| (STREQ (str, "cntrl") && ISCNTRL ((unsigned char) *n))
|
||||
|| (STREQ (str, "digit") && ISDIGIT ((unsigned char) *n))
|
||||
|| (STREQ (str, "graph") && ISGRAPH ((unsigned char) *n))
|
||||
|| (STREQ (str, "lower") && ISLOWER ((unsigned char) *n))
|
||||
|| (STREQ (str, "print") && ISPRINT ((unsigned char) *n))
|
||||
|| (STREQ (str, "punct") && ISPUNCT ((unsigned char) *n))
|
||||
|| (STREQ (str, "space") && ISSPACE ((unsigned char) *n))
|
||||
|| (STREQ (str, "upper") && ISUPPER ((unsigned char) *n))
|
||||
|| (STREQ (str, "xdigit") && ISXDIGIT ((unsigned char) *n)))
|
||||
goto matched;
|
||||
# endif
|
||||
}
|
||||
else if (c == '\0')
|
||||
/* [ (unterminated) loses. */
|
||||
return FNM_NOMATCH;
|
||||
else
|
||||
{
|
||||
normal_bracket:
|
||||
if (FOLD (c) == fn)
|
||||
goto matched;
|
||||
|
||||
cold = c;
|
||||
c = *p++;
|
||||
|
||||
if (c == '-' && *p != ']')
|
||||
{
|
||||
/* It is a range. */
|
||||
unsigned char cend = *p++;
|
||||
if (!(flags & FNM_NOESCAPE) && cend == '\\')
|
||||
cend = *p++;
|
||||
if (cend == '\0')
|
||||
return FNM_NOMATCH;
|
||||
|
||||
if (cold <= fn && fn <= FOLD (cend))
|
||||
goto matched;
|
||||
|
||||
c = *p++;
|
||||
}
|
||||
}
|
||||
|
||||
if (c == ']')
|
||||
break;
|
||||
}
|
||||
|
||||
if (!not)
|
||||
return FNM_NOMATCH;
|
||||
break;
|
||||
|
||||
matched:
|
||||
/* Skip the rest of the [...] that already matched. */
|
||||
while (c != ']')
|
||||
{
|
||||
if (c == '\0')
|
||||
/* [... (unterminated) loses. */
|
||||
return FNM_NOMATCH;
|
||||
|
||||
c = *p++;
|
||||
if (!(flags & FNM_NOESCAPE) && c == '\\')
|
||||
{
|
||||
if (*p == '\0')
|
||||
return FNM_NOMATCH;
|
||||
/* XXX 1003.2d11 is unclear if this is right. */
|
||||
++p;
|
||||
}
|
||||
else if (c == '[' && *p == ':')
|
||||
{
|
||||
do
|
||||
if (*++p == '\0')
|
||||
return FNM_NOMATCH;
|
||||
while (*p != ':' || p[1] == ']');
|
||||
p += 2;
|
||||
c = *p;
|
||||
}
|
||||
}
|
||||
if (not)
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (c != FOLD ((unsigned char) *n))
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
++n;
|
||||
}
|
||||
|
||||
if (*n == '\0')
|
||||
return 0;
|
||||
|
||||
if ((flags & FNM_LEADING_DIR) && *n == '/')
|
||||
/* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */
|
||||
return 0;
|
||||
|
||||
return FNM_NOMATCH;
|
||||
|
||||
# undef FOLD
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
fnmatch (pattern, string, flags)
|
||||
const char *pattern;
|
||||
const char *string;
|
||||
int flags;
|
||||
{
|
||||
return internal_fnmatch (pattern, string, flags & FNM_PERIOD, flags);
|
||||
}
|
||||
|
||||
#endif /* _LIBC or not __GNU_LIBRARY__. */
|
||||
84
flaim/external/w32/make/fnmatch.h
vendored
Normal file
84
flaim/external/w32/make/fnmatch.h
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/* Copyright (C) 1991, 92, 93, 96, 97, 98, 99 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _FNMATCH_H
|
||||
#define _FNMATCH_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32
|
||||
# if !defined __GLIBC__ || !defined __P
|
||||
# undef __P
|
||||
# define __P(protos) protos
|
||||
# endif
|
||||
#else /* Not C++ or ANSI C. */
|
||||
# undef __P
|
||||
# define __P(protos) ()
|
||||
/* We can get away without defining `const' here only because in this file
|
||||
it is used only inside the prototype for `fnmatch', which is elided in
|
||||
non-ANSI C where `const' is problematical. */
|
||||
#endif /* C++ or ANSI C. */
|
||||
|
||||
#ifndef const
|
||||
# if (defined __STDC__ && __STDC__) || defined __cplusplus
|
||||
# define __const const
|
||||
# else
|
||||
# define __const
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* We #undef these before defining them because some losing systems
|
||||
(HP-UX A.08.07 for example) define these in <unistd.h>. */
|
||||
#undef FNM_PATHNAME
|
||||
#undef FNM_NOESCAPE
|
||||
#undef FNM_PERIOD
|
||||
|
||||
/* Bits set in the FLAGS argument to `fnmatch'. */
|
||||
#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
|
||||
#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
|
||||
#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
|
||||
|
||||
#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
|
||||
# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
|
||||
# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
|
||||
# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
|
||||
#endif
|
||||
|
||||
/* Value returned by `fnmatch' if STRING does not match PATTERN. */
|
||||
#define FNM_NOMATCH 1
|
||||
|
||||
/* This value is returned if the implementation does not support
|
||||
`fnmatch'. Since this is not the case here it will never be
|
||||
returned but the conformance test suites still require the symbol
|
||||
to be defined. */
|
||||
#ifdef _XOPEN_SOURCE
|
||||
# define FNM_NOSYS (-1)
|
||||
#endif
|
||||
|
||||
/* Match NAME against the filename pattern PATTERN,
|
||||
returning zero if it matches, FNM_NOMATCH if not. */
|
||||
extern int fnmatch __P ((__const char *__pattern, __const char *__name,
|
||||
int __flags));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* fnmatch.h */
|
||||
2076
flaim/external/w32/make/function.c
vendored
Normal file
2076
flaim/external/w32/make/function.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1034
flaim/external/w32/make/getloadavg.c
vendored
Normal file
1034
flaim/external/w32/make/getloadavg.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1047
flaim/external/w32/make/getopt.c
vendored
Normal file
1047
flaim/external/w32/make/getopt.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
133
flaim/external/w32/make/getopt.h
vendored
Normal file
133
flaim/external/w32/make/getopt.h
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
/* Declarations for getopt.
|
||||
Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@gnu.org.
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
#define _GETOPT_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
extern char *optarg;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns -1, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int optopt;
|
||||
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
||||
of `struct option' terminated by an element containing a name which is
|
||||
zero.
|
||||
|
||||
The field `has_arg' is:
|
||||
no_argument (or 0) if the option does not take an argument,
|
||||
required_argument (or 1) if the option requires an argument,
|
||||
optional_argument (or 2) if the option takes an optional argument.
|
||||
|
||||
If the field `flag' is not NULL, it points to a variable that is set
|
||||
to the value given in the field `val' when the option is found, but
|
||||
left unchanged if the option is not found.
|
||||
|
||||
To have a long-named option do something other than set an `int' to
|
||||
a compiled-in constant, such as set a value from `optarg', set the
|
||||
option's `flag' field to zero and its `val' field to a nonzero
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero `flag' field, `getopt'
|
||||
returns the contents of the `val' field. */
|
||||
|
||||
struct option
|
||||
{
|
||||
#if defined (__STDC__) && __STDC__
|
||||
const char *name;
|
||||
#else
|
||||
char *name;
|
||||
#endif
|
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||
|
||||
#define no_argument 0
|
||||
#define required_argument 1
|
||||
#define optional_argument 2
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* Many other libraries have conflicting prototypes for getopt, with
|
||||
differences in the consts, in stdlib.h. To avoid compilation
|
||||
errors, only prototype getopt for the GNU C library. */
|
||||
extern int getopt (int argc, char *const *argv, const char *shortopts);
|
||||
#else /* not __GNU_LIBRARY__ */
|
||||
extern int getopt ();
|
||||
#endif /* __GNU_LIBRARY__ */
|
||||
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
extern int getopt_long_only (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
|
||||
/* Internal only. Users should not call this directly. */
|
||||
extern int _getopt_internal (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind,
|
||||
int long_only);
|
||||
#else /* not __STDC__ */
|
||||
extern int getopt ();
|
||||
extern int getopt_long ();
|
||||
extern int getopt_long_only ();
|
||||
|
||||
extern int _getopt_internal ();
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* getopt.h */
|
||||
190
flaim/external/w32/make/getopt1.c
vendored
Normal file
190
flaim/external/w32/make/getopt1.c
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@gnu.org.
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
#if !defined __STDC__ || !__STDC__
|
||||
/* This is a separate conditional since some stdc systems
|
||||
reject `defined (const)'. */
|
||||
#ifndef const
|
||||
#define const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object files,
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#define GETOPT_INTERFACE_VERSION 2
|
||||
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
|
||||
#include <gnu-versions.h>
|
||||
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
|
||||
#define ELIDE_CODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ELIDE_CODE
|
||||
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
int
|
||||
getopt_long (argc, argv, options, long_options, opt_index)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *options;
|
||||
const struct option *long_options;
|
||||
int *opt_index;
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
|
||||
}
|
||||
|
||||
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
||||
If an option that starts with '-' (not '--') doesn't match a long option,
|
||||
but does match a short option, it is parsed as a short option
|
||||
instead. */
|
||||
|
||||
int
|
||||
getopt_long_only (argc, argv, options, long_options, opt_index)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *options;
|
||||
const struct option *long_options;
|
||||
int *opt_index;
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
|
||||
}
|
||||
|
||||
|
||||
#endif /* Not ELIDE_CODE. */
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int c;
|
||||
int digit_optind = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
int option_index = 0;
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"add", 1, 0, 0},
|
||||
{"append", 0, 0, 0},
|
||||
{"delete", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"create", 0, 0, 0},
|
||||
{"file", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long (argc, argv, "abc:d:0123456789",
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
printf ("option %s", long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
printf ("option d with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
||||
59
flaim/external/w32/make/gettext.h
vendored
Normal file
59
flaim/external/w32/make/gettext.h
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/* Convenience header for conditional use of GNU <libintl.h>.
|
||||
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
by the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifndef _LIBGETTEXT_H
|
||||
#define _LIBGETTEXT_H 1
|
||||
|
||||
/* NLS can be disabled through the configure --disable-nls option. */
|
||||
#if ENABLE_NLS
|
||||
|
||||
/* Get declarations of GNU message catalog functions. */
|
||||
# include <libintl.h>
|
||||
|
||||
#else
|
||||
|
||||
/* Disabled NLS.
|
||||
The casts to 'const char *' serve the purpose of producing warnings
|
||||
for invalid uses of the value returned from these functions.
|
||||
On pre-ANSI systems without 'const', the config.h file is supposed to
|
||||
contain "#define const". */
|
||||
# define gettext(Msgid) ((const char *) (Msgid))
|
||||
# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
|
||||
# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
|
||||
# define ngettext(Msgid1, Msgid2, N) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define dngettext(Domainname, Msgid1, Msgid2, N) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define textdomain(Domainname) ((const char *) (Domainname))
|
||||
# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
|
||||
# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
|
||||
|
||||
#endif
|
||||
|
||||
/* A pseudo function call that serves as a marker for the automated
|
||||
extraction of messages, but does not call gettext(). The run-time
|
||||
translation is done at a different place in the code.
|
||||
The argument, String, should be a literal string. Concatenated strings
|
||||
and other string expressions won't work.
|
||||
The macro's expansion is not parenthesized, so that it is suitable as
|
||||
initializer for static 'char[]' or 'const char[]' variables. */
|
||||
#define gettext_noop(String) String
|
||||
|
||||
#endif /* _LIBGETTEXT_H */
|
||||
1425
flaim/external/w32/make/glob.c
vendored
Normal file
1425
flaim/external/w32/make/glob.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
205
flaim/external/w32/make/glob.h
vendored
Normal file
205
flaim/external/w32/make/glob.h
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
/* Copyright (C) 1991, 92, 95, 96, 97, 98 Free Software Foundation, Inc.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _GLOB_H
|
||||
#define _GLOB_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#undef __ptr_t
|
||||
#if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32
|
||||
# if !defined __GLIBC__ || !defined __P
|
||||
# undef __P
|
||||
# undef __PMT
|
||||
# define __P(protos) protos
|
||||
# define __PMT(protos) protos
|
||||
# if !defined __GNUC__ || __GNUC__ < 2
|
||||
# undef __const
|
||||
# define __const const
|
||||
# endif
|
||||
# endif
|
||||
# define __ptr_t void *
|
||||
#else /* Not C++ or ANSI C. */
|
||||
# undef __P
|
||||
# undef __PMT
|
||||
# define __P(protos) ()
|
||||
# define __PMT(protos) ()
|
||||
# undef __const
|
||||
# define __const
|
||||
# define __ptr_t char *
|
||||
#endif /* C++ or ANSI C. */
|
||||
|
||||
/* We need `size_t' for the following definitions. */
|
||||
#ifndef __size_t
|
||||
# if defined __GNUC__ && __GNUC__ >= 2
|
||||
typedef __SIZE_TYPE__ __size_t;
|
||||
# else
|
||||
/* This is a guess. */
|
||||
/*hb
|
||||
* Conflicts with DECCs aready defined type __size_t.
|
||||
* Defining an own type with a name beginning with '__' is no good.
|
||||
* Anyway if DECC is used and __SIZE_T is defined then __size_t is
|
||||
* already defined (and I hope it's exactly the one we need here).
|
||||
*/
|
||||
#if !(defined __DECC && defined __SIZE_T)
|
||||
typedef unsigned long int __size_t;
|
||||
#endif
|
||||
# endif
|
||||
#else
|
||||
/* The GNU CC stddef.h version defines __size_t as empty. We need a real
|
||||
definition. */
|
||||
# undef __size_t
|
||||
# define __size_t size_t
|
||||
#endif
|
||||
|
||||
/* Bits set in the FLAGS argument to `glob'. */
|
||||
#define GLOB_ERR (1 << 0)/* Return on read errors. */
|
||||
#define GLOB_MARK (1 << 1)/* Append a slash to each name. */
|
||||
#define GLOB_NOSORT (1 << 2)/* Don't sort the names. */
|
||||
#define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */
|
||||
#define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */
|
||||
#define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */
|
||||
#define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */
|
||||
#define GLOB_PERIOD (1 << 7)/* Leading `.' can be matched by metachars. */
|
||||
|
||||
#if (!defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _BSD_SOURCE \
|
||||
|| defined _GNU_SOURCE)
|
||||
# define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */
|
||||
# define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */
|
||||
# define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */
|
||||
# define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */
|
||||
# define GLOB_TILDE (1 << 12)/* Expand ~user and ~ to home directories. */
|
||||
# define GLOB_ONLYDIR (1 << 13)/* Match only directories. */
|
||||
# define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error
|
||||
if the user name is not available. */
|
||||
# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
|
||||
GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
|
||||
GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \
|
||||
GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK)
|
||||
#else
|
||||
# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
|
||||
GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
|
||||
GLOB_PERIOD)
|
||||
#endif
|
||||
|
||||
/* Error returns from `glob'. */
|
||||
#define GLOB_NOSPACE 1 /* Ran out of memory. */
|
||||
#define GLOB_ABORTED 2 /* Read error. */
|
||||
#define GLOB_NOMATCH 3 /* No matches found. */
|
||||
#define GLOB_NOSYS 4 /* Not implemented. */
|
||||
#ifdef _GNU_SOURCE
|
||||
/* Previous versions of this file defined GLOB_ABEND instead of
|
||||
GLOB_ABORTED. Provide a compatibility definition here. */
|
||||
# define GLOB_ABEND GLOB_ABORTED
|
||||
#endif
|
||||
|
||||
/* Structure describing a globbing run. */
|
||||
#if !defined _AMIGA && !defined VMS /* Buggy compiler. */
|
||||
struct stat;
|
||||
#endif
|
||||
typedef struct
|
||||
{
|
||||
__size_t gl_pathc; /* Count of paths matched by the pattern. */
|
||||
char **gl_pathv; /* List of matched pathnames. */
|
||||
__size_t gl_offs; /* Slots to reserve in `gl_pathv'. */
|
||||
int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
|
||||
|
||||
/* If the GLOB_ALTDIRFUNC flag is set, the following functions
|
||||
are used instead of the normal file access functions. */
|
||||
void (*gl_closedir) __PMT ((void *));
|
||||
struct dirent *(*gl_readdir) __PMT ((void *));
|
||||
__ptr_t (*gl_opendir) __PMT ((__const char *));
|
||||
int (*gl_lstat) __PMT ((__const char *, struct stat *));
|
||||
#if defined(VMS) && defined(__DECC) && !defined(_POSIX_C_SOURCE)
|
||||
int (*gl_stat) __PMT ((__const char *, struct stat *, ...));
|
||||
#else
|
||||
int (*gl_stat) __PMT ((__const char *, struct stat *));
|
||||
#endif
|
||||
} glob_t;
|
||||
|
||||
#ifdef _LARGEFILE64_SOURCE
|
||||
struct stat64;
|
||||
typedef struct
|
||||
{
|
||||
__size_t gl_pathc;
|
||||
char **gl_pathv;
|
||||
__size_t gl_offs;
|
||||
int gl_flags;
|
||||
|
||||
/* If the GLOB_ALTDIRFUNC flag is set, the following functions
|
||||
are used instead of the normal file access functions. */
|
||||
void (*gl_closedir) __PMT ((void *));
|
||||
struct dirent64 *(*gl_readdir) __PMT ((void *));
|
||||
__ptr_t (*gl_opendir) __PMT ((__const char *));
|
||||
int (*gl_lstat) __PMT ((__const char *, struct stat64 *));
|
||||
int (*gl_stat) __PMT ((__const char *, struct stat64 *));
|
||||
} glob64_t;
|
||||
#endif
|
||||
|
||||
#if _FILE_OFFSET_BITS == 64 && __GNUC__ < 2
|
||||
# define glob glob64
|
||||
# define globfree globfree64
|
||||
#else
|
||||
# ifdef _LARGEFILE64_SOURCE
|
||||
extern int glob64 __P ((__const char *__pattern, int __flags,
|
||||
int (*__errfunc) (__const char *, int),
|
||||
glob64_t *__pglob));
|
||||
|
||||
extern void globfree64 __P ((glob64_t *__pglob));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Do glob searching for PATTERN, placing results in PGLOB.
|
||||
The bits defined above may be set in FLAGS.
|
||||
If a directory cannot be opened or read and ERRFUNC is not nil,
|
||||
it is called with the pathname that caused the error, and the
|
||||
`errno' value from the failing call; if it returns non-zero
|
||||
`glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
|
||||
If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
|
||||
Otherwise, `glob' returns zero. */
|
||||
#if _FILE_OFFSET_BITS != 64 || __GNUC__ < 2
|
||||
extern int glob __P ((__const char *__pattern, int __flags,
|
||||
int (*__errfunc) (__const char *, int),
|
||||
glob_t *__pglob));
|
||||
|
||||
/* Free storage allocated in PGLOB by a previous `glob' call. */
|
||||
extern void globfree __P ((glob_t *__pglob));
|
||||
#else
|
||||
extern int glob __P ((__const char *__pattern, int __flags,
|
||||
int (*__errfunc) (__const char *, int),
|
||||
glob_t *__pglob)) __asm__ ("glob64");
|
||||
|
||||
extern void globfree __P ((glob_t *__pglob)) __asm__ ("globfree64");
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
/* Return nonzero if PATTERN contains any metacharacters.
|
||||
Metacharacters can be quoted with backslashes if QUOTE is nonzero.
|
||||
|
||||
This function is not part of the interface specified by POSIX.2
|
||||
but several programs want to use it. */
|
||||
extern int glob_pattern_p __P ((__const char *__pattern, int __quote));
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* glob.h */
|
||||
369
flaim/external/w32/make/hash.c
vendored
Normal file
369
flaim/external/w32/make/hash.c
vendored
Normal file
@@ -0,0 +1,369 @@
|
||||
/* hash.c -- hash table maintenance
|
||||
Copyright (C) 1995, 1999, 2002 Free Software Foundation, Inc.
|
||||
Written by Greg McGary <gkm@gnu.org> <greg@mcgary.org>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "make.h"
|
||||
#include "hash.h"
|
||||
|
||||
#define CALLOC(t, n) ((t *) calloc (sizeof (t), (n)))
|
||||
#define MALLOC(t, n) ((t *) xmalloc (sizeof (t) * (n)))
|
||||
#define REALLOC(o, t, n) ((t *) xrealloc ((o), sizeof (t) * (n)))
|
||||
#define CLONE(o, t, n) ((t *) memcpy (MALLOC (t, (n)), (o), sizeof (t) * (n)))
|
||||
|
||||
static void hash_rehash __P((struct hash_table* ht));
|
||||
static unsigned long round_up_2 __P((unsigned long rough));
|
||||
|
||||
/* Implement double hashing with open addressing. The table size is
|
||||
always a power of two. The secondary (`increment') hash function
|
||||
is forced to return an odd-value, in order to be relatively prime
|
||||
to the table size. This guarantees that the increment can
|
||||
potentially hit every slot in the table during collision
|
||||
resolution. */
|
||||
|
||||
void *hash_deleted_item = &hash_deleted_item;
|
||||
|
||||
/* Force the table size to be a power of two, possibly rounding up the
|
||||
given size. */
|
||||
|
||||
void
|
||||
hash_init (ht, size, hash_1, hash_2, hash_cmp)
|
||||
struct hash_table* ht;
|
||||
unsigned long size;
|
||||
hash_func_t hash_1;
|
||||
hash_func_t hash_2;
|
||||
hash_cmp_func_t hash_cmp;
|
||||
{
|
||||
ht->ht_size = round_up_2 (size);
|
||||
ht->ht_empty_slots = ht->ht_size;
|
||||
ht->ht_vec = (void**) CALLOC (struct token *, ht->ht_size);
|
||||
if (ht->ht_vec == 0)
|
||||
{
|
||||
fprintf (stderr, _("can't allocate %ld bytes for hash table: memory exhausted"),
|
||||
ht->ht_size * sizeof(struct token *));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
ht->ht_capacity = ht->ht_size - (ht->ht_size / 16); /* 93.75% loading factor */
|
||||
ht->ht_fill = 0;
|
||||
ht->ht_collisions = 0;
|
||||
ht->ht_lookups = 0;
|
||||
ht->ht_rehashes = 0;
|
||||
ht->ht_hash_1 = hash_1;
|
||||
ht->ht_hash_2 = hash_2;
|
||||
ht->ht_compare = hash_cmp;
|
||||
}
|
||||
|
||||
/* Load an array of items into `ht'. */
|
||||
|
||||
void
|
||||
hash_load (ht, item_table, cardinality, size)
|
||||
struct hash_table* ht;
|
||||
void *item_table;
|
||||
unsigned long cardinality;
|
||||
unsigned long size;
|
||||
{
|
||||
char *items = (char *) item_table;
|
||||
while (cardinality--)
|
||||
{
|
||||
hash_insert (ht, items);
|
||||
items += size;
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns the address of the table slot matching `key'. If `key' is
|
||||
not found, return the address of an empty slot suitable for
|
||||
inserting `key'. The caller is responsible for incrementing
|
||||
ht_fill on insertion. */
|
||||
|
||||
void **
|
||||
hash_find_slot (ht, key)
|
||||
struct hash_table* ht;
|
||||
void const *key;
|
||||
{
|
||||
void **slot;
|
||||
void **deleted_slot = 0;
|
||||
unsigned int hash_2 = 0;
|
||||
unsigned int hash_1 = (*ht->ht_hash_1) (key);
|
||||
|
||||
ht->ht_lookups++;
|
||||
for (;;)
|
||||
{
|
||||
hash_1 &= (ht->ht_size - 1);
|
||||
slot = &ht->ht_vec[hash_1];
|
||||
|
||||
if (*slot == 0)
|
||||
return (deleted_slot ? deleted_slot : slot);
|
||||
if (*slot == hash_deleted_item)
|
||||
{
|
||||
if (deleted_slot == 0)
|
||||
deleted_slot = slot;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key == *slot)
|
||||
return slot;
|
||||
if ((*ht->ht_compare) (key, *slot) == 0)
|
||||
return slot;
|
||||
ht->ht_collisions++;
|
||||
}
|
||||
if (!hash_2)
|
||||
hash_2 = (*ht->ht_hash_2) (key) | 1;
|
||||
hash_1 += hash_2;
|
||||
}
|
||||
}
|
||||
|
||||
void *
|
||||
hash_find_item (ht, key)
|
||||
struct hash_table* ht;
|
||||
void const *key;
|
||||
{
|
||||
void **slot = hash_find_slot (ht, key);
|
||||
return ((HASH_VACANT (*slot)) ? 0 : *slot);
|
||||
}
|
||||
|
||||
void *
|
||||
hash_insert (ht, item)
|
||||
struct hash_table* ht;
|
||||
void *item;
|
||||
{
|
||||
void **slot = hash_find_slot (ht, item);
|
||||
void *old_item = slot ? *slot : 0;
|
||||
hash_insert_at (ht, item, slot);
|
||||
return ((HASH_VACANT (old_item)) ? 0 : old_item);
|
||||
}
|
||||
|
||||
void *
|
||||
hash_insert_at (ht, item, slot)
|
||||
struct hash_table* ht;
|
||||
void *item;
|
||||
void const *slot;
|
||||
{
|
||||
void *old_item = *(void **) slot;
|
||||
if (HASH_VACANT (old_item))
|
||||
{
|
||||
ht->ht_fill++;
|
||||
if (old_item == 0)
|
||||
ht->ht_empty_slots--;
|
||||
old_item = item;
|
||||
}
|
||||
*(void const **) slot = item;
|
||||
if (ht->ht_empty_slots < ht->ht_size - ht->ht_capacity)
|
||||
{
|
||||
hash_rehash (ht);
|
||||
return (void *) hash_find_slot (ht, item);
|
||||
}
|
||||
else
|
||||
return (void *) slot;
|
||||
}
|
||||
|
||||
void *
|
||||
hash_delete (ht, item)
|
||||
struct hash_table* ht;
|
||||
void const *item;
|
||||
{
|
||||
void **slot = hash_find_slot (ht, item);
|
||||
return hash_delete_at (ht, slot);
|
||||
}
|
||||
|
||||
void *
|
||||
hash_delete_at (ht, slot)
|
||||
struct hash_table* ht;
|
||||
void const *slot;
|
||||
{
|
||||
void *item = *(void **) slot;
|
||||
if (!HASH_VACANT (item))
|
||||
{
|
||||
*(void const **) slot = hash_deleted_item;
|
||||
ht->ht_fill--;
|
||||
return item;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
hash_free_items (ht)
|
||||
struct hash_table* ht;
|
||||
{
|
||||
void **vec = ht->ht_vec;
|
||||
void **end = &vec[ht->ht_size];
|
||||
for (; vec < end; vec++)
|
||||
{
|
||||
void *item = *vec;
|
||||
if (!HASH_VACANT (item))
|
||||
free (item);
|
||||
*vec = 0;
|
||||
}
|
||||
ht->ht_fill = 0;
|
||||
ht->ht_empty_slots = ht->ht_size;
|
||||
}
|
||||
|
||||
void
|
||||
hash_delete_items (ht)
|
||||
struct hash_table* ht;
|
||||
{
|
||||
void **vec = ht->ht_vec;
|
||||
void **end = &vec[ht->ht_size];
|
||||
for (; vec < end; vec++)
|
||||
*vec = 0;
|
||||
ht->ht_fill = 0;
|
||||
ht->ht_collisions = 0;
|
||||
ht->ht_lookups = 0;
|
||||
ht->ht_rehashes = 0;
|
||||
ht->ht_empty_slots = ht->ht_size;
|
||||
}
|
||||
|
||||
void
|
||||
hash_free (ht, free_items)
|
||||
struct hash_table* ht;
|
||||
int free_items;
|
||||
{
|
||||
if (free_items)
|
||||
hash_free_items (ht);
|
||||
else
|
||||
{
|
||||
ht->ht_fill = 0;
|
||||
ht->ht_empty_slots = ht->ht_size;
|
||||
}
|
||||
free (ht->ht_vec);
|
||||
ht->ht_vec = 0;
|
||||
ht->ht_capacity = 0;
|
||||
}
|
||||
|
||||
void
|
||||
hash_map (ht, map)
|
||||
struct hash_table *ht;
|
||||
hash_map_func_t map;
|
||||
{
|
||||
void **slot;
|
||||
void **end = &ht->ht_vec[ht->ht_size];
|
||||
|
||||
for (slot = ht->ht_vec; slot < end; slot++)
|
||||
{
|
||||
if (!HASH_VACANT (*slot))
|
||||
(*map) (*slot);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
hash_map_arg (ht, map, arg)
|
||||
struct hash_table *ht;
|
||||
hash_map_arg_func_t map;
|
||||
void *arg;
|
||||
{
|
||||
void **slot;
|
||||
void **end = &ht->ht_vec[ht->ht_size];
|
||||
|
||||
for (slot = ht->ht_vec; slot < end; slot++)
|
||||
{
|
||||
if (!HASH_VACANT (*slot))
|
||||
(*map) (*slot, arg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Double the size of the hash table in the event of overflow... */
|
||||
|
||||
static void
|
||||
hash_rehash (ht)
|
||||
struct hash_table* ht;
|
||||
{
|
||||
unsigned long old_ht_size = ht->ht_size;
|
||||
void **old_vec = ht->ht_vec;
|
||||
void **ovp;
|
||||
|
||||
if (ht->ht_fill >= ht->ht_capacity)
|
||||
{
|
||||
ht->ht_size *= 2;
|
||||
ht->ht_capacity = ht->ht_size - (ht->ht_size >> 4);
|
||||
}
|
||||
ht->ht_rehashes++;
|
||||
ht->ht_vec = (void **) CALLOC (struct token *, ht->ht_size);
|
||||
|
||||
for (ovp = old_vec; ovp < &old_vec[old_ht_size]; ovp++)
|
||||
{
|
||||
if (! HASH_VACANT (*ovp))
|
||||
{
|
||||
void **slot = hash_find_slot (ht, *ovp);
|
||||
*slot = *ovp;
|
||||
}
|
||||
}
|
||||
ht->ht_empty_slots = ht->ht_size - ht->ht_fill;
|
||||
free (old_vec);
|
||||
}
|
||||
|
||||
void
|
||||
hash_print_stats (ht, out_FILE)
|
||||
struct hash_table *ht;
|
||||
FILE *out_FILE;
|
||||
{
|
||||
/* GKM FIXME: honor NO_FLOAT */
|
||||
fprintf (out_FILE, _("Load=%ld/%ld=%.0f%%, "), ht->ht_fill, ht->ht_size,
|
||||
100.0 * (double) ht->ht_fill / (double) ht->ht_size);
|
||||
fprintf (out_FILE, _("Rehash=%d, "), ht->ht_rehashes);
|
||||
fprintf (out_FILE, _("Collisions=%ld/%ld=%.0f%%"), ht->ht_collisions, ht->ht_lookups,
|
||||
(ht->ht_lookups
|
||||
? (100.0 * (double) ht->ht_collisions / (double) ht->ht_lookups)
|
||||
: 0));
|
||||
}
|
||||
|
||||
/* Dump all items into a NULL-terminated vector. Use the
|
||||
user-supplied vector, or malloc one. */
|
||||
|
||||
void **
|
||||
hash_dump (ht, vector_0, compare)
|
||||
struct hash_table *ht;
|
||||
void **vector_0;
|
||||
qsort_cmp_t compare;
|
||||
{
|
||||
void **vector;
|
||||
void **slot;
|
||||
void **end = &ht->ht_vec[ht->ht_size];
|
||||
|
||||
if (vector_0 == 0)
|
||||
vector_0 = MALLOC (void *, ht->ht_fill + 1);
|
||||
vector = vector_0;
|
||||
|
||||
for (slot = ht->ht_vec; slot < end; slot++)
|
||||
if (!HASH_VACANT (*slot))
|
||||
*vector++ = *slot;
|
||||
*vector = 0;
|
||||
|
||||
if (compare)
|
||||
qsort (vector_0, ht->ht_fill, sizeof (void *), compare);
|
||||
return vector_0;
|
||||
}
|
||||
|
||||
/* Round a given number up to the nearest power of 2. */
|
||||
|
||||
static unsigned long
|
||||
round_up_2 (n)
|
||||
unsigned long n;
|
||||
{
|
||||
n |= (n >> 1);
|
||||
n |= (n >> 2);
|
||||
n |= (n >> 4);
|
||||
n |= (n >> 8);
|
||||
n |= (n >> 16);
|
||||
|
||||
#if !defined(HAVE_LIMITS_H) || ULONG_MAX > 4294967295
|
||||
/* We only need this on systems where unsigned long is >32 bits. */
|
||||
n |= (n >> 32);
|
||||
#endif
|
||||
|
||||
return n + 1;
|
||||
}
|
||||
233
flaim/external/w32/make/hash.h
vendored
Normal file
233
flaim/external/w32/make/hash.h
vendored
Normal file
@@ -0,0 +1,233 @@
|
||||
/* hash.h -- decls for hash table
|
||||
Copyright (C) 1995, 1999, 2002 Free Software Foundation, Inc.
|
||||
Written by Greg McGary <gkm@gnu.org> <greg@mcgary.org>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _hash_h_
|
||||
#define _hash_h_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32
|
||||
# if !defined __GLIBC__ || !defined __P
|
||||
# undef __P
|
||||
# define __P(protos) protos
|
||||
# endif
|
||||
#else /* Not C++ or ANSI C. */
|
||||
# undef __P
|
||||
# define __P(protos) ()
|
||||
/* We can get away without defining `const' here only because in this file
|
||||
it is used only inside the prototype for `fnmatch', which is elided in
|
||||
non-ANSI C where `const' is problematical. */
|
||||
#endif /* C++ or ANSI C. */
|
||||
|
||||
typedef unsigned long (*hash_func_t) __P((void const *key));
|
||||
typedef int (*hash_cmp_func_t) __P((void const *x, void const *y));
|
||||
typedef void (*hash_map_func_t) __P((void const *item));
|
||||
typedef void (*hash_map_arg_func_t) __P((void const *item, void *arg));
|
||||
|
||||
struct hash_table
|
||||
{
|
||||
void **ht_vec;
|
||||
unsigned long ht_size; /* total number of slots (power of 2) */
|
||||
unsigned long ht_capacity; /* usable slots, limited by loading-factor */
|
||||
unsigned long ht_fill; /* items in table */
|
||||
unsigned long ht_empty_slots; /* empty slots not including deleted slots */
|
||||
unsigned long ht_collisions; /* # of failed calls to comparison function */
|
||||
unsigned long ht_lookups; /* # of queries */
|
||||
unsigned int ht_rehashes; /* # of times we've expanded table */
|
||||
hash_func_t ht_hash_1; /* primary hash function */
|
||||
hash_func_t ht_hash_2; /* secondary hash function */
|
||||
hash_cmp_func_t ht_compare; /* comparison function */
|
||||
};
|
||||
|
||||
typedef int (*qsort_cmp_t) __P((void const *, void const *));
|
||||
|
||||
void hash_init __P((struct hash_table *ht, unsigned long size,
|
||||
hash_func_t hash_1, hash_func_t hash_2, hash_cmp_func_t hash_cmp));
|
||||
void hash_load __P((struct hash_table *ht, void *item_table,
|
||||
unsigned long cardinality, unsigned long size));
|
||||
void **hash_find_slot __P((struct hash_table *ht, void const *key));
|
||||
void *hash_find_item __P((struct hash_table *ht, void const *key));
|
||||
void *hash_insert __P((struct hash_table *ht, void *item));
|
||||
void *hash_insert_at __P((struct hash_table *ht, void *item, void const *slot));
|
||||
void *hash_delete __P((struct hash_table *ht, void const *item));
|
||||
void *hash_delete_at __P((struct hash_table *ht, void const *slot));
|
||||
void hash_delete_items __P((struct hash_table *ht));
|
||||
void hash_free_items __P((struct hash_table *ht));
|
||||
void hash_free __P((struct hash_table *ht, int free_items));
|
||||
void hash_map __P((struct hash_table *ht, hash_map_func_t map));
|
||||
void hash_map_arg __P((struct hash_table *ht, hash_map_arg_func_t map, void *arg));
|
||||
void hash_print_stats __P((struct hash_table *ht, FILE *out_FILE));
|
||||
void **hash_dump __P((struct hash_table *ht, void **vector_0, qsort_cmp_t compare));
|
||||
|
||||
extern void *hash_deleted_item;
|
||||
#define HASH_VACANT(item) ((item) == 0 || (void *) (item) == hash_deleted_item)
|
||||
|
||||
|
||||
/* hash and comparison macros for case-sensitive string keys. */
|
||||
|
||||
#define STRING_HASH_1(KEY, RESULT) do { \
|
||||
unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
|
||||
while (*++_key_) \
|
||||
(RESULT) += (*_key_ << (_key_[1] & 0xf)); \
|
||||
} while (0)
|
||||
#define return_STRING_HASH_1(KEY) do { \
|
||||
unsigned long _result_ = 0; \
|
||||
STRING_HASH_1 ((KEY), _result_); \
|
||||
return _result_; \
|
||||
} while (0)
|
||||
|
||||
#define STRING_HASH_2(KEY, RESULT) do { \
|
||||
unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
|
||||
while (*++_key_) \
|
||||
(RESULT) += (*_key_ << (_key_[1] & 0x7)); \
|
||||
} while (0)
|
||||
#define return_STRING_HASH_2(KEY) do { \
|
||||
unsigned long _result_ = 0; \
|
||||
STRING_HASH_2 ((KEY), _result_); \
|
||||
return _result_; \
|
||||
} while (0)
|
||||
|
||||
#define STRING_COMPARE(X, Y, RESULT) do { \
|
||||
RESULT = strcmp ((X), (Y)); \
|
||||
} while (0)
|
||||
#define return_STRING_COMPARE(X, Y) do { \
|
||||
return strcmp ((X), (Y)); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define STRING_N_HASH_1(KEY, N, RESULT) do { \
|
||||
unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
|
||||
int _n_ = (N); \
|
||||
if (_n_) \
|
||||
while (--_n_ && *++_key_) \
|
||||
(RESULT) += (*_key_ << (_key_[1] & 0xf)); \
|
||||
(RESULT) += *++_key_; \
|
||||
} while (0)
|
||||
#define return_STRING_N_HASH_1(KEY, N) do { \
|
||||
unsigned long _result_ = 0; \
|
||||
STRING_N_HASH_1 ((KEY), (N), _result_); \
|
||||
return _result_; \
|
||||
} while (0)
|
||||
|
||||
#define STRING_N_HASH_2(KEY, N, RESULT) do { \
|
||||
unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
|
||||
int _n_ = (N); \
|
||||
if (_n_) \
|
||||
while (--_n_ && *++_key_) \
|
||||
(RESULT) += (*_key_ << (_key_[1] & 0x7)); \
|
||||
(RESULT) += *++_key_; \
|
||||
} while (0)
|
||||
#define return_STRING_N_HASH_2(KEY, N) do { \
|
||||
unsigned long _result_ = 0; \
|
||||
STRING_N_HASH_2 ((KEY), (N), _result_); \
|
||||
return _result_; \
|
||||
} while (0)
|
||||
|
||||
#define STRING_N_COMPARE(X, Y, N, RESULT) do { \
|
||||
RESULT = strncmp ((X), (Y), (N)); \
|
||||
} while (0)
|
||||
#define return_STRING_N_COMPARE(X, Y, N) do { \
|
||||
return strncmp ((X), (Y), (N)); \
|
||||
} while (0)
|
||||
|
||||
#ifdef HAVE_CASE_INSENSITIVE_FS
|
||||
|
||||
/* hash and comparison macros for case-insensitive string _key_s. */
|
||||
|
||||
#define ISTRING_HASH_1(KEY, RESULT) do { \
|
||||
unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
|
||||
while (*++_key_) \
|
||||
(RESULT) += ((isupper (*_key_) ? tolower (*_key_) : *_key_) << (_key_[1] & 0xf)); \
|
||||
} while (0)
|
||||
#define return_ISTRING_HASH_1(KEY) do { \
|
||||
unsigned long _result_ = 0; \
|
||||
ISTRING_HASH_1 ((KEY), _result_); \
|
||||
return _result_; \
|
||||
} while (0)
|
||||
|
||||
#define ISTRING_HASH_2(KEY, RESULT) do { \
|
||||
unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
|
||||
while (*++_key_) \
|
||||
(RESULT) += ((isupper (*_key_) ? tolower (*_key_) : *_key_) << (_key_[1] & 0x7)); \
|
||||
} while (0)
|
||||
#define return_ISTRING_HASH_2(KEY) do { \
|
||||
unsigned long _result_ = 0; \
|
||||
ISTRING_HASH_2 ((KEY), _result_); \
|
||||
return _result_; \
|
||||
} while (0)
|
||||
|
||||
#define ISTRING_COMPARE(X, Y, RESULT) do { \
|
||||
RESULT = strcmpi ((X), (Y)); \
|
||||
} while (0)
|
||||
#define return_ISTRING_COMPARE(X, Y) do { \
|
||||
return strcmpi ((X), (Y)); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define ISTRING_HASH_1(KEY, RESULT) STRING_HASH_1 ((KEY), (RESULT))
|
||||
#define return_ISTRING_HASH_1(KEY) return_STRING_HASH_1 (KEY)
|
||||
|
||||
#define ISTRING_HASH_2(KEY, RESULT) STRING_HASH_2 ((KEY), (RESULT))
|
||||
#define return_ISTRING_HASH_2(KEY) return_STRING_HASH_2 (KEY)
|
||||
|
||||
#define ISTRING_COMPARE(X, Y, RESULT) STRING_COMPARE ((X), (Y), (RESULT))
|
||||
#define return_ISTRING_COMPARE(X, Y) return_STRING_COMPARE ((X), (Y))
|
||||
|
||||
#endif
|
||||
|
||||
/* hash and comparison macros for integer _key_s. */
|
||||
|
||||
#define INTEGER_HASH_1(KEY, RESULT) do { \
|
||||
(RESULT) += ((unsigned long)(KEY)); \
|
||||
} while (0)
|
||||
#define return_INTEGER_HASH_1(KEY) do { \
|
||||
unsigned long _result_ = 0; \
|
||||
INTEGER_HASH_1 ((KEY), _result_); \
|
||||
return _result_; \
|
||||
} while (0)
|
||||
|
||||
#define INTEGER_HASH_2(KEY, RESULT) do { \
|
||||
(RESULT) += ~((unsigned long)(KEY)); \
|
||||
} while (0)
|
||||
#define return_INTEGER_HASH_2(KEY) do { \
|
||||
unsigned long _result_ = 0; \
|
||||
INTEGER_HASH_2 ((KEY), _result_); \
|
||||
return _result_; \
|
||||
} while (0)
|
||||
|
||||
#define INTEGER_COMPARE(X, Y, RESULT) do { \
|
||||
(RESULT) = X - Y; \
|
||||
} while (0)
|
||||
#define return_INTEGER_COMPARE(X, Y) do { \
|
||||
int _result_; \
|
||||
INTEGER_COMPARE (X, Y, _result_); \
|
||||
return _result_; \
|
||||
} while (0)
|
||||
|
||||
/* hash and comparison macros for address keys. */
|
||||
|
||||
#define ADDRESS_HASH_1(KEY, RESULT) INTEGER_HASH_1 (((unsigned long)(KEY)) >> 3, (RESULT))
|
||||
#define ADDRESS_HASH_2(KEY, RESULT) INTEGER_HASH_2 (((unsigned long)(KEY)) >> 3, (RESULT))
|
||||
#define ADDRESS_COMPARE(X, Y, RESULT) INTEGER_COMPARE ((X), (Y), (RESULT))
|
||||
#define return_ADDRESS_HASH_1(KEY) return_INTEGER_HASH_1 (((unsigned long)(KEY)) >> 3)
|
||||
#define return_ADDRESS_HASH_2(KEY) return_INTEGER_HASH_2 (((unsigned long)(KEY)) >> 3)
|
||||
#define return_ADDRESS_COMPARE(X, Y) return_INTEGER_COMPARE ((X), (Y))
|
||||
|
||||
#endif /* not _hash_h_ */
|
||||
635
flaim/external/w32/make/implicit.c
vendored
Normal file
635
flaim/external/w32/make/implicit.c
vendored
Normal file
@@ -0,0 +1,635 @@
|
||||
/* Implicit rule searching for GNU Make.
|
||||
Copyright (C) 1988,89,90,91,92,93,94,97,2000 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "make.h"
|
||||
#include "rule.h"
|
||||
#include "dep.h"
|
||||
#include "filedef.h"
|
||||
#include "debug.h"
|
||||
|
||||
static int pattern_search PARAMS ((struct file *file, int archive, unsigned int depth,
|
||||
unsigned int recursions));
|
||||
|
||||
/* For a FILE which has no commands specified, try to figure out some
|
||||
from the implicit pattern rules.
|
||||
Returns 1 if a suitable implicit rule was found,
|
||||
after modifying FILE to contain the appropriate commands and deps,
|
||||
or returns 0 if no implicit rule was found. */
|
||||
|
||||
int
|
||||
try_implicit_rule (file, depth)
|
||||
struct file *file;
|
||||
unsigned int depth;
|
||||
{
|
||||
DBF (DB_IMPLICIT, _("Looking for an implicit rule for `%s'.\n"));
|
||||
|
||||
/* The order of these searches was previously reversed. My logic now is
|
||||
that since the non-archive search uses more information in the target
|
||||
(the archive search omits the archive name), it is more specific and
|
||||
should come first. */
|
||||
|
||||
if (pattern_search (file, 0, depth, 0))
|
||||
return 1;
|
||||
|
||||
#ifndef NO_ARCHIVES
|
||||
/* If this is an archive member reference, use just the
|
||||
archive member name to search for implicit rules. */
|
||||
if (ar_name (file->name))
|
||||
{
|
||||
DBF (DB_IMPLICIT,
|
||||
_("Looking for archive-member implicit rule for `%s'.\n"));
|
||||
if (pattern_search (file, 1, depth, 0))
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Search the pattern rules for a rule with an existing dependency to make
|
||||
FILE. If a rule is found, the appropriate commands and deps are put in FILE
|
||||
and 1 is returned. If not, 0 is returned.
|
||||
|
||||
If ARCHIVE is nonzero, FILE->name is of the form "LIB(MEMBER)". A rule for
|
||||
"(MEMBER)" will be searched for, and "(MEMBER)" will not be chopped up into
|
||||
directory and filename parts.
|
||||
|
||||
If an intermediate file is found by pattern search, the intermediate file
|
||||
is set up as a target by the recursive call and is also made a dependency
|
||||
of FILE.
|
||||
|
||||
DEPTH is used for debugging messages. */
|
||||
|
||||
static int
|
||||
pattern_search (file, archive, depth, recursions)
|
||||
struct file *file;
|
||||
int archive;
|
||||
unsigned int depth;
|
||||
unsigned int recursions;
|
||||
{
|
||||
/* Filename we are searching for a rule for. */
|
||||
char *filename = archive ? strchr (file->name, '(') : file->name;
|
||||
|
||||
/* Length of FILENAME. */
|
||||
unsigned int namelen = strlen (filename);
|
||||
|
||||
/* The last slash in FILENAME (or nil if there is none). */
|
||||
char *lastslash;
|
||||
|
||||
/* This is a file-object used as an argument in
|
||||
recursive calls. It never contains any data
|
||||
except during a recursive call. */
|
||||
struct file *intermediate_file = 0;
|
||||
|
||||
/* List of dependencies found recursively. */
|
||||
struct file **intermediate_files
|
||||
= (struct file **) xmalloc (max_pattern_deps * sizeof (struct file *));
|
||||
|
||||
/* List of the patterns used to find intermediate files. */
|
||||
char **intermediate_patterns
|
||||
= (char **) alloca (max_pattern_deps * sizeof (char *));
|
||||
|
||||
/* This buffer records all the dependencies actually found for a rule. */
|
||||
char **found_files = (char **) alloca (max_pattern_deps * sizeof (char *));
|
||||
/* Number of dep names now in FOUND_FILES. */
|
||||
unsigned int deps_found = 0;
|
||||
|
||||
/* Names of possible dependencies are constructed in this buffer. */
|
||||
register char *depname = (char *) alloca (namelen + max_pattern_dep_length);
|
||||
|
||||
/* The start and length of the stem of FILENAME for the current rule. */
|
||||
register char *stem = 0;
|
||||
register unsigned int stemlen = 0;
|
||||
register unsigned int fullstemlen = 0;
|
||||
|
||||
/* Buffer in which we store all the rules that are possibly applicable. */
|
||||
struct rule **tryrules
|
||||
= (struct rule **) xmalloc (num_pattern_rules * max_pattern_targets
|
||||
* sizeof (struct rule *));
|
||||
|
||||
/* Number of valid elements in TRYRULES. */
|
||||
unsigned int nrules;
|
||||
|
||||
/* The numbers of the rule targets of each rule
|
||||
in TRYRULES that matched the target file. */
|
||||
unsigned int *matches
|
||||
= (unsigned int *) alloca (num_pattern_rules * sizeof (unsigned int));
|
||||
|
||||
/* Each element is nonzero if LASTSLASH was used in
|
||||
matching the corresponding element of TRYRULES. */
|
||||
char *checked_lastslash
|
||||
= (char *) alloca (num_pattern_rules * sizeof (char));
|
||||
|
||||
/* The index in TRYRULES of the rule we found. */
|
||||
unsigned int foundrule;
|
||||
|
||||
/* Nonzero if should consider intermediate files as dependencies. */
|
||||
int intermed_ok;
|
||||
|
||||
/* Nonzero if we have matched a pattern-rule target
|
||||
that is not just `%'. */
|
||||
int specific_rule_matched = 0;
|
||||
|
||||
register unsigned int i = 0; /* uninit checks OK */
|
||||
register struct rule *rule;
|
||||
register struct dep *dep;
|
||||
|
||||
char *p, *vp;
|
||||
|
||||
#ifndef NO_ARCHIVES
|
||||
if (archive || ar_name (filename))
|
||||
lastslash = 0;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* Set LASTSLASH to point at the last slash in FILENAME
|
||||
but not counting any slash at the end. (foo/bar/ counts as
|
||||
bar/ in directory foo/, not empty in directory foo/bar/.) */
|
||||
#ifdef VMS
|
||||
lastslash = strrchr (filename, ']');
|
||||
if (lastslash == 0)
|
||||
lastslash = strrchr (filename, ':');
|
||||
#else
|
||||
lastslash = strrchr (filename, '/');
|
||||
#ifdef HAVE_DOS_PATHS
|
||||
/* Handle backslashes (possibly mixed with forward slashes)
|
||||
and the case of "d:file". */
|
||||
{
|
||||
char *bslash = strrchr (filename, '\\');
|
||||
if (lastslash == 0 || bslash > lastslash)
|
||||
lastslash = bslash;
|
||||
if (lastslash == 0 && filename[0] && filename[1] == ':')
|
||||
lastslash = filename + 1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
if (lastslash != 0 && lastslash[1] == '\0')
|
||||
lastslash = 0;
|
||||
}
|
||||
|
||||
/* First see which pattern rules match this target
|
||||
and may be considered. Put them in TRYRULES. */
|
||||
|
||||
nrules = 0;
|
||||
for (rule = pattern_rules; rule != 0; rule = rule->next)
|
||||
{
|
||||
/* If the pattern rule has deps but no commands, ignore it.
|
||||
Users cancel built-in rules by redefining them without commands. */
|
||||
if (rule->deps != 0 && rule->cmds == 0)
|
||||
continue;
|
||||
|
||||
/* If this rule is in use by a parent pattern_search,
|
||||
don't use it here. */
|
||||
if (rule->in_use)
|
||||
{
|
||||
DBS (DB_IMPLICIT, (_("Avoiding implicit rule recursion.\n")));
|
||||
continue;
|
||||
}
|
||||
|
||||
for (i = 0; rule->targets[i] != 0; ++i)
|
||||
{
|
||||
char *target = rule->targets[i];
|
||||
char *suffix = rule->suffixes[i];
|
||||
int check_lastslash;
|
||||
|
||||
/* Rules that can match any filename and are not terminal
|
||||
are ignored if we're recursing, so that they cannot be
|
||||
intermediate files. */
|
||||
if (recursions > 0 && target[1] == '\0' && !rule->terminal)
|
||||
continue;
|
||||
|
||||
if (rule->lens[i] > namelen)
|
||||
/* It can't possibly match. */
|
||||
continue;
|
||||
|
||||
/* From the lengths of the filename and the pattern parts,
|
||||
find the stem: the part of the filename that matches the %. */
|
||||
stem = filename + (suffix - target - 1);
|
||||
stemlen = namelen - rule->lens[i] + 1;
|
||||
|
||||
/* Set CHECK_LASTSLASH if FILENAME contains a directory
|
||||
prefix and the target pattern does not contain a slash. */
|
||||
|
||||
#ifdef VMS
|
||||
check_lastslash = lastslash != 0
|
||||
&& ((strchr (target, ']') == 0)
|
||||
&& (strchr (target, ':') == 0));
|
||||
#else
|
||||
check_lastslash = lastslash != 0 && strchr (target, '/') == 0;
|
||||
#endif
|
||||
if (check_lastslash)
|
||||
{
|
||||
/* In that case, don't include the
|
||||
directory prefix in STEM here. */
|
||||
unsigned int difference = lastslash - filename + 1;
|
||||
if (difference > stemlen)
|
||||
continue;
|
||||
stemlen -= difference;
|
||||
stem += difference;
|
||||
}
|
||||
|
||||
/* Check that the rule pattern matches the text before the stem. */
|
||||
if (check_lastslash)
|
||||
{
|
||||
if (stem > (lastslash + 1)
|
||||
&& !strneq (target, lastslash + 1, stem - lastslash - 1))
|
||||
continue;
|
||||
}
|
||||
else if (stem > filename
|
||||
&& !strneq (target, filename, stem - filename))
|
||||
continue;
|
||||
|
||||
/* Check that the rule pattern matches the text after the stem.
|
||||
We could test simply use streq, but this way we compare the
|
||||
first two characters immediately. This saves time in the very
|
||||
common case where the first character matches because it is a
|
||||
period. */
|
||||
if (*suffix != stem[stemlen]
|
||||
|| (*suffix != '\0' && !streq (&suffix[1], &stem[stemlen + 1])))
|
||||
continue;
|
||||
|
||||
/* Record if we match a rule that not all filenames will match. */
|
||||
if (target[1] != '\0')
|
||||
specific_rule_matched = 1;
|
||||
|
||||
/* A rule with no dependencies and no commands exists solely to set
|
||||
specific_rule_matched when it matches. Don't try to use it. */
|
||||
if (rule->deps == 0 && rule->cmds == 0)
|
||||
continue;
|
||||
|
||||
/* Record this rule in TRYRULES and the index of the matching
|
||||
target in MATCHES. If several targets of the same rule match,
|
||||
that rule will be in TRYRULES more than once. */
|
||||
tryrules[nrules] = rule;
|
||||
matches[nrules] = i;
|
||||
checked_lastslash[nrules] = check_lastslash;
|
||||
++nrules;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we have found a matching rule that won't match all filenames,
|
||||
retroactively reject any non-"terminal" rules that do always match. */
|
||||
if (specific_rule_matched)
|
||||
for (i = 0; i < nrules; ++i)
|
||||
if (!tryrules[i]->terminal)
|
||||
{
|
||||
register unsigned int j;
|
||||
for (j = 0; tryrules[i]->targets[j] != 0; ++j)
|
||||
if (tryrules[i]->targets[j][1] == '\0')
|
||||
break;
|
||||
if (tryrules[i]->targets[j] != 0)
|
||||
tryrules[i] = 0;
|
||||
}
|
||||
|
||||
/* Try each rule once without intermediate files, then once with them. */
|
||||
for (intermed_ok = 0; intermed_ok == !!intermed_ok; ++intermed_ok)
|
||||
{
|
||||
/* Try each pattern rule till we find one that applies.
|
||||
If it does, copy the names of its dependencies (as substituted)
|
||||
and store them in FOUND_FILES. DEPS_FOUND is the number of them. */
|
||||
|
||||
for (i = 0; i < nrules; i++)
|
||||
{
|
||||
int check_lastslash;
|
||||
|
||||
rule = tryrules[i];
|
||||
|
||||
/* RULE is nil when we discover that a rule,
|
||||
already placed in TRYRULES, should not be applied. */
|
||||
if (rule == 0)
|
||||
continue;
|
||||
|
||||
/* Reject any terminal rules if we're
|
||||
looking to make intermediate files. */
|
||||
if (intermed_ok && rule->terminal)
|
||||
continue;
|
||||
|
||||
/* Mark this rule as in use so a recursive
|
||||
pattern_search won't try to use it. */
|
||||
rule->in_use = 1;
|
||||
|
||||
/* From the lengths of the filename and the matching pattern parts,
|
||||
find the stem: the part of the filename that matches the %. */
|
||||
stem = filename
|
||||
+ (rule->suffixes[matches[i]] - rule->targets[matches[i]]) - 1;
|
||||
stemlen = namelen - rule->lens[matches[i]] + 1;
|
||||
check_lastslash = checked_lastslash[i];
|
||||
if (check_lastslash)
|
||||
{
|
||||
stem += lastslash - filename + 1;
|
||||
stemlen -= (lastslash - filename) + 1;
|
||||
}
|
||||
|
||||
DBS (DB_IMPLICIT, (_("Trying pattern rule with stem `%.*s'.\n"),
|
||||
(int) stemlen, stem));
|
||||
|
||||
/* Try each dependency; see if it "exists". */
|
||||
|
||||
deps_found = 0;
|
||||
for (dep = rule->deps; dep != 0; dep = dep->next)
|
||||
{
|
||||
/* If the dependency name has a %, substitute the stem. */
|
||||
p = strchr (dep_name (dep), '%');
|
||||
if (p != 0)
|
||||
{
|
||||
register unsigned int i;
|
||||
if (check_lastslash)
|
||||
{
|
||||
/* Copy directory name from the original FILENAME. */
|
||||
i = lastslash - filename + 1;
|
||||
bcopy (filename, depname, i);
|
||||
}
|
||||
else
|
||||
i = 0;
|
||||
bcopy (dep_name (dep), depname + i, p - dep_name (dep));
|
||||
i += p - dep_name (dep);
|
||||
bcopy (stem, depname + i, stemlen);
|
||||
i += stemlen;
|
||||
strcpy (depname + i, p + 1);
|
||||
p = depname;
|
||||
}
|
||||
else
|
||||
p = dep_name (dep);
|
||||
|
||||
/* P is now the actual dependency name as substituted. */
|
||||
|
||||
if (file_impossible_p (p))
|
||||
{
|
||||
/* If this dependency has already been ruled
|
||||
"impossible", then the rule fails and don't
|
||||
bother trying it on the second pass either
|
||||
since we know that will fail too. */
|
||||
DBS (DB_IMPLICIT,
|
||||
(p == depname
|
||||
? _("Rejecting impossible implicit prerequisite `%s'.\n")
|
||||
: _("Rejecting impossible rule prerequisite `%s'.\n"),
|
||||
p));
|
||||
tryrules[i] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
intermediate_files[deps_found] = 0;
|
||||
|
||||
DBS (DB_IMPLICIT,
|
||||
(p == depname
|
||||
? _("Trying implicit prerequisite `%s'.\n")
|
||||
: _("Trying rule prerequisite `%s'.\n"), p));
|
||||
|
||||
/* The DEP->changed flag says that this dependency resides in a
|
||||
nonexistent directory. So we normally can skip looking for
|
||||
the file. However, if CHECK_LASTSLASH is set, then the
|
||||
dependency file we are actually looking for is in a different
|
||||
directory (the one gotten by prepending FILENAME's directory),
|
||||
so it might actually exist. */
|
||||
|
||||
if (lookup_file (p) != 0
|
||||
|| ((!dep->changed || check_lastslash) && file_exists_p (p)))
|
||||
{
|
||||
found_files[deps_found++] = xstrdup (p);
|
||||
continue;
|
||||
}
|
||||
/* This code, given FILENAME = "lib/foo.o", dependency name
|
||||
"lib/foo.c", and VPATH=src, searches for "src/lib/foo.c". */
|
||||
vp = p;
|
||||
if (vpath_search (&vp, (FILE_TIMESTAMP *) 0))
|
||||
{
|
||||
DBS (DB_IMPLICIT,
|
||||
(_("Found prerequisite `%s' as VPATH `%s'\n"), p, vp));
|
||||
strcpy (vp, p);
|
||||
found_files[deps_found++] = vp;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* We could not find the file in any place we should look.
|
||||
Try to make this dependency as an intermediate file,
|
||||
but only on the second pass. */
|
||||
|
||||
if (intermed_ok)
|
||||
{
|
||||
if (intermediate_file == 0)
|
||||
intermediate_file
|
||||
= (struct file *) alloca (sizeof (struct file));
|
||||
|
||||
DBS (DB_IMPLICIT,
|
||||
(_("Looking for a rule with intermediate file `%s'.\n"),
|
||||
p));
|
||||
|
||||
bzero ((char *) intermediate_file, sizeof (struct file));
|
||||
intermediate_file->name = p;
|
||||
if (pattern_search (intermediate_file, 0, depth + 1,
|
||||
recursions + 1))
|
||||
{
|
||||
p = xstrdup (p);
|
||||
intermediate_patterns[deps_found]
|
||||
= intermediate_file->name;
|
||||
intermediate_file->name = p;
|
||||
intermediate_files[deps_found] = intermediate_file;
|
||||
intermediate_file = 0;
|
||||
/* Allocate an extra copy to go in FOUND_FILES,
|
||||
because every elt of FOUND_FILES is consumed
|
||||
or freed later. */
|
||||
found_files[deps_found] = xstrdup (p);
|
||||
++deps_found;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If we have tried to find P as an intermediate
|
||||
file and failed, mark that name as impossible
|
||||
so we won't go through the search again later. */
|
||||
file_impossible (p);
|
||||
}
|
||||
|
||||
/* A dependency of this rule does not exist.
|
||||
Therefore, this rule fails. */
|
||||
break;
|
||||
}
|
||||
|
||||
/* This rule is no longer `in use' for recursive searches. */
|
||||
rule->in_use = 0;
|
||||
|
||||
if (dep != 0)
|
||||
{
|
||||
/* This pattern rule does not apply.
|
||||
If some of its dependencies succeeded,
|
||||
free the data structure describing them. */
|
||||
while (deps_found-- > 0)
|
||||
{
|
||||
register struct file *f = intermediate_files[deps_found];
|
||||
free (found_files[deps_found]);
|
||||
if (f != 0
|
||||
&& (f->stem < f->name
|
||||
|| f->stem > f->name + strlen (f->name)))
|
||||
free (f->stem);
|
||||
}
|
||||
}
|
||||
else
|
||||
/* This pattern rule does apply. Stop looking for one. */
|
||||
break;
|
||||
}
|
||||
|
||||
/* If we found an applicable rule without
|
||||
intermediate files, don't try with them. */
|
||||
if (i < nrules)
|
||||
break;
|
||||
|
||||
rule = 0;
|
||||
}
|
||||
|
||||
/* RULE is nil if the loop went all the way
|
||||
through the list and everything failed. */
|
||||
if (rule == 0)
|
||||
goto done;
|
||||
|
||||
foundrule = i;
|
||||
|
||||
/* If we are recursing, store the pattern that matched
|
||||
FILENAME in FILE->name for use in upper levels. */
|
||||
|
||||
if (recursions > 0)
|
||||
/* Kludge-o-matic */
|
||||
file->name = rule->targets[matches[foundrule]];
|
||||
|
||||
/* FOUND_FILES lists the dependencies for the rule we found.
|
||||
This includes the intermediate files, if any.
|
||||
Convert them into entries on the deps-chain of FILE. */
|
||||
|
||||
while (deps_found-- > 0)
|
||||
{
|
||||
register char *s;
|
||||
|
||||
if (intermediate_files[deps_found] != 0)
|
||||
{
|
||||
/* If we need to use an intermediate file,
|
||||
make sure it is entered as a target, with the info that was
|
||||
found for it in the recursive pattern_search call.
|
||||
We know that the intermediate file did not already exist as
|
||||
a target; therefore we can assume that the deps and cmds
|
||||
of F below are null before we change them. */
|
||||
|
||||
struct file *imf = intermediate_files[deps_found];
|
||||
register struct file *f = enter_file (imf->name);
|
||||
f->deps = imf->deps;
|
||||
f->cmds = imf->cmds;
|
||||
f->stem = imf->stem;
|
||||
f->also_make = imf->also_make;
|
||||
imf = lookup_file (intermediate_patterns[deps_found]);
|
||||
if (imf != 0 && imf->precious)
|
||||
f->precious = 1;
|
||||
f->intermediate = 1;
|
||||
f->tried_implicit = 1;
|
||||
for (dep = f->deps; dep != 0; dep = dep->next)
|
||||
{
|
||||
dep->file = enter_file (dep->name);
|
||||
/* enter_file uses dep->name _if_ we created a new file. */
|
||||
if (dep->name != dep->file->name)
|
||||
free (dep->name);
|
||||
dep->name = 0;
|
||||
dep->file->tried_implicit |= dep->changed;
|
||||
}
|
||||
}
|
||||
|
||||
dep = (struct dep *) xmalloc (sizeof (struct dep));
|
||||
dep->ignore_mtime = 0;
|
||||
s = found_files[deps_found];
|
||||
if (recursions == 0)
|
||||
{
|
||||
dep->name = 0;
|
||||
dep->file = lookup_file (s);
|
||||
if (dep->file == 0)
|
||||
/* enter_file consumes S's storage. */
|
||||
dep->file = enter_file (s);
|
||||
else
|
||||
/* A copy of S is already allocated in DEP->file->name.
|
||||
So we can free S. */
|
||||
free (s);
|
||||
}
|
||||
else
|
||||
{
|
||||
dep->name = s;
|
||||
dep->file = 0;
|
||||
dep->changed = 0;
|
||||
}
|
||||
if (intermediate_files[deps_found] == 0 && tryrules[foundrule]->terminal)
|
||||
{
|
||||
/* If the file actually existed (was not an intermediate file),
|
||||
and the rule that found it was a terminal one, then we want
|
||||
to mark the found file so that it will not have implicit rule
|
||||
search done for it. If we are not entering a `struct file' for
|
||||
it now, we indicate this with the `changed' flag. */
|
||||
if (dep->file == 0)
|
||||
dep->changed = 1;
|
||||
else
|
||||
dep->file->tried_implicit = 1;
|
||||
}
|
||||
dep->next = file->deps;
|
||||
file->deps = dep;
|
||||
}
|
||||
|
||||
if (!checked_lastslash[foundrule])
|
||||
{
|
||||
/* Always allocate new storage, since STEM might be
|
||||
on the stack for an intermediate file. */
|
||||
file->stem = savestring (stem, stemlen);
|
||||
fullstemlen = stemlen;
|
||||
}
|
||||
else
|
||||
{
|
||||
int dirlen = (lastslash + 1) - filename;
|
||||
|
||||
/* We want to prepend the directory from
|
||||
the original FILENAME onto the stem. */
|
||||
fullstemlen = dirlen + stemlen;
|
||||
file->stem = (char *) xmalloc (fullstemlen + 1);
|
||||
bcopy (filename, file->stem, dirlen);
|
||||
bcopy (stem, file->stem + dirlen, stemlen);
|
||||
file->stem[fullstemlen] = '\0';
|
||||
}
|
||||
|
||||
file->cmds = rule->cmds;
|
||||
|
||||
/* If this rule builds other targets, too, put the others into FILE's
|
||||
`also_make' member. */
|
||||
|
||||
if (rule->targets[1] != 0)
|
||||
for (i = 0; rule->targets[i] != 0; ++i)
|
||||
if (i != matches[foundrule])
|
||||
{
|
||||
struct dep *new = (struct dep *) xmalloc (sizeof (struct dep));
|
||||
/* GKM FIMXE: handle '|' here too */
|
||||
new->ignore_mtime = 0;
|
||||
new->name = p = (char *) xmalloc (rule->lens[i] + fullstemlen + 1);
|
||||
bcopy (rule->targets[i], p,
|
||||
rule->suffixes[i] - rule->targets[i] - 1);
|
||||
p += rule->suffixes[i] - rule->targets[i] - 1;
|
||||
bcopy (file->stem, p, fullstemlen);
|
||||
p += fullstemlen;
|
||||
bcopy (rule->suffixes[i], p,
|
||||
rule->lens[i] - (rule->suffixes[i] - rule->targets[i]) + 1);
|
||||
new->file = enter_file (new->name);
|
||||
new->next = file->also_make;
|
||||
file->also_make = new;
|
||||
}
|
||||
|
||||
done:
|
||||
free (intermediate_files);
|
||||
free (tryrules);
|
||||
|
||||
return rule != 0;
|
||||
}
|
||||
3110
flaim/external/w32/make/job.c
vendored
Normal file
3110
flaim/external/w32/make/job.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
83
flaim/external/w32/make/job.h
vendored
Normal file
83
flaim/external/w32/make/job.h
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
/* Definitions for managing subprocesses in GNU Make.
|
||||
Copyright (C) 1992, 1993, 1996, 1999 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef SEEN_JOB_H
|
||||
#define SEEN_JOB_H
|
||||
|
||||
/* Structure describing a running or dead child process. */
|
||||
|
||||
struct child
|
||||
{
|
||||
struct child *next; /* Link in the chain. */
|
||||
|
||||
struct file *file; /* File being remade. */
|
||||
|
||||
char **environment; /* Environment for commands. */
|
||||
|
||||
char **command_lines; /* Array of variable-expanded cmd lines. */
|
||||
unsigned int command_line; /* Index into above. */
|
||||
char *command_ptr; /* Ptr into command_lines[command_line]. */
|
||||
|
||||
pid_t pid; /* Child process's ID number. */
|
||||
#ifdef VMS
|
||||
int efn; /* Completion event flag number */
|
||||
int cstatus; /* Completion status */
|
||||
#endif
|
||||
char *sh_batch_file; /* Script file for shell commands */
|
||||
unsigned int remote:1; /* Nonzero if executing remotely. */
|
||||
|
||||
unsigned int noerror:1; /* Nonzero if commands contained a `-'. */
|
||||
|
||||
unsigned int good_stdin:1; /* Nonzero if this child has a good stdin. */
|
||||
unsigned int deleted:1; /* Nonzero if targets have been deleted. */
|
||||
};
|
||||
|
||||
extern struct child *children;
|
||||
|
||||
extern void new_job PARAMS ((struct file *file));
|
||||
extern void reap_children PARAMS ((int block, int err));
|
||||
extern void start_waiting_jobs PARAMS ((void));
|
||||
|
||||
extern char **construct_command_argv PARAMS ((char *line, char **restp, struct file *file, char** batch_file));
|
||||
#ifdef VMS
|
||||
extern int child_execute_job PARAMS ((char *argv, struct child *child));
|
||||
#else
|
||||
extern void child_execute_job PARAMS ((int stdin_fd, int stdout_fd, char **argv, char **envp));
|
||||
#endif
|
||||
#ifdef _AMIGA
|
||||
extern void exec_command PARAMS ((char **argv));
|
||||
#else
|
||||
extern void exec_command PARAMS ((char **argv, char **envp));
|
||||
#endif
|
||||
|
||||
extern unsigned int job_slots_used;
|
||||
|
||||
extern void block_sigs PARAMS ((void));
|
||||
#ifdef POSIX
|
||||
extern void unblock_sigs PARAMS ((void));
|
||||
#else
|
||||
#ifdef HAVE_SIGSETMASK
|
||||
extern int fatal_signal_mask;
|
||||
#define unblock_sigs() sigsetmask (0)
|
||||
#else
|
||||
#define unblock_sigs()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* SEEN_JOB_H */
|
||||
2813
flaim/external/w32/make/main.c
vendored
Normal file
2813
flaim/external/w32/make/main.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
562
flaim/external/w32/make/make.h
vendored
Normal file
562
flaim/external/w32/make/make.h
vendored
Normal file
@@ -0,0 +1,562 @@
|
||||
/* Miscellaneous global declarations and portability cruft for GNU Make.
|
||||
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999,
|
||||
2002 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* We use <config.h> instead of "config.h" so that a compilation
|
||||
using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
|
||||
(which it would do because make.h was found in $srcdir). */
|
||||
#include <config.h>
|
||||
#undef HAVE_CONFIG_H
|
||||
#define HAVE_CONFIG_H 1
|
||||
|
||||
/* AIX requires this to be the first thing in the file. */
|
||||
#ifndef __GNUC__
|
||||
# if HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
# else
|
||||
# ifdef _AIX
|
||||
#pragma alloca
|
||||
# else
|
||||
# ifndef alloca /* predefined by HP cc +Olibcalls */
|
||||
char *alloca ();
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Use prototypes if available. */
|
||||
#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
|
||||
# undef PARAMS
|
||||
# define PARAMS(protos) protos
|
||||
#else /* Not C++ or ANSI C. */
|
||||
# undef PARAMS
|
||||
# define PARAMS(protos) ()
|
||||
#endif /* C++ or ANSI C. */
|
||||
|
||||
/* Specify we want GNU source code. This must be defined before any
|
||||
system headers are included. */
|
||||
|
||||
#define _GNU_SOURCE 1
|
||||
|
||||
|
||||
#ifdef CRAY
|
||||
/* This must happen before #include <signal.h> so
|
||||
that the declaration therein is changed. */
|
||||
# define signal bsdsignal
|
||||
#endif
|
||||
|
||||
/* If we're compiling for the dmalloc debugger, turn off string inlining. */
|
||||
#if defined(HAVE_DMALLOC_H) && defined(__GNUC__)
|
||||
# define __NO_STRING_INLINES
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#ifdef HAVE_SYS_TIMEB_H
|
||||
/* SCO 3.2 "devsys 4.2" has a prototype for `ftime' in <time.h> that bombs
|
||||
unless <sys/timeb.h> has been included first. Does every system have a
|
||||
<sys/timeb.h>? If any does not, configure should check for it. */
|
||||
# include <sys/timeb.h>
|
||||
#endif
|
||||
|
||||
#if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#ifndef isblank
|
||||
# define isblank(c) ((c) == ' ' || (c) == '\t')
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
/* Ultrix's unistd.h always defines _POSIX_VERSION, but you only get
|
||||
POSIX.1 behavior with `cc -YPOSIX', which predefines POSIX itself! */
|
||||
# if defined (_POSIX_VERSION) && !defined (ultrix) && !defined (VMS)
|
||||
# define POSIX 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Some systems define _POSIX_VERSION but are not really POSIX.1. */
|
||||
#if (defined (butterfly) || defined (__arm) || (defined (__mips) && defined (_SYSTYPE_SVR3)) || (defined (sequent) && defined (i386)))
|
||||
# undef POSIX
|
||||
#endif
|
||||
|
||||
#if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
|
||||
# define POSIX 1
|
||||
#endif
|
||||
|
||||
#ifndef RETSIGTYPE
|
||||
# define RETSIGTYPE void
|
||||
#endif
|
||||
|
||||
#ifndef sigmask
|
||||
# define sigmask(sig) (1 << ((sig) - 1))
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SA_RESTART
|
||||
# define SA_RESTART 0
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
# ifndef POSIX
|
||||
# define PATH_MAX MAXPATHLEN
|
||||
# endif
|
||||
#endif
|
||||
#ifndef MAXPATHLEN
|
||||
# define MAXPATHLEN 1024
|
||||
#endif
|
||||
|
||||
#ifdef PATH_MAX
|
||||
# define GET_PATH_MAX PATH_MAX
|
||||
# define PATH_VAR(var) char var[PATH_MAX]
|
||||
#else
|
||||
# define NEED_GET_PATH_MAX 1
|
||||
# define GET_PATH_MAX (get_path_max ())
|
||||
# define PATH_VAR(var) char *var = (char *) alloca (GET_PATH_MAX)
|
||||
extern unsigned int get_path_max PARAMS ((void));
|
||||
#endif
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
/* Nonzero if the integer type T is signed. */
|
||||
#define INTEGER_TYPE_SIGNED(t) ((t) -1 < 0)
|
||||
|
||||
/* The minimum and maximum values for the integer type T.
|
||||
Use ~ (t) 0, not -1, for portability to 1's complement hosts. */
|
||||
#define INTEGER_TYPE_MINIMUM(t) \
|
||||
(! INTEGER_TYPE_SIGNED (t) ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))
|
||||
#define INTEGER_TYPE_MAXIMUM(t) (~ (t) 0 - INTEGER_TYPE_MINIMUM (t))
|
||||
|
||||
#ifndef CHAR_MAX
|
||||
# define CHAR_MAX INTEGER_TYPE_MAXIMUM (char)
|
||||
#endif
|
||||
|
||||
#ifdef STAT_MACROS_BROKEN
|
||||
# ifdef S_ISREG
|
||||
# undef S_ISREG
|
||||
# endif
|
||||
# ifdef S_ISDIR
|
||||
# undef S_ISDIR
|
||||
# endif
|
||||
#endif /* STAT_MACROS_BROKEN. */
|
||||
|
||||
#ifndef S_ISREG
|
||||
# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
|
||||
#endif
|
||||
#ifndef S_ISDIR
|
||||
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
#ifdef VMS
|
||||
# include <types.h>
|
||||
# include <unixlib.h>
|
||||
# include <unixio.h>
|
||||
# include <perror.h>
|
||||
/* Needed to use alloca on VMS. */
|
||||
# include <builtins.h>
|
||||
#endif
|
||||
|
||||
#ifndef __attribute__
|
||||
/* This feature is available in gcc versions 2.5 and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
/* The __-protected variants of `format' and `printf' attributes
|
||||
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||
# define __format__ format
|
||||
# define __printf__ printf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (STDC_HEADERS) || defined (__GNU_LIBRARY__)
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# define ANSI_STRING 1
|
||||
#else /* No standard headers. */
|
||||
# ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
# define ANSI_STRING 1
|
||||
# else
|
||||
# include <strings.h>
|
||||
# endif
|
||||
# ifdef HAVE_MEMORY_H
|
||||
# include <memory.h>
|
||||
# endif
|
||||
# ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
# else
|
||||
extern char *malloc PARAMS ((int));
|
||||
extern char *realloc PARAMS ((char *, int));
|
||||
extern void free PARAMS ((char *));
|
||||
|
||||
extern void abort PARAMS ((void)) __attribute__ ((noreturn));
|
||||
extern void exit PARAMS ((int)) __attribute__ ((noreturn));
|
||||
# endif /* HAVE_STDLIB_H. */
|
||||
|
||||
#endif /* Standard headers. */
|
||||
|
||||
/* These should be in stdlib.h. Make sure we have them. */
|
||||
#ifndef EXIT_SUCCESS
|
||||
# define EXIT_SUCCESS 0
|
||||
#endif
|
||||
#ifndef EXIT_FAILURE
|
||||
# define EXIT_FAILURE 0
|
||||
#endif
|
||||
|
||||
#ifdef ANSI_STRING
|
||||
|
||||
# ifndef bcmp
|
||||
# define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
|
||||
# endif
|
||||
# ifndef bzero
|
||||
# define bzero(s, n) memset ((s), 0, (n))
|
||||
# endif
|
||||
# if defined(HAVE_MEMMOVE) && !defined(bcopy)
|
||||
# define bcopy(s, d, n) memmove ((d), (s), (n))
|
||||
# endif
|
||||
|
||||
#else /* Not ANSI_STRING. */
|
||||
|
||||
# ifndef HAVE_STRCHR
|
||||
# define strchr(s, c) index((s), (c))
|
||||
# define strrchr(s, c) rindex((s), (c))
|
||||
# endif
|
||||
|
||||
# ifndef bcmp
|
||||
extern int bcmp PARAMS ((const char *, const char *, int));
|
||||
# endif
|
||||
# ifndef bzero
|
||||
extern void bzero PARAMS ((char *, int));
|
||||
#endif
|
||||
# ifndef bcopy
|
||||
extern void bcopy PARAMS ((const char *b1, char *b2, int));
|
||||
# endif
|
||||
|
||||
#endif /* ANSI_STRING. */
|
||||
#undef ANSI_STRING
|
||||
|
||||
/* SCO Xenix has a buggy macro definition in <string.h>. */
|
||||
#undef strerror
|
||||
|
||||
#if !defined(ANSI_STRING) && !defined(__DECC)
|
||||
extern char *strerror PARAMS ((int errnum));
|
||||
#endif
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
#define FILE_TIMESTAMP uintmax_t
|
||||
|
||||
#if !defined(HAVE_STRSIGNAL)
|
||||
extern char *strsignal PARAMS ((int signum));
|
||||
#endif
|
||||
|
||||
/* ISDIGIT offers the following features:
|
||||
- Its arg may be any int or unsigned int; it need not be an unsigned char.
|
||||
- It's guaranteed to evaluate its argument exactly once.
|
||||
NOTE! Make relies on this behavior, don't change it!
|
||||
- It's typically faster.
|
||||
POSIX 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
|
||||
only '0' through '9' are digits. Prefer ISDIGIT to isdigit() unless
|
||||
it's important to use the locale's definition of `digit' even when the
|
||||
host does not conform to POSIX. */
|
||||
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
|
||||
|
||||
#ifndef iAPX286
|
||||
# define streq(a, b) \
|
||||
((a) == (b) || \
|
||||
(*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
|
||||
# ifdef HAVE_CASE_INSENSITIVE_FS
|
||||
/* This is only used on Windows/DOS platforms, so we assume strcmpi(). */
|
||||
# define strieq(a, b) \
|
||||
((a) == (b) \
|
||||
|| (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \
|
||||
&& (*(a) == '\0' || !strcmpi ((a) + 1, (b) + 1))))
|
||||
# else
|
||||
# define strieq(a, b) streq(a, b)
|
||||
# endif
|
||||
#else
|
||||
/* Buggy compiler can't handle this. */
|
||||
# define streq(a, b) (strcmp ((a), (b)) == 0)
|
||||
# define strieq(a, b) (strcmp ((a), (b)) == 0)
|
||||
#endif
|
||||
#define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0)
|
||||
#ifdef VMS
|
||||
extern int strcmpi (const char *,const char *);
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined(ENUM_BITFIELDS)
|
||||
# define ENUM_BITFIELD(bits) :bits
|
||||
#else
|
||||
# define ENUM_BITFIELD(bits)
|
||||
#endif
|
||||
|
||||
/* Handle gettext and locales. */
|
||||
|
||||
#if HAVE_LOCALE_H
|
||||
# include <locale.h>
|
||||
#else
|
||||
# define setlocale(category, locale)
|
||||
#endif
|
||||
|
||||
#include <gettext.h>
|
||||
|
||||
#define _(msgid) gettext (msgid)
|
||||
#define N_(msgid) gettext_noop (msgid)
|
||||
#define S_(msg1,msg2,num) ngettext (msg1,msg2,num)
|
||||
|
||||
/* Handle other OSs. */
|
||||
|
||||
#if defined(__MSDOS__) || defined(WINDOWS32)
|
||||
# define PATH_SEPARATOR_CHAR ';'
|
||||
#else
|
||||
# if defined(VMS)
|
||||
# define PATH_SEPARATOR_CHAR ','
|
||||
# else
|
||||
# define PATH_SEPARATOR_CHAR ':'
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef WINDOWS32
|
||||
# include <fcntl.h>
|
||||
# include <malloc.h>
|
||||
# define pipe(p) _pipe(p, 512, O_BINARY)
|
||||
# define kill(pid,sig) w32_kill(pid,sig)
|
||||
|
||||
extern void sync_Path_environment(void);
|
||||
extern int kill(int pid, int sig);
|
||||
extern int safe_stat(char *file, struct stat *sb);
|
||||
extern char *end_of_token_w32(char *s, char stopchar);
|
||||
extern int find_and_set_default_shell(char *token);
|
||||
|
||||
/* indicates whether or not we have Bourne shell */
|
||||
extern int no_default_sh_exe;
|
||||
|
||||
/* is default_shell unixy? */
|
||||
extern int unixy_shell;
|
||||
#endif /* WINDOWS32 */
|
||||
|
||||
struct floc
|
||||
{
|
||||
char *filenm;
|
||||
unsigned long lineno;
|
||||
};
|
||||
#define NILF ((struct floc *)0)
|
||||
|
||||
#define STRING_SIZE_TUPLE(_s) (_s), (sizeof (_s)-1)
|
||||
|
||||
|
||||
/* Fancy processing for variadic functions in both ANSI and pre-ANSI
|
||||
compilers. */
|
||||
#if defined __STDC__ && __STDC__
|
||||
extern void message (int prefix, const char *fmt, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
extern void error (const struct floc *flocp, const char *fmt, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
extern void fatal (const struct floc *flocp, const char *fmt, ...)
|
||||
__attribute__ ((noreturn, __format__ (__printf__, 2, 3)));
|
||||
#else
|
||||
extern void message ();
|
||||
extern void error ();
|
||||
extern void fatal ();
|
||||
#endif
|
||||
|
||||
extern void die PARAMS ((int)) __attribute__ ((noreturn));
|
||||
extern void log_working_directory PARAMS ((int));
|
||||
extern void pfatal_with_name PARAMS ((const char *)) __attribute__ ((noreturn));
|
||||
extern void perror_with_name PARAMS ((const char *, const char *));
|
||||
extern char *savestring PARAMS ((const char *, unsigned int));
|
||||
extern char *concat PARAMS ((const char *, const char *, const char *));
|
||||
extern char *xmalloc PARAMS ((unsigned int));
|
||||
extern char *xrealloc PARAMS ((char *, unsigned int));
|
||||
extern char *xstrdup PARAMS ((const char *));
|
||||
extern char *find_next_token PARAMS ((char **, unsigned int *));
|
||||
extern char *next_token PARAMS ((const char *));
|
||||
extern char *end_of_token PARAMS ((char *));
|
||||
extern void collapse_continuations PARAMS ((char *));
|
||||
extern void remove_comments PARAMS((char *));
|
||||
extern char *sindex PARAMS ((const char *, unsigned int, \
|
||||
const char *, unsigned int));
|
||||
extern char *lindex PARAMS ((const char *, const char *, int));
|
||||
extern int alpha_compare PARAMS ((const void *, const void *));
|
||||
extern void print_spaces PARAMS ((unsigned int));
|
||||
extern char *find_char_unquote PARAMS ((char *, int, int, int));
|
||||
extern char *find_percent PARAMS ((char *));
|
||||
extern FILE *open_tmpfile PARAMS ((char **, const char *));
|
||||
|
||||
#ifndef NO_ARCHIVES
|
||||
extern int ar_name PARAMS ((char *));
|
||||
extern void ar_parse_name PARAMS ((char *, char **, char **));
|
||||
extern int ar_touch PARAMS ((char *));
|
||||
extern time_t ar_member_date PARAMS ((char *));
|
||||
#endif
|
||||
|
||||
extern int dir_file_exists_p PARAMS ((char *, char *));
|
||||
extern int file_exists_p PARAMS ((char *));
|
||||
extern int file_impossible_p PARAMS ((char *));
|
||||
extern void file_impossible PARAMS ((char *));
|
||||
extern char *dir_name PARAMS ((char *));
|
||||
extern void hash_init_directories PARAMS ((void));
|
||||
|
||||
extern void define_default_variables PARAMS ((void));
|
||||
extern void set_default_suffixes PARAMS ((void));
|
||||
extern void install_default_suffix_rules PARAMS ((void));
|
||||
extern void install_default_implicit_rules PARAMS ((void));
|
||||
|
||||
extern void build_vpath_lists PARAMS ((void));
|
||||
extern void construct_vpath_list PARAMS ((char *pattern, char *dirpath));
|
||||
extern int vpath_search PARAMS ((char **file, FILE_TIMESTAMP *mtime_ptr));
|
||||
extern int gpath_search PARAMS ((char *file, int len));
|
||||
|
||||
extern void construct_include_path PARAMS ((char **arg_dirs));
|
||||
|
||||
extern void user_access PARAMS ((void));
|
||||
extern void make_access PARAMS ((void));
|
||||
extern void child_access PARAMS ((void));
|
||||
|
||||
#ifdef HAVE_VFORK_H
|
||||
# include <vfork.h>
|
||||
#endif
|
||||
|
||||
/* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
|
||||
because such systems often declare them in header files anyway. */
|
||||
|
||||
#if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32)
|
||||
|
||||
extern long int atol ();
|
||||
# ifndef VMS
|
||||
extern long int lseek ();
|
||||
# endif
|
||||
|
||||
#endif /* Not GNU C library or POSIX. */
|
||||
|
||||
#ifdef HAVE_GETCWD
|
||||
# if !defined(VMS) && !defined(__DECC)
|
||||
extern char *getcwd ();
|
||||
#endif
|
||||
#else
|
||||
extern char *getwd ();
|
||||
# define getcwd(buf, len) getwd (buf)
|
||||
#endif
|
||||
|
||||
extern const struct floc *reading_file;
|
||||
|
||||
extern char **environ;
|
||||
|
||||
extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
|
||||
extern int print_data_base_flag, question_flag, touch_flag, always_make_flag;
|
||||
extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag;
|
||||
extern int print_version_flag, print_directory_flag;
|
||||
extern int warn_undefined_variables_flag, posix_pedantic, not_parallel;
|
||||
extern int clock_skew_detected;
|
||||
|
||||
/* can we run commands via 'sh -c xxx' or must we use batch files? */
|
||||
extern int batch_mode_shell;
|
||||
|
||||
extern unsigned int job_slots;
|
||||
extern int job_fds[2];
|
||||
extern int job_rfd;
|
||||
#ifndef NO_FLOAT
|
||||
extern double max_load_average;
|
||||
#else
|
||||
extern int max_load_average;
|
||||
#endif
|
||||
|
||||
extern char *program;
|
||||
extern char *starting_directory;
|
||||
extern unsigned int makelevel;
|
||||
extern char *version_string, *remote_description;
|
||||
|
||||
extern unsigned int commands_started;
|
||||
|
||||
extern int handling_fatal_signal;
|
||||
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
|
||||
#endif
|
||||
#ifndef MAX
|
||||
#define MAX(_a,_b) ((_a)>(_b)?(_a):(_b))
|
||||
#endif
|
||||
|
||||
#ifdef VMS
|
||||
# define MAKE_SUCCESS 1
|
||||
# define MAKE_TROUBLE 2
|
||||
# define MAKE_FAILURE 3
|
||||
#else
|
||||
# define MAKE_SUCCESS 0
|
||||
# define MAKE_TROUBLE 1
|
||||
# define MAKE_FAILURE 2
|
||||
#endif
|
||||
|
||||
/* Set up heap debugging library dmalloc. */
|
||||
|
||||
#ifdef HAVE_DMALLOC_H
|
||||
#include <dmalloc.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* If we have broken SA_RESTART support, then wrap stat() and readdir() with
|
||||
versions that handle EINTR. Note that there are still plenty of system
|
||||
calls that can fail with EINTR but this, reportedly, gets the vast
|
||||
majority of failure cases. If you still experience failures you'll need
|
||||
to either get a system where SA_RESTART works, or you need to avoid -j. */
|
||||
|
||||
#ifdef HAVE_BROKEN_RESTART
|
||||
|
||||
/* Here we make an assumption that a system with a broken SA_RESTART has
|
||||
dirent.h. Right now the only system I know of in this category is PTX, and
|
||||
it does have dirent.h.
|
||||
*/
|
||||
#include <dirent.h>
|
||||
|
||||
#define stat(_f,_b) atomic_stat ((_f), (_b))
|
||||
#define readdir(_d) atomic_readdir (_d)
|
||||
|
||||
extern int atomic_stat PARAMS ((const char *file, struct stat *buf));
|
||||
extern struct dirent *atomic_readdir PARAMS ((DIR *dir));
|
||||
|
||||
#endif
|
||||
893
flaim/external/w32/make/misc.c
vendored
Normal file
893
flaim/external/w32/make/misc.c
vendored
Normal file
@@ -0,0 +1,893 @@
|
||||
/* Miscellaneous generic support functions for GNU Make.
|
||||
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997,
|
||||
2002 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "make.h"
|
||||
#include "dep.h"
|
||||
#include "debug.h"
|
||||
|
||||
/* Variadic functions. We go through contortions to allow proper function
|
||||
prototypes for both ANSI and pre-ANSI C compilers, and also for those
|
||||
which support stdarg.h vs. varargs.h, and finally those which have
|
||||
vfprintf(), etc. and those who have _doprnt... or nothing.
|
||||
|
||||
This fancy stuff all came from GNU fileutils, except for the VA_PRINTF and
|
||||
VA_END macros used here since we have multiple print functions. */
|
||||
|
||||
#if HAVE_VPRINTF || HAVE_DOPRNT
|
||||
# define HAVE_STDVARARGS 1
|
||||
# if __STDC__
|
||||
# include <stdarg.h>
|
||||
# define VA_START(args, lastarg) va_start(args, lastarg)
|
||||
# else
|
||||
# include <varargs.h>
|
||||
# define VA_START(args, lastarg) va_start(args)
|
||||
# endif
|
||||
# if HAVE_VPRINTF
|
||||
# define VA_PRINTF(fp, lastarg, args) vfprintf((fp), (lastarg), (args))
|
||||
# else
|
||||
# define VA_PRINTF(fp, lastarg, args) _doprnt((lastarg), (args), (fp))
|
||||
# endif
|
||||
# define VA_END(args) va_end(args)
|
||||
#else
|
||||
/* # undef HAVE_STDVARARGS */
|
||||
# define va_alist a1, a2, a3, a4, a5, a6, a7, a8
|
||||
# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
|
||||
# define VA_START(args, lastarg)
|
||||
# define VA_PRINTF(fp, lastarg, args) fprintf((fp), (lastarg), va_alist)
|
||||
# define VA_END(args)
|
||||
#endif
|
||||
|
||||
|
||||
/* Compare strings *S1 and *S2.
|
||||
Return negative if the first is less, positive if it is greater,
|
||||
zero if they are equal. */
|
||||
|
||||
int
|
||||
alpha_compare (v1, v2)
|
||||
const void *v1, *v2;
|
||||
{
|
||||
const char *s1 = *((char **)v1);
|
||||
const char *s2 = *((char **)v2);
|
||||
|
||||
if (*s1 != *s2)
|
||||
return *s1 - *s2;
|
||||
return strcmp (s1, s2);
|
||||
}
|
||||
|
||||
/* Discard each backslash-newline combination from LINE.
|
||||
Backslash-backslash-newline combinations become backslash-newlines.
|
||||
This is done by copying the text at LINE into itself. */
|
||||
|
||||
void
|
||||
collapse_continuations (line)
|
||||
char *line;
|
||||
{
|
||||
register char *in, *out, *p;
|
||||
register int backslash;
|
||||
register unsigned int bs_write;
|
||||
|
||||
in = strchr (line, '\n');
|
||||
if (in == 0)
|
||||
return;
|
||||
|
||||
out = in;
|
||||
while (out > line && out[-1] == '\\')
|
||||
--out;
|
||||
|
||||
while (*in != '\0')
|
||||
{
|
||||
/* BS_WRITE gets the number of quoted backslashes at
|
||||
the end just before IN, and BACKSLASH gets nonzero
|
||||
if the next character is quoted. */
|
||||
backslash = 0;
|
||||
bs_write = 0;
|
||||
for (p = in - 1; p >= line && *p == '\\'; --p)
|
||||
{
|
||||
if (backslash)
|
||||
++bs_write;
|
||||
backslash = !backslash;
|
||||
|
||||
/* It should be impossible to go back this far without exiting,
|
||||
but if we do, we can't get the right answer. */
|
||||
if (in == out - 1)
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* Output the appropriate number of backslashes. */
|
||||
while (bs_write-- > 0)
|
||||
*out++ = '\\';
|
||||
|
||||
/* Skip the newline. */
|
||||
++in;
|
||||
|
||||
/* If the newline is quoted, discard following whitespace
|
||||
and any preceding whitespace; leave just one space. */
|
||||
if (backslash)
|
||||
{
|
||||
in = next_token (in);
|
||||
while (out > line && isblank ((unsigned char)out[-1]))
|
||||
--out;
|
||||
*out++ = ' ';
|
||||
}
|
||||
else
|
||||
/* If the newline isn't quoted, put it in the output. */
|
||||
*out++ = '\n';
|
||||
|
||||
/* Now copy the following line to the output.
|
||||
Stop when we find backslashes followed by a newline. */
|
||||
while (*in != '\0')
|
||||
if (*in == '\\')
|
||||
{
|
||||
p = in + 1;
|
||||
while (*p == '\\')
|
||||
++p;
|
||||
if (*p == '\n')
|
||||
{
|
||||
in = p;
|
||||
break;
|
||||
}
|
||||
while (in < p)
|
||||
*out++ = *in++;
|
||||
}
|
||||
else
|
||||
*out++ = *in++;
|
||||
}
|
||||
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
|
||||
/* Remove comments from LINE.
|
||||
This is done by copying the text at LINE onto itself. */
|
||||
|
||||
void
|
||||
remove_comments (line)
|
||||
char *line;
|
||||
{
|
||||
char *comment;
|
||||
|
||||
comment = find_char_unquote (line, '#', 0, 0);
|
||||
|
||||
if (comment != 0)
|
||||
/* Cut off the line at the #. */
|
||||
*comment = '\0';
|
||||
}
|
||||
|
||||
/* Print N spaces (used in debug for target-depth). */
|
||||
|
||||
void
|
||||
print_spaces (n)
|
||||
unsigned int n;
|
||||
{
|
||||
while (n-- > 0)
|
||||
putchar (' ');
|
||||
}
|
||||
|
||||
|
||||
/* Return a newly-allocated string whose contents
|
||||
concatenate those of s1, s2, s3. */
|
||||
|
||||
char *
|
||||
concat (s1, s2, s3)
|
||||
const char *s1, *s2, *s3;
|
||||
{
|
||||
unsigned int len1, len2, len3;
|
||||
char *result;
|
||||
|
||||
len1 = *s1 != '\0' ? strlen (s1) : 0;
|
||||
len2 = *s2 != '\0' ? strlen (s2) : 0;
|
||||
len3 = *s3 != '\0' ? strlen (s3) : 0;
|
||||
|
||||
result = (char *) xmalloc (len1 + len2 + len3 + 1);
|
||||
|
||||
if (*s1 != '\0')
|
||||
bcopy (s1, result, len1);
|
||||
if (*s2 != '\0')
|
||||
bcopy (s2, result + len1, len2);
|
||||
if (*s3 != '\0')
|
||||
bcopy (s3, result + len1 + len2, len3);
|
||||
*(result + len1 + len2 + len3) = '\0';
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Print a message on stdout. */
|
||||
|
||||
void
|
||||
#if __STDC__ && HAVE_STDVARARGS
|
||||
message (int prefix, const char *fmt, ...)
|
||||
#else
|
||||
message (prefix, fmt, va_alist)
|
||||
int prefix;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#if HAVE_STDVARARGS
|
||||
va_list args;
|
||||
#endif
|
||||
|
||||
log_working_directory (1);
|
||||
|
||||
if (fmt != 0)
|
||||
{
|
||||
if (prefix)
|
||||
{
|
||||
if (makelevel == 0)
|
||||
printf ("%s: ", program);
|
||||
else
|
||||
printf ("%s[%u]: ", program, makelevel);
|
||||
}
|
||||
VA_START (args, fmt);
|
||||
VA_PRINTF (stdout, fmt, args);
|
||||
VA_END (args);
|
||||
putchar ('\n');
|
||||
}
|
||||
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
/* Print an error message. */
|
||||
|
||||
void
|
||||
#if __STDC__ && HAVE_STDVARARGS
|
||||
error (const struct floc *flocp, const char *fmt, ...)
|
||||
#else
|
||||
error (flocp, fmt, va_alist)
|
||||
const struct floc *flocp;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#if HAVE_STDVARARGS
|
||||
va_list args;
|
||||
#endif
|
||||
|
||||
log_working_directory (1);
|
||||
|
||||
if (flocp && flocp->filenm)
|
||||
fprintf (stderr, "%s:%lu: ", flocp->filenm, flocp->lineno);
|
||||
else if (makelevel == 0)
|
||||
fprintf (stderr, "%s: ", program);
|
||||
else
|
||||
fprintf (stderr, "%s[%u]: ", program, makelevel);
|
||||
|
||||
VA_START(args, fmt);
|
||||
VA_PRINTF (stderr, fmt, args);
|
||||
VA_END (args);
|
||||
|
||||
putc ('\n', stderr);
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
/* Print an error message and exit. */
|
||||
|
||||
void
|
||||
#if __STDC__ && HAVE_STDVARARGS
|
||||
fatal (const struct floc *flocp, const char *fmt, ...)
|
||||
#else
|
||||
fatal (flocp, fmt, va_alist)
|
||||
const struct floc *flocp;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#if HAVE_STDVARARGS
|
||||
va_list args;
|
||||
#endif
|
||||
|
||||
log_working_directory (1);
|
||||
|
||||
if (flocp && flocp->filenm)
|
||||
fprintf (stderr, "%s:%lu: *** ", flocp->filenm, flocp->lineno);
|
||||
else if (makelevel == 0)
|
||||
fprintf (stderr, "%s: *** ", program);
|
||||
else
|
||||
fprintf (stderr, "%s[%u]: *** ", program, makelevel);
|
||||
|
||||
VA_START(args, fmt);
|
||||
VA_PRINTF (stderr, fmt, args);
|
||||
VA_END (args);
|
||||
|
||||
fputs (_(". Stop.\n"), stderr);
|
||||
|
||||
die (2);
|
||||
}
|
||||
|
||||
#ifndef HAVE_STRERROR
|
||||
|
||||
#undef strerror
|
||||
|
||||
char *
|
||||
strerror (errnum)
|
||||
int errnum;
|
||||
{
|
||||
extern int errno, sys_nerr;
|
||||
#ifndef __DECC
|
||||
extern char *sys_errlist[];
|
||||
#endif
|
||||
static char buf[] = "Unknown error 12345678901234567890";
|
||||
|
||||
if (errno < sys_nerr)
|
||||
return sys_errlist[errnum];
|
||||
|
||||
sprintf (buf, _("Unknown error %d"), errnum);
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Print an error message from errno. */
|
||||
|
||||
void
|
||||
perror_with_name (str, name)
|
||||
const char *str, *name;
|
||||
{
|
||||
error (NILF, _("%s%s: %s"), str, name, strerror (errno));
|
||||
}
|
||||
|
||||
/* Print an error message from errno and exit. */
|
||||
|
||||
void
|
||||
pfatal_with_name (name)
|
||||
const char *name;
|
||||
{
|
||||
fatal (NILF, _("%s: %s"), name, strerror (errno));
|
||||
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/* Like malloc but get fatal error if memory is exhausted. */
|
||||
/* Don't bother if we're using dmalloc; it provides these for us. */
|
||||
|
||||
#ifndef HAVE_DMALLOC_H
|
||||
|
||||
#undef xmalloc
|
||||
#undef xrealloc
|
||||
#undef xstrdup
|
||||
|
||||
char *
|
||||
xmalloc (size)
|
||||
unsigned int size;
|
||||
{
|
||||
char *result = (char *) malloc (size);
|
||||
if (result == 0)
|
||||
fatal (NILF, _("virtual memory exhausted"));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
xrealloc (ptr, size)
|
||||
char *ptr;
|
||||
unsigned int size;
|
||||
{
|
||||
char *result;
|
||||
|
||||
/* Some older implementations of realloc() don't conform to ANSI. */
|
||||
result = ptr ? realloc (ptr, size) : malloc (size);
|
||||
if (result == 0)
|
||||
fatal (NILF, _("virtual memory exhausted"));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
xstrdup (ptr)
|
||||
const char *ptr;
|
||||
{
|
||||
char *result;
|
||||
|
||||
#ifdef HAVE_STRDUP
|
||||
result = strdup (ptr);
|
||||
#else
|
||||
result = (char *) malloc (strlen (ptr) + 1);
|
||||
#endif
|
||||
|
||||
if (result == 0)
|
||||
fatal (NILF, _("virtual memory exhausted"));
|
||||
|
||||
#ifdef HAVE_STRDUP
|
||||
return result;
|
||||
#else
|
||||
return strcpy(result, ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* HAVE_DMALLOC_H */
|
||||
|
||||
char *
|
||||
savestring (str, length)
|
||||
const char *str;
|
||||
unsigned int length;
|
||||
{
|
||||
register char *out = (char *) xmalloc (length + 1);
|
||||
if (length > 0)
|
||||
bcopy (str, out, length);
|
||||
out[length] = '\0';
|
||||
return out;
|
||||
}
|
||||
|
||||
/* Search string BIG (length BLEN) for an occurrence of
|
||||
string SMALL (length SLEN). Return a pointer to the
|
||||
beginning of the first occurrence, or return nil if none found. */
|
||||
|
||||
char *
|
||||
sindex (big, blen, small, slen)
|
||||
const char *big;
|
||||
unsigned int blen;
|
||||
const char *small;
|
||||
unsigned int slen;
|
||||
{
|
||||
if (!blen)
|
||||
blen = strlen (big);
|
||||
if (!slen)
|
||||
slen = strlen (small);
|
||||
|
||||
if (slen && blen >= slen)
|
||||
{
|
||||
register unsigned int b;
|
||||
|
||||
/* Quit when there's not enough room left for the small string. */
|
||||
--slen;
|
||||
blen -= slen;
|
||||
|
||||
for (b = 0; b < blen; ++b, ++big)
|
||||
if (*big == *small && strneq (big + 1, small + 1, slen))
|
||||
return (char *)big;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Limited INDEX:
|
||||
Search through the string STRING, which ends at LIMIT, for the character C.
|
||||
Returns a pointer to the first occurrence, or nil if none is found.
|
||||
Like INDEX except that the string searched ends where specified
|
||||
instead of at the first null. */
|
||||
|
||||
char *
|
||||
lindex (s, limit, c)
|
||||
register const char *s, *limit;
|
||||
int c;
|
||||
{
|
||||
while (s < limit)
|
||||
if (*s++ == c)
|
||||
return (char *)(s - 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return the address of the first whitespace or null in the string S. */
|
||||
|
||||
char *
|
||||
end_of_token (s)
|
||||
char *s;
|
||||
{
|
||||
while (*s != '\0' && !isblank ((unsigned char)*s))
|
||||
++s;
|
||||
return s;
|
||||
}
|
||||
|
||||
#ifdef WINDOWS32
|
||||
/*
|
||||
* Same as end_of_token, but take into account a stop character
|
||||
*/
|
||||
char *
|
||||
end_of_token_w32 (s, stopchar)
|
||||
char *s;
|
||||
char stopchar;
|
||||
{
|
||||
register char *p = s;
|
||||
register int backslash = 0;
|
||||
|
||||
while (*p != '\0' && *p != stopchar
|
||||
&& (backslash || !isblank ((unsigned char)*p)))
|
||||
{
|
||||
if (*p++ == '\\')
|
||||
{
|
||||
backslash = !backslash;
|
||||
while (*p == '\\')
|
||||
{
|
||||
backslash = !backslash;
|
||||
++p;
|
||||
}
|
||||
}
|
||||
else
|
||||
backslash = 0;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Return the address of the first nonwhitespace or null in the string S. */
|
||||
|
||||
char *
|
||||
next_token (s)
|
||||
const char *s;
|
||||
{
|
||||
while (isblank ((unsigned char)*s))
|
||||
++s;
|
||||
return (char *)s;
|
||||
}
|
||||
|
||||
/* Find the next token in PTR; return the address of it, and store the
|
||||
length of the token into *LENGTHPTR if LENGTHPTR is not nil. */
|
||||
|
||||
char *
|
||||
find_next_token (ptr, lengthptr)
|
||||
char **ptr;
|
||||
unsigned int *lengthptr;
|
||||
{
|
||||
char *p = next_token (*ptr);
|
||||
char *end;
|
||||
|
||||
if (*p == '\0')
|
||||
return 0;
|
||||
|
||||
*ptr = end = end_of_token (p);
|
||||
if (lengthptr != 0)
|
||||
*lengthptr = end - p;
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Copy a chain of `struct dep', making a new chain
|
||||
with the same contents as the old one. */
|
||||
|
||||
struct dep *
|
||||
copy_dep_chain (d)
|
||||
register struct dep *d;
|
||||
{
|
||||
register struct dep *c;
|
||||
struct dep *firstnew = 0;
|
||||
struct dep *lastnew = 0;
|
||||
|
||||
while (d != 0)
|
||||
{
|
||||
c = (struct dep *) xmalloc (sizeof (struct dep));
|
||||
bcopy ((char *) d, (char *) c, sizeof (struct dep));
|
||||
if (c->name != 0)
|
||||
c->name = xstrdup (c->name);
|
||||
c->next = 0;
|
||||
if (firstnew == 0)
|
||||
firstnew = lastnew = c;
|
||||
else
|
||||
lastnew = lastnew->next = c;
|
||||
|
||||
d = d->next;
|
||||
}
|
||||
|
||||
return firstnew;
|
||||
}
|
||||
|
||||
#ifdef iAPX286
|
||||
/* The losing compiler on this machine can't handle this macro. */
|
||||
|
||||
char *
|
||||
dep_name (dep)
|
||||
struct dep *dep;
|
||||
{
|
||||
return dep->name == 0 ? dep->file->name : dep->name;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GETLOADAVG_PRIVILEGED
|
||||
|
||||
#ifdef POSIX
|
||||
|
||||
/* Hopefully if a system says it's POSIX.1 and has the setuid and setgid
|
||||
functions, they work as POSIX.1 says. Some systems (Alpha OSF/1 1.2,
|
||||
for example) which claim to be POSIX.1 also have the BSD setreuid and
|
||||
setregid functions, but they don't work as in BSD and only the POSIX.1
|
||||
way works. */
|
||||
|
||||
#undef HAVE_SETREUID
|
||||
#undef HAVE_SETREGID
|
||||
|
||||
#else /* Not POSIX. */
|
||||
|
||||
/* Some POSIX.1 systems have the seteuid and setegid functions. In a
|
||||
POSIX-like system, they are the best thing to use. However, some
|
||||
non-POSIX systems have them too but they do not work in the POSIX style
|
||||
and we must use setreuid and setregid instead. */
|
||||
|
||||
#undef HAVE_SETEUID
|
||||
#undef HAVE_SETEGID
|
||||
|
||||
#endif /* POSIX. */
|
||||
|
||||
#ifndef HAVE_UNISTD_H
|
||||
extern int getuid (), getgid (), geteuid (), getegid ();
|
||||
extern int setuid (), setgid ();
|
||||
#ifdef HAVE_SETEUID
|
||||
extern int seteuid ();
|
||||
#else
|
||||
#ifdef HAVE_SETREUID
|
||||
extern int setreuid ();
|
||||
#endif /* Have setreuid. */
|
||||
#endif /* Have seteuid. */
|
||||
#ifdef HAVE_SETEGID
|
||||
extern int setegid ();
|
||||
#else
|
||||
#ifdef HAVE_SETREGID
|
||||
extern int setregid ();
|
||||
#endif /* Have setregid. */
|
||||
#endif /* Have setegid. */
|
||||
#endif /* No <unistd.h>. */
|
||||
|
||||
/* Keep track of the user and group IDs for user- and make- access. */
|
||||
static int user_uid = -1, user_gid = -1, make_uid = -1, make_gid = -1;
|
||||
#define access_inited (user_uid != -1)
|
||||
static enum { make, user } current_access;
|
||||
|
||||
|
||||
/* Under -d, write a message describing the current IDs. */
|
||||
|
||||
static void
|
||||
log_access (flavor)
|
||||
char *flavor;
|
||||
{
|
||||
if (! ISDB (DB_JOBS))
|
||||
return;
|
||||
|
||||
/* All the other debugging messages go to stdout,
|
||||
but we write this one to stderr because it might be
|
||||
run in a child fork whose stdout is piped. */
|
||||
|
||||
fprintf (stderr, _("%s: user %lu (real %lu), group %lu (real %lu)\n"),
|
||||
flavor, (unsigned long) geteuid (), (unsigned long) getuid (),
|
||||
(unsigned long) getegid (), (unsigned long) getgid ());
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init_access ()
|
||||
{
|
||||
#ifndef VMS
|
||||
user_uid = getuid ();
|
||||
user_gid = getgid ();
|
||||
|
||||
make_uid = geteuid ();
|
||||
make_gid = getegid ();
|
||||
|
||||
/* Do these ever fail? */
|
||||
if (user_uid == -1 || user_gid == -1 || make_uid == -1 || make_gid == -1)
|
||||
pfatal_with_name ("get{e}[gu]id");
|
||||
|
||||
log_access (_("Initialized access"));
|
||||
|
||||
current_access = make;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* GETLOADAVG_PRIVILEGED */
|
||||
|
||||
/* Give the process appropriate permissions for access to
|
||||
user data (i.e., to stat files, or to spawn a child process). */
|
||||
void
|
||||
user_access ()
|
||||
{
|
||||
#ifdef GETLOADAVG_PRIVILEGED
|
||||
|
||||
if (!access_inited)
|
||||
init_access ();
|
||||
|
||||
if (current_access == user)
|
||||
return;
|
||||
|
||||
/* We are in "make access" mode. This means that the effective user and
|
||||
group IDs are those of make (if it was installed setuid or setgid).
|
||||
We now want to set the effective user and group IDs to the real IDs,
|
||||
which are the IDs of the process that exec'd make. */
|
||||
|
||||
#ifdef HAVE_SETEUID
|
||||
|
||||
/* Modern systems have the seteuid/setegid calls which set only the
|
||||
effective IDs, which is ideal. */
|
||||
|
||||
if (seteuid (user_uid) < 0)
|
||||
pfatal_with_name ("user_access: seteuid");
|
||||
|
||||
#else /* Not HAVE_SETEUID. */
|
||||
|
||||
#ifndef HAVE_SETREUID
|
||||
|
||||
/* System V has only the setuid/setgid calls to set user/group IDs.
|
||||
There is an effective ID, which can be set by setuid/setgid.
|
||||
It can be set (unless you are root) only to either what it already is
|
||||
(returned by geteuid/getegid, now in make_uid/make_gid),
|
||||
the real ID (return by getuid/getgid, now in user_uid/user_gid),
|
||||
or the saved set ID (what the effective ID was before this set-ID
|
||||
executable (make) was exec'd). */
|
||||
|
||||
if (setuid (user_uid) < 0)
|
||||
pfatal_with_name ("user_access: setuid");
|
||||
|
||||
#else /* HAVE_SETREUID. */
|
||||
|
||||
/* In 4BSD, the setreuid/setregid calls set both the real and effective IDs.
|
||||
They may be set to themselves or each other. So you have two alternatives
|
||||
at any one time. If you use setuid/setgid, the effective will be set to
|
||||
the real, leaving only one alternative. Using setreuid/setregid, however,
|
||||
you can toggle between your two alternatives by swapping the values in a
|
||||
single setreuid or setregid call. */
|
||||
|
||||
if (setreuid (make_uid, user_uid) < 0)
|
||||
pfatal_with_name ("user_access: setreuid");
|
||||
|
||||
#endif /* Not HAVE_SETREUID. */
|
||||
#endif /* HAVE_SETEUID. */
|
||||
|
||||
#ifdef HAVE_SETEGID
|
||||
if (setegid (user_gid) < 0)
|
||||
pfatal_with_name ("user_access: setegid");
|
||||
#else
|
||||
#ifndef HAVE_SETREGID
|
||||
if (setgid (user_gid) < 0)
|
||||
pfatal_with_name ("user_access: setgid");
|
||||
#else
|
||||
if (setregid (make_gid, user_gid) < 0)
|
||||
pfatal_with_name ("user_access: setregid");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
current_access = user;
|
||||
|
||||
log_access (_("User access"));
|
||||
|
||||
#endif /* GETLOADAVG_PRIVILEGED */
|
||||
}
|
||||
|
||||
/* Give the process appropriate permissions for access to
|
||||
make data (i.e., the load average). */
|
||||
void
|
||||
make_access ()
|
||||
{
|
||||
#ifdef GETLOADAVG_PRIVILEGED
|
||||
|
||||
if (!access_inited)
|
||||
init_access ();
|
||||
|
||||
if (current_access == make)
|
||||
return;
|
||||
|
||||
/* See comments in user_access, above. */
|
||||
|
||||
#ifdef HAVE_SETEUID
|
||||
if (seteuid (make_uid) < 0)
|
||||
pfatal_with_name ("make_access: seteuid");
|
||||
#else
|
||||
#ifndef HAVE_SETREUID
|
||||
if (setuid (make_uid) < 0)
|
||||
pfatal_with_name ("make_access: setuid");
|
||||
#else
|
||||
if (setreuid (user_uid, make_uid) < 0)
|
||||
pfatal_with_name ("make_access: setreuid");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SETEGID
|
||||
if (setegid (make_gid) < 0)
|
||||
pfatal_with_name ("make_access: setegid");
|
||||
#else
|
||||
#ifndef HAVE_SETREGID
|
||||
if (setgid (make_gid) < 0)
|
||||
pfatal_with_name ("make_access: setgid");
|
||||
#else
|
||||
if (setregid (user_gid, make_gid) < 0)
|
||||
pfatal_with_name ("make_access: setregid");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
current_access = make;
|
||||
|
||||
log_access (_("Make access"));
|
||||
|
||||
#endif /* GETLOADAVG_PRIVILEGED */
|
||||
}
|
||||
|
||||
/* Give the process appropriate permissions for a child process.
|
||||
This is like user_access, but you can't get back to make_access. */
|
||||
void
|
||||
child_access ()
|
||||
{
|
||||
#ifdef GETLOADAVG_PRIVILEGED
|
||||
|
||||
if (!access_inited)
|
||||
abort ();
|
||||
|
||||
/* Set both the real and effective UID and GID to the user's.
|
||||
They cannot be changed back to make's. */
|
||||
|
||||
#ifndef HAVE_SETREUID
|
||||
if (setuid (user_uid) < 0)
|
||||
pfatal_with_name ("child_access: setuid");
|
||||
#else
|
||||
if (setreuid (user_uid, user_uid) < 0)
|
||||
pfatal_with_name ("child_access: setreuid");
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SETREGID
|
||||
if (setgid (user_gid) < 0)
|
||||
pfatal_with_name ("child_access: setgid");
|
||||
#else
|
||||
if (setregid (user_gid, user_gid) < 0)
|
||||
pfatal_with_name ("child_access: setregid");
|
||||
#endif
|
||||
|
||||
log_access (_("Child access"));
|
||||
|
||||
#endif /* GETLOADAVG_PRIVILEGED */
|
||||
}
|
||||
|
||||
#ifdef NEED_GET_PATH_MAX
|
||||
unsigned int
|
||||
get_path_max ()
|
||||
{
|
||||
static unsigned int value;
|
||||
|
||||
if (value == 0)
|
||||
{
|
||||
long int x = pathconf ("/", _PC_PATH_MAX);
|
||||
if (x > 0)
|
||||
value = x;
|
||||
else
|
||||
return MAXPATHLEN;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_BROKEN_RESTART
|
||||
|
||||
#undef stat
|
||||
#undef readdir
|
||||
|
||||
int
|
||||
atomic_stat(file, buf)
|
||||
const char *file;
|
||||
struct stat *buf;
|
||||
{
|
||||
int r;
|
||||
|
||||
while ((r = stat (file, buf)) < 0)
|
||||
if (errno != EINTR)
|
||||
break;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
struct dirent *
|
||||
atomic_readdir(dir)
|
||||
DIR *dir;
|
||||
{
|
||||
struct dirent *r;
|
||||
|
||||
while ((r = readdir (dir)) == NULL)
|
||||
if (errno != EINTR)
|
||||
break;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif /* HAVE_BROKEN_RESTART */
|
||||
65
flaim/external/w32/make/misc_w32.c
vendored
Normal file
65
flaim/external/w32/make/misc_w32.c
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include "proc.h"
|
||||
|
||||
|
||||
/*
|
||||
* Description: Convert a NULL string terminated UNIX environment block to
|
||||
* an environment block suitable for a windows32 system call
|
||||
*
|
||||
* Returns: TRUE= success, FALSE=fail
|
||||
*
|
||||
* Notes/Dependencies: the environment block is sorted in case-insensitive
|
||||
* order, is double-null terminated, and is a char *, not a char **
|
||||
*/
|
||||
int _cdecl compare(const void *a1, const void *a2)
|
||||
{
|
||||
return _stricoll(*((char**)a1),*((char**)a2));
|
||||
}
|
||||
bool_t
|
||||
arr2envblk(char **arr, char **envblk_out)
|
||||
{
|
||||
char **tmp;
|
||||
int size_needed;
|
||||
int arrcnt;
|
||||
char *ptr;
|
||||
|
||||
arrcnt = 0;
|
||||
while (arr[arrcnt]) {
|
||||
arrcnt++;
|
||||
}
|
||||
|
||||
tmp = (char**) calloc(arrcnt + 1, sizeof(char *));
|
||||
if (!tmp) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
arrcnt = 0;
|
||||
size_needed = 0;
|
||||
while (arr[arrcnt]) {
|
||||
tmp[arrcnt] = arr[arrcnt];
|
||||
size_needed += strlen(arr[arrcnt]) + 1;
|
||||
arrcnt++;
|
||||
}
|
||||
size_needed++;
|
||||
|
||||
qsort((void *) tmp, (size_t) arrcnt, sizeof (char*), compare);
|
||||
|
||||
ptr = *envblk_out = calloc(size_needed, 1);
|
||||
if (!ptr) {
|
||||
free(tmp);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
arrcnt = 0;
|
||||
while (tmp[arrcnt]) {
|
||||
strcpy(ptr, tmp[arrcnt]);
|
||||
ptr += strlen(tmp[arrcnt]) + 1;
|
||||
arrcnt++;
|
||||
}
|
||||
|
||||
free(tmp);
|
||||
return TRUE;
|
||||
}
|
||||
238
flaim/external/w32/make/pathstuff.c
vendored
Normal file
238
flaim/external/w32/make/pathstuff.c
vendored
Normal file
@@ -0,0 +1,238 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "make.h"
|
||||
#include "pathstuff.h"
|
||||
|
||||
/*
|
||||
* Convert delimiter separated vpath to Canonical format.
|
||||
*/
|
||||
char *
|
||||
convert_vpath_to_windows32(char *Path, char to_delim)
|
||||
{
|
||||
char *etok; /* token separator for old Path */
|
||||
|
||||
/*
|
||||
* Convert all spaces to delimiters. Note that pathnames which
|
||||
* contain blanks get trounced here. Use 8.3 format as a workaround.
|
||||
*/
|
||||
for (etok = Path; etok && *etok; etok++)
|
||||
if (isblank ((unsigned char) *etok))
|
||||
*etok = to_delim;
|
||||
|
||||
return (convert_Path_to_windows32(Path, to_delim));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert delimiter separated path to Canonical format.
|
||||
*/
|
||||
char *
|
||||
convert_Path_to_windows32(char *Path, char to_delim)
|
||||
{
|
||||
char *etok; /* token separator for old Path */
|
||||
char *p; /* points to element of old Path */
|
||||
|
||||
/* is this a multi-element Path ? */
|
||||
for (p = Path, etok = strpbrk(p, ":;");
|
||||
etok;
|
||||
etok = strpbrk(p, ":;"))
|
||||
if ((etok - p) == 1) {
|
||||
if (*(etok - 1) == ';' ||
|
||||
*(etok - 1) == ':') {
|
||||
etok[-1] = to_delim;
|
||||
etok[0] = to_delim;
|
||||
p = ++etok;
|
||||
continue; /* ignore empty bucket */
|
||||
} else if (!isalpha ((unsigned char) *p)) {
|
||||
/* found one to count, handle things like '.' */
|
||||
*etok = to_delim;
|
||||
p = ++etok;
|
||||
} else if ((*etok == ':') && (etok = strpbrk(etok+1, ":;"))) {
|
||||
/* found one to count, handle drive letter */
|
||||
*etok = to_delim;
|
||||
p = ++etok;
|
||||
} else
|
||||
/* all finished, force abort */
|
||||
p += strlen(p);
|
||||
} else {
|
||||
/* found another one, no drive letter */
|
||||
*etok = to_delim;
|
||||
p = ++etok;
|
||||
}
|
||||
|
||||
return Path;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert to forward slashes. Resolve to full pathname optionally
|
||||
*/
|
||||
char *
|
||||
w32ify(char *filename, int resolve)
|
||||
{
|
||||
static char w32_path[FILENAME_MAX];
|
||||
char *p;
|
||||
|
||||
if (resolve)
|
||||
_fullpath(w32_path, filename, sizeof (w32_path));
|
||||
else
|
||||
strncpy(w32_path, filename, sizeof (w32_path));
|
||||
|
||||
for (p = w32_path; p && *p; p++)
|
||||
if (*p == '\\')
|
||||
*p = '/';
|
||||
|
||||
return w32_path;
|
||||
}
|
||||
|
||||
char *
|
||||
getcwd_fs(char* buf, int len)
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (p = getcwd(buf, len)) {
|
||||
char *q = w32ify(buf, 0);
|
||||
strncpy(buf, q, len);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
#ifdef unused
|
||||
/*
|
||||
* Convert delimiter separated pathnames (e.g. PATH) or single file pathname
|
||||
* (e.g. c:/foo, c:\bar) to NutC format. If we are handed a string that
|
||||
* _NutPathToNutc() fails to convert, just return the path we were handed
|
||||
* and assume the caller will know what to do with it (It was probably
|
||||
* a mistake to try and convert it anyway due to some of the bizarre things
|
||||
* that might look like pathnames in makefiles).
|
||||
*/
|
||||
char *
|
||||
convert_path_to_nutc(char *path)
|
||||
{
|
||||
int count; /* count of path elements */
|
||||
char *nutc_path; /* new NutC path */
|
||||
int nutc_path_len; /* length of buffer to allocate for new path */
|
||||
char *pathp; /* pointer to nutc_path used to build it */
|
||||
char *etok; /* token separator for old path */
|
||||
char *p; /* points to element of old path */
|
||||
char sep; /* what flavor of separator used in old path */
|
||||
char *rval;
|
||||
|
||||
/* is this a multi-element path ? */
|
||||
for (p = path, etok = strpbrk(p, ":;"), count = 0;
|
||||
etok;
|
||||
etok = strpbrk(p, ":;"))
|
||||
if ((etok - p) == 1) {
|
||||
if (*(etok - 1) == ';' ||
|
||||
*(etok - 1) == ':') {
|
||||
p = ++etok;
|
||||
continue; /* ignore empty bucket */
|
||||
} else if (etok = strpbrk(etok+1, ":;"))
|
||||
/* found one to count, handle drive letter */
|
||||
p = ++etok, count++;
|
||||
else
|
||||
/* all finished, force abort */
|
||||
p += strlen(p);
|
||||
} else
|
||||
/* found another one, no drive letter */
|
||||
p = ++etok, count++;
|
||||
|
||||
if (count) {
|
||||
count++; /* x1;x2;x3 <- need to count x3 */
|
||||
|
||||
/*
|
||||
* Hazard a guess on how big the buffer needs to be.
|
||||
* We have to convert things like c:/foo to /c=/foo.
|
||||
*/
|
||||
nutc_path_len = strlen(path) + (count*2) + 1;
|
||||
nutc_path = xmalloc(nutc_path_len);
|
||||
pathp = nutc_path;
|
||||
*pathp = '\0';
|
||||
|
||||
/*
|
||||
* Loop through PATH and convert one elemnt of the path at at
|
||||
* a time. Single file pathnames will fail this and fall
|
||||
* to the logic below loop.
|
||||
*/
|
||||
for (p = path, etok = strpbrk(p, ":;");
|
||||
etok;
|
||||
etok = strpbrk(p, ":;")) {
|
||||
|
||||
/* don't trip up on device specifiers or empty path slots */
|
||||
if ((etok - p) == 1)
|
||||
if (*(etok - 1) == ';' ||
|
||||
*(etok - 1) == ':') {
|
||||
p = ++etok;
|
||||
continue;
|
||||
} else if ((etok = strpbrk(etok+1, ":;")) == NULL)
|
||||
break; /* thing found was a WINDOWS32 pathname */
|
||||
|
||||
/* save separator */
|
||||
sep = *etok;
|
||||
|
||||
/* terminate the current path element -- temporarily */
|
||||
*etok = '\0';
|
||||
|
||||
#ifdef __NUTC__
|
||||
/* convert to NutC format */
|
||||
if (_NutPathToNutc(p, pathp, 0) == FALSE) {
|
||||
free(nutc_path);
|
||||
rval = savestring(path, strlen(path));
|
||||
return rval;
|
||||
}
|
||||
#else
|
||||
*pathp++ = '/';
|
||||
*pathp++ = p[0];
|
||||
*pathp++ = '=';
|
||||
*pathp++ = '/';
|
||||
strcpy(pathp, &p[2]);
|
||||
#endif
|
||||
|
||||
pathp += strlen(pathp);
|
||||
*pathp++ = ':'; /* use Unix style path separtor for new path */
|
||||
*pathp = '\0'; /* make sure we are null terminaed */
|
||||
|
||||
/* restore path separator */
|
||||
*etok = sep;
|
||||
|
||||
/* point p to first char of next path element */
|
||||
p = ++etok;
|
||||
|
||||
}
|
||||
} else {
|
||||
nutc_path_len = strlen(path) + 3;
|
||||
nutc_path = xmalloc(nutc_path_len);
|
||||
pathp = nutc_path;
|
||||
*pathp = '\0';
|
||||
p = path;
|
||||
}
|
||||
|
||||
/*
|
||||
* OK, here we handle the last element in PATH (e.g. c of a;b;c)
|
||||
* or the path was a single filename and will be converted
|
||||
* here. Note, testing p here assures that we don't trip up
|
||||
* on paths like a;b; which have trailing delimiter followed by
|
||||
* nothing.
|
||||
*/
|
||||
if (*p != '\0') {
|
||||
#ifdef __NUTC__
|
||||
if (_NutPathToNutc(p, pathp, 0) == FALSE) {
|
||||
free(nutc_path);
|
||||
rval = savestring(path, strlen(path));
|
||||
return rval;
|
||||
}
|
||||
#else
|
||||
*pathp++ = '/';
|
||||
*pathp++ = p[0];
|
||||
*pathp++ = '=';
|
||||
*pathp++ = '/';
|
||||
strcpy(pathp, &p[2]);
|
||||
#endif
|
||||
} else
|
||||
*(pathp-1) = '\0'; /* we're already done, don't leave trailing : */
|
||||
|
||||
rval = savestring(nutc_path, strlen(nutc_path));
|
||||
free(nutc_path);
|
||||
return rval;
|
||||
}
|
||||
|
||||
#endif
|
||||
9
flaim/external/w32/make/pathstuff.h
vendored
Normal file
9
flaim/external/w32/make/pathstuff.h
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef _PATHSTUFF_H
|
||||
#define _PATHSTUFF_H
|
||||
|
||||
extern char * convert_Path_to_windows32(char *Path, char to_delim);
|
||||
extern char * convert_vpath_to_windows32(char *Path, char to_delim);
|
||||
extern char * w32ify(char *file, int resolve);
|
||||
extern char * getcwd_fs(char *buf, int len);
|
||||
|
||||
#endif
|
||||
13
flaim/external/w32/make/proc.h
vendored
Normal file
13
flaim/external/w32/make/proc.h
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef _PROC_H
|
||||
#define _PROC_H
|
||||
|
||||
typedef int bool_t;
|
||||
|
||||
#define E_SCALL 101
|
||||
#define E_IO 102
|
||||
#define E_NO_MEM 103
|
||||
#define E_FORK 104
|
||||
|
||||
extern bool_t arr2envblk(char **arr, char **envblk_out);
|
||||
|
||||
#endif
|
||||
3105
flaim/external/w32/make/read.c
vendored
Normal file
3105
flaim/external/w32/make/read.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1420
flaim/external/w32/make/remake.c
vendored
Normal file
1420
flaim/external/w32/make/remake.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
109
flaim/external/w32/make/remote-stub.c
vendored
Normal file
109
flaim/external/w32/make/remote-stub.c
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
/* Template for the remote job exportation interface to GNU Make.
|
||||
Copyright (C) 1988, 1989, 1992, 1993, 1996 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "make.h"
|
||||
#include "filedef.h"
|
||||
#include "job.h"
|
||||
#include "commands.h"
|
||||
|
||||
|
||||
char *remote_description = 0;
|
||||
|
||||
/* Call once at startup even if no commands are run. */
|
||||
|
||||
void
|
||||
remote_setup ()
|
||||
{
|
||||
}
|
||||
|
||||
/* Called before exit. */
|
||||
|
||||
void
|
||||
remote_cleanup ()
|
||||
{
|
||||
}
|
||||
|
||||
/* Return nonzero if the next job should be done remotely. */
|
||||
|
||||
int
|
||||
start_remote_job_p (first_p)
|
||||
int first_p;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Start a remote job running the command in ARGV,
|
||||
with environment from ENVP. It gets standard input from STDIN_FD. On
|
||||
failure, return nonzero. On success, return zero, and set *USED_STDIN
|
||||
to nonzero if it will actually use STDIN_FD, zero if not, set *ID_PTR to
|
||||
a unique identification, and set *IS_REMOTE to zero if the job is local,
|
||||
nonzero if it is remote (meaning *ID_PTR is a process ID). */
|
||||
|
||||
int
|
||||
start_remote_job (argv, envp, stdin_fd, is_remote, id_ptr, used_stdin)
|
||||
char **argv, **envp;
|
||||
int stdin_fd;
|
||||
int *is_remote;
|
||||
int *id_ptr;
|
||||
int *used_stdin;
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Get the status of a dead remote child. Block waiting for one to die
|
||||
if BLOCK is nonzero. Set *EXIT_CODE_PTR to the exit status, *SIGNAL_PTR
|
||||
to the termination signal or zero if it exited normally, and *COREDUMP_PTR
|
||||
nonzero if it dumped core. Return the ID of the child that died,
|
||||
0 if we would have to block and !BLOCK, or < 0 if there were none. */
|
||||
|
||||
int
|
||||
remote_status (exit_code_ptr, signal_ptr, coredump_ptr, block)
|
||||
int *exit_code_ptr, *signal_ptr, *coredump_ptr;
|
||||
int block;
|
||||
{
|
||||
errno = ECHILD;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Block asynchronous notification of remote child death.
|
||||
If this notification is done by raising the child termination
|
||||
signal, do not block that signal. */
|
||||
void
|
||||
block_remote_children ()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Restore asynchronous notification of remote child death.
|
||||
If this is done by raising the child termination signal,
|
||||
do not unblock that signal. */
|
||||
void
|
||||
unblock_remote_children ()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Send signal SIG to child ID. Return 0 if successful, -1 if not. */
|
||||
int
|
||||
remote_kill (id, sig)
|
||||
int id;
|
||||
int sig;
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
717
flaim/external/w32/make/rule.c
vendored
Normal file
717
flaim/external/w32/make/rule.c
vendored
Normal file
@@ -0,0 +1,717 @@
|
||||
/* Pattern and suffix rule internals for GNU Make.
|
||||
Copyright (C) 1988,89,90,91,92,93, 1998 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "make.h"
|
||||
#include "dep.h"
|
||||
#include "filedef.h"
|
||||
#include "job.h"
|
||||
#include "commands.h"
|
||||
#include "variable.h"
|
||||
#include "rule.h"
|
||||
|
||||
static void freerule PARAMS ((struct rule *rule, struct rule *lastrule));
|
||||
|
||||
/* Chain of all pattern rules. */
|
||||
|
||||
struct rule *pattern_rules;
|
||||
|
||||
/* Pointer to last rule in the chain, so we can add onto the end. */
|
||||
|
||||
struct rule *last_pattern_rule;
|
||||
|
||||
/* Number of rules in the chain. */
|
||||
|
||||
unsigned int num_pattern_rules;
|
||||
|
||||
/* Maximum number of target patterns of any pattern rule. */
|
||||
|
||||
unsigned int max_pattern_targets;
|
||||
|
||||
/* Maximum number of dependencies of any pattern rule. */
|
||||
|
||||
unsigned int max_pattern_deps;
|
||||
|
||||
/* Maximum length of the name of a dependencies of any pattern rule. */
|
||||
|
||||
unsigned int max_pattern_dep_length;
|
||||
|
||||
/* Chain of all pattern-specific variables. */
|
||||
|
||||
static struct pattern_var *pattern_vars;
|
||||
|
||||
/* Pointer to last struct in the chain, so we can add onto the end. */
|
||||
|
||||
static struct pattern_var *last_pattern_var;
|
||||
|
||||
/* Pointer to structure for the file .SUFFIXES
|
||||
whose dependencies are the suffixes to be searched. */
|
||||
|
||||
struct file *suffix_file;
|
||||
|
||||
/* Maximum length of a suffix. */
|
||||
|
||||
unsigned int maxsuffix;
|
||||
|
||||
/* Compute the maximum dependency length and maximum number of
|
||||
dependencies of all implicit rules. Also sets the subdir
|
||||
flag for a rule when appropriate, possibly removing the rule
|
||||
completely when appropriate. */
|
||||
|
||||
void
|
||||
count_implicit_rule_limits ()
|
||||
{
|
||||
char *name;
|
||||
unsigned int namelen;
|
||||
register struct rule *rule, *lastrule;
|
||||
|
||||
num_pattern_rules = max_pattern_targets = max_pattern_deps = 0;
|
||||
max_pattern_dep_length = 0;
|
||||
|
||||
name = 0;
|
||||
namelen = 0;
|
||||
rule = pattern_rules;
|
||||
lastrule = 0;
|
||||
while (rule != 0)
|
||||
{
|
||||
unsigned int ndeps = 0;
|
||||
register struct dep *dep;
|
||||
struct rule *next = rule->next;
|
||||
unsigned int ntargets;
|
||||
|
||||
++num_pattern_rules;
|
||||
|
||||
ntargets = 0;
|
||||
while (rule->targets[ntargets] != 0)
|
||||
++ntargets;
|
||||
|
||||
if (ntargets > max_pattern_targets)
|
||||
max_pattern_targets = ntargets;
|
||||
|
||||
for (dep = rule->deps; dep != 0; dep = dep->next)
|
||||
{
|
||||
unsigned int len = strlen (dep->name);
|
||||
|
||||
#ifdef VMS
|
||||
char *p = strrchr (dep->name, ']');
|
||||
char *p2;
|
||||
if (p == 0)
|
||||
p = strrchr (dep->name, ':');
|
||||
p2 = p != 0 ? strchr (dep->name, '%') : 0;
|
||||
#else
|
||||
char *p = strrchr (dep->name, '/');
|
||||
char *p2 = p != 0 ? strchr (dep->name, '%') : 0;
|
||||
#endif
|
||||
ndeps++;
|
||||
|
||||
if (len > max_pattern_dep_length)
|
||||
max_pattern_dep_length = len;
|
||||
|
||||
if (p != 0 && p2 > p)
|
||||
{
|
||||
/* There is a slash before the % in the dep name.
|
||||
Extract the directory name. */
|
||||
if (p == dep->name)
|
||||
++p;
|
||||
if (p - dep->name > namelen)
|
||||
{
|
||||
if (name != 0)
|
||||
free (name);
|
||||
namelen = p - dep->name;
|
||||
name = (char *) xmalloc (namelen + 1);
|
||||
}
|
||||
bcopy (dep->name, name, p - dep->name);
|
||||
name[p - dep->name] = '\0';
|
||||
|
||||
/* In the deps of an implicit rule the `changed' flag
|
||||
actually indicates that the dependency is in a
|
||||
nonexistent subdirectory. */
|
||||
|
||||
dep->changed = !dir_file_exists_p (name, "");
|
||||
#ifdef VMS
|
||||
if (dep->changed && strchr (name, ':') != 0)
|
||||
#else
|
||||
if (dep->changed && *name == '/')
|
||||
#endif
|
||||
{
|
||||
/* The name is absolute and the directory does not exist.
|
||||
This rule can never possibly match, since this dependency
|
||||
can never possibly exist. So just remove the rule from
|
||||
the list. */
|
||||
freerule (rule, lastrule);
|
||||
--num_pattern_rules;
|
||||
goto end_main_loop;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* This dependency does not reside in a subdirectory. */
|
||||
dep->changed = 0;
|
||||
}
|
||||
|
||||
if (ndeps > max_pattern_deps)
|
||||
max_pattern_deps = ndeps;
|
||||
|
||||
lastrule = rule;
|
||||
end_main_loop:
|
||||
rule = next;
|
||||
}
|
||||
|
||||
if (name != 0)
|
||||
free (name);
|
||||
}
|
||||
|
||||
/* Create a pattern rule from a suffix rule.
|
||||
TARGET is the target suffix; SOURCE is the source suffix.
|
||||
CMDS are the commands.
|
||||
If TARGET is nil, it means the target pattern should be `(%.o)'.
|
||||
If SOURCE is nil, it means there should be no deps. */
|
||||
|
||||
static void
|
||||
convert_suffix_rule (target, source, cmds)
|
||||
char *target, *source;
|
||||
struct commands *cmds;
|
||||
{
|
||||
char *targname, *targpercent, *depname;
|
||||
char **names, **percents;
|
||||
struct dep *deps;
|
||||
unsigned int len;
|
||||
|
||||
if (target == 0)
|
||||
/* Special case: TARGET being nil means we are defining a
|
||||
`.X.a' suffix rule; the target pattern is always `(%.o)'. */
|
||||
{
|
||||
#ifdef VMS
|
||||
targname = savestring ("(%.obj)", 7);
|
||||
#else
|
||||
targname = savestring ("(%.o)", 5);
|
||||
#endif
|
||||
targpercent = targname + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Construct the target name. */
|
||||
len = strlen (target);
|
||||
targname = xmalloc (1 + len + 1);
|
||||
targname[0] = '%';
|
||||
bcopy (target, targname + 1, len + 1);
|
||||
targpercent = targname;
|
||||
}
|
||||
|
||||
names = (char **) xmalloc (2 * sizeof (char *));
|
||||
percents = (char **) alloca (2 * sizeof (char *));
|
||||
names[0] = targname;
|
||||
percents[0] = targpercent;
|
||||
names[1] = percents[1] = 0;
|
||||
|
||||
if (source == 0)
|
||||
deps = 0;
|
||||
else
|
||||
{
|
||||
/* Construct the dependency name. */
|
||||
len = strlen (source);
|
||||
depname = xmalloc (1 + len + 1);
|
||||
depname[0] = '%';
|
||||
bcopy (source, depname + 1, len + 1);
|
||||
deps = (struct dep *) xmalloc (sizeof (struct dep));
|
||||
deps->next = 0;
|
||||
deps->name = depname;
|
||||
deps->ignore_mtime = 0;
|
||||
}
|
||||
|
||||
create_pattern_rule (names, percents, 0, deps, cmds, 0);
|
||||
}
|
||||
|
||||
/* Convert old-style suffix rules to pattern rules.
|
||||
All rules for the suffixes on the .SUFFIXES list
|
||||
are converted and added to the chain of pattern rules. */
|
||||
|
||||
void
|
||||
convert_to_pattern ()
|
||||
{
|
||||
register struct dep *d, *d2;
|
||||
register struct file *f;
|
||||
register char *rulename;
|
||||
register unsigned int slen, s2len;
|
||||
|
||||
/* Compute maximum length of all the suffixes. */
|
||||
|
||||
maxsuffix = 0;
|
||||
for (d = suffix_file->deps; d != 0; d = d->next)
|
||||
{
|
||||
register unsigned int namelen = strlen (dep_name (d));
|
||||
if (namelen > maxsuffix)
|
||||
maxsuffix = namelen;
|
||||
}
|
||||
|
||||
rulename = (char *) alloca ((maxsuffix * 2) + 1);
|
||||
|
||||
for (d = suffix_file->deps; d != 0; d = d->next)
|
||||
{
|
||||
/* Make a rule that is just the suffix, with no deps or commands.
|
||||
This rule exists solely to disqualify match-anything rules. */
|
||||
convert_suffix_rule (dep_name (d), (char *) 0, (struct commands *) 0);
|
||||
|
||||
f = d->file;
|
||||
if (f->cmds != 0)
|
||||
/* Record a pattern for this suffix's null-suffix rule. */
|
||||
convert_suffix_rule ("", dep_name (d), f->cmds);
|
||||
|
||||
/* Record a pattern for each of this suffix's two-suffix rules. */
|
||||
slen = strlen (dep_name (d));
|
||||
bcopy (dep_name (d), rulename, slen);
|
||||
for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next)
|
||||
{
|
||||
s2len = strlen (dep_name (d2));
|
||||
|
||||
if (slen == s2len && streq (dep_name (d), dep_name (d2)))
|
||||
continue;
|
||||
|
||||
bcopy (dep_name (d2), rulename + slen, s2len + 1);
|
||||
f = lookup_file (rulename);
|
||||
if (f == 0 || f->cmds == 0)
|
||||
continue;
|
||||
|
||||
if (s2len == 2 && rulename[slen] == '.' && rulename[slen + 1] == 'a')
|
||||
/* A suffix rule `.X.a:' generates the pattern rule `(%.o): %.X'.
|
||||
It also generates a normal `%.a: %.X' rule below. */
|
||||
convert_suffix_rule ((char *) 0, /* Indicates `(%.o)'. */
|
||||
dep_name (d),
|
||||
f->cmds);
|
||||
|
||||
/* The suffix rule `.X.Y:' is converted
|
||||
to the pattern rule `%.Y: %.X'. */
|
||||
convert_suffix_rule (dep_name (d2), dep_name (d), f->cmds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Install the pattern rule RULE (whose fields have been filled in)
|
||||
at the end of the list (so that any rules previously defined
|
||||
will take precedence). If this rule duplicates a previous one
|
||||
(identical target and dependencies), the old one is replaced
|
||||
if OVERRIDE is nonzero, otherwise this new one is thrown out.
|
||||
When an old rule is replaced, the new one is put at the end of the
|
||||
list. Return nonzero if RULE is used; zero if not. */
|
||||
|
||||
int
|
||||
new_pattern_rule (rule, override)
|
||||
register struct rule *rule;
|
||||
int override;
|
||||
{
|
||||
register struct rule *r, *lastrule;
|
||||
register unsigned int i, j;
|
||||
|
||||
rule->in_use = 0;
|
||||
rule->terminal = 0;
|
||||
|
||||
rule->next = 0;
|
||||
|
||||
/* Search for an identical rule. */
|
||||
lastrule = 0;
|
||||
for (r = pattern_rules; r != 0; lastrule = r, r = r->next)
|
||||
for (i = 0; rule->targets[i] != 0; ++i)
|
||||
{
|
||||
for (j = 0; r->targets[j] != 0; ++j)
|
||||
if (!streq (rule->targets[i], r->targets[j]))
|
||||
break;
|
||||
if (r->targets[j] == 0)
|
||||
/* All the targets matched. */
|
||||
{
|
||||
register struct dep *d, *d2;
|
||||
for (d = rule->deps, d2 = r->deps;
|
||||
d != 0 && d2 != 0; d = d->next, d2 = d2->next)
|
||||
if (!streq (dep_name (d), dep_name (d2)))
|
||||
break;
|
||||
if (d == 0 && d2 == 0)
|
||||
{
|
||||
/* All the dependencies matched. */
|
||||
if (override)
|
||||
{
|
||||
/* Remove the old rule. */
|
||||
freerule (r, lastrule);
|
||||
/* Install the new one. */
|
||||
if (pattern_rules == 0)
|
||||
pattern_rules = rule;
|
||||
else
|
||||
last_pattern_rule->next = rule;
|
||||
last_pattern_rule = rule;
|
||||
|
||||
/* We got one. Stop looking. */
|
||||
goto matched;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The old rule stays intact. Destroy the new one. */
|
||||
freerule (rule, (struct rule *) 0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
matched:;
|
||||
|
||||
if (r == 0)
|
||||
{
|
||||
/* There was no rule to replace. */
|
||||
if (pattern_rules == 0)
|
||||
pattern_rules = rule;
|
||||
else
|
||||
last_pattern_rule->next = rule;
|
||||
last_pattern_rule = rule;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Install an implicit pattern rule based on the three text strings
|
||||
in the structure P points to. These strings come from one of
|
||||
the arrays of default implicit pattern rules.
|
||||
TERMINAL specifies what the `terminal' field of the rule should be. */
|
||||
|
||||
void
|
||||
install_pattern_rule (p, terminal)
|
||||
struct pspec *p;
|
||||
int terminal;
|
||||
{
|
||||
register struct rule *r;
|
||||
char *ptr;
|
||||
|
||||
r = (struct rule *) xmalloc (sizeof (struct rule));
|
||||
|
||||
r->targets = (char **) xmalloc (2 * sizeof (char *));
|
||||
r->suffixes = (char **) xmalloc (2 * sizeof (char *));
|
||||
r->lens = (unsigned int *) xmalloc (2 * sizeof (unsigned int));
|
||||
|
||||
r->targets[1] = 0;
|
||||
r->suffixes[1] = 0;
|
||||
r->lens[1] = 0;
|
||||
|
||||
r->lens[0] = strlen (p->target);
|
||||
/* These will all be string literals, but we malloc space for
|
||||
them anyway because somebody might want to free them later on. */
|
||||
r->targets[0] = savestring (p->target, r->lens[0]);
|
||||
r->suffixes[0] = find_percent (r->targets[0]);
|
||||
if (r->suffixes[0] == 0)
|
||||
/* Programmer-out-to-lunch error. */
|
||||
abort ();
|
||||
else
|
||||
++r->suffixes[0];
|
||||
|
||||
ptr = p->dep;
|
||||
r->deps = (struct dep *) multi_glob (parse_file_seq (&ptr, '\0',
|
||||
sizeof (struct dep), 1),
|
||||
sizeof (struct dep));
|
||||
|
||||
if (new_pattern_rule (r, 0))
|
||||
{
|
||||
r->terminal = terminal;
|
||||
r->cmds = (struct commands *) xmalloc (sizeof (struct commands));
|
||||
r->cmds->fileinfo.filenm = 0;
|
||||
r->cmds->fileinfo.lineno = 0;
|
||||
/* These will all be string literals, but we malloc space for them
|
||||
anyway because somebody might want to free them later. */
|
||||
r->cmds->commands = xstrdup (p->commands);
|
||||
r->cmds->command_lines = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Free all the storage used in RULE and take it out of the
|
||||
pattern_rules chain. LASTRULE is the rule whose next pointer
|
||||
points to RULE. */
|
||||
|
||||
static void
|
||||
freerule (rule, lastrule)
|
||||
register struct rule *rule, *lastrule;
|
||||
{
|
||||
struct rule *next = rule->next;
|
||||
register unsigned int i;
|
||||
register struct dep *dep;
|
||||
|
||||
for (i = 0; rule->targets[i] != 0; ++i)
|
||||
free (rule->targets[i]);
|
||||
|
||||
dep = rule->deps;
|
||||
while (dep)
|
||||
{
|
||||
struct dep *t;
|
||||
|
||||
t = dep->next;
|
||||
/* We might leak dep->name here, but I'm not sure how to fix this: I
|
||||
think that pointer might be shared (e.g., in the file hash?) */
|
||||
free ((char *) dep);
|
||||
dep = t;
|
||||
}
|
||||
|
||||
free ((char *) rule->targets);
|
||||
free ((char *) rule->suffixes);
|
||||
free ((char *) rule->lens);
|
||||
|
||||
/* We can't free the storage for the commands because there
|
||||
are ways that they could be in more than one place:
|
||||
* If the commands came from a suffix rule, they could also be in
|
||||
the `struct file's for other suffix rules or plain targets given
|
||||
on the same makefile line.
|
||||
* If two suffixes that together make a two-suffix rule were each
|
||||
given twice in the .SUFFIXES list, and in the proper order, two
|
||||
identical pattern rules would be created and the second one would
|
||||
be discarded here, but both would contain the same `struct commands'
|
||||
pointer from the `struct file' for the suffix rule. */
|
||||
|
||||
free ((char *) rule);
|
||||
|
||||
if (pattern_rules == rule)
|
||||
if (lastrule != 0)
|
||||
abort ();
|
||||
else
|
||||
pattern_rules = next;
|
||||
else if (lastrule != 0)
|
||||
lastrule->next = next;
|
||||
if (last_pattern_rule == rule)
|
||||
last_pattern_rule = lastrule;
|
||||
}
|
||||
|
||||
/* Create a new pattern rule with the targets in the nil-terminated
|
||||
array TARGETS. If TARGET_PERCENTS is not nil, it is an array of
|
||||
pointers into the elements of TARGETS, where the `%'s are.
|
||||
The new rule has dependencies DEPS and commands from COMMANDS.
|
||||
It is a terminal rule if TERMINAL is nonzero. This rule overrides
|
||||
identical rules with different commands if OVERRIDE is nonzero.
|
||||
|
||||
The storage for TARGETS and its elements is used and must not be freed
|
||||
until the rule is destroyed. The storage for TARGET_PERCENTS is not used;
|
||||
it may be freed. */
|
||||
|
||||
void
|
||||
create_pattern_rule (targets, target_percents,
|
||||
terminal, deps, commands, override)
|
||||
char **targets, **target_percents;
|
||||
int terminal;
|
||||
struct dep *deps;
|
||||
struct commands *commands;
|
||||
int override;
|
||||
{
|
||||
register struct rule *r = (struct rule *) xmalloc (sizeof (struct rule));
|
||||
register unsigned int max_targets, i;
|
||||
|
||||
r->cmds = commands;
|
||||
r->deps = deps;
|
||||
r->targets = targets;
|
||||
|
||||
max_targets = 2;
|
||||
r->lens = (unsigned int *) xmalloc (2 * sizeof (unsigned int));
|
||||
r->suffixes = (char **) xmalloc (2 * sizeof (char *));
|
||||
for (i = 0; targets[i] != 0; ++i)
|
||||
{
|
||||
if (i == max_targets - 1)
|
||||
{
|
||||
max_targets += 5;
|
||||
r->lens = (unsigned int *)
|
||||
xrealloc ((char *) r->lens, max_targets * sizeof (unsigned int));
|
||||
r->suffixes = (char **)
|
||||
xrealloc ((char *) r->suffixes, max_targets * sizeof (char *));
|
||||
}
|
||||
r->lens[i] = strlen (targets[i]);
|
||||
r->suffixes[i] = (target_percents == 0 ? find_percent (targets[i])
|
||||
: target_percents[i]) + 1;
|
||||
if (r->suffixes[i] == 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
if (i < max_targets - 1)
|
||||
{
|
||||
r->lens = (unsigned int *) xrealloc ((char *) r->lens,
|
||||
(i + 1) * sizeof (unsigned int));
|
||||
r->suffixes = (char **) xrealloc ((char *) r->suffixes,
|
||||
(i + 1) * sizeof (char *));
|
||||
}
|
||||
|
||||
if (new_pattern_rule (r, override))
|
||||
r->terminal = terminal;
|
||||
}
|
||||
|
||||
/* Create a new pattern-specific variable struct. */
|
||||
|
||||
struct pattern_var *
|
||||
create_pattern_var (target, suffix)
|
||||
char *target, *suffix;
|
||||
{
|
||||
register struct pattern_var *p = 0;
|
||||
unsigned int len = strlen(target);
|
||||
|
||||
/* Look to see if this pattern already exists in the list. */
|
||||
for (p = pattern_vars; p != NULL; p = p->next)
|
||||
if (p->len == len && !strcmp(p->target, target))
|
||||
break;
|
||||
|
||||
if (p == 0)
|
||||
{
|
||||
p = (struct pattern_var *) xmalloc (sizeof (struct pattern_var));
|
||||
if (last_pattern_var != 0)
|
||||
last_pattern_var->next = p;
|
||||
else
|
||||
pattern_vars = p;
|
||||
last_pattern_var = p;
|
||||
p->next = 0;
|
||||
p->target = target;
|
||||
p->len = len;
|
||||
p->suffix = suffix + 1;
|
||||
p->vars = create_new_variable_set();
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Look up a target in the pattern-specific variable list. */
|
||||
|
||||
struct pattern_var *
|
||||
lookup_pattern_var (target)
|
||||
char *target;
|
||||
{
|
||||
struct pattern_var *p;
|
||||
unsigned int targlen = strlen(target);
|
||||
|
||||
for (p = pattern_vars; p != 0; p = p->next)
|
||||
{
|
||||
char *stem;
|
||||
unsigned int stemlen;
|
||||
|
||||
if (p->len > targlen)
|
||||
/* It can't possibly match. */
|
||||
continue;
|
||||
|
||||
/* From the lengths of the filename and the pattern parts,
|
||||
find the stem: the part of the filename that matches the %. */
|
||||
stem = target + (p->suffix - p->target - 1);
|
||||
stemlen = targlen - p->len + 1;
|
||||
|
||||
/* Compare the text in the pattern before the stem, if any. */
|
||||
if (stem > target && !strneq (p->target, target, stem - target))
|
||||
continue;
|
||||
|
||||
/* Compare the text in the pattern after the stem, if any.
|
||||
We could test simply using streq, but this way we compare the
|
||||
first two characters immediately. This saves time in the very
|
||||
common case where the first character matches because it is a
|
||||
period. */
|
||||
if (*p->suffix == stem[stemlen]
|
||||
&& (*p->suffix == '\0' || streq (&p->suffix[1], &stem[stemlen+1])))
|
||||
break;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Print the data base of rules. */
|
||||
|
||||
static void /* Useful to call from gdb. */
|
||||
print_rule (r)
|
||||
struct rule *r;
|
||||
{
|
||||
register unsigned int i;
|
||||
register struct dep *d;
|
||||
|
||||
for (i = 0; r->targets[i] != 0; ++i)
|
||||
{
|
||||
fputs (r->targets[i], stdout);
|
||||
if (r->targets[i + 1] != 0)
|
||||
putchar (' ');
|
||||
else
|
||||
putchar (':');
|
||||
}
|
||||
if (r->terminal)
|
||||
putchar (':');
|
||||
|
||||
for (d = r->deps; d != 0; d = d->next)
|
||||
printf (" %s", dep_name (d));
|
||||
putchar ('\n');
|
||||
|
||||
if (r->cmds != 0)
|
||||
print_commands (r->cmds);
|
||||
}
|
||||
|
||||
void
|
||||
print_rule_data_base ()
|
||||
{
|
||||
register unsigned int rules, terminal;
|
||||
register struct rule *r;
|
||||
|
||||
puts (_("\n# Implicit Rules"));
|
||||
|
||||
rules = terminal = 0;
|
||||
for (r = pattern_rules; r != 0; r = r->next)
|
||||
{
|
||||
++rules;
|
||||
|
||||
putchar ('\n');
|
||||
print_rule (r);
|
||||
|
||||
if (r->terminal)
|
||||
++terminal;
|
||||
}
|
||||
|
||||
if (rules == 0)
|
||||
puts (_("\n# No implicit rules."));
|
||||
else
|
||||
{
|
||||
printf (_("\n# %u implicit rules, %u"), rules, terminal);
|
||||
#ifndef NO_FLOAT
|
||||
printf (" (%.1f%%)", (double) terminal / (double) rules * 100.0);
|
||||
#else
|
||||
{
|
||||
int f = (terminal * 1000 + 5) / rules;
|
||||
printf (" (%d.%d%%)", f/10, f%10);
|
||||
}
|
||||
#endif
|
||||
puts (_(" terminal."));
|
||||
}
|
||||
|
||||
if (num_pattern_rules != rules)
|
||||
{
|
||||
/* This can happen if a fatal error was detected while reading the
|
||||
makefiles and thus count_implicit_rule_limits wasn't called yet. */
|
||||
if (num_pattern_rules != 0)
|
||||
fatal (NILF, _("BUG: num_pattern_rules wrong! %u != %u"),
|
||||
num_pattern_rules, rules);
|
||||
}
|
||||
|
||||
puts (_("\n# Pattern-specific variable values"));
|
||||
|
||||
{
|
||||
struct pattern_var *p;
|
||||
|
||||
rules = 0;
|
||||
for (p = pattern_vars; p != 0; p = p->next)
|
||||
{
|
||||
++rules;
|
||||
|
||||
printf ("\n%s :\n", p->target);
|
||||
print_variable_set (p->vars->set, "# ");
|
||||
}
|
||||
|
||||
if (rules == 0)
|
||||
puts (_("\n# No pattern-specific variable values."));
|
||||
else
|
||||
{
|
||||
printf (_("\n# %u pattern-specific variable values"), rules);
|
||||
}
|
||||
}
|
||||
}
|
||||
72
flaim/external/w32/make/rule.h
vendored
Normal file
72
flaim/external/w32/make/rule.h
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/* Definitions for using pattern rules in GNU Make.
|
||||
Copyright (C) 1988, 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Structure used for pattern rules. */
|
||||
|
||||
struct rule
|
||||
{
|
||||
struct rule *next;
|
||||
char **targets; /* Targets of the rule. */
|
||||
unsigned int *lens; /* Lengths of each target. */
|
||||
char **suffixes; /* Suffixes (after `%') of each target. */
|
||||
struct dep *deps; /* Dependencies of the rule. */
|
||||
struct commands *cmds; /* Commands to execute. */
|
||||
char terminal; /* If terminal (double-colon). */
|
||||
char in_use; /* If in use by a parent pattern_search. */
|
||||
};
|
||||
|
||||
struct pattern_var
|
||||
{
|
||||
struct pattern_var *next;
|
||||
char *target;
|
||||
unsigned int len;
|
||||
char *suffix;
|
||||
struct variable_set_list *vars;
|
||||
};
|
||||
|
||||
/* For calling install_pattern_rule. */
|
||||
struct pspec
|
||||
{
|
||||
char *target, *dep, *commands;
|
||||
};
|
||||
|
||||
|
||||
extern struct rule *pattern_rules;
|
||||
extern struct rule *last_pattern_rule;
|
||||
extern unsigned int num_pattern_rules;
|
||||
|
||||
extern unsigned int max_pattern_deps;
|
||||
extern unsigned int max_pattern_targets;
|
||||
extern unsigned int max_pattern_dep_length;
|
||||
|
||||
extern struct file *suffix_file;
|
||||
extern unsigned int maxsuffix;
|
||||
|
||||
|
||||
extern void install_pattern_rule PARAMS ((struct pspec *p, int terminal));
|
||||
extern int new_pattern_rule PARAMS ((struct rule *rule, int override));
|
||||
extern struct pattern_var *create_pattern_var PARAMS ((char *target, char *suffix));
|
||||
extern struct pattern_var *lookup_pattern_var PARAMS ((char *target));
|
||||
extern void count_implicit_rule_limits PARAMS ((void));
|
||||
extern void convert_to_pattern PARAMS ((void));
|
||||
extern void create_pattern_rule PARAMS ((char **targets,
|
||||
char **target_percents, int terminal,
|
||||
struct dep *deps,
|
||||
struct commands *commands,
|
||||
int override));
|
||||
255
flaim/external/w32/make/signame.c
vendored
Normal file
255
flaim/external/w32/make/signame.c
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
/* Convert between signal names and numbers.
|
||||
Copyright (C) 1990,92,93,95,96,99, 2002 Free Software Foundation, Inc.
|
||||
This file was part of the GNU C Library, but is now part of GNU make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "make.h"
|
||||
|
||||
/* If the system provides strsignal, we don't need it. */
|
||||
|
||||
#if !defined(HAVE_STRSIGNAL)
|
||||
|
||||
/* If the system provides sys_siglist, we'll use that.
|
||||
Otherwise create our own.
|
||||
*/
|
||||
|
||||
#if !defined(SYS_SIGLIST_DECLARED)
|
||||
|
||||
/* Some systems do not define NSIG in <signal.h>. */
|
||||
#ifndef NSIG
|
||||
#ifdef _NSIG
|
||||
#define NSIG _NSIG
|
||||
#else
|
||||
#define NSIG 32
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* There is too much variation in Sys V signal numbers and names, so
|
||||
we must initialize them at runtime. */
|
||||
|
||||
static const char *undoc;
|
||||
|
||||
static const char *sys_siglist[NSIG];
|
||||
|
||||
/* Table of abbreviations for signals. Note: A given number can
|
||||
appear more than once with different abbreviations. */
|
||||
#define SIG_TABLE_SIZE (NSIG*2)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int number;
|
||||
const char *abbrev;
|
||||
} num_abbrev;
|
||||
|
||||
static num_abbrev sig_table[SIG_TABLE_SIZE];
|
||||
|
||||
/* Number of elements of sig_table used. */
|
||||
static int sig_table_nelts = 0;
|
||||
|
||||
/* Enter signal number NUMBER into the tables with ABBREV and NAME. */
|
||||
|
||||
static void
|
||||
init_sig (number, abbrev, name)
|
||||
int number;
|
||||
const char *abbrev;
|
||||
const char *name;
|
||||
{
|
||||
/* If this value is ever greater than NSIG it seems like it'd be a bug in
|
||||
the system headers, but... better safe than sorry. We know, for
|
||||
example, that this isn't always true on VMS. */
|
||||
|
||||
if (number >= 0 && number < NSIG)
|
||||
sys_siglist[number] = name;
|
||||
|
||||
if (sig_table_nelts < SIG_TABLE_SIZE)
|
||||
{
|
||||
sig_table[sig_table_nelts].number = number;
|
||||
sig_table[sig_table_nelts++].abbrev = abbrev;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
signame_init ()
|
||||
{
|
||||
int i;
|
||||
|
||||
undoc = xstrdup (_("unknown signal"));
|
||||
|
||||
/* Initialize signal names. */
|
||||
for (i = 0; i < NSIG; i++)
|
||||
sys_siglist[i] = undoc;
|
||||
|
||||
/* Initialize signal names. */
|
||||
#if defined (SIGHUP)
|
||||
init_sig (SIGHUP, "HUP", _("Hangup"));
|
||||
#endif
|
||||
#if defined (SIGINT)
|
||||
init_sig (SIGINT, "INT", _("Interrupt"));
|
||||
#endif
|
||||
#if defined (SIGQUIT)
|
||||
init_sig (SIGQUIT, "QUIT", _("Quit"));
|
||||
#endif
|
||||
#if defined (SIGILL)
|
||||
init_sig (SIGILL, "ILL", _("Illegal Instruction"));
|
||||
#endif
|
||||
#if defined (SIGTRAP)
|
||||
init_sig (SIGTRAP, "TRAP", _("Trace/breakpoint trap"));
|
||||
#endif
|
||||
/* If SIGIOT == SIGABRT, we want to print it as SIGABRT because
|
||||
SIGABRT is in ANSI and POSIX.1 and SIGIOT isn't. */
|
||||
#if defined (SIGABRT)
|
||||
init_sig (SIGABRT, "ABRT", _("Aborted"));
|
||||
#endif
|
||||
#if defined (SIGIOT)
|
||||
init_sig (SIGIOT, "IOT", _("IOT trap"));
|
||||
#endif
|
||||
#if defined (SIGEMT)
|
||||
init_sig (SIGEMT, "EMT", _("EMT trap"));
|
||||
#endif
|
||||
#if defined (SIGFPE)
|
||||
init_sig (SIGFPE, "FPE", _("Floating point exception"));
|
||||
#endif
|
||||
#if defined (SIGKILL)
|
||||
init_sig (SIGKILL, "KILL", _("Killed"));
|
||||
#endif
|
||||
#if defined (SIGBUS)
|
||||
init_sig (SIGBUS, "BUS", _("Bus error"));
|
||||
#endif
|
||||
#if defined (SIGSEGV)
|
||||
init_sig (SIGSEGV, "SEGV", _("Segmentation fault"));
|
||||
#endif
|
||||
#if defined (SIGSYS)
|
||||
init_sig (SIGSYS, "SYS", _("Bad system call"));
|
||||
#endif
|
||||
#if defined (SIGPIPE)
|
||||
init_sig (SIGPIPE, "PIPE", _("Broken pipe"));
|
||||
#endif
|
||||
#if defined (SIGALRM)
|
||||
init_sig (SIGALRM, "ALRM", _("Alarm clock"));
|
||||
#endif
|
||||
#if defined (SIGTERM)
|
||||
init_sig (SIGTERM, "TERM", _("Terminated"));
|
||||
#endif
|
||||
#if defined (SIGUSR1)
|
||||
init_sig (SIGUSR1, "USR1", _("User defined signal 1"));
|
||||
#endif
|
||||
#if defined (SIGUSR2)
|
||||
init_sig (SIGUSR2, "USR2", _("User defined signal 2"));
|
||||
#endif
|
||||
/* If SIGCLD == SIGCHLD, we want to print it as SIGCHLD because that
|
||||
is what is in POSIX.1. */
|
||||
#if defined (SIGCHLD)
|
||||
init_sig (SIGCHLD, "CHLD", _("Child exited"));
|
||||
#endif
|
||||
#if defined (SIGCLD)
|
||||
init_sig (SIGCLD, "CLD", _("Child exited"));
|
||||
#endif
|
||||
#if defined (SIGPWR)
|
||||
init_sig (SIGPWR, "PWR", _("Power failure"));
|
||||
#endif
|
||||
#if defined (SIGTSTP)
|
||||
init_sig (SIGTSTP, "TSTP", _("Stopped"));
|
||||
#endif
|
||||
#if defined (SIGTTIN)
|
||||
init_sig (SIGTTIN, "TTIN", _("Stopped (tty input)"));
|
||||
#endif
|
||||
#if defined (SIGTTOU)
|
||||
init_sig (SIGTTOU, "TTOU", _("Stopped (tty output)"));
|
||||
#endif
|
||||
#if defined (SIGSTOP)
|
||||
init_sig (SIGSTOP, "STOP", _("Stopped (signal)"));
|
||||
#endif
|
||||
#if defined (SIGXCPU)
|
||||
init_sig (SIGXCPU, "XCPU", _("CPU time limit exceeded"));
|
||||
#endif
|
||||
#if defined (SIGXFSZ)
|
||||
init_sig (SIGXFSZ, "XFSZ", _("File size limit exceeded"));
|
||||
#endif
|
||||
#if defined (SIGVTALRM)
|
||||
init_sig (SIGVTALRM, "VTALRM", _("Virtual timer expired"));
|
||||
#endif
|
||||
#if defined (SIGPROF)
|
||||
init_sig (SIGPROF, "PROF", _("Profiling timer expired"));
|
||||
#endif
|
||||
#if defined (SIGWINCH)
|
||||
/* "Window size changed" might be more accurate, but even if that
|
||||
is all that it means now, perhaps in the future it will be
|
||||
extended to cover other kinds of window changes. */
|
||||
init_sig (SIGWINCH, "WINCH", _("Window changed"));
|
||||
#endif
|
||||
#if defined (SIGCONT)
|
||||
init_sig (SIGCONT, "CONT", _("Continued"));
|
||||
#endif
|
||||
#if defined (SIGURG)
|
||||
init_sig (SIGURG, "URG", _("Urgent I/O condition"));
|
||||
#endif
|
||||
#if defined (SIGIO)
|
||||
/* "I/O pending" has also been suggested. A disadvantage is
|
||||
that signal only happens when the process has
|
||||
asked for it, not everytime I/O is pending. Another disadvantage
|
||||
is the confusion from giving it a different name than under Unix. */
|
||||
init_sig (SIGIO, "IO", _("I/O possible"));
|
||||
#endif
|
||||
#if defined (SIGWIND)
|
||||
init_sig (SIGWIND, "WIND", _("SIGWIND"));
|
||||
#endif
|
||||
#if defined (SIGPHONE)
|
||||
init_sig (SIGPHONE, "PHONE", _("SIGPHONE"));
|
||||
#endif
|
||||
#if defined (SIGPOLL)
|
||||
init_sig (SIGPOLL, "POLL", _("I/O possible"));
|
||||
#endif
|
||||
#if defined (SIGLOST)
|
||||
init_sig (SIGLOST, "LOST", _("Resource lost"));
|
||||
#endif
|
||||
#if defined (SIGDANGER)
|
||||
init_sig (SIGDANGER, "DANGER", _("Danger signal"));
|
||||
#endif
|
||||
#if defined (SIGINFO)
|
||||
init_sig (SIGINFO, "INFO", _("Information request"));
|
||||
#endif
|
||||
#if defined (SIGNOFP)
|
||||
init_sig (SIGNOFP, "NOFP", _("Floating point co-processor not available"));
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* SYS_SIGLIST_DECLARED */
|
||||
|
||||
|
||||
char *
|
||||
strsignal (signal)
|
||||
int signal;
|
||||
{
|
||||
static char buf[] = "Signal 12345678901234567890";
|
||||
|
||||
#if !defined(SYS_SIGLIST_DECLARED)
|
||||
static char sig_initted = 0;
|
||||
|
||||
if (!sig_initted)
|
||||
sig_initted = signame_init ();
|
||||
#endif
|
||||
|
||||
if (signal > 0 || signal < NSIG)
|
||||
return (char *) sys_siglist[signal];
|
||||
|
||||
sprintf (buf, "Signal %d", signal);
|
||||
return buf;
|
||||
}
|
||||
|
||||
#endif /* HAVE_STRSIGNAL */
|
||||
1207
flaim/external/w32/make/sub_proc.c
vendored
Normal file
1207
flaim/external/w32/make/sub_proc.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
47
flaim/external/w32/make/sub_proc.h
vendored
Normal file
47
flaim/external/w32/make/sub_proc.h
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef SUB_PROC_H
|
||||
#define SUB_PROC_H
|
||||
|
||||
/*
|
||||
* Component Name:
|
||||
*
|
||||
* $Date: 1997/08/27 20:34:23 $
|
||||
*
|
||||
* $Source: /cvsroot/make/make/w32/include/sub_proc.h,v $
|
||||
*
|
||||
* $Revision: 1.4 $
|
||||
*/
|
||||
|
||||
/* $Id: sub_proc.h,v 1.4 1997/08/27 20:34:23 psmith Exp $ */
|
||||
|
||||
#ifdef WINDOWS32
|
||||
|
||||
#define EXTERN_DECL(entry, args) extern entry args
|
||||
#define VOID_DECL void
|
||||
|
||||
EXTERN_DECL(HANDLE process_init, (VOID_DECL));
|
||||
EXTERN_DECL(HANDLE process_init_fd, (HANDLE stdinh, HANDLE stdouth,
|
||||
HANDLE stderrh));
|
||||
EXTERN_DECL(long process_begin, (HANDLE proc, char **argv, char **envp,
|
||||
char *exec_path, char *as_user));
|
||||
EXTERN_DECL(long process_pipe_io, (HANDLE proc, char *stdin_data,
|
||||
int stdin_data_len));
|
||||
EXTERN_DECL(long process_file_io, (HANDLE proc));
|
||||
EXTERN_DECL(void process_cleanup, (HANDLE proc));
|
||||
EXTERN_DECL(HANDLE process_wait_for_any, (VOID_DECL));
|
||||
EXTERN_DECL(void process_register, (HANDLE proc));
|
||||
EXTERN_DECL(HANDLE process_easy, (char** argv, char** env));
|
||||
EXTERN_DECL(BOOL process_kill, (HANDLE proc, int signal));
|
||||
|
||||
/* support routines */
|
||||
EXTERN_DECL(long process_errno, (HANDLE proc));
|
||||
EXTERN_DECL(long process_last_err, (HANDLE proc));
|
||||
EXTERN_DECL(long process_exit_code, (HANDLE proc));
|
||||
EXTERN_DECL(long process_signal, (HANDLE proc));
|
||||
EXTERN_DECL(char * process_outbuf, (HANDLE proc));
|
||||
EXTERN_DECL(char * process_errbuf, (HANDLE proc));
|
||||
EXTERN_DECL(int process_outcnt, (HANDLE proc));
|
||||
EXTERN_DECL(int process_errcnt, (HANDLE proc));
|
||||
EXTERN_DECL(void process_pipes, (HANDLE proc, int pipes[3]));
|
||||
|
||||
#endif
|
||||
#endif
|
||||
1263
flaim/external/w32/make/variable.c
vendored
Normal file
1263
flaim/external/w32/make/variable.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
183
flaim/external/w32/make/variable.h
vendored
Normal file
183
flaim/external/w32/make/variable.h
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
/* Definitions for using variables in GNU Make.
|
||||
Copyright (C) 1988, 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "hash.h"
|
||||
|
||||
/* Codes in a variable definition saying where the definition came from.
|
||||
Increasing numeric values signify less-overridable definitions. */
|
||||
enum variable_origin
|
||||
{
|
||||
o_default, /* Variable from the default set. */
|
||||
o_env, /* Variable from environment. */
|
||||
o_file, /* Variable given in a makefile. */
|
||||
o_env_override, /* Variable from environment, if -e. */
|
||||
o_command, /* Variable given by user. */
|
||||
o_override, /* Variable from an `override' directive. */
|
||||
o_automatic, /* Automatic variable -- cannot be set. */
|
||||
o_invalid /* Core dump time. */
|
||||
};
|
||||
|
||||
enum variable_flavor
|
||||
{
|
||||
f_bogus, /* Bogus (error) */
|
||||
f_simple, /* Simple definition (:=) */
|
||||
f_recursive, /* Recursive definition (=) */
|
||||
f_append, /* Appending definition (+=) */
|
||||
f_conditional /* Conditional definition (?=) */
|
||||
};
|
||||
|
||||
/* Structure that represents one variable definition.
|
||||
Each bucket of the hash table is a chain of these,
|
||||
chained through `next'. */
|
||||
|
||||
#define EXP_COUNT_BITS 15 /* This gets all the bitfields into 32 bits */
|
||||
|
||||
#define EXP_COUNT_MAX ((1<<EXP_COUNT_BITS)-1)
|
||||
|
||||
struct variable
|
||||
{
|
||||
char *name; /* Variable name. */
|
||||
int length; /* strlen (name) */
|
||||
char *value; /* Variable value. */
|
||||
struct floc fileinfo; /* Where the variable was defined. */
|
||||
unsigned int recursive:1; /* Gets recursively re-evaluated. */
|
||||
unsigned int per_target:1; /* Nonzero if a target-specific variable. */
|
||||
unsigned int append:1; /* Nonzero if an appending target-specific
|
||||
variable. */
|
||||
unsigned int special:1; /* Nonzero if this is a special variable. */
|
||||
unsigned int expanding:1; /* Nonzero if currently being expanded. */
|
||||
unsigned int exp_count:EXP_COUNT_BITS;
|
||||
/* If >1, allow this many self-referential
|
||||
expansions. */
|
||||
|
||||
enum variable_origin
|
||||
origin ENUM_BITFIELD (3); /* Variable origin. */
|
||||
|
||||
unsigned int exportable:1; /* Nonzero if the variable _could_ be
|
||||
exported. */
|
||||
enum variable_export
|
||||
{
|
||||
v_export, /* Export this variable. */
|
||||
v_noexport, /* Don't export this variable. */
|
||||
v_ifset, /* Export it if it has a non-default value. */
|
||||
v_default /* Decide in target_environment. */
|
||||
} export ENUM_BITFIELD (2);
|
||||
};
|
||||
|
||||
/* Structure that represents a variable set. */
|
||||
|
||||
struct variable_set
|
||||
{
|
||||
struct hash_table table; /* Hash table of variables. */
|
||||
};
|
||||
|
||||
/* Structure that represents a list of variable sets. */
|
||||
|
||||
struct variable_set_list
|
||||
{
|
||||
struct variable_set_list *next; /* Link in the chain. */
|
||||
struct variable_set *set; /* Variable set. */
|
||||
};
|
||||
|
||||
extern char *variable_buffer;
|
||||
extern struct variable_set_list *current_variable_set_list;
|
||||
|
||||
/* expand.c */
|
||||
extern char *variable_buffer_output PARAMS ((char *ptr, char *string, unsigned int length));
|
||||
extern char *variable_expand PARAMS ((char *line));
|
||||
extern char *allocated_variable_expand_for_file PARAMS ((char *line, struct file *file));
|
||||
#define allocated_variable_expand(line) \
|
||||
allocated_variable_expand_for_file (line, (struct file *) 0)
|
||||
extern char *expand_argument PARAMS ((char *str, char *end));
|
||||
extern char *variable_expand_string PARAMS ((char *line, char *string,
|
||||
long length));
|
||||
|
||||
/* function.c */
|
||||
extern int handle_function PARAMS ((char **op, char **stringp));
|
||||
extern int pattern_matches PARAMS ((char *pattern, char *percent, char *str));
|
||||
extern char *subst_expand PARAMS ((char *o, char *text, char *subst, char *replace,
|
||||
unsigned int slen, unsigned int rlen, int by_word, int suffix_only));
|
||||
extern char *patsubst_expand PARAMS ((char *o, char *text, char *pattern, char *replace,
|
||||
char *pattern_percent, char *replace_percent));
|
||||
|
||||
/* expand.c */
|
||||
extern char *recursively_expand_for_file PARAMS ((struct variable *v,
|
||||
struct file *file));
|
||||
#define recursively_expand(v) recursively_expand_for_file (v, NULL)
|
||||
|
||||
/* variable.c */
|
||||
extern struct variable_set_list *create_new_variable_set PARAMS ((void));
|
||||
extern struct variable_set_list *push_new_variable_scope PARAMS ((void));
|
||||
extern void pop_variable_scope PARAMS ((void));
|
||||
extern void define_automatic_variables PARAMS ((void));
|
||||
extern void initialize_file_variables PARAMS ((struct file *file, int read));
|
||||
extern void print_file_variables PARAMS ((struct file *file));
|
||||
extern void print_variable_set PARAMS ((struct variable_set *set, char *prefix));
|
||||
extern void merge_variable_set_lists PARAMS ((struct variable_set_list **setlist0, struct variable_set_list *setlist1));
|
||||
extern struct variable *do_variable_definition PARAMS ((const struct floc *flocp, const char *name, char *value, enum variable_origin origin, enum variable_flavor flavor, int target_var));
|
||||
extern struct variable *try_variable_definition PARAMS ((const struct floc *flocp, char *line, enum variable_origin origin, int target_var));
|
||||
extern void init_hash_global_variable_set PARAMS ((void));
|
||||
extern void hash_init_function_table PARAMS ((void));
|
||||
extern struct variable *lookup_variable PARAMS ((const char *name, unsigned int length));
|
||||
extern struct variable *lookup_variable_in_set PARAMS ((const char *name,
|
||||
unsigned int length,
|
||||
const struct variable_set *set));
|
||||
|
||||
extern struct variable *define_variable_in_set
|
||||
PARAMS ((const char *name, unsigned int length, char *value,
|
||||
enum variable_origin origin, int recursive,
|
||||
struct variable_set *set, const struct floc *flocp));
|
||||
|
||||
/* Define a variable in the current variable set. */
|
||||
|
||||
#define define_variable(n,l,v,o,r) \
|
||||
define_variable_in_set((n),(l),(v),(o),(r),\
|
||||
current_variable_set_list->set,NILF)
|
||||
|
||||
/* Define a variable with a location in the current variable set. */
|
||||
|
||||
#define define_variable_loc(n,l,v,o,r,f) \
|
||||
define_variable_in_set((n),(l),(v),(o),(r),\
|
||||
current_variable_set_list->set,(f))
|
||||
|
||||
/* Define a variable with a location in the global variable set. */
|
||||
|
||||
#define define_variable_global(n,l,v,o,r,f) \
|
||||
define_variable_in_set((n),(l),(v),(o),(r),NULL,(f))
|
||||
|
||||
/* Define a variable in FILE's variable set. */
|
||||
|
||||
#define define_variable_for_file(n,l,v,o,r,f) \
|
||||
define_variable_in_set((n),(l),(v),(o),(r),(f)->variables->set,NILF)
|
||||
|
||||
/* Warn that NAME is an undefined variable. */
|
||||
|
||||
#define warn_undefined(n,l) do{\
|
||||
if (warn_undefined_variables_flag) \
|
||||
error (reading_file, \
|
||||
_("warning: undefined variable `%.*s'"), \
|
||||
(int)(l), (n)); \
|
||||
}while(0)
|
||||
|
||||
extern char **target_environment PARAMS ((struct file *file));
|
||||
|
||||
extern int export_all_variables;
|
||||
|
||||
#define MAKELEVEL_NAME "MAKELEVEL"
|
||||
#define MAKELEVEL_LENGTH (sizeof (MAKELEVEL_NAME) - 1)
|
||||
17
flaim/external/w32/make/version.c
vendored
Normal file
17
flaim/external/w32/make/version.c
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/* We use <config.h> instead of "config.h" so that a compilation
|
||||
using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
|
||||
(which it would do because make.h was found in $srcdir). */
|
||||
#include <config.h>
|
||||
|
||||
#ifndef MAKE_HOST
|
||||
# define MAKE_HOST "unknown"
|
||||
#endif
|
||||
|
||||
char *version_string = VERSION;
|
||||
char *make_host = MAKE_HOST;
|
||||
|
||||
/*
|
||||
Local variables:
|
||||
version-control: never
|
||||
End:
|
||||
*/
|
||||
587
flaim/external/w32/make/vpath.c
vendored
Normal file
587
flaim/external/w32/make/vpath.c
vendored
Normal file
@@ -0,0 +1,587 @@
|
||||
/* Implementation of pattern-matching file search paths for GNU Make.
|
||||
Copyright (C) 1988,89,91,92,93,94,95,96,97 Free Software Foundation, Inc.
|
||||
This file is part of GNU Make.
|
||||
|
||||
GNU Make 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 Make 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 Make; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "make.h"
|
||||
#include "filedef.h"
|
||||
#include "variable.h"
|
||||
#ifdef WINDOWS32
|
||||
#include "pathstuff.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* Structure used to represent a selective VPATH searchpath. */
|
||||
|
||||
struct vpath
|
||||
{
|
||||
struct vpath *next; /* Pointer to next struct in the linked list. */
|
||||
char *pattern; /* The pattern to match. */
|
||||
char *percent; /* Pointer into `pattern' where the `%' is. */
|
||||
unsigned int patlen;/* Length of the pattern. */
|
||||
char **searchpath; /* Null-terminated list of directories. */
|
||||
unsigned int maxlen;/* Maximum length of any entry in the list. */
|
||||
};
|
||||
|
||||
/* Linked-list of all selective VPATHs. */
|
||||
|
||||
static struct vpath *vpaths;
|
||||
|
||||
/* Structure for the general VPATH given in the variable. */
|
||||
|
||||
static struct vpath *general_vpath;
|
||||
|
||||
/* Structure for GPATH given in the variable. */
|
||||
|
||||
static struct vpath *gpaths;
|
||||
|
||||
static int selective_vpath_search PARAMS ((struct vpath *path, char **file, FILE_TIMESTAMP *mtime_ptr));
|
||||
|
||||
/* Reverse the chain of selective VPATH lists so they
|
||||
will be searched in the order given in the makefiles
|
||||
and construct the list from the VPATH variable. */
|
||||
|
||||
void
|
||||
build_vpath_lists ()
|
||||
{
|
||||
register struct vpath *new = 0;
|
||||
register struct vpath *old, *nexto;
|
||||
register char *p;
|
||||
|
||||
/* Reverse the chain. */
|
||||
for (old = vpaths; old != 0; old = nexto)
|
||||
{
|
||||
nexto = old->next;
|
||||
old->next = new;
|
||||
new = old;
|
||||
}
|
||||
|
||||
vpaths = new;
|
||||
|
||||
/* If there is a VPATH variable with a nonnull value, construct the
|
||||
general VPATH list from it. We use variable_expand rather than just
|
||||
calling lookup_variable so that it will be recursively expanded. */
|
||||
|
||||
{
|
||||
/* Turn off --warn-undefined-variables while we expand SHELL and IFS. */
|
||||
int save = warn_undefined_variables_flag;
|
||||
warn_undefined_variables_flag = 0;
|
||||
|
||||
p = variable_expand ("$(strip $(VPATH))");
|
||||
|
||||
warn_undefined_variables_flag = save;
|
||||
}
|
||||
|
||||
if (*p != '\0')
|
||||
{
|
||||
/* Save the list of vpaths. */
|
||||
struct vpath *save_vpaths = vpaths;
|
||||
|
||||
/* Empty `vpaths' so the new one will have no next, and `vpaths'
|
||||
will still be nil if P contains no existing directories. */
|
||||
vpaths = 0;
|
||||
|
||||
/* Parse P. */
|
||||
construct_vpath_list ("%", p);
|
||||
|
||||
/* Store the created path as the general path,
|
||||
and restore the old list of vpaths. */
|
||||
general_vpath = vpaths;
|
||||
vpaths = save_vpaths;
|
||||
}
|
||||
|
||||
/* If there is a GPATH variable with a nonnull value, construct the
|
||||
GPATH list from it. We use variable_expand rather than just
|
||||
calling lookup_variable so that it will be recursively expanded. */
|
||||
|
||||
{
|
||||
/* Turn off --warn-undefined-variables while we expand SHELL and IFS. */
|
||||
int save = warn_undefined_variables_flag;
|
||||
warn_undefined_variables_flag = 0;
|
||||
|
||||
p = variable_expand ("$(strip $(GPATH))");
|
||||
|
||||
warn_undefined_variables_flag = save;
|
||||
}
|
||||
|
||||
if (*p != '\0')
|
||||
{
|
||||
/* Save the list of vpaths. */
|
||||
struct vpath *save_vpaths = vpaths;
|
||||
|
||||
/* Empty `vpaths' so the new one will have no next, and `vpaths'
|
||||
will still be nil if P contains no existing directories. */
|
||||
vpaths = 0;
|
||||
|
||||
/* Parse P. */
|
||||
construct_vpath_list ("%", p);
|
||||
|
||||
/* Store the created path as the GPATH,
|
||||
and restore the old list of vpaths. */
|
||||
gpaths = vpaths;
|
||||
vpaths = save_vpaths;
|
||||
}
|
||||
}
|
||||
|
||||
/* Construct the VPATH listing for the pattern and searchpath given.
|
||||
|
||||
This function is called to generate selective VPATH lists and also for
|
||||
the general VPATH list (which is in fact just a selective VPATH that
|
||||
is applied to everything). The returned pointer is either put in the
|
||||
linked list of all selective VPATH lists or in the GENERAL_VPATH
|
||||
variable.
|
||||
|
||||
If SEARCHPATH is nil, remove all previous listings with the same
|
||||
pattern. If PATTERN is nil, remove all VPATH listings. Existing
|
||||
and readable directories that are not "." given in the searchpath
|
||||
separated by the path element separator (defined in make.h) are
|
||||
loaded into the directory hash table if they are not there already
|
||||
and put in the VPATH searchpath for the given pattern with trailing
|
||||
slashes stripped off if present (and if the directory is not the
|
||||
root, "/"). The length of the longest entry in the list is put in
|
||||
the structure as well. The new entry will be at the head of the
|
||||
VPATHS chain. */
|
||||
|
||||
void
|
||||
construct_vpath_list (pattern, dirpath)
|
||||
char *pattern, *dirpath;
|
||||
{
|
||||
register unsigned int elem;
|
||||
register char *p;
|
||||
register char **vpath;
|
||||
register unsigned int maxvpath;
|
||||
unsigned int maxelem;
|
||||
char *percent = NULL;
|
||||
|
||||
if (pattern != 0)
|
||||
{
|
||||
pattern = xstrdup (pattern);
|
||||
percent = find_percent (pattern);
|
||||
}
|
||||
|
||||
if (dirpath == 0)
|
||||
{
|
||||
/* Remove matching listings. */
|
||||
register struct vpath *path, *lastpath;
|
||||
|
||||
lastpath = 0;
|
||||
path = vpaths;
|
||||
while (path != 0)
|
||||
{
|
||||
struct vpath *next = path->next;
|
||||
|
||||
if (pattern == 0
|
||||
|| (((percent == 0 && path->percent == 0)
|
||||
|| (percent - pattern == path->percent - path->pattern))
|
||||
&& streq (pattern, path->pattern)))
|
||||
{
|
||||
/* Remove it from the linked list. */
|
||||
if (lastpath == 0)
|
||||
vpaths = path->next;
|
||||
else
|
||||
lastpath->next = next;
|
||||
|
||||
/* Free its unused storage. */
|
||||
free (path->pattern);
|
||||
free ((char *) path->searchpath);
|
||||
free ((char *) path);
|
||||
}
|
||||
else
|
||||
lastpath = path;
|
||||
|
||||
path = next;
|
||||
}
|
||||
|
||||
if (pattern != 0)
|
||||
free (pattern);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef WINDOWS32
|
||||
convert_vpath_to_windows32(dirpath, ';');
|
||||
#endif
|
||||
|
||||
/* Figure out the maximum number of VPATH entries and put it in
|
||||
MAXELEM. We start with 2, one before the first separator and one
|
||||
nil (the list terminator) and increment our estimated number for
|
||||
each separator or blank we find. */
|
||||
maxelem = 2;
|
||||
p = dirpath;
|
||||
while (*p != '\0')
|
||||
if (*p++ == PATH_SEPARATOR_CHAR || isblank ((unsigned char)*p))
|
||||
++maxelem;
|
||||
|
||||
vpath = (char **) xmalloc (maxelem * sizeof (char *));
|
||||
maxvpath = 0;
|
||||
|
||||
/* Skip over any initial separators and blanks. */
|
||||
p = dirpath;
|
||||
while (*p == PATH_SEPARATOR_CHAR || isblank ((unsigned char)*p))
|
||||
++p;
|
||||
|
||||
elem = 0;
|
||||
while (*p != '\0')
|
||||
{
|
||||
char *v;
|
||||
unsigned int len;
|
||||
|
||||
/* Find the end of this entry. */
|
||||
v = p;
|
||||
while (*p != '\0' && *p != PATH_SEPARATOR_CHAR
|
||||
&& !isblank ((unsigned char)*p))
|
||||
++p;
|
||||
|
||||
len = p - v;
|
||||
/* Make sure there's no trailing slash,
|
||||
but still allow "/" as a directory. */
|
||||
#ifdef __MSDOS__
|
||||
/* We need also to leave alone a trailing slash in "d:/". */
|
||||
if (len > 3 || (len > 1 && v[1] != ':'))
|
||||
#endif
|
||||
if (len > 1 && p[-1] == '/')
|
||||
--len;
|
||||
|
||||
if (len > 1 || *v != '.')
|
||||
{
|
||||
v = savestring (v, len);
|
||||
|
||||
/* Verify that the directory actually exists. */
|
||||
|
||||
if (dir_file_exists_p (v, ""))
|
||||
{
|
||||
/* It does. Put it in the list. */
|
||||
vpath[elem++] = dir_name (v);
|
||||
free (v);
|
||||
if (len > maxvpath)
|
||||
maxvpath = len;
|
||||
}
|
||||
else
|
||||
/* The directory does not exist. Omit from the list. */
|
||||
free (v);
|
||||
}
|
||||
|
||||
/* Skip over separators and blanks between entries. */
|
||||
while (*p == PATH_SEPARATOR_CHAR || isblank ((unsigned char)*p))
|
||||
++p;
|
||||
}
|
||||
|
||||
if (elem > 0)
|
||||
{
|
||||
struct vpath *path;
|
||||
/* ELEM is now incremented one element past the last
|
||||
entry, to where the nil-pointer terminator goes.
|
||||
Usually this is maxelem - 1. If not, shrink down. */
|
||||
if (elem < (maxelem - 1))
|
||||
vpath = (char **) xrealloc ((char *) vpath,
|
||||
(elem + 1) * sizeof (char *));
|
||||
|
||||
/* Put the nil-pointer terminator on the end of the VPATH list. */
|
||||
vpath[elem] = 0;
|
||||
|
||||
/* Construct the vpath structure and put it into the linked list. */
|
||||
path = (struct vpath *) xmalloc (sizeof (struct vpath));
|
||||
path->searchpath = vpath;
|
||||
path->maxlen = maxvpath;
|
||||
path->next = vpaths;
|
||||
vpaths = path;
|
||||
|
||||
/* Set up the members. */
|
||||
path->pattern = pattern;
|
||||
path->percent = percent;
|
||||
path->patlen = strlen (pattern);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* There were no entries, so free whatever space we allocated. */
|
||||
free ((char *) vpath);
|
||||
if (pattern != 0)
|
||||
free (pattern);
|
||||
}
|
||||
}
|
||||
|
||||
/* Search the GPATH list for a pathname string that matches the one passed
|
||||
in. If it is found, return 1. Otherwise we return 0. */
|
||||
|
||||
int
|
||||
gpath_search (file, len)
|
||||
char *file;
|
||||
int len;
|
||||
{
|
||||
register char **gp;
|
||||
|
||||
if (gpaths && (len <= gpaths->maxlen))
|
||||
for (gp = gpaths->searchpath; *gp != NULL; ++gp)
|
||||
if (strneq (*gp, file, len) && (*gp)[len] == '\0')
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Search the VPATH list whose pattern matches *FILE for a directory
|
||||
where the name pointed to by FILE exists. If it is found, we set *FILE to
|
||||
the newly malloc'd name of the existing file, *MTIME_PTR (if MTIME_PTR is
|
||||
not NULL) to its modtime (or zero if no stat call was done), and return 1.
|
||||
Otherwise we return 0. */
|
||||
|
||||
int
|
||||
vpath_search (file, mtime_ptr)
|
||||
char **file;
|
||||
FILE_TIMESTAMP *mtime_ptr;
|
||||
{
|
||||
register struct vpath *v;
|
||||
|
||||
/* If there are no VPATH entries or FILENAME starts at the root,
|
||||
there is nothing we can do. */
|
||||
|
||||
if (**file == '/'
|
||||
#ifdef HAVE_DOS_PATHS
|
||||
|| **file == '\\'
|
||||
|| (*file)[1] == ':'
|
||||
#endif
|
||||
|| (vpaths == 0 && general_vpath == 0))
|
||||
return 0;
|
||||
|
||||
for (v = vpaths; v != 0; v = v->next)
|
||||
if (pattern_matches (v->pattern, v->percent, *file))
|
||||
if (selective_vpath_search (v, file, mtime_ptr))
|
||||
return 1;
|
||||
|
||||
if (general_vpath != 0
|
||||
&& selective_vpath_search (general_vpath, file, mtime_ptr))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Search the given VPATH list for a directory where the name pointed
|
||||
to by FILE exists. If it is found, we set *FILE to the newly malloc'd
|
||||
name of the existing file, *MTIME_PTR (if MTIME_PTR is not NULL) to
|
||||
its modtime (or zero if no stat call was done), and we return 1.
|
||||
Otherwise we return 0. */
|
||||
|
||||
static int
|
||||
selective_vpath_search (path, file, mtime_ptr)
|
||||
struct vpath *path;
|
||||
char **file;
|
||||
FILE_TIMESTAMP *mtime_ptr;
|
||||
{
|
||||
int not_target;
|
||||
char *name, *n;
|
||||
char *filename;
|
||||
register char **vpath = path->searchpath;
|
||||
unsigned int maxvpath = path->maxlen;
|
||||
register unsigned int i;
|
||||
unsigned int flen, vlen, name_dplen;
|
||||
int exists = 0;
|
||||
|
||||
/* Find out if *FILE is a target.
|
||||
If and only if it is NOT a target, we will accept prospective
|
||||
files that don't exist but are mentioned in a makefile. */
|
||||
{
|
||||
struct file *f = lookup_file (*file);
|
||||
not_target = f == 0 || !f->is_target;
|
||||
}
|
||||
|
||||
flen = strlen (*file);
|
||||
|
||||
/* Split *FILE into a directory prefix and a name-within-directory.
|
||||
NAME_DPLEN gets the length of the prefix; FILENAME gets the
|
||||
pointer to the name-within-directory and FLEN is its length. */
|
||||
|
||||
n = strrchr (*file, '/');
|
||||
#ifdef HAVE_DOS_PATHS
|
||||
/* We need the rightmost slash or backslash. */
|
||||
{
|
||||
char *bslash = strrchr(*file, '\\');
|
||||
if (!n || bslash > n)
|
||||
n = bslash;
|
||||
}
|
||||
#endif
|
||||
name_dplen = n != 0 ? n - *file : 0;
|
||||
filename = name_dplen > 0 ? n + 1 : *file;
|
||||
if (name_dplen > 0)
|
||||
flen -= name_dplen + 1;
|
||||
|
||||
/* Allocate enough space for the biggest VPATH entry,
|
||||
a slash, the directory prefix that came with *FILE,
|
||||
another slash (although this one may not always be
|
||||
necessary), the filename, and a null terminator. */
|
||||
name = (char *) xmalloc (maxvpath + 1 + name_dplen + 1 + flen + 1);
|
||||
|
||||
/* Try each VPATH entry. */
|
||||
for (i = 0; vpath[i] != 0; ++i)
|
||||
{
|
||||
int exists_in_cache = 0;
|
||||
|
||||
n = name;
|
||||
|
||||
/* Put the next VPATH entry into NAME at N and increment N past it. */
|
||||
vlen = strlen (vpath[i]);
|
||||
bcopy (vpath[i], n, vlen);
|
||||
n += vlen;
|
||||
|
||||
/* Add the directory prefix already in *FILE. */
|
||||
if (name_dplen > 0)
|
||||
{
|
||||
#ifndef VMS
|
||||
*n++ = '/';
|
||||
#endif
|
||||
bcopy (*file, n, name_dplen);
|
||||
n += name_dplen;
|
||||
}
|
||||
|
||||
#ifdef HAVE_DOS_PATHS
|
||||
/* Cause the next if to treat backslash and slash alike. */
|
||||
if (n != name && n[-1] == '\\' )
|
||||
n[-1] = '/';
|
||||
#endif
|
||||
/* Now add the name-within-directory at the end of NAME. */
|
||||
#ifndef VMS
|
||||
if (n != name && n[-1] != '/')
|
||||
{
|
||||
*n = '/';
|
||||
bcopy (filename, n + 1, flen + 1);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
bcopy (filename, n, flen + 1);
|
||||
|
||||
/* Check if the file is mentioned in a makefile. If *FILE is not
|
||||
a target, that is enough for us to decide this file exists.
|
||||
If *FILE is a target, then the file must be mentioned in the
|
||||
makefile also as a target to be chosen.
|
||||
|
||||
The restriction that *FILE must not be a target for a
|
||||
makefile-mentioned file to be chosen was added by an
|
||||
inadequately commented change in July 1990; I am not sure off
|
||||
hand what problem it fixes.
|
||||
|
||||
In December 1993 I loosened this restriction to allow a file
|
||||
to be chosen if it is mentioned as a target in a makefile. This
|
||||
seem logical. */
|
||||
{
|
||||
struct file *f = lookup_file (name);
|
||||
if (f != 0)
|
||||
exists = not_target || f->is_target;
|
||||
}
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
/* That file wasn't mentioned in the makefile.
|
||||
See if it actually exists. */
|
||||
|
||||
#ifdef VMS
|
||||
exists_in_cache = exists = dir_file_exists_p (vpath[i], filename);
|
||||
#else
|
||||
/* Clobber a null into the name at the last slash.
|
||||
Now NAME is the name of the directory to look in. */
|
||||
*n = '\0';
|
||||
|
||||
/* We know the directory is in the hash table now because either
|
||||
construct_vpath_list or the code just above put it there.
|
||||
Does the file we seek exist in it? */
|
||||
exists_in_cache = exists = dir_file_exists_p (name, filename);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (exists)
|
||||
{
|
||||
/* The file is in the directory cache.
|
||||
Now check that it actually exists in the filesystem.
|
||||
The cache may be out of date. When vpath thinks a file
|
||||
exists, but stat fails for it, confusion results in the
|
||||
higher levels. */
|
||||
|
||||
struct stat st;
|
||||
|
||||
#ifndef VMS
|
||||
/* Put the slash back in NAME. */
|
||||
*n = '/';
|
||||
#endif
|
||||
|
||||
if (!exists_in_cache /* Makefile-mentioned file need not exist. */
|
||||
|| stat (name, &st) == 0) /* Does it really exist? */
|
||||
{
|
||||
/* We have found a file.
|
||||
Store the name we found into *FILE for the caller. */
|
||||
|
||||
*file = savestring (name, (n + 1 - name) + flen);
|
||||
|
||||
if (mtime_ptr != 0)
|
||||
/* Store the modtime into *MTIME_PTR for the caller.
|
||||
If we have had no need to stat the file here,
|
||||
we record UNKNOWN_MTIME to indicate this. */
|
||||
*mtime_ptr = (exists_in_cache
|
||||
? FILE_TIMESTAMP_STAT_MODTIME (name, st)
|
||||
: UNKNOWN_MTIME);
|
||||
|
||||
free (name);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
exists = 0;
|
||||
}
|
||||
}
|
||||
|
||||
free (name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Print the data base of VPATH search paths. */
|
||||
|
||||
void
|
||||
print_vpath_data_base ()
|
||||
{
|
||||
register unsigned int nvpaths;
|
||||
register struct vpath *v;
|
||||
|
||||
puts (_("\n# VPATH Search Paths\n"));
|
||||
|
||||
nvpaths = 0;
|
||||
for (v = vpaths; v != 0; v = v->next)
|
||||
{
|
||||
register unsigned int i;
|
||||
|
||||
++nvpaths;
|
||||
|
||||
printf ("vpath %s ", v->pattern);
|
||||
|
||||
for (i = 0; v->searchpath[i] != 0; ++i)
|
||||
printf ("%s%c", v->searchpath[i],
|
||||
v->searchpath[i + 1] == 0 ? '\n' : PATH_SEPARATOR_CHAR);
|
||||
}
|
||||
|
||||
if (vpaths == 0)
|
||||
puts (_("# No `vpath' search paths."));
|
||||
else
|
||||
printf (_("\n# %u `vpath' search paths.\n"), nvpaths);
|
||||
|
||||
if (general_vpath == 0)
|
||||
puts (_("\n# No general (`VPATH' variable) search path."));
|
||||
else
|
||||
{
|
||||
register char **path = general_vpath->searchpath;
|
||||
register unsigned int i;
|
||||
|
||||
fputs (_("\n# General (`VPATH' variable) search path:\n# "), stdout);
|
||||
|
||||
for (i = 0; path[i] != 0; ++i)
|
||||
printf ("%s%c", path[i],
|
||||
path[i + 1] == 0 ? '\n' : PATH_SEPARATOR_CHAR);
|
||||
}
|
||||
}
|
||||
51
flaim/external/w32/make/w32err.c
vendored
Normal file
51
flaim/external/w32/make/w32err.c
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <windows.h>
|
||||
#include "w32err.h"
|
||||
|
||||
/*
|
||||
* Description: the windows32 version of perror()
|
||||
*
|
||||
* Returns: a pointer to a static error
|
||||
*
|
||||
* Notes/Dependencies: I got this from
|
||||
* comp.os.ms-windows.programmer.win32
|
||||
*/
|
||||
char *
|
||||
map_windows32_error_to_string (DWORD ercode) {
|
||||
/* __declspec (thread) necessary if you will use multiple threads */
|
||||
__declspec (thread) static char szMessageBuffer[128];
|
||||
|
||||
/* Fill message buffer with a default message in
|
||||
* case FormatMessage fails
|
||||
*/
|
||||
wsprintf (szMessageBuffer, "Error %ld", ercode);
|
||||
|
||||
/*
|
||||
* Special code for winsock error handling.
|
||||
*/
|
||||
if (ercode > WSABASEERR) {
|
||||
HMODULE hModule = GetModuleHandle("wsock32");
|
||||
if (hModule != NULL) {
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,
|
||||
hModule,
|
||||
ercode,
|
||||
LANG_NEUTRAL,
|
||||
szMessageBuffer,
|
||||
sizeof(szMessageBuffer),
|
||||
NULL);
|
||||
FreeLibrary(hModule);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Default system message handling
|
||||
*/
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
ercode,
|
||||
LANG_NEUTRAL,
|
||||
szMessageBuffer,
|
||||
sizeof(szMessageBuffer),
|
||||
NULL);
|
||||
}
|
||||
return szMessageBuffer;
|
||||
}
|
||||
|
||||
10
flaim/external/w32/make/w32err.h
vendored
Normal file
10
flaim/external/w32/make/w32err.h
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef _W32ERR_H_
|
||||
#define _W32ERR_H_
|
||||
|
||||
#ifndef EXTERN_DECL
|
||||
#define EXTERN_DECL(entry, args) entry args
|
||||
#endif
|
||||
|
||||
EXTERN_DECL(char * map_windows32_error_to_string, (DWORD error));
|
||||
|
||||
#endif /* !_W32ERR_H */
|
||||
33
flaim/external/w32/printf/build.bat
vendored
Normal file
33
flaim/external/w32/printf/build.bat
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
@echo off
|
||||
|
||||
REM -------------------------------------------------------------------------
|
||||
REM Desc: Batch file for building GNU printf on Windows platforms
|
||||
REM Tabs: 3
|
||||
REM
|
||||
REM Copyright (c) 2006 Novell, Inc. All Rights Reserved.
|
||||
REM
|
||||
REM This program is free software; you can redistribute it and/or
|
||||
REM modify it under the terms of version 2 of the GNU General Public
|
||||
REM License as published by the Free Software Foundation.
|
||||
REM
|
||||
REM This program is distributed in the hope that it will be useful,
|
||||
REM but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
REM GNU General Public License for more details.
|
||||
REM
|
||||
REM You should have received a copy of the GNU General Public License
|
||||
REM along with this program; if not, contact Novell, Inc.
|
||||
REM
|
||||
REM To contact Novell about this file by physical or electronic mail,
|
||||
REM you may find current contact information at www.novell.com
|
||||
REM
|
||||
REM $Id$
|
||||
REM -------------------------------------------------------------------------
|
||||
|
||||
setlocal
|
||||
if exist build-dir rd /s /q build-dir
|
||||
mkdir build-dir
|
||||
cd build-dir
|
||||
cl /nologo -I.. ../*.cpp /Feprintf.exe
|
||||
cd ..
|
||||
endlocal
|
||||
716
flaim/external/w32/printf/printf.cpp
vendored
Normal file
716
flaim/external/w32/printf/printf.cpp
vendored
Normal file
@@ -0,0 +1,716 @@
|
||||
// printf - format and print data
|
||||
// Copyright (C) 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
|
||||
//
|
||||
// This program 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.
|
||||
//
|
||||
// This program 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 this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// Orignal version by David MacKenzie <djm@gnu.ai.mit.edu>
|
||||
// Modified to build and run on Windows platforms by ahodgkinson@novell.com
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define isodigit(c) \
|
||||
((c) >= '0' && (c) <= '7')
|
||||
|
||||
#define hextobin(c) \
|
||||
((c) >= 'a' && (c) <= 'f' ? (c) - 'a' + 10 \
|
||||
: (c) >= 'A' && (c) <= 'F' \
|
||||
? (c) - 'A' + 10 : (c) - '0')
|
||||
|
||||
#define octtobin(c) \
|
||||
((c) - '0')
|
||||
|
||||
char *xmalloc();
|
||||
void error();
|
||||
|
||||
static int exit_status = 0;
|
||||
char * program_name;
|
||||
|
||||
void usage(
|
||||
int status);
|
||||
|
||||
int print_formatted(
|
||||
char * format,
|
||||
int argc,
|
||||
char ** argv);
|
||||
|
||||
int print_esc(
|
||||
char * escstart);
|
||||
|
||||
void print_esc_char(
|
||||
char c);
|
||||
|
||||
void print_esc_string(
|
||||
char * str);
|
||||
|
||||
void print_direc(
|
||||
char * start,
|
||||
int length,
|
||||
int field_width,
|
||||
int precision,
|
||||
char * argument);
|
||||
|
||||
unsigned long xstrtoul(
|
||||
char * s);
|
||||
|
||||
long xstrtol(
|
||||
char * s);
|
||||
|
||||
double xstrtod(
|
||||
char * s);
|
||||
|
||||
void verify(
|
||||
char * s,
|
||||
char * end);
|
||||
|
||||
void error(
|
||||
int status,
|
||||
int errnum,
|
||||
char * message, ...);
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
inline bool isxdigit(
|
||||
char c)
|
||||
{
|
||||
if( (c >= '0' && c <= '9') ||
|
||||
(c >= 'a' && c <= 'f') ||
|
||||
(c >= 'A' && c <= 'F'))
|
||||
{
|
||||
return( true);
|
||||
}
|
||||
|
||||
return( false);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
void main(
|
||||
int argc,
|
||||
char ** argv)
|
||||
{
|
||||
char * format;
|
||||
int args_used;
|
||||
|
||||
program_name = argv[ 0];
|
||||
|
||||
if( argc == 1)
|
||||
{
|
||||
fprintf (stderr, "Usage: %s format [argument...]\n", program_name);
|
||||
exit( 1);
|
||||
}
|
||||
|
||||
format = argv[ 1];
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
|
||||
do
|
||||
{
|
||||
args_used = print_formatted (format, argc, argv);
|
||||
argc -= args_used;
|
||||
argv += args_used;
|
||||
}
|
||||
while( args_used > 0 && argc > 0);
|
||||
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
void usage(
|
||||
int status)
|
||||
{
|
||||
if( status != 0)
|
||||
{
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "Usage: %s FORMAT [ARGUMENT]...\n or: %s OPTION\n",
|
||||
program_name, program_name);
|
||||
|
||||
printf( "\n"
|
||||
"FORMAT controls the output as in C printf. Interpreted sequences are:\n"
|
||||
"\n"
|
||||
" \\\" double quote\n"
|
||||
" \\0NNN character with octal value NNN (0 to 3 digits)\n"
|
||||
" \\\\ backslash\n"
|
||||
" \\a alert (BEL)\n"
|
||||
" \\b backspace\n"
|
||||
" \\c produce no further output\n"
|
||||
" \\f form feed\n"
|
||||
" \\n new line\n"
|
||||
" \\r carriage return\n"
|
||||
" \\t horizontal tab\n"
|
||||
" \\v vertical tab\n"
|
||||
" \\xNNN character with hexadecimal value NNN (1 to 3 digits)\n"
|
||||
"\n"
|
||||
" %%%% a single %%\n"
|
||||
" %%b ARGUMENT as a string with `\\' escapes interpreted\n"
|
||||
"\n"
|
||||
" and all C format specifications ending with one of\n"
|
||||
" diouxXfeEgGcs, with ARGUMENTs converted to proper type\n"
|
||||
" first. Variable widths are handled.\n");
|
||||
}
|
||||
|
||||
exit (status);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc: Print the text in FORMAT, using ARGV (with ARGC elements) for
|
||||
arguments to any `%' directives.
|
||||
|
||||
Return the number of elements of ARGV used.
|
||||
****************************************************************************/
|
||||
int print_formatted(
|
||||
char * format,
|
||||
int argc,
|
||||
char ** argv)
|
||||
{
|
||||
int save_argc = argc; // Preserve original value
|
||||
char * f; // Pointer into `format'
|
||||
char * direc_start; // Start of % directive
|
||||
int direc_length; // Length of % directive
|
||||
int field_width; // Arg to first '*', or -1 if none
|
||||
int precision; // Arg to second '*', or -1 if none
|
||||
|
||||
for( f = format; *f; ++f)
|
||||
{
|
||||
switch( *f)
|
||||
{
|
||||
case '%':
|
||||
{
|
||||
direc_start = f++;
|
||||
direc_length = 1;
|
||||
field_width = precision = -1;
|
||||
|
||||
if( *f == '%')
|
||||
{
|
||||
putchar ('%');
|
||||
break;
|
||||
}
|
||||
|
||||
if( *f == 'b')
|
||||
{
|
||||
if( argc > 0)
|
||||
{
|
||||
print_esc_string (*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if( strchr( "-+ #", *f))
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
|
||||
if( *f == '*')
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
|
||||
if (argc > 0)
|
||||
{
|
||||
field_width = xstrtoul (*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
else
|
||||
{
|
||||
field_width = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while( isdigit (*f))
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
|
||||
if( *f == '.')
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
|
||||
if( *f == '*')
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
|
||||
if (argc > 0)
|
||||
{
|
||||
precision = xstrtoul (*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
else
|
||||
{
|
||||
precision = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while( isdigit (*f))
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( *f == 'l' || *f == 'L' || *f == 'h')
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
|
||||
if( !strchr( "diouxXfeEgGcs", *f))
|
||||
{
|
||||
error( 1, 0, "%%%c: invalid directive", *f);
|
||||
}
|
||||
|
||||
++direc_length;
|
||||
|
||||
if( argc > 0)
|
||||
{
|
||||
print_direc( direc_start, direc_length, field_width,
|
||||
precision, *argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
else
|
||||
{
|
||||
print_direc( direc_start, direc_length, field_width,
|
||||
precision, "");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case '\\':
|
||||
{
|
||||
f += print_esc (f);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
putchar( *f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return( save_argc - argc);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc: Print a \ escape sequence starting at ESCSTART.
|
||||
Return the number of characters in the escape sequence
|
||||
besides the backslash.
|
||||
****************************************************************************/
|
||||
int print_esc(
|
||||
char * escstart)
|
||||
{
|
||||
register char * p = escstart + 1;
|
||||
int esc_value = 0; // Value of \nnn escape
|
||||
int esc_length; // Length of \nnn escape
|
||||
|
||||
// \0ooo and \xhhh escapes have maximum length of 3 chars.
|
||||
|
||||
if (*p == 'x')
|
||||
{
|
||||
for( esc_length = 0, ++p;
|
||||
esc_length < 3 && isxdigit (*p);
|
||||
++esc_length, ++p)
|
||||
{
|
||||
esc_value = esc_value * 16 + hextobin (*p);
|
||||
}
|
||||
|
||||
if (esc_length == 0)
|
||||
{
|
||||
error (1, 0, "missing hexadecimal number in escape");
|
||||
putchar (esc_value);
|
||||
}
|
||||
}
|
||||
else if( *p == '0')
|
||||
{
|
||||
for( esc_length = 0, ++p;
|
||||
esc_length < 3 && isodigit (*p);
|
||||
++esc_length, ++p)
|
||||
{
|
||||
esc_value = esc_value * 8 + octtobin (*p);
|
||||
}
|
||||
|
||||
putchar (esc_value);
|
||||
}
|
||||
else if( strchr ("\"\\abcfnrtv", *p))
|
||||
{
|
||||
print_esc_char (*p++);
|
||||
}
|
||||
else
|
||||
{
|
||||
error( 1, 0, "\\%c: invalid escape", *p);
|
||||
}
|
||||
|
||||
return( p - escstart - 1);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc: Output a single-character \ escape
|
||||
****************************************************************************/
|
||||
void print_esc_char(
|
||||
char c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'a': // Alert
|
||||
{
|
||||
putchar (7);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'b': // Backspace
|
||||
{
|
||||
putchar (8);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'c': // Cancel the rest of the output
|
||||
{
|
||||
exit (0);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'f': // Form feed
|
||||
{
|
||||
putchar (12);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'n': // New line
|
||||
{
|
||||
putchar (10);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'r': // Carriage return
|
||||
{
|
||||
putchar (13);
|
||||
break;
|
||||
}
|
||||
|
||||
case 't': // Horizontal tab
|
||||
{
|
||||
putchar (9);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'v': // Vertical tab
|
||||
{
|
||||
putchar (11);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
putchar (c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc: Print string STR, evaluating \ escapes
|
||||
****************************************************************************/
|
||||
void print_esc_string(
|
||||
char * str)
|
||||
{
|
||||
for( ; *str; str++)
|
||||
{
|
||||
if (*str == '\\')
|
||||
{
|
||||
str += print_esc (str);
|
||||
}
|
||||
else
|
||||
{
|
||||
putchar (*str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc: Output a % directive. START is the start of the directive,
|
||||
LENGTH is its length, and ARGUMENT is its argument.
|
||||
If FIELD_WIDTH or PRECISION is non-negative, they are args for
|
||||
'*' values in those fields
|
||||
****************************************************************************/
|
||||
void print_direc(
|
||||
char * start,
|
||||
int length,
|
||||
int field_width,
|
||||
int precision,
|
||||
char * argument)
|
||||
{
|
||||
char * p; // Null-terminated copy of % directive
|
||||
|
||||
p = (char *)malloc( (unsigned)(length + 1));
|
||||
strncpy (p, start, length);
|
||||
p[length] = 0;
|
||||
|
||||
switch( p[ length - 1])
|
||||
{
|
||||
case 'd':
|
||||
case 'i':
|
||||
{
|
||||
if (field_width < 0)
|
||||
{
|
||||
if (precision < 0)
|
||||
{
|
||||
printf (p, xstrtol (argument));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf (p, precision, xstrtol (argument));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (precision < 0)
|
||||
{
|
||||
printf (p, field_width, xstrtol (argument));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf (p, field_width, precision, xstrtol (argument));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'o':
|
||||
case 'u':
|
||||
case 'x':
|
||||
case 'X':
|
||||
{
|
||||
if (field_width < 0)
|
||||
{
|
||||
if (precision < 0)
|
||||
{
|
||||
printf (p, xstrtoul (argument));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf (p, precision, xstrtoul (argument));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (precision < 0)
|
||||
{
|
||||
printf (p, field_width, xstrtoul (argument));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf (p, field_width, precision, xstrtoul (argument));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'f':
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'g':
|
||||
case 'G':
|
||||
{
|
||||
if( field_width < 0)
|
||||
{
|
||||
if (precision < 0)
|
||||
{
|
||||
printf (p, xstrtod (argument));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf (p, precision, xstrtod (argument));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (precision < 0)
|
||||
{
|
||||
printf (p, field_width, xstrtod (argument));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf (p, field_width, precision, xstrtod (argument));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'c':
|
||||
{
|
||||
printf (p, *argument);
|
||||
break;
|
||||
}
|
||||
|
||||
case 's':
|
||||
{
|
||||
if( field_width < 0)
|
||||
{
|
||||
if (precision < 0)
|
||||
{
|
||||
printf (p, argument);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf (p, precision, argument);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (precision < 0)
|
||||
{
|
||||
printf (p, field_width, argument);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf (p, field_width, precision, argument);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free( p);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
unsigned long xstrtoul(
|
||||
char * s)
|
||||
{
|
||||
char * end;
|
||||
unsigned long val;
|
||||
|
||||
errno = 0;
|
||||
val = strtoul (s, &end, 0);
|
||||
verify (s, end);
|
||||
|
||||
return( val);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
long xstrtol(
|
||||
char * s)
|
||||
{
|
||||
char * end;
|
||||
long val;
|
||||
|
||||
errno = 0;
|
||||
val = strtol (s, &end, 0);
|
||||
verify( s, end);
|
||||
|
||||
return( val);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
double xstrtod(
|
||||
char * s)
|
||||
{
|
||||
char * end;
|
||||
double val;
|
||||
|
||||
errno = 0;
|
||||
val = strtod (s, &end);
|
||||
verify (s, end);
|
||||
|
||||
return( val);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
void verify(
|
||||
char * s,
|
||||
char * end)
|
||||
{
|
||||
if( *end)
|
||||
{
|
||||
if( s == end)
|
||||
{
|
||||
error (0, 0, "%s: expected a numeric value", s);
|
||||
}
|
||||
else
|
||||
{
|
||||
error (0, 0, "%s: value not completely converted", s);
|
||||
}
|
||||
|
||||
exit_status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
void error(
|
||||
int status,
|
||||
int errnum,
|
||||
char * message, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
fflush (stdout);
|
||||
fprintf (stderr, "%s: ", program_name);
|
||||
|
||||
va_start( args, message);
|
||||
vfprintf( stderr, message, args);
|
||||
va_end( args);
|
||||
|
||||
if (errnum)
|
||||
{
|
||||
fprintf( stderr, ": %d", errnum);
|
||||
}
|
||||
|
||||
putc ('\n', stderr);
|
||||
|
||||
fflush (stderr);
|
||||
|
||||
if (status)
|
||||
{
|
||||
exit( status);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,207 +0,0 @@
|
||||
#*****************************************************************************
|
||||
#File: gprintf.gnu
|
||||
#Desc: GNU makefile for gprintf utility
|
||||
#
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.2 2005/11/10 22:58:48 dsanders
|
||||
# Check in open-source changes at head branch - taken from rosalind base.
|
||||
#
|
||||
# Revision 1.0 2000/06/28 13:46:40 andy
|
||||
# Initial revision
|
||||
#
|
||||
#
|
||||
# Rev 1.0 28 Jun 2000 13:46:40 andy
|
||||
# Initial revision.
|
||||
#
|
||||
#---------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (C) Unpublished Work of Novell, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# This work is an unpublished work and contains confidential,
|
||||
# proprietary and trade secret information of Novell, Inc. Access
|
||||
# to this work is restricted to (i) Novell, Inc. employees who have
|
||||
# a need to know how to perform tasks within the scope of their
|
||||
# assignments and (ii) entities other than Novell, Inc. who have
|
||||
# entered into appropriate license agreements. No part of this work
|
||||
# may be used, practiced, performed, copied, distributed, revised,
|
||||
# modified, translated, abridged, condensed, expanded, collected,
|
||||
# compiled, linked, recast, transformed or adapted without the
|
||||
# prior written consent of Novell, Inc. Any use or exploitation of
|
||||
# this work without authorization could subject the perpetrator to
|
||||
# criminal and civil liability.
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# -- includes --
|
||||
|
||||
# -- misc. declarations --
|
||||
.PHONY : all clean
|
||||
.SUFFIXES : .cpp .c .h .hpp .obj .rsp
|
||||
|
||||
# -- variables --
|
||||
|
||||
build_os =
|
||||
env_ok = 1
|
||||
error_str =
|
||||
win32_target =
|
||||
|
||||
# -- includes --
|
||||
|
||||
# -- OS --
|
||||
|
||||
ifeq ($(OS),WINNT)
|
||||
build_os = WINNT
|
||||
endif
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
build_os = WINNT
|
||||
endif
|
||||
|
||||
ifndef build_os
|
||||
error_str = Unsupported operating system
|
||||
env_ok =
|
||||
endif
|
||||
|
||||
# -- build (debug, release, etc.) --
|
||||
|
||||
ifndef build
|
||||
build = release
|
||||
endif
|
||||
|
||||
# -- platform --
|
||||
|
||||
ifndef platform
|
||||
platform = vc6
|
||||
endif
|
||||
|
||||
ifeq ($(platform),vc6)
|
||||
win32_target = 1
|
||||
endif
|
||||
|
||||
# -- default directories --
|
||||
|
||||
ifndef vc_dir
|
||||
vc_dir = c:/msdev6/vc98
|
||||
endif
|
||||
|
||||
ifndef flmroot
|
||||
flmroot = c:/flaim/$(flm_dir)
|
||||
endif
|
||||
|
||||
# -- Files --
|
||||
|
||||
gprintf_src = gprintf.cpp
|
||||
gprintf_obj = $(patsubst %.cpp,$(flmroot)/$(build)/$(platform)/%.obj,$(gprintf_src))
|
||||
|
||||
# -- linker definitions --
|
||||
|
||||
kernel_libs=
|
||||
link_flags=
|
||||
|
||||
ifdef win32_target
|
||||
kernel_libs = user32.lib mpr.lib libcmt.lib libcpmt.lib \
|
||||
oldnames.lib kernel32.lib imagehlp.lib wsock32.lib advapi32.lib
|
||||
|
||||
link_flags = /fixed:no /nologo /machine:i386
|
||||
|
||||
ifeq ($(build),debug)
|
||||
kernel_libs += msvcrtd.lib
|
||||
link_flags += /debug
|
||||
else
|
||||
kernel_libs += msvcrt.lib
|
||||
endif
|
||||
endif
|
||||
|
||||
# -- utility variables --
|
||||
em :=
|
||||
sp := $(em) $(em)
|
||||
comma := ,
|
||||
|
||||
# -- setup include path --
|
||||
inc = $(vc_dir)/include;$(flmroot)/util
|
||||
|
||||
# -- compiler definitions --
|
||||
ccdefs =
|
||||
ccincs =
|
||||
ccflags =
|
||||
libflags =
|
||||
|
||||
ifdef win32_target
|
||||
|
||||
ccdefs += WIN32 WIN32_LEAN_AND_MEAN WIN32_EXTRA_LEAN
|
||||
|
||||
ifeq ($(build),debug)
|
||||
ccdefs += DEBUG
|
||||
endif
|
||||
|
||||
ccincs += /I"$(subst ;,"$(sp)/I",$(inc))"
|
||||
ccincs += /I$(vc_dir)/include
|
||||
|
||||
ccflags += /nologo /c /G3s /Zp1 /Gf /J \
|
||||
/MT /W3 /YX /Oy-
|
||||
|
||||
ifeq ($(build),release)
|
||||
ccflags += /Ox /Gy
|
||||
else
|
||||
ccflags += /Z7 /Od /Ob1
|
||||
endif
|
||||
|
||||
libflags += /nologo
|
||||
|
||||
endif
|
||||
|
||||
# -- tool names --
|
||||
libr =
|
||||
linker =
|
||||
cc =
|
||||
ccp =
|
||||
|
||||
ifdef win32_target
|
||||
libr = $(subst \,/,$(strip $(vc_dir)))/bin/lib.exe
|
||||
linker = $(subst \,/,$(strip $(vc_dir)))/bin/link.exe
|
||||
cc = $(subst \,/,$(strip $(vc_dir)))/bin/cl.exe
|
||||
ccp = $(subst \,/,$(strip $(vc_dir)))/bin/cl.exe
|
||||
endif
|
||||
|
||||
ifndef libr
|
||||
error_str = Librarian not defined
|
||||
env_ok =
|
||||
endif
|
||||
|
||||
ifndef cc
|
||||
error_str = C compiler not defined
|
||||
env_ok =
|
||||
endif
|
||||
|
||||
ifndef ccp
|
||||
error_str = C++ compiler not defined
|
||||
env_ok =
|
||||
endif
|
||||
|
||||
# -- make system pattern search paths --
|
||||
|
||||
vpath %.c $(inc)
|
||||
vpath %.cpp $(inc)
|
||||
|
||||
# -- pattern rules --
|
||||
|
||||
ifdef env_ok
|
||||
|
||||
$(flmroot)/$(build)/$(platform)/%.obj : %.cpp
|
||||
@$(subst /,\\,$(strip $(ccp))) $(ccflags) /Fo$@ /D$(subst $(sp), /D,$(strip $(ccdefs))) $(ccincs) $<
|
||||
|
||||
$(flmroot)/$(build)/$(platform)/gprintf.exe: $(gprintf_obj)
|
||||
@echo $(gprintf_obj) > gprintf.lis
|
||||
@echo $(kernel_libs) >> gprintf.lis
|
||||
@$(linker) $(link_flags) /out:$@ @gprintf.lis
|
||||
@del gprintf.lis
|
||||
|
||||
else
|
||||
|
||||
@echo Environment not configured properly.
|
||||
@echo $(error_str)
|
||||
|
||||
endif
|
||||
|
||||
|
||||
BIN
flaim/make.exe
BIN
flaim/make.exe
Binary file not shown.
BIN
flaim/printf.exe
BIN
flaim/printf.exe
Binary file not shown.
Reference in New Issue
Block a user