Home | History | Annotate | Download | only in emacs
      1 #
      2 #
      3 # CDDL HEADER START
      4 #
      5 # The contents of this file are subject to the terms of the
      6 # Common Development and Distribution License (the "License").
      7 # You may not use this file except in compliance with the License.
      8 #
      9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10 # or http://www.opensolaris.org/os/licensing.
     11 # See the License for the specific language governing permissions
     12 # and limitations under the License.
     13 #
     14 # When distributing Covered Code, include this CDDL HEADER in each
     15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16 # If applicable, add the following below this CDDL HEADER, with the
     17 # fields enclosed by brackets "[]" replaced with your own identifying
     18 # information: Portions Copyright [yyyy] [name of copyright owner]
     19 #
     20 # CDDL HEADER END
     21 #
     22 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     23 # Use is subject to license terms.
     24 #
     25 # ident	"@(#)Makefile.sfw	1.3	09/10/29 SMI"
     26 
     27 VER=23.1
     28 EMACSDIST=emacs-$(VER)
     29 
     30 include ../Makefile.cmd
     31 
     32 # Strategy:
     33 # We need to build emacs multiple times, for 32/64-bit, and for
     34 # the different toolkit variants. Rather than make multiple copies
     35 # of the unpacked emacs source tree, we reuse a single tree, copying
     36 # out the parts we want after each build.
     37 #
     38 # We copy these files into a local proto directory, rather than
     39 # putting them into the real proto directly, for two reasons:
     40 #	1) Files should not go into the proto unless "make install"
     41 #		is used.
     42 #	2) An emacs distribution has lots of files. A local proto
     43 #		allows us to examine these files in isolation
     44 #		before they get mixed into the real proto, and is
     45 #		thus an aid to debugging and packaging.
     46 #
     47 
     48 # Paths to proto/usr/bin and its subdirectories
     49 PBIN=		proto/usr/bin
     50 PBIN32=		$(PBIN)/$(MACH32)
     51 PBIN64=		$(PBIN)/$(MACH64)
     52 PSHAREMAN1=	proto/usr/share/man/man1
     53 
     54 # Paths to proto/usr/gnu
     55 PGBIN=		proto/usr/gnu/bin
     56 PGSHAREMAN1=	proto/usr/gnu/share/man/man1
     57 
     58 MANPAGES=	$(PSHAREMAN1)/b2m.1 \
     59 		$(PSHAREMAN1)/ebrowse.1 \
     60 		$(PSHAREMAN1)/emacs.1 \
     61 		$(PSHAREMAN1)/emacs-gtk.1 \
     62 		$(PSHAREMAN1)/emacs-nox.1 \
     63 		$(PSHAREMAN1)/emacs-x.1 \
     64 		$(PSHAREMAN1)/emacsclient.1 \
     65 		$(PSHAREMAN1)/grep-changelog.1 \
     66 		$(PSHAREMAN1)/rcs-checkin.1 \
     67 		$(PSHAREMAN1)/emacsclient.1 \
     68 		$(PGSHAREMAN1)/ctags.1 \
     69 		$(PGSHAREMAN1)/etags.1
     70 
     71 # The various toolkit permutations
     72 EMACS_X=	$(PBIN)/emacs-x		$(PBIN)/emacs-x-$(VER) \
     73 		$(PBIN32)/emacs-x	$(PBIN32)/emacs-x-$(VER) \
     74 		$(PBIN64)/emacs-x	$(PBIN64)/emacs-x-$(VER)
     75 
     76 EMACS_NOX=	$(PBIN)/emacs-nox	$(PBIN)/emacs-nox-$(VER) \
     77 		$(PBIN32)/emacs-nox	$(PBIN32)/emacs-nox-$(VER) \
     78 		$(PBIN64)/emacs-nox	$(PBIN64)/emacs-nox-$(VER)
     79 
     80 EMACS_GTK=	$(PBIN)/emacs-gtk	$(PBIN)/emacs-gtk-$(VER) \
     81 		$(PBIN32)/emacs-gtk	$(PBIN32)/emacs-gtk-$(VER) \
     82 		$(PBIN64)/emacs-gtk	$(PBIN64)/emacs-gtk-$(VER)
     83 
     84 # On X86, the machine types differ (i386-pc and x86_64-pc). We want
     85 # to share the 32-bit architecture specific binaries in both cases,
     86 # so we install the i386-pc version, and use a symlink to make the
     87 # amd64 version see them. The name of the 32-bit version will be
     88 # something like i386-pc-solaris2.11, where the 2.11 is tied
     89 # to the output from 'uname -r'. So use uname to get the value, so
     90 # that we might handle a transition from Nevada (5.11) to the next thing.
     91 #
     92 LIBDIR=proto/usr/lib/emacs/$(VER)
     93 SOL_REV:sh=uname -r | sed "s,^5\.,2\.,"
     94 LIBDIRSYMLINK:sh=	if [ "$MACH" = 'i386' ]; \
     95 	then echo  '$(LIBDIR)/x86_64-pc-solaris$(SOL_REV)'; \
     96 	fi
     97 
     98 all: $(EMACS_X) .WAIT $(EMACS_NOX) .WAIT $(EMACS_GTK) .WAIT \
     99 	$(PBIN)/emacs .WAIT $(MANPAGES) $(LIBDIRSYMLINK)
    100 
    101 install: all
    102 	$(SH) install-sfw
    103 
    104 # LPROTO is a fully qualified path to the proto subdirectory.
    105 # It is needed for the emacs makefile install rule.
    106 #
    107 LPROTO:sh=	echo `pwd`/proto
    108 
    109 # Uncomment this for debugging only. It configures emacs to
    110 # run from the local proto instead of from its final installed
    111 # location
    112 # 
    113 ##INSTALL_ROOT=$(LPROTO)
    114 
    115 # Execute the build_emacs script with an appropriate environment
    116 BUILD_EMACS=	env GCC="$(GCC)" PATH=$(SFW_PATH) sh -x tools/build_emacs
    117 
    118 
    119 # Build the base 32-bit emacs-x, and install it along with the rest of
    120 # the emacs distribution into the local proto area. We use the emacs
    121 # makefile install rule to do this, as discussed in README.SUNWgnu-emacs.
    122 #
    123 # Note that we put usr/src/tools at the head of the PATH. This is done
    124 # in order to ensure that the emacs install uses the no-op links
    125 # to /bin/true for chown and chgrp. We don't need the file ownerships
    126 # to change, and we don't have a 'games' user.
    127 #
    128 # Once the emacs install is finished, we then tweak the results:
    129 #	- Change 'emacs' to $(MACH)/emacs-x
    130 #	- Put ctags/etags into usr/gnu/bin instead of usr/bin
    131 #	- Throw away the manpages that were installed. We will
    132 #	  generate them again, using sed to bolt on an ATTRIBUTES section
    133 #
    134 $(PBIN32)/emacs-x : $(PBIN32) $(PGBIN) $(PGSHAREMAN1)
    135 	rm -f $(PBIN)/emacs	# emacs install will clobber this
    136 	$(BUILD_EMACS) 32 lucid $(INSTALL_ROOT)
    137 	(cd $(EMACSDIST); env prefix=$(LPROTO) bindir=$(LPROTO)/usr/bin \
    138 	    datarootdir=$(LPROTO)/usr/share \
    139 	    libexecdir=$(LPROTO)/usr/lib \
    140 	    INSTALL=ginstall \
    141 	    MAKE=$(GMAKE) \
    142 	    PATH="$${SRC}/tools:$(SFW_PATH)" \
    143 	    $(GMAKE) install)
    144 	mv $(PBIN)/emacs $(PBIN32)/emacs-x
    145 	mv $(PBIN)/emacs-$(VER) $(PBIN32)/emacs-x-$(VER)
    146 	mv $(PBIN)/ctags $(PBIN)/etags $(PGBIN)
    147 	rm $(PSHAREMAN1)/*
    148 
    149 
    150 
    151 # For the other 5 variants, we do the build with the necessary
    152 # configuration, and then take only the emacs binary. These binaries
    153 # will operate with the files produced by the base 32-bit build.
    154 
    155 $(PBIN64)/emacs-x: $(PBIN64)
    156 	$(BUILD_EMACS) 64 lucid $(INSTALL_ROOT)
    157 	cp $(EMACSDIST)/src/emacs $(PBIN64)/emacs-x
    158 	ln -f $(PBIN64)/emacs-x $(PBIN64)/emacs-x-$(VER)
    159 
    160 $(PBIN32)/emacs-nox: $(PBIN32)
    161 	$(BUILD_EMACS) 32 nox $(INSTALL_ROOT)
    162 	cp $(EMACSDIST)/src/emacs $(PBIN32)/emacs-nox
    163 	ln -f $(PBIN32)/emacs-nox $(PBIN32)/emacs-nox-$(VER)
    164 
    165 $(PBIN64)/emacs-nox: $(PBIN64)
    166 	$(BUILD_EMACS) 64 nox $(INSTALL_ROOT)
    167 	cp $(EMACSDIST)/src/emacs $(PBIN64)/emacs-nox
    168 	ln -f $(PBIN64)/emacs-nox $(PBIN64)/emacs-nox-$(VER)
    169 
    170 $(PBIN32)/emacs-gtk: $(PBIN32)
    171 	$(BUILD_EMACS) 32 gtk $(INSTALL_ROOT)
    172 	cp $(EMACSDIST)/src/emacs $(PBIN32)/emacs-gtk
    173 	ln -f $(PBIN32)/emacs-gtk $(PBIN32)/emacs-gtk-$(VER)
    174 
    175 $(PBIN64)/emacs-gtk: $(PBIN64)
    176 	$(BUILD_EMACS) 64 gtk $(INSTALL_ROOT)
    177 	cp $(EMACSDIST)/src/emacs $(PBIN64)/emacs-gtk
    178 	ln -f $(PBIN64)/emacs-gtk $(PBIN64)/emacs-gtk-$(VER)
    179 
    180 
    181 # Rules to copy emacs manpages into the local proto, adding the
    182 # Sun-specific attribute information. Some go in usr/share/man, others
    183 # in usr/gnu/share/man
    184 #
    185 # ctags is a special case that should not go through sunman.pl.
    186 # It simply inlines etags.1.
    187 #
    188 $(PGSHAREMAN1)/ctags.1: $(EMACSDIST)/doc/man/ctags.1
    189 	cp $(EMACSDIST)/doc/man/ctags.1 $(PGSHAREMAN1)/ctags.1
    190 
    191 $(PSHAREMAN1)/% $(PGSHAREMAN1)/%: $(EMACSDIST)/doc/man/%
    192 	perl tools/sunman.pl SUNWgnu-emacs < $< > $@
    193 
    194 # Manpages lacking from the emacs distribution that we supply
    195 #
    196 # The emacs binaries come in their own packages
    197 # 
    198 $(PSHAREMAN1)/emacs-x.1: augment/man/man1/emacs-x.1
    199 	perl tools/sunman.pl SUNWgnu-emacs-x \
    200 		< augment/man/man1/emacs-x.1 > $(PSHAREMAN1)/emacs-x.1
    201 
    202 $(PSHAREMAN1)/emacs-nox.1: augment/man/man1/emacs-nox.1
    203 	perl tools/sunman.pl SUNWgnu-emacs-nox \
    204 		< augment/man/man1/emacs-nox.1 > $(PSHAREMAN1)/emacs-nox.1
    205 
    206 $(PSHAREMAN1)/emacs-gtk.1: augment/man/man1/emacs-gtk.1
    207 	perl tools/sunman.pl SUNWgnu-emacs-gtk \
    208 		< augment/man/man1/emacs-gtk.1 > $(PSHAREMAN1)/emacs-gtk.1
    209 
    210 $(PSHAREMAN1)/%: augment/man/man1/%
    211 	perl tools/sunman.pl SUNWgnu-emacs < $< > $@
    212 
    213 
    214 $(LIBDIRSYMLINK): $(LIBDIR)
    215 	(cd $(LIBDIR); \
    216 		ln -s i386-pc-solaris$(SOL_REV) x86_64-pc-solaris$(SOL_REV));
    217 
    218 # Subdirectores we need to create within the local proto area
    219 proto $(PBIN) $(PBIN32) $(PBIN64) $(PGBIN) $(PGSHAREMAN1) \
    220 		proto/usr/lib $(LIBDIR) :
    221 	mkdir -p $@
    222 
    223 # The emacs files in PBIN are all links to /usr/lib/isaexec.
    224 # Use a copy of the system version in our local proto so we have
    225 # a file to link against. This file is not delivered to the real proto
    226 #
    227 proto/usr/lib/isaexec: proto/usr/lib
    228 	cp /usr/lib/isaexec proto/usr/lib
    229 
    230 $(PBIN)/emacs-x		$(PBIN)/emacs-x-$(VER) \
    231 $(PBIN)/emacs-nox	$(PBIN)/emacs-nox-$(VER) \
    232 $(PBIN)/emacs-gtk	$(PBIN)/emacs-gtk-$(VER) : $(PBIN) proto/usr/lib/isaexec
    233 	ln proto/usr/lib/isaexec $@
    234 
    235 # proto/usr/bin/emacs is a shell script that decides which binary
    236 # to exec at runtime.
    237 #
    238 $(PBIN)/emacs: augment/emacs
    239 	rm -f $(PBIN)/emacs
    240 	cp augment/emacs $(PBIN)
    241 	chmod +x $(PBIN)/emacs
    242 
    243 test:	# there aren't any
    244 
    245 clean:
    246 	-rm -rf $(EMACSDIST) proto
    247 
    248 include ../Makefile.targ
    249 
    250 FRC:
    251