make-rules/perl-generic.mk
changeset 260 cc1837bbe69e
parent 259 520697a05dde
child 261 f7fc4962fa91
equal deleted inserted replaced
259:520697a05dde 260:cc1837bbe69e
     1 #
       
     2 # CDDL HEADER START
       
     3 #
       
     4 # The contents of this file are subject to the terms of the
       
     5 # Common Development and Distribution License (the "License").
       
     6 # You may not use this file except in compliance with the License.
       
     7 #
       
     8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
       
     9 # or http://www.opensolaris.org/os/licensing.
       
    10 # See the License for the specific language governing permissions
       
    11 # and limitations under the License.
       
    12 #
       
    13 # When distributing Covered Code, include this CDDL HEADER in each
       
    14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
       
    15 # If applicable, add the following below this CDDL HEADER, with the
       
    16 # fields enclosed by brackets "[]" replaced with your own identifying
       
    17 # information: Portions Copyright [yyyy] [name of copyright owner]
       
    18 #
       
    19 # CDDL HEADER END
       
    20 #
       
    21 # Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
       
    22 #
       
    23 
       
    24 include ../../../make-rules/prep.mk
       
    25 include ../../../make-rules/ips.mk
       
    26 
       
    27 # Maybe not necessary, but won't do any harm neither
       
    28 PERL_ENV = MAKE=$(GMAKE)
       
    29 # PATH has to contain the same CC compiler which was used for perl component
       
    30 # itself
       
    31 PERL_ENV += PATH=$(dir $(CC.studio.32)):$(PATH)
       
    32 
       
    33 PERL_ARCH=$(shell arch)
       
    34 
       
    35 PKG_MACROS             +=      PERL_ARCH=$(PERL_ARCH)
       
    36 PKG_MACROS             +=      PERL_VERSION=$(PERL_VERSION)
       
    37 
       
    38 
       
    39 ################
       
    40 # Prepare
       
    41 ################
       
    42 $(BUILD_DIR)/%/.configured:	$(SOURCE_DIR)/.prep
       
    43 	($(RM) -rf $(@D) ; $(MKDIR) $(@D))
       
    44 	$(CLONEY) $(SOURCE_DIR) $(@D)
       
    45 	$(COMPONENT_PRE_CONFIGURE_ACTION)
       
    46 	(cd $(@D) ; $(PERL_ENV) $(PERL) Makefile.PL)
       
    47 	$(COMPONENT_POST_CONFIGURE_ACTION)
       
    48 	$(TOUCH) $@
       
    49 
       
    50 
       
    51 ################
       
    52 # Build
       
    53 ################
       
    54 COMPONENT_BUILD_ENV	+= $(PERL_ENV)
       
    55 
       
    56 # build the configured source
       
    57 $(BUILD_DIR)/%/.built:	$(BUILD_DIR)/%/.configured
       
    58 	$(COMPONENT_PRE_BUILD_ACTION)
       
    59 	(cd $(@D) ; $(ENV) $(COMPONENT_BUILD_ENV) \
       
    60 		$(GMAKE) $(COMPONENT_BUILD_ARGS) $(COMPONENT_BUILD_TARGETS))
       
    61 	$(COMPONENT_POST_BUILD_ACTION)
       
    62 	$(TOUCH) $@
       
    63 
       
    64 build:		$(VARIANTS:%=%/.built)
       
    65 
       
    66 
       
    67 ################
       
    68 # Install
       
    69 ################
       
    70 COMPONENT_INSTALL_TARGETS = \
       
    71 	DESTDIR="$(PROTO_DIR)" install_vendor
       
    72 
       
    73 $(BUILD_DIR)/%/.installed:	$(BUILD_DIR)/%/.built
       
    74 	$(COMPONENT_PRE_INSTALL_ACTION)
       
    75 	(cd $(@D) ; $(ENV) $(COMPONENT_INSTALL_ENV) $(GMAKE) \
       
    76 			$(COMPONENT_INSTALL_ARGS) $(COMPONENT_INSTALL_TARGETS))
       
    77 	# Now walk the files which should have the magic line #!/usr/bin/perl
       
    78 	# changed to comply with Solaris standards
       
    79 	(cd $(PROTO_DIR); \
       
    80 		for file in $(PERL_FILES_TO_UPDATE_MAGIC_LINE); do \
       
    81 			$(CHMOD) +w $$file; \
       
    82 			$(PERL) -pi -e 's,^#!.*?perl,#!$(PERL), if $$.==1' $$file; \
       
    83 		done)
       
    84 	$(COMPONENT_POST_INSTALL_ACTION)
       
    85 	$(TOUCH) $@
       
    86 
       
    87 install:	$(VARIANTS:%=%/.installed)
       
    88 
       
    89 
       
    90 ################
       
    91 # Test
       
    92 ################
       
    93 # Do not create .tested file, so that test can be re-run anytime
       
    94 $(BUILD_DIR)/%/.tested:	$(BUILD_DIR)/%/.built
       
    95 	@cd $(@D); $(GMAKE) test
       
    96 
       
    97 test:  $(VARIANTS:%=%/.tested)
       
    98 
       
    99 
       
   100 ################
       
   101 # General stuff
       
   102 ################
       
   103 BUILD_PKG_DEPENDENCIES =	$(BUILD_TOOLS)
       
   104 
       
   105 clean:: 
       
   106 	$(RM) -r $(BUILD_DIR) $(PROTO_DIR) $(VARIANTS)
       
   107 
       
   108 include ../../../make-rules/depend.mk