usr/src/cmd/perl/5.6.1/distrib/Makefile
author wesolows
Tue, 20 Sep 2005 15:07:36 -0700
changeset 580 70dfd36fd02c
parent 0 68f95e015346
child 1717 ef845d4a1074
permissions -rw-r--r--
6237094 perl build should honor $(CC) 6272179 relocation processing should be bypassed when building libgenunix et al 6307198 Need to pass in -save_args option when the new gcc is available 6310495 gcc and sun4 rootnex don't get along 6310534 new gcc options should be used to build ON 6319181 cw needs -xbuiltin support

#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# ident	"%Z%%M%	%I%	%E% SMI"
#

#
# The perl5 installation for Solaris differs from that generated by the
# Perl Configure procedure.  The configuration appropriate for the current
# build is automatically generated from pre-existing configuration files
# for the build platform.
#

PROG = perl

#
# Some  of the Makefile.master and Makefile.cmd flags are overridden by
# ../Makefile.perlcfg which is in turn generated from config.sh by
# ../extract_config.sh - check there first before overriding anything in this
# Makefile.
#
include ../../../Makefile.cmd
include ../Makefile.perlcfg

# DynaLoader is a special extension as it has to be built statically.
DYNALOADER=lib/auto/DynaLoader/DynaLoader.a

# Because autosplit generates a lot of files, we create a dummy timestamp file
# so that dependency checking can be performed.
AUTOSPLIT = lib/auto/.tstamp

CLEANFILES = miniperlmain.o perlmain.o opmini.o perlmain.c writemain cflags \
    ext.libs

CLOBBERFILES = $(MINIPERL) $(PROG) $(PERL_CONFIGDEP) libperl.so lib/re.pm \
    lib/ExtUtils/Miniperl.pm  t/perl
clobber := CLOBBERFILES += CLEANFILES

# Add in the perl-specific flags (including largefile flags).
CPPFLAGS += $(PERL_COREFLAGS) $(PERL_LFFLAGS)

# Add in the libraries perl needs to be linked against.
LDLIBS += $(PERL_LDLIBS)

# Compiler replacement rules
SED_UN_CC =	-e "s!'$(CC)!'cc!"
SED_UN_CC_E =	-e "s!'$(REAL_CC)!'cc!"

all :=		TARGET = all
install :=	TARGET = install
clobber :=	TARGET = clobber
clean :=	TARGET = clean
test :=		TARGET = test

all: perl extensions utilities

#
# Expand template files that depend on config.sh.
#

$(PERL_CONFIG_H): config_h.SH config.sh
	$(CHMOD) 0555 config_h.SH
	./config_h.SH

perlmain.c: writemain $(PERL_CONFIG_H)
	./writemain $(DYNALOADER) > perlmain.c

writemain: writemain.SH $(PERL_CONFIG_H)
	$(CHMOD) 0555 writemain.SH
	./writemain.SH

#
# Build the libperl.so and libperl.so.1 shared objects using Makefile.lib,
# which uses the correct library build environment.
#

libperl.so: $(PERL_CONFIG_H) FRC
	@ $(ECHO) "Building libperl.so"; $(MAKE) -f Makefile.lib $(TARGET)

#
# Build miniperl, the bootstrap perl executable, and check it executes OK.
#
$(MINIPERL): miniperlmain.o opmini.o libperl.so
	$(LINK.c) -o $@ miniperlmain.o opmini.o \
	    -R \$$ORIGIN -L. -lperl $(LDLIBS)
	@ $(MINIPERL) -w -Ilib -MExporter -e 'exit(0);' || \
	    { $(ECHO) "error building miniperl"; $(RM) $(MINIPERL); exit 2; }

miniperlmain.o: miniperlmain.c $(PERL_CONFIG_H)

#
# opmini.o is a version of op.o compiled with -DPERL_EXTERNAL_GLOB.  Perl has
# an internal implementation of glob, but it isn't available at this point.
#
opmini.o: op.c $(PERL_CONFIG_H)
	$(COMPILE.c) -o $@ op.c -DPERL_EXTERNAL_GLOB
	$(POST_PROCESS_O)

.PARALLEL: miniperlmain.o opmini.o libperl.so

#
# Prepare for building perl modules by:
#   * Building miniperl.
#   * Copying re.pm from ext/re into lib.
#   * Creating Config.pm from config.sh.
#   * Autosplitting any ./lib modules that require it.
#   * Creating a fake cflags file.  ExtUtils::MM_Unix (used to build extensions)
#     checks to see if there is a non-zero sized file called 'cflags' in this
#     directory, so we fool it by creating one.
#

preplibrary: $(MINIPERL) $(PERL_CONFIG_PM) lib/ExtUtils/Miniperl.pm cflags \
    $(AUTOSPLIT)

$(PERL_CONFIG_PM): configpm $(PERL_CONFIG_H) myconfig.SH $(MINIPERL) lib/re.pm
	$(MINIPERL) configpm $@

lib/re.pm : ext/re/re.pm
	$(CP) -f ext/re/re.pm $@

lib/ExtUtils/Miniperl.pm: $(PERL_CONFIGDEP) $(MINIPERL) \
    miniperlmain.c minimod.pl
	$(MINIPERL) minimod.pl > minimod.tmp
	$(MV) minimod.tmp $@

# Note: cflags needs to be non-zero sized, so $(TOUCH) won't do.
cflags:
	$(ECHO) > cflags

.PARALLEL: $(PERL_CONFIGDEP) lib/re.pm lib/ExtUtils/Miniperl.pm \
    cflags $(AUTOSPLIT)

