Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
2f3d394e
Commit
2f3d394e
authored
Jun 22, 2016
by
Mike Gabriel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nx-X11/config/{imake,makedepend}: Use system-wide available imake and makedepend tools.
parent
5b36f644
Show whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
12 additions
and
8257 deletions
+12
-8257
control
debian/control
+1
-0
Imakefile
nx-X11/Imakefile
+0
-12
Makefile
nx-X11/Makefile
+7
-64
Imakefile
nx-X11/config/Imakefile
+1
-6
Imake.rules
nx-X11/config/cf/Imake.rules
+3
-13
Imake.tmpl
nx-X11/config/cf/Imake.tmpl
+0
-22
Imakefile
nx-X11/config/cf/Imakefile
+0
-3
Imakefile
nx-X11/config/imake/Imakefile
+0
-84
Makefile.ini
nx-X11/config/imake/Makefile.ini
+0
-85
ccimake.c
nx-X11/config/imake/ccimake.c
+0
-62
imake.c
nx-X11/config/imake/imake.c
+0
-2190
imake.man
nx-X11/config/imake/imake.man
+0
-262
imakemdep.h
nx-X11/config/imake/imakemdep.h
+0
-1514
imakesvc.cmd
nx-X11/config/imake/imakesvc.cmd
+0
-302
Imakefile
nx-X11/config/makedepend/Imakefile
+0
-101
cpp.ed
nx-X11/config/makedepend/cpp.ed
+0
-75
cppsetup.c
nx-X11/config/makedepend/cppsetup.c
+0
-233
def.h
nx-X11/config/makedepend/def.h
+0
-188
ifparser.c
nx-X11/config/makedepend/ifparser.c
+0
-553
ifparser.h
nx-X11/config/makedepend/ifparser.h
+0
-83
include.c
nx-X11/config/makedepend/include.c
+0
-318
main.c
nx-X11/config/makedepend/main.c
+0
-865
mkdepend.man
nx-X11/config/makedepend/mkdepend.man
+0
-382
parse.c
nx-X11/config/makedepend/parse.c
+0
-686
pr.c
nx-X11/config/makedepend/pr.c
+0
-124
configure.in
nxcomp/configure.in
+0
-10
configure.in
nxcompext/configure.in
+0
-10
configure.in
nxcompshad/configure.in
+0
-10
No files found.
debian/control
View file @
2f3d394e
...
...
@@ -28,6 +28,7 @@ Build-Depends:
x11proto-core-dev,
expat,
libpixman-1-dev (>= 0.13.2),
xutils-dev,
Standards-Version: 3.9.6
Homepage: https://github.com/ArcticaProject/nx-libs/
Vcs-Git: https://github.com/ArcticaProject/nx-libs/
...
...
nx-X11/Imakefile
View file @
2f3d394e
...
...
@@ -105,11 +105,6 @@ Everything::
@echo ""
@date
@echo ""
cd $(IMAKESRC) && if [ -f Makefile ]; then \
$(MAKE) $(MFLAGS) BOOTSTRAPCFLAGS="$(BOOTSTRAPCFLAGS)"; \
else \
$(MAKE) $(MFLAGS) -f Makefile.ini BOOTSTRAPCFLAGS="$(BOOTSTRAPCFLAGS)"; \
fi
-$(RM) xmakefile.bak; $(MV) xmakefile xmakefile.bak
$(MAKE) $(MFLAGS) xmakefile
$(MAKE) $(MFLAGS) $(MAKE_OPTS) Makefiles
...
...
@@ -149,9 +144,6 @@ Everything::
@echo Rebuilding $(RELEASE) of the X Window System.
@echo :
@echo :
cd $(IMAKESRC)
$(MAKE) $(MFLAGS) -f Makefile.ini imake.exe
cd ..\..
RMoveToBakFile(xmakefile)
$(MAKE) $(MFLAGS) xmakefile
$(MAKE) $(MFLAGS) $(MAKE_OPTS) Makefiles
...
...
@@ -186,7 +178,3 @@ xmakefile-exists::
#ifndef MakeHtmlManIndex
#define MakeHtmlManIndex YES /* install.man generates HTML man page index */
#endif
#undef BootstrapCleanSubdirs
#define BootstrapCleanSubdirs BOOTSTRAPSUBDIRS="$(BOOTSTRAPSUBDIRS)"
BOOTSTRAPSUBDIRS = imake makedepend
nx-X11/Makefile
View file @
2f3d394e
...
...
@@ -8,7 +8,7 @@
# Luna users will need to either run make as "make MAKE=make"
# or add "MAKE = make" to this file.
RELEASE
=
"Release
6.9
"
RELEASE
=
"Release
$(
shell
cat ../VERSION
)
"
SHELL
=
/bin/sh
RM
=
rm
-f
MV
=
mv
...
...
@@ -17,16 +17,11 @@ WIN32WORLDOPTS = -i
TOP
=
.
CURRENT_DIR
=
.
CONFIGSRC
=
$(TOP)
/config
IMAKESRC
=
$(CONFIGSRC)
/imake
DEPENDSRC
=
$(CONFIGSRC)
/makedepend
DEPENDTOP
=
../..
IMAKETOP
=
../..
IRULESRC
=
$(CONFIGSRC)
/cf
IMAKE
=
$(IMAKESRC)
/
imake
IMAKE
=
imake
IMAKE_CMD
=
$(IMAKE)
-I
$(IRULESRC)
$(IMAKE_DEFINES)
MAKE_OPTS
=
-f
xmakefile
MAKE_CMD
=
$(MAKE)
$(MAKE_OPTS)
FLAGS
=
$(MFLAGS)
-f
Makefile.ini
BOOTSTRAPCFLAGS
=
"
$(BOOTSTRAPCFLAGS)
"
CC
=
"
$(CC)
"
all
:
@
${
MAKE
}
${
MAKE_OPTS
}
xmakefile-exists
||
$(MAKE)
all-initial
...
...
@@ -34,8 +29,7 @@ all:
all-initial
:
@
echo
Please use make World, or on NT use nmake World.Win32.
@
echo
Check the configuration parameters
in
the
$(IRULESRC)
directory,
@
echo
and pass BOOTSTRAPCFLAGS
if
necessary.
@
echo
@
echo
Read the release notes carefully before proceeding.
@
echo
Do not name your log file make.log or it will be deleted.
...
...
@@ -43,11 +37,6 @@ World:
@
echo
""
@
echo
Building
$(RELEASE)
.
@
echo
""
@
case
"x
$(BOOTSTRAPCFLAGS)
"
in
x
)
\
echo
I hope you checked the configuration parameters
in
$(IRULESRC)
;
\
echo
to see
if
you need to pass BOOTSTRAPCFLAGS.
;
\
echo
""
;
\
;;
esac
;
@
date
@
echo
""
@
if
[
-f
xmakefile
]
;
then
\
...
...
@@ -55,31 +44,9 @@ World:
${
MAKE
}
${
MAKE_OPTS
}
-k
clean
||
\
$(RM)
xmakefile
;
\
fi
@
if
[
!
-f
$(IRULESRC)
/host.def
]
;
then
\
if
[
!
-f
$(TOP)
/lib/Xt/Imakefile
]
;
then
\
echo
"#define BuildServersOnly YES"
>
$(IRULESRC)
/host.def
;
\
else
\
if
[
!
-f
$(TOP)
/fonts/Imakefile
]
;
then
\
echo
"#define BuildFonts NO"
>
$(IRULESRC)
/host.def
;
\
else
\
echo
""
>
$(IRULESRC)
/host.def
;
\
fi
;
\
fi
;
\
fi
# @rm -f $(IRULESRC)/version.def; echo "" > $(IRULESRC)/version.def;
@
rm
-f
$(IRULESRC)
/date.def
;
echo
""
>
$(IRULESRC)
/date.def
;
# @if [ ! -f $(IRULESRC)/version.def ]; then \
# rm -f $(IRULESRC)/version.def; \
# echo "" > $(IRULESRC)/version.def; \
# fi
# @if [ ! -f $(IRULESRC)/date.def ]; then \
# rm -f $(IRULESRC)/date.def; \
# echo "" > $(IRULESRC)/date.def; \
# fi
cd
$(IMAKESRC)
&&
$(MAKE)
$(FLAGS)
clean
$(MAKE)
$(MFLAGS)
Makefile.boot
${
MAKE
}
$(MFLAGS)
xmakefile
${
MAKE
}
${
MAKE_OPTS
}
$(MFLAGS)
version.def
$(MAKE)
$(MFLAGS)
Makefile.boot
${
MAKE
}
${
MAKE_OPTS
}
$(MFLAGS)
VerifyOS
${
MAKE
}
${
MAKE_OPTS
}
$(MFLAGS)
Makefiles
${
MAKE
}
${
MAKE_OPTS
}
$(MFLAGS)
BOOTSTRAPSUBDIRS
=
clean
...
...
@@ -98,37 +65,13 @@ World:
# The steps are listed as separate targets so clearmake can wink in
# the Makefile.proto files.
Makefile.boot
:
imake.bootstrap
$(RM)
$(IMAKESRC)
/Makefile.proto
imake.proto
:
cd
$(IMAKESRC)
&&
$(MAKE)
$(FLAGS)
$(RM)
$(DEPENDSRC)
/Makefile.proto
$(DEPENDSRC)/Makefile.proto
:
imake.proto
$(IMAKE_CMD)
-s
$(DEPENDSRC)
/Makefile.proto
-f
$(DEPENDSRC)
/Imakefile
-DTOPDIR
=
$(DEPENDTOP)
-DCURDIR
=
$(DEPENDSRC)
depend.bootstrap
:
$(DEPENDSRC)/Makefile.proto
cd
$(DEPENDSRC)
&&
$(RM)
-r
Makefile Makefile.dep makedepend
*
.o bootstrap
cd
$(DEPENDSRC)
&&
$(MAKE)
-f
Makefile.proto bootstrap
$(IMAKESRC)/Makefile.proto
:
depend.bootstrap
$(IMAKE_CMD)
-s
$(IMAKESRC)
/Makefile.proto
-f
$(IMAKESRC)
/Imakefile
-DTOPDIR
=
$(IMAKETOP)
-DCURDIR
=
$(IMAKESRC)
-DBootStrap
imake.bootstrap
:
$(IMAKESRC)/Makefile.proto
cd
$(IMAKESRC)
&&
$(MAKE)
-f
Makefile.proto bootstrapdepend
cd
$(IMAKESRC)
&&
$(MAKE)
$(FLAGS)
bootstrap
cd
$(IMAKESRC)
&&
$(MAKE)
-f
Makefile.proto imakeonly
-
@if
[
-f
xmakefile
]
;
then
set
-x
;
\
$(RM)
xmakefile.bak
;
$(MV)
xmakefile xmakefile.bak
;
\
else
exit
0
;
fi
$(MAKE)
$(MFLAGS)
xmakefile
Makefile
::
$(MAKE)
$(MFLAGS)
xmakefile
xmakefile
:
Imakefile
$(RM)
xmakefile
@
if
[
-f
xmakefile
]
;
then
set
-x
;
\
$(RM)
xmakefile.bak
;
$(MV)
xmakefile xmakefile.bak
;
\
else
exit
0
;
fi
@
rm
-f
$(IRULESRC)
/date.def
;
echo
""
>
$(IRULESRC)
/date.def
;
$(IMAKE_CMD)
-s
xmakefile
-DTOPDIR
=
$(TOP)
-DCURDIR
=
$(CURRENT_DIR)
...
...
nx-X11/config/Imakefile
View file @
2f3d394e
...
...
@@ -8,12 +8,7 @@ XCOMM $XFree86: xc/config/Imakefile,v 1.3 2001/01/17 16:22:29 dawes Exp $
NULL =
BOOTSTRAPSUBDIRS = \
imake \
makedepend \
$(NULL)
SUBDIRS = cf $(BOOTSTRAPSUBDIRS)
SUBDIRS = cf
#if defined(XorgVersionString) \
&& defined(ProjectRoot) && \
...
...
nx-X11/config/cf/Imake.rules
View file @
2f3d394e
...
...
@@ -1930,9 +1930,7 @@ DependDependencyStatement() @@\
NoCmpScript(ProgramTargetName($(DEPEND))) @@\
@@\
ProgramTargetName($(DEPEND)): @@\
@echo "checking $@ over in $(DEPENDSRC) first..."; \ @@\
cd $(DEPENDSRC) && $(MAKE) makedependonly; \ @@\
echo "okay, continuing in $(CURRENT_DIR)"
echo "using system-wide depend, continuing in $(CURRENT_DIR)"
#endif /* UseInstalled */
#endif /* DependDependency */
...
...
@@ -2025,11 +2023,7 @@ target:: ProgramTargetName($(IMAKE)) @@\
NoCmpScript(ProgramTargetName($(IMAKE)) $(IMAKE).Osuf) @@\
@@\
ProgramTargetName($(IMAKE)) $(IMAKE).Osuf: @@\
-@(cd $(IMAKESRC) && if [ -f Makefile ]; then \ @@\
echo "checking $@ in $(IMAKESRC) first..."; $(MAKE) imakeonly; else \ @@\
echo "bootstrapping $@ from Makefile.ini in $(IMAKESRC) first..."; \ @@\
$(MAKE) -f Makefile.ini BOOTSTRAPCFLAGS="$(BOOTSTRAPCFLAGS)"; fi; \ @@\
echo "okay, continuing in $(CURRENT_DIR)")
echo "using system-wide imake, continuing in $(CURRENT_DIR)"
#endif /* UseInstalled */
#endif /* ImakeDependency */
...
...
@@ -3226,12 +3220,8 @@ target:: @@\
fi; \ @@\
done
#ifdef UseInstalled
#define ImakeSubCmdHelper $(IMAKE_CMD)
#else
#define ImakeSubCmdHelper $(IMAKEPREFIX)$(IMAKE) -I$(IMAKEPREFIX)$(IRULESRC) \
#define ImakeSubCmdHelper $(IMAKE_CMD) -I$(IMAKEPREFIX)$(IRULESRC) \
$(IMAKE_DEFINES) $(IMAKE_WARNINGS)
#endif
#endif /* MakeMakeSubdirs */
...
...
nx-X11/config/cf/Imake.tmpl
View file @
2f3d394e
...
...
@@ -1386,35 +1386,13 @@ TCLIBDIR = TclLibDir
#define LoaderLibPrefix /**/
#endif
#ifndef ImakeCmd
#ifdef UseInstalled /* assume BINDIR in path */
#define ImakeCmd imake
#else
#define ImakeCmd $(IMAKESRC)/imake
#endif
#endif
#ifndef ImakeWarningFlags
#define ImakeWarningFlags /* Nothing */
#endif
#ifndef DependCmd
#if UseGccMakeDepend
#ifdef UseInstalled /* assume BINDIR in path */
#define DependCmd gccmakedep
#else
#define DependCmd $(DEPENDSRC)/gccmakedep
#endif
#elif UseCCMakeDepend
#ifdef UseInstalled /* assume BINDIR in path */
#define DependCmd ccmakedep
#else
#define DependCmd $(DEPENDSRC)/ccmakedep
#endif
#else
#ifdef UseInstalled /* assume BINDIR in path */
#define DependCmd makedepend
#else
#define DependCmd $(DEPENDSRC)/makedepend
#endif
#endif
#endif
#ifndef DependDefines
# if UseCCMakeDepend || UseGccMakeDepend
...
...
nx-X11/config/cf/Imakefile
View file @
2f3d394e
...
...
@@ -30,14 +30,12 @@ xorgversion.def \
nxversion.def
RULEFILES = \
Imake.rules \
X11.rules \
lnxLib.rules \
noop.rules \
xf86.rules
TMPLFILES = \
Imake.tmpl \
Library.tmpl \
Server.tmpl \
ServerLib.tmpl \
...
...
@@ -47,7 +45,6 @@ lnxLib.tmpl \
xorg.tmpl
CFFILES = \
Imake.cf \
linux.cf \
xorg.cf
...
...
nx-X11/config/imake/Imakefile
deleted
100644 → 0
View file @
5b36f644
XCOMM $XdotOrg: xc/config/imake/Imakefile,v 1.3 2005/10/10 23:49:09 kem Exp $
XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:41:50 cpqbld Exp $
XCOMM
XCOMM
XCOMM
XCOMM
XCOMM $XFree86: xc/config/imake/Imakefile,v 3.18 2003/10/21 17:41:44 tsi Exp $
XCOMM Some compilers generate fatal errors if an -L directory does
XCOMM not exist. Since BUILDLIBDIR may not exist yet suppress its use.
LDPRELIB =
LDPRELIBS =
DEPLIBS =
INCLUDES = -I$(TOP)/include $(TOP_X_INCLUDES)/X11
CPP_PROGRAM = CppCmd
CPP_DEFINES = -DCPP_PROGRAM="\"$(CPP_PROGRAM)\""
GCC_COMMAND = $(CC) -fmerge-constants -xc /dev/null -S -o /dev/null 2> /dev/null 1> /dev/null
GCC_DEFINES = -DHAS_MERGE_CONSTANTS=`if $(GCC_COMMAND); then echo 1; else echo 0; fi`
EXTRA_DEFINES=-DMONOLITH
#ifdef CrossCompileDir
CROSSCOMPILEDIR = CrossCompileDir
CROSSCOMPILEDEFINES=-DCROSSCOMPILE -DCROSSCOMPILEDIR=\"$(CROSSCOMPILEDIR)\"
#else
CROSSCOMPILEDIR =
CROSSCOMPILEDEFINES=
BOOTSTRAPDEFINES =
#endif
DEFINES = $(SIGNAL_DEFINES) $(BOOTSTRAPCFLAGS) $(CPP_DEFINES) $(GCC_DEFINES) \
$(CROSSCOMPILEDEFINES)
EXTRAMANDEFS = -D__cpp__="\"$(CPP_PROGRAM)\""
#if defined(MacIIArchitecture) || defined(SequentArchitecture) || defined(i386ScoArchitecture)
XBSDLIB = /**/
#endif
#ifdef CrossCompileDir
# ifdef TargetPreProcessCmd
CPP = TargetPreProcessCmd
# else
CPP = CrossCompileDir/cc -E -
# endif
IMAKEMDEFS_CPPDEFINES = $(DEFINES) -DCROSSCOMPILE_CPP
CppFileTarget(imakemdep_cpp.h,imakemdep.h,$(IMAKEMDEFS_CPPDEFINES),\
NullParameter)
#endif
#undef ImakeDependency
#define ImakeDependency(dummy) @@\
imake.o: imakemdep_cpp.h @@\
Makefile:: ProgramTargetName(imake)
#if CrossCompiling
SimpleHostProgramTarget(imake)
#else
SimpleProgramTarget(imake)
#endif
imakeonly:: $(PROGRAM)
InstallDriverSDKNamedProg(imake,imake,$(DRIVERSDKDIR)/config/imake)
#if HasClearmake
bootstrapdepend: depend
#else
bootstrapdepend:
#endif
clean::
RemoveFile(ProgramTargetName(ccimake))
RemoveFile(Makefile.proto)
RemoveFile(imakemdep_cpp.h)
$(RM) -r bootstrap
#ifdef OS2Architecture
clean::
RemoveFiles(imake ccimake)
#endif
nx-X11/config/imake/Makefile.ini
deleted
100644 → 0
View file @
5b36f644
# $Xorg: Makefile.ini,v 1.3 2000/08/17 19:41:50 cpqbld Exp $
#
# WARNING WARNING WARNING WARNING WARNING WARNING WARNING
#
# This is NOT an automatically generated Makefile! It is hand-crafted as a
# bootstrap, may need editing for your system. The BOOTSTRAPCFLAGS variable
# may be given at the top of the build tree for systems that do not define
# any machine-specific preprocessor symbols.
#
# $XFree86: xc/config/imake/Makefile.ini,v 3.9 2000/10/26 17:57:45 dawes Exp $
CROSSCOMPILEDIR
=
CROSSCOMPILEFLAGS
=
-DCROSSCOMPILEDIR=
\"
$(CROSSCOMPILEDIR)
\"
BOOTSTRAPCFLAGS
=
CC = cc
PREPROCESS_CMD
=
cc -E
CDEBUGFLAGS
=
-O
INCLUDES
=
-I../../include -I../../imports/x11/include/X11
CFLAGS
=
$(BOOTSTRAPCFLAGS) $(CDEBUGFLAGS) $(INCLUDES) -DMONOLITH
IMAKEMDEP_CROSSCOMPILE
=
-DCROSSCOMPILE_CPP
SHELL
=
/bin/sh
RM
=
rm -f
MV
=
mv
RM_CMD
=
$(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a
\
tags TAGS make.log
NPROC
=
1
imake::
@echo
"making
imake
with
BOOTSTRAPCFLAGS
=
$(BOOTSTRAPCFLAGS) and CROSSCOMPILEFLAGS=$(CROSSCOMPILEFLAGS) in config/imake"
imake::
imake.o
$(CC)
-o
imake
$(CFLAGS)
imake.o
imake.o:
ccimake
imake.c
imakemdep_cpp.h
$(CC)
-c
$(CFLAGS)
`./ccimake`
imake.c
ccimake:
ccimake.c
$(CC)
-o
ccimake
$(CROSSCOMPILEFLAGS)
$(CFLAGS)
ccimake.c
imakemdep_cpp.h:
ccimake
imakemdep.h
if
[ -n "$(CROSSCOMPILEDIR)" ]
; then \
$(CROSSCOMPILEDIR)/$(PREPROCESS_CMD)
`./ccimake`
\
$(IMAKEMDEP_CROSSCOMPILE)
imakemdep.h
>
imakemdep_cpp.h
; \
else
touch
imakemdep_cpp.h
; fi
# a derived object erroneously would get shared across platforms by clearmake
.NO_CONFIG_REC:
ccimake
bootstrap:
-@if
[ -d bootstrap ]
; then exit 0; else set -x; mkdir bootstrap; fi
$(MV)
*.o
bootstrap
@if
[ -f imake.exe ]
; then set -x; $(MV) imake.exe bootstrap; \
elif
[ -f imake ]
; then set -x; $(MV) imake bootstrap; else exit 0; fi
relink:
$(RM)
imake
$(MAKE)
$(MFLAGS)
imake
clean:
$(RM)
ccimake
imake.o
imake
$(RM_CMD)
\
#*
$(RM)
-r
Makefile.proto
Makefile
Makefile.dep
bootstrap
$(RM)
imakemdep_cpp.h
depend:
imake.exe::
@echo
making
imake
with
BOOTSTRAPCFLAGS
=
-DWIN32
imake.exe::
imake.obj
cl
-nologo
imake.obj
libc.lib
kernel32.lib
imake.obj:
imake.c
cl
-nologo
-W2
-D__STDC__
-c
-DWIN32
$(CFLAGS)
imake.c
clean.Win32:
if
exist
imake.exe
del
imake.exe
if
exist
imake.obj
del
imake.obj
clean.os2:
imakesvc
4
imake
imake.exe
imake.o
/imake.exe
imake.os2:
imake.c
$(CC)
-DBSD43
$(CFLAGS)
-o
imake.exe
imake.c
copy
imake.exe
\\
nx-X11/config/imake/ccimake.c
deleted
100644 → 0
View file @
5b36f644
/* $Xorg: ccimake.c,v 1.4 2001/02/09 02:03:15 xorgcvs Exp $ */
/*
Copyright (c) 1993, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group .
*/
/* $XFree86: xc/config/imake/ccimake.c,v 1.2 2001/04/01 13:59:56 tsi Exp $ */
/*
* Warning: This file must be kept as simple as possible so that it can
* compile without any special flags on all systems. Do not touch it unless
* you *really* know what you're doing. Make changes in imakemdep.h, not here.
*/
#define CCIMAKE
/* only get imake_ccflags definitions */
#include "imakemdep.h"
/* things to set when porting imake */
#ifndef imake_ccflags
# define imake_ccflags "-O"
#endif
#ifndef CROSSCOMPILEDIR
# define CROSSCOMPILEDIR ""
#endif
#define crosscompile_ccflags " -DCROSSCOMPILE "
#define crosscompiledir_str "-DCROSSCOMPILEDIR="
int
main
()
{
if
(
CROSSCOMPILEDIR
[
0
]
!=
'\0'
)
{
write
(
1
,
crosscompiledir_str
,
sizeof
(
crosscompiledir_str
)
-
1
);
write
(
1
,
"
\"
"
,
1
);
write
(
1
,
CROSSCOMPILEDIR
,
sizeof
(
CROSSCOMPILEDIR
)
-
1
);
write
(
1
,
"
\"
"
,
1
);
write
(
1
,
crosscompile_ccflags
,
sizeof
(
crosscompile_ccflags
)
-
1
);
}
write
(
1
,
imake_ccflags
,
sizeof
(
imake_ccflags
)
-
1
);
return
0
;
}
nx-X11/config/imake/imake.c
deleted
100644 → 0
View file @
5b36f644
/***************************************************************************
* *
* Porting Note *
* *
* Add the value of BOOTSTRAPCFLAGS to the cpp_argv table so that it will *
* be passed to the template file. *
* *
***************************************************************************/
/*
*
Copyright (c) 1985, 1986, 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*
* Original Author:
* Todd Brunhoff
* Tektronix, inc.
* While a guest engineer at Project Athena, MIT
*
* imake: the include-make program.
*
* Usage: imake [-Idir] [-Ddefine] [-T template] [-f imakefile ] [-C Imakefile.c ] [-s] [-e] [-v] [make flags]
*
* Imake takes a template file (Imake.tmpl) and a prototype (Imakefile)
* and runs cpp on them producing a Makefile. It then optionally runs make
* on the Makefile.
* Options:
* -D define. Same as cpp -D argument.
* -U undefine. Same as cpp -U argument.
* -W warning. Same as cpp -W argument.
* -I Include directory. Same as cpp -I argument.
* -T template. Designate a template other
* than Imake.tmpl
* -f specify the Imakefile file
* -C specify the name to use instead of Imakefile.c
* -s[F] show. Show the produced makefile on the standard
* output. Make is not run is this case. If a file
* argument is provided, the output is placed there.
* -e[F] execute instead of show; optionally name Makefile F
* -v verbose. Show the make command line executed.
*
* Environment variables:
*
* IMAKEINCLUDE Include directory to use in addition to "."
* IMAKECPP Cpp to use instead of /lib/cpp
* IMAKEMAKE make program to use other than what is
* found by searching the $PATH variable.
* Other features:
* imake reads the entire cpp output into memory and then scans it
* for occurences of "@@". If it encounters them, it replaces it with
* a newline. It also trims any trailing white space on output lines
* (because make gets upset at them). This helps when cpp expands
* multi-line macros but you want them to appear on multiple lines.
* It also changes occurences of "XCOMM" to "#", to avoid problems
* with treating commands as invalid preprocessor commands.
*
* The macros MAKEFILE and MAKE are provided as macros
* to make. MAKEFILE is set to imake's makefile (not the constructed,
* preprocessed one) and MAKE is set to argv[0], i.e. the name of
* the imake program.
*
* Theory of operation:
* 1. Determine the name of the imakefile from the command line (-f)
* or from the content of the current directory (Imakefile or imakefile).
* Call this <imakefile>. This gets added to the arguments for
* make as MAKEFILE=<imakefile>.
* 2. Determine the name of the template from the command line (-T)
* or the default, Imake.tmpl. Call this <template>
* 3. Determine the name of the imakeCfile from the command line (-C)
* or the default, Imakefile.c. Call this <imakeCfile>
* 4. Store lines of input into <imakeCfile>:
* - A c-style comment header (see ImakefileCHeader below), used
* to recognize temporary files generated by imake.
* - If DEFAULT_OS_NAME is defined, format the utsname struct and
* call the result <defaultOsName>. Add:
* #define DefaultOSName <defaultOsName>
* - If DEFAULT_OS_MAJOR_REV is defined, format the utsname struct
* and call the result <defaultOsMajorVersion>. Add:
* #define DefaultOSMajorVersion <defaultOsMajorVersion>
* - If DEFAULT_OS_MINOR_REV is defined, format the utsname struct
* and call the result <defaultOsMinorVersion>. Add:
* #define DefaultOSMinorVersion <defaultOsMinorVersion>
* - If DEFAULT_OS_TEENY_REV is defined, format the utsname struct
* and call the result <defaultOsTeenyVersion>. Add:
* #define DefaultOSTeenyVersion <defaultOsTeenyVersion>
* - If DEFAULT_MACHINE_ARCITECTURE is defined, format the utsname struct
* and define the corresponding macro. (For example on the amiga,
* this will define amiga in addition to m68k).
* - If the file "localdefines" is readable in the current
* directory, print a warning message to stderr and add:
* #define IMAKE_LOCAL_DEFINES "localdefines"
* #include IMAKE_LOCAL_DEFINES
* - If the file "admindefines" is readable in the current
* directory, print a warning message to stderr and add:
* #define IMAKE_ADMIN_DEFINES "admindefines"
* #include IMAKE_ADMIN_DEFINES
* - The following lines:
* #define INCLUDE_IMAKEFILE < <imakefile> >
* #define IMAKE_TEMPLATE " <template> "
* #include IMAKE_TEMPLATE
* - If the file "adminmacros" is readable in the current
* directory, print a warning message to stderr and add:
* #define IMAKE_ADMIN_MACROS "adminmacros"
* #include IMAKE_ADMIN_MACROS
* - If the file "localmacros" is readable in the current
* directory, print a warning message to stderr and add:
* #define IMAKE_LOCAL_MACROS "localmacros"
* #include IMAKE_LOCAL_MACROS
* 5. Start up cpp and provide it with this file.
* Note that the define for INCLUDE_IMAKEFILE is intended for
* use in the template file. This implies that the imake is
* useless unless the template file contains at least the line
* #include INCLUDE_IMAKEFILE
* 6. Gather the output from cpp, and clean it up, expanding @@ to
* newlines, stripping trailing white space, cpp control lines,
* and extra blank lines, and changing XCOMM to #. This cleaned
* output is placed in a new file, default "Makefile", but can
* be specified with -s or -e options.
* 7. Optionally start up make on the resulting file.
*
* The design of the template makefile should therefore be:
* <set global macros like CFLAGS, etc.>
* <include machine dependent additions>
* #include INCLUDE_IMAKEFILE
* <add any global targets like 'clean' and long dependencies>
*/
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
/* This needs to be before _POSIX_SOURCE gets defined */
# include <sys/param.h>
# include <sys/types.h>
# include <sys/sysctl.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <X11/Xfuncproto.h>
#include <X11/Xosdefs.h>
#include <string.h>
#include <ctype.h>
#ifdef WIN32
# include "Xw32defs.h"
#endif
#include <sys/types.h>
#include <fcntl.h>
#ifdef X_NOT_POSIX
# ifndef WIN32
# include <sys/file.h>
# endif
#else
# include <unistd.h>
#endif
#ifdef ISC
# include <unistd.h>
#endif
#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE)
# include <signal.h>
#else
# define _POSIX_SOURCE
# include <signal.h>
# undef _POSIX_SOURCE
#endif
#if !defined(SIGCHLD) && defined(SIGCLD)
# define SIGCHLD SIGCLD
#endif
#include <sys/stat.h>
#ifndef X_NOT_POSIX
# ifdef _POSIX_SOURCE
# ifdef __SCO__
# include <sys/procset.h>
# include <sys/siginfo.h>
# endif
# include <sys/wait.h>
# else
# define _POSIX_SOURCE
# include <sys/wait.h>
# undef _POSIX_SOURCE
# endif
# define waitCode(w) WEXITSTATUS(w)
# define waitSig(w) WTERMSIG(w)
typedef
int
waitType
;
#else
/* X_NOT_POSIX */
# ifdef SYSV
# define waitCode(w) (((w) >> 8) & 0x7f)
# define waitSig(w) ((w) & 0xff)
typedef
int
waitType
;
# else
/* SYSV */
# ifdef WIN32
# include <process.h>
typedef
int
waitType
;
# else
# include <sys/wait.h>
# define waitCode(w) ((w).w_T.w_Retcode)
# define waitSig(w) ((w).w_T.w_Termsig)
typedef
union
wait
waitType
;
# endif
# endif
# ifndef WIFSIGNALED
# define WIFSIGNALED(w) waitSig(w)
# endif
# ifndef WIFEXITED
# define WIFEXITED(w) waitCode(w)
# endif
#endif
/* X_NOT_POSIX */
#include <stdlib.h>
#include <errno.h>
#ifdef __minix_vmd
# define USE_FREOPEN 1
#endif
#ifndef WIN32
# include <sys/utsname.h>
#else
# include <windows.h>
#endif
#ifndef SYS_NMLN
# ifdef _SYS_NMLN
# define SYS_NMLN _SYS_NMLN
# else
# define SYS_NMLN 257
# endif
#endif
#if defined(linux) || defined(__GNU__) || defined(__GLIBC__)
# include <limits.h>
# include <stdio.h>
#endif
#ifdef __QNX__
# include <unix.h>
#endif
#if defined(__NetBSD__)
/* see code clock in init() below */
# include <sys/utsname.h>
#endif
typedef
unsigned
char
boolean
;
#define TRUE 1
#define FALSE 0
#include "imakemdep.h"
#ifdef CROSSCOMPILE
# include "imakemdep_cpp.h"
#endif
#if defined CROSSCOMPILE || defined FIXUP_CPP_WHITESPACE
int
InRule
=
FALSE
;
#endif
#if defined CROSSCOMPILE || defined INLINE_SYNTAX
int
InInline
=
0
;
#endif
#if defined CROSSCOMPILE || defined MAGIC_MAKE_VARS
int
xvariable
=
0
;
int
xvariables
[
10
];
#endif
#ifndef PATH_MAX
# define PATH_MAX 1024
#endif
/*
* Some versions of cpp reduce all tabs in macro expansion to a single
* space. In addition, the escaped newline may be replaced with a
* space instead of being deleted. Blech.
*/
void
KludgeOutputLine
(
char
**
),
KludgeResetRule
(
void
);
#ifndef CROSSCOMPILE
# ifdef USE_CC_E
# ifndef DEFAULT_CC
# define DEFAULT_CC "cc"
# endif
# else
# ifndef DEFAULT_CPP
# ifdef CPP_PROGRAM
# define DEFAULT_CPP CPP_PROGRAM
# else
# define DEFAULT_CPP "/lib/cpp"
# endif
# endif
# endif
#endif
const
char
*
cpp
=
NULL
;
const
char
*
tmpMakefile
;
const
char
*
tmpMakefileTemplate
=
"/tmp/Imf.XXXXXX"
;
const
char
*
tmpImakefile
;
const
char
*
tmpImakefileTemplate
=
"/tmp/IIf.XXXXXX"
;
const
char
*
make_argv
[
ARGUMENTS
]
=
{
#ifdef WIN32
"nmake"
#else
"make"
#endif
};
int
make_argindex
;
int
cpp_argindex
;
const
char
*
Imakefile
=
NULL
;
const
char
*
Makefile
=
"Makefile"
;
const
char
*
Template
=
"Imake.tmpl"
;
const
char
*
ImakefileC
=
"Imakefile.c"
;
boolean
haveImakefileC
=
FALSE
;
const
char
*
cleanedImakefile
=
NULL
;
const
char
*
program
;
const
char
*
FindImakefile
(
const
char
*
Imakefile
);
char
*
ReadLine
(
FILE
*
tmpfd
,
const
char
*
tmpfname
);
const
char
*
CleanCppInput
(
const
char
*
imakefile
);
char
*
Strdup
(
const
char
*
cp
);
char
*
Emalloc
(
int
size
);
void
LogFatal
(
const
char
*
x0
,
...)
_X_ATTRIBUTE_PRINTF
(
1
,
2
);
void
LogMsg
(
const
char
*
x0
,
...)
_X_ATTRIBUTE_PRINTF
(
1
,
2
);
void
showit
(
FILE
*
fd
);
void
wrapup
(
void
);
void
init
(
void
);
void
AddMakeArg
(
const
char
*
arg
);
void
AddCppArg
(
const
char
*
arg
);
#ifdef CROSSCOMPILE
char
*
CrossCompileCPP
(
void
);
#endif
void
SetOpts
(
int
argc
,
char
**
argv
);
void
CheckImakefileC
(
const
char
*
masterc
);
void
cppit
(
const
char
*
imakefile
,
const
char
*
template
,
const
char
*
masterc
,
FILE
*
outfd
,
const
char
*
outfname
);
void
makeit
(
void
);
void
CleanCppOutput
(
FILE
*
tmpfd
,
const
char
*
tmpfname
);
boolean
isempty
(
char
*
line
);
void
writetmpfile
(
FILE
*
fd
,
const
char
*
buf
,
int
cnt
,
const
char
*
fname
);
#ifdef SIGNALRETURNSINT
int
catch
(
int
sig
);
#else
void
catch
(
int
sig
);
#endif
void
showargs
(
const
char
**
argv
);
boolean
optional_include
(
FILE
*
inFile
,
const
char
*
defsym
,
const
char
*
fname
);
void
doit
(
FILE
*
outfd
,
const
char
*
cmd
,
const
char
**
argv
);
boolean
define_os_defaults
(
FILE
*
inFile
);
#ifdef CROSSCOMPILE
static
void
get_cross_compile_dir
(
FILE
*
inFile
);
#endif
#ifdef CROSSCOMPILEDIR
const
char
*
CrossCompileDir
=
CROSSCOMPILEDIR
;
#else
const
char
*
CrossCompileDir
=
""
;
#endif
boolean
CrossCompiling
=
FALSE
;
boolean
verbose
=
FALSE
;
boolean
show
=
TRUE
;
int
main
(
int
argc
,
char
*
argv
[])
{
FILE
*
tmpfd
=
NULL
;
char
makeMacro
[
BUFSIZ
];
char
makefileMacro
[
BUFSIZ
];
int
lenCrossCompileDir
=
0
;
program
=
argv
[
0
];
init
();
lenCrossCompileDir
=
strlen
(
CrossCompileDir
);
if
(
lenCrossCompileDir
)
{
if
(
lenCrossCompileDir
>
(
PATH_MAX
-
20
))
LogFatal
(
"Cross compile directory path too long %s
\n
"
,
CrossCompileDir
);
else
CrossCompiling
=
TRUE
;
}
SetOpts
(
argc
,
argv
);
Imakefile
=
FindImakefile
(
Imakefile
);
CheckImakefileC
(
ImakefileC
);
if
(
Makefile
)
{
tmpMakefile
=
Makefile
;
if
((
tmpfd
=
fopen
(
tmpMakefile
,
"w+"
))
==
NULL
)
LogFatal
(
"Cannot create temporary file %s."
,
tmpMakefile
);
}
else
{
#ifdef HAVE_MKSTEMP
int
fd
;
#endif
char
*
tmpMakefileName
=
Strdup
(
tmpMakefileTemplate
);
#ifndef HAVE_MKSTEMP
if
(
mktemp
(
tmpMakefileName
)
==
NULL
||
(
tmpfd
=
fopen
(
tmpMakefileName
,
"w+"
))
==
NULL
)
{
LogFatal
(
"Cannot create temporary file %s."
,
tmpMakefileName
);
}
#else
fd
=
mkstemp
(
tmpMakefileName
);
if
(
fd
==
-
1
||
(
tmpfd
=
fdopen
(
fd
,
"w+"
))
==
NULL
)
{
if
(
fd
!=
-
1
)
{
unlink
(
tmpMakefileName
);
close
(
fd
);
}
LogFatal
(
"Cannot create temporary file %s."
,
tmpMakefileName
);
}
#endif
tmpMakefile
=
tmpMakefileName
;
}
AddMakeArg
(
"-f"
);
AddMakeArg
(
tmpMakefile
);
sprintf
(
makeMacro
,
"MAKE=%s"
,
program
);
AddMakeArg
(
makeMacro
);
sprintf
(
makefileMacro
,
"MAKEFILE=%s"
,
Imakefile
);
AddMakeArg
(
makefileMacro
);
cleanedImakefile
=
CleanCppInput
(
Imakefile
);
cppit
(
cleanedImakefile
,
Template
,
ImakefileC
,
tmpfd
,
tmpMakefile
);
if
(
show
)
{
if
(
Makefile
==
NULL
)
showit
(
tmpfd
);
}
else
makeit
();
wrapup
();
exit
(
0
);
}
void
showit
(
FILE
*
fd
)
{
char
buf
[
BUFSIZ
];
int
red
;
fseek
(
fd
,
0
,
0
);
while
((
red
=
fread
(
buf
,
1
,
BUFSIZ
,
fd
))
>
0
)
writetmpfile
(
stdout
,
buf
,
red
,
"stdout"
);
if
(
red
<
0
)
LogFatal
(
"Cannot read %s."
,
tmpMakefile
);
}
void
wrapup
(
void
)
{
if
(
tmpMakefile
!=
Makefile
)
unlink
(
tmpMakefile
);
if
(
cleanedImakefile
&&
cleanedImakefile
!=
Imakefile
)
unlink
(
cleanedImakefile
);
if
(
haveImakefileC
)
unlink
(
ImakefileC
);
}
#ifdef SIGNALRETURNSINT
int
#else
void
#endif
catch
(
int
sig
)
{
errno
=
0
;
LogFatal
(
"Signal %d."
,
sig
);
}
/*
* Initialize some variables.
*/
void
init
(
void
)
{
register
char
*
p
;
make_argindex
=
0
;
while
(
make_argv
[
make_argindex
]
!=
NULL
)
make_argindex
++
;
cpp_argindex
=
0
;
while
(
cpp_argv
[
cpp_argindex
]
!=
NULL
)
cpp_argindex
++
;
#if defined CROSSCOMPILE
if
(
sys
==
netBSD
)
if
(
CrossCompiling
)
{
LogFatal
(
"fix imake to do crosscompiling for NetBSD
\n
"
,
""
);
}
else
#endif
#if defined(__NetBSD__) || defined CROSSCOMPILE
{
struct
utsname
uts
;
static
char
argument
[
512
];
/*
* Sharable imake configurations require a
* machine identifier.
*/
if
(
uname
(
&
uts
)
!=
0
)
LogFatal
(
"uname(3) failed; can't tell what %s"
,
"kind of machine you have."
);
memset
(
argument
,
0
,
sizeof
(
argument
));
(
void
)
snprintf
(
argument
,
sizeof
(
argument
)
-
1
,
"-D__%s__"
,
uts
.
machine
);
AddCppArg
(
argument
);
}
#endif
/* __NetBSD__ */
/*
* See if the standard include directory is different than
* the default. Or if cpp is not the default. Or if the make
* found by the PATH variable is not the default.
*/
if
((
p
=
getenv
(
"IMAKEINCLUDE"
)))
{
if
(
*
p
!=
'-'
||
*
(
p
+
1
)
!=
'I'
)
LogFatal
(
"Environment var IMAKEINCLUDE %s"
,
"must begin with -I"
);
AddCppArg
(
p
);
for
(;
*
p
;
p
++
)
if
(
*
p
==
' '
)
{
*
p
++
=
'\0'
;
AddCppArg
(
p
);
}
}
if
((
p
=
getenv
(
"IMAKECPP"
)))
cpp
=
p
;
if
((
p
=
getenv
(
"IMAKEMAKE"
)))
make_argv
[
0
]
=
p
;
if
(
signal
(
SIGINT
,
SIG_IGN
)
!=
SIG_IGN
)
signal
(
SIGINT
,
catch
);
#ifdef SIGCHLD
signal
(
SIGCHLD
,
SIG_DFL
);
#endif
}
void
AddMakeArg
(
const
char
*
arg
)
{
errno
=
0
;
if
(
make_argindex
>=
ARGUMENTS
-
1
)
LogFatal
(
"Out of internal storage."
);
make_argv
[
make_argindex
++
]
=
arg
;
make_argv
[
make_argindex
]
=
NULL
;
}
void
AddCppArg
(
const
char
*
arg
)
{
errno
=
0
;
if
(
cpp_argindex
>=
ARGUMENTS
-
1
)
LogFatal
(
"Out of internal storage."
);
cpp_argv
[
cpp_argindex
++
]
=
arg
;
cpp_argv
[
cpp_argindex
]
=
NULL
;
}
void
SetOpts
(
int
argc
,
char
**
argv
)
{
errno
=
0
;
/*
* Now gather the arguments for make
*/
for
(
argc
--
,
argv
++
;
argc
;
argc
--
,
argv
++
)
{
/*
* We intercept these flags.
*/
if
(
argv
[
0
][
0
]
==
'-'
)
{
if
(
argv
[
0
][
1
]
==
'D'
)
{
AddCppArg
(
argv
[
0
]);
}
else
if
(
argv
[
0
][
1
]
==
'I'
)
{
AddCppArg
(
argv
[
0
]);
}
else
if
(
argv
[
0
][
1
]
==
'U'
)
{
AddCppArg
(
argv
[
0
]);
}
else
if
(
argv
[
0
][
1
]
==
'W'
)
{
AddCppArg
(
argv
[
0
]);
}
else
if
(
argv
[
0
][
1
]
==
'f'
)
{
if
(
argv
[
0
][
2
])
Imakefile
=
argv
[
0
]
+
2
;
else
{
argc
--
,
argv
++
;
if
(
!
argc
)
LogFatal
(
"No description arg after -f flag"
);
Imakefile
=
argv
[
0
];
}
}
else
if
(
argv
[
0
][
1
]
==
's'
)
{
if
(
argv
[
0
][
2
])
Makefile
=
((
argv
[
0
][
2
]
==
'-'
)
&&
!
argv
[
0
][
3
])
?
NULL
:
argv
[
0
]
+
2
;
else
{
argc
--
,
argv
++
;
if
(
!
argc
)
LogFatal
(
"No description arg after -s flag"
);
Makefile
=
((
argv
[
0
][
0
]
==
'-'
)
&&
!
argv
[
0
][
1
])
?
NULL
:
argv
[
0
];
}
show
=
TRUE
;
}
else
if
(
argv
[
0
][
1
]
==
'e'
)
{
Makefile
=
(
argv
[
0
][
2
]
?
argv
[
0
]
+
2
:
NULL
);
show
=
FALSE
;
}
else
if
(
argv
[
0
][
1
]
==
'T'
)
{
if
(
argv
[
0
][
2
])
Template
=
argv
[
0
]
+
2
;
else
{
argc
--
,
argv
++
;
if
(
!
argc
)
LogFatal
(
"No description arg after -T flag"
);
Template
=
argv
[
0
];
}
}
else
if
(
argv
[
0
][
1
]
==
'C'
)
{
if
(
argv
[
0
][
2
])
ImakefileC
=
argv
[
0
]
+
2
;
else
{
argc
--
,
argv
++
;
if
(
!
argc
)
LogFatal
(
"No imakeCfile arg after -C flag"
);
ImakefileC
=
argv
[
0
];
}
}
else
if
(
argv
[
0
][
1
]
==
'v'
)
{
verbose
=
TRUE
;
}
else
AddMakeArg
(
argv
[
0
]);
}
else
AddMakeArg
(
argv
[
0
]);
}
#ifndef CROSSCOMPILE
# ifdef USE_CC_E
if
(
!
cpp
)
{
AddCppArg
(
"-E"
);
# ifdef __GNUC__
if
(
verbose
)
AddCppArg
(
"-v"
);
# endif
cpp
=
DEFAULT_CC
;
}
# else
if
(
!
cpp
)
cpp
=
DEFAULT_CPP
;
# endif
#else
if
(
!
cpp
)
cpp
=
CrossCompileCPP
();
#endif
cpp_argv
[
0
]
=
cpp
;
AddCppArg
(
ImakefileC
);
}
const
char
*
FindImakefile
(
const
char
*
Imakefile
)
{
if
(
Imakefile
)
{
if
(
access
(
Imakefile
,
R_OK
)
<
0
)
LogFatal
(
"Cannot find %s."
,
Imakefile
);
}
else
{
if
(
access
(
"Imakefile"
,
R_OK
)
<
0
)
{
if
(
access
(
"imakefile"
,
R_OK
)
<
0
)
LogFatal
(
"No description file."
);
else
Imakefile
=
"imakefile"
;
}
else
Imakefile
=
"Imakefile"
;
}
return
(
Imakefile
);
}
static
void
_X_ATTRIBUTE_PRINTF
(
1
,
0
)
vLogMsg
(
const
char
*
fmt
,
va_list
args
)
{
int
error_number
=
errno
;
if
(
error_number
)
{
fprintf
(
stderr
,
"%s: "
,
program
);
fprintf
(
stderr
,
"%s
\n
"
,
strerror
(
error_number
));
}
fprintf
(
stderr
,
"%s: "
,
program
);
vfprintf
(
stderr
,
fmt
,
args
);
fprintf
(
stderr
,
"
\n
"
);
}
void
LogFatal
(
const
char
*
fmt
,
...)
{
static
boolean
entered
=
FALSE
;
va_list
args
;
if
(
entered
)
return
;
entered
=
TRUE
;
va_start
(
args
,
fmt
);
vLogMsg
(
fmt
,
args
);
va_end
(
args
);
fprintf
(
stderr
,
" Stop.
\n
"
);
wrapup
();
exit
(
1
);
}
void
LogMsg
(
const
char
*
fmt
,
...)
{
va_list
args
;
va_start
(
args
,
fmt
);
vLogMsg
(
fmt
,
args
);
va_end
(
args
);
}
void
showargs
(
const
char
**
argv
)
{
for
(;
*
argv
;
argv
++
)
fprintf
(
stderr
,
"%s "
,
*
argv
);
fprintf
(
stderr
,
"
\n
"
);
}
#define ImakefileCHeader "
/* imake - temporary file */
"
void
CheckImakefileC
(
const
char
*
masterc
)
{
char
mkcbuf
[
1024
];
FILE
*
inFile
;
if
(
access
(
masterc
,
F_OK
)
==
0
)
{
inFile
=
fopen
(
masterc
,
"r"
);
if
(
inFile
==
NULL
)
LogFatal
(
"Refuse to overwrite: %s"
,
masterc
);
if
((
fgets
(
mkcbuf
,
sizeof
(
mkcbuf
),
inFile
)
&&
strncmp
(
mkcbuf
,
ImakefileCHeader
,
sizeof
(
ImakefileCHeader
)
-
1
)))
{
fclose
(
inFile
);
LogFatal
(
"Refuse to overwrite: %s"
,
masterc
);
}
else
fclose
(
inFile
);
}
}
#define LocalDefineFmt "#define %s \"%s\"\n"
#define IncludeFmt "#include %s\n"
#define ImakeDefSym "INCLUDE_IMAKEFILE"
#define ImakeTmplSym "IMAKE_TEMPLATE"
#define OverrideWarning "Warning: local file \"%s\" overrides global macros."
boolean
optional_include
(
FILE
*
inFile
,
const
char
*
defsym
,
const
char
*
fname
)
{
errno
=
0
;
if
(
access
(
fname
,
R_OK
)
==
0
)
{
LogMsg
(
OverrideWarning
,
fname
);
return
(
fprintf
(
inFile
,
LocalDefineFmt
,
defsym
,
fname
)
<
0
||
fprintf
(
inFile
,
IncludeFmt
,
defsym
)
<
0
);
}
return
FALSE
;
}
void
doit
(
FILE
*
outfd
,
const
char
*
cmd
,
const
char
**
argv
)
{
int
pid
;
waitType
status
;
/*
* Fork and exec the command.
*/
#ifdef WIN32
if
(
outfd
)
dup2
(
fileno
(
outfd
),
1
);
status
=
_spawnvp
(
_P_WAIT
,
cmd
,
argv
);
if
(
status
<
0
)
LogFatal
(
"Cannot spawn %s."
,
cmd
);
if
(
status
>
0
)
LogFatal
(
"Exit code %d."
,
status
);
#else
pid
=
fork
();
if
(
pid
<
0
)
LogFatal
(
"Cannot fork."
);
if
(
pid
)
{
/* parent... simply wait */
while
(
wait
(
&
status
)
>
0
)
{
errno
=
0
;
if
(
WIFSIGNALED
(
status
))
LogFatal
(
"Signal %d."
,
waitSig
(
status
));
if
(
WIFEXITED
(
status
)
&&
waitCode
(
status
))
LogFatal
(
"Exit code %d."
,
waitCode
(
status
));
}
}
else
{
/* child... dup and exec cmd */
if
(
verbose
)
showargs
(
argv
);
if
(
outfd
)
dup2
(
fileno
(
outfd
),
1
);
execvp
(
cmd
,
argv
);
LogFatal
(
"Cannot exec %s."
,
cmd
);
}
#endif
}
#if !defined WIN32
static
void
parse_utsname
(
struct
utsname
*
name
,
const
char
*
fmt
,
char
*
result
,
const
char
*
msg
)
{
char
buf
[
SYS_NMLN
*
5
+
1
];
char
*
ptr
=
buf
;
int
arg
;
if
(
!
name
)
LogFatal
(
msg
,
fmt
);
/* Assemble all the pieces into a buffer. */
for
(
arg
=
0
;
fmt
[
arg
]
!=
' '
;
arg
++
)
{
/* Our buffer is only guaranteed to hold 5 arguments. */
if
(
arg
>=
5
)
LogFatal
(
msg
,
fmt
);
switch
(
fmt
[
arg
])
{
case
's'
:
if
(
arg
>
0
)
*
ptr
++
=
' '
;
strcpy
(
ptr
,
name
->
sysname
);
ptr
+=
strlen
(
ptr
);
break
;
case
'n'
:
if
(
arg
>
0
)
*
ptr
++
=
' '
;
strcpy
(
ptr
,
name
->
nodename
);
ptr
+=
strlen
(
ptr
);
break
;
case
'r'
:
if
(
arg
>
0
)
*
ptr
++
=
' '
;
strcpy
(
ptr
,
name
->
release
);
ptr
+=
strlen
(
ptr
);
break
;
case
'v'
:
if
(
arg
>
0
)
*
ptr
++
=
' '
;
strcpy
(
ptr
,
name
->
version
);
ptr
+=
strlen
(
ptr
);
break
;
case
'm'
:
if
(
arg
>
0
)
*
ptr
++
=
' '
;
strcpy
(
ptr
,
name
->
machine
);
ptr
+=
strlen
(
ptr
);
break
;
default
:
LogFatal
(
msg
,
fmt
);
}
}
/* Just in case... */
if
(
strlen
(
buf
)
>=
sizeof
(
buf
))
LogFatal
(
"Buffer overflow parsing uname."
);
/* Parse the buffer. The sscanf() return value is rarely correct. */
*
result
=
'\0'
;
(
void
)
sscanf
(
buf
,
fmt
+
arg
+
1
,
result
);
}
/* Trim leading 0's and periods from version names. The 0's cause
the number to be interpreted as octal numbers. Some version strings
have the potential for different numbers of .'s in them.
*/
static
char
*
trim_version
(
char
*
p
)
{
if
(
p
!=
0
&&
*
p
!=
'\0'
)
{
while
((
*
p
==
'0'
||
*
p
==
'.'
)
&&
*
(
p
+
1
)
!=
'\0'
)
++
p
;
}
return
(
p
);
}
#endif
#if defined(linux) || defined(__GLIBC__)
const
char
*
libc_c
=
"#include <stdio.h>
\n
"
"#include <ctype.h>
\n
"
"
\n
"
"#if 1
\n
"
"#pragma weak gnu_get_libc_version
\n
"
"#pragma weak __libc_version
\n
"
"#pragma weak __linux_C_lib_version
\n
"
"#endif
\n
"
"
\n
"
"extern const char * gnu_get_libc_version (void);
\n
"
"extern const char * __linux_C_lib_version;
\n
"
"extern const char __libc_version [];
\n
"
"
\n
"
"int
\n
"
"main ()
\n
"
"{
\n
"
" int libcmajor = 0, libcminor = 0, libcteeny = 0;
\n
"
" const char * ptr = NULL;
\n
"
" int glibcmajor = 0;
\n
"
"
\n
"
" if (gnu_get_libc_version != 0)
\n
"
" {
\n
"
" ptr = gnu_get_libc_version ();
\n
"
" glibcmajor = 4;
\n
"
" }
\n
"
" else if (&__libc_version != 0)
\n
"
" {
\n
"
" ptr = __libc_version;
\n
"
" glibcmajor = 4;
\n
"
" }
\n
"
" else if (&__linux_C_lib_version != 0)
\n
"
" {
\n
"
" ptr = __linux_C_lib_version;
\n
"
" }
\n
"
" else
\n
"
" {
\n
"
" libcmajor = 0; libcminor = 0; libcteeny = 0;
\n
"
" }
\n
"
"
\n
"
" if (ptr)
\n
"
" {
\n
"
" while (!isdigit (*ptr))
\n
"
" ptr++;
\n
"
"
\n
"
" sscanf (ptr,
\"
%d.%d.%d
\"
, &libcmajor, &libcminor, &libcteeny);
\n
"
" libcmajor += glibcmajor;
\n
"
" }
\n
"
"
\n
"
" printf(
\"
#define DefaultLinuxCLibMajorVersion %d
\\
n
\"
, libcmajor);
\n
"
" printf(
\"
#define DefaultLinuxCLibMinorVersion %d
\\
n
\"
, libcminor);
\n
"
" printf(
\"
#define DefaultLinuxCLibTeenyVersion %d
\\
n
\"
, libcteeny);
\n
"
"
\n
"
" return 0;
\n
"
"}
\n
"
;
static
void
get_libc_version
(
FILE
*
inFile
)
{
char
aout
[
4096
],
*
tmpdir
;
FILE
*
fp
;
const
char
*
format
=
"%s -o %s -x c -"
;
char
*
cc
;
int
len
;
char
*
command
;
/* If $TMPDIR is defined and has an acceptable length,
* use that as tmp dir, else use /tmp. That fixes
* problems with /tmp mounted "noexec".
*/
if
((
tmpdir
=
getenv
(
"TMPDIR"
))
!=
NULL
&&
strlen
(
tmpdir
)
<
(
4096
-
13
))
strcpy
(
aout
,
tmpdir
);
else
strcpy
(
aout
,
"/tmp"
);
strcat
(
aout
,
"/imakeXXXXXX"
);
/* Pre-create temp file safely */
{
/* Linux + ELF has mkstemp() */
int
tmpfd
;
if
((
tmpfd
=
mkstemp
(
aout
))
==
-
1
)
{
perror
(
"mkstemp"
);
abort
();
}
close
(
tmpfd
);
}
cc
=
getenv
(
"CC"
);
if
(
cc
==
NULL
)
cc
=
"gcc"
;
len
=
strlen
(
aout
)
+
strlen
(
format
)
+
strlen
(
cc
);
if
(
len
<
128
)
len
=
128
;
if
((
command
=
alloca
(
len
))
==
NULL
)
abort
();
if
(
snprintf
(
command
,
len
,
format
,
cc
,
aout
)
==
len
)
abort
();
fp
=
popen
(
command
,
"w"
);
if
(
fp
==
NULL
||
fprintf
(
fp
,
"%s
\n
"
,
libc_c
)
<
0
||
pclose
(
fp
)
!=
0
)
abort
();
fp
=
popen
(
aout
,
"r"
);
if
(
fp
==
NULL
)
abort
();
while
(
fgets
(
command
,
len
,
fp
))
fputs
(
command
,
inFile
);
len
=
pclose
(
fp
);
remove
(
aout
);
if
(
len
)
{
/* handwave furiously */
printf
(
"#define DefaultLinuxCLibMajorVersion 6
\n
"
);
printf
(
"#define DefaultLinuxCLibMinorVersion 12
\n
"
);
printf
(
"#define DefaultLinuxCLibTeenyVersion 0
\n
"
);
}
}
#endif
#if defined(__OpenBSD__) || defined(__DragonFly__)
static
void
get_stackprotector
(
FILE
*
inFile
)
{
FILE
*
fp
;
char
*
cc
;
char
command
[
1024
],
buf
[
1024
];
cc
=
getenv
(
"CC"
);
if
(
cc
==
NULL
)
{
cc
=
"cc"
;
}
snprintf
(
command
,
sizeof
(
command
),
"%s -v 2>&1"
,
cc
);
fp
=
popen
(
command
,
"r"
);
if
(
fp
==
NULL
)
abort
();
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
))
{
if
(
strstr
(
buf
,
"propolice"
)
!=
NULL
)
{
fprintf
(
inFile
,
"#define ProPoliceSupport YES
\n
"
);
break
;
}
}
pclose
(
fp
);
}
#endif
#if defined CROSSCOMPILE || defined linux || defined(__GLIBC__)
static
void
get_distrib
(
FILE
*
inFile
)
{
struct
stat
sb
;
static
const
char
*
suse
=
"/etc/SuSE-release"
;
static
const
char
*
redhat
=
"/etc/redhat-release"
;
static
const
char
*
debian
=
"/etc/debian_version"
;
fprintf
(
inFile
,
"%s
\n
"
,
"#define LinuxUnknown 0"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define LinuxSuSE 1"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define LinuxCaldera 2"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define LinuxCraftworks 3"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define LinuxDebian 4"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define LinuxInfoMagic 5"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define LinuxKheops 6"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define LinuxPro 7"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define LinuxRedHat 8"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define LinuxSlackware 9"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define LinuxTurbo 10"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define LinuxWare 11"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define LinuxYggdrasil 12"
);
# ifdef CROSSCOMPILE
if
(
CrossCompiling
)
{
fprintf
(
inFile
,
"%s
\n
"
,
"#define DefaultLinuxDistribution LinuxUnknown"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define DefaultLinuxDistName Unknown"
);
return
;
}
# endif
if
(
lstat
(
suse
,
&
sb
)
==
0
)
{
fprintf
(
inFile
,
"%s
\n
"
,
"#define DefaultLinuxDistribution LinuxSuSE"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define DefaultLinuxDistName SuSE"
);
return
;
}
if
(
lstat
(
redhat
,
&
sb
)
==
0
)
{
fprintf
(
inFile
,
"%s
\n
"
,
"#define DefaultLinuxDistribution LinuxRedHat"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define DefaultLinuxDistName RedHat"
);
return
;
}
if
(
lstat
(
debian
,
&
sb
)
==
0
)
{
fprintf
(
inFile
,
"%s
\n
"
,
"#define DefaultLinuxDistribution LinuxDebian"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define DefaultLinuxDistName Debian"
);
/* You could also try to get the version of the Debian distrib by looking
* at the content of /etc/debian_version */
return
;
}
/* what's the definitive way to tell what any particular distribution is? */
fprintf
(
inFile
,
"%s
\n
"
,
"#define DefaultLinuxDistribution LinuxUnknown"
);
fprintf
(
inFile
,
"%s
\n
"
,
"#define DefaultLinuxDistName Unknown"
);
/* would like to know what version of the distribution it is */
}
static
void
get_ld_version
(
FILE
*
inFile
)
{
FILE
*
ldprog
;
signed
char
c
;
int
ldmajor
,
ldminor
;
const
char
*
ld
=
"ld -v"
;
# ifdef CROSSCOMPILE
if
(
CrossCompiling
)
{
char
cmd
[
PATH_MAX
];
strcpy
(
cmd
,
CrossCompileDir
);
strcat
(
cmd
,
"/"
);
strcat
(
cmd
,
ld
);
ldprog
=
popen
(
cmd
,
"r"
);
}
else
# endif
ldprog
=
popen
(
ld
,
"r"
);
if
(
ldprog
)
{
do
{
c
=
fgetc
(
ldprog
);
}
while
(
c
!=
EOF
&&
!
isdigit
(
c
));
ungetc
(
c
,
ldprog
);
(
void
)
fscanf
(
ldprog
,
"%d.%d"
,
&
ldmajor
,
&
ldminor
);
/* Start conversion to a more rational number */
if
((
ldmajor
>
2
)
||
((
ldmajor
==
2
)
&&
(
ldminor
>
9
)))
ldmajor
*=
100
;
else
ldmajor
*=
10
;
fprintf
(
inFile
,
"#define DefaultLinuxBinUtilsMajorVersion %d
\n
"
,
ldmajor
+
ldminor
);
pclose
(
ldprog
);
}
}
#endif
#if defined __FreeBSD__
static
void
get_binary_format
(
FILE
*
inFile
)
{
int
mib
[
2
];
size_t
len
;
int
osrel
=
0
;
FILE
*
objprog
=
NULL
;
int
iself
=
0
;
char
buf
[
10
];
char
cmd
[
PATH_MAX
];
mib
[
0
]
=
CTL_KERN
;
mib
[
1
]
=
KERN_OSRELDATE
;
len
=
sizeof
(
osrel
);
sysctl
(
mib
,
2
,
&
osrel
,
&
len
,
NULL
,
0
);
if
(
CrossCompiling
)
{
strcpy
(
cmd
,
CrossCompileDir
);
strcat
(
cmd
,
"/"
);
strcat
(
cmd
,
"objformat"
);
}
else
strcpy
(
cmd
,
"objformat"
);
if
(
osrel
>=
300004
&&
(
objprog
=
popen
(
cmd
,
"r"
))
!=
NULL
&&
fgets
(
buf
,
sizeof
(
buf
),
objprog
)
!=
NULL
&&
strncmp
(
buf
,
"elf"
,
3
)
==
0
)
iself
=
1
;
if
(
objprog
)
pclose
(
objprog
);
fprintf
(
inFile
,
"#define DefaultToElfFormat %s
\n
"
,
iself
?
"YES"
:
"NO"
);
}
#endif
#if defined(sun) && defined(__SVR4)
/* Runs Sun compiler command and parses output - this is a bit of a hack
* as it depends on the particular output format of the -V flag, but it's
* worked for many releases.
*
* Input : cmd - command to run (called with -V flag)
* path - path to command to run (use $PATH if NULL)
* Output: cmajor & cminor - major and minor versions if found
* Returns: 0 if successful, -1 if not.
*/
static
int
ask_sun_compiler_for_versions
(
const
char
*
cmd
,
const
char
*
path
,
int
*
cmajor
,
int
*
cminor
)
{
char
buf
[
BUFSIZ
];
char
cmdtorun
[
PATH_MAX
];
char
*
vptr
;
FILE
*
ccproc
;
const
char
vflag
[]
=
" -V 2>&1"
;
int
retval
=
-
1
;
int
len
=
strlen
(
cmd
)
+
sizeof
(
vflag
);
if
(
path
!=
NULL
)
{
len
+=
strlen
(
path
)
+
1
;
}
if
(
len
<
sizeof
(
cmdtorun
))
{
if
(
path
!=
NULL
)
{
sprintf
(
cmdtorun
,
"%s/%s %s"
,
path
,
cmd
,
vflag
);
}
else
{
sprintf
(
cmdtorun
,
"%s %s"
,
cmd
,
vflag
);
}
if
((
ccproc
=
popen
(
cmdtorun
,
"r"
))
!=
NULL
)
{
if
(
fgets
(
buf
,
sizeof
(
buf
),
ccproc
)
!=
NULL
)
{
vptr
=
strrchr
(
buf
,
'C'
);
if
(
vptr
)
{
for
(;
(
*
vptr
!=
'\0'
)
&&
!
isdigit
(
*
vptr
);
vptr
++
)
{
/* Do nothing - just scanning for first digit */
}
if
(
*
vptr
!=
'\0'
)
{
if
(
sscanf
(
vptr
,
"%d.%d"
,
cmajor
,
cminor
)
==
2
)
{
retval
=
0
;
}
}
}
if
(
retval
!=
0
)
{
fprintf
(
stderr
,
"warning: could not parse version number in output of:
\n
"
" %s
\n
"
,
cmdtorun
);
}
while
(
fgets
(
buf
,
sizeof
(
buf
),
ccproc
)
!=
NULL
)
{};
}
pclose
(
ccproc
);
}
}
return
retval
;
}
/* Find Sun compilers and their versions if present */
static
void
get_sun_compiler_versions
(
FILE
*
inFile
)
{
const
char
*
sunpro_path
=
"/opt/SUNWspro/bin"
;
int
cmajor
,
cminor
,
found
=
0
;
/* If cross-compiling, only check CrossCompilerDir for compilers.
* If not cross-compiling, first check cc in users $PATH,
* then try /opt/SUNWspro if not found in the users $PATH
*/
# if defined CROSSCOMPILE
if
(
CrossCompiling
)
{
if
(
ask_sun_compiler_for_versions
(
"cc"
,
CrossCompileDir
,
&
cmajor
,
&
cminor
)
==
0
)
{
found
=
1
;
}
}
else
# endif
{
if
(
ask_sun_compiler_for_versions
(
"cc"
,
NULL
,
&
cmajor
,
&
cminor
)
==
0
)
{
found
=
1
;
}
else
if
(
ask_sun_compiler_for_versions
(
"cc"
,
sunpro_path
,
&
cmajor
,
&
cminor
)
==
0
)
{
found
=
1
;
fprintf
(
inFile
,
"#define DefaultSunProCCompilerDir %s"
,
sunpro_path
);
}
}
if
(
found
)
{
fprintf
(
inFile
,
"#define DefaultSunProCCompilerMajorVersion %d
\n
"
,
cmajor
);
fprintf
(
inFile
,
"#define DefaultSunProCCompilerMinorVersion %d
\n
"
,
cminor
);
}
/* Now do it again for C++ compiler (CC) */
found
=
0
;
# if defined CROSSCOMPILE
if
(
CrossCompiling
)
{
if
(
ask_sun_compiler_for_versions
(
"CC"
,
CrossCompileDir
,
&
cmajor
,
&
cminor
)
==
0
)
{
found
=
1
;
}
}
else
# endif
{
if
(
ask_sun_compiler_for_versions
(
"CC"
,
NULL
,
&
cmajor
,
&
cminor
)
==
0
)
{
found
=
1
;
}
else
if
(
ask_sun_compiler_for_versions
(
"CC"
,
sunpro_path
,
&
cmajor
,
&
cminor
)
==
0
)
{
found
=
1
;
fprintf
(
inFile
,
"#define DefaultSunProCplusplusCompilerDir %s"
,
sunpro_path
);
}
}
if
(
found
)
{
fprintf
(
inFile
,
"#define DefaultSunProCplusplusCompilerMajorVersion %d
\n
"
,
cmajor
);
fprintf
(
inFile
,
"#define DefaultSunProCplusplusCompilerMinorVersion %d
\n
"
,
cminor
);
}
}
#endif
#if defined CROSSCOMPILE || defined __GNUC__
static
void
get_gcc_version
(
FILE
*
inFile
,
char
*
name
)
{
fprintf
(
inFile
,
"#define HasGcc 1
\n
"
);
# ifdef CROSSCOMPILE
if
(
CrossCompiling
)
{
if
(
gnu_c
>
1
)
{
fprintf
(
inFile
,
"#define HasGcc2 1
\n
"
);
if
(
gnu_c
>
2
)
fprintf
(
inFile
,
"#define HasGcc3 1
\n
"
);
}
fprintf
(
inFile
,
"#define GccMajorVersion %d
\n
"
,
gnu_c
);
fprintf
(
inFile
,
"#define GccMinorVersion %d
\n
"
,
gnu_c_minor
);
}
else
# endif
{
# if __GNUC__ > 1
fprintf
(
inFile
,
"#define HasGcc2 1
\n
"
);
# if __GNUC__ > 2
fprintf
(
inFile
,
"#define HasGcc3 1
\n
"
);
# endif
# endif
fprintf
(
inFile
,
"#define GccMajorVersion %d
\n
"
,
__GNUC__
);
fprintf
(
inFile
,
"#define GccMinorVersion %d
\n
"
,
__GNUC_MINOR__
);
}
# if defined(HAS_MERGE_CONSTANTS)
fprintf
(
inFile
,
"#define HasGccMergeConstants %d
\n
"
,
HAS_MERGE_CONSTANTS
);
# endif
}
#endif
static
boolean
get_gcc
(
char
*
cmd
)
{
struct
stat
sb
;
static
const
char
*
gcc_path
[]
=
{
#if defined(linux) || \
defined(__NetBSD__) || \
defined(__OpenBSD__) || \
defined(__FreeBSD__) || \
defined(__DragonFly__) || \
defined(__APPLE__) || \
defined(__CYGWIN__) || \
defined(__MINGW32__) || \
defined(__GNU__) || \
defined(__GLIBC__)
"/usr/bin/cc"
,
/* for Linux PostIncDir */
#endif
"/usr/local/bin/gcc"
,
"/opt/gnu/bin/gcc"
,
"/usr/pkg/bin/gcc"
};
#ifdef CROSSCOMPILE
static
const
char
*
cross_cc_name
[]
=
{
"cc"
,
"gcc"
};
if
(
CrossCompiling
)
{
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
cross_cc_name
)
/
sizeof
cross_cc_name
[
0
];
i
++
){
strcpy
(
cmd
,
CrossCompileDir
);
strcat
(
cmd
,
"/"
);
strcat
(
cmd
,
cross_cc_name
[
i
]);
if
(
lstat
(
cmd
,
&
sb
)
==
0
)
{
return
TRUE
;
break
;
}
}
}
else
#endif
{
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
gcc_path
)
/
sizeof
gcc_path
[
0
];
i
++
)
{
if
(
lstat
(
gcc_path
[
i
],
&
sb
)
==
0
)
{
strcpy
(
cmd
,
gcc_path
[
i
]);
return
TRUE
;
}
}
}
return
FALSE
;
}
#ifdef CROSSCOMPILE
static
void
get_gcc_incdir
(
FILE
*
inFile
,
char
*
name
)
{
FILE
*
gccproc
;
char
buf
[
PATH_MAX
];
char
cmd
[
PATH_MAX
];
char
*
ptr
;
strcpy
(
cmd
,
name
);
buf
[
0
]
=
'\0'
;
strcat
(
cmd
,
" --print-libgcc-file-name"
);
if
((
gccproc
=
popen
(
cmd
,
"r"
))
!=
NULL
)
{
if
(
fgets
(
buf
,
PATH_MAX
,
gccproc
)
!=
NULL
)
{
ptr
=
strstr
(
buf
,
"libgcc.a"
);
if
(
ptr
)
strcpy
(
ptr
,
"include"
);
}
(
void
)
pclose
(
gccproc
);
}
if
(
buf
[
0
])
fprintf
(
inFile
,
"#define DefaultGccIncludeDir
\"
%s
\"\n
"
,
buf
);
}
#endif
boolean
define_os_defaults
(
FILE
*
inFile
)
{
#if defined CROSSCOMPILE || !defined(WIN32)
# ifdef CROSSCOMPILE
# ifdef __GNUC__
if
(
1
)
# else
if
((
sys
!=
win32
)
&&
(
sys
!=
emx
))
# endif
# endif
{
# if (defined(DEFAULT_OS_NAME) || defined(DEFAULT_OS_MAJOR_REV) || \
defined(DEFAULT_OS_MINOR_REV) || defined(DEFAULT_OS_TEENY_REV))
struct
utsname
*
name
=
NULL
;
struct
utsname
uts_name
;
char
buf
[
SYS_NMLN
*
5
+
1
];
/* Obtain the system information. */
# ifdef CROSSCOMPILE
if
(
!
CrossCompiling
)
# endif
{
if
(
uname
(
&
uts_name
)
<
0
)
LogFatal
(
"Cannot invoke uname"
);
else
name
=
&
uts_name
;
}
# if defined CROSSCOMPILE && (defined linux || defined(__GLIBC__))
else
{
strncpy
(
uts_name
.
sysname
,
cross_uts_sysname
,
SYS_NMLN
);
strncpy
(
uts_name
.
release
,
cross_uts_release
,
SYS_NMLN
);
strncpy
(
uts_name
.
version
,
cross_uts_version
,
SYS_NMLN
);
strncpy
(
uts_name
.
machine
,
cross_uts_machine
,
SYS_NMLN
);
name
=
&
uts_name
;
}
# endif
# ifdef __FreeBSD__
/* Override for compiling in chroot of other OS version, such as
* in the bento build cluster.
*/
{
char
*
e
;
if
((
e
=
getenv
(
"OSREL"
))
!=
NULL
&&
strlen
(
name
->
sysname
)
+
strlen
(
e
)
+
1
<
SYS_NMLN
)
{
strcpy
(
name
->
release
,
e
);
strcpy
(
name
->
version
,
name
->
sysname
);
strcat
(
name
->
version
,
" "
);
strcat
(
name
->
version
,
e
);
}
}
# endif
# if defined DEFAULT_OS_NAME
# if defined CROSSCOMPILE
if
(
!
CrossCompiling
)
# endif
{
parse_utsname
(
name
,
DEFAULT_OS_NAME
,
buf
,
"Bad DEFAULT_OS_NAME syntax %s"
);
# ifdef DEFAULT_OS_NAME_FROB
DEFAULT_OS_NAME_FROB
(
buf
,
sizeof
buf
);
# endif
if
(
buf
[
0
]
!=
'\0'
)
fprintf
(
inFile
,
"#define DefaultOSName %s
\n
"
,
buf
);
}
# endif
# if defined CROSSCOMPILE
if
(
CrossCompiling
&&
defaultOsName
)
{
parse_utsname
(
name
,
defaultOsName
,
buf
,
"Bad DEFAULT_OS_NAME syntax %s"
);
if
(
defaultOsNameFrob
)
defaultOsNameFrob
(
buf
,
sizeof
buf
);
if
(
buf
[
0
]
!=
'\0'
)
fprintf
(
inFile
,
"#define DefaultOSName %s
\n
"
,
buf
);
}
# endif
# ifdef DEFAULT_OS_MAJOR_REV
# if defined CROSSCOMPILE
if
(
!
CrossCompiling
)
# endif
{
parse_utsname
(
name
,
DEFAULT_OS_MAJOR_REV
,
buf
,
"Bad DEFAULT_OS_MAJOR_REV syntax %s"
);
# ifdef DEFAULT_OS_MAJOR_REV_FROB
DEFAULT_OS_MAJOR_REV_FROB
(
buf
,
sizeof
buf
);
# endif
fprintf
(
inFile
,
"#define DefaultOSMajorVersion %s
\n
"
,
*
buf
?
trim_version
(
buf
)
:
"0"
);
}
# endif
# if defined CROSSCOMPILE
if
(
CrossCompiling
&&
defaultOsMajorRev
)
{
parse_utsname
(
name
,
defaultOsMajorRev
,
buf
,
"Bad defaultOsMajorRev syntax %s"
);
if
(
defaultOsMajorRevFrob
)
defaultOsMajorRevFrob
(
buf
,
sizeof
buf
);
fprintf
(
inFile
,
"#define DefaultOSMajorVersion %s
\n
"
,
*
buf
?
trim_version
(
buf
)
:
"0"
);
}
# endif
# ifdef DEFAULT_OS_MINOR_REV
# if defined CROSSCOMPILE
if
(
!
CrossCompiling
)
# endif
{
parse_utsname
(
name
,
DEFAULT_OS_MINOR_REV
,
buf
,
"Bad DEFAULT_OS_MINOR_REV syntax %s"
);
# ifdef DEFAULT_OS_MINOR_REV_FROB
DEFAULT_OS_MINOR_REV_FROB
(
buf
,
sizeof
buf
);
# endif
fprintf
(
inFile
,
"#define DefaultOSMinorVersion %s
\n
"
,
*
buf
?
trim_version
(
buf
)
:
"0"
);
}
# endif
# if defined CROSSCOMPILE
if
(
CrossCompiling
&&
defaultOsMinorRev
)
{
parse_utsname
(
name
,
defaultOsMinorRev
,
buf
,
"Bad defaultOsMinorRev syntax %s"
);
if
(
defaultOsMinorRevFrob
)
defaultOsMinorRevFrob
(
buf
,
sizeof
buf
);
fprintf
(
inFile
,
"#define DefaultOSMinorVersion %s
\n
"
,
*
buf
?
trim_version
(
buf
)
:
"0"
);
}
# endif
# ifdef DEFAULT_OS_TEENY_REV
# if defined CROSSCOMPILE
if
(
!
CrossCompiling
)
# endif
{
parse_utsname
(
name
,
DEFAULT_OS_TEENY_REV
,
buf
,
"Bad DEFAULT_OS_TEENY_REV syntax %s"
);
# ifdef DEFAULT_OS_TEENY_REV_FROB
DEFAULT_OS_TEENY_REV_FROB
(
buf
,
sizeof
buf
);
# endif
fprintf
(
inFile
,
"#define DefaultOSTeenyVersion %s
\n
"
,
*
buf
?
trim_version
(
buf
)
:
"0"
);
}
# endif
# if defined CROSSCOMPILE
if
(
CrossCompiling
&&
defaultOsTeenyRev
)
{
parse_utsname
(
name
,
defaultOsTeenyRev
,
buf
,
"Bad defaultOsTeenyRev syntax %s"
);
if
(
defaultOsTeenyRevFrob
)
defaultOsTeenyRevFrob
(
buf
,
sizeof
buf
);
fprintf
(
inFile
,
"#define DefaultOSTeenyVersion %s
\n
"
,
*
buf
?
trim_version
(
buf
)
:
"0"
);
}
# endif
# ifdef DEFAULT_MACHINE_ARCHITECTURE
# if defined CROSSCOMPILE
if
(
!
CrossCompiling
)
# endif
{
parse_utsname
(
name
,
DEFAULT_MACHINE_ARCHITECTURE
,
buf
,
"Bad DEFAULT_MACHINE_ARCHITECTURE %s"
);
fprintf
(
inFile
,
"#ifndef %s
\n
# define %s
\n
#endif
\n
"
,
buf
,
buf
);
}
# endif
# if defined CROSSCOMPILE
if
(
CrossCompiling
&&
defaultMachineArchitecture
)
{
parse_utsname
(
name
,
defaultMachineArchitecture
,
buf
,
"Bad defaultMachineArchitecture syntax %s"
);
fprintf
(
inFile
,
"#ifndef %s
\n
# define %s
\n
#endif
\n
"
,
buf
,
buf
);
}
# endif
# endif
# if defined CROSSCOMPILE
if
(
CrossCompiling
)
get_cross_compile_dir
(
inFile
);
else
# endif
fprintf
(
inFile
,
"#define CrossCompiling NO
\n
"
);
# if defined CROSSCOMPILE
if
(
CrossCompiling
&&
sys
==
LinuX
)
# endif
# if defined CROSSCOMPILE || defined linux || defined(__GLIBC__)
# if defined(CROSSCOMPILE) && defined(__linux__)
if
(
sys
==
LinuX
)
# endif
get_distrib
(
inFile
);
# endif
# if defined linux || defined(__GLIBC__)
# if defined CROSSCOMPILE
if
(
!
CrossCompiling
)
# endif
get_libc_version
(
inFile
);
# if defined CROSSCOMPILE
else
{
fprintf
(
inFile
,
"#define DefaultLinuxCLibMajorVersion %d
\n
"
,
glibc_major
);
fprintf
(
inFile
,
"#define DefaultLinuxCLibMinorVersion %d
\n
"
,
glibc_minor
);
fprintf
(
inFile
,
"#define DefaultLinuxCLibTeenyVersion 0
\n
"
);
}
# endif
# endif
/* linux || __GLIBC__ */
# if defined CROSSCOMPILE || defined linux || defined(__GLIBC__)
# if defined CROSSCOMPILE && defined(__linux__)
if
(
sys
==
LinuX
)
# endif
get_ld_version
(
inFile
);
# endif
# if defined (sun) && defined(SVR4)
get_sun_compiler_versions
(
inFile
);
# endif
# if defined CROSSCOMPILE || defined __GNUC__
# if defined CROSSCOMPILE
if
(
gnu_c
)
# endif
{
char
name
[
PATH_MAX
];
if
(
get_gcc
(
name
))
{
get_gcc_version
(
inFile
,
name
);
# if defined CROSSCOMPILE
if
(
sys
!=
emx
)
get_gcc_incdir
(
inFile
,
name
);
# endif
}
}
# endif
# if defined __FreeBSD__
# if defined CROSSCOMPILE
if
(
sys
==
freeBSD
)
# endif
get_binary_format
(
inFile
);
# endif
}
#endif
/* !WIN32 */
#if defined WIN32
# ifdef CROSSCOMPILE
else
if
(
sys
==
win32
&&
!
CrossCompiling
)
# endif
{
OSVERSIONINFO
osvi
;
static
char
*
os_names
[]
=
{
"Win32s"
,
"Windows 95"
,
"Windows NT"
};
memset
(
&
osvi
,
0
,
sizeof
(
OSVERSIONINFO
));
osvi
.
dwOSVersionInfoSize
=
sizeof
(
OSVERSIONINFO
);
GetVersionEx
(
&
osvi
);
fprintf
(
inFile
,
"#define DefaultOSName Microsoft %s
\n
"
,
os_names
[
osvi
.
dwPlatformId
]);
fprintf
(
inFile
,
"#define DefaultOSMajorVersion %d
\n
"
,
osvi
.
dwMajorVersion
);
fprintf
(
inFile
,
"#define DefaultOSMinorVersion %d
\n
"
,
osvi
.
dwMinorVersion
);
fprintf
(
inFile
,
"#define DefaultOSTeenyVersion %d
\n
"
,
osvi
.
dwBuildNumber
&
0xFFFF
);
}
#endif
/* WIN32 */
#ifdef CROSSCOMPILE
else
if
(
sys
==
emx
)
{
fprintf
(
inFile
,
"#define DefaultOSMajorVersion 4
\n
"
);
fprintf
(
inFile
,
"#define DefaultOSMinorVersion 0
\n
"
);
fprintf
(
inFile
,
"#define DefaultOSTeenyVersion 0
\n
"
);
}
#endif
/* EMX */
#if defined(__OpenBSD__) || defined(__DragonFly__)
get_stackprotector
(
inFile
);
#endif
return
FALSE
;
}
void
cppit
(
const
char
*
imakefile
,
const
char
*
template
,
const
char
*
masterc
,
FILE
*
outfd
,
const
char
*
outfname
)
{
FILE
*
inFile
;
haveImakefileC
=
TRUE
;
inFile
=
fopen
(
masterc
,
"w"
);
if
(
inFile
==
NULL
)
LogFatal
(
"Cannot open %s for output."
,
masterc
);
if
(
fprintf
(
inFile
,
"%s
\n
"
,
ImakefileCHeader
)
<
0
||
define_os_defaults
(
inFile
)
||
optional_include
(
inFile
,
"IMAKE_LOCAL_DEFINES"
,
"localdefines"
)
||
optional_include
(
inFile
,
"IMAKE_ADMIN_DEFINES"
,
"admindefines"
)
||
fprintf
(
inFile
,
"#define %s <%s>
\n
"
,
ImakeDefSym
,
imakefile
)
<
0
||
fprintf
(
inFile
,
LocalDefineFmt
,
ImakeTmplSym
,
template
)
<
0
||
fprintf
(
inFile
,
IncludeFmt
,
ImakeTmplSym
)
<
0
||
optional_include
(
inFile
,
"IMAKE_ADMIN_MACROS"
,
"adminmacros"
)
||
optional_include
(
inFile
,
"IMAKE_LOCAL_MACROS"
,
"localmacros"
)
||
fflush
(
inFile
))
{
fclose
(
inFile
);
LogFatal
(
"Cannot write to %s."
,
masterc
);
}
else
if
(
fclose
(
inFile
))
LogFatal
(
"Cannot write to %s."
,
masterc
);
/*
* Fork and exec cpp
*/
doit
(
outfd
,
cpp
,
cpp_argv
);
CleanCppOutput
(
outfd
,
outfname
);
}
void
makeit
(
void
)
{
doit
(
NULL
,
make_argv
[
0
],
make_argv
);
}
const
char
*
CleanCppInput
(
const
char
*
imakefile
)
{
FILE
*
outFile
=
NULL
;
FILE
*
inFile
;
char
*
buf
,
/* buffer for file content */
*
pbuf
,
/* walking pointer to buf */
*
punwritten
,
/* pointer to unwritten portion of buf */
*
ptoken
,
/* pointer to # token */
*
pend
,
/* pointer to end of # token */
savec
;
/* temporary character holder */
int
count
;
struct
stat
st
;
/*
* grab the entire file.
*/
if
(
!
(
inFile
=
fopen
(
imakefile
,
"r"
)))
LogFatal
(
"Cannot open %s for input."
,
imakefile
);
if
(
fstat
(
fileno
(
inFile
),
&
st
)
<
0
)
LogFatal
(
"Cannot stat %s for size."
,
imakefile
);
buf
=
Emalloc
((
int
)
st
.
st_size
+
3
);
count
=
fread
(
buf
+
2
,
1
,
st
.
st_size
,
inFile
);
if
(
count
==
0
&&
st
.
st_size
!=
0
)
LogFatal
(
"Cannot read %s:"
,
imakefile
);
fclose
(
inFile
);
buf
[
0
]
=
'\n'
;
buf
[
1
]
=
'\n'
;
buf
[
count
+
2
]
=
'\0'
;
punwritten
=
pbuf
=
buf
+
2
;
while
(
*
pbuf
)
{
/* for compatibility, replace make comments for cpp */
if
(
*
pbuf
==
'#'
&&
pbuf
[
-
1
]
==
'\n'
&&
pbuf
[
-
2
]
!=
'\\'
)
{
ptoken
=
pbuf
+
1
;
while
(
*
ptoken
==
' '
||
*
ptoken
==
'\t'
)
ptoken
++
;
pend
=
ptoken
;
while
(
*
pend
&&
*
pend
!=
' '
&&
*
pend
!=
'\t'
&&
*
pend
!=
'\n'
&&
*
pend
!=
'\r'
)
pend
++
;
savec
=
*
pend
;
*
pend
=
'\0'
;
if
(
strcmp
(
ptoken
,
"define"
)
&&
strcmp
(
ptoken
,
"if"
)
&&
strcmp
(
ptoken
,
"ifdef"
)
&&
strcmp
(
ptoken
,
"ifndef"
)
&&
strcmp
(
ptoken
,
"include"
)
&&
strcmp
(
ptoken
,
"line"
)
&&
strcmp
(
ptoken
,
"else"
)
&&
strcmp
(
ptoken
,
"elif"
)
&&
strcmp
(
ptoken
,
"endif"
)
&&
strcmp
(
ptoken
,
"error"
)
&&
strcmp
(
ptoken
,
"pragma"
)
&&
strcmp
(
ptoken
,
"undef"
))
{
if
(
outFile
==
NULL
)
{
#ifdef HAVE_MKSTEMP
int
fd
;
#endif
char
*
tmpImakefileName
=
Strdup
(
tmpImakefileTemplate
);
#ifndef HAVE_MKSTEMP
if
(
mktemp
(
tmpImakefileName
)
==
NULL
||
(
outFile
=
fopen
(
tmpImakefileName
,
"w+"
))
==
NULL
)
{
LogFatal
(
"Cannot open %s for write."
,
tmpImakefileName
);
}
#else
fd
=
mkstemp
(
tmpImakefileName
);
if
(
fd
!=
-
1
)
outFile
=
fdopen
(
fd
,
"w"
);
if
(
outFile
==
NULL
)
{
if
(
fd
!=
-
1
)
{
unlink
(
tmpImakefileName
);
close
(
fd
);
}
LogFatal
(
"Cannot open %s for write."
,
tmpImakefileName
);
}
#endif
tmpImakefile
=
tmpImakefileName
;
}
writetmpfile
(
outFile
,
punwritten
,
pbuf
-
punwritten
,
tmpImakefile
);
if
(
ptoken
>
pbuf
+
1
)
writetmpfile
(
outFile
,
"XCOMM"
,
5
,
tmpImakefile
);
else
writetmpfile
(
outFile
,
"XCOMM "
,
6
,
tmpImakefile
);
punwritten
=
pbuf
+
1
;
}
*
pend
=
savec
;
}
pbuf
++
;
}
if
(
outFile
)
{
writetmpfile
(
outFile
,
punwritten
,
pbuf
-
punwritten
,
tmpImakefile
);
fclose
(
outFile
);
return
tmpImakefile
;
}
return
(
imakefile
);
}
void
CleanCppOutput
(
FILE
*
tmpfd
,
const
char
*
tmpfname
)
{
char
*
input
;
int
blankline
=
0
;
while
((
input
=
ReadLine
(
tmpfd
,
tmpfname
)))
{
if
(
isempty
(
input
))
{
if
(
blankline
++
)
continue
;
#ifdef CROSSCOMPILE
if
(
fixup_whitespace
)
#endif
#if defined CROSSCOMPILE || defined FIXUP_CPP_WHITESPACE
KludgeResetRule
();
#endif
}
else
{
blankline
=
0
;
#ifdef CROSSCOMPILE
if
(
fixup_whitespace
)
#endif
#if defined CROSSCOMPILE || defined FIXUP_CPP_WHITESPACE
KludgeOutputLine
(
&
input
);
#endif
writetmpfile
(
tmpfd
,
input
,
strlen
(
input
),
tmpfname
);
}
writetmpfile
(
tmpfd
,
"
\n
"
,
1
,
tmpfname
);
}
fflush
(
tmpfd
);
#ifdef NFS_STDOUT_BUG
/*
* On some systems, NFS seems to leave a large number of nulls at
* the end of the file. Ralph Swick says that this kludge makes the
* problem go away.
*/
ftruncate
(
fileno
(
tmpfd
),
(
off_t
)
ftell
(
tmpfd
));
#endif
}
/*
* Determine if a line has nothing in it. As a side effect, we trim white
* space from the end of the line. Cpp magic cookies are also thrown away.
* "XCOMM" token is transformed to "#".
*/
boolean
isempty
(
char
*
line
)
{
char
*
pend
;
/*
* Check for lines of the form
* # n "...
* or
* # line n "...
*/
if
(
*
line
==
'#'
)
{
pend
=
line
+
1
;
if
(
*
pend
==
' '
)
pend
++
;
if
(
*
pend
==
'l'
&&
pend
[
1
]
==
'i'
&&
pend
[
2
]
==
'n'
&&
pend
[
3
]
==
'e'
&&
pend
[
4
]
==
' '
)
pend
+=
5
;
if
(
isdigit
(
*
pend
))
{
do
{
pend
++
;
}
while
(
isdigit
(
*
pend
));
if
(
*
pend
==
'\n'
||
*
pend
==
'\0'
)
return
(
TRUE
);
if
(
*
pend
++
==
' '
&&
*
pend
==
'"'
)
return
(
TRUE
);
}
while
(
*
pend
)
pend
++
;
}
else
{
for
(
pend
=
line
;
*
pend
;
pend
++
)
{
if
(
*
pend
==
'X'
&&
pend
[
1
]
==
'C'
&&
pend
[
2
]
==
'O'
&&
pend
[
3
]
==
'M'
&&
pend
[
4
]
==
'M'
&&
(
pend
==
line
||
pend
[
-
1
]
==
' '
||
pend
[
-
1
]
==
'\t'
||
pend
[
-
1
]
==
'\r'
)
&&
(
pend
[
5
]
==
' '
||
pend
[
5
]
==
'\t'
||
pend
[
5
]
==
'\r'
||
pend
[
5
]
==
'\0'
))
{
*
pend
=
'#'
;
memmove
(
pend
+
1
,
pend
+
5
,
strlen
(
pend
+
5
)
+
1
);
}
#ifdef CROSSCOMPILE
if
(
magic_make_vars
)
#endif
{
#if defined CROSSCOMPILE || defined MAGIC_MAKE_VARS
if
(
*
pend
==
'X'
&&
pend
[
1
]
==
'V'
&&
pend
[
2
]
==
'A'
&&
pend
[
3
]
==
'R'
)
{
char
varbuf
[
5
];
int
i
;
if
(
pend
[
4
]
==
'd'
&&
pend
[
5
]
==
'e'
&&
pend
[
6
]
==
'f'
&&
pend
[
7
]
>=
'0'
&&
pend
[
7
]
<=
'9'
)
{
i
=
pend
[
7
]
-
'0'
;
sprintf
(
varbuf
,
"%0.4d"
,
xvariable
);
strncpy
(
pend
+
4
,
varbuf
,
4
);
xvariables
[
i
]
=
xvariable
;
xvariable
=
(
xvariable
+
1
)
%
10000
;
}
else
if
(
pend
[
4
]
==
'u'
&&
pend
[
5
]
==
's'
&&
pend
[
6
]
==
'e'
&&
pend
[
7
]
>=
'0'
&&
pend
[
7
]
<=
'9'
)
{
i
=
pend
[
7
]
-
'0'
;
sprintf
(
varbuf
,
"%0.4d"
,
xvariables
[
i
]);
strncpy
(
pend
+
4
,
varbuf
,
4
);
}
}
#endif
}
}
}
while
(
--
pend
>=
line
&&
(
*
pend
==
' '
||
*
pend
==
'\t'
||
*
pend
==
'\r'
))
;
pend
[
1
]
=
'\0'
;
return
(
*
line
==
'\0'
);
}
/*ARGSUSED*/
char
*
ReadLine
(
FILE
*
tmpfd
,
const
char
*
tmpfname
)
{
static
boolean
initialized
=
FALSE
;
static
char
*
buf
,
*
pline
,
*
end
;
register
char
*
p1
,
*
p2
;
if
(
!
initialized
)
{
#ifdef WIN32
FILE
*
fp
=
tmpfd
;
#endif
int
total_red
;
struct
stat
st
;
/*
* Slurp it all up.
*/
fseek
(
tmpfd
,
0
,
0
);
if
(
fstat
(
fileno
(
tmpfd
),
&
st
)
<
0
)
LogFatal
(
"cannot stat %s for size"
,
tmpMakefile
);
pline
=
buf
=
Emalloc
((
int
)
st
.
st_size
+
1
);
total_red
=
fread
(
buf
,
1
,
st
.
st_size
,
tmpfd
);
if
(
total_red
==
0
&&
st
.
st_size
!=
0
)
LogFatal
(
"cannot read %s"
,
tmpMakefile
);
end
=
buf
+
total_red
;
*
end
=
'\0'
;
fseek
(
tmpfd
,
0
,
0
);
#if defined(SYSV) || defined(WIN32) || defined(USE_FREOPEN)
tmpfd
=
freopen
(
tmpfname
,
"w+"
,
tmpfd
);
# ifdef WIN32
if
(
!
tmpfd
)
/* if failed try again */
tmpfd
=
freopen
(
tmpfname
,
"w+"
,
fp
);
# endif
if
(
!
tmpfd
)
LogFatal
(
"cannot reopen %s
\n
"
,
tmpfname
);
#else
/* !SYSV */
ftruncate
(
fileno
(
tmpfd
),
(
off_t
)
0
);
#endif
/* !SYSV */
initialized
=
TRUE
;
fprintf
(
tmpfd
,
"# Makefile generated by imake - do not edit!
\n
"
);
}
for
(
p1
=
pline
;
p1
<
end
;
p1
++
)
{
if
(
*
p1
==
'@'
&&
*
(
p1
+
1
)
==
'@'
/* ignore ClearCase version-extended pathnames */
&&
!
(
p1
!=
pline
&&
!
isspace
(
*
(
p1
-
1
))
&&
*
(
p1
+
2
)
==
'/'
))
{
/* soft EOL */
*
p1
++
=
'\0'
;
p1
++
;
/* skip over second @ */
break
;
}
else
if
(
*
p1
==
'\n'
)
{
/* real EOL */
#if defined CROSSCOMPILE || defined WIN32
# if defined CROSSCOMPILE
if
(
sys
==
win32
)
# endif
{
if
(
p1
>
pline
&&
p1
[
-
1
]
==
'\r'
)
p1
[
-
1
]
=
'\0'
;
}
#endif
*
p1
++
=
'\0'
;
break
;
}
}
/*
* return NULL at the end of the file.
*/
p2
=
(
pline
==
p1
?
NULL
:
pline
);
pline
=
p1
;
return
(
p2
);
}
void
writetmpfile
(
FILE
*
fd
,
const
char
*
buf
,
int
cnt
,
const
char
*
fname
)
{
if
(
fwrite
(
buf
,
sizeof
(
char
),
cnt
,
fd
)
==
-
1
)
LogFatal
(
"Cannot write to %s."
,
fname
);
}
char
*
Emalloc
(
int
size
)
{
char
*
p
;
if
((
p
=
malloc
(
size
))
==
NULL
)
LogFatal
(
"Cannot allocate %d bytes"
,
size
);
return
(
p
);
}
#if defined CROSSCOMPILE || defined FIXUP_CPP_WHITESPACE
void
KludgeOutputLine
(
char
**
pline
)
{
char
*
p
=
*
pline
;
char
quotechar
=
'\0'
;
switch
(
*
p
)
{
case
'#'
:
/*Comment - ignore*/
break
;
case
'\t'
:
/*Already tabbed - ignore it*/
break
;
case
' '
:
/*May need a tab*/
default:
# ifdef CROSSCOMPILE
if
(
inline_syntax
)
# endif
# if defined CROSSCOMPILE || defined INLINE_SYNTAX
{
if
(
*
p
==
'<'
&&
p
[
1
]
==
'<'
)
{
/* inline file close */
InInline
--
;
InRule
=
TRUE
;
break
;
}
}
# endif
/*
* The following cases should not be treated as beginning of
* rules:
* variable := name (GNU make)
* variable = .*:.* (':' should be allowed as value)
* sed 's:/a:/b:' (: used in quoted values)
*/
for
(;
*
p
;
p
++
)
{
if
(
quotechar
)
{
if
(
quotechar
==
'\\'
||
(
*
p
==
quotechar
&&
# if defined CROSSCOMPILE || defined WIN32
(
# if defined CROSSCOMPILE
(
sys
==
win32
)
&&
# endif
quotechar
!=
')'
)
&&
# endif
p
[
-
1
]
!=
'\\'
))
quotechar
=
'\0'
;
continue
;
}
switch
(
*
p
)
{
case
'\\'
:
case
'"'
:
case
'\''
:
quotechar
=
*
p
;
break
;
case
'('
:
quotechar
=
')'
;
break
;
case
'{'
:
quotechar
=
'}'
;
break
;
case
'['
:
quotechar
=
']'
;
break
;
case
'='
:
# ifdef CROSSCOMPILE
if
(
remove_cpp_leadspace
)
# endif
# if defined CROSSCOMPILE || defined REMOVE_CPP_LEADSPACE
{
if
(
!
InRule
&&
**
pline
==
' '
)
{
while
(
**
pline
==
' '
)
(
*
pline
)
++
;
}
}
# endif
goto
breakfor
;
# if defined CROSSCOMPILE || defined INLINE_SYNTAX
case
'<'
:
if
(
inline_syntax
)
{
if
(
p
[
1
]
==
'<'
)
/* inline file start */
InInline
++
;
}
break
;
# endif
case
':'
:
if
(
p
[
1
]
==
'='
)
goto
breakfor
;
while
(
**
pline
==
' '
)
(
*
pline
)
++
;
InRule
=
TRUE
;
return
;
}
}
breakfor:
if
(
InRule
&&
**
pline
==
' '
)
**
pline
=
'\t'
;
break
;
}
}
void
KludgeResetRule
(
void
)
{
InRule
=
FALSE
;
}
#endif
char
*
Strdup
(
const
char
*
cp
)
{
char
*
new
=
Emalloc
(
strlen
(
cp
)
+
1
);
strcpy
(
new
,
cp
);
return
new
;
}
#ifdef CROSSCOMPILE
char
*
CrossCompileCPP
(
void
)
{
char
*
cpp
,
*
c
;
int
len
;
if
(
crosscompile_use_cc_e
)
AddCppArg
(
"-E"
);
cpp
=
strrchr
(
crosscompile_cpp
,
'/'
);
if
(
!
cpp
)
cpp
=
crosscompile_cpp
;
else
cpp
++
;
len
=
strlen
(
cpp
)
+
strlen
(
CrossCompileDir
)
+
2
;
c
=
Emalloc
(
len
);
(
void
)
snprintf
(
c
,
len
,
"%s/%s"
,
CrossCompileDir
,
cpp
);
return
c
;
}
#endif
#ifdef CROSSCOMPILE
static
void
get_cross_compile_dir
(
FILE
*
inFile
)
{
fprintf
(
inFile
,
"#define CrossCompileDir %s
\n
"
,
CrossCompileDir
);
fprintf
(
inFile
,
"#define CrossCompiling YES
\n
"
);
}
#endif
nx-X11/config/imake/imake.man
deleted
100644 → 0
View file @
5b36f644
.\" $Xorg: imake.man,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $
.\" Copyright (c) 1993, 1994, 1998 The Open Group
.\"
.\" Permission to use, copy, modify, distribute, and sell this software and its
.\" documentation for any purpose is hereby granted without fee, provided that
.\" the above copyright notice appear in all copies and that both that
.\" copyright notice and this permission notice appear in supporting
.\" documentation.
.\"
.\" The above copyright notice and this permission notice shall be included
.\" in all copies or substantial portions of the Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
.\" OTHER DEALINGS IN THE SOFTWARE.
.\"
.\" Except as contained in this notice, the name of The Open Group shall
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from The Open Group.
.\"
.\" $XFree86: imake.man,v 1.8 2001/12/14 19:53:19 dawes Exp $
.\"
.TH IMAKE 1 __xorgversion__
.SH NAME
imake \- C preprocessor interface to the make utility
.SH SYNOPSIS
\fBimake\fP [ \fB\-D\fP\fIdefine\fP ] [ \fB\-I\fP\fIdir\fP ]
[ \fB\-U\fP\fIdefine\fP ]
[ \fB\-T\fP\fItemplate\fP ]
[ \fB\-f\fP \fIfilename\fP ] [ \fB\-C\fP \fIfilename\fP ]
[ \fB\-s\fP \fIfilename\fP ] [ \fB\-e\fP ]
[ \fB\-v\fP ]
.SH DESCRIPTION
.I Imake
is used to
generate \fIMakefiles\fP from a template, a set of \fIcpp\fP macro functions,
and a per-directory input file called an \fIImakefile\fP. This allows machine
dependencies (such as compiler options, alternate command names, and special
\fImake\fP rules) to be kept separate from the descriptions of the
various items to be built.
.SH OPTIONS
The following command line options may be passed to \fIimake\fP:
.TP 8
.B \-D\fIdefine\fP
This option is passed directly to \fIcpp\fP. It is typically used to set
directory-specific variables. For example, the X Window System uses this
flag to set \fITOPDIR\fP to the name of the directory containing the top
of the core distribution and \fICURDIR\fP to the name of the current
directory, relative to the top.
.TP 8
.B \-I\fIdirectory\fP
This option is passed directly to \fIcpp\fP. It is typically used to
indicate the directory in which the \fIimake\fP template and configuration
files may be found.
.TP 8
.B \-U\fIdefine\fP
This option is passed directly to \fIcpp\fP. It is typically used to
unset variables when debugging \fIimake\fP configuration files.
.TP 8
.B \-T\fItemplate\fP
This option specifies the name of the master template file (which is usually
located in the directory specified with \fI\-I\fP) used by \fIcpp\fP.
The default is \fIImake.tmpl\fP.
.TP 8
.B \-f \fIfilename\fP
This option specifies the name of the per-directory input file. The default
is \fIImakefile\fP.
.TP 8
.B \-C \fIfilename\fP
This option specifies the name of the .c file that is constructed in the
current directory. The default is \fIImakefile.c\fP.
.TP 8
.B \-s \fIfilename\fP
This option specifies the name of the \fImake\fP description file to be
generated but \fImake\fP should not be invoked.
If the \fIfilename\fP is a dash (\-), the
output is written to \fIstdout\fP. The default is to generate, but
not execute, a \fIMakefile\fP.
.TP 8
.B \-e
This option indicates the \fIimake\fP should execute the generated
\fIMakefile\fP. The default is to leave this to the user.
.TP 8
.B \-v
This option indicates that \fIimake\fP should print the \fIcpp\fP command line
that it is using to generate the \fIMakefile\fP.
.SH "HOW IT WORKS"
\fIImake\fP invokes \fIcpp\fP with any \fI\-I\fP or \fI\-D\fP flags passed
on the command line and passes the name of a file containing the
following 3 lines:
.sp
.nf
\& #define IMAKE_TEMPLATE "Imake.tmpl"
\& #define INCLUDE_IMAKEFILE <Imakefile>
\& #include IMAKE_TEMPLATE
.fi
.sp
where \fIImake.tmpl\fP and \fIImakefile\fP may be overridden by the
\fI\-T\fP and \fI\-f\fP command options, respectively.
.PP
The IMAKE_TEMPLATE typically
reads in a file containing machine-dependent parameters
(specified as \fIcpp\fP symbols), a site-specific parameters file,
a file defining variables,
a file
containing \fIcpp\fP macro functions for generating \fImake\fP rules, and
finally the \fIImakefile\fP (specified by INCLUDE_IMAKEFILE) in the current
directory. The \fIImakefile\fP uses the macro functions to indicate what
targets should be built; \fIimake\fP takes care of generating the appropriate
rules.
.PP
.I Imake
configuration files contain two types of variables, imake variables
and make variables. The imake variables are interpreted by cpp when
.I imake
is run. By convention they are mixed case. The make variables are
written into the
.I Makefile
for later interpretation by
.I make.
By convention make variables are upper case.
.PP
The rules file (usually named \fIImake.rules\fP in the configuration
directory) contains a variety of \fIcpp\fP macro functions that are
configured according to the current platform. \fIImake\fP replaces
any occurrences of the string ``@@'' with a newline to allow macros that
generate more than one line of \fImake\fP rules.
For example, the macro
.ta 1i 1.6i 5i
.nf
\& #define program_target(program, objlist) @@\e
program: objlist @@\e
$(CC) \-o $@ objlist $(LDFLAGS)
.fi
when called with
.I "program_target(foo, foo1.o foo2.o)"
will expand to
.nf
foo: foo1.o foo2.o
$(CC) \-o $@ foo1.o foo2.o $(LDFLAGS)
.fi
.PP
\fIImake\fP also replaces any occurrences of the word ``XCOMM'' with
the character ``#'' to permit placing comments in the Makefile without
causing ``invalid directive'' errors from the preprocessor.
.PP
Some complex \fIimake\fP macros require generated \fImake\fP variables
local to each invocation of the macro, often because their value
depends on parameters passed to the macro.
Such variables can be created by using an \fIimake\fP variable
of the form \fBXVARdef\fP\fIn\fP, where \fIn\fP is a single digit.
A unique \fImake\fP variable will be substituted. Later occurrences
of the variable \fBXVARuse\fP\fIn\fP will
be replaced by the variable created by the corresponding
\fBXVARdef\fP\fIn\fP.
.PP
On systems whose \fIcpp\fP reduces multiple tabs and spaces to a single
space, \fIimake\fP attempts to put back any necessary tabs (\fImake\fP is
very picky about the difference between tabs and spaces). For this reason,
colons (:) in command lines must be preceded by a backslash (\\).
.SH "USE WITH THE X WINDOW SYSTEM"
The X Window System uses \fIimake\fP extensively, for both full builds within
the source tree and external software. As mentioned above, two special
variables, \fITOPDIR\fP and \fICURDIR,\fP are set to make referencing files
using relative path names easier. For example, the following command is
generated automatically to build the \fIMakefile\fP in the directory
\fIlib/X/\fP (relative to the top of the sources):
.sp
.nf
% ../.././config/imake \-I../.././config \\
\-DTOPDIR=../../. \-DCURDIR=./lib/X
.fi
.sp
When building X programs outside the source tree, a special symbol
\fIUseInstalled\fP is defined and \fITOPDIR\fP and
\fICURDIR\fP are omitted. If the configuration files have been
properly installed, the script \fIxmkmf\fP(1) may be used.
.SH "INPUT FILES"
Here is a summary of the files read by
.I imake
as used by X.
The indentation shows what files include what other files.
.nf
.sp
.ta 3i
Imake.tmpl generic variables
site.def site-specific, BeforeVendorCF defined
*.cf machine-specific
*Lib.rules shared library rules
site.def site-specific, AfterVendorCF defined
Imake.rules rules
Project.tmpl X-specific variables
*Lib.tmpl shared library variables
Imakefile
Library.tmpl library rules
Server.tmpl server rules
Threads.tmpl multi-threaded rules
.fi
.LP
Note that \fIsite.def\fP gets included twice, once before the
\fI*.cf\fP file and once after. Although most site customizations
should be specified after the \fI*.cf\fP file, some, such as the
choice of compiler, need to be specified before, because other
variable settings may depend on them.
.LP
The first time \fIsite.def\fP is included, the variable BeforeVendorCF
is defined, and the second time, the variable AfterVendorCF is
defined. All code in \fIsite.def\fP should be inside an #ifdef for
one of these symbols.
.SH FILES
.ta 3i
Imakefile.c temporary input file for cpp
.br
/tmp/Imf.XXXXXX temporary Makefile for -s
.br
/tmp/IIf.XXXXXX temporary Imakefile if specified Imakefile uses # comments
.br
__cpp__ default C preprocessor
.DT
.SH "SEE ALSO"
make(1), xmkmf(1)
.br
S. I. Feldman,
.I
Make \(em A Program for Maintaining Computer Programs
.SH "ENVIRONMENT VARIABLES"
The following environment variables may be set, however their use is not
recommended as they introduce dependencies that are not readily apparent
when \fIimake\fP is run:
.TP 5
.B IMAKEINCLUDE
If defined, this specifies a ``\-I'' include argument to pass to the
C preprocessor. E.g., ``\-I/usr/X11/config''.
.TP 5
.B IMAKECPP
If defined, this should be a valid path to a preprocessor program.
E.g., ``/usr/local/cpp''.
By default,
.I imake
will use cc -E or __cpp__, depending on the OS specific configuration.
.TP 5
.B IMAKEMAKE
If defined, this should be a valid path to a make program,
such as ``/usr/local/make''.
By default,
.I imake
will use whatever
.I make
program is found using
.I execvp(3).
This variable is only used if the ``\-e'' option is specified.
.SH "AUTHOR"
Todd Brunhoff, Tektronix and MIT Project Athena; Jim Fulton, MIT X Consortium
nx-X11/config/imake/imakemdep.h
deleted
100644 → 0
View file @
5b36f644
/* $Xorg: imakemdep.h,v 1.6 2001/02/09 02:03:16 xorgcvs Exp $ */
/* $XdotOrg: xc/config/imake/imakemdep.h,v 1.12 2005/11/08 06:33:24 jkj Exp $ */
/*
Copyright (c) 1993, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/* $XFree86: xc/config/imake/imakemdep.h,v 3.71 2003/06/12 14:12:26 eich Exp $ */
/*
* This file contains machine-dependent constants for the imake utility.
* When porting imake, read each of the steps below and add in any necessary
* definitions. In general you should *not* edit ccimake.c or imake.c!
*/
#ifdef __UNIXOS2__
#define lstat stat
#endif
#ifdef CCIMAKE
/*
* Step 1: imake_ccflags
* Define any special flags that will be needed to get imake.c to compile.
* These will be passed to the compile along with the contents of the
* make variable BOOTSTRAPCFLAGS.
*/
#if defined(clipper) || defined(__clipper__)
#define imake_ccflags "-O -DSYSV -DBOOTSTRAPCFLAGS=-DSYSV"
#endif
#ifdef hpux
#ifdef hp9000s800
#define imake_ccflags "-DSYSV"
#else
#define imake_ccflags "-Wc,-Nd4000,-Ns3000 -DSYSV"
#endif
#endif
#if defined(macII) || defined(_AUX_SOURCE)
#define imake_ccflags "-DmacII -DSYSV"
#endif
#ifdef stellar
#define imake_ccflags "-DSYSV"
#endif
/*
* SCO UnixWare and OpenServer 6 are both System V Release 5 based OSes.
* The native C compiler doesn't assert __UNIXWARE__ but gcc does, so
* we don't redefine it if we are using gcc (as it sets it to a specific
* value). On OpenServer 6, which is a multi-ABI world, if you attempt
* to build with -Kosr, then the C compiler will assert __OPENSERVER__
* and set it to the value 507. That indicates an OSR5 compile, and
* is handled below.
*/
#if defined(__UNIXWARE__) || defined(__USLC__) || defined(Oki) || defined(NCR)
# ifdef imake_ccflags
# undef imake_ccflags
# endif
# ifdef __UNIXWARE__
# ifndef __GNUC__
# define imake_ccflags "-Xa -DSVR4 -DSVR5 -D__UNIXWARE__"
# else
# define imake_ccflags "-Xa -DSVR4 -DSVR5"
# endif
# else
# define imake_ccflags "-Xa -DSVR4"
# endif
#endif
/* SCO may define __USLC__ so put this after the USL check */
#if defined(M_UNIX) || defined(_SCO_DS) || defined(__OPENSERVER__)
# ifdef imake_ccflags
# undef imake_ccflags
# endif
# define imake_ccflags "-DSYSV -DSCO325 -D__SCO__"
#endif
#ifdef sony
#if defined(SYSTYPE_SYSV) || defined(_SYSTYPE_SYSV)
#define imake_ccflags "-DSVR4"
#else
#include <sys/param.h>
#if NEWSOS < 41
#define imake_ccflags "-Dbsd43 -DNOSTDHDRS"
#else
#if NEWSOS < 42
#define imake_ccflags "-Dbsd43"
#endif
#endif
#endif
#endif
#if defined(_IBMR2) || defined(aix)
#define imake_ccflags "-Daix -DSYSV"
#endif
#ifdef Mips
# if defined(SYSTYPE_BSD) || defined(BSD) || defined(BSD43)
# define imake_ccflags "-DBSD43"
# else
# define imake_ccflags "-DSYSV"
# endif
#endif
#ifdef is68k
#define imake_ccflags "-Dluna -Duniosb"
#endif
#ifdef SYSV386
# ifdef SVR4
# define imake_ccflags "-Xa -DSVR4"
# else
# define imake_ccflags "-DSYSV"
# endif
#endif
#ifdef SVR4
# ifdef i386
# define imake_ccflags "-Xa -DSVR4"
# endif
#endif
#ifdef SYSV
# ifdef i386
# define imake_ccflags "-DSYSV"
# endif
#endif
#if defined(Lynx) || defined(__Lynx__)
#define imake_ccflags "-DLynx"
#endif
/* Lynx */
#ifdef __convex__
#define imake_ccflags "-fn -tm c1"
#endif
#ifdef apollo
#define imake_ccflags "-DX_NOT_POSIX"
#endif
#ifdef WIN32
#ifdef __GNUC__
#define imake_ccflags "-D__STDC__"
#else
#if _MSC_VER < 1000
#define imake_ccflags "-nologo -batch -D__STDC__"
#else
#define imake_ccflags "-nologo -D__STDC__"
#endif
#endif
#endif
#ifdef __uxp__
#define imake_ccflags "-DSVR4 -DANSICPP"
#endif
#ifdef __sxg__
#define imake_ccflags "-DSYSV -DUSG -DNOSTDHDRS"
#endif
#ifdef _SEQUENT_
#define imake_ccflags "-Xa -DSVR4"
#endif
#if defined(SX) || defined(PC_UX)
#define imake_ccflags "-DSYSV"
#endif
#ifdef nec_ews_svr2
#define imake_ccflags "-DUSG"
#endif
#if defined(nec_ews_svr4) || defined(_nec_ews_svr4) || defined(_nec_up) || defined(_nec_ft)
#define imake_ccflags "-DSVR4"
#endif
#if defined(MACH) && !defined(__GNU__)
#define imake_ccflags "-DNOSTDHDRS"
#endif
/* this is for OS/2 under UNIXOS2. This won't work with DOS */
#if defined(__UNIXOS2__)
#define imake_ccflags "-DBSD43"
#endif
#if defined(__QNX__) && !defined(__QNXNTO__)
#define imake_ccflags "-D__QNX__ -D_i386"
#endif
#if defined(__QNXNTO__)
#define imake_ccflags "-D__QNXNTO__"
#endif
#else
/* not CCIMAKE */
#ifndef MAKEDEPEND
/*
* Step 2: dup2
* If your OS doesn't have a dup2() system call to duplicate one file
* descriptor onto another, define such a mechanism here (if you don't
* already fall under the existing category(ies).
*/
#if defined(SYSV) && !defined(Mips) && !defined(_SEQUENT_) && !defined(__SCO__)
#define dup2(fd1,fd2) ((fd1 == fd2) ? fd1 : (close(fd2), \
fcntl(fd1, F_DUPFD, fd2)))
#endif
/*
* Step 3: FIXUP_CPP_WHITESPACE
* If your cpp collapses tabs in macro expansions into a single space and
* replaces escaped newlines with a space, define this symbol. This will
* cause imake to attempt to patch up the generated Makefile by looking
* for lines that have colons in them (this is why the rules file escapes
* all colons). One way to tell if you need this is to see whether or not
* your Makefiles have no tabs in them and lots of @@ strings.
*/
#if defined(sun) || defined(SYSV) || defined(SVR4) || defined(hcx) || defined(WIN32) || defined(__SCO__) || (defined(AMOEBA) && defined(CROSS_COMPILE)) || defined(__QNX__) || defined(__sgi) || defined(__UNIXOS2__) || defined(__UNIXWARE__)
#define FIXUP_CPP_WHITESPACE
#endif
#ifdef WIN32
#define REMOVE_CPP_LEADSPACE
#define INLINE_SYNTAX
#define MAGIC_MAKE_VARS
#endif
#ifdef __minix_vmd
#define FIXUP_CPP_WHITESPACE
#endif
#if defined(Lynx)
/* On LynxOS 2.4.0 imake gets built with the old "legacy"
* /bin/cc which has a rather pedantic builtin preprocessor.
* Using a macro which is not #defined (as in Step 5
* below) flags an *error*
*/
#define __NetBSD_Version__ 0
#endif
/*
* Step 4: USE_CC_E, DEFAULT_CC, DEFAULT_CPP
* If you want to use cc -E instead of cpp, define USE_CC_E.
* If use cc -E but want a different compiler, define DEFAULT_CC.
* If the cpp you need is not in /lib/cpp, define DEFAULT_CPP.
*/
#if !defined (CROSSCOMPILE) || defined (CROSSCOMPILE_CPP)
#if defined(__APPLE__)
#define DEFAULT_CPP "/usr/bin/cpp"
#define DEFAULT_CC "cc"
#endif
#if defined(Lynx) || defined(__Lynx__)
#define DEFAULT_CC "gcc"
#define USE_CC_E
#endif
#ifdef hpux
#define USE_CC_E
#endif
#ifdef WIN32
#define USE_CC_E
#ifdef __GNUC__
#define DEFAULT_CC "gcc"
#else
#define DEFAULT_CC "cl"
#endif
#endif
#ifdef apollo
#define DEFAULT_CPP "/usr/lib/cpp"
#endif
#if defined(clipper) || defined(__clipper__)
#define DEFAULT_CPP "/usr/lib/cpp"
#endif
#if defined(_IBMR2) && !defined(DEFAULT_CPP)
#define DEFAULT_CPP "/usr/ccs/lib/cpp"
#endif
#if defined(sun) && (defined(SVR4) || defined(__svr4__) || defined(__SVR4) || defined(__sol__))
#define DEFAULT_CPP "/usr/ccs/lib/cpp"
#endif
#ifdef __bsdi__
#define DEFAULT_CPP "/usr/bin/cpp"
#endif
#ifdef __uxp__
#define DEFAULT_CPP "/usr/ccs/lib/cpp"
#endif
#ifdef __sxg__
#define DEFAULT_CPP "/usr/lib/cpp"
#endif
#if defined(__386BSD__)
#define DEFAULT_CPP "/usr/libexec/cpp"
#endif
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
#define USE_CC_E
#endif
#if defined(__sgi) && defined(__ANSI_CPP__)
#define USE_CC_E
#endif
#if defined(MACH) && !defined(__GNU__)
#define USE_CC_E
#endif
#ifdef __minix_vmd
#define DEFAULT_CPP "/usr/lib/cpp"
#endif
#if defined(__UNIXOS2__)
/* expects cpp in PATH */
#define DEFAULT_CPP "cpp"
#endif
#ifdef __CYGWIN__
#define DEFAULT_CC "gcc"
#define DEFAULT_CPP "/usr/bin/cpp"
#endif
#if defined (__QNX__)
#ifdef __QNXNTO__
#define DEFAULT_CPP "/usr/bin/cpp"
#else
#define DEFAULT_CPP "/usr/X11R6/bin/cpp"
#endif
#endif
#if defined(__GNUC__) && !defined(USE_CC_E)
#define USE_CC_E
#ifndef DEFAULT_CC
#define DEFAULT_CC "gcc"
#endif
#endif
#endif
/* !defined (CROSSCOMPILE) || defined (CROSSCOMPILE_CPP) */
/*
* Step 5: cpp_argv
* The following table contains the flags that should be passed
* whenever a Makefile is being generated. If your preprocessor
* doesn't predefine any unique symbols, choose one and add it to the
* end of this table. Then, do the following:
*
* a. Use this symbol in Imake.cf when setting MacroFile.
* b. Put this symbol in the definition of BootstrapCFlags in your
* <platform>.cf file.
* c. When doing a make World, always add "BOOTSTRAPCFLAGS=-Dsymbol"
* to the end of the command line.
*
* Note that you may define more than one symbol (useful for platforms
* that support multiple operating systems).
*/
#define ARGUMENTS 50
/* number of arguments in various arrays */
#if !defined (CROSSCOMPILE) || defined (CROSSCOMPILE_CPP)
char
*
cpp_argv
[
ARGUMENTS
]
=
{
"cc"
,
/* replaced by the actual program to exec */
"-I."
,
/* add current directory to include path */
#if !defined(__NetBSD_Version__) || __NetBSD_Version__ < 103080000
#ifdef unix
"-Uunix"
,
/* remove unix symbol so that filename unix.c okay */
#endif
#endif
#if defined(__386BSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
defined(__FreeBSD__) || defined(__DragonFly__) || defined(MACH) || \
defined(linux) || defined(__GNU__) || defined(__bsdi__) || \
defined(__GNUC__) || defined(__GLIBC__)
# ifdef __i386__
"-D__i386__"
,
# if defined(__GNUC__) && (__GNUC__ >= 3)
"-m32"
,
# endif
# endif
# ifdef __i486__
"-D__i486__"
,
# endif
# ifdef __i586__
"-D__i586__"
,
# endif
# ifdef __i686__
"-D__i686__"
,
# endif
# ifdef __k6__
"-D__k6__"
,
# endif
# ifdef __ia64__
"-D__ia64__"
,
# endif
# ifdef __amd64__
"-D__amd64__"
,
# endif
# ifdef __x86_64__
"-D__amd64__"
,
# endif
# ifdef __s390__
"-D__s390__"
,
# endif
# ifdef __alpha__
"-D__alpha__"
,
# endif
# ifdef __arm__
"-D__arm__"
,
# endif
# ifdef __s390x__
"-D__s390x__"
,
# endif
# ifdef __sparc__
"-D__sparc__"
,
# endif
# ifdef __m68k__
"-D__m68k__"
,
# endif
# ifdef __hppa__
"-D__hppa__"
,
# endif
# ifdef __sh__
"-D__sh__"
,
# endif
# ifdef __sh3__
"-D__sh3__"
,
# endif
# ifdef __SH3__
"-D__SH3__"
,
# endif
# ifdef __SH4__
"-D__SH4__"
,
# endif
# ifdef __SH4NOFPU__
"-D__SH4_NOFPU__"
,
# endif
# ifdef __GNUC__
"-traditional"
,
# endif
#endif
#ifdef M4330
"-DM4330"
,
/* Tektronix */
#endif
#ifdef M4310
"-DM4310"
,
/* Tektronix */
#endif
#if defined(macII) || defined(_AUX_SOURCE)
"-DmacII"
,
/* Apple A/UX */
#endif
#if defined(USL) || defined(__UNIXWARE__) || \
(defined(__USLC__) && !defined(_SCO_DS))
"-D__UNIXWARE__"
,
/* SCO UnixWare 7 */
#endif
#ifdef sony
"-Dsony"
,
/* Sony */
#if !defined(SYSTYPE_SYSV) && !defined(_SYSTYPE_SYSV) && NEWSOS < 42
"-Dbsd43"
,
#endif
#endif
#ifdef _IBMR2
"-D_IBMR2"
,
/* IBM RS-6000 (we ensured that aix is defined above */
#ifndef aix
#define aix
/* allow BOOTSTRAPCFLAGS="-D_IBMR2" */
#endif
#endif
/* _IBMR2 */
#ifdef aix
"-Daix"
,
/* AIX instead of AOS */
#ifndef ibm
#define ibm
/* allow BOOTSTRAPCFLAGS="-Daix" */
#endif
#endif
/* aix */
#ifdef ibm
"-Dibm"
,
/* IBM PS/2 and RT under both AOS and AIX */
#endif
#ifdef luna
"-Dluna"
,
/* OMRON luna 68K and 88K */
#ifdef luna1
"-Dluna1"
,
#endif
#ifdef luna88k
/* need not on UniOS-Mach Vers. 1.13 */
"-traditional"
,
/* for some older version */
#endif
/* instead of "-DXCOMM=\\#" */
#ifdef uniosb
"-Duniosb"
,
#endif
#ifdef uniosu
"-Duniosu"
,
#endif
#endif
/* luna */
#ifdef Mips
"-DMips"
,
/* Define and use Mips for Mips Co. OS/mach. */
# if defined(SYSTYPE_BSD) || defined(BSD) || defined(BSD43)
"-DBSD43"
,
/* Mips RISCOS supports two environments */
# else
"-DSYSV"
,
/* System V environment is the default */
# endif
#endif
/* Mips */
#ifdef MOTOROLA
"-DMOTOROLA"
,
/* Motorola Delta Systems */
# ifdef SYSV
"-DSYSV"
,
# endif
# ifdef SVR4
"-DSVR4"
,
# endif
#endif
/* MOTOROLA */
#if defined(M_UNIX) || defined(sco) || defined(__SCO__) || \
defined(_SCO_DS) || defined(__OPENSERVER__)
"-D__SCO__"
,
"-DSYSV"
,
#endif
#ifdef i386
"-Di386"
,
# ifdef SVR4
"-DSVR4"
,
# endif
# ifdef SYSV
"-DSYSV"
,
# ifdef ISC
"-DISC"
,
# ifdef ISC40
"-DISC40"
,
/* ISC 4.0 */
# else
# ifdef ISC202
"-DISC202"
,
/* ISC 2.0.2 */
# else
# ifdef ISC30
"-DISC30"
,
/* ISC 3.0 */
# else
"-DISC22"
,
/* ISC 2.2.1 */
# endif
# endif
# endif
# endif
# if (_SCO_DS - 0 == 1)
"-DSCO325"
,
# endif
# if (_SCO_DS - 0 > 1)
"-DSCO5V6"
,
# endif
# endif
# ifdef ESIX
"-DESIX"
,
# endif
# ifdef ATT
"-DATT"
,
# endif
# ifdef DELL
"-DDELL"
,
# endif
#endif
#ifdef SYSV386
/* System V/386 folks, obsolete */
"-Di386"
,
# ifdef SVR4
"-DSVR4"
,
# endif
# ifdef ISC
"-DISC"
,
# ifdef ISC40
"-DISC40"
,
/* ISC 4.0 */
# else
# ifdef ISC202
"-DISC202"
,
/* ISC 2.0.2 */
# else
# ifdef ISC30
"-DISC30"
,
/* ISC 3.0 */
# else
"-DISC22"
,
/* ISC 2.2.1 */
# endif
# endif
# endif
# endif
# if (_SCO_DS - 0 == 1)
"-DSCO325"
,
# endif
# if (_SCO_DS - 0 > 1)
"-DSCO5V6"
,
# endif
# ifdef ESIX
"-DESIX"
,
# endif
# ifdef ATT
"-DATT"
,
# endif
# ifdef DELL
"-DDELL"
,
# endif
#endif
#ifdef __osf__
"-D__osf__"
,
# ifdef __mips__
"-D__mips__"
,
# endif
# ifdef __alpha
"-D__alpha"
,
# endif
# ifdef __amiga__
"-D__amiga__"
,
# endif
# ifdef __alpha__
"-D__alpha__"
,
# endif
# ifdef __i386__
"-D__i386__"
,
# endif
# ifdef __GNUC__
"-traditional"
,
# endif
#endif
#ifdef Oki
"-DOki"
,
#endif
#ifdef sun
#if defined(SVR4) || defined(__svr4__) || defined(__SVR4) || defined(__sol__)
"-DSVR4"
,
#endif
# ifdef __sparcv9
"-D__sparcv9"
,
# endif
# ifdef __amd64
"-D__amd64"
,
# endif
#endif
#ifdef WIN32
"-DWIN32"
,
#ifndef __GNUC__
"-nologo"
,
#if _MSC_VER < 1000
"-batch"
,
#endif
#endif
"-D__STDC__"
,
#endif
#ifdef NCR
"-DNCR"
,
/* NCR */
#endif
#ifdef linux
"-Dlinux"
,
#endif
#if defined(__CYGWIN__)
"-traditional"
,
#endif
#if defined(Lynx) || defined(__Lynx__)
"-traditional"
,
#if 0
"-DLYNX", /* do we really need this?? */
#endif
"-DLynx"
,
# ifdef ppc
"-Dppc"
,
# endif
# ifdef ppc64
"-Dppc64"
,
# endif
# if defined(m68k) || defined(M68k) || defined(m68040)
"-Dm68k"
,
"-DM68k"
,
# endif
# ifdef uSPARC1
"-Dsparc"
,
# endif
#endif
#ifdef __uxp__
"-D__uxp__"
,
#endif
#ifdef __sxg__
"-D__sxg__"
,
#endif
#ifdef nec_ews_svr2
"-Dnec_ews_svr2"
,
#endif
#ifdef AMOEBA
"-DAMOEBA"
,
# ifdef CROSS_COMPILE
"-DCROSS_COMPILE"
,
# ifdef CROSS_i80386
"-Di80386"
,
# endif
# ifdef CROSS_sparc
"-Dsparc"
,
# endif
# ifdef CROSS_mc68000
"-Dmc68000"
,
# endif
# else
# ifdef i80386
"-Di80386"
,
# endif
# ifdef sparc
"-Dsparc"
,
# endif
# ifdef mc68000
"-Dmc68000"
,
# endif
# endif
#endif
#if defined(__sgi) && defined(__ANSI_CPP__)
"-cckr"
,
#endif
#ifdef __minix_vmd
"-Dminix"
,
#endif
#if defined(__UNIXOS2__)
"-traditional"
,
"-Demxos2"
,
#endif
#ifdef MetroLink
"-DMetroLink"
,
# ifdef SVR4
"-DSVR4"
,
# endif
#endif
#ifdef __powerpc__
"-D__powerpc__"
,
#endif
#ifdef __powerpc64__
"-D__powerpc64__"
,
#endif
#ifdef PowerMAX_OS
"-DPowerMAX_OS"
,
#endif
#if defined (__QNX__) && !defined(__QNXNTO__)
"-traditional"
,
"-D__QNX__"
,
#endif
#if defined(__QNXNTO__)
"-traditional"
,
"-D__QNXNTO__"
,
#if defined(i386)
"-Di386"
,
#endif
#if defined(__i386__)
"-D__i386__"
,
#endif
#if defined(PPC)
"-DPPC"
,
#endif
#if defined(MIPS)
"-DMIPS"
,
#endif
#endif
#if defined(__APPLE__)
"-D__APPLE__"
,
"-D__DARWIN__"
,
# ifdef __ppc__
"-D__ppc__"
,
# endif
# ifdef __ppc64__
"-D__ppc64__"
,
# endif
# ifdef __i386__
"-D__i386__"
,
# endif
#endif
};
#endif
/* CROSSCOMPILE */
/*
* Step 6: DEFAULT_OS_MAJOR_REV, DEFAULT_OS_MINOR_REV, DEFAULT_OS_TEENY_REV,
* and DEFAULT_OS_NAME.
* If your system provides a way to generate the default major,
* minor, teeny, or system names at runtime add commands below.
* The syntax of the _REV strings is 'f fmt' where 'f' is an argument
* you would give to uname, and "fmt" is a scanf() format string.
* Supported uname arguments are "snrvm", and if you specify multiple
* arguments they will be separated by spaces. No more than 5 arguments
* may be given. Unlike uname() order of arguments matters.
*
* DEFAULT_OS_MAJOR_REV_FROB, DEFAULT_OS_MINOR_REV_FROB,
* DEFAULT_OS_TEENY_REV_FROB, and DEFAULT_OS_NAME_FROB can be used to
* modify the results of the use of the various strings.
*/
#if !defined CROSSCOMPILE || defined CROSSCOMPILE_CPP
# if defined(aix)
/* uname -v returns "x" (e.g. "4"), and uname -r returns "y" (e.g. "1") */
# define DEFAULT_OS_MAJOR_REV "v %[0-9]"
# define DEFAULT_OS_MINOR_REV "r %[0-9]"
/* No information available to generate default OSTeenyVersion value. */
# define DEFAULT_OS_NAME "srvm %[^\n]"
# elif defined(sun) || defined(sgi) || defined(ultrix) || defined(__uxp__) || defined(sony)
/* uname -r returns "x.y[.z]", e.g. "5.4" or "4.1.3" */
# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"
# define DEFAULT_OS_NAME "srvm %[^\n]"
# elif defined(hpux)
/* uname -r returns "W.x.yz", e.g. "B.10.01" */
# define DEFAULT_OS_MAJOR_REV "r %*[^.].%[0-9]"
# define DEFAULT_OS_MINOR_REV "r %*[^.].%*d.%1s"
# define DEFAULT_OS_TEENY_REV "r %*[^.].%*d.%*c%[0-9]"
# define DEFAULT_OS_NAME "srvm %[^\n]"
# elif defined(USL) || defined(__USLC__) || defined(__UNIXWARE__) || \
defined(__SCO__) || defined(__OPENSERVER__) || defined(_SCO_DS)
/* uname -v returns "x.yz" or "x.y.z", e.g. "2.02" or "2.1.2". */
# define DEFAULT_OS_MAJOR_REV "v %[0-9]"
# define DEFAULT_OS_MINOR_REV "v %*d.%1s"
# define DEFAULT_OS_TEENY_REV "v %*d.%*c%[.0-9]"
# define DEFAULT_OS_NAME "srvm %[^\n]"
# elif defined(__APPLE__)
/* uname -v returns "x.yz" or "x.y.z", e.g. "2.02" or "2.1.2". */
# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"
/* this will just get 0 */
# define DEFAULT_OS_NAME "s %[^\n]"
# elif defined(__osf__)
/* uname -r returns "Wx.y", e.g. "V3.2" or "T4.0" */
# define DEFAULT_OS_MAJOR_REV "r %*[^0-9]%[0-9]"
# define DEFAULT_OS_MINOR_REV "r %*[^.].%[0-9]"
# define DEFAULT_OS_NAME "srvm %[^\n]"
# elif defined(__uxp__)
/* NOTE: "x.y[.z]" above handles UXP/DF. This is a sample alternative. */
/* uname -v returns "VxLy Yzzzzz ....", e.g. "V20L10 Y95021 Increment 5 ..." */
# define DEFAULT_OS_MAJOR_REV "v V%[0-9]"
# define DEFAULT_OS_MINOR_REV "v V%*dL%[0-9]"
# define DEFAULT_OS_NAME "srvm %[^\n]"
# elif defined(linux) || defined(__bsdi__)
# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"
# define DEFAULT_OS_NAME "srm %[^\n]"
# if defined(linux) && defined (CROSSCOMPILE_CPP)
# define CROSS_UTS_SYSNAME "Linux"
# include <linux/version.h>
# define CROSS_UTS_RELEASE UTS_RELEASE
# endif
# elif defined(__CYGWIN__)
# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"
# define DEFAULT_OS_NAME "srm %[^\n]"
# if defined(__CYGWIN__) && defined (CROSSCOMPILE_CPP)
# define CROSS_UTS_SYSNAME "Cygwin"
# include <cygwin/version.h>
# define CROSS_UTS_RELEASE "1.3.12"
# endif
# elif defined(__GNU__)
# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
# define DEFAULT_OS_NAME "srm %[^\n]"
# elif defined(ISC)
/* ISC all Versions ? */
/* uname -r returns "x.y", e.g. "3.2" ,uname -v returns "x" e.g. "2" */
# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
# define DEFAULT_OS_TEENY_REV "v %[0-9]"
/* # define DEFAULT_OS_NAME "srm %[^\n]" */
/* Not useful on ISC */
# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__DragonFly__)
/* BSD/OS too? */
/* uname -r returns "x.y[.z]-mumble", e.g. "2.1.5-RELEASE" or "2.2-0801SNAP" */
# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"
# define DEFAULT_OS_NAME "srm %[^\n]"
# if defined(__FreeBSD__) || defined(__DragonFly__)
/* Use an alternate way to find the teeny version for -STABLE, -SNAP versions */
# ifndef CROSSCOMPILE_CPP
# define DEFAULT_OS_TEENY_REV_FROB(buf, size) \
do { \
if (*buf == 0) { \
int __mib[2]; \
size_t __len; \
int __osrel; \
\
__mib[0] = CTL_KERN; \
__mib[1] = KERN_OSRELDATE; \
__len = sizeof(__osrel); \
sysctl(__mib, 2, &__osrel, &__len, NULL, 0); \
if (__osrel < 210000) { \
if (__osrel < 199607) \
buf[0] = '0'; \
else if (__osrel < 199612) \
buf[0] = '5'; \
else if (__osrel == 199612) \
buf[0] = '6'; \
else \
buf[0] = '8';
/* guess */
\
} else { \
buf[0] = ((__osrel / 1000) % 10) + '0'; \
} \
buf[1] = 0; \
} \
} while (0)
# endif
# else
/* OpenBSD - Add DEFAULT_MACHINE_ARCHITECTURE */
# define DEFAULT_MACHINE_ARCHITECTURE "m %[^\n]"
# endif
# elif defined(__NetBSD__)
/*
* uname -r returns "x.y([ABCD...]|_mumble)", e.g.:
* 1.2 1.2_BETA 1.2A 1.2B
*
* That means that we have to do something special to turn the
* TEENY revision into a form that we can use (i.e., a string of
* decimal digits).
*
* We also frob the name DEFAULT_OS_NAME so that it looks like the
* 'standard' NetBSD name for the version, e.g. "NetBSD/i386 1.2B" for
* NetBSD 1.2B on an i386.
*/
# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
# define DEFAULT_OS_TEENY_REV "r %*d.%*d%[A-Z]"
# define DEFAULT_OS_TEENY_REV_FROB(buf, size) \
do { \
int teeny = 0; \
char *ptr = (buf); \
\
while (*ptr >= 'A' && *ptr <= 'Z')
/* sanity check */
\
teeny = teeny * 26 + (int)(*ptr++ - 'A'); \
\
snprintf((buf), (size), "%d", teeny + 1); \
} while (0)
# define DEFAULT_OS_NAME "smr %[^\n]"
# define DEFAULT_OS_NAME_FROB(buf, size) \
do { \
char *__sp; \
if ((__sp = strchr((buf), ' ')) != NULL) \
*__sp = '/'; \
} while (0)
# elif defined(__Lynx__) || defined(Lynx)
/* Lynx 2.4.0 /bin/cc doesn't like #elif */
# define DEFAULT_OS_MAJOR_REV "r %[0-9]"
# define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"
# define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"
# define DEFAULT_OS_NAME "srm %[^\n]"
# elif defined(_SEQUENT_)
/* uname -v returns 'Vx.y.z', e.g. 'V4.4.2' */
# define DEFAULT_OS_MAJOR_REV "v V%[0-9]"
# define DEFAULT_OS_MINOR_REV "v V%*d.%[0-9]"
# define DEFAULT_OS_TEENY_REV "v V%*d.%*d.%[0-9]"
# define DEFAULT_OS_NAME "s %[^\n]"
# endif
#endif
/* !defined CROSSCOMPILE || defined CROSSCOMPILE_CPP */
# if defined (CROSSCOMPILE_CPP)
# ifndef CROSS_UTS_SYSNAME
char
*
cross_uts_sysname
=
""
;
# else
char
*
cross_uts_sysname
=
CROSS_UTS_SYSNAME
;
# endif
# ifndef CROSS_UTS_RELEASE
char
*
cross_uts_release
=
""
;
# else
char
*
cross_uts_release
=
CROSS_UTS_RELEASE
;
# endif
# ifndef CROSS_UTS_MACHINE
char
*
cross_uts_machine
=
""
;
# else
char
*
cross_uts_machine
=
CROSS_UTS_MACHINE
;
# endif
# ifndef CROSS_UTS_VERSION
char
*
cross_uts_version
=
""
;
# else
char
*
cross_uts_version
=
CROSS_UTS_VERSION
;
# endif
# ifdef DEFAULT_OS_NAME
char
*
defaultOsName
=
DEFAULT_OS_NAME
;
# else
char
*
defaultOsName
=
NULL
;
# endif
# ifdef DEFAULT_OS_MAJOR_REV
char
*
defaultOsMajorRev
=
DEFAULT_OS_MAJOR_REV
;
# else
char
*
defaultOsMajorRev
=
NULL
;
# endif
# ifdef DEFAULT_OS_MINOR_REV
char
*
defaultOsMinorRev
=
DEFAULT_OS_MINOR_REV
;
# else
char
*
defaultOsMinorRev
=
NULL
;
# endif
# ifdef DEFAULT_OS_TEENY_REV
char
*
defaultOsTeenyRev
=
DEFAULT_OS_TEENY_REV
;
# else
char
*
defaultOsTeenyRev
=
NULL
;
# endif
# ifdef DEFAULT_MACHINE_ARCHITECTURE
char
*
defaultMachineArchitecture
=
DEFAULT_MACHINE_ARCHITECTURE
;
# else
char
*
defaultMachineArchitecture
=
NULL
;
# endif
# ifdef DEFAULT_OS_NAME_FROB
void
defaultOsNameFrob
(
char
*
buf
,
int
size
)
{
DEFAULT_OS_NAME_FROB
(
buf
,
size
)}
# else
void
(
*
defaultOsNameFrob
)(
char
*
buf
,
int
size
)
=
NULL
;
# endif
# ifdef DEFAULT_OS_MAJOR_REV_FROB
void
defaultOsMajorRevFrob
(
char
*
buf
,
int
size
)
{
DEFAULT_OS_MAJOR_REV_FROB
(
buf
,
size
)}
# else
void
(
*
defaultOsMajorRevFrob
)(
char
*
buf
,
int
size
)
=
NULL
;
# endif
# ifdef DEFAULT_OS_MINOR_REV_FROB
void
defaultOsMinorRevFrob
(
char
*
buf
,
int
size
)
{
DEFAULT_OS_MINOR_REV_FROB
(
buf
,
size
)}
# else
void
(
*
defaultOsMinorRevFrob
)(
char
*
buf
,
int
size
)
=
NULL
;
# endif
# ifdef DEFAULT_OS_TEENY_REV_FROB
void
defaultOsTeenyRevFrob
(
char
*
buf
,
int
size
)
{
DEFAULT_OS_TEENY_REV_FROB
(
buf
,
size
)}
# else
void
(
*
defaultOsTeenyRevFrob
)(
char
*
buf
,
int
size
)
=
NULL
;
# endif
# endif
/* CROSSCOMPILE_CPP */
#else
/* else MAKEDEPEND */
#if !defined (CROSSCOMPILE) || defined (CROSSCOMPILE_CPP)
/*
* Step 7: predefs
* If your compiler and/or preprocessor define any specific symbols, add
* them to the the following table. The definition of struct symtab is
* in util/makedepend/def.h.
*/
#undef DEF_EVALUATE
#undef DEF_STRINGIFY
#define DEF_EVALUATE(__x) #__x
#define DEF_STRINGIFY(_x) DEF_EVALUATE(_x)
struct
symtab
predefs
[]
=
{
#ifdef apollo
{
"apollo"
,
"1"
},
#endif
#if defined(clipper) || defined(__clipper__)
{
"clipper"
,
"1"
},
{
"__clipper__"
,
"1"
},
{
"clix"
,
"1"
},
{
"__clix__"
,
"1"
},
#endif
#ifdef ibm032
{
"ibm032"
,
"1"
},
#endif
#ifdef ibm
{
"ibm"
,
"1"
},
#endif
#ifdef aix
{
"aix"
,
"1"
},
#endif
#ifdef sun
{
"sun"
,
"1"
},
#endif
#ifdef sun2
{
"sun2"
,
"1"
},
#endif
#ifdef sun3
{
"sun3"
,
"1"
},
#endif
#ifdef sun4
{
"sun4"
,
"1"
},
#endif
#ifdef sparc
{
"sparc"
,
"1"
},
#endif
#ifdef __sparc
{
"__sparc"
,
"1"
},
#endif
#ifdef __sparcv9
{
"__sparcv9"
,
"1"
},
#endif
#ifdef __sparc__
{
"__sparc__"
,
"1"
},
#endif
#ifdef __sparcv9__
{
"__sparcv9__"
,
"1"
},
#endif
#ifdef hpux
{
"hpux"
,
"1"
},
#endif
#ifdef __hpux
{
"__hpux"
,
"1"
},
#endif
#ifdef __hp9000s800
{
"__hp9000s800"
,
"1"
},
#endif
#ifdef __hp9000s700
{
"__hp9000s700"
,
"1"
},
#endif
#ifdef vax
{
"vax"
,
"1"
},
#endif
#ifdef VMS
{
"VMS"
,
"1"
},
#endif
#ifdef att
{
"att"
,
"1"
},
#endif
#ifdef mips
{
"mips"
,
"1"
},
#endif
#ifdef __mips__
{
"__mips__"
,
"1"
},
#endif
#ifdef ultrix
{
"ultrix"
,
"1"
},
#endif
#ifdef stellar
{
"stellar"
,
"1"
},
#endif
#ifdef mc68000
{
"mc68000"
,
"1"
},
#endif
#ifdef mc68020
{
"mc68020"
,
"1"
},
#endif
#ifdef __GNUC__
{
"__GNUC__"
,
DEF_STRINGIFY
(
__GNUC__
)},
#endif
#ifdef __STRICT_ANSI__
{
"__STRICT_ANSI__"
,
"1"
},
#endif
#ifdef __STDC__
{
"__STDC__"
,
DEF_STRINGIFY
(
__STDC__
)},
#endif
#ifdef __HIGHC__
{
"__HIGHC__"
,
"1"
},
#endif
#ifdef __OPENSERVER__
{
"__OPENSERVER__"
,
DEF_STRINGIFY
(
__OPENSERVER__
)},
#endif
#ifdef _SCO_DS
{
"_SCO_DS"
,
DEF_STRINGIFY
(
_SCO_DS
)},
#endif
#ifdef _SCO_DS_LL
{
"_SCO_DS_LL"
,
DEF_STRINGIFY
(
_SCO_DS_LL
)},
#endif
#ifdef __SCO_VERSION__
{
"__SCO_VERSION__"
,
DEF_STRINGIFY
(
__SCO_VERSION__
)},
#endif
#ifdef __UNIXWARE__
{
"__UNIXWARE__"
,
DEF_STRINGIFY
(
__UNIXWARE__
)},
#endif
#ifdef __USLC__
{
"__USLC__"
,
DEF_STRINGIFY
(
__USLC__
)},
#endif
#ifdef CMU
{
"CMU"
,
"1"
},
#endif
#ifdef luna
{
"luna"
,
"1"
},
#ifdef luna1
{
"luna1"
,
"1"
},
#endif
#ifdef luna2
{
"luna2"
,
"1"
},
#endif
#ifdef luna88k
{
"luna88k"
,
"1"
},
#endif
#ifdef uniosb
{
"uniosb"
,
"1"
},
#endif
#ifdef uniosu
{
"uniosu"
,
"1"
},
#endif
#endif
#ifdef ieeep754
{
"ieeep754"
,
"1"
},
#endif
#ifdef is68k
{
"is68k"
,
"1"
},
#endif
#ifdef m68k
{
"m68k"
,
"1"
},
#endif
#ifdef M68k
{
"M68k"
,
"1"
},
#endif
#ifdef __m68k__
{
"__m68k__"
,
"1"
},
#endif
#ifdef m88k
{
"m88k"
,
"1"
},
#endif
#ifdef __m88k__
{
"__m88k__"
,
"1"
},
#endif
#ifdef bsd43
{
"bsd43"
,
"1"
},
#endif
#ifdef hcx
{
"hcx"
,
"1"
},
#endif
#ifdef sony
{
"sony"
,
"1"
},
#ifdef SYSTYPE_SYSV
{
"SYSTYPE_SYSV"
,
"1"
},
#endif
#ifdef _SYSTYPE_SYSV
{
"_SYSTYPE_SYSV"
,
"1"
},
#endif
#endif
#ifdef __OSF__
{
"__OSF__"
,
"1"
},
#endif
#ifdef __osf__
{
"__osf__"
,
"1"
},
#endif
#ifdef __amiga__
{
"__amiga__"
,
"1"
},
#endif
#ifdef __alpha
{
"__alpha"
,
"1"
},
#endif
#ifdef __alpha__
{
"__alpha__"
,
"1"
},
#endif
#ifdef __DECC
{
"__DECC"
,
"1"
},
#endif
#ifdef __decc
{
"__decc"
,
"1"
},
#endif
#ifdef __unix__
{
"__unix__"
,
"1"
},
#endif
#ifdef __uxp__
{
"__uxp__"
,
"1"
},
#endif
#ifdef __sxg__
{
"__sxg__"
,
"1"
},
#endif
#ifdef _SEQUENT_
{
"_SEQUENT_"
,
"1"
},
{
"__STDC__"
,
"1"
},
#endif
#ifdef __bsdi__
{
"__bsdi__"
,
"1"
},
#endif
#ifdef nec_ews_svr2
{
"nec_ews_svr2"
,
"1"
},
#endif
#ifdef nec_ews_svr4
{
"nec_ews_svr4"
,
"1"
},
#endif
#ifdef _nec_ews_svr4
{
"_nec_ews_svr4"
,
"1"
},
#endif
#ifdef _nec_up
{
"_nec_up"
,
"1"
},
#endif
#ifdef SX
{
"SX"
,
"1"
},
#endif
#ifdef nec
{
"nec"
,
"1"
},
#endif
#ifdef _nec_ft
{
"_nec_ft"
,
"1"
},
#endif
#ifdef PC_UX
{
"PC_UX"
,
"1"
},
#endif
#ifdef sgi
{
"sgi"
,
"1"
},
#endif
#ifdef __sgi
{
"__sgi"
,
"1"
},
#endif
#ifdef _MIPS_FPSET
{
"_MIPS_FPSET"
,
DEF_STRINGIFY
(
_MIPS_FPSET
)},
#endif
#ifdef _MIPS_ISA
{
"_MIPS_ISA"
,
DEF_STRINGIFY
(
_MIPS_ISA
)},
#endif
#ifdef _MIPS_SIM
{
"_MIPS_SIM"
,
DEF_STRINGIFY
(
_MIPS_SIM
)},
#endif
#ifdef _MIPS_SZINT
{
"_MIPS_SZINT"
,
DEF_STRINGIFY
(
_MIPS_SZINT
)},
#endif
#ifdef _MIPS_SZLONG
{
"_MIPS_SZLONG"
,
DEF_STRINGIFY
(
_MIPS_SZLONG
)},
#endif
#ifdef _MIPS_SZPTR
{
"_MIPS_SZPTR"
,
DEF_STRINGIFY
(
_MIPS_SZPTR
)},
#endif
#ifdef __DragonFly__
{
"__DragonFly__"
,
"1"
},
#endif
#ifdef __FreeBSD__
{
"__FreeBSD__"
,
"1"
},
#endif
#ifdef __OpenBSD__
{
"__OpenBSD__"
,
"1"
},
#endif
#ifdef __NetBSD__
{
"__NetBSD__"
,
"1"
},
#endif
#ifdef __GNU__
{
"__GNU__"
,
"1"
},
#endif
#ifdef __ELF__
{
"__ELF__"
,
"1"
},
#endif
#ifdef __UNIXOS2__
{
"__UNIXOS2__"
,
"1"
},
#endif
#if defined(__QNX__)
{
"__QNX__"
,
"1"
},
#endif
#ifdef __QNXNTO__
{
"__QNXNTO__"
,
"1"
},
#endif
# ifdef __powerpc__
{
"__powerpc__"
,
"1"
},
# endif
# ifdef __powerpc64__
{
"__powerpc64__"
,
"1"
},
# endif
# ifdef PowerMAX_OS
{
"PowerMAX_OS"
,
"1"
},
# endif
# ifdef ia64
{
"ia64"
,
"1"
},
# endif
# ifdef __ia64__
{
"__ia64__"
,
"1"
},
# endif
# if defined (amd64) || defined (x86_64)
{
"amd64"
,
"1"
},
{
"x86_64"
,
"1"
},
# endif
# if defined (__amd64__) || defined (__x86_64__)
{
"__amd64__"
,
"1"
},
{
"__x86_64__"
,
"1"
},
# endif
# if defined (__amd64) || defined(__x86_64)
{
"__amd64"
,
"1"
},
{
"__x86_64"
,
"1"
},
# endif
# ifdef __x86
{
"__x86"
,
"1"
},
# endif
# ifdef __i386
{
"__i386"
,
"1"
},
# endif
# ifdef __i386__
{
"__i386__"
,
"1"
},
# endif
# ifdef __i486__
{
"__i486__"
,
"1"
},
# endif
# ifdef __i586__
{
"__i586__"
,
"1"
},
# endif
# ifdef __i686__
{
"__i686__"
,
"1"
},
# endif
# ifdef __k6__
{
"__k6__"
,
"1"
},
# endif
# ifdef i386
{
"i386"
,
"1"
},
# endif
# ifdef i486
{
"i486"
,
"1"
},
# endif
# ifdef i586
{
"i586"
,
"1"
},
# endif
# ifdef i686
{
"i686"
,
"1"
},
# endif
# ifdef k6
{
"k6"
,
"1"
},
# endif
# ifdef sparc
{
"sparc"
,
"1"
},
# endif
# ifdef __sparc__
{
"__sparc__"
,
"1"
},
# endif
# ifdef __s390__
{
"__s390__"
,
"1"
},
# endif
# ifdef __hppa__
{
"__hppa__"
,
"1"
},
# endif
# ifdef __sh__
{
"__sh__"
,
"1"
},
# endif
# ifdef __sh3_
{
"__sh3__"
,
"1"
},
# endif
# ifdef __SH3__
{
"__SH3__"
,
"1"
},
# endif
# ifdef __SH4__
{
"__SH4__"
,
"1"
},
# endif
# ifdef __SH4NOFPU__
{
"__SH4NOFPU__"
,
"1"
},
# endif
#if defined(__ppc__)
{
"__ppc__"
,
"1"
},
#endif
#if defined(__ppc64__)
{
"__ppc64__"
,
"1"
},
#endif
#if defined(__BIG_ENDIAN__)
{
"__BIG_ENDIAN__"
,
"1"
},
#endif
#if defined(__LITTLE_ENDIAN__)
{
"__LITTLE_ENDIAN__"
,
"1"
},
#endif
#if defined (__CHAR_BIT__)
{
"__CHAR_BIT__"
,
DEF_STRINGIFY
(
__CHAR_BIT__
)},
#endif
#if defined (__BUILTIN_VA_STRUCT)
{
"__BUILTIN_VA_STRUCT"
,
"1"
},
#endif
#if defined (__BUILTIN_VA_ARG_INCR)
{
"__BUILTIN_VA_ARG_INCR"
,
"1"
},
#endif
/* add any additional symbols before this line */
{
NULL
,
NULL
}
};
#undef DEF_EVALUATE
#undef DEF_STRINGIFY
#endif
/* CROSSCOMPILE */
#endif
/* MAKEDEPEND */
# ifndef MAKEDEPEND
# if defined (CROSSCOMPILE_CPP)
# ifdef USE_CC_E
boolean
crosscompile_use_cc_e
=
TRUE
;
# ifdef DEFAULT_CC
char
*
crosscompile_cpp
=
DEFAULT_CC
;
# else
char
*
crosscompile_cpp
=
"cc"
;
# endif
# else
boolean
crosscompile_use_cc_e
=
FALSE
;
# ifdef DEFAULT_CPP
char
*
crosscompile_cpp
=
DEFAULT_CPP
;
# else
char
*
crosscompile_cpp
=
"cpp"
;
# endif
# endif
# ifdef FIXUP_CPP_WHITESPACE
boolean
fixup_whitespace
=
TRUE
;
# else
boolean
fixup_whitespace
=
FALSE
;
# endif
# ifdef REMOVE_CPP_LEADSPACE
boolean
remove_cpp_leadspace
=
TRUE
;
# else
boolean
remove_cpp_leadspace
=
FALSE
;
# endif
# ifdef INLINE_SYNTAX
boolean
inline_syntax
=
TRUE
;
# else
boolean
inline_syntax
=
FALSE
;
# endif
# ifdef MAGIC_MAKE_VARS
boolean
magic_make_vars
=
TRUE
;
# else
boolean
magic_make_vars
=
FALSE
;
# endif
typedef
enum
{
unknown
,
freeBSD
,
netBSD
,
LinuX
,
emx
,
win32
,
dragonfly
}
System
;
# if defined(linux) || defined(__GLIBC__)
System
sys
=
LinuX
;
# elif defined __FreeBSD__
System
sys
=
freebsd
;
# elif defined __NetBSD__
System
sys
=
netBSD
;
# elif defined __EMX__
System
sys
=
emx
;
# elif defined WIN32
System
sys
=
win32
;
# elif defined __DragonFly__
System
sys
=
dragonfly
;
# else
System
sys
=
unknown
;
# endif
# if defined __GNUC__
int
gnu_c
=
__GNUC__
;
int
gnu_c_minor
=
__GNUC_MINOR__
;
# else
int
gnu_c
=
0
;
int
gnu_c_minor
=
-
1
;
# endif
# if defined(linux) || defined(__GLIBC__)
# include <features.h>
int
glibc_major
=
__GLIBC__
+
4
;
int
glibc_minor
=
__GLIBC_MINOR__
;
# else
int
glibc_major
=
0
;
int
glibc_minor
=
-
1
;
# endif
# endif
/* !CROSSCOMPILE || CROSSCOMPILE_CPP */
# endif
/* MAKEDEPEND */
#endif
/* CCIMAKE */
nx-X11/config/imake/imakesvc.cmd
deleted
100644 → 0
View file @
5b36f644
/* Rexx OS/2
* This script serves as a helper cmd file for imake. Install this in
* the path just like imake itself.
*
* $XFree86: xc/config/imake/imakesvc.cmd,v 3.13 1999/04/29 09:13:23 dawes Exp $
*/
'@echo off'
ADDRESS CMD
CALL RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
CALL RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
CALL RxFuncAdd 'SysRmDir', 'RexxUtil', 'SysRmDir'
CALL RxFuncAdd 'SysMkDir', 'RexxUtil', 'SysMkDir'
PARSE ARG all
code = WORD(all,1)
SELECT
WHEN code=1 THEN DO
/* imakesvc 1 u/n dir ruledir top current */
instflg = WORD(all,2)
imakecmd = '\imake'
ruledir = WORD(all,4)
topdir = WORD(all,5)
currentdir = WORD(all,6)
IF instflg = 'u' THEN DO
root = VALUE('X11ROOT',,'OS2ENVIRONMENT')
IF root = '' THEN DO
SAY 'Fatal error: no X11ROOT environment variable found!'
EXIT 99
END
imakecmd = 'imake'
IF POS(':',ruledir) = 0 THEN
ruledir1 = root||ruledir
ELSE
ruledir1 = ruledir
topdir1 = topdir
useinst = '-DUseInstalled'
END
ELSE DO
/* in n mode, we must add a prefix ../ for MakeMakeSubdirs */
ruledir1 = '../'||ruledir
topdir1 = '../'||topdir
useinst = ''
END
ruledir = ruledir1
topdir = topdir1
curdir = DIRECTORY()
dir = fixbadprefix(WORD(all,3))
d = DIRECTORY(dir)
dirfwd=TRANSLATE(dir,'/','\')
RC = SysFileDelete('Makefile.bak')
IF exists('Makefile') THEN REN Makefile Makefile.bak
/* There is a difficulty in the Imakefiles. Some builds refer
* to directories that are in a different subtree. We need to adjust
* the CURDIR and TOPDIR and -I paths
*/
IF SUBSTR(dirfwd,1,2)='..' THEN DO
/* must recalculate passed topdir, currentdir, and ruledir */
ndist = nlevels(topdir)
ncurdir = './'striplevel(dirfwd,ndist-1)
ntopdir = maketop(nlevels(ncurdir))
nruledir = ntopdir||'/config/cf'
END
ELSE DO
/* this is simple it is relative to this dir */
pfx = downlevels(dirfwd)
nruledir = ruledir
IF instflg = 'n' THEN DO /*sm120296*/
nruledir = pfx||ruledir
END
ntopdir = pfx||topdir
ncurdir = currentdir /* use to be pfx || currentdir */
END
imakecmd useinst '-I'nruledir' -DTOPDIR='ntopdir' -DCURDIR='ncurdir'/'dirfwd
'x11make MAKE=x11make SHELL= Makefiles'
d = DIRECTORY(curdir)
END
WHEN code=2 THEN DO
/* imakesvc 2 buildincdir buildinctop currentdir file */
bid = WORD(all,3)
cid = WORD(all,4)
fil = WORD(all,5)
curdir = DIRECTORY()
d = DIRECTORY(WORD(all,2))
rc = SysFileDelete(fil)
dir = TRANSLATE(bid'/'cid'/'fil,'\','/')
COPY dir .' >nul 2>&1 '
d = DIRECTORY(curdir)
END
WHEN code=3 THEN DO
/* imakesvc 3 subdir updir file */
sdi = WORD(all,2)
fil = WORD(all,4)
curdir = DIRECTORY()
d = DIRECTORY(WORD(all,3))
rc = SysFileDelete(fil)
dir = TRANSLATE(sdi'/'fil,'\','/')
COPY dir' . >nul 2>&1'
d = DIRECTORY(curdir)
END
WHEN code=4 THEN DO
/* imakesvc 4 [-r] files... */
rec = WORD(all,2)
fp = 2
IF rec = '-r' THEN fp = 3
ELSE rec = '-n'
DO i=fp TO WORDS(all)
CALL discard rec,TRANSLATE(WORD(all,i),'\','/')
END
END
WHEN code=5 THEN DO
/* imakesvc 5 file */
file = TRANSLATE(WORD(all,2),'\','/')
RC = SysFileDelete(file'.bak')
if exists(file) THEN 'REN 'file file||'.bak'
END
WHEN code=6 THEN DO
/* imakesvc 6 file */
file = TRANSLATE(WORD(all,2),'\','/')
CALL SysFileDelete(file||'.bak')
if exists(file) THEN 'REN 'file file||'.bak'
END
WHEN code=7 THEN DO
/* imakesvc 7 from to */
from = TRANSLATE(WORD(all,2),'\','/')
to = TRANSLATE(WORD(all,3),'\','/')
CALL SysFileDelete(to)
COPY from to' >nul 2>&1'
END
WHEN code=8 THEN DO
/* imakesvc 8 arg */
SAY SUBWORD(TRANSLATE(all,' ','222c'x),2)
END
WHEN code=9 THEN DO
/* imakesvc 9 dst.c incl.h src.c */
dst = TRANSLATE(WORD(all,2),'\','/')
src = TRANSLATE(WORD(all,4),'\','/')
CALL SysFileDelete(dst)
CALL LINEOUT dst,'#include "'WORD(all,3)'"'
CALL LINEOUT dst,'#include "'src'"'
CALL LINEOUT dst
END
WHEN code=10 THEN DO
/* imakesvc 10 srcfile destdir destfile suffix */
src = stripsuffix(WORD(all,2))
destdir = TRANSLATE(WORD(all,3),'\','/')
dest = stripsuffix(WORD(all,4))
suffix = WORD(all,5)
tgt = destdir'\'dest'.'suffix
/* if you have no col.exe get one from 4.4BSD */
'groff -e -t -man -Tascii 'src'.man | col -b >'tgt
END
WHEN code=11 THEN DO
/* imakesvc 11 dirtomake */
dirtomake = TRANSLATE(WORD(all,2),'\','/')
rc = SysMkDir(dirtomake)
END
WHEN code=12 THEN DO
/* imakesvc 12 srcfile destdir destfile */
src = stripsuffix(WORD(all,2))
destdir = TRANSLATE(WORD(all,3),'\','/')
dest = stripsuffix(WORD(all,4))
tgt = destdir'\'dest'.gz'
/* if you have no col.exe get one from 4.4BSD */
'groff -e -t -man -Tascii 'src'.man | col -b | gzip -n >'tgt
END
WHEN code=13 THEN DO
/* imakesvc 13 indir fromfile tofile */
ind = TRANSLATE(WORD(all,2),'\','/')
frm = TRANSLATE(WORD(all,3),'\','/')
tof = ind'\'WORD(all,4)
IF \(exists(ind)) THEN call SysMkDir ind
rc = SysFileDelete(tof)
COPY frm' 'tof
END
WHEN code=14 THEN DO
/* imakesvc 14 destdir srcfile... */
destdir = TRANSLATE(WORD(all,2),'\','/')
DO i=3 TO WORDS(all)
src = stripsuffix(WORD(all,i))
tgt = destdir'\'src'.gz'
'groff -e -t -man -Tascii 'src'.man | col -b | gzip -n >'tgt
END
END
WHEN code=15 THEN DO
/* imakesvc 15 destdir suffix srcfile... */
destdir = TRANSLATE(WORD(all,2),'\','/')
suffix = WORD(all,3)
DO i=4 TO WORDS(all)
src = stripsuffix(WORD(all,i))
tgt = destdir'\'src'.'suffix
'groff -e -t -man -Tascii 'src'.man | col -b >'tgt
END
END
WHEN code=16 THEN DO
/* imakesvc 16 dirlist...*/
mkfontdir = TRANSLATE(WORD(all,2),'\','/')
earg=''
DO i=3 TO WORDS(all)
arg = WORD(all,i)
earg = earg' -e 'arg
END
mkfontdir' -r -p inst/ 'earg' .'
END
OTHERWISE NOP
END
RETURN
downlevels:
oldpos = 1
pfx = ''
DO FOREVER
newpos = POS('/',ARG(1),oldpos)
IF newpos = 0 THEN LEAVE
newpfx = '../'pfx
oldpos = newpos+1
pfx = newpfx
END
RETURN pfx
/* returns 1, if file exists */
exists:
'DIR "'arg(1)'" >nul 2>&1'
IF rc = 0 THEN return 1
RETURN 0
discard: PROCEDURE
rec=ARG(1)
files=ARG(2)
IF rec = '-r' THEN DO
old = DIRECTORY()
nd = DIRECTORY
CALL SysFileTree files, 'deld', 'DO'
IF deld.0 > 0 THEN DO
DO m=1 TO deld.0
CALL DIRECTORY deld.m
CALL discard '-R' .
CALL DIRECTORY ..
CALL SysRmDir deld.m
END
CALL SysRmDir files
END
CALL SysFileTree files, 'delf', 'FO'
DO k=1 TO delf.0
DEL '"'delf.k'"' '>nul 2>&1'
END
CALL SysRmDir files
END
ELSE DO
DEL '"'files'"' '>nul 2>&1'
END
RETURN
/* somehow make or cmd manages to convert a relative path ..\..\. to ..... */
fixbadprefix:
count = 1
str = ARG(1)
DO WHILE SUBSTR(str,count,2) = '..'
count = count+1
str = INSERT('\',str,count)
count = count+2
END
RETURN str
striplevel:
str=ARG(1)
n=arg(2)
DO count=0 TO n
p = POS('/',str)
IF p = 0 THEN LEAVE
str = DELSTR(str,1,p)
END
RETURN str
nlevels:
str = ARG(1)
count = 0
oldpos = 1
DO FOREVER
newpos = POS('/',str,oldpos)
IF newpos = 0 THEN LEAVE
oldpos = newpos + 1
count = count + 1
END
RETURN count
maketop:
str = ''
n = ARG(1)
DO k=1 TO n
str = str||'../'
END
RETURN str||'.'
stripsuffix:
str = ARG(1)
spos = POS('.',str)
IF spos = 0 THEN
RETURN str
ELSE
RETURN LEFT(str,spos-1)
nx-X11/config/makedepend/Imakefile
deleted
100644 → 0
View file @
5b36f644
XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:41:50 cpqbld Exp $
XCOMM
XCOMM
XCOMM
XCOMM
XCOMM $XFree86: xc/config/makedepend/Imakefile,v 3.12tsi Exp $
SRCS = include.c main.c parse.c pr.c cppsetup.c ifparser.c
OBJS = include.o main.o parse.o pr.o cppsetup.o ifparser.o
XCOMM Some compilers generate fatal errors if an -L directory does
XCOMM not exist. Since BUILDLIBDIR may not exist yet suppress its use.
LDPRELIB =
LDPRELIBS =
#if HasGcc && !defined(PreIncDir)
#ifdef CrossCompileDir
#else
#define PreIncDir /usr/local/lib/gcc-include
#endif
#endif
#ifdef PreIncDir
PREINCDIR = PreIncDir
PREINC_DEFINES = -DPREINCDIR=\"$(PREINCDIR)\"
#endif
#ifndef StdIncDir
#ifdef CrossCompileDir
#define StdIncDir Concat(CrossCompileDir,/../include)
#else
#define StdIncDir /usr/include
#endif
#endif
STDINCDIR = StdIncDir
STDINC_DEFINES = -DINCLUDEDIR=\"$(STDINCDIR)\"
#ifdef PostIncDir
POSTINCDIR = PostIncDir
POSTINC_DEFINES = -DPOSTINCDIR=\"$(POSTINCDIR)\"
#endif
#ifdef ExtraIncDir
EXTRAINCDIR = ExtraIncDir
EXTRAINC_DEFINES = -DEXTRAINCDIR=\"$(EXTRAINCDIR)\"
#endif
INC_DEFINES = $(PREINC_DEFINES) $(STDINC_DEFINES) $(POSTINC_DEFINES) \
$(EXTRAINC_DEFINES)
OSUF = Concat(.,Osuf)
OSUF_DEFINES = -DOBJSUFFIX=\"$(OSUF)\"
MAIN_DEFINES = $(INC_DEFINES) $(SIGNAL_DEFINES) $(OSUF_DEFINES)
INCLUDES = -I$(IMAKESRC) -I$(TOP)/include $(TOP_X_INCLUDES)/X11
DEPLIBS =
#if defined(MacIIArchitecture) || defined(SequentArchitecture) || defined(i386ScoArchitecture)
XBSDLIB = /**/
#endif
AllTarget(HostProgramTargetName(makedepend))
makedependonly:: HostProgramTargetName(makedepend)
/*
* bootstrapping: want to build the real makedepend
* only after we've run "make depend" here. That way
* the program has the right dependencies for clearmake.
* Save the bootstrap original files so they can be winked in
* to other views.
*/
#if HasClearmake
bootstrap:
test -h X11 || $(LN) TOPDIR/include X11
$(MAKE) -f Makefile.proto TOP_INCLUDES=-I. makedepend
depend::
$(MAKE) -f Makefile.proto depend
test -d bootstrap || mkdir bootstrap
$(MV) *.o makedepend bootstrap
$(MAKE) -f Makefile.proto makedepend
clean::
$(RM) -r bootstrap
$(RM) X11
#else
bootstrap:
#endif /* HasClearmake */
clean::
$(RM) Makefile.proto
#undef InstallManPage
#define InstallManPage(file,dest) /* as nothing */
#if CrossCompiling
ComplexHostProgramTarget(makedepend)
#else
ComplexProgramTarget(makedepend)
#endif
SpecialCObjectRule(main,$(ICONFIGFILES),$(MAIN_DEFINES))
InstallManPageLong(mkdepend,$(MANDIR),makedepend)
InstallDriverSDKNamedProg(makedepend,makedepend,$(DRIVERSDKDIR)/config/makedepend)
nx-X11/config/makedepend/cpp.ed
deleted
100644 → 0
View file @
5b36f644
#
# $Xorg: cpp.ed,v 1.3 2000/08/17 19:41:50 cpqbld Exp $
#
# $Locker $
#
/struct symtab stab/d
/struct symtab \*defloc;/d
/struct symtab \*udfloc;/d
/struct symtab \*incloc;/d
/struct symtab \*ifloc;/d
/struct symtab \*elsloc;/d
/struct symtab \*eifloc;/d
/struct symtab \*ifdloc;/d
/struct symtab \*ifnloc;/d
/struct symtab \*ysysloc;/d
/struct symtab \*varloc;/d
/struct symtab \*lneloc;/d
/struct symtab \*ulnloc;/d
/struct symtab \*uflloc;/d
/^sayline(/s/$/ DELETED/p
.,/^}/d
/^unfill(/s/$/ DELETED/p
.-1,/^}/d
/^doincl(/s/$/ DELETED/p
.-1,/^}/d
/^equfrm(/s/$/ DELETED/p
.,/^}/d
/^dodef(/s/$/ DELETED/p
.-1,/^}/d
/^control(/s/$/ DELETED/p
.-1,/^}/d
/^savestring(/s/$/ DELETED/p
.-1,/^}/d
/^stsym(/s/$/ DELETED/p
.-1,/^}/d
/^ppsym(/s/$/ DELETED/p
.-1,/^}/d
/^yyerror(/s/$/ DELETED/p
.,/^}/d
/^ppwarn(/s/$/ DELETED/p
.,/^}/d
/^lookup(/s/$/ DELETED/p
.-1,/^}/d
/^subst(/s/$/ DELETED/p
.-1,/^}/d
/^trmdir(/s/$/ DELETED/p
.-1,/^}/d
/^copy(/s/$/ DELETED/p
.-1,/^}/d
/^pperror(/s/$/ DELETED/p
.,/^}/d
/^main(/s/$/ CHANGED to cpp_varsetup(argc,argv)/p
.c
cpp_varsetup(argc,argv)
.
/^strdex(/s/$/ DELETED/p
.-1,/^}/d
/^ for(i=1; i<argc; i++)/s/$/ To the end DELETED/p
.,$c
}
.
/^dump(/s/$/ DELETED/p
.,/^}/c
dump() { fatal("dump\n"); }
.
/^refill(/s/$/ DELETED/p
.,/^}/c
refill() { fatal("refill\n"); }
.
/^slookup(/s/$/ DELETED/p
.-1,/^}/c
static struct symtab *slookup() { fatal("slookup\n"); }
.
w
q
nx-X11/config/makedepend/cppsetup.c
deleted
100644 → 0
View file @
5b36f644
/* $Xorg: cppsetup.c,v 1.5 2001/02/09 02:03:16 xorgcvs Exp $ */
/*
Copyright (c) 1993, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/* $XFree86: xc/config/makedepend/cppsetup.c,v 3.10 2001/12/14 19:53:20 dawes Exp $ */
#include "def.h"
#ifdef CPP
/*
* This file is strictly for the sake of cpy.y and yylex.c (if
* you indeed have the source for cpp).
*/
#define IB 1
#define SB 2
#define NB 4
#define CB 8
#define QB 16
#define WB 32
#define SALT '#'
#if defined(pdp11) || defined(vax) || defined(ns16000) || defined(mc68000) || defined(ibm032)
#define COFF 128
#else
#define COFF 0
#endif
/*
* These variables used by cpy.y and yylex.c
*/
extern
char
*
outp
,
*
inp
,
*
newp
,
*
pend
;
extern
char
*
ptrtab
;
extern
char
fastab
[];
extern
char
slotab
[];
/*
* cppsetup
*/
struct
filepointer
*
currentfile
;
struct
inclist
*
currentinc
;
int
cppsetup
(
char
*
line
,
struct
filepointer
*
filep
,
struct
inclist
*
inc
)
{
char
*
p
,
savec
;
static
boolean
setupdone
=
FALSE
;
boolean
value
;
if
(
!
setupdone
)
{
cpp_varsetup
();
setupdone
=
TRUE
;
}
currentfile
=
filep
;
currentinc
=
inc
;
inp
=
newp
=
line
;
for
(
p
=
newp
;
*
p
;
p
++
)
;
/*
* put a newline back on the end, and set up pend, etc.
*/
*
p
++
=
'\n'
;
savec
=
*
p
;
*
p
=
'\0'
;
pend
=
p
;
ptrtab
=
slotab
+
COFF
;
*--
inp
=
SALT
;
outp
=
inp
;
value
=
yyparse
();
*
p
=
savec
;
return
(
value
);
}
struct
symtab
**
lookup
(
symbol
)
char
*
symbol
;
{
static
struct
symtab
*
undefined
;
struct
symtab
**
sp
;
sp
=
isdefined
(
symbol
,
currentinc
,
NULL
);
if
(
sp
==
NULL
)
{
sp
=
&
undefined
;
(
*
sp
)
->
s_value
=
NULL
;
}
return
(
sp
);
}
pperror
(
tag
,
x0
,
x1
,
x2
,
x3
,
x4
)
int
tag
,
x0
,
x1
,
x2
,
x3
,
x4
;
{
warning
(
"
\"
%s
\"
, line %d: "
,
currentinc
->
i_file
,
currentfile
->
f_line
);
warning
(
x0
,
x1
,
x2
,
x3
,
x4
);
}
yyerror
(
s
)
register
char
*
s
;
{
fatalerr
(
"Fatal error: %s
\n
"
,
s
);
}
#else
/* not CPP */
#include "ifparser.h"
struct
_parse_data
{
struct
filepointer
*
filep
;
struct
inclist
*
inc
;
char
*
filename
;
const
char
*
line
;
};
static
const
char
*
my_if_errors
(
IfParser
*
ip
,
const
char
*
cp
,
const
char
*
expecting
)
{
struct
_parse_data
*
pd
=
(
struct
_parse_data
*
)
ip
->
data
;
int
lineno
=
pd
->
filep
->
f_line
;
char
*
filename
=
pd
->
filename
;
char
prefix
[
300
];
int
prefixlen
;
int
i
;
sprintf
(
prefix
,
"
\"
%s
\"
:%d"
,
filename
,
lineno
);
prefixlen
=
strlen
(
prefix
);
fprintf
(
stderr
,
"%s: %s"
,
prefix
,
pd
->
line
);
i
=
cp
-
pd
->
line
;
if
(
i
>
0
&&
pd
->
line
[
i
-
1
]
!=
'\n'
)
{
putc
(
'\n'
,
stderr
);
}
for
(
i
+=
prefixlen
+
3
;
i
>
0
;
i
--
)
{
putc
(
' '
,
stderr
);
}
fprintf
(
stderr
,
"^--- expecting %s
\n
"
,
expecting
);
return
NULL
;
}
#define MAXNAMELEN 256
static
struct
symtab
**
lookup_variable
(
IfParser
*
ip
,
const
char
*
var
,
int
len
)
{
char
tmpbuf
[
MAXNAMELEN
+
1
];
struct
_parse_data
*
pd
=
(
struct
_parse_data
*
)
ip
->
data
;
if
(
len
>
MAXNAMELEN
)
return
0
;
strncpy
(
tmpbuf
,
var
,
len
);
tmpbuf
[
len
]
=
'\0'
;
return
isdefined
(
tmpbuf
,
pd
->
inc
,
NULL
);
}
static
int
my_eval_defined
(
IfParser
*
ip
,
const
char
*
var
,
int
len
)
{
if
(
lookup_variable
(
ip
,
var
,
len
))
return
1
;
else
return
0
;
}
#define isvarfirstletter(ccc) (isalpha(ccc) || (ccc) == '_')
static
long
my_eval_variable
(
IfParser
*
ip
,
const
char
*
var
,
int
len
)
{
long
val
;
struct
symtab
**
s
;
s
=
lookup_variable
(
ip
,
var
,
len
);
if
(
!
s
)
return
0
;
do
{
var
=
(
*
s
)
->
s_value
;
if
(
!
isvarfirstletter
(
*
var
)
||
!
strcmp
((
*
s
)
->
s_name
,
var
))
break
;
s
=
lookup_variable
(
ip
,
var
,
strlen
(
var
));
}
while
(
s
);
var
=
ParseIfExpression
(
ip
,
var
,
&
val
);
if
(
var
&&
*
var
)
debug
(
4
,
(
"extraneous: '%s'
\n
"
,
var
));
return
val
;
}
int
cppsetup
(
char
*
filename
,
char
*
line
,
struct
filepointer
*
filep
,
struct
inclist
*
inc
)
{
IfParser
ip
;
struct
_parse_data
pd
;
long
val
=
0
;
pd
.
filep
=
filep
;
pd
.
inc
=
inc
;
pd
.
line
=
line
;
pd
.
filename
=
filename
;
ip
.
funcs
.
handle_error
=
my_if_errors
;
ip
.
funcs
.
eval_defined
=
my_eval_defined
;
ip
.
funcs
.
eval_variable
=
my_eval_variable
;
ip
.
data
=
(
char
*
)
&
pd
;
(
void
)
ParseIfExpression
(
&
ip
,
line
,
&
val
);
if
(
val
)
return
IF
;
else
return
IFFALSE
;
}
#endif
/* CPP */
nx-X11/config/makedepend/def.h
deleted
100644 → 0
View file @
5b36f644
/* $XdotOrg: xc/config/makedepend/def.h,v 1.4 2005/07/29 18:42:37 kem Exp $ */
/* $Xorg: def.h,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ */
/*
Copyright (c) 1993, 1994, 1998 The Open Group.
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/* $XFree86: xc/config/makedepend/def.h,v 3.13tsi Exp $ */
#ifdef HAVE_CONFIG_H
/* Autotooled for Xorg 7.0? */
# include "makedepend-config.h"
# define USING_AUTOCONF
#endif
#include <X11/Xos.h>
#include <X11/Xfuncproto.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#if 0
#ifndef X_NOT_POSIX
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE
#endif
#endif
#endif
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#define MAXDEFINES 512
#define MAXFILES 1024
#define MAXINCFILES 128
/* "-include" files */
#define MAXDIRS 64
#define SYMTABINC 10
/* must be > 1 for define() to work right */
#define TRUE 1
#define FALSE 0
/* the following must match the directives table in main.c */
#define IF 0
#define IFDEF 1
#define IFNDEF 2
#define ELSE 3
#define ENDIF 4
#define DEFINE 5
#define UNDEF 6
#define INCLUDE 7
#define LINE 8
#define PRAGMA 9
#define ERROR 10
#define IDENT 11
#define SCCS 12
#define ELIF 13
#define EJECT 14
#define WARNING 15
#define INCLUDENEXT 16
#define IFFALSE 17
/* pseudo value --- never matched */
#define ELIFFALSE 18
/* pseudo value --- never matched */
#define INCLUDEDOT 19
/* pseudo value --- never matched */
#define IFGUESSFALSE 20
/* pseudo value --- never matched */
#define ELIFGUESSFALSE 21
/* pseudo value --- never matched */
#define INCLUDENEXTDOT 22
/* pseudo value --- never matched */
#ifdef DEBUG
extern
int
_debugmask
;
/*
* debug levels are:
*
* 0 show ifn*(def)*,endif
* 1 trace defined/!defined
* 2 show #include
* 3 show #include SYMBOL
* 4-6 unused
*/
#define debug(level,arg) { if (_debugmask & (1 << level)) warning arg; }
#else
#define debug(level,arg)
/**/
#endif
/* DEBUG */
typedef
unsigned
char
boolean
;
struct
symtab
{
char
*
s_name
;
char
*
s_value
;
};
/* possible i_flag */
#define DEFCHECKED (1<<0)
/* whether defines have been checked */
#define NOTIFIED (1<<1)
/* whether we have revealed includes */
#define MARKED (1<<2)
/* whether it's in the makefile */
#define SEARCHED (1<<3)
/* whether we have read this */
#define FINISHED (1<<4)
/* whether we are done reading this */
#define INCLUDED_SYM (1<<5)
/* whether #include SYMBOL was found
Can't use i_list if TRUE */
struct
inclist
{
char
*
i_incstring
;
/* string from #include line */
char
*
i_file
;
/* path name of the include file */
struct
inclist
**
i_list
;
/* list of files it itself includes */
int
i_listlen
;
/* length of i_list */
struct
symtab
**
i_defs
;
/* symbol table for this file and its
children when merged */
int
i_ndefs
;
/* current # defines */
boolean
*
i_merged
;
/* whether we have merged child
defines */
unsigned
char
i_flags
;
};
struct
filepointer
{
char
*
f_name
;
char
*
f_p
;
char
*
f_base
;
char
*
f_end
;
long
f_len
;
long
f_line
;
long
cmdinc_count
;
char
**
cmdinc_list
;
long
cmdinc_line
;
};
#include <stdlib.h>
#if defined(macII) && !defined(__STDC__)
/* stdlib.h fails to define these */
char
*
malloc
(),
*
realloc
();
#endif
/* macII */
char
*
copy
(
char
*
str
);
int
match
(
char
*
str
,
char
**
list
);
char
*
base_name
(
char
*
file
);
char
*
getnextline
(
struct
filepointer
*
fp
);
struct
symtab
**
slookup
(
char
*
symbol
,
struct
inclist
*
file
);
struct
symtab
**
isdefined
(
char
*
symbol
,
struct
inclist
*
file
,
struct
inclist
**
srcfile
);
struct
symtab
**
fdefined
(
char
*
symbol
,
struct
inclist
*
file
,
struct
inclist
**
srcfile
);
struct
filepointer
*
getfile
(
char
*
file
);
void
included_by
(
struct
inclist
*
ip
,
struct
inclist
*
newfile
);
struct
inclist
*
newinclude
(
char
*
newfile
,
char
*
incstring
);
void
inc_clean
(
void
);
struct
inclist
*
inc_path
(
char
*
file
,
char
*
include
,
int
type
);
void
freefile
(
struct
filepointer
*
fp
);
void
define2
(
char
*
name
,
char
*
val
,
struct
inclist
*
file
);
void
define
(
char
*
def
,
struct
inclist
*
file
);
void
undefine
(
char
*
symbol
,
struct
inclist
*
file
);
int
find_includes
(
struct
filepointer
*
filep
,
struct
inclist
*
file
,
struct
inclist
*
file_red
,
int
recursion
,
boolean
failOK
);
void
recursive_pr_include
(
struct
inclist
*
head
,
char
*
file
,
char
*
base
);
void
add_include
(
struct
filepointer
*
filep
,
struct
inclist
*
file
,
struct
inclist
*
file_red
,
char
*
include
,
int
type
,
boolean
failOK
);
int
cppsetup
(
char
*
filename
,
char
*
line
,
struct
filepointer
*
filep
,
struct
inclist
*
inc
);
extern
void
fatalerr
(
char
*
,
...);
extern
void
warning
(
char
*
,
...);
extern
void
warning1
(
char
*
,
...);
nx-X11/config/makedepend/ifparser.c
deleted
100644 → 0
View file @
5b36f644
/*
* $Xorg: ifparser.c,v 1.3 2000/08/17 19:41:50 cpqbld Exp $
*
* Copyright 1992 Network Computing Devices, Inc.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Network Computing Devices may not be
* used in advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. Network Computing Devices makes
* no representations about the suitability of this software for any purpose.
* It is provided ``as is'' without express or implied warranty.
*
* NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
* IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Author: Jim Fulton
* Network Computing Devices, Inc.
*
* Simple if statement processor
*
* This module can be used to evaluate string representations of C language
* if constructs. It accepts the following grammar:
*
* EXPRESSION := VALUE
* | VALUE BINOP EXPRESSION
* | VALUE '?' EXPRESSION ':' EXPRESSION
*
* VALUE := '(' EXPRESSION ')'
* | '!' VALUE
* | '-' VALUE
* | '+' VALUE
* | '~' VALUE
* | 'defined' '(' variable ')'
* | 'defined' variable
* | # variable '(' variable-list ')'
* | variable
* | number
*
* BINOP := '*' | '/' | '%'
* | '+' | '-'
* | '<<' | '>>'
* | '<' | '>' | '<=' | '>='
* | '==' | '!='
* | '&' | '^' | '|'
* | '&&' | '||'
*
* The normal C order of precedence is supported.
*
*
* External Entry Points:
*
* ParseIfExpression parse a string for #if
*/
/* $XFree86: xc/config/makedepend/ifparser.c,v 3.10tsi Exp $ */
#include "ifparser.h"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
/****************************************************************************
Internal Macros and Utilities for Parser
****************************************************************************/
#define DO(val) if (!(val)) return NULL
#define CALLFUNC(ggg,fff) (*((ggg)->funcs.fff))
#define SKIPSPACE(ccc) while (isspace(*ccc)) ccc++
#define isvarfirstletter(ccc) (isalpha(ccc) || (ccc) == '_')
static
const
char
*
parse_variable
(
IfParser
*
g
,
const
char
*
cp
,
const
char
**
varp
)
{
SKIPSPACE
(
cp
);
if
(
!
isvarfirstletter
(
*
cp
))
return
CALLFUNC
(
g
,
handle_error
)
(
g
,
cp
,
"variable name"
);
*
varp
=
cp
;
/* EMPTY */
for
(
cp
++
;
isalnum
(
*
cp
)
||
*
cp
==
'_'
;
cp
++
)
;
return
cp
;
}
static
const
char
*
parse_number
(
IfParser
*
g
,
const
char
*
cp
,
long
*
valp
)
{
long
base
=
10
;
SKIPSPACE
(
cp
);
if
(
!
isdigit
(
*
cp
))
return
CALLFUNC
(
g
,
handle_error
)
(
g
,
cp
,
"number"
);
*
valp
=
0
;
if
(
*
cp
==
'0'
)
{
cp
++
;
if
((
*
cp
==
'x'
)
||
(
*
cp
==
'X'
))
{
base
=
16
;
cp
++
;
}
else
{
base
=
8
;
}
}
/* Ignore overflows and assume ASCII, what source is usually written in */
while
(
1
)
{
int
increment
=
-
1
;
if
(
base
==
8
)
{
if
((
*
cp
>=
'0'
)
&&
(
*
cp
<=
'7'
))
increment
=
*
cp
++
-
'0'
;
}
else
if
(
base
==
16
)
{
if
((
*
cp
>=
'0'
)
&&
(
*
cp
<=
'9'
))
increment
=
*
cp
++
-
'0'
;
else
if
((
*
cp
>=
'A'
)
&&
(
*
cp
<=
'F'
))
increment
=
*
cp
++
-
(
'A'
-
10
);
else
if
((
*
cp
>=
'a'
)
&&
(
*
cp
<=
'f'
))
increment
=
*
cp
++
-
(
'a'
-
10
);
}
else
{
/* Decimal */
if
((
*
cp
>=
'0'
)
&&
(
*
cp
<=
'9'
))
increment
=
*
cp
++
-
'0'
;
}
if
(
increment
<
0
)
break
;
*
valp
=
(
*
valp
*
base
)
+
increment
;
}
/* Skip trailing qualifiers */
while
(
*
cp
==
'U'
||
*
cp
==
'u'
||
*
cp
==
'L'
||
*
cp
==
'l'
)
cp
++
;
return
cp
;
}
static
const
char
*
parse_character
(
IfParser
*
g
,
const
char
*
cp
,
long
*
valp
)
{
char
val
;
SKIPSPACE
(
cp
);
if
(
*
cp
==
'\\'
)
switch
(
cp
[
1
])
{
case
'n'
:
val
=
'\n'
;
break
;
case
't'
:
val
=
'\t'
;
break
;
case
'v'
:
val
=
'\v'
;
break
;
case
'b'
:
val
=
'\b'
;
break
;
case
'r'
:
val
=
'\r'
;
break
;
case
'f'
:
val
=
'\f'
;
break
;
case
'a'
:
val
=
'\a'
;
break
;
case
'\\'
:
val
=
'\\'
;
break
;
case
'?'
:
val
=
'\?'
;
break
;
case
'\''
:
val
=
'\''
;
break
;
case
'\"'
:
val
=
'\"'
;
break
;
case
'x'
:
val
=
(
char
)
strtol
(
cp
+
2
,
NULL
,
16
);
break
;
default:
val
=
(
char
)
strtol
(
cp
+
1
,
NULL
,
8
);
break
;
}
else
val
=
*
cp
;
while
(
*
cp
!=
'\''
)
cp
++
;
*
valp
=
(
long
)
val
;
return
cp
;
}
static
const
char
*
parse_value
(
IfParser
*
g
,
const
char
*
cp
,
long
*
valp
)
{
const
char
*
var
,
*
varend
;
*
valp
=
0
;
SKIPSPACE
(
cp
);
if
(
!*
cp
)
return
cp
;
switch
(
*
cp
)
{
case
'('
:
DO
(
cp
=
ParseIfExpression
(
g
,
cp
+
1
,
valp
));
SKIPSPACE
(
cp
);
if
(
*
cp
!=
')'
)
return
CALLFUNC
(
g
,
handle_error
)
(
g
,
cp
,
")"
);
return
cp
+
1
;
/* skip the right paren */
case
'!'
:
DO
(
cp
=
parse_value
(
g
,
cp
+
1
,
valp
));
*
valp
=
!
(
*
valp
);
return
cp
;
case
'-'
:
DO
(
cp
=
parse_value
(
g
,
cp
+
1
,
valp
));
*
valp
=
-
(
*
valp
);
return
cp
;
case
'+'
:
DO
(
cp
=
parse_value
(
g
,
cp
+
1
,
valp
));
return
cp
;
case
'~'
:
DO
(
cp
=
parse_value
(
g
,
cp
+
1
,
valp
));
*
valp
=
~
(
*
valp
);
return
cp
;
case
'#'
:
DO
(
cp
=
parse_variable
(
g
,
cp
+
1
,
&
var
));
SKIPSPACE
(
cp
);
if
(
*
cp
!=
'('
)
return
CALLFUNC
(
g
,
handle_error
)
(
g
,
cp
,
"("
);
do
{
DO
(
cp
=
parse_variable
(
g
,
cp
+
1
,
&
var
));
SKIPSPACE
(
cp
);
}
while
(
*
cp
&&
*
cp
!=
')'
);
if
(
*
cp
!=
')'
)
return
CALLFUNC
(
g
,
handle_error
)
(
g
,
cp
,
")"
);
*
valp
=
1
;
/* XXX */
return
cp
+
1
;
case
'\''
:
DO
(
cp
=
parse_character
(
g
,
cp
+
1
,
valp
));
if
(
*
cp
!=
'\''
)
return
CALLFUNC
(
g
,
handle_error
)
(
g
,
cp
,
"'"
);
return
cp
+
1
;
case
'd'
:
if
(
strncmp
(
cp
,
"defined"
,
7
)
==
0
&&
!
isalnum
(
cp
[
7
]))
{
int
paren
=
0
;
int
len
;
cp
+=
7
;
SKIPSPACE
(
cp
);
if
(
*
cp
==
'('
)
{
paren
=
1
;
cp
++
;
}
DO
(
cp
=
parse_variable
(
g
,
cp
,
&
var
));
len
=
cp
-
var
;
SKIPSPACE
(
cp
);
if
(
paren
&&
*
cp
!=
')'
)
return
CALLFUNC
(
g
,
handle_error
)
(
g
,
cp
,
")"
);
*
valp
=
(
*
(
g
->
funcs
.
eval_defined
))
(
g
,
var
,
len
);
return
cp
+
paren
;
/* skip the right paren */
}
/* fall out */
}
if
(
isdigit
(
*
cp
))
{
DO
(
cp
=
parse_number
(
g
,
cp
,
valp
));
}
else
if
(
!
isvarfirstletter
(
*
cp
))
return
CALLFUNC
(
g
,
handle_error
)
(
g
,
cp
,
"variable or number"
);
else
{
DO
(
cp
=
parse_variable
(
g
,
cp
,
&
var
));
varend
=
cp
;
SKIPSPACE
(
cp
);
if
(
*
cp
!=
'('
)
{
*
valp
=
(
*
(
g
->
funcs
.
eval_variable
))
(
g
,
var
,
varend
-
var
);
}
else
{
do
{
long
dummy
;
DO
(
cp
=
ParseIfExpression
(
g
,
cp
+
1
,
&
dummy
));
SKIPSPACE
(
cp
);
if
(
*
cp
==
')'
)
break
;
if
(
*
cp
!=
','
)
return
CALLFUNC
(
g
,
handle_error
)
(
g
,
cp
,
","
);
}
while
(
1
);
*
valp
=
1
;
/* XXX */
cp
++
;
}
}
return
cp
;
}
static
const
char
*
parse_product
(
IfParser
*
g
,
const
char
*
cp
,
long
*
valp
)
{
long
rightval
;
DO
(
cp
=
parse_value
(
g
,
cp
,
valp
));
SKIPSPACE
(
cp
);
switch
(
*
cp
)
{
case
'*'
:
DO
(
cp
=
parse_product
(
g
,
cp
+
1
,
&
rightval
));
*
valp
=
(
*
valp
*
rightval
);
break
;
case
'/'
:
DO
(
cp
=
parse_product
(
g
,
cp
+
1
,
&
rightval
));
if
(
rightval
)
*
valp
=
(
*
valp
/
rightval
);
else
*
valp
=
LONG_MAX
;
break
;
case
'%'
:
DO
(
cp
=
parse_product
(
g
,
cp
+
1
,
&
rightval
));
*
valp
=
(
*
valp
%
rightval
);
break
;
}
return
cp
;
}
static
const
char
*
parse_sum
(
IfParser
*
g
,
const
char
*
cp
,
long
*
valp
)
{
long
rightval
;
DO
(
cp
=
parse_product
(
g
,
cp
,
valp
));
SKIPSPACE
(
cp
);
switch
(
*
cp
)
{
case
'+'
:
DO
(
cp
=
parse_sum
(
g
,
cp
+
1
,
&
rightval
));
*
valp
=
(
*
valp
+
rightval
);
break
;
case
'-'
:
DO
(
cp
=
parse_sum
(
g
,
cp
+
1
,
&
rightval
));
*
valp
=
(
*
valp
-
rightval
);
break
;
}
return
cp
;
}
static
const
char
*
parse_shift
(
IfParser
*
g
,
const
char
*
cp
,
long
*
valp
)
{
long
rightval
;
DO
(
cp
=
parse_sum
(
g
,
cp
,
valp
));
SKIPSPACE
(
cp
);
switch
(
*
cp
)
{
case
'<'
:
if
(
cp
[
1
]
==
'<'
)
{
DO
(
cp
=
parse_shift
(
g
,
cp
+
2
,
&
rightval
));
*
valp
=
(
*
valp
<<
rightval
);
}
break
;
case
'>'
:
if
(
cp
[
1
]
==
'>'
)
{
DO
(
cp
=
parse_shift
(
g
,
cp
+
2
,
&
rightval
));
*
valp
=
(
*
valp
>>
rightval
);
}
break
;
}
return
cp
;
}
static
const
char
*
parse_inequality
(
IfParser
*
g
,
const
char
*
cp
,
long
*
valp
)
{
long
rightval
;
DO
(
cp
=
parse_shift
(
g
,
cp
,
valp
));
SKIPSPACE
(
cp
);
switch
(
*
cp
)
{
case
'<'
:
if
(
cp
[
1
]
==
'='
)
{
DO
(
cp
=
parse_inequality
(
g
,
cp
+
2
,
&
rightval
));
*
valp
=
(
*
valp
<=
rightval
);
}
else
{
DO
(
cp
=
parse_inequality
(
g
,
cp
+
1
,
&
rightval
));
*
valp
=
(
*
valp
<
rightval
);
}
break
;
case
'>'
:
if
(
cp
[
1
]
==
'='
)
{
DO
(
cp
=
parse_inequality
(
g
,
cp
+
2
,
&
rightval
));
*
valp
=
(
*
valp
>=
rightval
);
}
else
{
DO
(
cp
=
parse_inequality
(
g
,
cp
+
1
,
&
rightval
));
*
valp
=
(
*
valp
>
rightval
);
}
break
;
}
return
cp
;
}
static
const
char
*
parse_equality
(
IfParser
*
g
,
const
char
*
cp
,
long
*
valp
)
{
long
rightval
;
DO
(
cp
=
parse_inequality
(
g
,
cp
,
valp
));
SKIPSPACE
(
cp
);
switch
(
*
cp
)
{
case
'='
:
if
(
cp
[
1
]
==
'='
)
cp
++
;
DO
(
cp
=
parse_equality
(
g
,
cp
+
1
,
&
rightval
));
*
valp
=
(
*
valp
==
rightval
);
break
;
case
'!'
:
if
(
cp
[
1
]
!=
'='
)
break
;
DO
(
cp
=
parse_equality
(
g
,
cp
+
2
,
&
rightval
));
*
valp
=
(
*
valp
!=
rightval
);
break
;
}
return
cp
;
}
static
const
char
*
parse_band
(
IfParser
*
g
,
const
char
*
cp
,
long
*
valp
)
{
long
rightval
;
DO
(
cp
=
parse_equality
(
g
,
cp
,
valp
));
SKIPSPACE
(
cp
);
switch
(
*
cp
)
{
case
'&'
:
if
(
cp
[
1
]
!=
'&'
)
{
DO
(
cp
=
parse_band
(
g
,
cp
+
1
,
&
rightval
));
*
valp
=
(
*
valp
&
rightval
);
}
break
;
}
return
cp
;
}
static
const
char
*
parse_bxor
(
IfParser
*
g
,
const
char
*
cp
,
long
*
valp
)
{
long
rightval
;
DO
(
cp
=
parse_band
(
g
,
cp
,
valp
));
SKIPSPACE
(
cp
);
switch
(
*
cp
)
{
case
'^'
:
DO
(
cp
=
parse_bxor
(
g
,
cp
+
1
,
&
rightval
));
*
valp
=
(
*
valp
^
rightval
);
break
;
}
return
cp
;
}
static
const
char
*
parse_bor
(
IfParser
*
g
,
const
char
*
cp
,
long
*
valp
)
{
long
rightval
;
DO
(
cp
=
parse_bxor
(
g
,
cp
,
valp
));
SKIPSPACE
(
cp
);
switch
(
*
cp
)
{
case
'|'
:
if
(
cp
[
1
]
!=
'|'
)
{
DO
(
cp
=
parse_bor
(
g
,
cp
+
1
,
&
rightval
));
*
valp
=
(
*
valp
|
rightval
);
}
break
;
}
return
cp
;
}
static
const
char
*
parse_land
(
IfParser
*
g
,
const
char
*
cp
,
long
*
valp
)
{
long
rightval
;
DO
(
cp
=
parse_bor
(
g
,
cp
,
valp
));
SKIPSPACE
(
cp
);
switch
(
*
cp
)
{
case
'&'
:
if
(
cp
[
1
]
!=
'&'
)
return
CALLFUNC
(
g
,
handle_error
)
(
g
,
cp
,
"&&"
);
DO
(
cp
=
parse_land
(
g
,
cp
+
2
,
&
rightval
));
*
valp
=
(
*
valp
&&
rightval
);
break
;
}
return
cp
;
}
static
const
char
*
parse_lor
(
IfParser
*
g
,
const
char
*
cp
,
long
*
valp
)
{
long
rightval
;
DO
(
cp
=
parse_land
(
g
,
cp
,
valp
));
SKIPSPACE
(
cp
);
switch
(
*
cp
)
{
case
'|'
:
if
(
cp
[
1
]
!=
'|'
)
return
CALLFUNC
(
g
,
handle_error
)
(
g
,
cp
,
"||"
);
DO
(
cp
=
parse_lor
(
g
,
cp
+
2
,
&
rightval
));
*
valp
=
(
*
valp
||
rightval
);
break
;
}
return
cp
;
}
static
const
char
*
parse_cond
(
IfParser
*
g
,
const
char
*
cp
,
long
*
valp
)
{
long
trueval
,
falseval
;
DO
(
cp
=
parse_lor
(
g
,
cp
,
valp
));
SKIPSPACE
(
cp
);
switch
(
*
cp
)
{
case
'?'
:
DO
(
cp
=
parse_cond
(
g
,
cp
+
1
,
&
trueval
));
SKIPSPACE
(
cp
);
if
(
*
cp
!=
':'
)
return
CALLFUNC
(
g
,
handle_error
)
(
g
,
cp
,
":"
);
DO
(
cp
=
parse_cond
(
g
,
cp
+
1
,
&
falseval
));
*
valp
=
(
*
valp
?
trueval
:
falseval
);
break
;
}
return
cp
;
}
/****************************************************************************
External Entry Points
****************************************************************************/
const
char
*
ParseIfExpression
(
IfParser
*
g
,
const
char
*
cp
,
long
*
valp
)
{
return
parse_cond
(
g
,
cp
,
valp
);
}
nx-X11/config/makedepend/ifparser.h
deleted
100644 → 0
View file @
5b36f644
/*
* $Xorg: ifparser.h,v 1.3 2000/08/17 19:41:51 cpqbld Exp $
*
* Copyright 1992 Network Computing Devices, Inc.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Network Computing Devices may not be
* used in advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. Network Computing Devices makes
* no representations about the suitability of this software for any purpose.
* It is provided ``as is'' without express or implied warranty.
*
* NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
* IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Author: Jim Fulton
* Network Computing Devices, Inc.
*
* Simple if statement processor
*
* This module can be used to evaluate string representations of C language
* if constructs. It accepts the following grammar:
*
* EXPRESSION := VALUE
* | VALUE BINOP EXPRESSION
* | VALUE '?' EXPRESSION ':' EXPRESSION
*
* VALUE := '(' EXPRESSION ')'
* | '!' VALUE
* | '-' VALUE
* | '~' VALUE
* | 'defined' '(' variable ')'
* | variable
* | number
*
* BINOP := '*' | '/' | '%'
* | '+' | '-'
* | '<<' | '>>'
* | '<' | '>' | '<=' | '>='
* | '==' | '!='
* | '&' | '^' | '|'
* | '&&' | '||'
*
* The normal C order of precedence is supported.
*
*
* External Entry Points:
*
* ParseIfExpression parse a string for #if
*/
/* $XFree86: xc/config/makedepend/ifparser.h,v 3.4 2001/01/17 16:38:58 dawes Exp $ */
#include <stdio.h>
typedef
int
Bool
;
#define False 0
#define True 1
typedef
struct
_if_parser
{
struct
{
/* functions */
const
char
*
(
*
handle_error
)
(
struct
_if_parser
*
,
const
char
*
,
const
char
*
);
long
(
*
eval_variable
)
(
struct
_if_parser
*
,
const
char
*
,
int
);
int
(
*
eval_defined
)
(
struct
_if_parser
*
,
const
char
*
,
int
);
}
funcs
;
char
*
data
;
}
IfParser
;
const
char
*
ParseIfExpression
(
IfParser
*
,
const
char
*
,
long
*
);
nx-X11/config/makedepend/include.c
deleted
100644 → 0
View file @
5b36f644
/* $Xorg: include.c,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ */
/*
Copyright (c) 1993, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/* $XFree86: xc/config/makedepend/include.c,v 3.6 2001/04/29 23:25:02 tsi Exp $ */
#include "def.h"
extern
struct
inclist
inclist
[
MAXFILES
],
*
inclistp
,
*
inclistnext
;
extern
char
*
includedirs
[
],
**
includedirsnext
;
extern
char
*
notdotdot
[
];
extern
boolean
show_where_not
;
extern
boolean
warn_multiple
;
static
boolean
isdot
(
char
*
p
)
{
if
(
p
&&
*
p
++
==
'.'
&&
*
p
++
==
'\0'
)
return
(
TRUE
);
return
(
FALSE
);
}
static
boolean
isdotdot
(
char
*
p
)
{
if
(
p
&&
*
p
++
==
'.'
&&
*
p
++
==
'.'
&&
*
p
++
==
'\0'
)
return
(
TRUE
);
return
(
FALSE
);
}
static
boolean
issymbolic
(
char
*
dir
,
char
*
component
)
{
#ifdef S_IFLNK
struct
stat
st
;
char
buf
[
BUFSIZ
],
**
pp
;
sprintf
(
buf
,
"%s%s%s"
,
dir
,
*
dir
?
"/"
:
""
,
component
);
for
(
pp
=
notdotdot
;
*
pp
;
pp
++
)
if
(
strcmp
(
*
pp
,
buf
)
==
0
)
return
(
TRUE
);
if
(
lstat
(
buf
,
&
st
)
==
0
&&
(
st
.
st_mode
&
S_IFMT
)
==
S_IFLNK
)
{
*
pp
++
=
copy
(
buf
);
if
(
pp
>=
&
notdotdot
[
MAXDIRS
])
fatalerr
(
"out of .. dirs, increase MAXDIRS
\n
"
);
return
(
TRUE
);
}
#endif
return
(
FALSE
);
}
/*
* Occasionally, pathnames are created that look like .../x/../y
* Any of the 'x/..' sequences within the name can be eliminated.
* (but only if 'x' is not a symbolic link!!)
*/
static
void
remove_dotdot
(
char
*
path
)
{
register
char
*
end
,
*
from
,
*
to
,
**
cp
;
char
*
components
[
MAXFILES
],
newpath
[
BUFSIZ
];
boolean
component_copied
;
/*
* slice path up into components.
*/
to
=
newpath
;
if
(
*
path
==
'/'
)
*
to
++
=
'/'
;
*
to
=
'\0'
;
cp
=
components
;
for
(
from
=
end
=
path
;
*
end
;
end
++
)
if
(
*
end
==
'/'
)
{
while
(
*
end
==
'/'
)
*
end
++
=
'\0'
;
if
(
*
from
)
*
cp
++
=
from
;
from
=
end
;
}
*
cp
++
=
from
;
*
cp
=
NULL
;
/*
* Recursively remove all 'x/..' component pairs.
*/
cp
=
components
;
while
(
*
cp
)
{
if
(
!
isdot
(
*
cp
)
&&
!
isdotdot
(
*
cp
)
&&
isdotdot
(
*
(
cp
+
1
))
&&
!
issymbolic
(
newpath
,
*
cp
))
{
char
**
fp
=
cp
+
2
;
char
**
tp
=
cp
;
do
*
tp
++
=
*
fp
;
/* move all the pointers down */
while
(
*
fp
++
);
if
(
cp
!=
components
)
cp
--
;
/* go back and check for nested ".." */
}
else
{
cp
++
;
}
}
/*
* Concatenate the remaining path elements.
*/
cp
=
components
;
component_copied
=
FALSE
;
while
(
*
cp
)
{
if
(
component_copied
)
*
to
++
=
'/'
;
component_copied
=
TRUE
;
for
(
from
=
*
cp
;
*
from
;
)
*
to
++
=
*
from
++
;
*
to
=
'\0'
;
cp
++
;
}
*
to
++
=
'\0'
;
/*
* copy the reconstituted path back to our pointer.
*/
strcpy
(
path
,
newpath
);
}
/*
* Add an include file to the list of those included by 'file'.
*/
struct
inclist
*
newinclude
(
char
*
newfile
,
char
*
incstring
)
{
register
struct
inclist
*
ip
;
/*
* First, put this file on the global list of include files.
*/
ip
=
inclistp
++
;
if
(
inclistp
==
inclist
+
MAXFILES
-
1
)
fatalerr
(
"out of space: increase MAXFILES
\n
"
);
ip
->
i_file
=
copy
(
newfile
);
if
(
incstring
==
NULL
)
ip
->
i_incstring
=
ip
->
i_file
;
else
ip
->
i_incstring
=
copy
(
incstring
);
inclistnext
=
inclistp
;
return
(
ip
);
}
void
included_by
(
struct
inclist
*
ip
,
struct
inclist
*
newfile
)
{
register
int
i
;
if
(
ip
==
NULL
)
return
;
/*
* Put this include file (newfile) on the list of files included
* by 'file'. If 'file' is NULL, then it is not an include
* file itself (i.e. was probably mentioned on the command line).
* If it is already on the list, don't stick it on again.
*/
if
(
ip
->
i_list
==
NULL
)
{
ip
->
i_list
=
(
struct
inclist
**
)
malloc
(
sizeof
(
struct
inclist
*
)
*
++
ip
->
i_listlen
);
ip
->
i_merged
=
(
boolean
*
)
malloc
(
sizeof
(
boolean
)
*
ip
->
i_listlen
);
}
else
{
for
(
i
=
0
;
i
<
ip
->
i_listlen
;
i
++
)
if
(
ip
->
i_list
[
i
]
==
newfile
)
{
i
=
strlen
(
newfile
->
i_file
);
if
(
!
(
ip
->
i_flags
&
INCLUDED_SYM
)
&&
!
(
i
>
2
&&
newfile
->
i_file
[
i
-
1
]
==
'c'
&&
newfile
->
i_file
[
i
-
2
]
==
'.'
))
{
/* only bitch if ip has */
/* no #include SYMBOL lines */
/* and is not a .c file */
if
(
warn_multiple
)
{
warning
(
"%s includes %s more than once!
\n
"
,
ip
->
i_file
,
newfile
->
i_file
);
warning1
(
"Already have
\n
"
);
for
(
i
=
0
;
i
<
ip
->
i_listlen
;
i
++
)
warning1
(
"
\t
%s
\n
"
,
ip
->
i_list
[
i
]
->
i_file
);
}
}
return
;
}
ip
->
i_list
=
(
struct
inclist
**
)
realloc
(
ip
->
i_list
,
sizeof
(
struct
inclist
*
)
*
++
ip
->
i_listlen
);
ip
->
i_merged
=
(
boolean
*
)
realloc
(
ip
->
i_merged
,
sizeof
(
boolean
)
*
ip
->
i_listlen
);
}
ip
->
i_list
[
ip
->
i_listlen
-
1
]
=
newfile
;
ip
->
i_merged
[
ip
->
i_listlen
-
1
]
=
FALSE
;
}
void
inc_clean
(
void
)
{
register
struct
inclist
*
ip
;
for
(
ip
=
inclist
;
ip
<
inclistp
;
ip
++
)
{
ip
->
i_flags
&=
~
MARKED
;
}
}
struct
inclist
*
inc_path
(
char
*
file
,
char
*
include
,
int
type
)
{
static
char
path
[
BUFSIZ
];
register
char
**
pp
,
*
p
;
register
struct
inclist
*
ip
;
struct
stat
st
;
/*
* Check all previously found include files for a path that
* has already been expanded.
*/
if
((
type
==
INCLUDE
)
||
(
type
==
INCLUDEDOT
))
inclistnext
=
inclist
;
ip
=
inclistnext
;
for
(;
ip
->
i_file
;
ip
++
)
{
if
((
strcmp
(
ip
->
i_incstring
,
include
)
==
0
)
&&
!
(
ip
->
i_flags
&
INCLUDED_SYM
))
{
inclistnext
=
ip
+
1
;
return
ip
;
}
}
if
(
inclistnext
==
inclist
)
{
/*
* If the path was surrounded by "" or is an absolute path,
* then check the exact path provided.
*/
if
((
type
==
INCLUDEDOT
)
||
(
type
==
INCLUDENEXTDOT
)
||
(
*
include
==
'/'
))
{
if
(
stat
(
include
,
&
st
)
==
0
)
return
newinclude
(
include
,
include
);
if
(
show_where_not
)
warning1
(
"
\t
not in %s
\n
"
,
include
);
}
/*
* If the path was surrounded by "" see if this include file is
* in the directory of the file being parsed.
*/
if
((
type
==
INCLUDEDOT
)
||
(
type
==
INCLUDENEXTDOT
))
{
for
(
p
=
file
+
strlen
(
file
);
p
>
file
;
p
--
)
if
(
*
p
==
'/'
)
break
;
if
(
p
==
file
)
{
strcpy
(
path
,
include
);
}
else
{
strncpy
(
path
,
file
,
(
p
-
file
)
+
1
);
path
[
(
p
-
file
)
+
1
]
=
'\0'
;
strcpy
(
path
+
(
p
-
file
)
+
1
,
include
);
}
remove_dotdot
(
path
);
if
(
stat
(
path
,
&
st
)
==
0
)
return
newinclude
(
path
,
include
);
if
(
show_where_not
)
warning1
(
"
\t
not in %s
\n
"
,
path
);
}
}
/*
* Check the include directories specified. Standard include dirs
* should be at the end.
*/
if
((
type
==
INCLUDE
)
||
(
type
==
INCLUDEDOT
))
includedirsnext
=
includedirs
;
pp
=
includedirsnext
;
for
(;
*
pp
;
pp
++
)
{
sprintf
(
path
,
"%s/%s"
,
*
pp
,
include
);
remove_dotdot
(
path
);
if
(
stat
(
path
,
&
st
)
==
0
)
{
includedirsnext
=
pp
+
1
;
return
newinclude
(
path
,
include
);
}
if
(
show_where_not
)
warning1
(
"
\t
not in %s
\n
"
,
path
);
}
return
NULL
;
}
nx-X11/config/makedepend/main.c
deleted
100644 → 0
View file @
5b36f644
/* $Xorg: main.c,v 1.5 2001/02/09 02:03:16 xorgcvs Exp $ */
/* $XdotOrg: xc/config/makedepend/main.c,v 1.4 2005/07/05 19:02:01 alanc Exp $ */
/*
Copyright (c) 1993, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/* $XFree86: xc/config/makedepend/main.c,v 3.31tsi Exp $ */
#include "def.h"
#ifdef hpux
#define sigvec sigvector
#endif
/* hpux */
#ifdef X_POSIX_C_SOURCE
#define _POSIX_C_SOURCE X_POSIX_C_SOURCE
#include <signal.h>
#undef _POSIX_C_SOURCE
#else
#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE)
#include <signal.h>
#else
#define _POSIX_SOURCE
#include <signal.h>
#undef _POSIX_SOURCE
#endif
#endif
#include <stdarg.h>
#ifdef DEBUG
int
_debugmask
;
#endif
/* #define DEBUG_DUMP */
#ifdef DEBUG_DUMP
#define DBG_PRINT(file, fmt, args) fprintf(file, fmt, args)
#else
#define DBG_PRINT(file, fmt, args)
/* empty */
#endif
#define DASH_INC_PRE "#include \""
#define DASH_INC_POST "\""
char
*
ProgramName
;
char
*
directives
[]
=
{
"if"
,
"ifdef"
,
"ifndef"
,
"else"
,
"endif"
,
"define"
,
"undef"
,
"include"
,
"line"
,
"pragma"
,
"error"
,
"ident"
,
"sccs"
,
"elif"
,
"eject"
,
"warning"
,
"include_next"
,
NULL
};
#define MAKEDEPEND
#include "imakemdep.h"
/* from config sources */
#undef MAKEDEPEND
struct
inclist
inclist
[
MAXFILES
],
*
inclistp
=
inclist
,
*
inclistnext
=
inclist
,
maininclist
;
static
char
*
filelist
[
MAXFILES
];
char
*
includedirs
[
MAXDIRS
+
1
],
**
includedirsnext
=
includedirs
;
char
*
notdotdot
[
MAXDIRS
];
static
int
cmdinc_count
=
0
;
static
char
*
cmdinc_list
[
2
*
MAXINCFILES
];
char
*
objprefix
=
""
;
char
*
objsuffix
=
OBJSUFFIX
;
static
char
*
startat
=
"# DO NOT DELETE"
;
int
width
=
78
;
static
boolean
append
=
FALSE
;
boolean
printed
=
FALSE
;
boolean
verbose
=
FALSE
;
boolean
show_where_not
=
FALSE
;
/* Warn on multiple includes of same file */
boolean
warn_multiple
=
FALSE
;
static
void
setfile_cmdinc
(
struct
filepointer
*
filep
,
long
count
,
char
**
list
);
static
void
redirect
(
char
*
line
,
char
*
makefile
);
static
#ifdef RETSIGTYPE
RETSIGTYPE
#else
# ifdef SIGNALRETURNSINT
int
# else
void
# endif
#endif
catch
(
int
sig
)
{
fflush
(
stdout
);
fatalerr
(
"got signal %d
\n
"
,
sig
);
}
#if defined(USG) || (defined(i386) && defined(SYSV)) || defined(WIN32) || defined(__UNIXOS2__) || defined(Lynx_22) || defined(__CYGWIN__)
#define USGISH
#endif
#ifndef USGISH
#ifdef X_NOT_POSIX
#define sigaction sigvec
#define sa_handler sv_handler
#define sa_mask sv_mask
#define sa_flags sv_flags
#endif
struct
sigaction
sig_act
;
#endif
/* USGISH */
#ifndef USING_AUTOCONF
# if !defined(USGISH) && !defined(_SEQUENT_) && !defined(MINIX)
# define HAVE_FCHMOD 1
# endif
#endif
int
main
(
int
argc
,
char
*
argv
[])
{
char
**
fp
=
filelist
;
char
**
incp
=
includedirs
;
char
*
p
;
struct
inclist
*
ip
;
char
*
makefile
=
NULL
;
struct
filepointer
*
filecontent
;
struct
symtab
*
psymp
=
predefs
;
char
*
endmarker
=
NULL
;
char
*
defincdir
=
NULL
;
char
**
undeflist
=
NULL
;
int
numundefs
=
0
,
i
;
ProgramName
=
argv
[
0
];
while
(
psymp
->
s_name
)
{
define2
(
psymp
->
s_name
,
psymp
->
s_value
,
&
maininclist
);
psymp
++
;
}
if
(
argc
==
2
&&
argv
[
1
][
0
]
==
'@'
)
{
struct
stat
ast
;
int
afd
;
char
*
args
;
char
**
nargv
;
int
nargc
;
char
quotechar
=
'\0'
;
nargc
=
1
;
if
((
afd
=
open
(
argv
[
1
]
+
1
,
O_RDONLY
))
<
0
)
fatalerr
(
"cannot open
\"
%s
\"\n
"
,
argv
[
1
]
+
1
);
fstat
(
afd
,
&
ast
);
args
=
(
char
*
)
malloc
(
ast
.
st_size
+
1
);
if
((
ast
.
st_size
=
read
(
afd
,
args
,
ast
.
st_size
))
<
0
)
fatalerr
(
"failed to read %s
\n
"
,
argv
[
1
]
+
1
);
args
[
ast
.
st_size
]
=
'\0'
;
close
(
afd
);
for
(
p
=
args
;
*
p
;
p
++
)
{
if
(
quotechar
)
{
if
(
quotechar
==
'\\'
||
(
*
p
==
quotechar
&&
p
[
-
1
]
!=
'\\'
))
quotechar
=
'\0'
;
continue
;
}
switch
(
*
p
)
{
case
'\\'
:
case
'"'
:
case
'\''
:
quotechar
=
*
p
;
break
;
case
' '
:
case
'\n'
:
*
p
=
'\0'
;
if
(
p
>
args
&&
p
[
-
1
])
nargc
++
;
break
;
}
}
if
(
p
[
-
1
])
nargc
++
;
nargv
=
(
char
**
)
malloc
(
nargc
*
sizeof
(
char
*
));
nargv
[
0
]
=
argv
[
0
];
argc
=
1
;
for
(
p
=
args
;
argc
<
nargc
;
p
+=
strlen
(
p
)
+
1
)
if
(
*
p
)
nargv
[
argc
++
]
=
p
;
argv
=
nargv
;
}
for
(
argc
--
,
argv
++
;
argc
;
argc
--
,
argv
++
)
{
/* if looking for endmarker then check before parsing */
if
(
endmarker
&&
strcmp
(
endmarker
,
*
argv
)
==
0
)
{
endmarker
=
NULL
;
continue
;
}
if
(
**
argv
!=
'-'
)
{
/* treat +thing as an option for C++ */
if
(
endmarker
&&
**
argv
==
'+'
)
continue
;
*
fp
++
=
argv
[
0
];
continue
;
}
switch
(
argv
[
0
][
1
])
{
case
'-'
:
endmarker
=
&
argv
[
0
][
2
];
if
(
endmarker
[
0
]
==
'\0'
)
endmarker
=
"--"
;
break
;
case
'D'
:
if
(
argv
[
0
][
2
]
==
'\0'
)
{
argv
++
;
argc
--
;
}
for
(
p
=
argv
[
0
]
+
2
;
*
p
;
p
++
)
if
(
*
p
==
'='
)
{
*
p
=
' '
;
break
;
}
define
(
argv
[
0
]
+
2
,
&
maininclist
);
break
;
case
'I'
:
if
(
incp
>=
includedirs
+
MAXDIRS
)
fatalerr
(
"Too many -I flags.
\n
"
);
*
incp
++
=
argv
[
0
]
+
2
;
if
(
**
(
incp
-
1
)
==
'\0'
)
{
*
(
incp
-
1
)
=
*
(
++
argv
);
argc
--
;
}
break
;
case
'U'
:
/* Undef's override all -D's so save them up */
numundefs
++
;
if
(
numundefs
==
1
)
undeflist
=
malloc
(
sizeof
(
char
*
));
else
undeflist
=
realloc
(
undeflist
,
numundefs
*
sizeof
(
char
*
));
if
(
argv
[
0
][
2
]
==
'\0'
)
{
argv
++
;
argc
--
;
}
undeflist
[
numundefs
-
1
]
=
argv
[
0
]
+
2
;
break
;
case
'Y'
:
defincdir
=
argv
[
0
]
+
2
;
break
;
/* do not use if endmarker processing */
case
'a'
:
if
(
endmarker
)
break
;
append
=
TRUE
;
break
;
case
'w'
:
if
(
endmarker
)
break
;
if
(
argv
[
0
][
2
]
==
'\0'
)
{
argv
++
;
argc
--
;
width
=
atoi
(
argv
[
0
]);
}
else
width
=
atoi
(
argv
[
0
]
+
2
);
break
;
case
'o'
:
if
(
endmarker
)
break
;
if
(
argv
[
0
][
2
]
==
'\0'
)
{
argv
++
;
argc
--
;
objsuffix
=
argv
[
0
];
}
else
objsuffix
=
argv
[
0
]
+
2
;
break
;
case
'p'
:
if
(
endmarker
)
break
;
if
(
argv
[
0
][
2
]
==
'\0'
)
{
argv
++
;
argc
--
;
objprefix
=
argv
[
0
];
}
else
objprefix
=
argv
[
0
]
+
2
;
break
;
case
'v'
:
if
(
endmarker
)
break
;
verbose
=
TRUE
;
#ifdef DEBUG
if
(
argv
[
0
][
2
])
_debugmask
=
atoi
(
argv
[
0
]
+
2
);
#endif
break
;
case
's'
:
if
(
endmarker
)
break
;
startat
=
argv
[
0
]
+
2
;
if
(
*
startat
==
'\0'
)
{
startat
=
*
(
++
argv
);
argc
--
;
}
if
(
*
startat
!=
'#'
)
fatalerr
(
"-s flag's value should start %s
\n
"
,
"with '#'."
);
break
;
case
'f'
:
if
(
endmarker
)
break
;
makefile
=
argv
[
0
]
+
2
;
if
(
*
makefile
==
'\0'
)
{
makefile
=
*
(
++
argv
);
argc
--
;
}
break
;
case
'm'
:
warn_multiple
=
TRUE
;
break
;
/* Ignore -O, -g so we can just pass ${CFLAGS} to
makedepend
*/
case
'O'
:
case
'g'
:
break
;
case
'i'
:
if
(
strcmp
(
&
argv
[
0
][
1
],
"include"
)
==
0
)
{
char
*
buf
;
if
(
argc
<
2
)
fatalerr
(
"option -include is a "
"missing its parameter
\n
"
);
if
(
cmdinc_count
>=
MAXINCFILES
)
fatalerr
(
"Too many -include flags.
\n
"
);
argc
--
;
argv
++
;
buf
=
malloc
(
strlen
(
DASH_INC_PRE
)
+
strlen
(
argv
[
0
])
+
strlen
(
DASH_INC_POST
)
+
1
);
if
(
!
buf
)
fatalerr
(
"out of memory at "
"-include string
\n
"
);
cmdinc_list
[
2
*
cmdinc_count
+
0
]
=
argv
[
0
];
cmdinc_list
[
2
*
cmdinc_count
+
1
]
=
buf
;
cmdinc_count
++
;
break
;
}
/* intentional fall through */
default:
if
(
endmarker
)
break
;
/* fatalerr("unknown opt = %s\n", argv[0]); */
warning
(
"ignoring option %s
\n
"
,
argv
[
0
]);
}
}
/* Now do the undefs from the command line */
for
(
i
=
0
;
i
<
numundefs
;
i
++
)
undefine
(
undeflist
[
i
],
&
maininclist
);
if
(
numundefs
>
0
)
free
(
undeflist
);
if
(
!
defincdir
)
{
#ifdef PREINCDIR
if
(
incp
>=
includedirs
+
MAXDIRS
)
fatalerr
(
"Too many -I flags.
\n
"
);
*
incp
++
=
PREINCDIR
;
#endif
#ifdef __UNIXOS2__
{
char
*
emxinc
=
getenv
(
"C_INCLUDE_PATH"
);
/* can have more than one component */
if
(
emxinc
)
{
char
*
beg
,
*
end
;
beg
=
(
char
*
)
strdup
(
emxinc
);
for
(;;)
{
end
=
(
char
*
)
strchr
(
beg
,
';'
);
if
(
end
)
*
end
=
0
;
if
(
incp
>=
includedirs
+
MAXDIRS
)
fatalerr
(
"Too many include dirs
\n
"
);
*
incp
++
=
beg
;
if
(
!
end
)
break
;
beg
=
end
+
1
;
}
}
}
#else
/* !__UNIXOS2__, does not use INCLUDEDIR at all */
if
(
incp
>=
includedirs
+
MAXDIRS
)
fatalerr
(
"Too many -I flags.
\n
"
);
*
incp
++
=
INCLUDEDIR
;
#endif
#ifdef EXTRAINCDIR
if
(
incp
>=
includedirs
+
MAXDIRS
)
fatalerr
(
"Too many -I flags.
\n
"
);
*
incp
++
=
EXTRAINCDIR
;
#endif
#ifdef POSTINCDIR
if
(
incp
>=
includedirs
+
MAXDIRS
)
fatalerr
(
"Too many -I flags.
\n
"
);
*
incp
++
=
POSTINCDIR
;
#endif
}
else
if
(
*
defincdir
)
{
if
(
incp
>=
includedirs
+
MAXDIRS
)
fatalerr
(
"Too many -I flags.
\n
"
);
*
incp
++
=
defincdir
;
}
redirect
(
startat
,
makefile
);
/*
* catch signals.
*/
#ifdef USGISH
/* should really reset SIGINT to SIG_IGN if it was. */
#ifdef SIGHUP
signal
(
SIGHUP
,
catch
);
#endif
signal
(
SIGINT
,
catch
);
#ifdef SIGQUIT
signal
(
SIGQUIT
,
catch
);
#endif
signal
(
SIGILL
,
catch
);
#ifdef SIGBUS
signal
(
SIGBUS
,
catch
);
#endif
signal
(
SIGSEGV
,
catch
);
#ifdef SIGSYS
signal
(
SIGSYS
,
catch
);
#endif
#else
sig_act
.
sa_handler
=
catch
;
#if defined(_POSIX_SOURCE) || !defined(X_NOT_POSIX)
sigemptyset
(
&
sig_act
.
sa_mask
);
sigaddset
(
&
sig_act
.
sa_mask
,
SIGINT
);
sigaddset
(
&
sig_act
.
sa_mask
,
SIGQUIT
);
#ifdef SIGBUS
sigaddset
(
&
sig_act
.
sa_mask
,
SIGBUS
);
#endif
sigaddset
(
&
sig_act
.
sa_mask
,
SIGILL
);
sigaddset
(
&
sig_act
.
sa_mask
,
SIGSEGV
);
sigaddset
(
&
sig_act
.
sa_mask
,
SIGHUP
);
sigaddset
(
&
sig_act
.
sa_mask
,
SIGPIPE
);
#ifdef SIGSYS
sigaddset
(
&
sig_act
.
sa_mask
,
SIGSYS
);
#endif
#else
sig_act
.
sa_mask
=
((
1
<<
(
SIGINT
-
1
))
|
(
1
<<
(
SIGQUIT
-
1
))
#ifdef SIGBUS
|
(
1
<<
(
SIGBUS
-
1
))
#endif
|
(
1
<<
(
SIGILL
-
1
))
|
(
1
<<
(
SIGSEGV
-
1
))
|
(
1
<<
(
SIGHUP
-
1
))
|
(
1
<<
(
SIGPIPE
-
1
))
#ifdef SIGSYS
|
(
1
<<
(
SIGSYS
-
1
))
#endif
);
#endif
/* _POSIX_SOURCE */
sig_act
.
sa_flags
=
0
;
sigaction
(
SIGHUP
,
&
sig_act
,
(
struct
sigaction
*
)
0
);
sigaction
(
SIGINT
,
&
sig_act
,
(
struct
sigaction
*
)
0
);
sigaction
(
SIGQUIT
,
&
sig_act
,
(
struct
sigaction
*
)
0
);
sigaction
(
SIGILL
,
&
sig_act
,
(
struct
sigaction
*
)
0
);
#ifdef SIGBUS
sigaction
(
SIGBUS
,
&
sig_act
,
(
struct
sigaction
*
)
0
);
#endif
sigaction
(
SIGSEGV
,
&
sig_act
,
(
struct
sigaction
*
)
0
);
#ifdef SIGSYS
sigaction
(
SIGSYS
,
&
sig_act
,
(
struct
sigaction
*
)
0
);
#endif
#endif
/* USGISH */
/*
* now peruse through the list of files.
*/
for
(
fp
=
filelist
;
*
fp
;
fp
++
)
{
DBG_PRINT
(
stderr
,
"file: %s
\n
"
,
*
fp
);
filecontent
=
getfile
(
*
fp
);
setfile_cmdinc
(
filecontent
,
cmdinc_count
,
cmdinc_list
);
ip
=
newinclude
(
*
fp
,
(
char
*
)
NULL
);
find_includes
(
filecontent
,
ip
,
ip
,
0
,
FALSE
);
freefile
(
filecontent
);
recursive_pr_include
(
ip
,
ip
->
i_file
,
base_name
(
*
fp
));
inc_clean
();
}
if
(
printed
)
printf
(
"
\n
"
);
return
0
;
}
#ifdef __UNIXOS2__
/*
* eliminate \r chars from file
*/
static
int
elim_cr
(
char
*
buf
,
int
sz
)
{
int
i
,
wp
;
for
(
i
=
wp
=
0
;
i
<
sz
;
i
++
)
{
if
(
buf
[
i
]
!=
'\r'
)
buf
[
wp
++
]
=
buf
[
i
];
}
return
wp
;
}
#endif
struct
filepointer
*
getfile
(
char
*
file
)
{
int
fd
;
struct
filepointer
*
content
;
struct
stat
st
;
content
=
(
struct
filepointer
*
)
malloc
(
sizeof
(
struct
filepointer
));
content
->
f_name
=
file
;
if
((
fd
=
open
(
file
,
O_RDONLY
))
<
0
)
{
warning
(
"cannot open
\"
%s
\"\n
"
,
file
);
content
->
f_p
=
content
->
f_base
=
content
->
f_end
=
(
char
*
)
malloc
(
1
);
*
content
->
f_p
=
'\0'
;
return
(
content
);
}
fstat
(
fd
,
&
st
);
content
->
f_base
=
(
char
*
)
malloc
(
st
.
st_size
+
1
);
if
(
content
->
f_base
==
NULL
)
fatalerr
(
"cannot allocate mem
\n
"
);
if
((
st
.
st_size
=
read
(
fd
,
content
->
f_base
,
st
.
st_size
))
<
0
)
fatalerr
(
"failed to read %s
\n
"
,
file
);
#ifdef __UNIXOS2__
st
.
st_size
=
elim_cr
(
content
->
f_base
,
st
.
st_size
);
#endif
close
(
fd
);
content
->
f_len
=
st
.
st_size
+
1
;
content
->
f_p
=
content
->
f_base
;
content
->
f_end
=
content
->
f_base
+
st
.
st_size
;
*
content
->
f_end
=
'\0'
;
content
->
f_line
=
0
;
content
->
cmdinc_count
=
0
;
content
->
cmdinc_list
=
NULL
;
content
->
cmdinc_line
=
0
;
return
(
content
);
}
void
setfile_cmdinc
(
struct
filepointer
*
filep
,
long
count
,
char
**
list
)
{
filep
->
cmdinc_count
=
count
;
filep
->
cmdinc_list
=
list
;
filep
->
cmdinc_line
=
0
;
}
void
freefile
(
struct
filepointer
*
fp
)
{
free
(
fp
->
f_base
);
free
(
fp
);
}
char
*
copy
(
char
*
str
)
{
char
*
p
=
(
char
*
)
malloc
(
strlen
(
str
)
+
1
);
strcpy
(
p
,
str
);
return
(
p
);
}
int
match
(
char
*
str
,
char
**
list
)
{
int
i
;
for
(
i
=
0
;
*
list
;
i
++
,
list
++
)
if
(
strcmp
(
str
,
*
list
)
==
0
)
return
(
i
);
return
(
-
1
);
}
/*
* Get the next line. We only return lines beginning with '#' since that
* is all this program is ever interested in.
*/
char
*
getnextline
(
struct
filepointer
*
filep
)
{
char
*
p
,
/* walking pointer */
*
eof
,
/* end of file pointer */
*
bol
;
/* beginning of line pointer */
int
lineno
;
/* line number */
boolean
whitespace
=
FALSE
;
/*
* Fake the "-include" line files in form of #include to the
* start of each file.
*/
if
(
filep
->
cmdinc_line
<
filep
->
cmdinc_count
)
{
char
*
inc
=
filep
->
cmdinc_list
[
2
*
filep
->
cmdinc_line
+
0
];
char
*
buf
=
filep
->
cmdinc_list
[
2
*
filep
->
cmdinc_line
+
1
];
filep
->
cmdinc_line
++
;
sprintf
(
buf
,
"%s%s%s"
,
DASH_INC_PRE
,
inc
,
DASH_INC_POST
);
DBG_PRINT
(
stderr
,
"%s
\n
"
,
buf
);
return
(
buf
);
}
p
=
filep
->
f_p
;
eof
=
filep
->
f_end
;
if
(
p
>=
eof
)
return
((
char
*
)
NULL
);
lineno
=
filep
->
f_line
;
for
(
bol
=
p
--
;
++
p
<
eof
;
)
{
if
((
bol
==
p
)
&&
((
*
p
==
' '
)
||
(
*
p
==
'\t'
)))
{
/* Consume leading white-spaces for this line */
while
(((
p
+
1
)
<
eof
)
&&
((
*
p
==
' '
)
||
(
*
p
==
'\t'
)))
{
p
++
;
bol
++
;
}
whitespace
=
TRUE
;
}
if
(
*
p
==
'/'
&&
(
p
+
1
)
<
eof
&&
*
(
p
+
1
)
==
'*'
)
{
/* Consume C comments */
*
(
p
++
)
=
' '
;
*
(
p
++
)
=
' '
;
while
(
p
<
eof
&&
*
p
)
{
if
(
*
p
==
'*'
&&
(
p
+
1
)
<
eof
&&
*
(
p
+
1
)
==
'/'
)
{
*
(
p
++
)
=
' '
;
*
(
p
++
)
=
' '
;
break
;
}
if
(
*
p
==
'\n'
)
lineno
++
;
*
(
p
++
)
=
' '
;
}
--
p
;
}
else
if
(
*
p
==
'/'
&&
(
p
+
1
)
<
eof
&&
*
(
p
+
1
)
==
'/'
)
{
/* Consume C++ comments */
*
(
p
++
)
=
' '
;
*
(
p
++
)
=
' '
;
while
(
p
<
eof
&&
*
p
)
{
if
(
*
p
==
'\\'
&&
(
p
+
1
)
<
eof
&&
*
(
p
+
1
)
==
'\n'
)
{
*
(
p
++
)
=
' '
;
lineno
++
;
}
else
if
(
*
p
==
'?'
&&
(
p
+
3
)
<
eof
&&
*
(
p
+
1
)
==
'?'
&&
*
(
p
+
2
)
==
'/'
&&
*
(
p
+
3
)
==
'\n'
)
{
*
(
p
++
)
=
' '
;
*
(
p
++
)
=
' '
;
*
(
p
++
)
=
' '
;
lineno
++
;
}
else
if
(
*
p
==
'\n'
)
break
;
/* to process end of line */
*
(
p
++
)
=
' '
;
}
--
p
;
}
else
if
(
*
p
==
'\\'
&&
(
p
+
1
)
<
eof
&&
*
(
p
+
1
)
==
'\n'
)
{
/* Consume backslash line terminations */
*
(
p
++
)
=
' '
;
*
p
=
' '
;
lineno
++
;
}
else
if
(
*
p
==
'?'
&&
(
p
+
3
)
<
eof
&&
*
(
p
+
1
)
==
'?'
&&
*
(
p
+
2
)
==
'/'
&&
*
(
p
+
3
)
==
'\n'
)
{
/* Consume trigraph'ed backslash line terminations */
*
(
p
++
)
=
' '
;
*
(
p
++
)
=
' '
;
*
(
p
++
)
=
' '
;
*
p
=
' '
;
lineno
++
;
}
else
if
(
*
p
==
'\n'
)
{
lineno
++
;
if
(
*
bol
==
'#'
)
{
char
*
cp
;
*
(
p
++
)
=
'\0'
;
/* punt lines with just # (yacc generated) */
for
(
cp
=
bol
+
1
;
*
cp
&&
(
*
cp
==
' '
||
*
cp
==
'\t'
);
cp
++
);
if
(
*
cp
)
goto
done
;
--
p
;
}
bol
=
p
+
1
;
whitespace
=
FALSE
;
}
}
if
(
*
bol
!=
'#'
)
bol
=
NULL
;
done:
filep
->
f_p
=
p
;
filep
->
f_line
=
lineno
;
#ifdef DEBUG_DUMP
if
(
bol
)
DBG_PRINT
(
stderr
,
"%s
\n
"
,
bol
);
#endif
return
(
bol
);
}
/*
* Strip the file name down to what we want to see in the Makefile.
* It will have objprefix and objsuffix around it.
*/
char
*
base_name
(
char
*
file
)
{
char
*
p
;
file
=
copy
(
file
);
for
(
p
=
file
+
strlen
(
file
);
p
>
file
&&
*
p
!=
'.'
;
p
--
)
;
if
(
*
p
==
'.'
)
*
p
=
'\0'
;
return
(
file
);
}
#ifdef USING_AUTOCONF
# ifndef HAVE_RENAME
# define NEED_RENAME
# endif
#else
/* Imake configured, check known OS'es without rename() */
# if defined(USG) && !defined(SVR4) && !defined(__UNIXOS2__) && !defined(clipper) && !defined(__clipper__)
# define NEED_RENAME
# endif
#endif
#ifdef NEED_RENAME
int
rename
(
char
*
from
,
char
*
to
)
{
(
void
)
unlink
(
to
);
if
(
link
(
from
,
to
)
==
0
)
{
unlink
(
from
);
return
0
;
}
else
{
return
-
1
;
}
}
#endif
/* NEED_RENAME */
void
redirect
(
char
*
line
,
char
*
makefile
)
{
struct
stat
st
;
FILE
*
fdin
,
*
fdout
;
char
backup
[
BUFSIZ
],
buf
[
BUFSIZ
];
boolean
found
=
FALSE
;
int
len
;
/*
* if makefile is "-" then let it pour onto stdout.
*/
if
(
makefile
&&
*
makefile
==
'-'
&&
*
(
makefile
+
1
)
==
'\0'
)
{
puts
(
line
);
return
;
}
/*
* use a default makefile is not specified.
*/
if
(
!
makefile
)
{
if
(
stat
(
"Makefile"
,
&
st
)
==
0
)
makefile
=
"Makefile"
;
else
if
(
stat
(
"makefile"
,
&
st
)
==
0
)
makefile
=
"makefile"
;
else
fatalerr
(
"[mM]akefile is not present
\n
"
);
}
else
stat
(
makefile
,
&
st
);
if
((
fdin
=
fopen
(
makefile
,
"r"
))
==
NULL
)
fatalerr
(
"cannot open
\"
%s
\"\n
"
,
makefile
);
sprintf
(
backup
,
"%s.bak"
,
makefile
);
unlink
(
backup
);
#if defined(WIN32) || defined(__UNIXOS2__) || defined(__CYGWIN__)
fclose
(
fdin
);
#endif
if
(
rename
(
makefile
,
backup
)
<
0
)
fatalerr
(
"cannot rename %s to %s
\n
"
,
makefile
,
backup
);
#if defined(WIN32) || defined(__UNIXOS2__) || defined(__CYGWIN__)
if
((
fdin
=
fopen
(
backup
,
"r"
))
==
NULL
)
fatalerr
(
"cannot open
\"
%s
\"\n
"
,
backup
);
#endif
if
((
fdout
=
freopen
(
makefile
,
"w"
,
stdout
))
==
NULL
)
fatalerr
(
"cannot open
\"
%s
\"\n
"
,
backup
);
len
=
strlen
(
line
);
while
(
!
found
&&
fgets
(
buf
,
BUFSIZ
,
fdin
))
{
if
(
*
buf
==
'#'
&&
strncmp
(
line
,
buf
,
len
)
==
0
)
found
=
TRUE
;
fputs
(
buf
,
fdout
);
}
if
(
!
found
)
{
if
(
verbose
)
warning
(
"Adding new delimiting line
\"
%s
\"
and dependencies...
\n
"
,
line
);
puts
(
line
);
/* same as fputs(fdout); but with newline */
}
else
if
(
append
)
{
while
(
fgets
(
buf
,
BUFSIZ
,
fdin
))
{
fputs
(
buf
,
fdout
);
}
}
fflush
(
fdout
);
#ifndef HAVE_FCHMOD
chmod
(
makefile
,
st
.
st_mode
);
#else
fchmod
(
fileno
(
fdout
),
st
.
st_mode
);
#endif
/* HAVE_FCHMOD */
}
void
fatalerr
(
char
*
msg
,
...)
{
va_list
args
;
fprintf
(
stderr
,
"%s: error: "
,
ProgramName
);
va_start
(
args
,
msg
);
vfprintf
(
stderr
,
msg
,
args
);
va_end
(
args
);
exit
(
1
);
}
void
warning
(
char
*
msg
,
...)
{
va_list
args
;
fprintf
(
stderr
,
"%s: warning: "
,
ProgramName
);
va_start
(
args
,
msg
);
vfprintf
(
stderr
,
msg
,
args
);
va_end
(
args
);
}
void
warning1
(
char
*
msg
,
...)
{
va_list
args
;
va_start
(
args
,
msg
);
vfprintf
(
stderr
,
msg
,
args
);
va_end
(
args
);
}
nx-X11/config/makedepend/mkdepend.man
deleted
100644 → 0
View file @
5b36f644
.\" $Xorg: mkdepend.man,v 1.5 2001/02/09 02:03:16 xorgcvs Exp $
.\" Copyright (c) 1993, 1994, 1998 The Open Group
.\"
.\" Permission to use, copy, modify, distribute, and sell this software and its
.\" documentation for any purpose is hereby granted without fee, provided that
.\" the above copyright notice appear in all copies and that both that
.\" copyright notice and this permission notice appear in supporting
.\" documentation.
.\"
.\" The above copyright notice and this permission notice shall be included in
.\" all copies or substantial portions of the Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
.\" THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
.\" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
.\" OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
.\" SOFTWARE.
.\"
.\" Except as contained in this notice, the name of The Open Group shall not
.\" be used in advertising or otherwise to promote the sale, use or other
.\" dealing in this Software without prior written authorization from The
.\" Open Group.
.\"
.\" $XFree86: xc/config/makedepend/mkdepend.man,v 1.6 2001/12/17 20:52:22 dawes Exp $
.\"
.TH MAKEDEPEND 1 __xorgversion__
.UC 4
.SH NAME
makedepend \- create dependencies in makefiles
.SH SYNOPSIS
.B makedepend
[
.BI \-D name\fB=\fPdef
] [
.BI \-D name
] [
.BI \-I includedir
] [
.BI \-Y includedir
] [
.B \-a
] [
.BI \-f makefile
] [
.BI \-include \ file
] [
.BI \-o objsuffix
] [
.BI \-p objprefix
] [
.BI \-s string
] [
.BI \-w width
] [
.B \-v
] [
.B \-m
] [
\-\^\-
.I otheroptions
\-\^\-
]
.I sourcefile
\&.\|.\|.
.br
.SH DESCRIPTION
The
.B makedepend
program reads each
.I sourcefile
in sequence and parses it like a C-preprocessor,
processing all
.I #include,
.I #define,
.I #undef,
.I #ifdef,
.I #ifndef,
.I #endif,
.I #if,
.I #elif
and
.I #else
directives so that it can correctly tell which
.I #include,
directives would be used in a compilation.
Any
.I #include,
directives can reference files having other
.I #include
directives, and parsing will occur in these files as well.
.PP
Every file that a
.I sourcefile
includes,
directly or indirectly,
is what
.B makedepend
calls a \fIdependency.\fP
These dependencies are then written to a
.I makefile
in such a way that
.B make(1)
will know which object files must be recompiled when a dependency has changed.
.PP
By default,
.B makedepend
places its output in the file named
.I makefile
if it exists, otherwise
.I Makefile.
An alternate makefile may be specified with the
.B \-f
option.
It first searches the makefile for
the line
.sp
\& # DO NOT DELETE THIS LINE \-\^\- make depend depends on it.
.sp
or one provided with the
.B \-s
option,
as a delimiter for the dependency output.
If it finds it, it will delete everything
following this to the end of the makefile
and put the output after this line.
If it doesn't find it, the program
will append the string to the end of the makefile
and place the output following that.
For each
.I sourcefile
appearing on the command line,
.B makedepend
puts lines in the makefile of the form
.sp
sourcefile.o:\0dfile .\|.\|.
.sp
Where \fIsourcefile.o\fP is the name from the command
line with its suffix replaced with ``.o'',
and \fIdfile\fP is a dependency discovered in a
.I #include
directive while parsing
.I sourcefile
or one of the files it included.
.SH EXAMPLE
Normally,
.B makedepend
will be used in a makefile target so that typing ``make depend'' will
bring the dependencies up to date for the makefile.
For example,
.nf
SRCS\0=\0file1.c\0file2.c\0.\|.\|.
CFLAGS\0=\0\-O\0\-DHACK\0\-I\^.\^.\^/foobar\0\-xyz
depend:
makedepend\0\-\^\-\0$(CFLAGS)\0\-\^\-\0$(SRCS)
.fi
.SH OPTIONS
The program
will ignore any option that it does not understand so that you may use
the same arguments that you would for
.B cc(1).
.TP 5
.B \-D\fIname\fP=\fIdef\fP \fRor\fP \-D\fIname\fP
Define.
This places a definition for
.I name
in
.B makedepend's
symbol table.
Without
.I =def\|
the symbol becomes defined as ``1''.
.TP 5
.B \-I\fIincludedir\fP
Include directory.
This option tells
.B makedepend
to prepend
.I includedir
to its list of directories to search when it encounters
a
.I #include
directive.
By default,
.B makedepend
only searches the standard include directories (usually /usr/include
and possibly a compiler-dependent directory).
.TP 5
.B \-Y\fIincludedir\fP
Replace all of the standard include directories with the single specified
include directory; you can omit the
.I includedir
to simply prevent searching the standard include directories.
.TP 5
.B \-a
Append the dependencies to the end of the file instead of replacing them.
.TP 5
.B \-f\fImakefile\fP
Filename.
This allows you to specify an alternate makefile in which
.B makedepend
can place its output.
Specifying ``\-'' as the file name (i.e., \fB\-f\-\fP) sends the
output to standard output instead of modifying an existing file.
.TP 5
.B \-include \fIfile\fP
Process file as input, and include all the resulting output
before processing the regular input file. This has the same
affect as if the specified file is an include statement that
appears before the very first line of the regular input file.
.TP 5
.B \-o\fIobjsuffix\fP
Object file suffix.
Some systems may have object files whose suffix is something other
than ``.o''.
This option allows you to specify another suffix, such as
``.b'' with
.I \-o.b
or ``:obj''
with
.I \-o:obj
and so forth.
.TP 5
.B \-p\fIobjprefix\fP
Object file prefix.
The prefix is prepended to the name of the object file. This is
usually used to designate a different directory for the object file.
The default is the empty string.
.TP 5
.B \-s\fIstring\fP
Starting string delimiter.
This option permits you to specify
a different string for
.B makedepend
to look for in the makefile.
.TP 5
.B \-w\fIwidth\fP
Line width.
Normally,
.B makedepend
will ensure that every output line that it writes will be no wider than
78 characters for the sake of readability.
This option enables you to change this width.
.TP 5
.B \-v
Verbose operation.
This option causes
.B makedepend
to emit the list of files included by each input file.
.TP 5
.B \-m
Warn about multiple inclusion.
This option causes
.B makedepend
to produce a warning if any input file includes another file more than
once. In previous versions of
.B makedepend
this was the default behavior; the default has been changed to better
match the behavior of the C compiler, which does not consider multiple
inclusion to be an error. This option is provided for backward
compatibility, and to aid in debugging problems related to multiple
inclusion.
.TP 5
.B "\-\^\- \fIoptions\fP \-\^\-"
If
.B makedepend
encounters a double hyphen (\-\^\-) in the argument list,
then any unrecognized argument following it
will be silently ignored; a second double hyphen terminates this
special treatment.
In this way,
.B makedepend
can be made to safely ignore esoteric compiler arguments that might
normally be found in a CFLAGS
.B make
macro (see the
.B EXAMPLE
section above).
All options that
.B makedepend
recognizes and appear between the pair of double hyphens
are processed normally.
.SH ALGORITHM
The approach used in this program enables it to run an order of magnitude
faster than any other ``dependency generator'' I have ever seen.
Central to this performance are two assumptions:
that all files compiled by a single
makefile will be compiled with roughly the same
.I \-I
and
.I \-D
options;
and that most files in a single directory will include largely the
same files.
.PP
Given these assumptions,
.B makedepend
expects to be called once for each makefile, with
all source files that are maintained by the
makefile appearing on the command line.
It parses each source and include
file exactly once, maintaining an internal symbol table
for each.
Thus, the first file on the command line will take an amount of time
proportional to the amount of time that a normal C preprocessor takes.
But on subsequent files, if it encounters an include file
that it has already parsed, it does not parse it again.
.PP
For example,
imagine you are compiling two files,
.I file1.c
and
.I file2.c,
they each include the header file
.I header.h,
and the file
.I header.h
in turn includes the files
.I def1.h
and
.I def2.h.
When you run the command
.sp
makedepend\0file1.c\0file2.c
.sp
.B makedepend
will parse
.I file1.c
and consequently,
.I header.h
and then
.I def1.h
and
.I def2.h.
It then decides that the dependencies for this file are
.sp
file1.o:\0header.h\0def1.h\0def2.h
.sp
But when the program parses
.I file2.c
and discovers that it, too, includes
.I header.h,
it does not parse the file,
but simply adds
.I header.h,
.I def1.h
and
.I def2.h
to the list of dependencies for
.I file2.o.
.SH "SEE ALSO"
cc(1), make(1)
.SH BUGS
.B makedepend
parses, but does not currently evaluate, the SVR4 #predicate(token-list)
preprocessor expression; such expressions are simply assumed to be true.
This may cause the wrong
.I #include
directives to be evaluated.
.PP
Imagine you are parsing two files,
say
.I file1.c
and
.I file2.c,
each includes the file
.I def.h.
The list of files that
.I def.h
includes might truly be different when
.I def.h
is included by
.I file1.c
than when it is included by
.I file2.c.
But once
.B makedepend
arrives at a list of dependencies for a file,
it is cast in concrete.
.SH AUTHOR
Todd Brunhoff, Tektronix, Inc. and MIT Project Athena
nx-X11/config/makedepend/parse.c
deleted
100644 → 0
View file @
5b36f644
/* $Xorg: parse.c,v 1.6 2001/02/09 02:03:16 xorgcvs Exp $ */
/*
Copyright (c) 1993, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/* $XFree86: xc/config/makedepend/parse.c,v 1.11 2001/12/17 20:52:22 dawes Exp $ */
#include "def.h"
extern
char
*
directives
[];
extern
struct
inclist
inclist
[
MAXFILES
],
*
inclistnext
,
maininclist
;
extern
char
*
includedirs
[
],
**
includedirsnext
;
static
int
deftype
(
char
*
line
,
struct
filepointer
*
filep
,
struct
inclist
*
file_red
,
struct
inclist
*
file
,
int
parse_it
);
static
int
zero_value
(
char
*
filename
,
char
*
exp
,
struct
filepointer
*
filep
,
struct
inclist
*
file_red
);
static
int
merge2defines
(
struct
inclist
*
file1
,
struct
inclist
*
file2
);
static
int
gobble
(
struct
filepointer
*
filep
,
struct
inclist
*
file
,
struct
inclist
*
file_red
)
{
char
*
line
;
int
type
;
while
((
line
=
getnextline
(
filep
)))
{
switch
(
type
=
deftype
(
line
,
filep
,
file_red
,
file
,
FALSE
))
{
case
IF
:
case
IFFALSE
:
case
IFGUESSFALSE
:
case
IFDEF
:
case
IFNDEF
:
type
=
gobble
(
filep
,
file
,
file_red
);
while
((
type
==
ELIF
)
||
(
type
==
ELIFFALSE
)
||
(
type
==
ELIFGUESSFALSE
))
type
=
gobble
(
filep
,
file
,
file_red
);
if
(
type
==
ELSE
)
(
void
)
gobble
(
filep
,
file
,
file_red
);
break
;
case
ELSE
:
case
ENDIF
:
debug
(
0
,(
"%s, line %d: #%s
\n
"
,
file
->
i_file
,
filep
->
f_line
,
directives
[
type
]));
return
(
type
);
case
DEFINE
:
case
UNDEF
:
case
INCLUDE
:
case
INCLUDEDOT
:
case
PRAGMA
:
case
ERROR
:
case
IDENT
:
case
SCCS
:
case
EJECT
:
case
WARNING
:
case
INCLUDENEXT
:
case
INCLUDENEXTDOT
:
break
;
case
ELIF
:
case
ELIFFALSE
:
case
ELIFGUESSFALSE
:
return
(
type
);
case
-
1
:
warning
(
"%s"
,
file_red
->
i_file
);
if
(
file_red
!=
file
)
warning1
(
" (reading %s)"
,
file
->
i_file
);
warning1
(
", line %d: unknown directive ==
\"
%s
\"\n
"
,
filep
->
f_line
,
line
);
break
;
}
}
return
(
-
1
);
}
/*
* Decide what type of # directive this line is.
*/
static
int
deftype
(
char
*
line
,
struct
filepointer
*
filep
,
struct
inclist
*
file_red
,
struct
inclist
*
file
,
int
parse_it
)
{
register
char
*
p
;
char
*
directive
,
savechar
,
*
q
;
register
int
ret
;
/*
* Parse the directive...
*/
directive
=
line
+
1
;
while
(
*
directive
==
' '
||
*
directive
==
'\t'
)
directive
++
;
p
=
directive
;
while
((
*
p
==
'_'
)
||
(
*
p
>=
'a'
&&
*
p
<=
'z'
))
p
++
;
savechar
=
*
p
;
*
p
=
'\0'
;
ret
=
match
(
directive
,
directives
);
*
p
=
savechar
;
/* If we don't recognize this compiler directive or we happen to just
* be gobbling up text while waiting for an #endif or #elif or #else
* in the case of an #elif we must check the zero_value and return an
* ELIF or an ELIFFALSE.
*/
if
(
ret
==
ELIF
&&
!
parse_it
)
{
while
(
*
p
==
' '
||
*
p
==
'\t'
)
p
++
;
/*
* parse an expression.
*/
debug
(
0
,(
"%s, line %d: #elif %s "
,
file
->
i_file
,
filep
->
f_line
,
p
));
ret
=
zero_value
(
file
->
i_file
,
p
,
filep
,
file_red
);
if
(
ret
!=
IF
)
{
debug
(
0
,(
"false...
\n
"
));
if
(
ret
==
IFFALSE
)
return
(
ELIFFALSE
);
else
return
(
ELIFGUESSFALSE
);
}
else
{
debug
(
0
,(
"true...
\n
"
));
return
(
ELIF
);
}
}
if
(
ret
<
0
||
!
parse_it
)
return
(
ret
);
/*
* now decide how to parse the directive, and do it.
*/
while
(
*
p
==
' '
||
*
p
==
'\t'
)
p
++
;
q
=
p
+
strlen
(
p
);
do
{
q
--
;
}
while
(
*
q
==
' '
||
*
q
==
'\t'
);
q
[
1
]
=
'\0'
;
switch
(
ret
)
{
case
IF
:
/*
* parse an expression.
*/
ret
=
zero_value
(
file
->
i_file
,
p
,
filep
,
file_red
);
debug
(
0
,(
"%s, line %d: %s #if %s
\n
"
,
file
->
i_file
,
filep
->
f_line
,
ret
?
"false"
:
"true"
,
p
));
break
;
case
IFDEF
:
case
IFNDEF
:
debug
(
0
,(
"%s, line %d: #%s %s
\n
"
,
file
->
i_file
,
filep
->
f_line
,
directives
[
ret
],
p
));
case
UNDEF
:
/*
* separate the name of a single symbol.
*/
while
(
isalnum
(
*
p
)
||
*
p
==
'_'
)
*
line
++
=
*
p
++
;
*
line
=
'\0'
;
break
;
case
INCLUDE
:
case
INCLUDENEXT
:
debug
(
2
,(
"%s, line %d: #include%s %s
\n
"
,
file
->
i_file
,
filep
->
f_line
,
(
ret
==
INCLUDE
)
?
""
:
"_next"
,
p
));
/* Support ANSI macro substitution */
while
(
1
)
{
struct
symtab
**
sym
;
if
(
!*
p
||
*
p
==
'"'
||
*
p
==
'<'
)
break
;
sym
=
isdefined
(
p
,
file_red
,
NULL
);
if
(
!
sym
)
break
;
p
=
(
*
sym
)
->
s_value
;
debug
(
3
,(
"%s : #includes SYMBOL %s = %s
\n
"
,
file
->
i_incstring
,
(
*
sym
)
->
s_name
,
(
*
sym
)
->
s_value
));
/* mark file as having included a 'soft include' */
file
->
i_flags
|=
INCLUDED_SYM
;
}
/*
* Separate the name of the include file.
*/
while
(
*
p
&&
*
p
!=
'"'
&&
*
p
!=
'<'
)
p
++
;
if
(
!
*
p
)
return
(
-
2
);
if
(
*
p
++
==
'"'
)
{
if
(
ret
==
INCLUDE
)
ret
=
INCLUDEDOT
;
else
ret
=
INCLUDENEXTDOT
;
while
(
*
p
&&
*
p
!=
'"'
)
*
line
++
=
*
p
++
;
}
else
while
(
*
p
&&
*
p
!=
'>'
)
*
line
++
=
*
p
++
;
*
line
=
'\0'
;
break
;
case
DEFINE
:
/*
* copy the definition back to the beginning of the line.
*/
strcpy
(
line
,
p
);
break
;
case
ELSE
:
case
ENDIF
:
case
ELIF
:
case
PRAGMA
:
case
ERROR
:
case
IDENT
:
case
SCCS
:
case
EJECT
:
case
WARNING
:
debug
(
0
,(
"%s, line %d: #%s
\n
"
,
file
->
i_file
,
filep
->
f_line
,
directives
[
ret
]));
/*
* nothing to do.
*/
break
;
}
return
(
ret
);
}
struct
symtab
**
fdefined
(
char
*
symbol
,
struct
inclist
*
file
,
struct
inclist
**
srcfile
)
{
struct
inclist
**
ip
;
struct
symtab
**
val
;
int
i
;
static
int
recurse_lvl
=
0
;
if
(
file
->
i_flags
&
DEFCHECKED
)
return
(
NULL
);
debug
(
2
,(
"Looking for %s in %s
\n
"
,
symbol
,
file
->
i_file
));
file
->
i_flags
|=
DEFCHECKED
;
if
((
val
=
slookup
(
symbol
,
file
)))
debug
(
1
,(
"%s defined in %s as %s
\n
"
,
symbol
,
file
->
i_file
,
(
*
val
)
->
s_value
));
if
(
val
==
NULL
&&
file
->
i_list
)
{
for
(
ip
=
file
->
i_list
,
i
=
0
;
i
<
file
->
i_listlen
;
i
++
,
ip
++
)
if
(
file
->
i_merged
[
i
]
==
FALSE
)
{
val
=
fdefined
(
symbol
,
*
ip
,
srcfile
);
file
->
i_merged
[
i
]
=
merge2defines
(
file
,
*
ip
);
if
(
val
!=
NULL
)
break
;
}
}
else
if
(
val
!=
NULL
&&
srcfile
!=
NULL
)
*
srcfile
=
file
;
recurse_lvl
--
;
file
->
i_flags
&=
~
DEFCHECKED
;
return
(
val
);
}
struct
symtab
**
isdefined
(
char
*
symbol
,
struct
inclist
*
file
,
struct
inclist
**
srcfile
)
{
struct
symtab
**
val
;
if
((
val
=
slookup
(
symbol
,
&
maininclist
)))
{
debug
(
1
,(
"%s defined on command line
\n
"
,
symbol
));
if
(
srcfile
!=
NULL
)
*
srcfile
=
&
maininclist
;
return
(
val
);
}
if
((
val
=
fdefined
(
symbol
,
file
,
srcfile
)))
return
(
val
);
debug
(
1
,(
"%s not defined in %s
\n
"
,
symbol
,
file
->
i_file
));
return
(
NULL
);
}
/*
* Return type based on if the #if expression evaluates to 0
*/
static
int
zero_value
(
char
*
filename
,
char
*
exp
,
struct
filepointer
*
filep
,
struct
inclist
*
file_red
)
{
if
(
cppsetup
(
filename
,
exp
,
filep
,
file_red
))
return
(
IFFALSE
);
else
return
(
IF
);
}
void
define2
(
char
*
name
,
char
*
val
,
struct
inclist
*
file
)
{
int
first
,
last
,
below
;
register
struct
symtab
**
sp
=
NULL
,
**
dest
;
struct
symtab
*
stab
;
/* Make space if it's needed */
if
(
file
->
i_defs
==
NULL
)
{
file
->
i_defs
=
(
struct
symtab
**
)
malloc
(
sizeof
(
struct
symtab
*
)
*
SYMTABINC
);
file
->
i_ndefs
=
0
;
}
else
if
(
!
(
file
->
i_ndefs
%
SYMTABINC
))
file
->
i_defs
=
(
struct
symtab
**
)
realloc
(
file
->
i_defs
,
sizeof
(
struct
symtab
*
)
*
(
file
->
i_ndefs
+
SYMTABINC
));
if
(
file
->
i_defs
==
NULL
)
fatalerr
(
"malloc()/realloc() failure in insert_defn()
\n
"
);
below
=
first
=
0
;
last
=
file
->
i_ndefs
-
1
;
while
(
last
>=
first
)
{
/* Fast inline binary search */
register
char
*
s1
;
register
char
*
s2
;
register
int
middle
=
(
first
+
last
)
/
2
;
/* Fast inline strchr() */
s1
=
name
;
s2
=
file
->
i_defs
[
middle
]
->
s_name
;
while
(
*
s1
++
==
*
s2
++
)
if
(
s2
[
-
1
]
==
'\0'
)
break
;
/* If exact match, set sp and break */
if
(
*--
s1
==
*--
s2
)
{
sp
=
file
->
i_defs
+
middle
;
break
;
}
/* If name > i_defs[middle] ... */
if
(
*
s1
>
*
s2
)
{
below
=
first
;
first
=
middle
+
1
;
}
/* else ... */
else
{
below
=
last
=
middle
-
1
;
}
}
/* Search is done. If we found an exact match to the symbol name,
just replace its s_value */
if
(
sp
!=
NULL
)
{
debug
(
1
,(
"redefining %s from %s to %s in file %s
\n
"
,
name
,
(
*
sp
)
->
s_value
,
val
,
file
->
i_file
));
free
((
*
sp
)
->
s_value
);
(
*
sp
)
->
s_value
=
copy
(
val
);
return
;
}
sp
=
file
->
i_defs
+
file
->
i_ndefs
++
;
dest
=
file
->
i_defs
+
below
+
1
;
while
(
sp
>
dest
)
{
*
sp
=
sp
[
-
1
];
sp
--
;
}
stab
=
(
struct
symtab
*
)
malloc
(
sizeof
(
struct
symtab
));
if
(
stab
==
NULL
)
fatalerr
(
"malloc()/realloc() failure in insert_defn()
\n
"
);
debug
(
1
,(
"defining %s to %s in file %s
\n
"
,
name
,
val
,
file
->
i_file
));
stab
->
s_name
=
copy
(
name
);
stab
->
s_value
=
copy
(
val
);
*
sp
=
stab
;
}
void
define
(
char
*
def
,
struct
inclist
*
file
)
{
char
*
val
;
/* Separate symbol name and its value */
val
=
def
;
while
(
isalnum
(
*
val
)
||
*
val
==
'_'
)
val
++
;
if
(
*
val
)
*
val
++
=
'\0'
;
while
(
*
val
==
' '
||
*
val
==
'\t'
)
val
++
;
if
(
!*
val
)
val
=
"1"
;
define2
(
def
,
val
,
file
);
}
struct
symtab
**
slookup
(
char
*
symbol
,
struct
inclist
*
file
)
{
register
int
first
=
0
;
register
int
last
=
file
->
i_ndefs
-
1
;
if
(
file
)
while
(
last
>=
first
)
{
/* Fast inline binary search */
register
char
*
s1
;
register
char
*
s2
;
register
int
middle
=
(
first
+
last
)
/
2
;
/* Fast inline strchr() */
s1
=
symbol
;
s2
=
file
->
i_defs
[
middle
]
->
s_name
;
while
(
*
s1
++
==
*
s2
++
)
if
(
s2
[
-
1
]
==
'\0'
)
break
;
/* If exact match, we're done */
if
(
*--
s1
==
*--
s2
)
{
return
file
->
i_defs
+
middle
;
}
/* If symbol > i_defs[middle] ... */
if
(
*
s1
>
*
s2
)
{
first
=
middle
+
1
;
}
/* else ... */
else
{
last
=
middle
-
1
;
}
}
return
(
NULL
);
}
static
int
merge2defines
(
struct
inclist
*
file1
,
struct
inclist
*
file2
)
{
int
i
;
if
((
file1
==
NULL
)
||
(
file2
==
NULL
)
||
!
(
file2
->
i_flags
&
FINISHED
))
return
0
;
for
(
i
=
0
;
i
<
file2
->
i_listlen
;
i
++
)
if
(
file2
->
i_merged
[
i
]
==
FALSE
)
return
0
;
{
int
first1
=
0
;
int
last1
=
file1
->
i_ndefs
-
1
;
int
first2
=
0
;
int
last2
=
file2
->
i_ndefs
-
1
;
int
first
=
0
;
struct
symtab
**
i_defs
=
NULL
;
int
deflen
=
file1
->
i_ndefs
+
file2
->
i_ndefs
;
debug
(
2
,(
"merging %s into %s
\n
"
,
file2
->
i_file
,
file1
->
i_file
));
if
(
deflen
>
0
)
{
/* make sure deflen % SYMTABINC == 0 is still true */
deflen
+=
(
SYMTABINC
-
deflen
%
SYMTABINC
)
%
SYMTABINC
;
i_defs
=
(
struct
symtab
**
)
malloc
(
deflen
*
sizeof
(
struct
symtab
*
));
if
(
i_defs
==
NULL
)
return
0
;
}
while
((
last1
>=
first1
)
&&
(
last2
>=
first2
))
{
char
*
s1
=
file1
->
i_defs
[
first1
]
->
s_name
;
char
*
s2
=
file2
->
i_defs
[
first2
]
->
s_name
;
if
(
strcmp
(
s1
,
s2
)
<
0
)
i_defs
[
first
++
]
=
file1
->
i_defs
[
first1
++
];
else
if
(
strcmp
(
s1
,
s2
)
>
0
)
i_defs
[
first
++
]
=
file2
->
i_defs
[
first2
++
];
else
/* equal */
{
i_defs
[
first
++
]
=
file2
->
i_defs
[
first2
++
];
first1
++
;
}
}
while
(
last1
>=
first1
)
{
i_defs
[
first
++
]
=
file1
->
i_defs
[
first1
++
];
}
while
(
last2
>=
first2
)
{
i_defs
[
first
++
]
=
file2
->
i_defs
[
first2
++
];
}
if
(
file1
->
i_defs
)
free
(
file1
->
i_defs
);
file1
->
i_defs
=
i_defs
;
file1
->
i_ndefs
=
first
;
return
1
;
}
}
void
undefine
(
char
*
symbol
,
struct
inclist
*
file
)
{
register
struct
symtab
**
ptr
;
struct
inclist
*
srcfile
;
while
((
ptr
=
isdefined
(
symbol
,
file
,
&
srcfile
))
!=
NULL
)
{
srcfile
->
i_ndefs
--
;
for
(;
ptr
<
srcfile
->
i_defs
+
srcfile
->
i_ndefs
;
ptr
++
)
*
ptr
=
ptr
[
1
];
}
}
int
find_includes
(
struct
filepointer
*
filep
,
struct
inclist
*
file
,
struct
inclist
*
file_red
,
int
recursion
,
boolean
failOK
)
{
struct
inclist
*
inclistp
;
char
**
includedirsp
;
register
char
*
line
;
register
int
type
;
boolean
recfailOK
;
while
((
line
=
getnextline
(
filep
)))
{
switch
(
type
=
deftype
(
line
,
filep
,
file_red
,
file
,
TRUE
))
{
case
IF
:
doif:
type
=
find_includes
(
filep
,
file
,
file_red
,
recursion
+
1
,
failOK
);
while
((
type
==
ELIF
)
||
(
type
==
ELIFFALSE
)
||
(
type
==
ELIFGUESSFALSE
))
type
=
gobble
(
filep
,
file
,
file_red
);
if
(
type
==
ELSE
)
gobble
(
filep
,
file
,
file_red
);
break
;
case
IFFALSE
:
case
IFGUESSFALSE
:
doiffalse:
if
(
type
==
IFGUESSFALSE
||
type
==
ELIFGUESSFALSE
)
recfailOK
=
TRUE
;
else
recfailOK
=
failOK
;
type
=
gobble
(
filep
,
file
,
file_red
);
if
(
type
==
ELSE
)
find_includes
(
filep
,
file
,
file_red
,
recursion
+
1
,
recfailOK
);
else
if
(
type
==
ELIF
)
goto
doif
;
else
if
((
type
==
ELIFFALSE
)
||
(
type
==
ELIFGUESSFALSE
))
goto
doiffalse
;
break
;
case
IFDEF
:
case
IFNDEF
:
if
((
type
==
IFDEF
&&
isdefined
(
line
,
file_red
,
NULL
))
||
(
type
==
IFNDEF
&&
!
isdefined
(
line
,
file_red
,
NULL
)))
{
debug
(
1
,(
type
==
IFNDEF
?
"line %d: %s !def'd in %s via %s%s
\n
"
:
""
,
filep
->
f_line
,
line
,
file
->
i_file
,
file_red
->
i_file
,
": doit"
));
type
=
find_includes
(
filep
,
file
,
file_red
,
recursion
+
1
,
failOK
);
while
(
type
==
ELIF
||
type
==
ELIFFALSE
||
type
==
ELIFGUESSFALSE
)
type
=
gobble
(
filep
,
file
,
file_red
);
if
(
type
==
ELSE
)
gobble
(
filep
,
file
,
file_red
);
}
else
{
debug
(
1
,(
type
==
IFDEF
?
"line %d: %s !def'd in %s via %s%s
\n
"
:
""
,
filep
->
f_line
,
line
,
file
->
i_file
,
file_red
->
i_file
,
": gobble"
));
type
=
gobble
(
filep
,
file
,
file_red
);
if
(
type
==
ELSE
)
find_includes
(
filep
,
file
,
file_red
,
recursion
+
1
,
failOK
);
else
if
(
type
==
ELIF
)
goto
doif
;
else
if
(
type
==
ELIFFALSE
||
type
==
ELIFGUESSFALSE
)
goto
doiffalse
;
}
break
;
case
ELSE
:
case
ELIFFALSE
:
case
ELIFGUESSFALSE
:
case
ELIF
:
if
(
!
recursion
)
gobble
(
filep
,
file
,
file_red
);
case
ENDIF
:
if
(
recursion
)
return
(
type
);
case
DEFINE
:
define
(
line
,
file
);
break
;
case
UNDEF
:
if
(
!*
line
)
{
warning
(
"%s"
,
file_red
->
i_file
);
if
(
file_red
!=
file
)
warning1
(
" (reading %s)"
,
file
->
i_file
);
warning1
(
", line %d: incomplete undef ==
\"
%s
\"\n
"
,
filep
->
f_line
,
line
);
break
;
}
undefine
(
line
,
file_red
);
break
;
case
INCLUDE
:
case
INCLUDEDOT
:
case
INCLUDENEXT
:
case
INCLUDENEXTDOT
:
inclistp
=
inclistnext
;
includedirsp
=
includedirsnext
;
debug
(
2
,(
"%s, reading %s, includes %s
\n
"
,
file_red
->
i_file
,
file
->
i_file
,
line
));
add_include
(
filep
,
file
,
file_red
,
line
,
type
,
failOK
);
inclistnext
=
inclistp
;
includedirsnext
=
includedirsp
;
break
;
case
ERROR
:
case
WARNING
:
warning
(
"%s"
,
file_red
->
i_file
);
if
(
file_red
!=
file
)
warning1
(
" (reading %s)"
,
file
->
i_file
);
warning1
(
", line %d: %s
\n
"
,
filep
->
f_line
,
line
);
break
;
case
PRAGMA
:
case
IDENT
:
case
SCCS
:
case
EJECT
:
break
;
case
-
1
:
warning
(
"%s"
,
file_red
->
i_file
);
if
(
file_red
!=
file
)
warning1
(
" (reading %s)"
,
file
->
i_file
);
warning1
(
", line %d: unknown directive ==
\"
%s
\"\n
"
,
filep
->
f_line
,
line
);
break
;
case
-
2
:
warning
(
"%s"
,
file_red
->
i_file
);
if
(
file_red
!=
file
)
warning1
(
" (reading %s)"
,
file
->
i_file
);
warning1
(
", line %d: incomplete include ==
\"
%s
\"\n
"
,
filep
->
f_line
,
line
);
break
;
}
}
file
->
i_flags
|=
FINISHED
;
debug
(
2
,(
"finished with %s
\n
"
,
file
->
i_file
));
return
(
-
1
);
}
nx-X11/config/makedepend/pr.c
deleted
100644 → 0
View file @
5b36f644
/* $Xorg: pr.c,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ */
/*
Copyright (c) 1993, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/* $XFree86: xc/config/makedepend/pr.c,v 1.4 2001/04/29 23:25:02 tsi Exp $ */
#include "def.h"
extern
struct
inclist
inclist
[
MAXFILES
],
*
inclistp
;
extern
char
*
objprefix
;
extern
char
*
objsuffix
;
extern
int
width
;
extern
boolean
printed
;
extern
boolean
verbose
;
extern
boolean
show_where_not
;
void
add_include
(
struct
filepointer
*
filep
,
struct
inclist
*
file
,
struct
inclist
*
file_red
,
char
*
include
,
int
type
,
boolean
failOK
)
{
register
struct
inclist
*
newfile
;
register
struct
filepointer
*
content
;
/*
* First decide what the pathname of this include file really is.
*/
newfile
=
inc_path
(
file
->
i_file
,
include
,
type
);
if
(
newfile
==
NULL
)
{
if
(
failOK
)
return
;
if
(
file
!=
file_red
)
warning
(
"%s (reading %s, line %d): "
,
file_red
->
i_file
,
file
->
i_file
,
filep
->
f_line
);
else
warning
(
"%s, line %d: "
,
file
->
i_file
,
filep
->
f_line
);
warning1
(
"cannot find include file
\"
%s
\"\n
"
,
include
);
show_where_not
=
TRUE
;
newfile
=
inc_path
(
file
->
i_file
,
include
,
type
);
show_where_not
=
FALSE
;
}
if
(
newfile
)
{
included_by
(
file
,
newfile
);
if
(
!
(
newfile
->
i_flags
&
SEARCHED
))
{
newfile
->
i_flags
|=
SEARCHED
;
content
=
getfile
(
newfile
->
i_file
);
find_includes
(
content
,
newfile
,
file_red
,
0
,
failOK
);
freefile
(
content
);
}
}
}
static
void
pr
(
struct
inclist
*
ip
,
char
*
file
,
char
*
base
)
{
static
char
*
lastfile
;
static
int
current_len
;
register
int
len
,
i
;
char
buf
[
BUFSIZ
];
printed
=
TRUE
;
len
=
strlen
(
ip
->
i_file
)
+
1
;
if
(
current_len
+
len
>
width
||
file
!=
lastfile
)
{
lastfile
=
file
;
sprintf
(
buf
,
"
\n
%s%s%s: %s"
,
objprefix
,
base
,
objsuffix
,
ip
->
i_file
);
len
=
current_len
=
strlen
(
buf
);
}
else
{
buf
[
0
]
=
' '
;
strcpy
(
buf
+
1
,
ip
->
i_file
);
current_len
+=
len
;
}
fwrite
(
buf
,
len
,
1
,
stdout
);
/*
* If verbose is set, then print out what this file includes.
*/
if
(
!
verbose
||
ip
->
i_list
==
NULL
||
ip
->
i_flags
&
NOTIFIED
)
return
;
ip
->
i_flags
|=
NOTIFIED
;
lastfile
=
NULL
;
printf
(
"
\n
# %s includes:"
,
ip
->
i_file
);
for
(
i
=
0
;
i
<
ip
->
i_listlen
;
i
++
)
printf
(
"
\n
#
\t
%s"
,
ip
->
i_list
[
i
]
->
i_incstring
);
}
void
recursive_pr_include
(
struct
inclist
*
head
,
char
*
file
,
char
*
base
)
{
int
i
;
if
(
head
->
i_flags
&
MARKED
)
return
;
head
->
i_flags
|=
MARKED
;
if
(
head
->
i_file
!=
file
)
pr
(
head
,
file
,
base
);
for
(
i
=
0
;
i
<
head
->
i_listlen
;
i
++
)
recursive_pr_include
(
head
->
i_list
[
i
],
file
,
base
);
}
nxcomp/configure.in
View file @
2f3d394e
...
...
@@ -367,16 +367,6 @@ dnl Find makedepend somewhere.
AC_SUBST(MAKEDEPEND)
MAKEDEPEND="$(which makedepend)"
# Try to desperately find makedepend.
# Set MAKEDEPEND to the shipped makedepend binary. This will not
# exist in nx-libs-lite, though, in which case MAKEDEPEND
# will stay empty.
if test -z "${MAKEDEPEND}"; then
if test -x "../nx-X11/config/makedepend/makedepend"; then
MAKEDEPEND="../nx-X11/config/makedepend/makedepend"
fi
fi
dnl Determine what to build based on the platform.
dnl Override the LIBS settings on Cygwin32 so that
dnl we always link with the exact set of libraries.
...
...
nxcompext/configure.in
View file @
2f3d394e
...
...
@@ -226,16 +226,6 @@ dnl Find makedepend somewhere.
AC_SUBST(MAKEDEPEND)
MAKEDEPEND="$(which makedepend)"
# Try to desperately find makedepend.
# Set MAKEDEPEND to the shipped makedepend binary. This will not
# exist in nx-libs-lite, though, in which case MAKEDEPEND
# will stay empty.
if test -z "${MAKEDEPEND}"; then
if test -x "../nx-X11/config/makedepend/makedepend"; then
MAKEDEPEND="../nx-X11/config/makedepend/makedepend"
fi
fi
dnl Determine what to build based on the platform.
dnl Override the LIBS settings on Cygwin32 so that
dnl we always link with the exact set of libraries.
...
...
nxcompshad/configure.in
View file @
2f3d394e
...
...
@@ -274,14 +274,4 @@ dnl Find makedepend somewhere.
AC_SUBST(MAKEDEPEND)
MAKEDEPEND="$(which makedepend)"
# Try to desperately find makedepend.
# Set MAKEDEPEND to the shipped makedepend binary. This will not
# exist in nx-libs-lite, though, in which case MAKEDEPEND
# will stay empty.
if test -z "${MAKEDEPEND}"; then
if test -x "../nx-X11/config/makedepend/makedepend"; then
MAKEDEPEND="../nx-X11/config/makedepend/makedepend"
fi
fi
AC_OUTPUT(Makefile nxcompshad.pc)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment