aboutsummaryrefslogtreecommitdiff
path: root/rules/common.mk
blob: ffe40a9c16f93f53b2e99e18284001350b22f8f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#
# 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 http://www.opensource.org/licenses/CDDL-1.0
# 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.
# 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 (C) 2012, Nexenta Systems, Inc. All rights reserved.
#

# include guard:
ifeq (,$(__common_mk))

skip := \#

build32 := $(skip)
build64 := $(skip)

# Default:
bits := 64

# Prepended to commands which require root privileges
# May be overriden in /etc/cibs/cibs.conf to, for example, pfexec
root-cmd := sudo

mach := $(shell uname -p)
mach32 :=
mach64 := amd64

variants :=

workdir-base := work
workdir   := $(CURDIR)/$(workdir-base)
sourcedir := $(workdir)/source

define add-variant
protodir-base.$1 = $(workdir-base)/proto/$1
builddir-base.$1 = $(workdir-base)/build/$1
protodir.$1 = $(workdir)/proto/$1
builddir.$1 = $(workdir)/build/$1
variants += $1
endef


CC.32  = gcc -m32
CC.64  = gcc -m64
CXX.32 = g++ -m32
CXX.64 = g++ -m64

export PATH := /usr/bin:/usr/gnu/bin:/usr/sbin:/sbin
export CFLAGS = -O2

prefix = /usr
libdir.32 = $(prefix)/lib/$(mach32)
libdir.64 = $(prefix)/lib/$(mach64)
bindir.32 = $(prefix)/bin/$(mach32)
bindir.64 = $(prefix)/bin/$(mach64)
includedir.32 = /usr/include
includedir.64 = /usr/include
libdir.noarch = $(prefix)/lib
bindir.noarch = $(prefix)/bin
includedir.noarch = /usr/include

PKG_CONFIG_PATH.32 = /usr/gnu/lib/$(mach32)/pkg-config:/usr/lib/$(mach32)/pkg-config
PKG_CONFIG_PATH.64 = /usr/gnu/lib/$(mach64)/pkg-config:/usr/lib/$(mach64)/pkg-config
export PKG_CONFIG_PATH = PKG_CONFIG_PATH.$(bits)

# $(bits) are target-specific and defined in 32.mk or 64.mk
bindir     = $(bindir.$(bits))
libdir     = $(libdir.$(bits))
includedir = $(includedir.$(bits))
CC         = $(CC.$(bits))
CXX        = $(CXX.$(bits))
builddir   = $(builddir.$(bits))
protodir   = $(protodir.$(bits))



# Common targets for internal usage.
# Some modules (e. g. 32.mk, autotools.mk) add dependencies
# to this, for example configure with autotools
check-build-dep-stamp unpack-stamp patch-stamp pre-configure-stamp configure-stamp build-stamp install-stamp:
	touch $@

install-stamp   : build-stamp
build-stamp     : configure-stamp
configure-stamp : pre-configure-stamp
pre-configure-stamp : patch-stamp unpack-stamp
patch-stamp     : unpack-stamp
unpack-stamp    : check-build-dep-stamp

# Common target to use from command line
# or in component top-level Makefile:
unpack    : unpack-stamp
patch     : patch-stamp
configure : configure-stamp
build     : build-stamp
install   : install-stamp

# clean is special and can be extended in Makefile:
clean :: 
	rm -f *-stamp
	rm -rf $(workdir)

__common_mk := included

-include /etc/cibs/cibs.conf

endif