# Because autosplit generates a lot of files, we create a dummy timestamp file
$(AUTOSPLIT): $(PERL_CONFIGDEP)
	@ $(MKDIR) -p lib/auto
	$(MINIPERL) -Ilib -MAutoSplit -e 'autosplit_lib_modules(@ARGV)' \
	    `find lib -name SCCS -prune -o -name '*.pm' -print`
	@ $(TOUCH) $(AUTOSPLIT)

#
# Make DynaLoader.  DynaLoader is statically linked into the perl executable
# because it is used to load in all the other dynamically loaded modules.
# Note: VERSION is used by ON as a environment variable and by perl module
# makefiles as a make macro, so we need to unset it before building any modules.
#

ext/DynaLoader/Makefile: ext/DynaLoader/Makefile.PL $(PERL_CONFIGDEP) cflags
	@ cd ext/DynaLoader; pwd; $(PERL_MM_ENV); \
	$(MINIPERL) Makefile.PL INSTALLDIRS=perl \
	    LIBPERL_A=libperl.so $(PERL_MM_ARGS)

$(DYNALOADER): ext/DynaLoader/Makefile $(PERL_CONFIGDEP) cflags FRC
	@ cd ext/DynaLoader; pwd; $(PERL_MM_ENV); \
	$(MAKE) LINKTYPE=static CCCDLFLAGS=

#
# Create the perl executable.
#

perl: libperl.so $(DYNALOADER) $(PERL_STATIC_TGT) perlmain.o
	$(LINK.c) -R$(PERL_REAL_CORE_DIR) -o $@ perlmain.o $(DYNALOADER) \
	    -L. -lperl $(LDLIBS)
	$(POST_PROCESS)

perlmain.o: perlmain.c $(PERL_CONFIG_H)
	$(COMPILE.c) -o $@ $<
	$(POST_PROCESS_O)

.PARALLEL: perlmain.o

#
# Build all the extensions.  The rules for this are in the generated
# ext/Makefile file.
#

extensions: preplibrary FRC
	@ cd ext; pwd; $(MAKE) $(TARGET)

#
# Build utilities and pod pages.
#

utilities: perl FRC
	@ cd x2p; pwd; $(MAKE) $(TARGET)
	@ cd pod; pwd; $(MAKE) $(TARGET)
	@ cd utils; pwd; $(MAKE) $(TARGET)

#
# Install targets.  The bin, lib and pod symlinks are created here.  The man
# link is created by the SUNWpl5m package.  Also we overwrite the Config.pm we
# used to build our modules with one sanitized of the /ws/on*-tools dependency.
#
install_files:
	$(RM) $(PERL_CORE_DIR)/libperl.so
	@ LD_LIBRARY_PATH=$(PERL_DISTRIB) $(PERL_DISTRIB)/perl ./installperl
	@ $(MAKE) -f Makefile.lib install_lib

	umask 022; $(MKDIR) -p $(PERL_VENDOR_DIR)

	$(RM) $(PERL_ARCHLIB_DIR)/Config.pm
	$(SED) $(SED_UN_CC) $(SED_UN_CC_E) $(PERL_CONFIG_PM) \
	    > $(PERL_ARCHLIB_DIR)/Config.pm
	$(CHMOD) 444 $(PERL_ARCHLIB_DIR)/Config.pm

	@ $(CHOWN) -R $(OWNER):$(GROUP) $(PERL_ROOT_STEM) 

install: all .WAIT install_files

#
# Perl test suite target.
#

test: all
	@ unset VERSION; \
	LD_LIBRARY_PATH=$(PERL_DISTRIB) export LD_LIBRARY_PATH; \
	PERL5LIB=../lib; export PERL5LIB; \
	cd t; pwd; \
	$(CP) ../perl .; \
	$(CHMOD) 755 TEST; \
	./TEST

#
# Cleaning targets.
#

clean_pod:
	@ cd pod; pwd; $(MAKE) clean

clean_utilities:
	@ cd utils; pwd; $(MAKE) clean

clean_x2p:
	@ cd x2p; pwd; $(MAKE) clean

clean_extensions:
	-@ unset VERSION; \
	cd ext; pwd; \
	( \
	cd DynaLoader; \
	[ -f Makefile.old ] && mf=Makefile.old; \
	[ -f Makefile ] && mf=Makefile; \
	[ ! -z "$$mf" ] && $(MAKE) -f $$mf clean; \
	); \
	$(MAKE) clean

clean_lib:
	$(MAKE) -f Makefile.lib clean

clean: clean_pod clean_utilities clean_x2p clean_extensions clean_lib 
	$(RM) $(CLEANFILES)

#
# Clobber targets
#

clobber_extensions:
	-@ unset VERSION; \
	cd ext; pwd; \
	( \
	cd DynaLoader; \
	[ -f Makefile.old ] && mf=Makefile.old; \
	[ -f Makefile ] && mf=Makefile; \
	[ ! -z "$$mf" ] && $(MAKE) -f $$mf realclean; \
	); \
	$(MAKE) clobber

clobber_lib:
	$(MAKE) -f Makefile.lib $(TARGET)
	$(RM) -r lib/auto
	$(RM) `find ./lib -name .exists`

clobber_pod:
	@ cd pod; pwd; $(MAKE) $(TARGET)

clobber_utilities:
	@ cd utils; pwd; $(MAKE) $(TARGET)

clobber_x2p:
	@ cd x2p; pwd; $(MAKE) $(TARGET)

clobber_contrib_bin:
	@ $(RM) -r contrib_bin

clobber: clobber_extensions clobber_lib clobber_pod clobber_utilities \
    clobber_x2p clobber_contrib_bin

include ../../../Makefile.targ

FRC: