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#
22# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25# ident	"%Z%%M%	%I%	%E% SMI"
26#
27
28#
29# The build process for libdisasm is sightly different from that used by other
30# libraries, because libdisasm must be built in two flavors - as a standalone
31# for use by kmdb and as a normal library.  We use $(CURTYPE) to indicate the
32# current flavor being built.
33#
34# The SPARC library is built from the closed gate.  This Makefile is shared
35# between both environments, so all paths must be absolute.
36#
37
38LIBRARY=	libdisasm.a
39STANDLIBRARY=	libstanddisasm.so
40VERS=		.1
41
42# By default, we build the shared library.  Construction of the standalone
43# is specifically requested by architecture-specific Makefiles.
44TYPES=		library
45CURTYPE=	library
46
47COMDIR=		$(SRC)/lib/libdisasm/common
48
49#
50# Architecture-dependent files common to both versions of libdisasm
51#
52OBJECTS_common_i386 = dis_i386.o dis_tables.o
53OBJECTS_common_sparc = dis_sparc.o
54
55SRCS_common_i386 = $(ISASRCDIR)/dis_i386.c $(SRC)/common/dis/i386/dis_tables.c
56SRCS_common_sparc = $(ISASRCDIR)/dis_sparc.c
57
58#
59# Architecture-independent files common to both version of libdisasm
60#
61OBJECTS_common_common = libdisasm.o
62SRC_common_common = $(OBJECTS_common_common:%.o=$(COMDIR)/%.c)
63
64
65OBJECTS=				\
66	$(OBJECTS_common_$(MACH))	\
67	$(OBJECTS_common_common)
68
69include $(SRC)/lib/Makefile.lib
70
71SRCS=					\
72	$(SRCS_$(CURTYPE))		\
73	$(SRCS_common_$(MACH))		\
74	$(SRCS_common_common)
75
76#
77# Used to verify that the standalone doesn't have any unexpected external
78# dependencies.
79#
80LINKTEST_OBJ = objs/linktest_stand.o
81
82CLOBBERFILES_standalone = $(LINKTEST_OBJ)
83CLOBBERFILES += $(CLOBBERFILES_$(CURTYPE))
84
85LIBS_standalone	= $(STANDLIBRARY)
86LIBS_library = $(DYNLIB) $(LINTLIB)
87LIBS = $(LIBS_$(CURTYPE))
88
89MAPFILES =	$(COMDIR)/mapfile-vers
90
91LDLIBS +=	-lc
92
93LDFLAGS_standalone = $(ZNOVERSION) $(BREDUCE) -dy -r
94LDFLAGS = $(LDFLAGS_$(CURTYPE))
95
96ASFLAGS_standalone = -DDIS_STANDALONE
97ASFLAGS_library =
98ASFLAGS += -P $(ASFLAGS_$(CURTYPE)) -D_ASM
99
100$(LINTLIB) := SRCS = $(COMDIR)/$(LINTSRC)
101
102# We want the thread-specific errno in the library, but we don't want it in
103# the standalone.  $(DTS_ERRNO) is designed to add -D_TS_ERRNO to $(CPPFLAGS),
104# in order to enable this feature.  Conveniently, -D_REENTRANT does the same
105# thing.  As such, we null out $(DTS_ERRNO) to ensure that the standalone
106# doesn't get it.
107DTS_ERRNO=
108
109# We need to rename some standard functions so we can easily implement them
110# in consumers.
111STAND_RENAMED_FUNCS= \
112	snprintf
113
114CPPFLAGS_standalone = -DDIS_STANDALONE $(STAND_RENAMED_FUNCS:%=-D%=mdb_%) \
115	-I$(SRC)/cmd/mdb/common
116CPPFLAGS_library = -D_REENTRANT
117CPPFLAGS +=	-I$(COMDIR) $(CPPFLAGS_$(CURTYPE))
118
119#
120# For x86, we have to link to sources in usr/src/common
121#
122CPPFLAGS_dis_i386 = -I$(SRC)/common/dis/i386 -DDIS_TEXT
123CPPFLAGS_dis_sparc =
124CPPFLAGS +=	$(CPPFLAGS_dis_$(MACH))
125
126CFLAGS_standalone = $(STAND_FLAGS_32)
127CFLAGS_common =
128CFLAGS += $(CFLAGS_$(CURTYPE)) $(CFLAGS_common)
129
130CFLAGS64_standalone = $(STAND_FLAGS_64)
131CFLAGS64 += $(CCVERBOSE) $(CFLAGS64_$(CURTYPE)) $(CFLAGS64_common)
132
133DYNFLAGS +=     $(ZINTERPOSE)
134
135.KEEP_STATE:
136