Mike Sullivan
2012-04-17 7999b2369aa32f39455eeeea6fd5bcec4167618b
commit | author | age
9c75c0 1 #
NJ 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 #
b74d96 21 # Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
9c75c0 22 #
NJ 23
24 #
25 # Rules and Macros for building opens source software that uses configure /
26 # GNU auto* tools to configure their build for the system they are on.  This
27 # uses GNU Make to build the components to take advantage of the viewpath
28 # support and build multiple version (32/64 bit) from a shared source.
29 #
30 # To use these rules, include ../make-rules/configure.mk in your Makefile
3a19d0 31 # and define "build", "install", and "test" targets appropriate to building
MT 32 # your component.
9c75c0 33 # Ex:
NJ 34 #
74300c 35 #     build:        $(SOURCE_DIR)/build/$(MACH32)/.built \
NJ 36 #             $(SOURCE_DIR)/build/$(MACH64)/.built
3a19d0 37 #
74300c 38 #    install:    $(SOURCE_DIR)/build/$(MACH32)/.installed \
NJ 39 #             $(SOURCE_DIR)/build/$(MACH64)/.installed
3a19d0 40 #
MT 41 #    test:        $(SOURCE_DIR)/build/$(MACH32)/.tested \
42 #             $(SOURCE_DIR)/build/$(MACH64)/.tested
9c75c0 43 #
NJ 44 # Any additional pre/post configure, build, or install actions can be specified
45 # in your make file by setting them in on of the following macros:
46 #    COMPONENT_PRE_CONFIGURE_ACTION, COMPONENT_POST_CONFIGURE_ACTION
47 #    COMPONENT_PRE_BUILD_ACTION, COMPONENT_POST_BUILD_ACTION
48 #    COMPONENT_PRE_INSTALL_ACTION, COMPONENT_POST_INSTALL_ACTION
3a19d0 49 #    COMPONENT_PRE_TEST_ACTION, COMPONENT_POST_TEST_ACTION
9c75c0 50 #
NJ 51 # If component specific make targets need to be used for build or install, they
52 # can be specified in
53 #    COMPONENT_BUILD_TARGETS, COMPONENT_INSTALL_TARGETS
3a19d0 54 #    COMPONENT_TEST_TARGETS
9c75c0 55 #
NJ 56
4b89a1 57 CONFIGURE_PREFIX =    /usr
NJ 58
59 CONFIGURE_BINDIR.32 =    $(CONFIGURE_PREFIX)/bin
60 CONFIGURE_BINDIR.64 =    $(CONFIGURE_PREFIX)/bin/$(MACH64)
61 CONFIGURE_LIBDIR.32 =    $(CONFIGURE_PREFIX)/lib
62 CONFIGURE_LIBDIR.64 =    $(CONFIGURE_PREFIX)/lib/$(MACH64)
9dfd18 63 CONFIGURE_SBINDIR.32 =    $(CONFIGURE_PREFIX)/sbin
NJ 64 CONFIGURE_SBINDIR.64 =    $(CONFIGURE_PREFIX)/sbin/$(MACH64)
4b89a1 65 CONFIGURE_MANDIR =    $(CONFIGURE_PREFIX)/share/man
NJ 66 CONFIGURE_LOCALEDIR =    $(CONFIGURE_PREFIX)/share/locale
67 # all texinfo documentation seems to go to /usr/share/info no matter what
68 CONFIGURE_INFODIR =    /usr/share/info
f0c88f 69 CONFIGURE_INCLUDEDIR =    /usr/include
4b89a1 70
aeb6c4 71 CONFIGURE_ENV = CONFIG_SHELL="$(CONFIG_SHELL)"
NJ 72
312c03 73 CONFIGURE_DEFAULT_DIRS?=yes
PS 74
011d27 75 CONFIGURE_OPTIONS += CC="$(CC)"
3cec7d 76 CONFIGURE_OPTIONS += CXX="$(CXX)"
4b89a1 77 CONFIGURE_OPTIONS += --prefix=$(CONFIGURE_PREFIX)
312c03 78 ifeq ($(CONFIGURE_DEFAULT_DIRS),yes)
4b89a1 79 CONFIGURE_OPTIONS += --mandir=$(CONFIGURE_MANDIR)
NJ 80 CONFIGURE_OPTIONS += --bindir=$(CONFIGURE_BINDIR.$(BITS))
81 CONFIGURE_OPTIONS += --libdir=$(CONFIGURE_LIBDIR.$(BITS))
9dfd18 82 CONFIGURE_OPTIONS += --sbindir=$(CONFIGURE_SBINDIR.$(BITS))
312c03 83 endif
e83e52 84 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(BITS))
4b89a1 85
NJ 86 COMPONENT_INSTALL_ARGS +=    DESTDIR=$(PROTO_DIR)
9c75c0 87
4158c0 88 $(BUILD_DIR_32)/.configured:    BITS=32
NJ 89 $(BUILD_DIR_64)/.configured:    BITS=64
9c75c0 90
e83e52 91 CONFIGURE_ENV += $(CONFIGURE_ENV.$(BITS))
7999b2 92 ifeq   ($(strip $(PARFAIT_BUILD)),yes)
MS 93 # parfait creates '*.bc' files which can confuse configure's
94 # object/exe extension detection. which we really don't need it
95 # to do anyway, so we'll just tell it what they are.
96 CONFIGURE_ENV += ac_cv_objext=o
97 CONFIGURE_ENV += ac_cv_exeext=""
98 # this is fixed in the clang compiler but we can't use it yet
99 CONFIGURE_ENV += ac_cv_header_stdbool_h=yes
100 endif
101
9c75c0 102
b74d96 103 # temporarily work around some issues
MS 104 CONFIGURE_ENV += "ac_cv_func_realloc_0_nonnull=yes"
105 COMPONENT_BUILD_ENV += "ac_cv_func_realloc_0_nonnull=yes"
106
9c75c0 107 # configure the unpacked source for building 32 and 64 bit version
9dfd18 108 CONFIGURE_SCRIPT =    $(SOURCE_DIR)/configure
74300c 109 $(BUILD_DIR)/%/.configured:    $(SOURCE_DIR)/.prep
9c75c0 110     ($(RM) -rf $(@D) ; $(MKDIR) $(@D))
NJ 111     $(COMPONENT_PRE_CONFIGURE_ACTION)
61c373 112     (cd $(@D) ; $(ENV) $(CONFIGURE_ENV) $(CONFIG_SHELL) \
9dfd18 113         $(CONFIGURE_SCRIPT) $(CONFIGURE_OPTIONS))
9c75c0 114     $(COMPONENT_POST_CONFIGURE_ACTION)
NJ 115     $(TOUCH) $@
116
117 # build the configured source
74300c 118 $(BUILD_DIR)/%/.built:    $(BUILD_DIR)/%/.configured
9c75c0 119     $(COMPONENT_PRE_BUILD_ACTION)
61c373 120     (cd $(@D) ; $(ENV) $(COMPONENT_BUILD_ENV) \
9dfd18 121         $(GMAKE) $(COMPONENT_BUILD_ARGS) $(COMPONENT_BUILD_TARGETS))
9c75c0 122     $(COMPONENT_POST_BUILD_ACTION)
7999b2 123 ifeq   ($(strip $(PARFAIT_BUILD)),yes)
MS 124     -$(PARFAIT) build
125 endif
9c75c0 126     $(TOUCH) $@
NJ 127
128 # install the built source into a prototype area
74300c 129 $(BUILD_DIR)/%/.installed:    $(BUILD_DIR)/%/.built
9c75c0 130     $(COMPONENT_PRE_INSTALL_ACTION)
61c373 131     (cd $(@D) ; $(ENV) $(COMPONENT_INSTALL_ENV) $(GMAKE) \
4b89a1 132             $(COMPONENT_INSTALL_ARGS) $(COMPONENT_INSTALL_TARGETS))
9c75c0 133     $(COMPONENT_POST_INSTALL_ACTION)
NJ 134     $(TOUCH) $@
74300c 135
3a19d0 136 # test the built source
MT 137 $(BUILD_DIR)/%/.tested:    $(BUILD_DIR)/%/.built
138     $(COMPONENT_PRE_TEST_ACTION)
139     (cd $(@D) ; $(ENV) $(COMPONENT_TEST_ENV) $(GMAKE) \
140             $(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS))
141     $(COMPONENT_POST_TEST_ACTION)
142     $(TOUCH) $@
143
7999b2 144 ifeq   ($(strip $(PARFAIT_BUILD)),yes)
MS 145 parfait: install
146     -$(PARFAIT) build
147 else
148 parfait:
149     $(MAKE) PARFAIT_BUILD=yes parfait
150 endif
151
74300c 152 clean::
NJ 153     $(RM) -r $(BUILD_DIR) $(PROTO_DIR)