Init
This commit is contained in:
532
lang/compile/Makefile
Normal file
532
lang/compile/Makefile
Normal file
@@ -0,0 +1,532 @@
|
||||
# @(#)Makefile 1.1 94/10/31 SMI
|
||||
|
||||
#
|
||||
# Makefile for /lib/compile (driver for cc, f77, pc, m2c, lint, ...)
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# RELEASE=32 for Release 3.x version.
|
||||
# RELEASE=40 for Release 4.0 version.
|
||||
# RELEASE=41 for Release 4.1 version.
|
||||
RELEASE = 41
|
||||
|
||||
# RELEASE_NAME=3.x for Release 3.x version.
|
||||
# RELEASE_NAME=4.0 for Release 4.0 version.
|
||||
# RELEASE_NAME=4.1 for Release 4.1 version.
|
||||
RELEASE_NAME = 4.1
|
||||
|
||||
# SRCDIR=. for Sys-V version.
|
||||
# SRCDIR=../../lang/compile for UCB version.
|
||||
SRCDIR = .
|
||||
|
||||
# ORIENTATION= for default version (/lib/compile).
|
||||
# ORIENTATION=-DFORCE_SYS5 for forced Sys-V version.
|
||||
# ORIENTATION=-DFORCE_UCB for forced UCB version.
|
||||
ORIENTATION = -DFORCE_SYS5
|
||||
|
||||
# VROOT=../vroot for Sys-V version.
|
||||
# VROOT=../../lang/vroot for UCB version.
|
||||
VROOT = ../vroot
|
||||
|
||||
# INCLUDE=/usr/include for regular 3.x/4.0 version.
|
||||
# INCLUDE=/usr/5include for Sys-V 3.x/4.0 version
|
||||
# INCLUDE=/usr/include for Sys-V/UCB 4.1 version
|
||||
INCLUDE = /usr/include
|
||||
|
||||
# LIB=/lib for UCB 3.x version
|
||||
# LIB=/usr/5lib for Sys-V 3.x version
|
||||
# LIB=/usr/lib for UCB 4.0 version
|
||||
# LIB=/usr/5lib for Sys-V 4.0 version
|
||||
# LIB=/usr/5lib for Sys-V 4.1 version
|
||||
# LIB=/usr/lib for UCB 4.1 version
|
||||
LIB = /usr/5lib
|
||||
|
||||
# BIN=/bin for Release 3.x version.
|
||||
# BIN=/usr/bin for Release 4.x version.
|
||||
BIN = /usr/bin
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
ROOT =
|
||||
DESTDIR =
|
||||
OWN = bin
|
||||
GRP = bin
|
||||
MODE = 755
|
||||
INSTALL = install -c
|
||||
INSTALL_CMD= ${INSTALL} -s -m ${MODE} -o ${OWN} -g ${GRP}
|
||||
MAKEOBJ = compile
|
||||
ARCH:sh = /bin/arch
|
||||
CC = /usr/ucb/cc
|
||||
|
||||
CPP = /lib/cpp
|
||||
LINT = /usr/bin/lint
|
||||
|
||||
#
|
||||
# -DRELEASE=<n> is used for making a version to run natively
|
||||
# under SunOS release <n> (n=32 for 3.x, or 4x for 4.x).
|
||||
|
||||
# INCL_FLAGS are flags for preprocessor file-inclusion, typically -I<whatever>.
|
||||
INCL_FLAGS= -I$(SRCDIR) -I$(VROOT) $(X_INC) -I${ROOT}${INCLUDE}
|
||||
|
||||
# FEATURES specify which features are to be compiled into the driver.
|
||||
#
|
||||
# -DCROSS provides cross-compiler support.
|
||||
#
|
||||
# -DNSE provides runtime support for NSE.
|
||||
# -DCROSS is a prerequisite for -DNSE.
|
||||
#
|
||||
# -DBROWSER provides support for the Code Browser.
|
||||
# It has no prerequisite features.
|
||||
#
|
||||
# We include them all, by default.
|
||||
FEATURES= -DCROSS -DNSE -DBROWSER
|
||||
|
||||
# xCPPFLAGS are our flags for /lib/cpp.
|
||||
xCPPFLAGS = ${INCL_FLAGS} -DRELEASE=$(RELEASE) $(ORIENTATION) $(FEATURES) $(X_DEF) -D$(ARCH)
|
||||
|
||||
COPTS = -O
|
||||
CFLAGS = $(COPTS) $(xCPPFLAGS)
|
||||
LDFLAGS =
|
||||
LIBS =
|
||||
LINTFLAGS = -x $(xCPPFLAGS)
|
||||
xLINKS = xcc xm2c xf77 xpc xlint
|
||||
XLINKS = Xcc Xm2c Xf77 Xpc Xlint
|
||||
|
||||
|
||||
# testing variables (for running tests)
|
||||
TEST = run
|
||||
TESTDIR2= test_dir2
|
||||
XCROSS=sun2 sun3 sun3x sun4
|
||||
DRIVERS=cc f77 lint m2c pc
|
||||
|
||||
|
||||
#
|
||||
# Driver sources and headers.
|
||||
#
|
||||
ROCSRCS = $(SRCDIR)/ro_data.c
|
||||
CSRCS = $(SRCDIR)/compile.c $(SRCDIR)/driver_version.c \
|
||||
$(SRCDIR)/rw_data.c $(SRCDIR)/ro_data.c \
|
||||
$(SRCDIR)/run_pass.c $(SRCDIR)/setup.c $(SRCDIR)/setup_cc.c \
|
||||
$(SRCDIR)/setup_f77.c $(SRCDIR)/setup_lint.c \
|
||||
$(SRCDIR)/setup_m2c.c $(SRCDIR)/setup_pc.c
|
||||
HDRS = $(SRCDIR)/driver.h $(VROOT)/report.h $(VROOT)/vroot.h
|
||||
|
||||
SRCS = $(ROSRCS) $(CSRCS) $(HDRS)
|
||||
|
||||
#
|
||||
# Driver objects.
|
||||
#
|
||||
LINTS = compile.ln rw_data.ln ro_data.ln run_pass.ln setup.ln setup_cc.ln \
|
||||
setup_f77.ln setup_lint.ln setup_m2c.ln setup_pc.ln
|
||||
ROOBJS = ro_data.o
|
||||
COBJS = compile.o driver_version.o rw_data.o run_pass.o setup.o setup_cc.o \
|
||||
setup_f77.o setup_lint.o setup_m2c.o setup_pc.o
|
||||
OBJS = $(ROOBJS) $(COBJS)
|
||||
|
||||
#
|
||||
# Browser stuff
|
||||
#
|
||||
BROWSER_DIR-sun3 = ../browser/cblib/m68k
|
||||
BROWSER_DIR-sun4 = ../browser/cblib/sparc
|
||||
BROWSER_DIR = $(BROWSER_DIR$(TARGET_ARCH))
|
||||
|
||||
#
|
||||
# Production rules for driver.
|
||||
#
|
||||
all: ${MAKEOBJ}
|
||||
|
||||
# "make bootstrap" can be used to make a native driver, on a pre-SunOS4.1
|
||||
# system. See the "boostrap := <etc>" line above.
|
||||
bootstrap: ${MAKEOBJ}
|
||||
|
||||
compile: $(BROWSER_DIR)/libcb.a $(OBJS) $(VROOT)/vroot.a
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) $(VROOT)/vroot.a
|
||||
|
||||
$(XLINKS) $(xLINKS):
|
||||
rm -f $@; ln -s compile $@
|
||||
|
||||
xlinks: $(xLINKS)
|
||||
|
||||
Xlinks: $(XLINKS)
|
||||
|
||||
$(COBJS): $(HDRS)
|
||||
$(CC) $(CFLAGS) -c -o $(@F) $(SRCDIR)/`basename $(@F) .o`.c
|
||||
|
||||
$(VROOT)/vroot.a $(VROOT)/report.h $(VROOT)/vroot.h:
|
||||
cd $(@D); $(MAKE) $(@F)
|
||||
|
||||
$(BROWSER_DIR)/libcb.a: FRC
|
||||
cd $(@D) ; $(MAKE) $(@F)
|
||||
|
||||
FRC:
|
||||
|
||||
.c.ln:
|
||||
$(LINT) $(LINTFLAGS) -i $*.c
|
||||
|
||||
# read-only (sharable) data
|
||||
ro_data.o: $(SRCDIR)/ro_data.c
|
||||
$(CC) $(CFLAGS) -c $(SRCDIR)/ro_data.c -R
|
||||
|
||||
lint: $(LINTS)
|
||||
lint $(LINTS) $(LINTFLAGS)
|
||||
|
||||
lang_info: FRC
|
||||
if [ -f lang_info ] ; then rm -f lang_info ; fi
|
||||
echo "# For use by compiler drivers." > lang_info; \
|
||||
echo "# prod version OS-version" >>lang_info; \
|
||||
echo "c ${RELEASE_NAME} ${RELEASE_NAME}" >>lang_info; \
|
||||
echo "lint ${RELEASE_NAME} ${RELEASE_NAME}" >>lang_info
|
||||
|
||||
install: ${MAKEOBJ} install_lang_info
|
||||
$(INSTALL_CMD) -s compile $(DESTDIR)$(LIB)/compile
|
||||
|
||||
install_lang_info: lang_info
|
||||
$(INSTALL) -m 644 -o ${OWN} -g ${GRP} lang_info \
|
||||
$(DESTDIR)/usr/lib/lang_info
|
||||
|
||||
install_cc: ${MAKEOBJ}
|
||||
$(INSTALL_CMD) -s compile $(DESTDIR)$(BIN)/cc
|
||||
|
||||
install_lint: ${MAKEOBJ}
|
||||
$(INSTALL_CMD) -s compile $(DESTDIR)/usr/bin/lint
|
||||
|
||||
install_f77: ${MAKEOBJ}
|
||||
if [ $(ARCH) = sun386 ] ; \
|
||||
then \
|
||||
$(INSTALL_CMD) compile $(DESTDIR)/usr/cluster/devel/base_devel/usr.bin/f77 ; \
|
||||
cd $(DESTDIR)/usr/bin ; \
|
||||
if [ -f $(DESTDIR)/usr/bin/f77 ] ; then rm -f $(DESTDIR)/usr/bin/f77 ; fi ; \
|
||||
ln -s ../cluster/devel/base_devel/usr.bin/f77 $(DESTDIR)/usr/bin/f77 ; \
|
||||
else \
|
||||
$(INSTALL_CMD) -s compile $(DESTDIR)/usr/bin/f77 ; \
|
||||
fi
|
||||
@echo "**Must add \"fortran\" entry to $(DESTDIR)/usr/lib/lang_info**"
|
||||
|
||||
install_m2c: ${MAKEOBJ}
|
||||
$(INSTALL_CMD) -s compile $(DESTDIR)/usr/bin/m2c
|
||||
@echo "**Must add \"modula2\" entry to $(DESTDIR)/usr/lib/lang_info**"
|
||||
|
||||
install_pc: ${MAKEOBJ}
|
||||
if [ $(ARCH) = sun386 ] ; \
|
||||
then \
|
||||
$(INSTALL_CMD) compile $(DESTDIR)/usr/cluster/devel/base_devel/usr.ucb/pc ; \
|
||||
cd $(DESTDIR)/usr/ucb ; \
|
||||
if [ -f $(DESTDIR)/usr/ucb/pc ] ; then rm -f $(DESTDIR)/usr/ucb/pc ; fi ; \
|
||||
ln -s ../cluster/devel/base_devel/usr.ucb/pc $(DESTDIR)/usr/ucb/pc ; \
|
||||
else \
|
||||
$(INSTALL_CMD) -s compile $(DESTDIR)/usr/ucb/pc ; \
|
||||
fi
|
||||
@echo "**Must add \"pascal\" entry to $(DESTDIR)/usr/lib/lang_info**"
|
||||
|
||||
tags: $(SRCS) $(VROOT)/*.c
|
||||
ctags $(SRCS) $(VROOT)/*.c
|
||||
|
||||
|
||||
# Run tests for /lib/compile
|
||||
test: build
|
||||
@cd ${TESTDIR2} ; \
|
||||
make ${TEST} RELEASE=${RELEASE} DRIVERS="${DRIVERS}" XCROSS="${XCROSS}"
|
||||
|
||||
# Build tests for /lib/compile
|
||||
build:
|
||||
@if [ ! -d ${TESTDIR2} ] ; then mkdir ${TESTDIR2} ; fi
|
||||
@if [ ! -h ${TESTDIR2}/SCCS ] ; then ln -s ../SCCS/../${TESTDIR2}/SCCS ${TESTDIR2}/SCCS ; fi
|
||||
|
||||
#
|
||||
# Miscellaneous production rules.
|
||||
#
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) compile ocompile $(LINTS) *.BAK tags
|
||||
rm -f gen gen.o syscall.a
|
||||
# leave the links in for testing, they don't cause problems
|
||||
# rm -f $(xLINKS) $(XLINKS)
|
||||
|
||||
depend: $(SRCS)
|
||||
rm -f makedep
|
||||
for i in $(CSRCS); do \
|
||||
( $(CPP) -M $(xCPPFLAGS) $$i >> makedep ); \
|
||||
done
|
||||
echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
|
||||
echo '$$r makedep' >>eddep
|
||||
echo 'w' >>eddep
|
||||
cp Makefile Makefile.bak
|
||||
ed - Makefile < eddep
|
||||
echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
|
||||
echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
|
||||
echo '# see make depend above' >> Makefile
|
||||
rm -f eddep makedep
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend uses it
|
||||
|
||||
compile.o: ./compile.c
|
||||
compile.o: ./driver.h
|
||||
compile.o: /usr/include/stdio.h
|
||||
compile.o: /usr/include/sys/types.h
|
||||
compile.o: /usr/include/sys/stdtypes.h
|
||||
compile.o: /usr/include/sys/sysmacros.h
|
||||
compile.o: /usr/include/sys/time.h
|
||||
compile.o: /usr/include/time.h
|
||||
compile.o: /usr/include/sys/stdtypes.h
|
||||
compile.o: /usr/include/sys/resource.h
|
||||
compile.o: /usr/include/sys/param.h
|
||||
compile.o: /usr/include/machine/param.h
|
||||
compile.o: /usr/include/sys/signal.h
|
||||
compile.o: /usr/include/vm/faultcode.h
|
||||
compile.o: /usr/include/sys/stdtypes.h
|
||||
compile.o: /usr/include/sys/types.h
|
||||
compile.o: ../vroot/report.h
|
||||
compile.o: /usr/include/stdio.h
|
||||
compile.o: ../vroot/vroot.h
|
||||
compile.o: /usr/include/stdio.h
|
||||
compile.o: /usr/include/alloca.h
|
||||
compile.o: /usr/include/signal.h
|
||||
compile.o: /usr/include/sys/signal.h
|
||||
compile.o: /usr/include/sys/types.h
|
||||
compile.o: /usr/include/sys/stat.h
|
||||
compile.o: /usr/include/sys/types.h
|
||||
compile.o: ./../browser/cblib/src/cb_init.h
|
||||
compile.o: ./../browser/cblib/src/array.h
|
||||
compile.o: ./../browser/cblib/src/cb_heap.h
|
||||
compile.o: ./../browser/cblib/src/cb_portability.h
|
||||
compile.o: ./../browser/cblib/src/cb_directory.h
|
||||
compile.o: ./../browser/cblib/src/hash.h
|
||||
compile.o: ./../browser/cblib/src/cb_literals.h
|
||||
compile.o: /usr/include/alloca.h
|
||||
driver_version.o: ./driver_version.c
|
||||
driver_version.o: /usr/include/stdio.h
|
||||
driver_version.o: /usr/include/sys/file.h
|
||||
driver_version.o: /usr/include/sys/types.h
|
||||
driver_version.o: /usr/include/sys/stdtypes.h
|
||||
driver_version.o: /usr/include/sys/sysmacros.h
|
||||
driver_version.o: /usr/include/sys/fcntlcom.h
|
||||
driver_version.o: /usr/include/sys/stdtypes.h
|
||||
driver_version.o: /usr/include/sys/stat.h
|
||||
driver_version.o: /usr/include/sys/types.h
|
||||
driver_version.o: ./driver.h
|
||||
driver_version.o: /usr/include/stdio.h
|
||||
driver_version.o: /usr/include/sys/types.h
|
||||
driver_version.o: /usr/include/sys/time.h
|
||||
driver_version.o: /usr/include/time.h
|
||||
driver_version.o: /usr/include/sys/stdtypes.h
|
||||
driver_version.o: /usr/include/sys/resource.h
|
||||
driver_version.o: /usr/include/sys/param.h
|
||||
driver_version.o: /usr/include/machine/param.h
|
||||
driver_version.o: /usr/include/sys/signal.h
|
||||
driver_version.o: /usr/include/vm/faultcode.h
|
||||
driver_version.o: /usr/include/sys/stdtypes.h
|
||||
driver_version.o: /usr/include/sys/types.h
|
||||
driver_version.o: ../vroot/report.h
|
||||
driver_version.o: /usr/include/stdio.h
|
||||
driver_version.o: ../vroot/vroot.h
|
||||
driver_version.o: /usr/include/stdio.h
|
||||
driver_version.o: /usr/include/alloca.h
|
||||
rw_data.o: ./rw_data.c
|
||||
rw_data.o: ./driver.h
|
||||
rw_data.o: /usr/include/stdio.h
|
||||
rw_data.o: /usr/include/sys/types.h
|
||||
rw_data.o: /usr/include/sys/stdtypes.h
|
||||
rw_data.o: /usr/include/sys/sysmacros.h
|
||||
rw_data.o: /usr/include/sys/time.h
|
||||
rw_data.o: /usr/include/time.h
|
||||
rw_data.o: /usr/include/sys/stdtypes.h
|
||||
rw_data.o: /usr/include/sys/resource.h
|
||||
rw_data.o: /usr/include/sys/param.h
|
||||
rw_data.o: /usr/include/machine/param.h
|
||||
rw_data.o: /usr/include/sys/signal.h
|
||||
rw_data.o: /usr/include/vm/faultcode.h
|
||||
rw_data.o: /usr/include/sys/stdtypes.h
|
||||
rw_data.o: /usr/include/sys/types.h
|
||||
rw_data.o: ../vroot/report.h
|
||||
rw_data.o: /usr/include/stdio.h
|
||||
rw_data.o: ../vroot/vroot.h
|
||||
rw_data.o: /usr/include/stdio.h
|
||||
rw_data.o: /usr/include/alloca.h
|
||||
ro_data.o: ./ro_data.c
|
||||
ro_data.o: ./driver.h
|
||||
ro_data.o: /usr/include/stdio.h
|
||||
ro_data.o: /usr/include/sys/types.h
|
||||
ro_data.o: /usr/include/sys/stdtypes.h
|
||||
ro_data.o: /usr/include/sys/sysmacros.h
|
||||
ro_data.o: /usr/include/sys/time.h
|
||||
ro_data.o: /usr/include/time.h
|
||||
ro_data.o: /usr/include/sys/stdtypes.h
|
||||
ro_data.o: /usr/include/sys/resource.h
|
||||
ro_data.o: /usr/include/sys/param.h
|
||||
ro_data.o: /usr/include/machine/param.h
|
||||
ro_data.o: /usr/include/sys/signal.h
|
||||
ro_data.o: /usr/include/vm/faultcode.h
|
||||
ro_data.o: /usr/include/sys/stdtypes.h
|
||||
ro_data.o: /usr/include/sys/types.h
|
||||
ro_data.o: ../vroot/report.h
|
||||
ro_data.o: /usr/include/stdio.h
|
||||
ro_data.o: ../vroot/vroot.h
|
||||
ro_data.o: /usr/include/stdio.h
|
||||
ro_data.o: /usr/include/alloca.h
|
||||
run_pass.o: ./run_pass.c
|
||||
run_pass.o: ./driver.h
|
||||
run_pass.o: /usr/include/stdio.h
|
||||
run_pass.o: /usr/include/sys/types.h
|
||||
run_pass.o: /usr/include/sys/stdtypes.h
|
||||
run_pass.o: /usr/include/sys/sysmacros.h
|
||||
run_pass.o: /usr/include/sys/time.h
|
||||
run_pass.o: /usr/include/time.h
|
||||
run_pass.o: /usr/include/sys/stdtypes.h
|
||||
run_pass.o: /usr/include/sys/resource.h
|
||||
run_pass.o: /usr/include/sys/param.h
|
||||
run_pass.o: /usr/include/machine/param.h
|
||||
run_pass.o: /usr/include/sys/signal.h
|
||||
run_pass.o: /usr/include/vm/faultcode.h
|
||||
run_pass.o: /usr/include/sys/stdtypes.h
|
||||
run_pass.o: /usr/include/sys/types.h
|
||||
run_pass.o: ../vroot/report.h
|
||||
run_pass.o: /usr/include/stdio.h
|
||||
run_pass.o: ../vroot/vroot.h
|
||||
run_pass.o: /usr/include/stdio.h
|
||||
run_pass.o: /usr/include/alloca.h
|
||||
run_pass.o: /usr/include/sys/wait.h
|
||||
run_pass.o: /usr/include/sys/stdtypes.h
|
||||
run_pass.o: /usr/include/sys/file.h
|
||||
run_pass.o: /usr/include/sys/types.h
|
||||
run_pass.o: /usr/include/sys/fcntlcom.h
|
||||
run_pass.o: /usr/include/sys/stdtypes.h
|
||||
run_pass.o: /usr/include/sys/stat.h
|
||||
run_pass.o: /usr/include/sys/types.h
|
||||
run_pass.o: /usr/include/ctype.h
|
||||
setup.o: ./setup.c
|
||||
setup.o: ./driver.h
|
||||
setup.o: /usr/include/stdio.h
|
||||
setup.o: /usr/include/sys/types.h
|
||||
setup.o: /usr/include/sys/stdtypes.h
|
||||
setup.o: /usr/include/sys/sysmacros.h
|
||||
setup.o: /usr/include/sys/time.h
|
||||
setup.o: /usr/include/time.h
|
||||
setup.o: /usr/include/sys/stdtypes.h
|
||||
setup.o: /usr/include/sys/resource.h
|
||||
setup.o: /usr/include/sys/param.h
|
||||
setup.o: /usr/include/machine/param.h
|
||||
setup.o: /usr/include/sys/signal.h
|
||||
setup.o: /usr/include/vm/faultcode.h
|
||||
setup.o: /usr/include/sys/stdtypes.h
|
||||
setup.o: /usr/include/sys/types.h
|
||||
setup.o: ../vroot/report.h
|
||||
setup.o: /usr/include/stdio.h
|
||||
setup.o: ../vroot/vroot.h
|
||||
setup.o: /usr/include/stdio.h
|
||||
setup.o: /usr/include/alloca.h
|
||||
setup_cc.o: ./setup_cc.c
|
||||
setup_cc.o: ./driver.h
|
||||
setup_cc.o: /usr/include/stdio.h
|
||||
setup_cc.o: /usr/include/sys/types.h
|
||||
setup_cc.o: /usr/include/sys/stdtypes.h
|
||||
setup_cc.o: /usr/include/sys/sysmacros.h
|
||||
setup_cc.o: /usr/include/sys/time.h
|
||||
setup_cc.o: /usr/include/time.h
|
||||
setup_cc.o: /usr/include/sys/stdtypes.h
|
||||
setup_cc.o: /usr/include/sys/resource.h
|
||||
setup_cc.o: /usr/include/sys/param.h
|
||||
setup_cc.o: /usr/include/machine/param.h
|
||||
setup_cc.o: /usr/include/sys/signal.h
|
||||
setup_cc.o: /usr/include/vm/faultcode.h
|
||||
setup_cc.o: /usr/include/sys/stdtypes.h
|
||||
setup_cc.o: /usr/include/sys/types.h
|
||||
setup_cc.o: ../vroot/report.h
|
||||
setup_cc.o: /usr/include/stdio.h
|
||||
setup_cc.o: ../vroot/vroot.h
|
||||
setup_cc.o: /usr/include/stdio.h
|
||||
setup_cc.o: /usr/include/alloca.h
|
||||
setup_f77.o: ./setup_f77.c
|
||||
setup_f77.o: ./driver.h
|
||||
setup_f77.o: /usr/include/stdio.h
|
||||
setup_f77.o: /usr/include/sys/types.h
|
||||
setup_f77.o: /usr/include/sys/stdtypes.h
|
||||
setup_f77.o: /usr/include/sys/sysmacros.h
|
||||
setup_f77.o: /usr/include/sys/time.h
|
||||
setup_f77.o: /usr/include/time.h
|
||||
setup_f77.o: /usr/include/sys/stdtypes.h
|
||||
setup_f77.o: /usr/include/sys/resource.h
|
||||
setup_f77.o: /usr/include/sys/param.h
|
||||
setup_f77.o: /usr/include/machine/param.h
|
||||
setup_f77.o: /usr/include/sys/signal.h
|
||||
setup_f77.o: /usr/include/vm/faultcode.h
|
||||
setup_f77.o: /usr/include/sys/stdtypes.h
|
||||
setup_f77.o: /usr/include/sys/types.h
|
||||
setup_f77.o: ../vroot/report.h
|
||||
setup_f77.o: /usr/include/stdio.h
|
||||
setup_f77.o: ../vroot/vroot.h
|
||||
setup_f77.o: /usr/include/stdio.h
|
||||
setup_f77.o: /usr/include/alloca.h
|
||||
setup_lint.o: ./setup_lint.c
|
||||
setup_lint.o: ./driver.h
|
||||
setup_lint.o: /usr/include/stdio.h
|
||||
setup_lint.o: /usr/include/sys/types.h
|
||||
setup_lint.o: /usr/include/sys/stdtypes.h
|
||||
setup_lint.o: /usr/include/sys/sysmacros.h
|
||||
setup_lint.o: /usr/include/sys/time.h
|
||||
setup_lint.o: /usr/include/time.h
|
||||
setup_lint.o: /usr/include/sys/stdtypes.h
|
||||
setup_lint.o: /usr/include/sys/resource.h
|
||||
setup_lint.o: /usr/include/sys/param.h
|
||||
setup_lint.o: /usr/include/machine/param.h
|
||||
setup_lint.o: /usr/include/sys/signal.h
|
||||
setup_lint.o: /usr/include/vm/faultcode.h
|
||||
setup_lint.o: /usr/include/sys/stdtypes.h
|
||||
setup_lint.o: /usr/include/sys/types.h
|
||||
setup_lint.o: ../vroot/report.h
|
||||
setup_lint.o: /usr/include/stdio.h
|
||||
setup_lint.o: ../vroot/vroot.h
|
||||
setup_lint.o: /usr/include/stdio.h
|
||||
setup_lint.o: /usr/include/alloca.h
|
||||
setup_lint.o: /usr/include/sys/file.h
|
||||
setup_lint.o: /usr/include/sys/types.h
|
||||
setup_lint.o: /usr/include/sys/fcntlcom.h
|
||||
setup_lint.o: /usr/include/sys/stdtypes.h
|
||||
setup_lint.o: /usr/include/sys/stat.h
|
||||
setup_lint.o: /usr/include/sys/types.h
|
||||
setup_m2c.o: ./setup_m2c.c
|
||||
setup_m2c.o: ./driver.h
|
||||
setup_m2c.o: /usr/include/stdio.h
|
||||
setup_m2c.o: /usr/include/sys/types.h
|
||||
setup_m2c.o: /usr/include/sys/stdtypes.h
|
||||
setup_m2c.o: /usr/include/sys/sysmacros.h
|
||||
setup_m2c.o: /usr/include/sys/time.h
|
||||
setup_m2c.o: /usr/include/time.h
|
||||
setup_m2c.o: /usr/include/sys/stdtypes.h
|
||||
setup_m2c.o: /usr/include/sys/resource.h
|
||||
setup_m2c.o: /usr/include/sys/param.h
|
||||
setup_m2c.o: /usr/include/machine/param.h
|
||||
setup_m2c.o: /usr/include/sys/signal.h
|
||||
setup_m2c.o: /usr/include/vm/faultcode.h
|
||||
setup_m2c.o: /usr/include/sys/stdtypes.h
|
||||
setup_m2c.o: /usr/include/sys/types.h
|
||||
setup_m2c.o: ../vroot/report.h
|
||||
setup_m2c.o: /usr/include/stdio.h
|
||||
setup_m2c.o: ../vroot/vroot.h
|
||||
setup_m2c.o: /usr/include/stdio.h
|
||||
setup_m2c.o: /usr/include/alloca.h
|
||||
setup_pc.o: ./setup_pc.c
|
||||
setup_pc.o: ./driver.h
|
||||
setup_pc.o: /usr/include/stdio.h
|
||||
setup_pc.o: /usr/include/sys/types.h
|
||||
setup_pc.o: /usr/include/sys/stdtypes.h
|
||||
setup_pc.o: /usr/include/sys/sysmacros.h
|
||||
setup_pc.o: /usr/include/sys/time.h
|
||||
setup_pc.o: /usr/include/time.h
|
||||
setup_pc.o: /usr/include/sys/stdtypes.h
|
||||
setup_pc.o: /usr/include/sys/resource.h
|
||||
setup_pc.o: /usr/include/sys/param.h
|
||||
setup_pc.o: /usr/include/machine/param.h
|
||||
setup_pc.o: /usr/include/sys/signal.h
|
||||
setup_pc.o: /usr/include/vm/faultcode.h
|
||||
setup_pc.o: /usr/include/sys/stdtypes.h
|
||||
setup_pc.o: /usr/include/sys/types.h
|
||||
setup_pc.o: ../vroot/report.h
|
||||
setup_pc.o: /usr/include/stdio.h
|
||||
setup_pc.o: ../vroot/vroot.h
|
||||
setup_pc.o: /usr/include/stdio.h
|
||||
setup_pc.o: /usr/include/alloca.h
|
||||
# DEPENDENCIES MUST END AT END OF FILE
|
||||
# IF YOU PUT STUFF HERE IT WILL GO AWAY
|
||||
# see make depend above
|
||||
10
lang/compile/README
Normal file
10
lang/compile/README
Normal file
@@ -0,0 +1,10 @@
|
||||
# @(#)README 1.1 10/31/94
|
||||
|
||||
REGRESSION TESTING OF COMPILE:
|
||||
==============================
|
||||
|
||||
<The old contents of this file are now out of date.
|
||||
All regression testing is now done under the "test_dir2"
|
||||
directory. Note that cross-compilers, or a faked-out
|
||||
version of them, must be installed in order for the
|
||||
regression test to work.>
|
||||
2086
lang/compile/arch.t
Normal file
2086
lang/compile/arch.t
Normal file
File diff suppressed because it is too large
Load Diff
2730
lang/compile/compile.c
Normal file
2730
lang/compile/compile.c
Normal file
File diff suppressed because it is too large
Load Diff
739
lang/compile/driver.h
Normal file
739
lang/compile/driver.h
Normal file
@@ -0,0 +1,739 @@
|
||||
/* @(#)driver.h 1.77 88/11/19 SMI */
|
||||
/*
|
||||
* Copyright (c) 1987 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/param.h>
|
||||
#include <report.h>
|
||||
#include <vroot.h>
|
||||
|
||||
#ifdef sparc
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
|
||||
typedef unsigned char Bool;
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
#define UNINIT_BOOL 2
|
||||
|
||||
#define STR_EQUAL(a,b) (strcmp((a),(b)) == 0)
|
||||
#define STR_EQUAL_N(a,b,n) (strncmp((a),(b),(n)) == 0)
|
||||
|
||||
/*
|
||||
* Const_int defines the integer constant values that Named_int can assume.
|
||||
*
|
||||
* The "name" field is used when printing error messages.
|
||||
*
|
||||
* The "extra" field holds an optional value associated with the int
|
||||
* constant, to wit:
|
||||
*
|
||||
* Type of
|
||||
* Const_int Use of "extra"
|
||||
* -------------- -----------------------------------------------
|
||||
* float_mode the run time startup routine for the mode
|
||||
* profile the run time startup routine for the mode
|
||||
* target_sw_release[R_VROOT]:
|
||||
* the value (string) to be used in the VROOT path
|
||||
* system architecture
|
||||
* the name of the architecture
|
||||
* drivers the name of the product to which they belong
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int value;
|
||||
char *name;
|
||||
char *extra;
|
||||
} Const_int, *Const_intP;
|
||||
|
||||
/*
|
||||
* Named_int cells are used to hold slightly complex integer values.
|
||||
* The value field is always a reference to a Const_int.
|
||||
* The help field is used when printing error messages.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
Const_intP value;
|
||||
char *help;
|
||||
Bool touched :1;
|
||||
Bool redefine_ok:1;
|
||||
} Named_int, *Named_intP;
|
||||
|
||||
/*
|
||||
* The Suffix struct holds information about one suffix the driver knows
|
||||
* about. Fields:
|
||||
* suffix Points to the plain suffix string (w/o the ".")
|
||||
* in_drivers 2 sets (bitmasks) that define which drivers
|
||||
* out_drivers consume/produce files with this suffix
|
||||
* (DRIVER_* values).
|
||||
* compile Function that compiles files with this suffix.
|
||||
* collect Function that collects files with this suffix
|
||||
* for postprocessing.
|
||||
* help String describing the suffix.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char *suffix;
|
||||
short int in_drivers;
|
||||
short int out_drivers;
|
||||
int (*compile)();
|
||||
void (*collect)();
|
||||
char *help;
|
||||
} Suffix, *SuffixP;
|
||||
|
||||
/*
|
||||
* There is one variable of the type Suffixes.
|
||||
* It contains one entry for each suffix that the driver
|
||||
* is prepared to handle. The individual suffix cells
|
||||
* are described above.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
Suffix a;
|
||||
Suffix c;
|
||||
Suffix def;
|
||||
Suffix f;
|
||||
Suffix F;
|
||||
Suffix il;
|
||||
Suffix i;
|
||||
Suffix ln;
|
||||
Suffix mod;
|
||||
Suffix o;
|
||||
Suffix pas;
|
||||
Suffix pi;
|
||||
Suffix p;
|
||||
Suffix r;
|
||||
Suffix sym;
|
||||
Suffix s;
|
||||
Suffix so;
|
||||
Suffix S;
|
||||
Suffix ir;
|
||||
Suffix none;
|
||||
Suffix sentinel_suffix_field;
|
||||
} Suffixes;
|
||||
|
||||
/*
|
||||
* The List struct is used for building linked lists of strings.
|
||||
* It is possible to associate a suffix with each string.
|
||||
*/
|
||||
typedef struct List
|
||||
{
|
||||
char *value;
|
||||
SuffixP suffix;
|
||||
struct List *next;
|
||||
} List, *ListP;
|
||||
|
||||
|
||||
typedef unsigned char Template;
|
||||
/* Values for the Template (program argument template) */
|
||||
#define IN_TEMPLATE 1
|
||||
#define OUT_TEMPLATE 2
|
||||
#define OPTION_TEMPLATE 3
|
||||
#define STDOUT_TEMPLATE 4
|
||||
#define STDIN_TEMPLATE 5 /* must be the 1st template,if it is used*/
|
||||
#define MINUS_O_TEMPLATE 6
|
||||
#define MINUS_TEMPLATE 7
|
||||
#define OUT2_TEMPLATE 8
|
||||
|
||||
/*
|
||||
* The Program struct contains information about one program
|
||||
* that the driver is prepared to invoke.
|
||||
* Fields:
|
||||
* name Short name of program
|
||||
* path Path to the program
|
||||
* drivers bitmask describing which drivers use this prog
|
||||
* setup Function called to prepare for run of program
|
||||
* (determined dynamically)
|
||||
* permanent_options Options used for all runs of program
|
||||
* trailing_options Options used for all runs, but specified on
|
||||
* cmd line with -Qoption, therefore need
|
||||
* to be on the end of the option list.
|
||||
* options list of options with which program will be run
|
||||
* infile List of infiles for program (dynamic)
|
||||
* outfile The file produced by the program
|
||||
* outfile2 A second file produced by the program
|
||||
* has_been_initialized
|
||||
* Flags if permanent_options has been set yet
|
||||
* template Vector that describes the order in which
|
||||
* options should be passed to the program
|
||||
* The lists options and infile and the value outfile are set for each
|
||||
* run of the program by the setup functions.
|
||||
*/
|
||||
#define PGM_TEMPLATE_LENGTH 5
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
char *path;
|
||||
short int drivers;
|
||||
char *(*setup)();
|
||||
ListP permanent_options;
|
||||
ListP trailing_options;
|
||||
ListP options;
|
||||
ListP infile;
|
||||
char *outfile;
|
||||
char *outfile2;
|
||||
Bool has_been_initialized :1;
|
||||
Template template[PGM_TEMPLATE_LENGTH];
|
||||
} Program, *ProgramP;
|
||||
|
||||
/*
|
||||
* There is one variabe of the type Programs.
|
||||
* Each program that the driver is prepared to invoke is described here.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
Program cppas;
|
||||
Program cpp;
|
||||
Program m4;
|
||||
Program ratfor;
|
||||
Program lint1;
|
||||
Program cat;
|
||||
Program lint2;
|
||||
Program m2cfe;
|
||||
Program ccom;
|
||||
Program pc0;
|
||||
Program f1;
|
||||
Program mf1;
|
||||
Program vpaf77;
|
||||
Program f77pass1;
|
||||
Program iropt;
|
||||
Program cg;
|
||||
Program inline;
|
||||
Program c2;
|
||||
Program as;
|
||||
Program asS;
|
||||
Program pc3;
|
||||
Program ld;
|
||||
Program vpald;
|
||||
Program m2l;
|
||||
Program sentinel_program_field;
|
||||
} Programs;
|
||||
|
||||
/*
|
||||
* The Step struct is used to build vectors that describes
|
||||
* which programs should run in what order for one particular compile
|
||||
* Fields:
|
||||
* program References the program to run
|
||||
* out_suffix The suffix of the file produced
|
||||
* expression Expression that determines if step is relevant
|
||||
* setup Function that performs special setup for step
|
||||
* start Time program started. Used when reporting
|
||||
* runtime.
|
||||
* process Process id of process running program
|
||||
* killed Indicated if the process has been killed
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ProgramP program;
|
||||
SuffixP out_suffix;
|
||||
int (*expression)();
|
||||
char *(*setup)();
|
||||
struct timeval start;
|
||||
short int process;
|
||||
Bool killed :1;
|
||||
} Step, *StepP;
|
||||
|
||||
/*
|
||||
* This enum defines the special actions that can
|
||||
* be used for processing command line options
|
||||
* after they have been recognized.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
end_of_list= 1, /* The last option in the list of options */
|
||||
help_option, /* Show help message */
|
||||
infile_option, /* This option is an infile */
|
||||
lint1_option, /* pass to lint1 */
|
||||
lint_i_option, /* Special check for lint -n & -i to make sure*/
|
||||
lint_n_option, /* they do not have more options trailing*/
|
||||
make_lint_lib_option, /* Make lint library option */
|
||||
module_option, /* Force load modula module */
|
||||
module_list_option, /* m2c search path option */
|
||||
optimize_option, /* -O/-P options */
|
||||
outfile_option, /* next arg is the outfile */
|
||||
pass_on_lint_option, /* Pass to lint1 & lint2 */
|
||||
pass_on_select_option, /* -Qoption handler */
|
||||
pass_on_1_option, /* -x => prog -x */
|
||||
pass_on_1t12_1t_option, /* -xREST => prog -xREST */
|
||||
/* [or] -x REST => prog -xREST */
|
||||
pass_on_1t12_1t_option_pc,
|
||||
/* -config REST => prog -configREST */
|
||||
/* [or] -configREST => prog -configREST */
|
||||
pass_on_1t_option, /* -xREST => prog -xREST */
|
||||
pass_on_12_option, /* -x REST => prog -x REST */
|
||||
pass_on_1to_option, /* -xREST => prog REST */
|
||||
produce_option, /* -Qproduce handler */
|
||||
path_option, /* -Qpath handler */
|
||||
run_m2l_option, /* m2c -e handler */
|
||||
load_m2l_option, /* m2c -E handler */
|
||||
set_int_arg_option, /* Handle simple boolean options */
|
||||
set_named_int_arg_option, /* Handle multiple choice options */
|
||||
set_target_arch_option1,/* -{TARGET} (set target_arch) */
|
||||
set_target_arch_option2,/* -target {TARGET} (set target_arch) */
|
||||
set_target_proc_option1,/* -{PROCESSOR} (set target processor
|
||||
* type & target_arch)
|
||||
*/
|
||||
set_sw_release_option, /* next arg is the target S/W release */
|
||||
temp_dir_option /* Handle -temp option */
|
||||
} Options;
|
||||
|
||||
/*
|
||||
* The Option struct describes one legal option for the driver.
|
||||
*
|
||||
* Fields:
|
||||
* name String with the option expected as an argument
|
||||
* drivers Bitmask (of Z_* values) describing drivers
|
||||
* for which option is legal.
|
||||
* type Of option. Determines what action is taken when
|
||||
* option is seen.
|
||||
* subtype Extra value, for use in decoding option.
|
||||
* variable Associated Named_int
|
||||
* program Program to pass option to
|
||||
* constant Associated Const_int
|
||||
* help String describing option
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
int drivers :16;
|
||||
Options type :8;
|
||||
int subtype :8;
|
||||
Named_intP variable;
|
||||
ProgramP program;
|
||||
Const_intP constant;
|
||||
char *help;
|
||||
} Option, *OptionP;
|
||||
|
||||
/*
|
||||
* Various global binary flags; listed in alphabetical order.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
Bool as_R;
|
||||
Bool checkC;
|
||||
Bool checkH;
|
||||
Bool checkV;
|
||||
#ifdef BROWSER
|
||||
Bool code_browser;
|
||||
Bool code_browser_seen;
|
||||
#endif
|
||||
Bool debug; /* (for internal debugging) */
|
||||
Bool do_cppas;
|
||||
Bool do_cpp;
|
||||
Bool do_dependency;
|
||||
Bool do_cat;
|
||||
Bool do_inline;
|
||||
Bool do_m2l;
|
||||
Bool do_m4;
|
||||
Bool do_ratfor;
|
||||
Bool doing_mod_file;
|
||||
Bool doubleword_aligned_doubles;
|
||||
Bool dryrun;
|
||||
Bool fstore;
|
||||
Bool generate_nonzero_activation_records;
|
||||
Bool handle_misalignment;
|
||||
Bool ignore_lc;
|
||||
Bool junk;
|
||||
Bool long_offset;
|
||||
Bool no_c2;
|
||||
Bool no_default_module_list;
|
||||
Bool onetrip;
|
||||
Bool pic_code;
|
||||
Bool PIC_code;
|
||||
Bool pipe_ok;
|
||||
Bool pure_cross;
|
||||
Bool remove_tmp_files;
|
||||
Bool root_module_seen;
|
||||
Bool show_rm_commands; /* OK to echo "rm" cmds */
|
||||
Bool statement_count;
|
||||
Bool sparc_sdata;
|
||||
Bool sys5_flag; /* For defining sys5 setup */
|
||||
Bool testing_driver; /* For testing the driver */
|
||||
Bool time_run;
|
||||
Bool trace;
|
||||
Bool verbose;
|
||||
Bool vpa;
|
||||
Bool warning;
|
||||
} Global_flag;
|
||||
|
||||
#define FLOAT_OPTION "FLOAT_OPTION"
|
||||
#define MAX_HELP_PREFIX_WIDTH 10
|
||||
#define HELP_STRING_INDENT_DEPTH 21
|
||||
#define MAX_NUMBER_OF_DRIVER_SUPPLIED_ARGS 32
|
||||
#define LOCAL_STRING_LENGTH 1000
|
||||
#define DUMMY_FLAG "/usr/lib"
|
||||
#define DUMMY_LENGTH 8
|
||||
#define XL_FLAG "-xl"
|
||||
|
||||
#define set_named_int(i, v) { (i).value= (v); (i).touched= TRUE;}
|
||||
#define append_list(list, value) \
|
||||
append_list_with_suffix(list, value, (SuffixP)NULL)
|
||||
|
||||
#define uninitialize_flag(flag) global_flag.flag= UNINIT_BOOL
|
||||
#define set_flag(flag) global_flag.flag= TRUE
|
||||
#define reset_flag(flag) global_flag.flag= FALSE
|
||||
#define is_initialized(flag) (global_flag.flag != UNINIT_BOOL)
|
||||
#define is_uninitialized(flag) (!is_initialized(flag))
|
||||
#ifdef DEBUG
|
||||
# define chk_uninit(flag) ( is_initialized(flag) || \
|
||||
(fatal("uninit flag"),FALSE) )
|
||||
# define is_off(flag) (chk_uninit(flag),(global_flag.flag == FALSE))
|
||||
# define is_on(flag) (chk_uninit(flag),(global_flag.flag == TRUE ))
|
||||
#else /*!DEBUG*/
|
||||
# define is_off(flag) (global_flag.flag == FALSE)
|
||||
# define is_on(flag) (global_flag.flag == TRUE )
|
||||
#endif /*DEBUG*/
|
||||
|
||||
/*
|
||||
* The following macros are used to set bitmask fields
|
||||
*/
|
||||
#define HIDE_OPTION 0x0100 /* Do not show option (for -help
|
||||
* option)
|
||||
*/
|
||||
#define NO_MINUS_OPTION 0x0200 /* Option takes extra arg that must not
|
||||
* start with "-"
|
||||
*/
|
||||
#define SOURCE_SUFFIX 0x0400 /* Suffix is suffixes that should be
|
||||
* traced when compiling
|
||||
*/
|
||||
#define HIDE(x) ((x) | HIDE_OPTION)
|
||||
#define NO_MINUS(x) ((x) | NO_MINUS_OPTION)
|
||||
#define SOURCE(x) ((x) | SOURCE_SUFFIX)
|
||||
|
||||
/* Basic values for the different drivers */
|
||||
#define DRIVER_none 0x00
|
||||
#define DRIVER_C 0x01 /* cc */
|
||||
#define DRIVER_F 0x02 /* f77 */
|
||||
#define DRIVER_L 0x04 /* lint */
|
||||
#define DRIVER_M 0x08 /* m2c */
|
||||
#define DRIVER_P 0x10 /* pc */
|
||||
/* Combinations of the above */
|
||||
#define DRIVER_all (DRIVER_C|DRIVER_F|DRIVER_L|DRIVER_M|DRIVER_P)
|
||||
#define DRIVER_CF (DRIVER_C|DRIVER_F)
|
||||
#define DRIVER_CFLM (DRIVER_C|DRIVER_F|DRIVER_L|DRIVER_M)
|
||||
#define DRIVER_CFLMP (DRIVER_C|DRIVER_F|DRIVER_L|DRIVER_M|DRIVER_P)
|
||||
#define DRIVER_CFLP (DRIVER_C|DRIVER_F|DRIVER_L|DRIVER_P)
|
||||
#define DRIVER_CFM (DRIVER_C|DRIVER_F|DRIVER_M)
|
||||
#define DRIVER_CFMP (DRIVER_C|DRIVER_F|DRIVER_M|DRIVER_P)
|
||||
#define DRIVER_CFP (DRIVER_C|DRIVER_F|DRIVER_P)
|
||||
#define DRIVER_CL (DRIVER_C|DRIVER_L)
|
||||
#define DRIVER_CLP (DRIVER_C|DRIVER_L|DRIVER_P)
|
||||
#define DRIVER_CMP (DRIVER_C|DRIVER_M|DRIVER_P)
|
||||
#define DRIVER_CP (DRIVER_C|DRIVER_P)
|
||||
#define DRIVER_FL (DRIVER_F|DRIVER_L)
|
||||
#define DRIVER_FMP (DRIVER_F|DRIVER_M|DRIVER_P)
|
||||
#define DRIVER_LP (DRIVER_L|DRIVER_P)
|
||||
#define DRIVER_MP (DRIVER_M|DRIVER_P)
|
||||
|
||||
#define GOAL_EXE 1
|
||||
#define GOAL_I 2
|
||||
#define GOAL_L 3
|
||||
#define GOAL_O 4
|
||||
#define GOAL_S 5
|
||||
|
||||
#define DEBUG_ADB 1
|
||||
#define DEBUG_DBX 2
|
||||
|
||||
#define PROF_NONE 1
|
||||
#define PROF_OLD 2
|
||||
#define PROF_NEW 3
|
||||
|
||||
#define ARCH_FOREIGN 1 /* Foreign (unknown) architecture. */
|
||||
#define ARCH_SUN2 20 /* Sun-2 */
|
||||
#define ARCH_SUN3 30 /* Sun-3 */
|
||||
#define ARCH_SUN3X 31 /* Sun-3x */
|
||||
#define ARCH_SUN4 40 /* Sun-4 */
|
||||
#define ARCH_SUN4C 41 /* Sun-4c */
|
||||
#define ARCH_SUN386 386 /* Sun-386 */
|
||||
|
||||
/* SW_REL_* values after SW_REL_DFLT are assumed to be in ascending order,
|
||||
* chronologically by release. (The absolute values don't matter, though)
|
||||
*/
|
||||
#define SW_REL_DFLT 1 /* default */
|
||||
#define SW_REL_3X 30 /* "3.x": 3.2, 3.4, 3.5, etc. */
|
||||
#define SW_REL_40 40 /* 4.0 */
|
||||
#define SW_REL_41 41 /* 4.1 */
|
||||
|
||||
/* DRIVER_REL version numbers
|
||||
* this is used when we need to look up a specific
|
||||
* driver version number, instead of the OS release number
|
||||
* as above
|
||||
*/
|
||||
#define DRIVER_REL_10 "1.0"
|
||||
#define DRIVER_REL_11 "1.1"
|
||||
#define DRIVER_REL_12 "1.2"
|
||||
#define DRIVER_REL_20 "2.0"
|
||||
#define DRIVER_REL_40 "4.0"
|
||||
|
||||
#define FLOAT_68881 10
|
||||
#define FLOAT_FPA 20
|
||||
#define FLOAT_SKY 30
|
||||
#define FLOAT_SOFT 40
|
||||
#define FLOAT_SWITCH 50
|
||||
|
||||
/* The driver assumes that the following values are ordered according to
|
||||
* increasing numerical value.
|
||||
*/
|
||||
typedef char OptimLevel;
|
||||
#define OPTIM_NONE '0'
|
||||
#define OPTIM_C2 '1'
|
||||
#define OPTIM_IROPT_P '2'
|
||||
#define OPTIM_IROPT_O '3'
|
||||
#define OPTIM_IROPT_O_TRACK_PTRS '4'
|
||||
|
||||
/* Used as subtypes for options:
|
||||
*/
|
||||
#define PASS_OPT_AS_FLAG 0
|
||||
#define PASS_OPT_AS_INFILE 1
|
||||
|
||||
/* Library routine declarations */
|
||||
extern char *alloca();
|
||||
extern char **environ;
|
||||
extern int errno;
|
||||
extern char *getenv();
|
||||
extern char *getwd();
|
||||
extern char *index();
|
||||
extern char *malloc();
|
||||
extern char *rindex();
|
||||
extern char *sprintf();
|
||||
extern char *strcat();
|
||||
extern char *strcpy();
|
||||
extern char *strncpy();
|
||||
extern char *sys_siglist[];
|
||||
|
||||
/* from ro_data.c & rw_data.c */
|
||||
extern Option options[];
|
||||
extern Option drivers[];
|
||||
extern Step c_iropt_steps[];
|
||||
extern Step c_no_iropt_steps[];
|
||||
extern Step def_steps_3x[];
|
||||
extern Step def_steps_non_3x[];
|
||||
extern Step f_iropt_steps[];
|
||||
extern Step f_no_iropt_steps[];
|
||||
extern Step link_steps[];
|
||||
extern Step link_m2c_steps[];
|
||||
extern Step lint_steps[];
|
||||
extern Step mod_rel3x_steps[];
|
||||
extern Step mod_iropt_steps[];
|
||||
extern Step mod_no_iropt_steps[];
|
||||
extern Step p_rel3x_steps[]; /* for release 3.x Pascal */
|
||||
extern Step p_no_iropt_steps[];/* for release 4.x Pascal */
|
||||
extern Step p_iropt_steps[]; /* for release 4.x Pascal */
|
||||
extern Step pc_steps[];
|
||||
extern Step s_steps[];
|
||||
extern Step anything_thru_cc_E_steps[];
|
||||
extern Step anything_thru_cc_P_steps[];
|
||||
extern Const_intP known_sw_releases[];
|
||||
extern Const_intP known_architectures[];
|
||||
|
||||
/* from compile.c */
|
||||
extern void append_list_with_suffix();
|
||||
extern int check_release_version_driver();
|
||||
extern void cleanup();
|
||||
extern void define_arch_and_sw_release();
|
||||
extern void fatal();
|
||||
extern char *get_file_suffix();
|
||||
extern char *get_memory();
|
||||
extern char *get_processor_type();
|
||||
extern char *get_processor_flag();
|
||||
extern char *lint_lib();
|
||||
extern char *make_string();
|
||||
extern Const_intP sw_release_lookup();
|
||||
extern void warning();
|
||||
|
||||
/* from driver_versions.c */
|
||||
extern Const_intP get_target_base_OS_version();
|
||||
extern char *get_base_driver_version();
|
||||
|
||||
/* from run_pass.c */
|
||||
extern char *outfile_name();
|
||||
extern char *temp_file_name();
|
||||
extern int run_steps();
|
||||
|
||||
/* from setup*.c */
|
||||
extern void cc_doit();
|
||||
extern void clear_program_options();
|
||||
extern void collect_ln();
|
||||
extern void collect_o();
|
||||
extern int compile_c();
|
||||
extern int compile_def();
|
||||
extern int compile_f();
|
||||
extern int compile_F();
|
||||
extern int compile_i();
|
||||
extern int compile_l();
|
||||
extern int compile_mod();
|
||||
extern int compile_r();
|
||||
extern int compile_p();
|
||||
extern int compile_pi();
|
||||
extern int compile_S();
|
||||
extern int compile_s();
|
||||
extern void do_infiles();
|
||||
extern void do_not_unlink_ld_infiles();
|
||||
extern void f1_to_mf1_copy();
|
||||
extern void f77_doit();
|
||||
extern char *get_crt0_name();
|
||||
extern void lint_doit();
|
||||
extern void m2c_doit();
|
||||
extern void pc_doit();
|
||||
extern char *scan_Qpath_and_vroot();
|
||||
extern char *scan_Qpath_only();
|
||||
extern void setup_tcov_file();
|
||||
extern char *setup_as();
|
||||
extern char *setup_as_for_cc();
|
||||
extern char *setup_as_for_f77();
|
||||
extern char *setup_as_for_m2c();
|
||||
extern char *setup_as_for_pc();
|
||||
extern void setup_asS();
|
||||
extern char *setup_asS_for_cc();
|
||||
extern char *setup_asS_for_f77();
|
||||
extern char *setup_asS_for_m2c();
|
||||
extern char *setup_asS_for_pc();
|
||||
extern char *setup_c2();
|
||||
extern char *setup_c2_for_f77();
|
||||
extern char *setup_ccom();
|
||||
extern char *setup_ccom_for_iropt();
|
||||
extern char *setup_cat_for_cc();
|
||||
extern char *setup_cat_for_mod();
|
||||
extern char *setup_cat_for_pc();
|
||||
extern char *setup_cat_for_f77();
|
||||
extern char *setup_cat_for_lint();
|
||||
extern char *setup_cg_all();
|
||||
extern char *setup_cg_f77();
|
||||
extern char *setup_cg_mod();
|
||||
extern char *setup_cg_pc();
|
||||
extern char *setup_cg_for_tcov();
|
||||
extern char *setup_cg_cc_for_tcov();
|
||||
extern char *setup_cg_f77_for_tcov();
|
||||
extern char *setup_cppas();
|
||||
extern char *setup_cpp();
|
||||
extern char *setup_cpp_for_cc();
|
||||
extern char *setup_f1();
|
||||
extern char *setup_f77pass1();
|
||||
extern char *setup_inline();
|
||||
extern char *setup_inline_for_pc();
|
||||
extern char *setup_iropt_all();
|
||||
extern char *setup_iropt_f77();
|
||||
extern char *setup_iropt_mod();
|
||||
extern char *setup_iropt_pc();
|
||||
extern char *setup_ld();
|
||||
extern char *setup_ld_for_cc();
|
||||
extern char *setup_ld_for_f77();
|
||||
extern char *setup_ld_for_pc();
|
||||
extern char *setup_link_step();
|
||||
extern char *setup_lint_l_special();
|
||||
extern char *setup_m2cfe();
|
||||
extern char *setup_m2cfe_for_3x_def();
|
||||
extern char *setup_m2cfe_for_non_3x_def();
|
||||
extern char *setup_m2cfe_for_3x_mod();
|
||||
extern char *setup_m2cfe_for_non_3x_mod();
|
||||
extern char *setup_m2l_for_m2c();
|
||||
extern char *setup_mf1();
|
||||
extern char *setup_pc0();
|
||||
extern char *setup_pc0_for_3x();
|
||||
extern char *setup_pc0_for_non_3x();
|
||||
extern char *setup_pc3();
|
||||
extern char *setup_vpald();
|
||||
extern void set_requested_suffix();
|
||||
|
||||
/* global variables */
|
||||
/* First, all the named_ints and the Const_ints they reference */
|
||||
extern Named_int debugger;
|
||||
extern Const_int adb;
|
||||
extern Const_int dbx;
|
||||
|
||||
extern Named_int driver;
|
||||
extern Const_int cc;
|
||||
extern Const_int dummy;
|
||||
extern Const_int f77;
|
||||
extern Const_int m2c;
|
||||
extern Const_int pc;
|
||||
extern Const_int xlint;
|
||||
|
||||
extern Named_int float_mode;
|
||||
extern Const_int ffpa;
|
||||
extern Const_int fsky;
|
||||
extern Const_int fsoft;
|
||||
extern Const_int fswitch;
|
||||
extern Const_int f68881;
|
||||
|
||||
extern Named_int host_arch;
|
||||
extern Named_int target_arch;
|
||||
extern Const_int arch_sun2;
|
||||
extern Const_int arch_sun386;
|
||||
extern Const_int arch_sun3x;
|
||||
extern Const_int arch_sun3;
|
||||
extern Const_int arch_sun4c;
|
||||
extern Const_int arch_sun4;
|
||||
extern Const_int arch_foreign;
|
||||
|
||||
/* Note that if the following "R_" constants are
|
||||
* modified, the corresponding initializations of
|
||||
* target_sw_release[] (in rw_data.c) must be modified.
|
||||
*/
|
||||
#define R_VROOT 0
|
||||
#define R_PATHS 1
|
||||
#define R_PASSES 2
|
||||
#define R_elements 3 /* number of elements */
|
||||
/* R_all is used when referring to all R_elements
|
||||
* elements of target_sw_release[], as a group.
|
||||
*/
|
||||
#define R_all R_elements
|
||||
extern Named_int target_sw_release[R_elements];
|
||||
extern Const_int sw_release_default; /* default */
|
||||
extern Const_int sw_release_3x_explicit; /* 3.x */
|
||||
extern Const_int sw_release_40_explicit; /* 4.0 */
|
||||
extern Const_int sw_release_41_explicit; /* 4.1 */
|
||||
extern Const_int sw_release_3x_implicit; /* 3.x */
|
||||
extern Const_int sw_release_40_implicit; /* 4.0 */
|
||||
extern Const_int sw_release_41_implicit; /* 4.1 */
|
||||
|
||||
extern Named_int product;
|
||||
extern Const_int lint1_file;
|
||||
extern Const_int preprocessed; /* -E output, to stdout */
|
||||
extern Const_int preprocessed2; /* -P output, to file.i */
|
||||
extern Const_int object;
|
||||
extern Const_int assembler;
|
||||
extern Const_int executable;
|
||||
|
||||
extern Named_int profile;
|
||||
extern Const_int gprof;
|
||||
extern Const_int no_prof;
|
||||
extern Const_int prof;
|
||||
|
||||
extern char **argv_for_passes;
|
||||
extern char *base_driver_release;
|
||||
#ifdef BROWSER
|
||||
extern char *browser_options;
|
||||
#endif
|
||||
extern char *debug_info_filename;
|
||||
extern int exit_status;
|
||||
extern ListP files_to_unlink;
|
||||
extern Global_flag global_flag;
|
||||
extern ListP infile;
|
||||
extern int infile_count;
|
||||
extern ListP infile_ln;
|
||||
extern ListP infile_o;
|
||||
extern char *iropt_files[3];
|
||||
extern int last_program_path;
|
||||
extern char *ld_to_vpa_file;
|
||||
extern int make_lint_lib_fd;
|
||||
extern ListP module_list;
|
||||
extern int optim_after_cat;
|
||||
extern OptimLevel optimizer_level;
|
||||
extern char *outfile;
|
||||
extern Programs program;
|
||||
extern char *program_name;
|
||||
extern pathpt program_path;
|
||||
extern ListP report;
|
||||
extern SuffixP requested_suffix;
|
||||
extern char *to_as_file;
|
||||
extern int source_infile_count;
|
||||
extern Suffixes suffix;
|
||||
extern char *tcov_file;
|
||||
extern char *temp_dir;
|
||||
extern int temp_file_number;
|
||||
extern ListP temp_files_named;
|
||||
extern int use_default_optimizer_level;
|
||||
334
lang/compile/driver_version.c
Normal file
334
lang/compile/driver_version.c
Normal file
@@ -0,0 +1,334 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)driver_version.c 1.1 94/10/31 SMI";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/file.h> /* for access() function args */
|
||||
#include "driver.h"
|
||||
|
||||
|
||||
static char *
|
||||
path_plus_filename(path, filename)
|
||||
char *path;
|
||||
char *filename;
|
||||
{
|
||||
char *fullpath;
|
||||
|
||||
fullpath = get_memory( strlen(path)
|
||||
+ 1 /*"/"*/
|
||||
+ strlen(filename)
|
||||
+ 1 /*'\0'*/
|
||||
);
|
||||
sprintf(fullpath, "%s/%s", path, filename);
|
||||
|
||||
return fullpath;
|
||||
}
|
||||
|
||||
|
||||
static FILE *
|
||||
open_driver_versions_file(root_path)
|
||||
char *root_path;
|
||||
{
|
||||
char *info_filename;
|
||||
FILE *fp;
|
||||
static char raw_info_filename[] = "/usr/lib/lang_info";
|
||||
|
||||
/* Look for the Info File using Qpath.
|
||||
* If that fails, look for it under the given virtual root.
|
||||
*/
|
||||
if ((info_filename = scan_Qpath_only(raw_info_filename, FALSE)) == NULL)
|
||||
{
|
||||
info_filename =
|
||||
path_plus_filename(root_path, &raw_info_filename[1]);
|
||||
/* info_filename is now {ROOTPATH}/usr/lib/lang_info . */
|
||||
}
|
||||
|
||||
fp = fopen(info_filename, "r");
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
debug_info_filename = make_string("lang_info not found");
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_info_filename = make_string(info_filename);
|
||||
}
|
||||
|
||||
free(info_filename);
|
||||
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
close_driver_versions_file(filep)
|
||||
FILE *filep;
|
||||
{
|
||||
fclose(filep);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
get_version_line(filep, product_namep, product_versionp, base_os_versionp)
|
||||
FILE *filep;
|
||||
char *product_namep;
|
||||
char *product_versionp;
|
||||
char *base_os_versionp;
|
||||
{
|
||||
char line[LOCAL_STRING_LENGTH];
|
||||
|
||||
/* Each line of the file contains these fields, in order:
|
||||
* product name (string)
|
||||
* product version # (string)
|
||||
* base-OS version # (string)
|
||||
* (possibly other info, which we ignore for now)
|
||||
*
|
||||
* Lines beginning with "#" are comment lines.
|
||||
*/
|
||||
|
||||
while ( fgets(line, LOCAL_STRING_LENGTH, filep) != NULL )
|
||||
{
|
||||
if ( ( 3 == sscanf(line, "%s %s %s", product_namep,
|
||||
product_versionp, base_os_versionp) )
|
||||
&&
|
||||
( *product_namep != '#' )
|
||||
)
|
||||
{
|
||||
/* Got a real product line (not blank or a comment) */
|
||||
return ~NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* fgets() returned NULL, so we hit EOF. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static Const_intP
|
||||
get_base_os_version(filep, driver)
|
||||
FILE *filep;
|
||||
Const_int *driver;
|
||||
{
|
||||
char product_name[LOCAL_STRING_LENGTH];
|
||||
char product_version[LOCAL_STRING_LENGTH];
|
||||
char base_os_version[LOCAL_STRING_LENGTH];
|
||||
char drivers_base_os_version[LOCAL_STRING_LENGTH];
|
||||
|
||||
drivers_base_os_version[0] = '\0';
|
||||
|
||||
while ( get_version_line(filep, &product_name[0], &product_version[0],
|
||||
&base_os_version[0]) != NULL )
|
||||
{
|
||||
/* Note that a product version of "-" causes this line in the
|
||||
* info file to be ignored. This can be used to leave a
|
||||
* "template" or "placeholder" line in the file for a product
|
||||
* which has not yet been installed, or has be de-intalled.
|
||||
*
|
||||
* In this case, base_os_version should also be "-", although
|
||||
* it is not checked.
|
||||
*/
|
||||
if ( STR_EQUAL(driver->extra, product_name) &&
|
||||
(! STR_EQUAL(product_version, "-"))
|
||||
)
|
||||
{
|
||||
/* This line in the version file applies to this
|
||||
* driver!
|
||||
*/
|
||||
strcpy(drivers_base_os_version, base_os_version);
|
||||
}
|
||||
}
|
||||
|
||||
/* get_version_line() returned NULL, so we've reached EOF on the
|
||||
* version file.
|
||||
*/
|
||||
|
||||
if ( drivers_base_os_version[0] == '\0' )
|
||||
{
|
||||
/* We never found a line for this driver.
|
||||
* Indictate this failure by returning NULL.
|
||||
*/
|
||||
return (Const_intP)NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We did find a line (at least one) for this driver.
|
||||
* Now look up its base-os version# among the versions we
|
||||
* know about.
|
||||
*/
|
||||
return sw_release_lookup(drivers_base_os_version);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns TRUE if the given file exists; FALSE otherwise.
|
||||
*/
|
||||
static Bool
|
||||
file_exists(path)
|
||||
char *path;
|
||||
{
|
||||
extern int access();
|
||||
|
||||
return ( access(path, F_OK) == 0 );
|
||||
}
|
||||
|
||||
|
||||
Const_intP
|
||||
get_target_base_OS_version(root_path, driver)
|
||||
char *root_path;
|
||||
Const_int *driver;
|
||||
{
|
||||
FILE *info_file_fp;
|
||||
Const_intP driver_version;
|
||||
|
||||
/* First, look for the magic version file. */
|
||||
info_file_fp = open_driver_versions_file(root_path);
|
||||
|
||||
if (info_file_fp == NULL)
|
||||
{
|
||||
/* If it's not even present, then we either have a 3.x release,
|
||||
* or a 4.0 release which doesn't have a versions file.
|
||||
*
|
||||
* If the file /usr/lib/crt0.o exists, then we assume that it's
|
||||
* a R4.0 file organization, since R3.x did not have that file.
|
||||
* [this is a grungy(!) way to do it, but we have to decide
|
||||
* SOME way if the lang_info file isn't present].
|
||||
*/
|
||||
char *crt0_filename;
|
||||
|
||||
crt0_filename = path_plus_filename(root_path, "usr/lib/crt0.o");
|
||||
/* crt0_filename is now {ROOTPATH}/usr/lib/crt0.o . */
|
||||
|
||||
if ( file_exists(crt0_filename) )
|
||||
{
|
||||
driver_version = &sw_release_40_implicit;
|
||||
if(is_on(debug))
|
||||
{
|
||||
fprintf(stderr,"[baseOS=4.0 (/usr/lib/crt0.o)]\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
driver_version = &sw_release_3x_implicit;
|
||||
if(is_on(debug))
|
||||
{
|
||||
fprintf(stderr,"[baseOS=3.x (!/usr/lib/crt0.o)]\n");
|
||||
}
|
||||
}
|
||||
|
||||
free(crt0_filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The magic version file is here (true for Rel 4.0 & later)!
|
||||
* Scan it for the version number of the product, whose driver
|
||||
* we're impersonating. Well, actually, don't look at the
|
||||
* PRODUCT's version number; look at the BASE O/S version #.
|
||||
*/
|
||||
driver_version =
|
||||
get_base_os_version(info_file_fp, driver);
|
||||
|
||||
if ( driver_version == NULL )
|
||||
{
|
||||
fatal("Product \"%s\" is not installed.\n",
|
||||
driver->extra);
|
||||
}
|
||||
|
||||
close_driver_versions_file(info_file_fp);
|
||||
}
|
||||
|
||||
return driver_version;
|
||||
}
|
||||
|
||||
|
||||
/* look up what driver version is being used */
|
||||
static char
|
||||
*get_driver_version(filep, driver)
|
||||
FILE *filep;
|
||||
Const_int *driver;
|
||||
{
|
||||
char product_name[LOCAL_STRING_LENGTH];
|
||||
char product_version[LOCAL_STRING_LENGTH];
|
||||
char base_os_version[LOCAL_STRING_LENGTH];
|
||||
char drivers_base_version[LOCAL_STRING_LENGTH];
|
||||
|
||||
drivers_base_version[0] = '\0';
|
||||
|
||||
while ( get_version_line(filep, &product_name[0], &product_version[0],
|
||||
&base_os_version[0]) != NULL )
|
||||
{
|
||||
/* Note that a product version of "-" causes this line in the
|
||||
* info file to be ignored. This can be used to leave a
|
||||
* "template" or "placeholder" line in the file for a product
|
||||
* which has not yet been installed, or has be de-intalled.
|
||||
*
|
||||
* In this case, base_version should also be "-", although
|
||||
* it is not checked.
|
||||
*/
|
||||
if ( STR_EQUAL(driver->extra, product_name) &&
|
||||
(! STR_EQUAL(product_version, "-"))
|
||||
)
|
||||
{
|
||||
/* This line in the version file applies to this
|
||||
* driver!
|
||||
*/
|
||||
strcpy(drivers_base_version, product_version);
|
||||
}
|
||||
}
|
||||
|
||||
/* get_version_line() returned NULL, so we've reached EOF on the
|
||||
* version file.
|
||||
*/
|
||||
|
||||
if ( drivers_base_version[0] == '\0' )
|
||||
{
|
||||
/* We never found a line for this driver.
|
||||
* Indictate this failure by returning NULL.
|
||||
*/
|
||||
return (char)NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (drivers_base_version);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char
|
||||
*get_base_driver_version(root_path, driver)
|
||||
char *root_path;
|
||||
Const_int *driver;
|
||||
{
|
||||
FILE *info_file_fp;
|
||||
char *driver_version;
|
||||
|
||||
/* First, look for the magic version file. */
|
||||
info_file_fp = open_driver_versions_file(root_path);
|
||||
|
||||
/* if not found, thats ok, because we only need the
|
||||
* driver version for 4.0 and later versions
|
||||
* so return null means it is not found.
|
||||
*/
|
||||
if (info_file_fp == NULL)
|
||||
{
|
||||
return make_string("Unknown");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The magic version file is here (true for Rel 4.0 & later)!
|
||||
* Scan it for the version number of the of the driver
|
||||
* product, whose driver we're impersonating.
|
||||
*/
|
||||
driver_version =
|
||||
get_driver_version(info_file_fp, driver);
|
||||
|
||||
close_driver_versions_file(info_file_fp);
|
||||
}
|
||||
|
||||
return make_string(driver_version);
|
||||
|
||||
}
|
||||
984
lang/compile/ro_data.c
Normal file
984
lang/compile/ro_data.c
Normal file
@@ -0,0 +1,984 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)ro_data.c 1.53 88/09/26 SMI";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "driver.h"
|
||||
|
||||
/* Suffixes. */
|
||||
Suffixes suffix=
|
||||
{
|
||||
{ "a", DRIVER_CFMP, DRIVER_none, NULL, collect_o, "Object library" },
|
||||
{ "c", SOURCE(DRIVER_CFLMP), DRIVER_C, compile_c, NULL, "C source" },
|
||||
{ "def", SOURCE(DRIVER_M), DRIVER_none, compile_def, NULL, "Module definitions" },
|
||||
{ "f", SOURCE(DRIVER_CFMP), DRIVER_F, compile_f, NULL, "F77 source" },
|
||||
{ "F", SOURCE(DRIVER_CFMP), DRIVER_none, compile_F, NULL, "F77 source for cpp" },
|
||||
{ "il", DRIVER_CFMP, DRIVER_none, NULL, NULL, "Inline expansion file" },
|
||||
{ "i", SOURCE(DRIVER_CL), DRIVER_C, compile_i, NULL, "C source after cpp" },
|
||||
{ "ln", DRIVER_L, DRIVER_L, NULL, collect_ln, "Lint library" },
|
||||
{ "mod", SOURCE(DRIVER_M), DRIVER_none, compile_mod, NULL, "Modula-2 source" },
|
||||
{ "o", DRIVER_CFMP, DRIVER_CFMP, NULL, collect_o, "Object file" },
|
||||
{ "pas", SOURCE(DRIVER_P), DRIVER_none, compile_p, NULL, "Pascal source" },
|
||||
{ "pi", SOURCE(DRIVER_P), DRIVER_P, compile_pi, NULL, "Pascal source after cpp" },
|
||||
{ "p", SOURCE(DRIVER_CFMP), DRIVER_none, compile_p, NULL, "Pascal source" },
|
||||
{ "r", SOURCE(DRIVER_CFMP), DRIVER_none, compile_r, NULL, "Ratfor source" },
|
||||
{ "sym", DRIVER_none, DRIVER_M, NULL, NULL, "Modula2 Symbol file" },
|
||||
{ "s", SOURCE(DRIVER_CFMP), DRIVER_CFMP, compile_s, NULL, "Assembler source" },
|
||||
{ "so", DRIVER_CFMP, DRIVER_none, NULL, collect_o, "Shared object" },
|
||||
{ "S", SOURCE(DRIVER_CFMP), DRIVER_none, compile_S, NULL, "Assembler source for cpp" },
|
||||
{ "ir", DRIVER_none, DRIVER_none, NULL, NULL, "IR Intermediate file" },
|
||||
{ "none", DRIVER_none, DRIVER_none, NULL, NULL, "Intermediate file" },
|
||||
};
|
||||
|
||||
|
||||
/* Drivers. */
|
||||
Const_int cc= { DRIVER_C, (char *)cc_doit, "c" };
|
||||
Const_int dummy= { DRIVER_none, NULL, "(none)" };
|
||||
Const_int f77= { DRIVER_F, (char *)f77_doit,"fortran"};
|
||||
Const_int xlint= { DRIVER_L, (char *)lint_doit,"lint" };
|
||||
Const_int m2c= { DRIVER_M, (char *)m2c_doit,"modula2"};
|
||||
Const_int pc= { DRIVER_P, (char *)pc_doit, "pascal" };
|
||||
|
||||
|
||||
/* Debuggers. */
|
||||
Const_int adb= { DEBUG_ADB, "adb", NULL };
|
||||
Const_int dbx= { DEBUG_DBX, "dbx", NULL };
|
||||
|
||||
|
||||
/* Compilation "goals". */
|
||||
Const_int assembler= { GOAL_S, "assembly-source", NULL };
|
||||
Const_int preprocessed= { GOAL_I, "source", NULL };
|
||||
Const_int preprocessed2= { GOAL_I, "source", NULL };
|
||||
Const_int executable= { GOAL_EXE, "executable", NULL };
|
||||
Const_int lint1_file= { GOAL_L, "lint", NULL };
|
||||
Const_int object= { GOAL_O, "object", NULL };
|
||||
|
||||
|
||||
/* Floating-point types. */
|
||||
Const_int fswitch= { FLOAT_SWITCH, "-fswitch", NULL };
|
||||
/* (the rest are in rw_data.c) */
|
||||
|
||||
|
||||
/* System architectures. */
|
||||
Const_int arch_sun2= { ARCH_SUN2, "-target sun2", "sun2" };
|
||||
Const_int arch_sun3x= { ARCH_SUN3X, "-target sun3x","sun3x"};
|
||||
Const_int arch_sun386= { ARCH_SUN386,"-target sun386",
|
||||
"sun386"};
|
||||
Const_int arch_sun3= { ARCH_SUN3, "-target sun3", "sun3" };
|
||||
Const_int arch_sun4c= { ARCH_SUN4C, "-target sun4c", "sun4c" };
|
||||
Const_int arch_sun4= { ARCH_SUN4, "-target sun4", "sun4" };
|
||||
|
||||
Const_intP known_architectures[]=
|
||||
{
|
||||
#if defined(CROSS) || defined(sun2)
|
||||
&arch_sun2,
|
||||
#endif /*defined(CROSS) || defined(sun2)*/
|
||||
#if defined(CROSS) || defined(sun3x)
|
||||
&arch_sun3x, /* must come before 3*/
|
||||
#endif /*defined(CROSS) || defined(sun3x)*/
|
||||
#if defined(CROSS) || defined(sun386)
|
||||
&arch_sun386,/* must come before 3*/
|
||||
#endif /*defined(CROSS) || defined(sun386)*/
|
||||
#if defined(CROSS) || defined(sun3)
|
||||
&arch_sun3,
|
||||
#endif /*defined(CROSS) || defined(sun3)*/
|
||||
#if defined(CROSS) || defined(sun4c)
|
||||
&arch_sun4c,
|
||||
#endif /*defined(CROSS) || defined(sun4c)*/
|
||||
#if defined(CROSS) || defined(sun4)
|
||||
&arch_sun4,
|
||||
#endif /*defined(CROSS) || defined(sun4)*/
|
||||
(Const_intP)NULL
|
||||
};
|
||||
|
||||
|
||||
/* Target software releases. */
|
||||
Const_int sw_release_default=
|
||||
{ SW_REL_DFLT, "", "" };
|
||||
|
||||
Const_int sw_release_3x_implicit=
|
||||
{ SW_REL_3X, "3.x", "" };
|
||||
Const_int sw_release_41_implicit=
|
||||
{ SW_REL_41, "4.1", "" };
|
||||
|
||||
Const_int sw_release_3x_explicit=
|
||||
{ SW_REL_3X, "3.x", "R3.2" };
|
||||
Const_int sw_release_32_explicit=
|
||||
{ SW_REL_3X, "3.2", "R3.2" };
|
||||
Const_int sw_release_34_explicit=
|
||||
{ SW_REL_3X, "3.4", "R3.2" };
|
||||
Const_int sw_release_35_explicit=
|
||||
{ SW_REL_3X, "3.5", "R3.2" };
|
||||
Const_int sw_release_sys4_explicit=
|
||||
{ SW_REL_3X, "sys4-3.2", "R3.2" };
|
||||
Const_int sw_release_40_implicit=
|
||||
{ SW_REL_40, "4.0", "" };
|
||||
Const_int sw_release_40_explicit=
|
||||
{ SW_REL_40, "4.0", "R4.0" };
|
||||
Const_int sw_release_41_explicit=
|
||||
{ SW_REL_41, "4.1", "R4.1" };
|
||||
|
||||
Const_intP known_sw_releases[]=
|
||||
{
|
||||
&sw_release_3x_explicit,
|
||||
&sw_release_32_explicit,
|
||||
&sw_release_34_explicit,
|
||||
&sw_release_35_explicit,
|
||||
&sw_release_sys4_explicit,
|
||||
&sw_release_40_explicit,
|
||||
&sw_release_41_explicit,
|
||||
(Const_intP)NULL
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define OPTION(name, driver, type, help) \
|
||||
{ (name), (driver), (type), 0, NULL, NULL, NULL, (help) },
|
||||
|
||||
/* OPTION_SET_SW_REL: used to set one (or all) of the internal
|
||||
* Software Release options.
|
||||
*/
|
||||
#define OPTION_SET_SW_REL(name, driver, which, help) \
|
||||
{ (name), (driver), set_sw_release_option, (which), NULL, NULL, (help)},
|
||||
|
||||
/* OPTION_SET0: presence of the cmd-line flag causes the given global
|
||||
* flag to be set to 0 (FALSE).
|
||||
*/
|
||||
#define OPTION_SET0(name, driver, flag, help) \
|
||||
{ (name), (driver), set_int_arg_option, 0, (Named_intP)(&global_flag.flag), NULL, (Const_intP)0, (help)},
|
||||
|
||||
/* OPTION_SET1: presence of the cmd-line flag causes the given global
|
||||
* flag to be set to 1 (TRUE).
|
||||
*/
|
||||
#define OPTION_SET1(name, driver, flag, help) \
|
||||
{ (name), (driver), set_int_arg_option, 0, (Named_intP)(&global_flag.flag), NULL, (Const_intP)1, (help)},
|
||||
|
||||
/* OPTION_SET ... */
|
||||
#define OPTION_SET(name, driver, flag, arg, help) \
|
||||
{ (name), (driver), set_named_int_arg_option, 0, &(flag), NULL, &(arg), (help)},
|
||||
|
||||
/* OPTION_TARGET_ARCH1 causes the variable pointed to by "flag" to be
|
||||
* given the (Const_int) value pointed to by "arg".
|
||||
*/
|
||||
#define OPTION_TARGET_ARCH1(name, driver, flag, arg, help) \
|
||||
{ (name), (driver), set_target_arch_option1, 0, &(flag), NULL, &(arg), (help)},
|
||||
|
||||
/* OPTION_TARGET_ARCH2:
|
||||
* option_target_arch2: -target {TARGET} ==> (lookup {TARGET})
|
||||
* causes the (target architecture) variable pointed to by "flag"
|
||||
* to be given a (Const_int) value, which is determied by looking
|
||||
* up the name given by the following argument.
|
||||
*/
|
||||
#define OPTION_TARGET_ARCH2(name, driver, flag, help) \
|
||||
{ (name), (driver), set_target_arch_option2, 0, &(flag), NULL, NULL, (help)},
|
||||
|
||||
/* OPTION_TARGET_PROC1 causes the variable pointed to by "flag" to be
|
||||
* given the (Const_int) value pointed to by "arg".
|
||||
* It also triggers special handling for target processor types
|
||||
* (target architecture types are normally used, not processor
|
||||
* types).
|
||||
*/
|
||||
#define OPTION_TARGET_PROC1(name, driver, flag, arg, help) \
|
||||
{ (name), (driver), set_target_proc_option1, 0, &(flag), NULL, &(arg), (help)},
|
||||
|
||||
/* OPTION_PASS_ON_1:
|
||||
* pass_on_1_option: -x => prog -x
|
||||
*/
|
||||
#define OPTION_PASS_ON_1(name, driver, prog, help) \
|
||||
{ (name), (driver), pass_on_1_option, 0, NULL, &(program.prog), NULL, (help)},
|
||||
|
||||
/* OPTION_PASS_ON_1T:
|
||||
* pass_on_1t_option: -xREST => prog -xREST
|
||||
*/
|
||||
#define OPTION_PASS_ON_1T(name, driver, prog, help) \
|
||||
{ (name), (driver), pass_on_1t_option, PASS_OPT_AS_FLAG, NULL, &(program.prog), NULL, (help)},
|
||||
|
||||
/* OPTION_PASS_ON_1T_INFILE:
|
||||
* pass_on_1t_option: -xREST => prog -xREST
|
||||
* (but -xREST is passed with the infiles)
|
||||
*/
|
||||
#define OPTION_PASS_ON_1T_INFILE(name, driver, prog, help) \
|
||||
{ (name), (driver), pass_on_1t_option, PASS_OPT_AS_INFILE, NULL, &(program.prog), NULL, (help)},
|
||||
|
||||
|
||||
/* OPTION_PASS_ON_1T_OR_12_AS_1T:
|
||||
* pass_on_1t12_1t_option: -xREST => prog -xREST
|
||||
* [or] -x REST => prog -xREST
|
||||
*/
|
||||
#define OPTION_PASS_ON_1T_OR_12_AS_1T(name, driver, prog, help) \
|
||||
{ (name), (driver), pass_on_1t12_1t_option, 0, NULL, &(program.prog), NULL, (help)},
|
||||
|
||||
/* OPTION_PASS_ON_1T_OR_12_AS_1T_PC:
|
||||
* pass_on_1t12_1t_option_pc: -configREST => prog -configREST
|
||||
* [or] -config REST=> prog -configREST
|
||||
*/
|
||||
#define OPTION_PASS_ON_1T_OR_12_AS_1T_PC(name, driver, prog, help) \
|
||||
{ (name), (driver), pass_on_1t12_1t_option_pc, 0, NULL, &(program.prog), NULL, (help)},
|
||||
|
||||
/* OPTION_PASS_ON_1TO:
|
||||
* pass_on_1to_option: -xREST => prog REST
|
||||
*/
|
||||
#define OPTION_PASS_ON_1TO(name, driver, prog, help) \
|
||||
{ (name), (driver), pass_on_1to_option, 0, NULL, &(program.prog), NULL, (help)},
|
||||
|
||||
|
||||
/* OPTION_PASS_ON_12:
|
||||
* pass_on_12_option: -x REST => prog -x REST
|
||||
*/
|
||||
#define OPTION_PASS_ON_12(name, driver, prog, help) \
|
||||
{ (name), (driver), pass_on_12_option, 0, NULL, &(program.prog), NULL, (help)},
|
||||
#define END_OF_OPTIONS() { NULL, 0, end_of_list, 0, NULL, NULL, NULL, NULL}
|
||||
|
||||
|
||||
Option options[]=
|
||||
{
|
||||
/*
|
||||
* Order is important in this table!
|
||||
*
|
||||
* Long strings *must* come before short ones, since the first partial
|
||||
* match is used.
|
||||
*
|
||||
* Options are listed in this table in alphabetical order, except when
|
||||
* this violates the above rule. (This is by convention, not necessity).
|
||||
*/
|
||||
|
||||
OPTION_PASS_ON_1("-66", DRIVER_F, f77pass1, "Report non FORTRAN-66 constructs as errors")
|
||||
|
||||
OPTION_PASS_ON_12("-align", NO_MINUS(DRIVER_CFMP), ld, "Page align and pad symbol X (for ld)")
|
||||
OPTION_PASS_ON_1("-ansi", DRIVER_F, f77pass1, "Report non-ANSI extensions.")
|
||||
OPTION_PASS_ON_12("-assert", DRIVER_C, ld, "Specify link time assertion")
|
||||
OPTION("-a", DRIVER_L, pass_on_lint_option, "Report assignments of long values to int variables")
|
||||
|
||||
#ifndef sun386
|
||||
OPTION_SET1("-a", DRIVER_CFM, statement_count, "Prepare to count # of times each basic block is executed")
|
||||
#else
|
||||
OPTION_SET1("-a", DRIVER_F, statement_count, "Prepare to count # of times each basic block is executed")
|
||||
#endif
|
||||
|
||||
#ifndef sun386
|
||||
OPTION_PASS_ON_1TO("-A", DRIVER_C, as, "Obsolete. Use \"-Qoption as X\".")
|
||||
OPTION_PASS_ON_12("-A", HIDE(DRIVER_FMP), ld, "Incremental linking")
|
||||
OPTION_SET1("-bnzero", HIDE(DRIVER_C), generate_nonzero_activation_records, "Generate code with nonzero activation_records")
|
||||
#endif /*!sun386*/
|
||||
|
||||
OPTION("-b", DRIVER_L, pass_on_lint_option, "Report break statements that can not be reached")
|
||||
OPTION_PASS_ON_1("-b", DRIVER_P, pc0, "Buffer 'output' in blocks, not lines")
|
||||
|
||||
/* "-B" is treated like an "infile", to keep args to ld correct in the
|
||||
* face of command lines like: "cc -Bstatic -lfoo.a -Bdynamic -lbar.a".
|
||||
*/
|
||||
#ifdef sun386
|
||||
OPTION_PASS_ON_1T_INFILE("-B", DRIVER_C, ld,"Specify the binding types")
|
||||
#else
|
||||
OPTION_PASS_ON_1T_INFILE("-B", DRIVER_CFMP, ld,"Specify the binding types")
|
||||
#endif
|
||||
|
||||
OPTION_PASS_ON_1T_OR_12_AS_1T_PC("-config", HIDE(DRIVER_P), cpp, "Define cppas symbol X (for cppas)")
|
||||
OPTION_PASS_ON_1("-cond", HIDE(DRIVER_P), cpp , "Apollo specific flag")
|
||||
#ifdef BROWSER
|
||||
OPTION_SET1("-cb", DRIVER_CFP, code_browser_seen, "Collect information for code browser")
|
||||
#endif
|
||||
OPTION_SET("-c", DRIVER_CFP, product, object, "Produce '.o' file. Do not run ld.")
|
||||
OPTION("-c", DRIVER_L, pass_on_lint_option, "Complain about casts with questionable portability")
|
||||
OPTION_PASS_ON_1("-C", DRIVER_C, cpp, "Make cpp preserve C style comments")
|
||||
|
||||
OPTION_PASS_ON_1("-C", DRIVER_F, f77pass1, "Generate code to check subscripts")
|
||||
|
||||
OPTION_SET1("-C", DRIVER_P, checkC, "Generate code to check subscripts and subranges")
|
||||
OPTION("-C", DRIVER_L, make_lint_lib_option, NULL)
|
||||
#ifndef sun386
|
||||
OPTION_SET1("-dalign", DRIVER_CFMP, doubleword_aligned_doubles, "Assume that all double-prec f.p. values are doubleword aligned.")
|
||||
#endif
|
||||
OPTION_SET1("-debug", HIDE(DRIVER_all), debug, "[internal debugging]")
|
||||
OPTION_SET1("-dryrun", DRIVER_all, dryrun, "Show but do not execute the cmds constructed by the driver")
|
||||
|
||||
#ifndef sun386
|
||||
OPTION_SET0("-dl", HIDE(DRIVER_C), sparc_sdata, "Generate all data-segment references \"long\" for SPARC")
|
||||
OPTION_SET1("-ds", HIDE(DRIVER_C), sparc_sdata, "Generate Small-Data Segment references for SPARC")
|
||||
|
||||
OPTION_PASS_ON_1("-d", DRIVER_F, f77pass1, "Debug/trace option")
|
||||
OPTION_PASS_ON_1("-d", HIDE(DRIVER_CMP), ld, "Force definition of common")
|
||||
#endif /*!sun386*/
|
||||
|
||||
OPTION_PASS_ON_1T_OR_12_AS_1T("-D", DRIVER_CFLP, cpp, "Define cpp symbol X (for cpp)")
|
||||
OPTION_PASS_ON_1("-e", DRIVER_F, f77pass1, "Recognize extended (132 character) source lines")
|
||||
OPTION("-e", NO_MINUS(DRIVER_M), run_m2l_option, NULL)
|
||||
OPTION("-E", NO_MINUS(DRIVER_M), load_m2l_option, NULL)
|
||||
OPTION_SET("-E", DRIVER_C, product, preprocessed, "Run source thru cpp, output to stdout")
|
||||
#ifndef sun386
|
||||
OPTION_SET("-f68881", DRIVER_CFMP, float_mode, f68881, NULL)
|
||||
OPTION_SET("-ffpa", DRIVER_CFMP, float_mode, ffpa, NULL)
|
||||
OPTION_SET("-fsky", DRIVER_CFMP, float_mode, fsky, NULL)
|
||||
OPTION_SET("-fsoft", DRIVER_CFMP, float_mode, fsoft, NULL)
|
||||
#endif
|
||||
OPTION_SET1("-fstore", DRIVER_CF, fstore, "Force assignments to write to memory")
|
||||
#ifndef sun386
|
||||
OPTION_SET("-fswitch", DRIVER_CFMP, float_mode, fswitch, NULL)
|
||||
#endif
|
||||
OPTION_PASS_ON_1("-fsingle2", DRIVER_C, ccom, "Pass float values as float not double")
|
||||
OPTION_PASS_ON_1("-fsingle", DRIVER_C, ccom, "Use single precision arithmetic when 'float' only")
|
||||
#ifndef sun386
|
||||
OPTION_PASS_ON_1("-f", DRIVER_F, f77pass1, "Force non-standard alignment of 8-byte quantities")
|
||||
#endif
|
||||
|
||||
OPTION_SET("-F", DRIVER_F, product, preprocessed2,"Run cpp/ratfor only")
|
||||
|
||||
OPTION_SET("-go", DRIVER_C, debugger, adb, "Generate extra information for adb")
|
||||
OPTION_SET("-g", DRIVER_CFMP, debugger, dbx, "Generate extra information for dbx")
|
||||
OPTION("-host=", DRIVER_L, lint1_option, "specify host to lint1")
|
||||
OPTION("-help", DRIVER_all, help_option, NULL)
|
||||
OPTION("-h", DRIVER_L, pass_on_lint_option, "Be heuristic")
|
||||
OPTION_SET1("-H", DRIVER_P, checkH, "Generate code to check heap pointers")
|
||||
|
||||
#if defined(CROSS) || defined(i386)
|
||||
OPTION_TARGET_PROC1("-i386", HIDE(DRIVER_all), target_arch, arch_sun386, "Generate 80386 .o's")
|
||||
#endif /*defined(CROSS) || defined(i386)*/
|
||||
|
||||
OPTION_PASS_ON_1("-i2", DRIVER_F, f77pass1, "Make integers be two bytes by default")
|
||||
OPTION_PASS_ON_1("-i4", DRIVER_F, f77pass1, "Make integers be four bytes by default")
|
||||
|
||||
OPTION_PASS_ON_12("-i", DRIVER_P, pc0, "Produce list of module")
|
||||
OPTION("-i", DRIVER_L, lint_i_option, "Run lint pass1 only. Leave '.ln' files")
|
||||
OPTION_PASS_ON_1T("-I", DRIVER_CFLP, cpp, "Add directory X to cpp include path (for cpp)")
|
||||
|
||||
#ifndef sun386
|
||||
OPTION_SET1("-J", DRIVER_CMP, long_offset, "Generate long offsets for switch/case statements")
|
||||
#endif /*!sun386*/
|
||||
|
||||
OPTION_SET0("-keeptmp", HIDE(DRIVER_all), remove_tmp_files, "keep /tmp files [for debugging]")
|
||||
OPTION_PASS_ON_1("-keys", DRIVER_M, m2l, "Report detailed result of consistency checks by m2l")
|
||||
OPTION_PASS_ON_1("-list", DRIVER_M, m2cfe, "Generate listing")
|
||||
OPTION("-l", DRIVER_CFM, infile_option, "Read object library (for ld)")
|
||||
OPTION("-l", DRIVER_L, infile_option, "Read definition of object library")
|
||||
OPTION("-l", DRIVER_P, infile_option, "Read object library (for ld) or generate listing")
|
||||
OPTION_PASS_ON_1T_OR_12_AS_1T("-L", DRIVER_CFM, ld, "Add directory X to ld library path (for ld)")
|
||||
OPTION_PASS_ON_1("-L", DRIVER_P, pc0, "Map upper case letters to lower case in identifiers and keywords")
|
||||
OPTION_SET1("-m4", DRIVER_F, do_m4, "Run source thru m4")
|
||||
|
||||
#ifndef sun386
|
||||
#if defined(CROSS) || defined(mc68000) /* mc68000, not mc680x0 here */
|
||||
OPTION_TARGET_PROC1("-mc68010", HIDE(DRIVER_all), target_arch, arch_sun2, "Generate 68010 .o's")
|
||||
|
||||
/* define mc68020 architecture for sun3 or sun3x */
|
||||
#ifdef sun3x
|
||||
OPTION_TARGET_PROC1("-mc68020", HIDE(DRIVER_all), target_arch, arch_sun3x, "Generate 68020 .o's")
|
||||
#else
|
||||
OPTION_TARGET_PROC1("-mc68020", HIDE(DRIVER_all), target_arch, arch_sun3, "Generate 68020 .o's")
|
||||
#endif
|
||||
|
||||
OPTION_TARGET_PROC1("-m68010", HIDE(DRIVER_all), target_arch, arch_sun2, "Generate 68010 .o's")
|
||||
|
||||
/* define m68020 architecture for sun3 or sun3x */
|
||||
#ifdef sun3x
|
||||
OPTION_TARGET_PROC1("-m68020", HIDE(DRIVER_all), target_arch, arch_sun3x, "Generate 68020 .o's")
|
||||
#else
|
||||
OPTION_TARGET_PROC1("-m68020", HIDE(DRIVER_all), target_arch, arch_sun3, "Generate 68020 .o's")
|
||||
#endif
|
||||
|
||||
#endif /*defined(CROSS) || defined(mc68000)*/
|
||||
|
||||
OPTION_SET1("-misalign", DRIVER_CFP, handle_misalignment, "Handle misalinged Sun-4 data w/pessimistic code")
|
||||
#endif /*!sun386*/
|
||||
|
||||
OPTION_PASS_ON_12("-map", NO_MINUS(DRIVER_M), m2l, "Generate modula-2 link map file")
|
||||
OPTION("-m", NO_MINUS(DRIVER_M), module_option, NULL)
|
||||
OPTION("-M", DRIVER_M, module_list_option, NULL)
|
||||
OPTION_SET1("-M", DRIVER_C, do_dependency, "Collect dependencies")
|
||||
OPTION_PASS_ON_1T("-Nd", DRIVER_F, f77pass1, "Set size of structure-decl nesting compiler table to X")
|
||||
OPTION_PASS_ON_1T("-Nl", DRIVER_F, f77pass1, "Set maximum number of continuation lines to X")
|
||||
OPTION_PASS_ON_1("-nobounds", DRIVER_M, m2cfe, "Do not compile array bound checking code")
|
||||
OPTION_PASS_ON_1("-norange", DRIVER_M, m2cfe, "Do not compile range checking code")
|
||||
OPTION_SET0("-normcmds", HIDE(DRIVER_all), show_rm_commands, "Don't bother to show \"rm\" commands in -dryrun or -verbose output")
|
||||
OPTION_SET1("-noc2", DRIVER_CFM, no_c2, "Don't do peephole optimization, even if -O is used")
|
||||
OPTION("-n", DRIVER_L, lint_n_option, "Do not check against C library")
|
||||
|
||||
OPTION_PASS_ON_1("-n", HIDE(DRIVER_CFMP), ld, "Make shared")
|
||||
OPTION_PASS_ON_1T("-Nc", DRIVER_F, f77pass1, "Set size of do loop nesting compiler table to X")
|
||||
OPTION_PASS_ON_1T("-Nn", DRIVER_F, f77pass1, "Set size of identifier compiler table to X")
|
||||
OPTION_PASS_ON_1T("-Nq", DRIVER_F, f77pass1, "Set size of equivalenced variables compiler table to X")
|
||||
OPTION_PASS_ON_1T("-Ns", DRIVER_F, f77pass1, "Set size of statement numbers compiler table to X")
|
||||
OPTION_PASS_ON_1T("-Nx", DRIVER_F, f77pass1, "Set size of external identifier compiler table to X")
|
||||
|
||||
OPTION_PASS_ON_1("-N", HIDE(DRIVER_CFMP), ld, "Do not make shared")
|
||||
|
||||
OPTION_SET1("-onetrip", DRIVER_F, onetrip, "Perform DO loops at least once")
|
||||
|
||||
OPTION("-o", NO_MINUS(DRIVER_CFLMP), outfile_option, NULL)
|
||||
OPTION("-O", DRIVER_CFMP, optimize_option, NULL)
|
||||
#ifndef sun386
|
||||
OPTION_SET1("-purecross", DRIVER_all, pure_cross, "Pure cross-compilation; use no files from /")
|
||||
#endif
|
||||
OPTION_SET1("-pipe", DRIVER_all, pipe_ok, "Use pipes instead of temp files, when possible")
|
||||
OPTION_SET1("-pic", DRIVER_C, pic_code, "Generate pic code with short offset")
|
||||
OPTION_SET1("-pic", HIDE(DRIVER_F), pic_code, "Generate pic code with short offset")
|
||||
OPTION_SET1("-PIC", DRIVER_C, PIC_code, "Generate pic code with long offset")
|
||||
OPTION_SET1("-PIC", HIDE(DRIVER_F), PIC_code, "Generate pic code with long offset")
|
||||
OPTION_SET("-pg", DRIVER_CFMP, profile, gprof, "Prepare to collect data for the gprof program")
|
||||
OPTION_SET("-p", DRIVER_CFMP, profile, prof, "Prepare to collect data for the prof program")
|
||||
|
||||
#ifdef sun386
|
||||
OPTION("-p", DRIVER_L, pass_on_lint_option, "Check for non-portable constructs")
|
||||
#endif
|
||||
|
||||
OPTION_SET("-P", DRIVER_C, product, preprocessed2, "Run source thru cpp, output to file.i")
|
||||
|
||||
OPTION("-P", DRIVER_F, optimize_option, NULL)
|
||||
|
||||
OPTION_PASS_ON_1("-P", DRIVER_P, pc0, "Use partial evaluation semantics for and/or")
|
||||
OPTION("-Qoption", NO_MINUS(DRIVER_all), pass_on_select_option, NULL)
|
||||
OPTION("-Qpath", NO_MINUS(DRIVER_all), path_option, NULL)
|
||||
OPTION("-Qproduce", NO_MINUS(DRIVER_all), produce_option, NULL)
|
||||
OPTION("-q", DRIVER_L, pass_on_lint_option, "Do not complain about Sun-specific C constructs")
|
||||
|
||||
OPTION_SET_SW_REL("-release", NO_MINUS(DRIVER_CFLMP), R_all, NULL)
|
||||
OPTION_SET_SW_REL("-relvroot", NO_MINUS(DRIVER_CFLMP), R_VROOT, NULL)
|
||||
OPTION_SET_SW_REL("-relpaths", NO_MINUS(DRIVER_CFLMP), R_PATHS, NULL)
|
||||
OPTION_SET_SW_REL("-relpasses", NO_MINUS(DRIVER_CFLMP), R_PASSES, NULL)
|
||||
|
||||
|
||||
#ifndef sun386
|
||||
OPTION_PASS_ON_1("-r", HIDE(DRIVER_CFMP), ld, "Make relocatable")
|
||||
#endif /*!sun386*/
|
||||
|
||||
OPTION_SET1("-R", DRIVER_CMP, as_R, "Merge data segment into text segment (for as)")
|
||||
|
||||
#ifndef sun386
|
||||
OPTION_PASS_ON_1TO("-R", DRIVER_F, ratfor, "Obsolete. Use -Qoption ratfor opt.")
|
||||
#endif /*!sun386*/
|
||||
|
||||
#if defined(CROSS) || defined(sparc)
|
||||
|
||||
/* define sparc architecture for sun4 or sun4c */
|
||||
#ifdef sun4c
|
||||
OPTION_TARGET_PROC1("-sparc", HIDE(DRIVER_all), target_arch, arch_sun4c, "Generate SPARC .o's")
|
||||
#else
|
||||
OPTION_TARGET_PROC1("-sparc", HIDE(DRIVER_all), target_arch, arch_sun4, "Generate SPARC .o's")
|
||||
#endif
|
||||
|
||||
#endif /*defined(CROSS) || defined(sparc)*/
|
||||
|
||||
#if defined(CROSS) || defined(sun2)
|
||||
OPTION_TARGET_ARCH1("-sun2", DRIVER_all, target_arch, arch_sun2, "Generate code for a Sun2 system")
|
||||
#endif /*defined(CROSS) || defined(sun2)*/
|
||||
|
||||
#if defined(CROSS) || defined(sun3x)
|
||||
OPTION_TARGET_ARCH1("-sun3x", DRIVER_all, target_arch, arch_sun3x, "Generate code for a Sun3x system")
|
||||
#endif /*defined(CROSS) || defined(sun3x)*/
|
||||
|
||||
#if defined(CROSS) || defined(sun386)
|
||||
OPTION_TARGET_ARCH1("-sun386", DRIVER_all, target_arch, arch_sun386, "Generate code for a Sun386 system")
|
||||
#endif /*defined(CROSS) || defined(sun386)*/
|
||||
|
||||
#if defined(CROSS) || defined(sun3)
|
||||
OPTION_TARGET_ARCH1("-sun3", DRIVER_all, target_arch, arch_sun3, "Generate code for a Sun3 system")
|
||||
#endif /*defined(CROSS) || defined(sun3)*/
|
||||
|
||||
#if defined(CROSS) || defined(sun4c)
|
||||
OPTION_TARGET_ARCH1("-sun4c", DRIVER_all, target_arch, arch_sun4c, "Generate code for a Sun4c system")
|
||||
#endif /*defined(CROSS) || defined(sun4c)*/
|
||||
|
||||
#if defined(CROSS) || defined(sun4)
|
||||
OPTION_TARGET_ARCH1("-sun4", DRIVER_all, target_arch, arch_sun4, "Generate code for a Sun4 system")
|
||||
#endif /*defined(CROSS) || defined(sun4)*/
|
||||
|
||||
/* -sys5 is an undocumented flag for testing purposes only */
|
||||
/* using this flag sets compile for sys5 as opposed to bsd version */
|
||||
OPTION_SET1("-sys5", HIDE(DRIVER_all), sys5_flag, "Set driver to sys5 version" )
|
||||
#ifdef BROWSER
|
||||
OPTION_SET1("-sb", DRIVER_CFP, code_browser_seen, "Collect information for code browser")
|
||||
#endif
|
||||
|
||||
OPTION_PASS_ON_1("-s", DRIVER_P, pc0, "Accept Standard Pascal only")
|
||||
OPTION_PASS_ON_1("-s", HIDE(DRIVER_CFM), ld, "Strip")
|
||||
OPTION_SET("-S", DRIVER_CFMP, product, assembler, "Produce '.s' file. Do not run \"as\".")
|
||||
OPTION("-target=", DRIVER_L, lint1_option, "specify target to lint1")
|
||||
OPTION_TARGET_ARCH2("-target", DRIVER_all, target_arch, "specify target architecture")
|
||||
OPTION("-temp=", DRIVER_all, temp_dir_option, NULL)
|
||||
OPTION_SET1("-test", HIDE(DRIVER_all), testing_driver, "Testing driver")
|
||||
OPTION_SET1("-time", DRIVER_all, time_run, "Report the execution time for the compiler passes")
|
||||
OPTION_SET1("-trace", DRIVER_M, trace, "Show compiler actions")
|
||||
OPTION_PASS_ON_1("-t", HIDE(DRIVER_CFMP), ld, "Trace ld")
|
||||
OPTION_PASS_ON_12("-Tdata", HIDE(DRIVER_CFMP), ld, "Set data address")
|
||||
OPTION_PASS_ON_12("-Ttext", HIDE(DRIVER_CFMP), ld, "Set text address")
|
||||
OPTION_PASS_ON_12("-T", HIDE(DRIVER_CFMP), ld, "Set text address")
|
||||
|
||||
/* -ucb is an undocumented flag for testing purposes only */
|
||||
/* using this flag sets compile for ucb as opposed to sys5 version */
|
||||
OPTION_SET0("-ucb", HIDE(DRIVER_all), sys5_flag, "Set driver to bsd version" )
|
||||
|
||||
OPTION_PASS_ON_1("-u", DRIVER_F, f77pass1, "Make the default type be 'undefined', not 'integer'")
|
||||
|
||||
OPTION_PASS_ON_12("-u", HIDE(DRIVER_CMP), ld, "Undefine")
|
||||
OPTION("-u", DRIVER_L, pass_on_lint_option, "Library mode")
|
||||
OPTION_PASS_ON_1T_OR_12_AS_1T("-U", DRIVER_CLP, cpp, "Delete initial definition of cpp symbol X (for cpp)")
|
||||
|
||||
OPTION_PASS_ON_1("-U", DRIVER_F, f77pass1, "Do not map upper case letters to lower case")
|
||||
|
||||
OPTION_SET1("-verbose", DRIVER_L, verbose, "Report which programs the driver invokes")
|
||||
|
||||
#ifndef sun386
|
||||
OPTION_SET1("-vpa", DRIVER_F, vpa, "Invoke pre- and post-processing for Sun VPA")
|
||||
#endif /*!sun386*/
|
||||
|
||||
OPTION_SET1("-v", DRIVER_CFMP, verbose, "Report which programs the driver invokes")
|
||||
OPTION("-v", DRIVER_L, pass_on_lint_option, "Do not complain about unused formals")
|
||||
OPTION_SET1("-V", DRIVER_P, checkV, "Report hard errors for non standard Pascal constructs")
|
||||
|
||||
OPTION_PASS_ON_1("-w66", DRIVER_F, f77pass1, "Do not print FORTRAN 66 compatibility warnings")
|
||||
|
||||
OPTION_PASS_ON_1("-w", DRIVER_C, ccom, "Do not print warnings")
|
||||
|
||||
OPTION_PASS_ON_1("-w", DRIVER_F, f77pass1, "Do not print warnings")
|
||||
|
||||
OPTION_SET1( "-w", DRIVER_P, warning, "Do not print warnings")
|
||||
OPTION_PASS_ON_1("-xl", HIDE(DRIVER_P), pc0, "Apollo specific flag")
|
||||
OPTION("-x", DRIVER_L, pass_on_lint_option, "Report variables referred to by extern but not used")
|
||||
OPTION_PASS_ON_1("-x", HIDE(DRIVER_CFMP), ld, "Remove local symbols")
|
||||
OPTION_PASS_ON_1("-X", HIDE(DRIVER_CFMP), ld, "Save most local symbols")
|
||||
OPTION_PASS_ON_1T("-y",HIDE(DRIVER_CFMP), ld, "Trace symbol")
|
||||
|
||||
OPTION("-z", DRIVER_L, pass_on_lint_option, "Do not complain about referenced but not defined structs")
|
||||
OPTION_PASS_ON_1("-z", DRIVER_P, pc0, "Prepare to collect data for the pxp program")
|
||||
OPTION_PASS_ON_1("-z", HIDE(DRIVER_CFM), ld, "Make demand load")
|
||||
OPTION_PASS_ON_1("-Z", DRIVER_P, pc0, "Initialize local storage to zero")
|
||||
|
||||
END_OF_OPTIONS()
|
||||
};
|
||||
|
||||
#define DRIVER(name, drivers, value) { (name), (drivers), set_named_int_arg_option, 0, &driver, NULL, (value), NULL},
|
||||
Option drivers[]=
|
||||
{
|
||||
DRIVER("cc", DRIVER_C, &cc)
|
||||
DRIVER("compile", HIDE(0), &dummy)
|
||||
DRIVER("f77", DRIVER_F, &f77)
|
||||
DRIVER("lint", DRIVER_L, &xlint)
|
||||
DRIVER("m2c", DRIVER_M, &m2c)
|
||||
DRIVER("pc", DRIVER_P, &pc)
|
||||
END_OF_OPTIONS()
|
||||
};
|
||||
|
||||
/*
|
||||
* A set of simple functions that are used to determine if
|
||||
* a particular compiler step should be used this time
|
||||
*/
|
||||
static int
|
||||
cppas_expr()
|
||||
{
|
||||
return is_on(do_cppas);
|
||||
}
|
||||
|
||||
static int
|
||||
not_cppas_expr()
|
||||
{
|
||||
return ( is_off(do_cppas) && is_on(do_cpp) );
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_expr()
|
||||
{
|
||||
return is_on(do_cpp);
|
||||
}
|
||||
|
||||
static int
|
||||
cat_expr()
|
||||
{
|
||||
#ifdef sun386
|
||||
optim_after_cat = c2_expr();
|
||||
#endif
|
||||
return is_on(do_cat) &&
|
||||
!( ((target_arch.value->value == ARCH_SUN4C) ||
|
||||
(target_arch.value->value == ARCH_SUN4)) &&
|
||||
(optimizer_level > OPTIM_NONE) );
|
||||
}
|
||||
|
||||
static int
|
||||
inline_expr()
|
||||
{
|
||||
/* Must always run "inline" if handle_misalignment is on. */
|
||||
|
||||
return ( ( is_on(do_inline) && (driver.value != &xlint) )
|
||||
||
|
||||
is_on(handle_misalignment) );
|
||||
}
|
||||
|
||||
static int
|
||||
lint_expr()
|
||||
{
|
||||
return driver.value == &xlint;
|
||||
}
|
||||
|
||||
static int
|
||||
m4_expr()
|
||||
{
|
||||
return is_on(do_ratfor) && is_on(do_m4);
|
||||
}
|
||||
|
||||
static int
|
||||
nlint_expr()
|
||||
{
|
||||
return !lint_expr();
|
||||
}
|
||||
|
||||
static int
|
||||
nsparc_expr()
|
||||
{
|
||||
return (target_arch.value->value != ARCH_SUN4) &&
|
||||
(target_arch.value->value != ARCH_SUN4C) &&
|
||||
(optimizer_level > OPTIM_NONE);
|
||||
}
|
||||
|
||||
static int
|
||||
c2_expr()
|
||||
{
|
||||
return (optimizer_level > OPTIM_NONE) &&
|
||||
(driver.value != &xlint) &&
|
||||
(target_arch.value->value != ARCH_SUN4C) &&
|
||||
(target_arch.value->value != ARCH_SUN4);
|
||||
}
|
||||
|
||||
static int
|
||||
ratfor_expr()
|
||||
{
|
||||
return is_on(do_ratfor);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
m2c_cat_expr()
|
||||
{
|
||||
return (set_flag(do_cat));
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
sparc_Soption_expr()
|
||||
{
|
||||
return is_on(do_cat) &&
|
||||
(optimizer_level > OPTIM_NONE) &&
|
||||
((target_arch.value->value == ARCH_SUN4C) ||
|
||||
(target_arch.value->value == ARCH_SUN4)) &&
|
||||
(driver.value != &xlint);
|
||||
}
|
||||
|
||||
static int
|
||||
nsparc_Soption_expr()
|
||||
{
|
||||
return !( is_on(do_cat) &&
|
||||
(optimizer_level > OPTIM_NONE) &&
|
||||
((target_arch.value->value == ARCH_SUN4C) ||
|
||||
(target_arch.value->value == ARCH_SUN4)) ) &&
|
||||
(driver.value != &xlint);
|
||||
}
|
||||
|
||||
static int
|
||||
do_source_expr()
|
||||
{
|
||||
return (product.value == &assembler) &&
|
||||
(optimizer_level > OPTIM_NONE) &&
|
||||
((target_arch.value->value == ARCH_SUN4C) ||
|
||||
(target_arch.value->value == ARCH_SUN4));
|
||||
}
|
||||
|
||||
static int
|
||||
do_object_expr()
|
||||
{
|
||||
return (product.value == &object) || (product.value == &executable);
|
||||
}
|
||||
|
||||
static int
|
||||
vpa_expr()
|
||||
{
|
||||
return is_on(vpa);
|
||||
}
|
||||
|
||||
#define STEP(prog, suff, expr, setup) \
|
||||
{&program.prog, &suffix.suff, (expr), (setup)},
|
||||
|
||||
#define END_OF_STEPS() { &program.sentinel_program_field, NULL, NULL, NULL}
|
||||
|
||||
#ifdef sun386
|
||||
Step c_iropt_steps[]= {
|
||||
STEP(cpp, i, cpp_expr, setup_cpp_for_cc)
|
||||
STEP(ccom, s, nlint_expr, setup_ccom_for_iropt)
|
||||
STEP(iropt, none, NULL, NULL)
|
||||
STEP(cg, s, NULL, setup_cg_for_tcov)
|
||||
STEP(inline, s, inline_expr, NULL)
|
||||
STEP(c2, s, nsparc_expr, NULL)
|
||||
STEP(cat, s, cat_expr, setup_cat_for_cc)
|
||||
STEP(as, o, nsparc_Soption_expr, setup_as_for_cc)
|
||||
STEP(asS, s, sparc_Soption_expr, setup_asS_for_cc)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
#else
|
||||
Step c_iropt_steps[]=
|
||||
{
|
||||
STEP(cpp, i, cpp_expr, setup_cpp_for_cc)
|
||||
STEP(ccom, s, nlint_expr, setup_ccom_for_iropt)
|
||||
STEP(iropt, ir, NULL, NULL)
|
||||
STEP(cg, s, NULL, setup_cg_cc_for_tcov)
|
||||
STEP(inline, s, inline_expr, setup_inline)
|
||||
STEP(c2, s, nsparc_expr, NULL)
|
||||
STEP(cat, s, cat_expr, setup_cat_for_cc)
|
||||
STEP(as, o, nsparc_Soption_expr, setup_as_for_cc)
|
||||
STEP(asS, s, sparc_Soption_expr, setup_asS_for_cc)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
#endif
|
||||
|
||||
Step c_no_iropt_steps[]=
|
||||
{
|
||||
STEP(cpp, i, cpp_expr, setup_cpp_for_cc)
|
||||
STEP(ccom, s, nlint_expr, NULL)
|
||||
STEP(lint1, ln, lint_expr, NULL)
|
||||
STEP(inline, s, inline_expr, setup_inline)
|
||||
STEP(c2, s, c2_expr, NULL)
|
||||
STEP(as, o, nsparc_Soption_expr, setup_as_for_cc)
|
||||
STEP(asS, s, sparc_Soption_expr, setup_asS_for_cc)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
Step def_steps_3x[]=
|
||||
{
|
||||
STEP(m2cfe, sym, NULL, setup_m2cfe_for_3x_def)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
Step def_steps_non_3x[]=
|
||||
{
|
||||
STEP(m2cfe, sym, NULL, setup_m2cfe_for_non_3x_def)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
|
||||
#ifdef sun386
|
||||
Step f_iropt_steps[]=
|
||||
{
|
||||
STEP(cpp, f, cpp_expr, NULL)
|
||||
STEP(m4, f, m4_expr, NULL)
|
||||
STEP(ratfor, f, ratfor_expr, NULL)
|
||||
STEP(vpaf77, none, vpa_expr, NULL)
|
||||
STEP(f77pass1, none, NULL, NULL)
|
||||
STEP(iropt, none, NULL, NULL)
|
||||
STEP(cg, s, NULL, setup_cg_f77_for_tcov)
|
||||
STEP(inline, s, inline_expr, NULL)
|
||||
STEP(cat, s, cat_expr, setup_cat_for_f77)
|
||||
STEP(c2, s, c2_expr, setup_c2_for_f77)
|
||||
STEP(as, o, nsparc_Soption_expr, setup_as_for_f77)
|
||||
STEP(asS, s, sparc_Soption_expr, setup_asS_for_f77)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
Step f_no_iropt_steps[]=
|
||||
{
|
||||
STEP(cpp, f, cpp_expr, NULL)
|
||||
STEP(m4, f, m4_expr, NULL)
|
||||
STEP(ratfor, f, ratfor_expr, NULL)
|
||||
STEP(vpaf77, none, vpa_expr, NULL)
|
||||
STEP(f77pass1, s, NULL, setup_f77pass1)
|
||||
STEP(inline, s, inline_expr, NULL)
|
||||
STEP(cat, s, cat_expr, setup_cat_for_f77)
|
||||
STEP(c2, s, c2_expr, setup_c2_for_f77)
|
||||
STEP(as, o, nsparc_Soption_expr, setup_as_for_f77)
|
||||
STEP(asS, s, sparc_Soption_expr, setup_asS_for_f77)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
#else
|
||||
Step f_iropt_steps[]=
|
||||
{
|
||||
STEP(cpp, f, cpp_expr, NULL)
|
||||
STEP(m4, f, m4_expr, NULL)
|
||||
STEP(ratfor, f, ratfor_expr, NULL)
|
||||
STEP(vpaf77, none, vpa_expr, NULL)
|
||||
STEP(f77pass1, none, NULL, NULL)
|
||||
STEP(iropt, ir, NULL, setup_iropt_f77)
|
||||
STEP(cg, s, NULL, setup_cg_f77)
|
||||
STEP(inline, s, inline_expr, setup_inline)
|
||||
STEP(c2, s, c2_expr, NULL)
|
||||
STEP(cat, s, cat_expr, setup_cat_for_f77)
|
||||
STEP(as, o, nsparc_Soption_expr, setup_as_for_f77)
|
||||
STEP(asS, s, sparc_Soption_expr, setup_asS_for_f77)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
Step f_no_iropt_steps[]=
|
||||
{
|
||||
STEP(cpp, f, cpp_expr, NULL)
|
||||
STEP(m4, f, m4_expr, NULL)
|
||||
STEP(ratfor, f, ratfor_expr, NULL)
|
||||
STEP(vpaf77, none, vpa_expr, NULL)
|
||||
STEP(f77pass1, s, NULL, NULL)
|
||||
STEP(inline, s, inline_expr, setup_inline)
|
||||
STEP(c2, s, c2_expr, NULL)
|
||||
STEP(cat, s, cat_expr, setup_cat_for_f77)
|
||||
STEP(as, o, nsparc_Soption_expr, setup_as_for_f77)
|
||||
STEP(asS, s, sparc_Soption_expr, setup_asS_for_f77)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
#endif
|
||||
|
||||
Step link_steps[]=
|
||||
{
|
||||
STEP(ld, none, NULL, NULL)
|
||||
STEP(vpald, none, vpa_expr, NULL)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
Step link_m2c_steps[]=
|
||||
{
|
||||
STEP(m2l, none, NULL, NULL)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
Step lint_steps[]=
|
||||
{
|
||||
STEP(cat, none, NULL, setup_cat_for_lint)
|
||||
STEP(lint2, none, NULL, NULL)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
Step mod_rel3x_steps[]= /* for release 3.x modula2 */
|
||||
{
|
||||
STEP(m2cfe, none, NULL, setup_m2cfe_for_3x_mod)
|
||||
STEP(mf1, s, NULL, NULL)
|
||||
STEP(inline, s, inline_expr, setup_inline)
|
||||
STEP(c2, s, c2_expr, NULL)
|
||||
STEP(asS, s, do_source_expr, setup_asS_for_m2c)
|
||||
STEP(as, o, do_object_expr, NULL)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
Step mod_no_iropt_steps[]= /* for release 4.x modula2 */
|
||||
{
|
||||
STEP(m2cfe, ir, NULL, setup_m2cfe_for_non_3x_mod)
|
||||
STEP(cg, s, NULL, setup_cg_mod)
|
||||
STEP(inline, s, inline_expr, setup_inline)
|
||||
STEP(c2, s, c2_expr, NULL)
|
||||
STEP(cat, s, m2c_cat_expr, setup_cat_for_mod)
|
||||
STEP(as, o, do_object_expr, setup_as_for_m2c)
|
||||
STEP(asS, s, sparc_Soption_expr, setup_asS_for_m2c)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
Step mod_iropt_steps[]= /* for release 4.x modula2 */
|
||||
{
|
||||
STEP(m2cfe, ir, NULL, setup_m2cfe_for_non_3x_mod)
|
||||
STEP(iropt, ir, NULL, setup_iropt_mod)
|
||||
STEP(cg, s, NULL, setup_cg_mod)
|
||||
STEP(inline, s, inline_expr, setup_inline)
|
||||
STEP(c2, s, c2_expr, NULL)
|
||||
STEP(cat, s, m2c_cat_expr, setup_cat_for_mod)
|
||||
STEP(as, o, do_object_expr, setup_as_for_m2c)
|
||||
STEP(asS, s, sparc_Soption_expr, setup_asS_for_m2c)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
|
||||
Step p_rel3x_steps[]= /* for release 3.x Pascal */
|
||||
{
|
||||
STEP(cpp, pi, cpp_expr, NULL)
|
||||
STEP(pc0, none, NULL, setup_pc0_for_3x)
|
||||
STEP(f1, s, NULL, NULL)
|
||||
STEP(inline, s, NULL, setup_inline_for_pc)
|
||||
STEP(c2, s, c2_expr, NULL)
|
||||
STEP(asS, s, do_source_expr, setup_asS_for_pc)
|
||||
STEP(as, o, do_object_expr, NULL)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
#ifdef sun386
|
||||
Step p_no_iropt_steps[]=
|
||||
{
|
||||
STEP(cppas, pi, cppas_expr, NULL)
|
||||
STEP(cpp, pi, not_cppas_expr, NULL)
|
||||
STEP(pc0, ir, NULL, setup_pc0_for_non_3x)
|
||||
STEP(cg, s, NULL, setup_cg_for_tcov)
|
||||
STEP(inline, s, NULL, setup_inline_for_pc)
|
||||
STEP(cat, s, cat_expr, setup_cat_for_pc)
|
||||
STEP(c2, s, c2_expr, NULL)
|
||||
STEP(asS, s, do_source_expr, setup_asS_for_pc)
|
||||
STEP(as, o, do_object_expr, NULL)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
Step p_iropt_steps[]=
|
||||
{
|
||||
STEP(cppas, pi, cppas_expr, NULL)
|
||||
STEP(cpp, pi, not_cppas_expr, NULL)
|
||||
STEP(pc0, ir, NULL, setup_pc0_for_non_3x)
|
||||
STEP(iropt, none, NULL, NULL)
|
||||
STEP(cg, s, NULL, setup_cg_for_tcov)
|
||||
STEP(inline, s, NULL, setup_inline_for_pc)
|
||||
STEP(cat, s, cat_expr, setup_cat_for_pc)
|
||||
STEP(c2, s, c2_expr, NULL)
|
||||
STEP(asS, s, do_source_expr, setup_asS_for_pc)
|
||||
STEP(as, o, do_object_expr, NULL)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
#else /* !sun386 */
|
||||
Step p_no_iropt_steps[]= /* for release 4.x Pascal */
|
||||
{
|
||||
STEP(cppas, pi, cppas_expr, NULL)
|
||||
STEP(cpp, pi, not_cppas_expr, NULL)
|
||||
STEP(pc0, none, NULL, setup_pc0_for_non_3x)
|
||||
STEP(cg, s, NULL, setup_cg_pc)
|
||||
STEP(inline, s, NULL, setup_inline_for_pc)
|
||||
STEP(c2, s, nsparc_expr, NULL)
|
||||
STEP(cat, s, cat_expr, setup_cat_for_pc)
|
||||
STEP(asS, s, do_source_expr, setup_asS_for_pc)
|
||||
STEP(as, o, do_object_expr, setup_as_for_pc)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
Step p_iropt_steps[]= /* for release 4.x Pascal */
|
||||
{
|
||||
STEP(cppas, pi, cppas_expr, NULL)
|
||||
STEP(cpp, pi, not_cppas_expr, NULL)
|
||||
STEP(pc0, none, NULL, setup_pc0_for_non_3x)
|
||||
STEP(iropt, ir, NULL, setup_iropt_pc)
|
||||
STEP(cg, s, NULL, setup_cg_pc)
|
||||
STEP(inline, s, NULL, setup_inline_for_pc)
|
||||
STEP(c2, s, nsparc_expr, NULL)
|
||||
STEP(cat, s, cat_expr, setup_cat_for_pc)
|
||||
STEP(as, o, nsparc_Soption_expr, setup_as_for_pc)
|
||||
STEP(asS, s, sparc_Soption_expr, setup_asS_for_pc)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
#endif
|
||||
|
||||
Step pc_steps[]=
|
||||
{
|
||||
STEP(pc3, none, NULL, NULL)
|
||||
STEP(ld, none, NULL, NULL)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
Step s_steps[]=
|
||||
{
|
||||
STEP(cpp, s, cpp_expr, NULL)
|
||||
STEP(as, o, NULL, NULL)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
/* The following is used for pushing anything, no matter what its
|
||||
* suffix, through "cc -E".
|
||||
*/
|
||||
Step anything_thru_cc_E_steps[]=
|
||||
{
|
||||
STEP(cpp, s, cpp_expr, NULL)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
|
||||
/* The following is used for pushing anything, no matter what its
|
||||
* suffix, through "cc -P".
|
||||
*/
|
||||
Step anything_thru_cc_P_steps[]=
|
||||
{
|
||||
STEP(cpp, s, cpp_expr, setup_cpp_for_cc)
|
||||
END_OF_STEPS()
|
||||
};
|
||||
804
lang/compile/run_pass.c
Normal file
804
lang/compile/run_pass.c
Normal file
@@ -0,0 +1,804 @@
|
||||
/* @(#)run_pass.c 1.1 94/10/31 SMI */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "driver.h"
|
||||
#include <sys/wait.h>
|
||||
#include <sys/file.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define PIPE_RD_FD 0
|
||||
#define PIPE_WR_FD 1
|
||||
|
||||
|
||||
/*
|
||||
* outfile_name
|
||||
* Figure out what the outfile name should be
|
||||
*/
|
||||
char *
|
||||
outfile_name(source, out_suffix, programp)
|
||||
register char *source;
|
||||
register SuffixP out_suffix;
|
||||
ProgramP programp;
|
||||
{
|
||||
register char *p;
|
||||
register char *result;
|
||||
|
||||
if (make_lint_lib_fd && (programp == &program.lint1))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
if ((outfile != NULL) && (product.value != &executable))
|
||||
{
|
||||
/* If a "-o" option was given */
|
||||
if (strcmp(get_file_suffix(outfile), out_suffix->suffix))
|
||||
fatal("Suffix mismatch between -o and produced file (should produce .%s)",
|
||||
out_suffix->suffix);
|
||||
result= outfile;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We derive the outfile name from the infile name */
|
||||
if ((p= rindex(source, '/')) != NULL)
|
||||
source= p+1;
|
||||
if ((p= rindex(source, '.')) != NULL)
|
||||
*p= 0;
|
||||
result= get_memory(strlen(source)+strlen(out_suffix->suffix)+2);
|
||||
(void)sprintf(result, "%s.%s", source, out_suffix->suffix);
|
||||
if (p != NULL)
|
||||
*p= '.';
|
||||
}
|
||||
if (STR_EQUAL(result, source))
|
||||
fatal("Outfile would overwrite infile %s", result);
|
||||
return result;
|
||||
|
||||
} /* outfile_name */
|
||||
|
||||
/*
|
||||
* temp_file_name
|
||||
* Construct one temp file name, and register it to make sure it
|
||||
* will be cleaned up.
|
||||
*/
|
||||
char *
|
||||
temp_file_name(program, suffix, mark)
|
||||
register ProgramP program;
|
||||
register SuffixP suffix;
|
||||
register char mark;
|
||||
{
|
||||
register char *string;
|
||||
char buffer[MAXPATHLEN];
|
||||
static int process_number= -1;
|
||||
|
||||
if (process_number == -1)
|
||||
{
|
||||
if (is_on(testing_driver))
|
||||
{
|
||||
process_number = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
process_number = getpid();
|
||||
}
|
||||
}
|
||||
|
||||
if (mark == 0)
|
||||
{
|
||||
(void)sprintf(buffer, "%s/%s.%05d.%d.%s",
|
||||
temp_dir, program->name, process_number,
|
||||
temp_file_number++, suffix->suffix);
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)sprintf(buffer, "%s/%s.%05d.%c.%d.%s",
|
||||
temp_dir, program->name, process_number, mark, temp_file_number++, suffix->suffix);
|
||||
}
|
||||
string= make_string(buffer);
|
||||
append_list(&temp_files_named, string);
|
||||
return string;
|
||||
} /* temp_file_name */
|
||||
|
||||
/*
|
||||
* wait_program
|
||||
* Wait for a process to terminate.
|
||||
* Report times for it if we need to after it exits.
|
||||
*/
|
||||
static int
|
||||
wait_program(wait_step, step)
|
||||
register StepP wait_step;
|
||||
register StepP step;
|
||||
{
|
||||
union wait wait_status;
|
||||
struct timeval stop;
|
||||
struct rusage usage;
|
||||
struct timeval cpu;
|
||||
struct timeval elapsed;
|
||||
register int process;
|
||||
register StepP p;
|
||||
register StepP q;
|
||||
|
||||
process= wait3(&wait_status, 0, &usage);
|
||||
|
||||
/* Find step for process that returned */
|
||||
for (p= wait_step; p <= step; p++)
|
||||
if (p->process == process)
|
||||
break;
|
||||
|
||||
/* And mark it as terminated */
|
||||
p->process= -1;
|
||||
/* If it returned an error we kill all other running processes */
|
||||
if ((wait_status.w_T.w_Termsig != 0) || (wait_status.w_T.w_Retcode))
|
||||
{
|
||||
for (q= wait_step; q <= step; q++)
|
||||
{
|
||||
if (q->process > 0)
|
||||
{
|
||||
(void)kill(q->process, SIGKILL);
|
||||
q->killed= TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_on(time_run))
|
||||
{
|
||||
/* Report program runtime */
|
||||
(void)gettimeofday(&stop, (struct timezone *)NULL);
|
||||
cpu.tv_sec= usage.ru_utime.tv_sec+usage.ru_stime.tv_sec;
|
||||
cpu.tv_usec= usage.ru_utime.tv_usec+usage.ru_stime.tv_usec;
|
||||
if (cpu.tv_usec > 1000000)
|
||||
{
|
||||
cpu.tv_usec-= 1000000;
|
||||
cpu.tv_sec++;
|
||||
}
|
||||
elapsed.tv_sec= stop.tv_sec-p->start.tv_sec;
|
||||
elapsed.tv_usec= stop.tv_usec-p->start.tv_usec;
|
||||
if (elapsed.tv_usec < 0)
|
||||
{
|
||||
elapsed.tv_usec+= 1000000;
|
||||
elapsed.tv_sec--;
|
||||
}
|
||||
(void)fprintf(stderr, "%s: time U:%d.%01ds+S:%d.%01ds=%d.%01ds REAL:%d.%01ds %d%%. ",
|
||||
p->program->name,
|
||||
usage.ru_utime.tv_sec, usage.ru_utime.tv_usec/100000,
|
||||
usage.ru_stime.tv_sec, usage.ru_stime.tv_usec/100000,
|
||||
cpu.tv_sec, cpu.tv_usec/100000,
|
||||
elapsed.tv_sec, elapsed.tv_usec/100000,
|
||||
(cpu.tv_sec*1000+cpu.tv_usec/1000)*100/
|
||||
(elapsed.tv_sec*1000+elapsed.tv_usec/1000));
|
||||
(void)fprintf(stderr, "core T:%dk D:%dk. io IN:%db OUT:%db. pf IN:%dp OUT:%dp.\n",
|
||||
usage.ru_ixrss/1024, usage.ru_idrss/1024,
|
||||
usage.ru_inblock, usage.ru_oublock,
|
||||
usage.ru_majflt, usage.ru_minflt);
|
||||
}
|
||||
|
||||
/* Report processes that returned errors */
|
||||
if (!p->killed && (wait_status.w_T.w_Termsig != 0))
|
||||
{
|
||||
(void)fprintf(stderr, "%s: Fatal error in %s: %s%s\n",
|
||||
program_name,
|
||||
p->program->name,
|
||||
sys_siglist[wait_status.w_T.w_Termsig],
|
||||
wait_status.w_T.w_Coredump?" (core dumped)":"");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return wait_status.w_T.w_Retcode;
|
||||
} /* wait_program */
|
||||
|
||||
|
||||
/*
|
||||
* use_temp_file
|
||||
* Mark one temp file as used.
|
||||
* Only files that are used will be removed by the driver.
|
||||
*/
|
||||
static char *
|
||||
use_temp_file(file)
|
||||
register char *file;
|
||||
{
|
||||
register ListP tp;
|
||||
|
||||
/* Move file from "temp_files_named" to "files_to_unlink" */
|
||||
for (tp= temp_files_named; tp != NULL; tp= tp->next)
|
||||
if (tp->value == file)
|
||||
{
|
||||
append_list(&files_to_unlink, file);
|
||||
tp->value= NULL;
|
||||
return file;
|
||||
}
|
||||
return file;
|
||||
} /* use_temp_file */
|
||||
|
||||
/*
|
||||
* append_list_to_argv
|
||||
* Take a list, and add all its strings to the current argv
|
||||
* being built.
|
||||
*/
|
||||
static void
|
||||
append_list_to_argv(p, consp)
|
||||
register char ***p;
|
||||
register ListP consp;
|
||||
{
|
||||
for (;consp != NULL; consp= consp->next)
|
||||
*(*p)++= use_temp_file(consp->value);
|
||||
} /* append_list_to_argv */
|
||||
|
||||
|
||||
/*
|
||||
* scan_Qpath_and_vroot
|
||||
* Take a path and transform it using Qpath and VIRTUAL_ROOT.
|
||||
* Also maybe save it for later dependency reporting.
|
||||
*/
|
||||
char *
|
||||
scan_Qpath_and_vroot(file, report_file)
|
||||
register char *file;
|
||||
register Bool report_file;
|
||||
{
|
||||
register int result;
|
||||
char buffer[MAXPATHLEN];
|
||||
register char *slash;
|
||||
char *path;
|
||||
|
||||
/* If filename contains a "/" and we have a path defined, we strip
|
||||
* the path from the filename and tack it on as the last component
|
||||
* of the path.
|
||||
*/
|
||||
if ((program_path != NULL) && ((slash= rindex(file, '/')) != NULL))
|
||||
{
|
||||
(void)strncpy(buffer, file, slash-file);
|
||||
buffer[slash-file]= '\0';
|
||||
/* Also put the full path to this file in the search path,
|
||||
* in case it isn't under the Qpath.
|
||||
*/
|
||||
add_dir_to_path(buffer, &program_path, last_program_path);
|
||||
result= access_vroot(slash+1, F_OK, program_path, VROOT_DEFAULT);
|
||||
}
|
||||
else
|
||||
{
|
||||
result= access_vroot(file, F_OK, (pathpt)NULL, VROOT_DEFAULT);
|
||||
}
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
/* Found the file. */
|
||||
/* Get the true path from the vroot subsystem */
|
||||
get_vroot_path(&path, (char **)NULL, (char **)NULL);
|
||||
(void)strcpy(buffer, path);
|
||||
if (report_file)
|
||||
{
|
||||
/* Get the name with the path but not the vroot for
|
||||
* dependency reporting.
|
||||
*/
|
||||
get_vroot_path((char **)NULL, &path, (char **)NULL);
|
||||
append_list(&report, make_string(path));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Didn't find the file.
|
||||
* If we are "-dryrun", just report the plain file.
|
||||
*/
|
||||
if (is_on(dryrun))
|
||||
(void)strcpy(buffer, file);
|
||||
else
|
||||
fatal("Cannot find %s", file);
|
||||
}
|
||||
return make_string(buffer);
|
||||
} /* scan_Qpath_and_vroot */
|
||||
|
||||
|
||||
/*
|
||||
* scan_Qpath_only
|
||||
* Take one path and transform it using the Qpath path.
|
||||
* Also maybe save it for later dependency reporting.
|
||||
*/
|
||||
char *
|
||||
scan_Qpath_only(file, report_file)
|
||||
register char *file;
|
||||
register Bool report_file;
|
||||
{
|
||||
register int result;
|
||||
char buffer[MAXPATHLEN];
|
||||
register char *slash;
|
||||
char *path;
|
||||
|
||||
/* If filename contains a "/" and we have a path defined, we strip
|
||||
* the path from the filename and tack it on as the last component
|
||||
* of the path.
|
||||
*/
|
||||
if ((program_path != NULL) && ((slash= rindex(file, '/')) != NULL))
|
||||
{
|
||||
(void)strncpy(buffer, file, slash-file);
|
||||
buffer[slash-file]= '\0';
|
||||
/* Also put the full path to this file in the search path,
|
||||
* in case it isn't under the Qpath.
|
||||
*/
|
||||
add_dir_to_path(buffer, &program_path, last_program_path);
|
||||
result= access_vroot(slash+1, F_OK, program_path, (pathpt)NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
result= -1;
|
||||
}
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
/* Found the file. */
|
||||
/* Get the true path from the vroot subsystem */
|
||||
get_vroot_path(&path, (char **)NULL, (char **)NULL);
|
||||
(void)strcpy(buffer, path);
|
||||
if (report_file)
|
||||
{
|
||||
/* Get the name with the path but not the vroot for
|
||||
* dependency reporting.
|
||||
*/
|
||||
get_vroot_path((char **)NULL, &path, (char **)NULL);
|
||||
append_list(&report, make_string(path));
|
||||
}
|
||||
return make_string(buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Didn't find the file. Return NULL to report that. */
|
||||
return (char *)NULL;
|
||||
}
|
||||
} /* scan_Qpath_only */
|
||||
|
||||
|
||||
/*
|
||||
* build_argv
|
||||
* Build the argument list for the process to be called
|
||||
*/
|
||||
static void
|
||||
build_argv(argv, step, this_pipe, std_in, std_out, unlink_candidates,
|
||||
previous_pipe)
|
||||
char **argv;
|
||||
StepP step;
|
||||
int this_pipe[2];
|
||||
char **std_in;
|
||||
char **std_out;
|
||||
ListP *unlink_candidates;
|
||||
int *previous_pipe;
|
||||
{
|
||||
char **vp= argv;
|
||||
Template *tp;
|
||||
|
||||
/* Get the true name of the executable */
|
||||
*vp++= scan_Qpath_and_vroot(step->program->path, FALSE);
|
||||
*vp++= step->program->name;
|
||||
this_pipe[PIPE_RD_FD]= this_pipe[PIPE_WR_FD]= -1;
|
||||
*std_in= *std_out= NULL;
|
||||
/* Build the argv vector.
|
||||
* The template from the program description is used to determine
|
||||
* the order of args.
|
||||
* It also specifies whether it is OK to use stdin/stdout or not.
|
||||
*/
|
||||
for (tp= step->program->template; *tp != '\0'; tp++)
|
||||
switch (*tp)
|
||||
{
|
||||
case IN_TEMPLATE:
|
||||
append_list_to_argv(&vp, step->program->infile);
|
||||
/* Temp files are removed as soon as one step has
|
||||
* read them
|
||||
*/
|
||||
append_list(unlink_candidates,
|
||||
step->program->infile->value);
|
||||
break;
|
||||
case STDIN_TEMPLATE:
|
||||
if (*previous_pipe == -1)
|
||||
{
|
||||
append_list(unlink_candidates,
|
||||
step->program->infile->value);
|
||||
*std_in= use_temp_file(
|
||||
step->program->infile->value);
|
||||
}
|
||||
break;
|
||||
case OUT_TEMPLATE:
|
||||
*vp++= use_temp_file(step->program->outfile);
|
||||
break;
|
||||
case OUT2_TEMPLATE:
|
||||
*vp++= use_temp_file(step->program->outfile2);
|
||||
break;
|
||||
case STDOUT_TEMPLATE:
|
||||
/* Use stdout only if this is not the last step */
|
||||
if ((step+1)->program &&
|
||||
((step+1)->program->template[0] == STDIN_TEMPLATE)&&
|
||||
is_on(pipe_ok))
|
||||
{
|
||||
if (pipe(this_pipe) == -1)
|
||||
{
|
||||
fatal("Trouble opening pipe");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (step->program->outfile != NULL) &&
|
||||
!(make_lint_lib_fd &&
|
||||
(step->program == &program.lint1))
|
||||
)
|
||||
{
|
||||
*std_out= use_temp_file(
|
||||
step->program->outfile);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OPTION_TEMPLATE:
|
||||
append_list_to_argv(&vp, step->program->options);
|
||||
append_list_to_argv(&vp,
|
||||
step->program->permanent_options);
|
||||
append_list_to_argv(&vp,
|
||||
step->program->trailing_options);
|
||||
break;
|
||||
case MINUS_TEMPLATE:
|
||||
*vp++= "-";
|
||||
break;
|
||||
case MINUS_O_TEMPLATE:
|
||||
*vp++= "-o";
|
||||
break;
|
||||
}
|
||||
|
||||
*vp= NULL;
|
||||
|
||||
/* Print trace if verbose is on */
|
||||
if ( is_on(verbose) || is_on(dryrun) )
|
||||
{
|
||||
Bool first_arg;
|
||||
(void)fprintf(stderr, "%s ", *argv);
|
||||
/* If argument contains whitespace or is empty we quote it */
|
||||
for (first_arg = TRUE, vp= argv+2; *vp != NULL; vp++)
|
||||
{
|
||||
char *q;
|
||||
Bool space= FALSE;
|
||||
|
||||
if (vp[0][0] == '\0')
|
||||
space= TRUE;
|
||||
for (q= *vp; *q != '\0'; q++)
|
||||
{
|
||||
if (isspace(*q))
|
||||
{
|
||||
space= TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (first_arg)
|
||||
{
|
||||
first_arg = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)putc(' ', stderr);
|
||||
}
|
||||
(void)fprintf(stderr, space ? "\"%s\"":"%s", *vp);
|
||||
}
|
||||
if (*std_in != NULL)
|
||||
(void)fprintf(stderr, " <%s", *std_in);
|
||||
if ( make_lint_lib_fd && (step->program == &program.lint1)
|
||||
&& (this_pipe[PIPE_RD_FD] == -1))
|
||||
(void)fprintf(stderr, " >>%s", outfile);
|
||||
if (*std_out != NULL)
|
||||
(void)fprintf(stderr, " >%s", *std_out);
|
||||
if (this_pipe[PIPE_RD_FD] != -1)
|
||||
(void)fprintf(stderr, " | ");
|
||||
else
|
||||
(void)fprintf(stderr, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
close_if_open(fd)
|
||||
int fd;
|
||||
{
|
||||
if (fd == -1) return 0;
|
||||
else
|
||||
{
|
||||
/** if(is_on(debug)) fprintf(stderr,"[close fd %d]", fd); **/
|
||||
return close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* run_steps
|
||||
* Run all the steps that are relevant to compile this source file.
|
||||
*/
|
||||
int
|
||||
run_steps(source, step, do_cb, source_suffix)
|
||||
register char *source; /* the previous out_file. */
|
||||
register StepP step;
|
||||
Bool do_cb;
|
||||
char *source_suffix;
|
||||
{
|
||||
Step current_steps[sizeof(program)/sizeof(Program)];
|
||||
StepP final_step= NULL;
|
||||
StepP wait_step= current_steps;
|
||||
StepP p;
|
||||
StepP q;
|
||||
char *out_file= source;
|
||||
char *proposed_out_file;
|
||||
int previous_pipe;
|
||||
int this_pipe[2];
|
||||
char *std_out= NULL;
|
||||
char *std_in= NULL;
|
||||
ListP unlink_candidates= NULL;
|
||||
int status= 0;
|
||||
int processes_running= 0;
|
||||
|
||||
if ( (requested_suffix == &suffix.i) &&
|
||||
(product.value == &preprocessed/*-E*/) )
|
||||
{
|
||||
/* As an exception, we can run "cc -E" on a file of any suffix
|
||||
* (doesn't have to be ".c").
|
||||
*/
|
||||
current_steps[0] = anything_thru_cc_E_steps[0];
|
||||
final_step = ¤t_steps[0];
|
||||
}
|
||||
else if ( (requested_suffix == &suffix.i) &&
|
||||
( (product.value == &preprocessed2/*-P*/) &&
|
||||
(strcmp(get_file_suffix(source), suffix.i.suffix) != 0 ) )
|
||||
)
|
||||
{
|
||||
/* As an exception, we can run "cc -P" on a file of any suffix
|
||||
* (doesn't have to be ".c") -- except for an input file with
|
||||
* a ".i" suffix, since it would get overwritten.
|
||||
*/
|
||||
current_steps[0] = anything_thru_cc_P_steps[0];
|
||||
final_step = ¤t_steps[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* First run thru the steps, and extract the ones we are going
|
||||
* to use this time.
|
||||
*/
|
||||
for ( p= step, q= current_steps;
|
||||
p->program != &program.sentinel_program_field;
|
||||
p++)
|
||||
{
|
||||
if ((p->expression == NULL) || (*p->expression)())
|
||||
{
|
||||
/* Remember the last step which produces the
|
||||
* suffix we want.
|
||||
*/
|
||||
if (p->out_suffix == requested_suffix)
|
||||
final_step= q;
|
||||
*q++= *p;
|
||||
}
|
||||
}
|
||||
if (final_step == NULL)
|
||||
{
|
||||
fatal("Cannot go from .%s to .%s",
|
||||
get_file_suffix(source),
|
||||
requested_suffix->suffix);
|
||||
}
|
||||
}
|
||||
(final_step+1)->program= NULL;
|
||||
|
||||
|
||||
/* Then run the steps */
|
||||
previous_pipe= -1;
|
||||
for (step= current_steps; step->program && (status == 0); step++)
|
||||
{
|
||||
step->program->outfile= NULL;
|
||||
proposed_out_file= NULL;
|
||||
|
||||
/* Run the setup for the step if any */
|
||||
if (step->setup != NULL)
|
||||
proposed_out_file= (*step->setup)(source, out_file);
|
||||
|
||||
/* Run the setup for the program if any and the step didn't
|
||||
* do it.
|
||||
*/
|
||||
if ((proposed_out_file == NULL) &&
|
||||
(step->program->setup != NULL))
|
||||
proposed_out_file=
|
||||
(*step->program->setup)(source, out_file);
|
||||
if (proposed_out_file != NULL)
|
||||
{
|
||||
/* The setup function is responsible for setting up the
|
||||
* infile.
|
||||
*/
|
||||
out_file= proposed_out_file;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The setup routines don't care about the outfile name.
|
||||
* The outfile name here is from the previous step;
|
||||
* use it as input.
|
||||
*/
|
||||
append_list(&step->program->infile, out_file);
|
||||
|
||||
if ( ( (product.value == &executable) &&
|
||||
(step->out_suffix == &suffix.o)) ||
|
||||
( ((step+1)->program == NULL) &&
|
||||
( (product.value != &executable) ||
|
||||
(driver.value == &m2c)
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
/* If this is the last step (or last before ld)
|
||||
* we use real outname.
|
||||
*/
|
||||
out_file= outfile_name(source, requested_suffix,
|
||||
step->program);
|
||||
if ((source_infile_count == 1) &&
|
||||
(product.value == &executable) &&
|
||||
(driver.value != &m2c))
|
||||
/* The command "cc foo.c" removes
|
||||
* "foo.o" after linking it.
|
||||
*/
|
||||
append_list(&files_to_unlink,
|
||||
make_string(out_file));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is intermediate outfile */
|
||||
out_file= temp_file_name(step->program,
|
||||
step->out_suffix, 0);
|
||||
}
|
||||
step->program->outfile= out_file;
|
||||
}
|
||||
|
||||
/* Execute the program for the step */
|
||||
build_argv(argv_for_passes, step, this_pipe, &std_in, &std_out,
|
||||
&unlink_candidates, &previous_pipe);
|
||||
|
||||
if (is_on(dryrun))
|
||||
{
|
||||
(void)close_if_open(this_pipe[PIPE_RD_FD]);
|
||||
(void)close_if_open(this_pipe[PIPE_WR_FD]);
|
||||
goto end_loop;
|
||||
}
|
||||
|
||||
if (is_on(time_run))
|
||||
{
|
||||
(void)gettimeofday(&step->start,
|
||||
(struct timezone *)NULL);
|
||||
}
|
||||
|
||||
step->killed= FALSE;
|
||||
|
||||
switch (step->process= fork())
|
||||
{
|
||||
|
||||
case -1:
|
||||
fatal("fork failed");
|
||||
|
||||
case 0: /* Child */
|
||||
if (std_out != NULL)
|
||||
{
|
||||
int mode= 0666;
|
||||
|
||||
/* If we need to create file to write, do it. */
|
||||
if (STR_EQUAL_N(temp_dir, std_out,
|
||||
strlen(temp_dir)))
|
||||
{
|
||||
/* Create temp files with fewer
|
||||
* permissions.
|
||||
*/
|
||||
mode= 0600;
|
||||
}
|
||||
if ( (this_pipe[PIPE_WR_FD]=
|
||||
/* opening /tmp file; deliberately
|
||||
* use open(), not open_vroot().
|
||||
*/
|
||||
open(std_out,
|
||||
O_WRONLY|O_CREAT|O_TRUNC, mode)
|
||||
) < 0)
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"%s: Cannot open %s for output\n",
|
||||
program_name, std_out);
|
||||
_exit(1);
|
||||
}
|
||||
}
|
||||
if (this_pipe[PIPE_WR_FD] > 0)
|
||||
{
|
||||
(void)dup2(this_pipe[PIPE_WR_FD],
|
||||
fileno(stdout));
|
||||
}
|
||||
if ( make_lint_lib_fd &&
|
||||
(step->program == &program.lint1) &&
|
||||
(std_out == NULL) &&
|
||||
(this_pipe[PIPE_WR_FD] <= 0) )
|
||||
{
|
||||
(void)dup2(make_lint_lib_fd, fileno(stdout));
|
||||
}
|
||||
(void)close_if_open(this_pipe[PIPE_RD_FD]);
|
||||
|
||||
/* Open the infile if we need to */
|
||||
if (std_in != NULL)
|
||||
{
|
||||
if ( (previous_pipe=
|
||||
/* opening /tmp file; deliberately
|
||||
* use open(), not open_vroot().
|
||||
*/
|
||||
open(std_in, O_RDONLY, 0644)
|
||||
) < 0)
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"%s: Cannot open %s for input\n",
|
||||
program_name, std_in);
|
||||
_exit(1);
|
||||
}
|
||||
}
|
||||
if (previous_pipe > 0)
|
||||
{
|
||||
(void)dup2(previous_pipe, fileno(stdin));
|
||||
}
|
||||
execve(*argv_for_passes, argv_for_passes+1, environ);
|
||||
(void)fprintf(stderr, "%s: Cannot exec %s\n",
|
||||
program_name, *argv_for_passes);
|
||||
_exit(1);
|
||||
break;
|
||||
|
||||
default: /* Parent */
|
||||
processes_running++;
|
||||
break;
|
||||
}
|
||||
|
||||
/* This step is done.
|
||||
* Close its input & output pipes, if used.
|
||||
*/
|
||||
(void)close_if_open(previous_pipe);
|
||||
(void)close_if_open(this_pipe[PIPE_WR_FD]);
|
||||
|
||||
/* If there are no steps reading piped output from this step,
|
||||
* then wait for all running steps to complete before going on.
|
||||
*/
|
||||
if (this_pipe[PIPE_RD_FD] == -1)
|
||||
{
|
||||
while (processes_running > 0)
|
||||
{
|
||||
status|= wait_program(wait_step, step);
|
||||
processes_running--;
|
||||
}
|
||||
wait_step= step;
|
||||
}
|
||||
|
||||
end_loop:
|
||||
if ( is_on(remove_tmp_files) &&
|
||||
((previous_pipe= this_pipe[PIPE_RD_FD]) == -1) )
|
||||
{
|
||||
/* If we are removing temp files (which is standard
|
||||
* procedure), and this was the last leg of a pipeline,
|
||||
* we remove all consumed tempfiles.
|
||||
* Files must be on both "files_to_unlink" and the
|
||||
* local "unlink_candidates" list to get removed.
|
||||
*/
|
||||
for (; unlink_candidates != NULL;
|
||||
unlink_candidates= unlink_candidates->next)
|
||||
{
|
||||
ListP cp;
|
||||
|
||||
for (cp= files_to_unlink; cp != NULL;
|
||||
cp= cp->next)
|
||||
{
|
||||
if (cp->value ==
|
||||
unlink_candidates->value)
|
||||
{
|
||||
if ( ( is_on(verbose) ||
|
||||
is_on(dryrun)
|
||||
) &&
|
||||
is_on(show_rm_commands)
|
||||
){
|
||||
(void)fprintf(stderr,
|
||||
"rm %s\n",
|
||||
unlink_candidates->value);
|
||||
}
|
||||
(void)unlink(unlink_candidates->value);
|
||||
cp->value= NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
step--;
|
||||
if (step->out_suffix->collect != NULL)
|
||||
/* And offer what we just produced for collection */
|
||||
/* Collected files will be postprocessed */
|
||||
(*step->out_suffix->collect)(out_file, step->out_suffix);
|
||||
return status;
|
||||
} /* run_steps */
|
||||
137
lang/compile/rw_data.c
Normal file
137
lang/compile/rw_data.c
Normal file
@@ -0,0 +1,137 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)rw_data.c 1.1 94/10/31 SMI";
|
||||
#endif
|
||||
/*
|
||||
* Copyright (c) 1987 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "driver.h"
|
||||
|
||||
/* The following crt0.o data must be R/W, in order to handle both 3.2
|
||||
* and 4.0 source organizations.
|
||||
*/
|
||||
Const_int f68881= { FLOAT_68881, "-f68881", NULL };
|
||||
Const_int ffpa= { FLOAT_FPA, "-ffpa", NULL };
|
||||
Const_int fsky= { FLOAT_SKY, "-fsky", NULL };
|
||||
Const_int fsoft= { FLOAT_SOFT, "-fsoft", NULL };
|
||||
|
||||
Const_int gprof= { PROF_NEW, "gprof", NULL };
|
||||
Const_int no_prof={ PROF_NONE, NULL, NULL };
|
||||
Const_int prof= { PROF_OLD, "prof", NULL };
|
||||
|
||||
Const_int arch_foreign= { ARCH_FOREIGN, NULL, NULL };
|
||||
|
||||
Named_int debugger= { NULL, "debug", 0, 0 };
|
||||
Named_int driver= { NULL, "", 0, 0 };
|
||||
Named_int float_mode= { NULL, "floating point option", 0, 0 };
|
||||
Named_int host_arch= { NULL, "host architecture", 0, 0 };
|
||||
Named_int product= { &executable, "produce", 0, 0 };
|
||||
Named_int profile= { &no_prof, "profile", 0, 0 };
|
||||
Named_int target_arch= { NULL, "target architecture", 0, 0 };
|
||||
Named_int target_sw_release[R_elements]=
|
||||
{ { &sw_release_default,
|
||||
"target software release[0]",
|
||||
0, 0 },
|
||||
{ &sw_release_default,
|
||||
"target software release[1]",
|
||||
0, 0 },
|
||||
{ &sw_release_default,
|
||||
"target software release[2]",
|
||||
0, 0 }
|
||||
};
|
||||
|
||||
char **argv_for_passes;
|
||||
char *base_driver_release;
|
||||
char *debug_info_filename;
|
||||
int exit_status;
|
||||
ListP files_to_unlink;
|
||||
Global_flag global_flag;
|
||||
ListP infile;
|
||||
int infile_count;
|
||||
ListP infile_ln;
|
||||
ListP infile_o;
|
||||
char *iropt_files[3];
|
||||
int last_program_path;
|
||||
char *ld_to_vpa_file;
|
||||
int make_lint_lib_fd;
|
||||
ListP module_list;
|
||||
int optim_after_cat;
|
||||
char optimizer_level= OPTIM_NONE;
|
||||
char *outfile;
|
||||
char *program_name= "compile";
|
||||
pathpt program_path;
|
||||
ListP report;
|
||||
SuffixP requested_suffix;
|
||||
int source_infile_count;
|
||||
char *tcov_file;
|
||||
char *temp_dir= "/tmp";
|
||||
int temp_file_number;
|
||||
ListP temp_files_named;
|
||||
char *to_as_file;
|
||||
int use_default_optimizer_level= 0;
|
||||
|
||||
#ifdef lint
|
||||
char *sys_siglist[1];
|
||||
char **environ;
|
||||
#endif lint
|
||||
|
||||
|
||||
Programs program=
|
||||
{
|
||||
{ "cppas", "/usr/ucb/cppas", DRIVER_P, setup_cppas, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ OPTION_TEMPLATE, STDOUT_TEMPLATE, IN_TEMPLATE } },
|
||||
{ "cpp", "/lib/cpp", DRIVER_CFLP, setup_cpp, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ STDOUT_TEMPLATE, OPTION_TEMPLATE, IN_TEMPLATE } },
|
||||
{ "m4", "/usr/bin/m4", DRIVER_F, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ STDIN_TEMPLATE, STDOUT_TEMPLATE, OPTION_TEMPLATE } },
|
||||
{ "ratfor", "/usr/bin/ratfor", DRIVER_F, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ STDIN_TEMPLATE, STDOUT_TEMPLATE, OPTION_TEMPLATE } },
|
||||
{ "lint1", "/usr/lib/lint/lint1", DRIVER_L, NULL, NULL, NULL,NULL,NULL,NULL,NULL,0,
|
||||
{ STDIN_TEMPLATE, STDOUT_TEMPLATE, OPTION_TEMPLATE } },
|
||||
{ "cat", "/bin/cat", HIDE(DRIVER_FL), NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ STDOUT_TEMPLATE, OPTION_TEMPLATE, IN_TEMPLATE } },
|
||||
{ "lint2", "/usr/lib/lint/lint2", DRIVER_L, NULL, NULL, NULL,NULL,NULL,NULL,NULL,0,
|
||||
{ IN_TEMPLATE, OPTION_TEMPLATE } },
|
||||
{ "m2cfe", "/usr/lib/modula2/m2cfe", DRIVER_M, setup_m2cfe, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ OPTION_TEMPLATE, IN_TEMPLATE, OUT_TEMPLATE, OUT2_TEMPLATE}},
|
||||
{ "ccom", "/lib/ccom", DRIVER_C, setup_ccom, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ STDIN_TEMPLATE, STDOUT_TEMPLATE, MINUS_TEMPLATE, OPTION_TEMPLATE } },
|
||||
{ "pc0", "/usr/lib/pc0", DRIVER_P, setup_pc0, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ OUT_TEMPLATE, MINUS_O_TEMPLATE, OPTION_TEMPLATE, IN_TEMPLATE} },
|
||||
{ "f1", "/usr/lib/f1", DRIVER_P, setup_f1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ STDOUT_TEMPLATE, OPTION_TEMPLATE, IN_TEMPLATE } },
|
||||
{ "mf1", "/usr/lib/modula2/f1", DRIVER_M, setup_mf1, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ STDOUT_TEMPLATE, OPTION_TEMPLATE, IN_TEMPLATE } },
|
||||
{ "vpaf77", "/usr/lib/vpaf77", DRIVER_F, NULL, NULL, NULL, NULL, NULL, NULL,NULL,0,
|
||||
{ STDIN_TEMPLATE, STDOUT_TEMPLATE, OPTION_TEMPLATE } },
|
||||
{ "f77pass1", "/usr/lib/f77pass1", DRIVER_F, setup_f77pass1, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ OPTION_TEMPLATE, IN_TEMPLATE, OUT_TEMPLATE } },
|
||||
|
||||
{ "iropt", "/usr/lib/iropt", DRIVER_CFMP, setup_iropt_all, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ OPTION_TEMPLATE, MINUS_O_TEMPLATE,OUT_TEMPLATE,IN_TEMPLATE} },
|
||||
|
||||
{ "cg", "/usr/lib/cg", DRIVER_CFP, setup_cg_all, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ STDOUT_TEMPLATE, OPTION_TEMPLATE, IN_TEMPLATE } },
|
||||
|
||||
{ "inline", "/usr/lib/inline", DRIVER_CFMP, NULL, NULL, NULL,NULL,NULL,NULL,NULL, 0,
|
||||
{ STDIN_TEMPLATE, STDOUT_TEMPLATE, OPTION_TEMPLATE } },
|
||||
|
||||
# ifdef sun386
|
||||
{ "optim", "/lib/optim", DRIVER_CFMP, setup_c2, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
# else /*!sun386*/
|
||||
{ "c2", "/lib/c2", DRIVER_CFMP, setup_c2, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
# endif /*sun386*/
|
||||
{ STDIN_TEMPLATE, STDOUT_TEMPLATE, OPTION_TEMPLATE } },
|
||||
{ "as", "/bin/as", DRIVER_CFMP, setup_as, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ MINUS_O_TEMPLATE, OUT_TEMPLATE,OPTION_TEMPLATE,IN_TEMPLATE} },
|
||||
{ "asS", "/bin/as", DRIVER_CFMP, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ STDOUT_TEMPLATE, OPTION_TEMPLATE, IN_TEMPLATE } },
|
||||
{ "pc3", "/usr/lib/pc3", DRIVER_P, setup_pc3, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ OPTION_TEMPLATE, IN_TEMPLATE } },
|
||||
{ "ld", "/bin/ld", DRIVER_CFP, setup_link_step, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ OPTION_TEMPLATE, MINUS_O_TEMPLATE,OUT_TEMPLATE,IN_TEMPLATE} },
|
||||
{ "vpald", "/usr/lib/vpald", DRIVER_F, setup_vpald, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ OPTION_TEMPLATE, MINUS_O_TEMPLATE,OUT_TEMPLATE,IN_TEMPLATE} },
|
||||
{ "m2l", "/usr/bin/m2l", DRIVER_M, setup_link_step, NULL, NULL, NULL, NULL, NULL, NULL, 0,
|
||||
{ OPTION_TEMPLATE, IN_TEMPLATE,MINUS_O_TEMPLATE,OUT_TEMPLATE} },
|
||||
};
|
||||
1328
lang/compile/setup.c
Normal file
1328
lang/compile/setup.c
Normal file
File diff suppressed because it is too large
Load Diff
325
lang/compile/setup_cc.c
Normal file
325
lang/compile/setup_cc.c
Normal file
@@ -0,0 +1,325 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)setup_cc.c 1.1 94/10/31 SMI";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "driver.h"
|
||||
|
||||
/*
|
||||
* compile_i
|
||||
*/
|
||||
int
|
||||
compile_i(source)
|
||||
char *source;
|
||||
{
|
||||
int status;
|
||||
|
||||
#ifdef BROWSER
|
||||
global_flag.code_browser = global_flag.code_browser_seen;
|
||||
#endif
|
||||
clear_program_options();
|
||||
|
||||
if (requested_suffix == &suffix.s)
|
||||
{
|
||||
set_flag(do_cat);
|
||||
}
|
||||
if (optimizer_level > OPTIM_C2 || is_on(statement_count))
|
||||
{
|
||||
status= run_steps(source, c_iropt_steps, TRUE, "c");
|
||||
}
|
||||
else
|
||||
{
|
||||
status= run_steps(source, c_no_iropt_steps, TRUE, "c");
|
||||
}
|
||||
reset_flag(do_cat);
|
||||
#ifdef BROWSER
|
||||
reset_flag(code_browser);
|
||||
#endif
|
||||
return status;
|
||||
} /* compile_i */
|
||||
|
||||
/*
|
||||
* compile_c
|
||||
*/
|
||||
int
|
||||
compile_c(source)
|
||||
char *source;
|
||||
{
|
||||
int status;
|
||||
|
||||
set_flag(do_cpp);
|
||||
if (is_on(statement_count))
|
||||
{
|
||||
setup_tcov_file(source);
|
||||
}
|
||||
status= compile_i(source);
|
||||
reset_flag(do_cpp);
|
||||
return status;
|
||||
} /* compile_c */
|
||||
|
||||
/*
|
||||
* setup_cpp_for_cc
|
||||
*/
|
||||
char *
|
||||
setup_cpp_for_cc()
|
||||
{
|
||||
if (product.value == &preprocessed2)
|
||||
{
|
||||
append_list(&program.cpp.options, "-P");
|
||||
}
|
||||
return NULL;
|
||||
} /* setup_cpp_for_cc */
|
||||
|
||||
/*
|
||||
* setup_ccom
|
||||
*/
|
||||
char *
|
||||
setup_ccom()
|
||||
{
|
||||
if (!program.ccom.has_been_initialized)
|
||||
{
|
||||
program.ccom.has_been_initialized = TRUE;
|
||||
if (profile.touched && (optimizer_level < OPTIM_IROPT_P))
|
||||
{
|
||||
char *ccom_profile_flag;
|
||||
switch (target_arch.value->value)
|
||||
{
|
||||
case ARCH_SUN2:
|
||||
case ARCH_SUN3X:
|
||||
case ARCH_SUN3:
|
||||
switch (target_sw_release[R_PASSES].value->value)
|
||||
{
|
||||
case SW_REL_3X:
|
||||
ccom_profile_flag = "-XP";/* 3.x flag */
|
||||
break;
|
||||
default:
|
||||
ccom_profile_flag = "-p"; /* 4.x flag */
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case ARCH_SUN386:
|
||||
ccom_profile_flag = "-XP"; /*3.x flag, for now*/
|
||||
break;
|
||||
|
||||
case ARCH_FOREIGN:
|
||||
default:
|
||||
/* Other ccom's (e.g. Sun-4) always gets
|
||||
* new-style flag.
|
||||
*/
|
||||
ccom_profile_flag = "-p"; /* 4.x flag */
|
||||
break;
|
||||
}
|
||||
append_list(&program.ccom.permanent_options,
|
||||
ccom_profile_flag);
|
||||
}
|
||||
|
||||
if (is_on(pic_code))
|
||||
append_list(&program.ccom.permanent_options, "-Xk");
|
||||
if (is_on(PIC_code))
|
||||
append_list(&program.ccom.permanent_options, "-XK");
|
||||
if (debugger.value == &adb)
|
||||
append_list(&program.ccom.permanent_options, "-XG");
|
||||
if (debugger.value == &dbx)
|
||||
append_list(&program.ccom.permanent_options, "-Xg");
|
||||
|
||||
if (optimizer_level < OPTIM_IROPT_P)
|
||||
{
|
||||
/* Since the optimization level is 0 or 1, "cg" is not
|
||||
* going to be run, so add these flags to "ccom".
|
||||
*/
|
||||
if (is_on(generate_nonzero_activation_records) &&
|
||||
is_off(statement_count) )
|
||||
{
|
||||
append_list(&program.ccom.permanent_options,
|
||||
"-bnzero");
|
||||
}
|
||||
if ( is_on(fstore) )
|
||||
{
|
||||
append_list(&program.ccom.permanent_options,
|
||||
"-fstore");
|
||||
}
|
||||
if ( is_on(handle_misalignment) )
|
||||
{
|
||||
append_list(&program.ccom.permanent_options,
|
||||
"-m");
|
||||
}
|
||||
if (target_sw_release[R_PASSES].value->value
|
||||
>= SW_REL_41 )
|
||||
{
|
||||
if ( is_on(doubleword_aligned_doubles) )
|
||||
{
|
||||
append_list(&program.ccom.permanent_options,
|
||||
"-d");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (target_arch.value->value)
|
||||
{
|
||||
case ARCH_SUN2:
|
||||
case ARCH_SUN3X:
|
||||
case ARCH_SUN3:
|
||||
if (is_on(long_offset) &&
|
||||
(optimizer_level < OPTIM_IROPT_P))
|
||||
{
|
||||
char *ccom_J_flag;
|
||||
switch (target_sw_release[R_PASSES].value->value)
|
||||
|
||||
{
|
||||
case SW_REL_3X: ccom_J_flag = "-XJ"; break;
|
||||
default: ccom_J_flag = "-J" ; break;
|
||||
}
|
||||
append_list(&program.ccom.permanent_options,
|
||||
ccom_J_flag);
|
||||
}
|
||||
append_list(&program.ccom.permanent_options,
|
||||
float_mode.value->name);
|
||||
break;
|
||||
case ARCH_SUN386:
|
||||
if(requested_suffix == &suffix.s)
|
||||
{
|
||||
append_list(&program.ccom.permanent_options,
|
||||
"-Xl");
|
||||
}
|
||||
if(is_on(as_R))
|
||||
{
|
||||
append_list(&program.ccom.permanent_options, "-XR");
|
||||
}
|
||||
break;
|
||||
case ARCH_SUN4C:
|
||||
case ARCH_SUN4:
|
||||
if (is_on(sparc_sdata))
|
||||
append_list(&program.ccom.permanent_options,
|
||||
"-Xx");
|
||||
break;
|
||||
case ARCH_FOREIGN:
|
||||
default:
|
||||
/* do nothing here. */
|
||||
break;
|
||||
}
|
||||
|
||||
switch (target_arch.value->value)
|
||||
{
|
||||
case ARCH_SUN2:
|
||||
case ARCH_SUN3X:
|
||||
case ARCH_SUN3:
|
||||
append_list(&program.ccom.permanent_options,
|
||||
get_processor_flag(target_arch.value));
|
||||
break;
|
||||
case ARCH_SUN386:
|
||||
case ARCH_SUN4C:
|
||||
case ARCH_SUN4:
|
||||
case ARCH_FOREIGN:
|
||||
default:
|
||||
/* do nothing here. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BROWSER
|
||||
if (is_on(code_browser)) {
|
||||
append_list(&program.ccom.options, "-cb");
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
} /* setup_ccom */
|
||||
|
||||
/*
|
||||
* setup_cat_for_cc
|
||||
* This is used when "cc -O3 -S" has been given.
|
||||
* The assembly source from ccom must be combined with the one
|
||||
* from c2.
|
||||
*/
|
||||
char *
|
||||
setup_cat_for_cc(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
{
|
||||
append_list(&program.cat.infile, program.ccom.outfile);
|
||||
append_list(&program.cat.infile, file);
|
||||
return program.cat.outfile=
|
||||
outfile_name(source, &suffix.s, (ProgramP)NULL);
|
||||
} /* setup_cat_for_cc */
|
||||
|
||||
/*
|
||||
* setup_as_for_cc
|
||||
* This is used to feed "as" the infiles from both ccom and c2,
|
||||
* when iropt is used.
|
||||
*/
|
||||
char *
|
||||
setup_as_for_cc(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
{
|
||||
(void)setup_as();
|
||||
if ( (optimizer_level > OPTIM_C2) || is_on(statement_count))
|
||||
append_list(&program.as.infile, program.ccom.outfile);
|
||||
append_list(&program.as.infile, file);
|
||||
program.as.outfile= outfile_name(source, &suffix.o, (ProgramP)NULL);
|
||||
if ((source_infile_count == 1) && (product.value == &executable))
|
||||
append_list(&files_to_unlink, make_string(program.as.outfile));
|
||||
return program.as.outfile;
|
||||
} /* setup_as_for_cc */
|
||||
|
||||
/*
|
||||
* setup_asS_for_cc
|
||||
* This is used to feed "as" the infiles from both ccom and c2,
|
||||
* when iropt is used, for SPARC.
|
||||
*/
|
||||
char *
|
||||
setup_asS_for_cc(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
{
|
||||
setup_asS();
|
||||
if (optimizer_level > OPTIM_C2 || is_on(statement_count))
|
||||
append_list(&program.asS.infile, program.ccom.outfile);
|
||||
append_list(&program.asS.infile, file);
|
||||
program.asS.outfile= outfile_name(source, &suffix.s, (ProgramP)NULL);
|
||||
return program.asS.outfile;
|
||||
|
||||
} /* setup_asS_for_cc */
|
||||
|
||||
/*
|
||||
* setup_ld_for_cc
|
||||
*/
|
||||
char *
|
||||
setup_ld_for_cc()
|
||||
{
|
||||
static char *libraries[] = { "-lc", NULL };
|
||||
static char *profiled_libraries[] = { "-lc_p", NULL };
|
||||
|
||||
setup_ld( (char **)NULL, libraries, profiled_libraries );
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/*
|
||||
* cc_doit
|
||||
*/
|
||||
void
|
||||
cc_doit()
|
||||
{
|
||||
set_requested_suffix(&suffix.i);
|
||||
do_infiles();
|
||||
if (!exit_status && (product.value == &executable) &&
|
||||
(infile_o != NULL))
|
||||
{
|
||||
requested_suffix= &suffix.none;
|
||||
if (source_infile_count > 1)
|
||||
{
|
||||
(void)printf("Linking:\n");
|
||||
}
|
||||
clear_program_options();
|
||||
exit_status|= run_steps("", link_steps, FALSE, "");
|
||||
if (exit_status != 0)
|
||||
{
|
||||
do_not_unlink_ld_infiles();
|
||||
}
|
||||
}
|
||||
} /* cc_doit */
|
||||
473
lang/compile/setup_f77.c
Normal file
473
lang/compile/setup_f77.c
Normal file
@@ -0,0 +1,473 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)setup_f77.c 1.1 94/10/31 SMI";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "driver.h"
|
||||
|
||||
/*
|
||||
* compile_f
|
||||
*/
|
||||
int
|
||||
compile_f(source)
|
||||
char *source;
|
||||
{
|
||||
int status;
|
||||
|
||||
#ifdef BROWSER
|
||||
global_flag.code_browser = global_flag.code_browser_seen;
|
||||
#endif
|
||||
clear_program_options();
|
||||
|
||||
if ( (requested_suffix == &suffix.s) ||
|
||||
(target_arch.value->value == ARCH_SUN386) )
|
||||
{
|
||||
set_flag(do_cat);
|
||||
}
|
||||
if (is_on(statement_count))
|
||||
{
|
||||
setup_tcov_file(source);
|
||||
}
|
||||
|
||||
/* if this is version 1.2 and sw release 4.0
|
||||
* then look for the assembler and c2 elsewhere
|
||||
*/
|
||||
if (check_release_version_driver(SW_REL_40,DRIVER_REL_12,DRIVER_F) )
|
||||
{
|
||||
program.as.path = "/usr/lib/f77/as";
|
||||
program.asS.path = "/usr/lib/f77/as";
|
||||
program.c2.path = "/usr/lib/f77/c2";
|
||||
}
|
||||
|
||||
/* if the pic flag was specified on the command line, we need
|
||||
* to turn it off, it is only valid for 1.2 and 4.0 OS
|
||||
*/
|
||||
else
|
||||
{
|
||||
if (is_on(PIC_code))
|
||||
{
|
||||
reset_flag(PIC_code);
|
||||
warning("-PIC option ignored");
|
||||
}
|
||||
if (is_on(pic_code))
|
||||
{
|
||||
reset_flag(pic_code);
|
||||
warning("-pic option ignored");
|
||||
}
|
||||
}
|
||||
|
||||
status= run_steps(source,
|
||||
((optimizer_level > OPTIM_C2) ||
|
||||
is_on(statement_count))
|
||||
? f_iropt_steps : f_no_iropt_steps,
|
||||
TRUE,
|
||||
"f");
|
||||
reset_flag(do_cat);
|
||||
#ifdef BROWSER
|
||||
reset_flag(code_browser);
|
||||
#endif
|
||||
return status;
|
||||
} /* compile_f */
|
||||
|
||||
/*
|
||||
* compile_F
|
||||
*/
|
||||
int
|
||||
compile_F(source)
|
||||
char *source;
|
||||
{
|
||||
int status;
|
||||
|
||||
set_flag(do_cpp);
|
||||
status= compile_f(source);
|
||||
reset_flag(do_cpp);
|
||||
return status;
|
||||
} /* compile_F */
|
||||
|
||||
/*
|
||||
* compile_r
|
||||
*/
|
||||
int
|
||||
compile_r(source)
|
||||
char *source;
|
||||
{
|
||||
int status;
|
||||
|
||||
set_flag(do_ratfor);
|
||||
status= compile_f(source);
|
||||
reset_flag(do_ratfor);
|
||||
return status;
|
||||
} /* compile_r */
|
||||
|
||||
/*
|
||||
* setup_f1
|
||||
*/
|
||||
char *
|
||||
setup_f1()
|
||||
{
|
||||
if (!program.f1.has_been_initialized)
|
||||
{
|
||||
program.f1.has_been_initialized = TRUE;
|
||||
f1_to_mf1_copy();
|
||||
if (profile.touched)
|
||||
{
|
||||
append_list(&program.f1.permanent_options, "-p");
|
||||
}
|
||||
if (is_on(checkC) || is_on(checkH) || is_on(checkV))
|
||||
{
|
||||
append_list(&program.f1.permanent_options, "-V");
|
||||
}
|
||||
switch (target_arch.value->value)
|
||||
{
|
||||
case ARCH_SUN2:
|
||||
case ARCH_SUN3X:
|
||||
case ARCH_SUN3:
|
||||
append_list(&program.f1.permanent_options,
|
||||
float_mode.value->name);
|
||||
append_list(&program.f1.permanent_options,
|
||||
get_processor_flag(target_arch.value));
|
||||
break;
|
||||
default:
|
||||
/* do nothing. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
} /* setup_f1 */
|
||||
|
||||
/*
|
||||
* setup_f77pass1
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
char *
|
||||
setup_f77pass1(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
{
|
||||
char buffer[LOCAL_STRING_LENGTH];
|
||||
|
||||
if (!program.f77pass1.has_been_initialized)
|
||||
{
|
||||
program.f77pass1.has_been_initialized = TRUE;
|
||||
if (optimizer_level > OPTIM_C2)
|
||||
append_list(&program.f77pass1.permanent_options, "-O");
|
||||
if (is_on(statement_count))
|
||||
append_list(&program.f77pass1.permanent_options, "-a");
|
||||
if (is_on(onetrip))
|
||||
append_list(&program.f77pass1.permanent_options, "-1");
|
||||
if (float_mode.value == &fsky)
|
||||
append_list(&program.f77pass1.permanent_options, "-F");
|
||||
if (debugger.value == &dbx)
|
||||
append_list(&program.f77pass1.permanent_options, "-g");
|
||||
if ( is_on(handle_misalignment) )
|
||||
append_list(&program.f77pass1.permanent_options, "-m");
|
||||
if ( (target_sw_release[R_PASSES].value->value >= SW_REL_41 )
|
||||
||
|
||||
/* if 4.0 OS and 1.2 fortran */
|
||||
check_release_version_driver(SW_REL_40,DRIVER_REL_12,DRIVER_F) )
|
||||
{
|
||||
if ( is_on(doubleword_aligned_doubles) )
|
||||
{
|
||||
append_list(&program.f77pass1.permanent_options, "-f");
|
||||
}
|
||||
}
|
||||
|
||||
if ( (optimizer_level < OPTIM_IROPT_P) &&
|
||||
is_off(statement_count) )
|
||||
{
|
||||
|
||||
strcpy(buffer, "-P");
|
||||
|
||||
if (is_on(pic_code))
|
||||
strcat(buffer, " -k");
|
||||
if (is_on(PIC_code))
|
||||
strcat(buffer, " -K");
|
||||
|
||||
if (profile.touched)
|
||||
{
|
||||
if ( (target_sw_release[R_PASSES].value->value
|
||||
== SW_REL_3X) &&
|
||||
(target_arch.value->value != ARCH_SUN4C) &&
|
||||
(target_arch.value->value != ARCH_SUN4)
|
||||
)
|
||||
{
|
||||
/* In release 3.x (for Sun-2 and Sun-3),
|
||||
* -p was passed directly to the
|
||||
* f77pass1 front-end.
|
||||
*/
|
||||
append_list(&program.f77pass1.permanent_options,
|
||||
"-p");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* In release 4.x (and in 3.x on Sun4),
|
||||
* -p is passed to the f77pass1
|
||||
* back-end via "-P -p".
|
||||
*/
|
||||
strcat(buffer, " -p");
|
||||
}
|
||||
}
|
||||
|
||||
switch (target_arch.value->value)
|
||||
{
|
||||
case ARCH_SUN2:
|
||||
case ARCH_SUN3X:
|
||||
case ARCH_SUN3:
|
||||
strcat(buffer, " ");
|
||||
strcat(buffer,
|
||||
get_processor_flag(target_arch.value));
|
||||
strcat(buffer, " ");
|
||||
strcat(buffer, float_mode.value->name);
|
||||
break;
|
||||
case ARCH_SUN4C:
|
||||
case ARCH_SUN4:
|
||||
if ( (target_sw_release[R_PASSES].value->value
|
||||
>= SW_REL_41 )
|
||||
||
|
||||
/* if 4.0 OS and 1.2 fortran */
|
||||
check_release_version_driver(SW_REL_40,DRIVER_REL_12,DRIVER_F) )
|
||||
|
||||
{
|
||||
if ( is_on(doubleword_aligned_doubles) )
|
||||
{
|
||||
strcat(buffer, " -d");
|
||||
}
|
||||
}
|
||||
if ( is_on(handle_misalignment) )
|
||||
{
|
||||
strcat(buffer, " -m");
|
||||
}
|
||||
break;
|
||||
case ARCH_FOREIGN:
|
||||
/* foreign arch'ture: let them set their own. */
|
||||
break;
|
||||
default:
|
||||
/* nothing to do. */
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !STR_EQUAL(buffer, "-P") )
|
||||
{
|
||||
/* buffer contains more than just "-P". */
|
||||
append_list(&program.f77pass1.permanent_options,
|
||||
make_string(buffer));
|
||||
}
|
||||
else
|
||||
if (target_arch.value->value == ARCH_SUN386)
|
||||
{
|
||||
append_list(&program.f77pass1.permanent_options, make_string(buffer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* When the original source file had a ".F" suffix, pass an extra
|
||||
* argument to f77pass1: "-Efile.F".
|
||||
* [This was done in f77's old dedicated driver (SunOS 3.0 and earlier).
|
||||
* It disappeared when /lib/compile was created, and was missing in
|
||||
* SunOS releases 3.2 thru 4.0beta2, and Sun FORTRAN releases up thru
|
||||
* at least 1.05].
|
||||
*/
|
||||
if (target_arch.value->value != ARCH_SUN386)
|
||||
{
|
||||
if (STR_EQUAL("F", get_file_suffix(source)))
|
||||
{
|
||||
strcpy(buffer, "-E");
|
||||
strcat(buffer, source);
|
||||
append_list(&program.f77pass1.options, make_string(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BROWSER
|
||||
if (is_on(code_browser))
|
||||
{
|
||||
append_list(&program.f77pass1.options, "-cb");
|
||||
}
|
||||
#endif
|
||||
|
||||
append_list(&program.f77pass1.infile, file);
|
||||
|
||||
/* Since f77pass1 produces three outfiles we need some extra temps */
|
||||
iropt_files[0]= temp_file_name(&program.f77pass1, &suffix.s, 's');
|
||||
iropt_files[1]= temp_file_name(&program.f77pass1, &suffix.s, 'i');
|
||||
iropt_files[2]= temp_file_name(&program.f77pass1, &suffix.s, 'd');
|
||||
append_list(&program.f77pass1.infile, iropt_files[0]);
|
||||
append_list(&program.f77pass1.infile, iropt_files[1]);
|
||||
append_list(&program.f77pass1.infile, iropt_files[2]);
|
||||
|
||||
return iropt_files[1];
|
||||
} /* setup_f77pass1 */
|
||||
|
||||
|
||||
/*
|
||||
* setup_cat_for_f77
|
||||
* Used for "-S -O3 foo.f" when we need to collect several
|
||||
* assembly sources.
|
||||
*/
|
||||
char *
|
||||
setup_cat_for_f77(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
{
|
||||
if ((requested_suffix != &suffix.s) && (target_arch.value == &arch_sun386))
|
||||
{
|
||||
append_list(&program.cat.infile, iropt_files[0]);
|
||||
append_list(&program.cat.infile, file);
|
||||
append_list(&program.cat.infile, iropt_files[2]);
|
||||
return program.cat.outfile= to_as_file = temp_file_name(&program.as, &suffix.s,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
append_list(&program.cat.infile, iropt_files[0]);
|
||||
append_list(&program.cat.infile, file);
|
||||
append_list(&program.cat.infile, iropt_files[2]);
|
||||
}
|
||||
if (target_arch.value->value == ARCH_SUN386)
|
||||
{
|
||||
if (optim_after_cat)
|
||||
{
|
||||
return program.cat.outfile = temp_file_name(&program.as, &suffix.s,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return program.cat.outfile = outfile_name(source, &suffix.s, (ProgramP)NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return program.cat.outfile = outfile_name(source, &suffix.s, (ProgramP)NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} /* setup_cat_for_f77 */
|
||||
|
||||
static int as_use_c2_output = FALSE;
|
||||
/*
|
||||
* setup_c2_for_f77
|
||||
* For the 386 if c2 is called then we must let the
|
||||
* assembler know that to_as_file should not be used, but the
|
||||
* output from c2 should be.
|
||||
*/
|
||||
char *
|
||||
setup_c2_for_f77(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
{
|
||||
as_use_c2_output = TRUE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* setup_as_for_f77
|
||||
* Used when "-O3 foo.f" means that as should be fed a number of
|
||||
* assembly source files.
|
||||
*
|
||||
* Also used for sun386 .. whose "as" does not take more than
|
||||
* one input file.
|
||||
*
|
||||
*/
|
||||
char *
|
||||
setup_as_for_f77(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
|
||||
{
|
||||
|
||||
(void)setup_as();
|
||||
if (target_arch.value->value == ARCH_SUN386)
|
||||
{
|
||||
if (as_use_c2_output)
|
||||
append_list(&program.as.infile, file);
|
||||
else
|
||||
append_list(&program.as.infile, to_as_file);
|
||||
as_use_c2_output = FALSE;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
append_list(&program.as.infile, iropt_files[0]);
|
||||
append_list(&program.as.infile, file);
|
||||
append_list(&program.as.infile, iropt_files[2]);
|
||||
}
|
||||
program.as.outfile= outfile_name(source, &suffix.o, (ProgramP)NULL);
|
||||
if ((source_infile_count == 1) && (product.value == &executable))
|
||||
append_list(&files_to_unlink, make_string(program.as.outfile));
|
||||
return program.as.outfile;
|
||||
} /* setup_as_for_f77 */
|
||||
|
||||
/*
|
||||
* setup_asS_for_f77
|
||||
* Used when "-O3 foo.f" means that "as" should be fed a number of
|
||||
* assembly source files. (SPARC version)
|
||||
*/
|
||||
char *
|
||||
setup_asS_for_f77(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
{
|
||||
setup_asS();
|
||||
append_list(&program.asS.infile, iropt_files[0]);
|
||||
append_list(&program.asS.infile, file);
|
||||
append_list(&program.asS.infile, iropt_files[2]);
|
||||
program.asS.outfile= outfile_name(source, &suffix.s, (ProgramP)NULL);
|
||||
return program.asS.outfile;
|
||||
} /* setup_asS_for_f77 */
|
||||
|
||||
/*
|
||||
* setup_ld_for_f77
|
||||
*/
|
||||
char *
|
||||
setup_ld_for_f77()
|
||||
{
|
||||
register ListP p;
|
||||
char buffer[LOCAL_STRING_LENGTH];
|
||||
#ifdef sun386
|
||||
static char *minus_u_options[] = { "-u", "MAIN_", NULL };
|
||||
#else
|
||||
static char *minus_u_options[] = { "-u", "_MAIN_", NULL };
|
||||
#endif
|
||||
static char *libraries[] =
|
||||
{ "-lF77", "-lI77", "-lU77", "-lm",
|
||||
"-lc", NULL };
|
||||
static char *profiled_libraries[] =
|
||||
{ "-lF77_p", "-lI77_p", "-lU77_p", "-lm_p",
|
||||
"-lc_p", NULL };
|
||||
|
||||
#ifdef sun386
|
||||
append_list(&program.ld.permanent_options, "-Bstatic");
|
||||
#endif sun386
|
||||
|
||||
setup_ld( (driver.value == &f77) ? minus_u_options : (char **)NULL,
|
||||
libraries, profiled_libraries );
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/*
|
||||
* f77_doit
|
||||
*/
|
||||
void
|
||||
f77_doit()
|
||||
{
|
||||
set_requested_suffix(&suffix.f);
|
||||
do_infiles();
|
||||
if (!exit_status && (product.value == &executable) &&
|
||||
(infile_o != NULL))
|
||||
{
|
||||
requested_suffix= &suffix.none;
|
||||
if (source_infile_count > 1)
|
||||
{
|
||||
(void)printf("Linking:\n");
|
||||
}
|
||||
clear_program_options();
|
||||
exit_status|= run_steps("", link_steps, FALSE, "");
|
||||
if (exit_status != 0)
|
||||
{
|
||||
do_not_unlink_ld_infiles();
|
||||
}
|
||||
}
|
||||
} /* f77_doit */
|
||||
145
lang/compile/setup_lint.c
Normal file
145
lang/compile/setup_lint.c
Normal file
@@ -0,0 +1,145 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)setup_lint.c 1.1 94/10/31 SMI";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "driver.h"
|
||||
#include <sys/file.h>
|
||||
|
||||
/*
|
||||
* setup_cat_for_lint
|
||||
* Since lint2 only takes one in arg we cat all the .ln files
|
||||
* together first
|
||||
*/
|
||||
char *
|
||||
setup_cat_for_lint()
|
||||
{
|
||||
register ListP p;
|
||||
|
||||
for (p= infile_ln; p != NULL; p= p->next)
|
||||
append_list(&program.cat.infile, p->value);
|
||||
return program.cat.outfile= temp_file_name(&program.cat, &suffix.ln, 0);
|
||||
} /* setup_cat_for_lint */
|
||||
|
||||
|
||||
/* This is a special program to determine what software release
|
||||
* we are going to be using. It is called from do_infiles.
|
||||
* The sw release is not known at the time it is first encountered
|
||||
* (parsing the command line), so we will get it know. This
|
||||
* function replaces the DUMMY_FLAG with the proper directory locations
|
||||
* for the specified sw release
|
||||
*/
|
||||
char *
|
||||
special_lint_l(file)
|
||||
char *file;
|
||||
|
||||
{
|
||||
char *lint_path;
|
||||
char path[MAXPATHLEN];
|
||||
char *temp;
|
||||
|
||||
switch (target_sw_release[R_PATHS].value->value)
|
||||
{
|
||||
case SW_REL_3X:
|
||||
case SW_REL_40:
|
||||
if (is_on(sys5_flag))
|
||||
{
|
||||
/* system 5 and release 4.0 or 3.x */
|
||||
lint_path = "/usr/5lib";
|
||||
}
|
||||
else
|
||||
{
|
||||
/* bsd and release 4.0 or 3.x */
|
||||
lint_path = "/usr/lib";
|
||||
}
|
||||
break;
|
||||
|
||||
case SW_REL_41:
|
||||
if (is_on(sys5_flag))
|
||||
{
|
||||
/* system 5 and release 4.1 */
|
||||
lint_path = "/usr/5lib";
|
||||
}
|
||||
else
|
||||
{
|
||||
/* bsd and release 4.1 */
|
||||
lint_path = "/usr/lib";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fatal("Invalid sw release specified for lint library");
|
||||
|
||||
}
|
||||
|
||||
temp = rindex(file,'/');
|
||||
temp++;
|
||||
(void)sprintf(path, "%s/lint/%s", lint_path, temp);
|
||||
|
||||
return make_string(path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* lint_doit
|
||||
*/
|
||||
void
|
||||
lint_doit()
|
||||
{
|
||||
temp_dir= "/usr/tmp";
|
||||
(void)dup2(fileno(stdout), fileno(stderr));
|
||||
|
||||
if (make_lint_lib_fd)
|
||||
{
|
||||
/* Open the outfile if creating a lint library */
|
||||
if (is_on(dryrun))
|
||||
make_lint_lib_fd= 1;
|
||||
else
|
||||
make_lint_lib_fd= open(outfile,
|
||||
O_WRONLY|O_CREAT|O_TRUNC, 0666);
|
||||
if (make_lint_lib_fd == -1)
|
||||
fatal("Cannot open %s for write", outfile);
|
||||
}
|
||||
|
||||
if (requested_suffix == NULL)
|
||||
{
|
||||
set_requested_suffix(&suffix.i);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (requested_suffix == &suffix.ln)
|
||||
set_named_int(product, &lint1_file);
|
||||
}
|
||||
|
||||
do_infiles();
|
||||
|
||||
/* Make sure the lint2 run sees -lc.
|
||||
* This must come *after* the call to do_infiles(), so that all user
|
||||
* function definitions are seen before the library ones -- in case
|
||||
* the user used a function of the same name as one of the library
|
||||
* routines.
|
||||
*/
|
||||
if (is_off(ignore_lc) && (product.value != &lint1_file))
|
||||
{
|
||||
collect_ln(lint_lib("-lc"), &suffix.ln);
|
||||
}
|
||||
|
||||
if (make_lint_lib_fd)
|
||||
{
|
||||
(void)close(make_lint_lib_fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((product.value != &lint1_file) && (infile_ln != NULL))
|
||||
{
|
||||
requested_suffix= &suffix.none;
|
||||
if (source_infile_count > 1)
|
||||
(void)printf("Lint pass2:\n");
|
||||
clear_program_options();
|
||||
exit_status|= run_steps("", lint_steps, FALSE, "");
|
||||
}
|
||||
}
|
||||
} /* lint_doit */
|
||||
485
lang/compile/setup_m2c.c
Normal file
485
lang/compile/setup_m2c.c
Normal file
@@ -0,0 +1,485 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)setup_m2c.c 1.1 94/10/31 SMI";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "driver.h"
|
||||
|
||||
/*
|
||||
* compile_def
|
||||
*/
|
||||
int
|
||||
compile_def(source)
|
||||
char *source;
|
||||
|
||||
{
|
||||
int status;
|
||||
|
||||
clear_program_options();
|
||||
if (target_sw_release[R_PASSES].value->value >= SW_REL_40)
|
||||
{
|
||||
status = run_steps(source, def_steps_non_3x, FALSE, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
status = run_steps(source, def_steps_3x, FALSE, "");
|
||||
}
|
||||
return status;
|
||||
|
||||
} /* compile_def */
|
||||
|
||||
/*
|
||||
* compile_mod
|
||||
*/
|
||||
int
|
||||
compile_mod(source)
|
||||
char *source;
|
||||
{
|
||||
int status;
|
||||
|
||||
clear_program_options();
|
||||
if (target_sw_release[R_PASSES].value->value >= SW_REL_40)
|
||||
{
|
||||
if (optimizer_level > OPTIM_C2 || is_on(statement_count))
|
||||
{
|
||||
status = run_steps(source, mod_iropt_steps, FALSE, "ir");
|
||||
}
|
||||
else
|
||||
{
|
||||
status = run_steps(source, mod_no_iropt_steps, FALSE, "ir");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = run_steps(source, mod_rel3x_steps, FALSE, "");
|
||||
}
|
||||
return status;
|
||||
|
||||
} /* compile_mod */
|
||||
|
||||
/*
|
||||
* setup_m2cfe
|
||||
*/
|
||||
char *
|
||||
setup_m2cfe()
|
||||
{
|
||||
char buffer[MAXPATHLEN];
|
||||
register ListP cp;
|
||||
|
||||
if (!program.m2cfe.has_been_initialized)
|
||||
{
|
||||
program.m2cfe.has_been_initialized = TRUE;
|
||||
if (optimizer_level > OPTIM_NONE)
|
||||
{
|
||||
append_list(&program.m2cfe.permanent_options, "-O");
|
||||
}
|
||||
/* else if no optimization append -noregs option */
|
||||
else
|
||||
{
|
||||
append_list(&program.m2cfe.permanent_options, "-noregs");
|
||||
}
|
||||
|
||||
if (debugger.touched)
|
||||
append_list(&program.m2cfe.permanent_options, "-g");
|
||||
if (is_on(trace))
|
||||
append_list(&program.m2cfe.permanent_options, "-v");
|
||||
if (is_on(statement_count))
|
||||
append_list(&program.m2cfe.permanent_options, "-a");
|
||||
/* The driver converts the list of -M options to one -M, with
|
||||
* all the dirs.
|
||||
*/
|
||||
(void)strcpy(buffer, "-M");
|
||||
for (cp= module_list; cp != NULL; cp= cp->next)
|
||||
{
|
||||
(void)strcat(buffer, cp->value+2);
|
||||
(void)strcat(buffer, " ");
|
||||
}
|
||||
if (is_off(no_default_module_list))
|
||||
{
|
||||
(void)strcat(buffer, ". /usr/lib/modula2");
|
||||
if (profile.touched)
|
||||
(void)strcat(buffer, "_p");
|
||||
}
|
||||
else
|
||||
if (module_list)
|
||||
/* Remove extra trailing space */
|
||||
buffer[strlen(buffer)-1]= '\0';
|
||||
if (buffer[2] != '\0')
|
||||
append_list(&program.m2cfe.permanent_options,
|
||||
make_string(buffer));
|
||||
}
|
||||
return NULL;
|
||||
} /* setup_m2cfe */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* setup_m2cfe_for_3x_def
|
||||
* Start m2cfe with -def option and basename of source filename
|
||||
*/
|
||||
char *
|
||||
setup_m2cfe_for_3x_def(source)
|
||||
char *source;
|
||||
{
|
||||
register char *p;
|
||||
register char *q;
|
||||
register int i;
|
||||
|
||||
static Template mod_def_template[PGM_TEMPLATE_LENGTH] =
|
||||
{ OPTION_TEMPLATE, IN_TEMPLATE, STDOUT_TEMPLATE};
|
||||
|
||||
for (i = 0; i < PGM_TEMPLATE_LENGTH; i++)
|
||||
{
|
||||
program.m2cfe.template[i] = mod_def_template[i];
|
||||
}
|
||||
|
||||
p= get_memory(strlen(source)+1);
|
||||
if ((q= rindex(source, '/')) == NULL)
|
||||
q= source;
|
||||
else
|
||||
q++; /* point PAST the '/' */
|
||||
(void)strcpy(p, q);
|
||||
if ((q= rindex(p, '.')) != NULL)
|
||||
*q= '\0';
|
||||
append_list(&program.m2cfe.options, "-def");
|
||||
append_list(&program.m2cfe.options, p);
|
||||
return NULL;
|
||||
|
||||
} /* setup_m2cfe_for_3x_def */
|
||||
|
||||
|
||||
/*
|
||||
* setup_m2cfe_for_non_3x_def
|
||||
* Start m2cfe with -def option and basename of source filename
|
||||
*/
|
||||
char *
|
||||
setup_m2cfe_for_non_3x_def(source)
|
||||
char *source;
|
||||
{
|
||||
register char *p;
|
||||
register char *q;
|
||||
register int i;
|
||||
|
||||
static Template mod_def_template[PGM_TEMPLATE_LENGTH] =
|
||||
{ OPTION_TEMPLATE, IN_TEMPLATE, OUT_TEMPLATE};
|
||||
|
||||
for (i = 0; i < PGM_TEMPLATE_LENGTH; i++)
|
||||
{
|
||||
program.m2cfe.template[i] = mod_def_template[i];
|
||||
}
|
||||
|
||||
p= get_memory(strlen(source)+1);
|
||||
if ((q= rindex(source, '/')) == NULL)
|
||||
q= source;
|
||||
else
|
||||
q++; /* point PAST the '/' */
|
||||
(void)strcpy(p, q);
|
||||
if ((q= rindex(p, '.')) != NULL)
|
||||
*q= '\0';
|
||||
append_list(&program.m2cfe.options, "-def");
|
||||
append_list(&program.m2cfe.options, p);
|
||||
return NULL;
|
||||
|
||||
} /* setup_m2cfe_for_non_3x_def */
|
||||
|
||||
|
||||
/*
|
||||
* setup_m2cfe_for_non_3x_mod
|
||||
* one iropt file
|
||||
* and one assembly file
|
||||
*/
|
||||
char *setup_m2cfe_for_non_3x_mod(source)
|
||||
char *source;
|
||||
{
|
||||
register char *p;
|
||||
register char *q;
|
||||
|
||||
p= get_memory(strlen(source)+1);
|
||||
if ((q= rindex(source, '/')) == NULL)
|
||||
q= source;
|
||||
else
|
||||
q++; /* point PAST the '/' */
|
||||
(void)strcpy(p, q);
|
||||
if ((q= rindex(p, '.')) != NULL)
|
||||
*q= '\0';
|
||||
append_list(&program.m2cfe.options, "-mod");
|
||||
append_list(&program.m2cfe.options, p);
|
||||
|
||||
program.m2cfe.outfile2= temp_file_name(&program.m2cfe, &suffix.s, 0);
|
||||
|
||||
return NULL;
|
||||
} /* setup_m2cfe_for_non_3x_mod */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* setup_m2cfe_for_3x_mod
|
||||
* Start m2cfe with "-mod" and basename of source filename
|
||||
*/
|
||||
char *setup_m2cfe_for_3x_mod(source)
|
||||
char *source;
|
||||
{
|
||||
register char *p;
|
||||
register char *q;
|
||||
|
||||
p= get_memory(strlen(source)+1);
|
||||
if ((q= rindex(source, '/')) == NULL)
|
||||
q= source;
|
||||
else
|
||||
q++; /* point PAST the '/' */
|
||||
(void)strcpy(p, q);
|
||||
if ((q= rindex(p, '.')) != NULL)
|
||||
*q= '\0';
|
||||
append_list(&program.m2cfe.options, "-mod");
|
||||
append_list(&program.m2cfe.options, p);
|
||||
return NULL;
|
||||
} /* setup_m2cfe_for_3x_mod */
|
||||
|
||||
|
||||
/*
|
||||
* setup_mf1
|
||||
*/
|
||||
char *
|
||||
setup_mf1()
|
||||
{
|
||||
if (!program.mf1.has_been_initialized)
|
||||
{
|
||||
program.mf1.has_been_initialized = TRUE;
|
||||
f1_to_mf1_copy();
|
||||
switch (target_arch.value->value)
|
||||
{
|
||||
case ARCH_SUN2:
|
||||
case ARCH_SUN3X:
|
||||
case ARCH_SUN3:
|
||||
if (is_on(long_offset))
|
||||
append_list(&program.mf1.permanent_options,
|
||||
"-J");
|
||||
if (profile.touched)
|
||||
append_list(&program.mf1.permanent_options,
|
||||
"-p");
|
||||
append_list(&program.mf1.permanent_options,
|
||||
float_mode.value->name);
|
||||
append_list(&program.mf1.permanent_options,
|
||||
get_processor_flag(target_arch.value));
|
||||
break;
|
||||
case ARCH_SUN4C:
|
||||
case ARCH_SUN4:
|
||||
if (profile.touched)
|
||||
append_list(&program.mf1.permanent_options,
|
||||
"-p");
|
||||
break;
|
||||
case ARCH_FOREIGN:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
} /* setup_mf1 */
|
||||
|
||||
/*
|
||||
* setup_as_for_m2c
|
||||
*/
|
||||
char *
|
||||
setup_as_for_m2c(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
{
|
||||
setup_as();
|
||||
append_list(&program.as.infile, file);
|
||||
program.as.outfile= outfile_name(source, &suffix.o, (ProgramP)NULL);
|
||||
return program.as.outfile;
|
||||
|
||||
} /* setup_as_for_m2c */
|
||||
|
||||
|
||||
/*
|
||||
* setup_asS_for_m2c
|
||||
*/
|
||||
char *
|
||||
setup_asS_for_m2c(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
{
|
||||
setup_asS();
|
||||
append_list(&program.asS.infile, file);
|
||||
program.asS.outfile= outfile_name(source, &suffix.s, (ProgramP)NULL);
|
||||
return program.asS.outfile;
|
||||
} /* setup_asS_for_m2c */
|
||||
|
||||
/*
|
||||
* setup_m2l_for_m2c
|
||||
*/
|
||||
char *
|
||||
setup_m2l_for_m2c()
|
||||
{
|
||||
register ListP p;
|
||||
char buffer[LOCAL_STRING_LENGTH];
|
||||
|
||||
if (!program.m2l.has_been_initialized)
|
||||
{
|
||||
program.m2l.has_been_initialized = TRUE;
|
||||
#ifdef sun386
|
||||
append_list(&program.ld.permanent_options, "-Bstatic");
|
||||
#endif sun386
|
||||
for (p= module_list; p != NULL; p= p->next)
|
||||
append_list(&program.m2l.permanent_options, p->value);
|
||||
if (is_off(no_default_module_list))
|
||||
{
|
||||
append_list(&program.m2l.permanent_options, "-M.");
|
||||
if (profile.touched)
|
||||
append_list(&program.m2l.permanent_options,
|
||||
"-M/usr/lib/modula2_p");
|
||||
else
|
||||
append_list(&program.m2l.permanent_options,
|
||||
"-M/usr/lib/modula2");
|
||||
}
|
||||
if (is_on(verbose))
|
||||
append_list(&program.m2l.permanent_options, "-v");
|
||||
if (is_on(trace))
|
||||
append_list(&program.m2l.permanent_options, "-trace");
|
||||
buffer[0] = '-';
|
||||
strcpy(&buffer[1], target_arch.value->extra);
|
||||
append_list(&program.m2l.permanent_options,
|
||||
make_string(buffer));
|
||||
append_list(&program.m2l.permanent_options, "-X");
|
||||
}
|
||||
for (p= program.ld.permanent_options; p != NULL; p= p->next)
|
||||
append_list(&program.m2l.permanent_options, p->value);
|
||||
for (p= program.ld.trailing_options; p != NULL; p= p->next)
|
||||
append_list(&program.m2l.trailing_options, p->value);
|
||||
program.m2l.outfile= (outfile == NULL) ? "a.out" : outfile;
|
||||
for (p= infile; p != NULL; p= p->next)
|
||||
{
|
||||
if (STR_EQUAL("-e", p->value))
|
||||
{
|
||||
p= p->next;
|
||||
continue;
|
||||
}
|
||||
if (STR_EQUAL(program.m2l.outfile, p->value))
|
||||
fatal("Outfile %s would overwrite infile", p->value);
|
||||
}
|
||||
|
||||
/* Add crt0.o routine */
|
||||
append_list(&program.m2l.infile,
|
||||
scan_Qpath_and_vroot(profile.value->extra, TRUE));
|
||||
|
||||
/* Add crt1.o routine */
|
||||
if ( (target_arch.value->value != ARCH_SUN4) &&
|
||||
(target_arch.value->value != ARCH_SUN4C) &&
|
||||
(target_arch.value->value != ARCH_SUN386) &&
|
||||
float_mode.value->extra
|
||||
)
|
||||
{
|
||||
append_list(&program.m2l.infile,
|
||||
scan_Qpath_and_vroot(float_mode.value->extra, TRUE));
|
||||
}
|
||||
|
||||
/* Add bb_link.o routine, if -a is enabled */
|
||||
if (is_on(statement_count))
|
||||
{
|
||||
append_list(&program.m2l.infile,
|
||||
scan_Qpath_and_vroot("/usr/lib/bb_link.o", TRUE));
|
||||
}
|
||||
|
||||
/* Do not append /usr/lib/f... search path if the release is 3x,
|
||||
* or the arch is sun386, sun4, or sun4c
|
||||
*/
|
||||
if ( (target_sw_release[R_PATHS].value->value != SW_REL_3X)
|
||||
&&
|
||||
(target_arch.value->value != ARCH_SUN386)
|
||||
&&
|
||||
(target_arch.value->value != ARCH_SUN4C)
|
||||
&&
|
||||
(target_arch.value->value != ARCH_SUN4) )
|
||||
{
|
||||
/* Add /usr/lib/f... search path for libraries. */
|
||||
(void)sprintf(buffer, "-L/usr/lib/%s",
|
||||
float_mode.value->name+1);
|
||||
append_list(&program.m2l.infile, make_string(buffer));
|
||||
}
|
||||
for (p= infile_o; p != NULL; p= p->next)
|
||||
{
|
||||
append_list(&program.m2l.infile, p->value);
|
||||
}
|
||||
if (debugger.touched)
|
||||
{
|
||||
append_list(&program.m2l.infile, "-lg");
|
||||
}
|
||||
append_list(&program.m2l.infile, profile.touched ? "-lc_p":"-lc");
|
||||
return "";
|
||||
} /* setup_m2l_for_m2c */
|
||||
|
||||
|
||||
static char *to_as_file;
|
||||
|
||||
/*
|
||||
* setup_cat_for_mod
|
||||
* The assembly source from must be combined with the one
|
||||
* from c2.
|
||||
*/
|
||||
char *
|
||||
setup_cat_for_mod(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
{
|
||||
append_list(&program.cat.infile, program.m2cfe.outfile2);
|
||||
append_list(&program.cat.infile, file);
|
||||
|
||||
if (requested_suffix != &suffix.s)
|
||||
{
|
||||
program.cat.outfile = to_as_file =
|
||||
temp_file_name(&program.as, &suffix.s, 0);
|
||||
}
|
||||
|
||||
/* this case is for sun4's with -S and -O */
|
||||
else if ( ( (target_arch.value->value == ARCH_SUN4) ||
|
||||
(target_arch.value->value == ARCH_SUN4C)
|
||||
)
|
||||
&&
|
||||
(optimizer_level > OPTIM_NONE ) )
|
||||
{
|
||||
program.cat.outfile = to_as_file =
|
||||
temp_file_name(&program.as, &suffix.s, 0);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
program.cat.outfile = outfile_name(source, &suffix.s, (ProgramP)NULL);
|
||||
}
|
||||
return program.cat.outfile;
|
||||
|
||||
} /* setup_cat_for_mod */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* m2c_doit
|
||||
*/
|
||||
void
|
||||
m2c_doit()
|
||||
{
|
||||
/* The default is to not run the linker for m2c */
|
||||
if (product.value == &executable)
|
||||
product.value= &object;
|
||||
if (is_on(do_m2l))
|
||||
product.value= &executable;
|
||||
set_requested_suffix(&suffix.none);
|
||||
do_infiles();
|
||||
if (!exit_status && (product.value == &executable))
|
||||
{
|
||||
requested_suffix= &suffix.none;
|
||||
if (source_infile_count > 1)
|
||||
{
|
||||
(void)printf("Linking:\n");
|
||||
}
|
||||
clear_program_options();
|
||||
exit_status|= run_steps("", link_m2c_steps, FALSE, "");
|
||||
if (exit_status != 0)
|
||||
{
|
||||
do_not_unlink_ld_infiles();
|
||||
}
|
||||
}
|
||||
} /* m2c_doit */
|
||||
432
lang/compile/setup_pc.c
Normal file
432
lang/compile/setup_pc.c
Normal file
@@ -0,0 +1,432 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)setup_pc.c 1.1 94/10/31 SMI";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "driver.h"
|
||||
|
||||
/*
|
||||
* compile_pi
|
||||
*/
|
||||
int
|
||||
compile_pi(source)
|
||||
char *source;
|
||||
{
|
||||
int status;
|
||||
|
||||
#ifdef BROWSER
|
||||
global_flag.code_browser = global_flag.code_browser_seen;
|
||||
#endif
|
||||
clear_program_options();
|
||||
|
||||
if (target_sw_release[R_PASSES].value->value == SW_REL_3X)
|
||||
{
|
||||
return run_steps(source, p_rel3x_steps, TRUE, "p");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (requested_suffix == &suffix.s) ||
|
||||
(target_arch.value->value == ARCH_SUN386) )
|
||||
{
|
||||
set_flag(do_cat);
|
||||
}
|
||||
|
||||
if (optimizer_level > OPTIM_C2 || is_on(statement_count))
|
||||
{
|
||||
status= run_steps(source, p_iropt_steps, TRUE, "p");
|
||||
}
|
||||
else status= run_steps(source, p_no_iropt_steps, TRUE, "p");
|
||||
|
||||
reset_flag(do_cat);
|
||||
#ifdef BROWSER
|
||||
reset_flag(code_browser);
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
} /* compile_pi */
|
||||
|
||||
|
||||
#ifdef PASCAL_105
|
||||
Bool special_pascal_105_case = FALSE;
|
||||
#endif /*PASCAL_105*/
|
||||
|
||||
/*
|
||||
* compile_p
|
||||
*/
|
||||
int
|
||||
compile_p(source)
|
||||
char *source;
|
||||
{
|
||||
int status;
|
||||
|
||||
#ifdef PASCAL_105
|
||||
extern Const_intP original_sw_rel_passes;
|
||||
static Const_intP saved_sw_rel_passes;
|
||||
static char *saved_iropt_path;
|
||||
|
||||
/* Special-case for Pascal 1.05 for Sun-4 target:
|
||||
* treat it as if the compiler passes were 4.0 passes,
|
||||
* except must use regular 3.x linker pass & flags.
|
||||
* (All of which is overridden if -release or -relpasses was used)
|
||||
*/
|
||||
if ( ( (target_arch.value->value == ARCH_SUN4) ||
|
||||
(target_arch.value->value == ARCH_SUN4C)
|
||||
)
|
||||
&&
|
||||
(original_sw_rel_passes->value == SW_REL_DFLT) )
|
||||
{
|
||||
special_pascal_105_case = TRUE;
|
||||
saved_sw_rel_passes = target_sw_release[R_PASSES].value;
|
||||
target_sw_release[R_PASSES].value = &sw_release_40_explicit;
|
||||
saved_iropt_path = program.iropt_pc.path;
|
||||
program.iropt_pc.path = "/usr/lib/iropt-pc";
|
||||
}
|
||||
#endif /*PASCAL_105*/
|
||||
|
||||
set_flag(do_cpp);
|
||||
status= compile_pi(source);
|
||||
reset_flag(do_cpp);
|
||||
|
||||
#ifdef PASCAL_105
|
||||
if ( special_pascal_105_case )
|
||||
{
|
||||
program.iropt_pc.path = saved_iropt_path;
|
||||
target_sw_release[R_PASSES].value = saved_sw_rel_passes;
|
||||
special_pascal_105_case = FALSE;
|
||||
}
|
||||
#endif /*PASCAL_105*/
|
||||
|
||||
return status;
|
||||
} /* compile_p */
|
||||
|
||||
|
||||
/*
|
||||
* setup_pc0_for_3x
|
||||
* 3.x pc0 has different arguments from 4.0 pc0, therefore the
|
||||
* argument template has to be changed.
|
||||
*/
|
||||
char *
|
||||
setup_pc0_for_3x(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
{
|
||||
register int i;
|
||||
static Template pc0_3x_template[PGM_TEMPLATE_LENGTH] =
|
||||
{ MINUS_O_TEMPLATE, OUT_TEMPLATE, OPTION_TEMPLATE, IN_TEMPLATE};
|
||||
|
||||
(void)setup_pc0();
|
||||
|
||||
for (i = 0; i < PGM_TEMPLATE_LENGTH; i++)
|
||||
{
|
||||
program.pc0.template[i] = pc0_3x_template[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
} /* setup_pc0_for_3x */
|
||||
|
||||
|
||||
/*
|
||||
* setup_pc0_for_non_3x
|
||||
* The post-3.x pc0 produces two outfiles;
|
||||
* one iropt file (containing IR for the Text segment)
|
||||
* and one assembly file (containing the Data segment).
|
||||
*/
|
||||
char *
|
||||
setup_pc0_for_non_3x(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
{
|
||||
(void)setup_pc0();
|
||||
append_list(&program.pc0.infile, file);
|
||||
/* program.pc0.outfile is referenced in setup_as_for_pc(), to get the
|
||||
* name of the extra infile.
|
||||
*/
|
||||
program.pc0.outfile= temp_file_name(&program.pc0, &suffix.s, 0);
|
||||
append_list(&program.pc0.options,
|
||||
source= temp_file_name(&program.pc0, &suffix.ir, 0));
|
||||
|
||||
return source;
|
||||
} /* setup_pc0_for_iropt */
|
||||
|
||||
|
||||
/*
|
||||
* setup_pc0
|
||||
*/
|
||||
char *
|
||||
setup_pc0()
|
||||
{
|
||||
char buffer[LOCAL_STRING_LENGTH];
|
||||
|
||||
if (!program.pc0.has_been_initialized)
|
||||
{
|
||||
program.pc0.has_been_initialized = TRUE;
|
||||
if (optimizer_level > OPTIM_NONE)
|
||||
{
|
||||
if (target_sw_release[R_PASSES].value->value
|
||||
== SW_REL_3X)
|
||||
{
|
||||
append_list(&program.pc0.permanent_options,
|
||||
"-O");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* a 4.x target release */
|
||||
(void)sprintf(buffer, "-O%c", optimizer_level);
|
||||
append_list(&program.pc0.permanent_options,
|
||||
make_string(buffer));
|
||||
}
|
||||
}
|
||||
if (is_on(warning))
|
||||
append_list(&program.pc0.permanent_options, "-w");
|
||||
if (is_on(checkC))
|
||||
append_list(&program.pc0.permanent_options, "-C");
|
||||
if (is_on(checkH))
|
||||
append_list(&program.pc0.permanent_options, "-H");
|
||||
if (is_on(checkV))
|
||||
append_list(&program.pc0.permanent_options, "-V");
|
||||
if (debugger.value)
|
||||
append_list(&program.pc0.permanent_options, "-g");
|
||||
if ( is_on(handle_misalignment) &&
|
||||
(optimizer_level < OPTIM_IROPT_P) )
|
||||
{
|
||||
append_list(&program.pc0.permanent_options, "-m");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BROWSER
|
||||
if (is_on(code_browser)) {
|
||||
append_list(&program.pc0.infile, "-cb");
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
} /* setup_pc0 */
|
||||
|
||||
/*
|
||||
*
|
||||
* setup_cppas
|
||||
*
|
||||
*/
|
||||
char *
|
||||
setup_cppas(original_source, source)
|
||||
char *original_source;
|
||||
char *source;
|
||||
|
||||
{
|
||||
/* we are reaching new heights in hacking
|
||||
* we need to copy cpp options to cppas
|
||||
* because we can't have a -I option for bot
|
||||
* cpp and cppas
|
||||
*/
|
||||
program.cppas.permanent_options = program.cpp.permanent_options;
|
||||
program.cppas.trailing_options = program.cpp.trailing_options;
|
||||
|
||||
|
||||
return NULL;
|
||||
|
||||
} /* setup_cppas */
|
||||
|
||||
|
||||
/*
|
||||
* setup_inline_for_pc
|
||||
* Make sure inline runs with the proper .il file for Pascal.
|
||||
*/
|
||||
char *
|
||||
setup_inline_for_pc()
|
||||
{
|
||||
setup_inline();
|
||||
append_list(&program.inline.options, "-i");
|
||||
append_list(&program.inline.options,
|
||||
scan_Qpath_and_vroot("/usr/lib/pc2.il",TRUE));
|
||||
return NULL;
|
||||
} /* setup_inline_for_pc */
|
||||
|
||||
|
||||
static char *to_as_file;
|
||||
|
||||
/*
|
||||
* setup_cat_for_pc
|
||||
* This is used when "pc -O3 -S" has been given.
|
||||
* The assembly source from pc0 must be combined with the one
|
||||
* from c2.
|
||||
*/
|
||||
char *
|
||||
setup_cat_for_pc(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
{
|
||||
append_list(&program.cat.infile, program.pc0.outfile);
|
||||
append_list(&program.cat.infile, file);
|
||||
|
||||
if (target_arch.value->value == ARCH_SUN386)
|
||||
{
|
||||
if ( (requested_suffix == &suffix.s)
|
||||
&&
|
||||
(optimizer_level == OPTIM_NONE))
|
||||
{
|
||||
program.cat.outfile = to_as_file =
|
||||
outfile_name(source, &suffix.s, (ProgramP)NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
program.cat.outfile = to_as_file =
|
||||
temp_file_name(&program.as, &suffix.s, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
program.cat.outfile = outfile_name(source, &suffix.s, (ProgramP)NULL);
|
||||
}
|
||||
|
||||
return program.cat.outfile;
|
||||
} /* setup_cat_for_pc */
|
||||
|
||||
/*
|
||||
* setup_as_for_pc
|
||||
* This is used to feed "as" the infiles from both pc0 and c2,
|
||||
* when iropt is used.
|
||||
*
|
||||
* Also used for sun386 .. whose "as" does not take more than
|
||||
* one input file.
|
||||
*/
|
||||
char *
|
||||
setup_as_for_pc(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
{
|
||||
(void)setup_as();
|
||||
|
||||
if (target_arch.value->value == ARCH_SUN386)
|
||||
{
|
||||
append_list(&program.as.infile, to_as_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (target_sw_release[R_PASSES].value->value == SW_REL_3X)
|
||||
{
|
||||
if ( (optimizer_level > OPTIM_C2) ||
|
||||
is_on(statement_count))
|
||||
{
|
||||
append_list(&program.as.infile,
|
||||
program.pc0.outfile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* a 4.x target release */
|
||||
append_list(&program.as.infile, program.pc0.outfile);
|
||||
}
|
||||
|
||||
append_list(&program.as.infile, file);
|
||||
}
|
||||
|
||||
program.as.outfile= outfile_name(source, &suffix.o, (ProgramP)NULL);
|
||||
if ((source_infile_count == 1) && (product.value == &executable))
|
||||
append_list(&files_to_unlink, make_string(program.as.outfile));
|
||||
|
||||
return program.as.outfile;
|
||||
} /* setup_as_for_pc */
|
||||
|
||||
/*
|
||||
* setup_asS_for_pc
|
||||
*/
|
||||
char *
|
||||
setup_asS_for_pc(source, file)
|
||||
char *source;
|
||||
char *file;
|
||||
{
|
||||
setup_asS();
|
||||
if (target_sw_release[R_PASSES].value->value == SW_REL_3X)
|
||||
{
|
||||
if ( (optimizer_level > OPTIM_C2) || is_on(statement_count))
|
||||
append_list(&program.asS.infile, program.pc0.outfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* a 4.x target release */
|
||||
append_list(&program.asS.infile, program.pc0.outfile);
|
||||
}
|
||||
|
||||
append_list(&program.asS.infile, file);
|
||||
program.asS.outfile= outfile_name(source, &suffix.s, (ProgramP)NULL);
|
||||
return program.asS.outfile;
|
||||
} /* setup_asS_for_pc */
|
||||
|
||||
/*
|
||||
* setup_pc3
|
||||
*/
|
||||
char *
|
||||
setup_pc3()
|
||||
{
|
||||
register ListP p;
|
||||
|
||||
if (!program.pc3.has_been_initialized)
|
||||
{
|
||||
program.pc3.has_been_initialized = TRUE;
|
||||
if (is_on(warning))
|
||||
append_list(&program.pc3.permanent_options, "-w");
|
||||
append_list(&program.pc3.permanent_options,
|
||||
scan_Qpath_and_vroot("/usr/lib/pcexterns.o", TRUE));
|
||||
}
|
||||
for (p= infile_o; p != NULL; p= p->next)
|
||||
{
|
||||
/* lets not append any -X options
|
||||
* there are certain cases where the infiles
|
||||
* do begin with -X (i.e. -Bxxxx )
|
||||
* pc3 should only have only true input files
|
||||
*/
|
||||
if (*p->value != '-')
|
||||
{
|
||||
append_list(&program.pc3.infile, p->value);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
} /* setup_pc3 */
|
||||
|
||||
/*
|
||||
* setup_ld_for_pc
|
||||
*/
|
||||
char *
|
||||
setup_ld_for_pc()
|
||||
{
|
||||
static char *libraries[] =
|
||||
{ "-lpc", "-lm", "-lc", NULL };
|
||||
static char *profiled_libraries[] =
|
||||
{ "-lpc_p", "-lm_p", "-lc_p", NULL };
|
||||
|
||||
#ifdef i386
|
||||
append_list(&program.ld.permanent_options, "-Bstatic");
|
||||
#endif i386
|
||||
|
||||
setup_ld( (char **)NULL, libraries, profiled_libraries );
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/*
|
||||
* pc_doit
|
||||
*/
|
||||
void
|
||||
pc_doit()
|
||||
{
|
||||
set_requested_suffix(&suffix.pi);
|
||||
do_infiles();
|
||||
if ((exit_status == 0) && (product.value == &executable) &&
|
||||
(infile_o != NULL))
|
||||
{
|
||||
requested_suffix= &suffix.none;
|
||||
if (source_infile_count > 1)
|
||||
{
|
||||
(void)printf("Linking:\n");
|
||||
}
|
||||
clear_program_options();
|
||||
exit_status|= run_steps("", pc_steps, FALSE, "");
|
||||
if (exit_status != 0)
|
||||
{
|
||||
do_not_unlink_ld_infiles();
|
||||
}
|
||||
}
|
||||
} /* pc_doit */
|
||||
Reference in New Issue
Block a user