usr/src/cmd/emacs/Makefile.sfw
author Cyril Plisko <cyril.plisko@grigale.com>
Tue, 06 Apr 2010 16:00:14 +0300
changeset 11 87960ed158f9
parent 2 8f1801a322e9
permissions -rw-r--r--
Import sfw build 137 Bugs Fixed ---------- 6926835 Wireshark cannot open files typed into the location bar 6930214 CVE-2010-0624: Heap-based buffer overflow in GNU Tar 6933424 Various sfw manual pages need to be adjusted to use the new OpenSolaris package names. 6937764 upgrade OpenSSL to 0.9.8n (and fix CVE-2010-0740)

#
#
# 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 2010 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# ident	"@(#)Makefile.sfw	1.4	10/03/16 SMI"

VER=23.1
EMACSDIST=emacs-$(VER)

include ../Makefile.cmd

# Strategy:
# We need to build emacs multiple times, for 32/64-bit, and for
# the different toolkit variants. Rather than make multiple copies
# of the unpacked emacs source tree, we reuse a single tree, copying
# out the parts we want after each build.
#
# We copy these files into a local proto directory, rather than
# putting them into the real proto directly, for two reasons:
#	1) Files should not go into the proto unless "make install"
#		is used.
#	2) An emacs distribution has lots of files. A local proto
#		allows us to examine these files in isolation
#		before they get mixed into the real proto, and is
#		thus an aid to debugging and packaging.
#

# Paths to proto/usr/bin and its subdirectories
PBIN=		proto/usr/bin
PBIN32=		$(PBIN)/$(MACH32)
PBIN64=		$(PBIN)/$(MACH64)
PSHAREMAN1=	proto/usr/share/man/man1

# Paths to proto/usr/gnu
PGBIN=		proto/usr/gnu/bin
PGSHAREMAN1=	proto/usr/gnu/share/man/man1

MANPAGES=	$(PSHAREMAN1)/b2m.1 \
		$(PSHAREMAN1)/ebrowse.1 \
		$(PSHAREMAN1)/emacs.1 \
		$(PSHAREMAN1)/emacs-gtk.1 \
		$(PSHAREMAN1)/emacs-nox.1 \
		$(PSHAREMAN1)/emacs-x.1 \
		$(PSHAREMAN1)/emacsclient.1 \
		$(PSHAREMAN1)/grep-changelog.1 \
		$(PSHAREMAN1)/rcs-checkin.1 \
		$(PSHAREMAN1)/emacsclient.1 \
		$(PGSHAREMAN1)/ctags.1 \
		$(PGSHAREMAN1)/etags.1

# The various toolkit permutations
EMACS_X=	$(PBIN)/emacs-x		$(PBIN)/emacs-x-$(VER) \
		$(PBIN32)/emacs-x	$(PBIN32)/emacs-x-$(VER) \
		$(PBIN64)/emacs-x	$(PBIN64)/emacs-x-$(VER)

EMACS_NOX=	$(PBIN)/emacs-nox	$(PBIN)/emacs-nox-$(VER) \
		$(PBIN32)/emacs-nox	$(PBIN32)/emacs-nox-$(VER) \
		$(PBIN64)/emacs-nox	$(PBIN64)/emacs-nox-$(VER)

EMACS_GTK=	$(PBIN)/emacs-gtk	$(PBIN)/emacs-gtk-$(VER) \
		$(PBIN32)/emacs-gtk	$(PBIN32)/emacs-gtk-$(VER) \
		$(PBIN64)/emacs-gtk	$(PBIN64)/emacs-gtk-$(VER)

# On X86, the machine types differ (i386-pc and x86_64-pc). We want
# to share the 32-bit architecture specific binaries in both cases,
# so we install the i386-pc version, and use a symlink to make the
# amd64 version see them. The name of the 32-bit version will be
# something like i386-pc-solaris2.11, where the 2.11 is tied
# to the output from 'uname -r'. So use uname to get the value, so
# that we might handle a transition from Nevada (5.11) to the next thing.
#
LIBDIR=proto/usr/lib/emacs/$(VER)
SOL_REV:sh=uname -r | sed "s,^5\.,2\.,"
LIBDIRSYMLINK:sh=	if [ "$MACH" = 'i386' ]; \
	then echo  '$(LIBDIR)/x86_64-pc-solaris$(SOL_REV)'; \
	fi

all: $(EMACS_X) .WAIT $(EMACS_NOX) .WAIT $(EMACS_GTK) .WAIT \
	$(PBIN)/emacs .WAIT $(MANPAGES) $(LIBDIRSYMLINK)

install: all
	$(SH) install-sfw

# LPROTO is a fully qualified path to the proto subdirectory.
# It is needed for the emacs makefile install rule.
#
LPROTO:sh=	echo `pwd`/proto

# Uncomment this for debugging only. It configures emacs to
# run from the local proto instead of from its final installed
# location
# 
##INSTALL_ROOT=$(LPROTO)

# Execute the build_emacs script with an appropriate environment
BUILD_EMACS=	env GCC="$(GCC)" PATH=$(SFW_PATH) sh -x tools/build_emacs


# Build the base 32-bit emacs-x, and install it along with the rest of
# the emacs distribution into the local proto area. We use the emacs
# makefile install rule to do this, as discussed in README.SUNWgnu-emacs.
#
# Note that we put usr/src/tools at the head of the PATH. This is done
# in order to ensure that the emacs install uses the no-op links
# to /bin/true for chown and chgrp. We don't need the file ownerships
# to change, and we don't have a 'games' user.
#
# Once the emacs install is finished, we then tweak the results:
#	- Change 'emacs' to $(MACH)/emacs-x
#	- Put ctags/etags into usr/gnu/bin instead of usr/bin
#	- Throw away the manpages that were installed. We will
#	  generate them again, using sed to bolt on an ATTRIBUTES section
#
$(PBIN32)/emacs-x : $(PBIN32) $(PGBIN) $(PGSHAREMAN1)
	rm -f $(PBIN)/emacs	# emacs install will clobber this
	$(BUILD_EMACS) 32 lucid $(INSTALL_ROOT)
	(cd $(EMACSDIST); env prefix=$(LPROTO) bindir=$(LPROTO)/usr/bin \
	    datarootdir=$(LPROTO)/usr/share \
	    libexecdir=$(LPROTO)/usr/lib \
	    INSTALL=ginstall \
	    MAKE=$(GMAKE) \
	    PATH="$${SRC}/tools:$(SFW_PATH)" \
	    $(GMAKE) install)
	mv $(PBIN)/emacs $(PBIN32)/emacs-x
	mv $(PBIN)/emacs-$(VER) $(PBIN32)/emacs-x-$(VER)
	mv $(PBIN)/ctags $(PBIN)/etags $(PGBIN)
	rm $(PSHAREMAN1)/*



# For the other 5 variants, we do the build with the necessary
# configuration, and then take only the emacs binary. These binaries
# will operate with the files produced by the base 32-bit build.

$(PBIN64)/emacs-x: $(PBIN64)
	$(BUILD_EMACS) 64 lucid $(INSTALL_ROOT)
	cp $(EMACSDIST)/src/emacs $(PBIN64)/emacs-x
	ln -f $(PBIN64)/emacs-x $(PBIN64)/emacs-x-$(VER)

$(PBIN32)/emacs-nox: $(PBIN32)
	$(BUILD_EMACS) 32 nox $(INSTALL_ROOT)
	cp $(EMACSDIST)/src/emacs $(PBIN32)/emacs-nox
	ln -f $(PBIN32)/emacs-nox $(PBIN32)/emacs-nox-$(VER)

$(PBIN64)/emacs-nox: $(PBIN64)
	$(BUILD_EMACS) 64 nox $(INSTALL_ROOT)
	cp $(EMACSDIST)/src/emacs $(PBIN64)/emacs-nox
	ln -f $(PBIN64)/emacs-nox $(PBIN64)/emacs-nox-$(VER)

$(PBIN32)/emacs-gtk: $(PBIN32)
	$(BUILD_EMACS) 32 gtk $(INSTALL_ROOT)
	cp $(EMACSDIST)/src/emacs $(PBIN32)/emacs-gtk
	ln -f $(PBIN32)/emacs-gtk $(PBIN32)/emacs-gtk-$(VER)

$(PBIN64)/emacs-gtk: $(PBIN64)
	$(BUILD_EMACS) 64 gtk $(INSTALL_ROOT)
	cp $(EMACSDIST)/src/emacs $(PBIN64)/emacs-gtk
	ln -f $(PBIN64)/emacs-gtk $(PBIN64)/emacs-gtk-$(VER)


# Rules to copy emacs manpages into the local proto, adding the
# Sun-specific attribute information. Some go in usr/share/man, others
# in usr/gnu/share/man
#
# ctags is a special case that should not go through sunman.pl.
# It simply inlines etags.1.
#
$(PGSHAREMAN1)/ctags.1: $(EMACSDIST)/doc/man/ctags.1
	cp $(EMACSDIST)/doc/man/ctags.1 $(PGSHAREMAN1)/ctags.1

$(PSHAREMAN1)/% $(PGSHAREMAN1)/%: $(EMACSDIST)/doc/man/%
	perl tools/sunman.pl editor/gnu-emacs < $< > $@

# Manpages lacking from the emacs distribution that we supply
#
# The emacs binaries come in their own packages
# 
$(PSHAREMAN1)/emacs-x.1: augment/man/man1/emacs-x.1
	perl tools/sunman.pl editor/gnu-emacs/gnu-emacs-x11 \
		< augment/man/man1/emacs-x.1 > $(PSHAREMAN1)/emacs-x.1

$(PSHAREMAN1)/emacs-nox.1: augment/man/man1/emacs-nox.1
	perl tools/sunman.pl editor/gnu-emacs/gnu-emacs-no-x11 \
		< augment/man/man1/emacs-nox.1 > $(PSHAREMAN1)/emacs-nox.1

$(PSHAREMAN1)/emacs-gtk.1: augment/man/man1/emacs-gtk.1
	perl tools/sunman.pl editor/gnu-emacs/gnu-emacs-gtk \
		< augment/man/man1/emacs-gtk.1 > $(PSHAREMAN1)/emacs-gtk.1

$(PSHAREMAN1)/%: augment/man/man1/%
	perl tools/sunman.pl editor/gnu-emacs < $< > $@


$(LIBDIRSYMLINK): $(LIBDIR)
	(cd $(LIBDIR); \
		ln -s i386-pc-solaris$(SOL_REV) x86_64-pc-solaris$(SOL_REV));

# Subdirectores we need to create within the local proto area
proto $(PBIN) $(PBIN32) $(PBIN64) $(PGBIN) $(PGSHAREMAN1) \
		proto/usr/lib $(LIBDIR) :
	mkdir -p $@

# The emacs files in PBIN are all links to /usr/lib/isaexec.
# Use a copy of the system version in our local proto so we have
# a file to link against. This file is not delivered to the real proto
#
proto/usr/lib/isaexec: proto/usr/lib
	cp /usr/lib/isaexec proto/usr/lib

$(PBIN)/emacs-x		$(PBIN)/emacs-x-$(VER) \
$(PBIN)/emacs-nox	$(PBIN)/emacs-nox-$(VER) \
$(PBIN)/emacs-gtk	$(PBIN)/emacs-gtk-$(VER) : $(PBIN) proto/usr/lib/isaexec
	ln proto/usr/lib/isaexec $@

# proto/usr/bin/emacs is a shell script that decides which binary
# to exec at runtime.
#
$(PBIN)/emacs: augment/emacs
	rm -f $(PBIN)/emacs
	cp augment/emacs $(PBIN)
	chmod +x $(PBIN)/emacs

test:	# there aren't any

clean:
	-rm -rf $(EMACSDIST) proto

include ../Makefile.targ

FRC: