xref: /illumos-gate/usr/src/lib/libdisasm/Makefile.com (revision 1a2d662a91cee3bf82f41cd47c7ae6f3825d9db2)
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# Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
25# Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
26# Copyright (c) 2018, Joyent, Inc.
27#
28
29#
30# The build process for libdisasm is sightly different from that used by other
31# libraries, because libdisasm must be built in two flavors - as a standalone
32# for use by kmdb and as a normal library.  We use $(CURTYPE) to indicate the
33# current flavor being built.
34#
35
36LIBRARY=	libdisasm.a
37STANDLIBRARY=	libstanddisasm.so
38VERS=		.1
39
40# By default, we build the shared library.  Construction of the standalone
41# is specifically requested by architecture-specific Makefiles.
42TYPES=		library
43CURTYPE=	library
44
45COMDIR=		$(SRC)/lib/libdisasm/common
46
47#
48# Architecture-independent files
49#
50SRCS_common=		$(COMDIR)/libdisasm.c
51OBJECTS_common=		libdisasm.o
52
53#
54# Architecture-dependent disassembly files
55#
56SRCS_i386=		$(COMDIR)/dis_i386.c \
57			$(SRC)/common/dis/i386/dis_tables.c
58SRCS_sparc=		$(COMDIR)/dis_sparc.c \
59			$(COMDIR)/dis_sparc_fmt.c \
60			$(COMDIR)/dis_sparc_instr.c
61SRCS_s390x=		$(COMDIR)/dis_s390x.c
62SRCS_riscv=		$(COMDIR)/dis_riscv.c
63
64OBJECTS_i386=		dis_i386.o \
65			dis_tables.o
66OBJECTS_sparc=		dis_sparc.o \
67			dis_sparc_fmt.o \
68			dis_sparc_instr.o
69OBJECTS_s390x=		dis_s390x.o
70OBJECTS_riscv=		dis_riscv.o
71
72#
73# We build the regular shared library with support for all architectures.
74# The standalone version should only contain code for the native
75# architecture to reduce the memory footprint of kmdb.
76#
77OBJECTS_library=	$(OBJECTS_common) \
78			$(OBJECTS_i386) \
79			$(OBJECTS_sparc) \
80			$(OBJECTS_s390x) \
81			$(OBJECTS_riscv)
82OBJECTS_standalone=	$(OBJECTS_common) \
83			$(OBJECTS_$(MACH))
84OBJECTS=		$(OBJECTS_$(CURTYPE))
85
86include $(SRC)/lib/Makefile.lib
87
88SRCS_library=		$(SRCS_common) \
89			$(SRCS_i386) \
90			$(SRCS_sparc) \
91			$(SRCS_s390x) \
92			$(SRCS_riscv)
93SRCS_standalone=	$(SRCS_common) \
94			$(SRCS_$(MACH))
95SRCS=			$(SRCS_$(CURTYPE))
96
97#
98# Used to verify that the standalone doesn't have any unexpected external
99# dependencies.
100#
101LINKTEST_OBJ = objs/linktest_stand.o
102
103CLOBBERFILES_standalone = $(LINKTEST_OBJ)
104CLOBBERFILES += $(CLOBBERFILES_$(CURTYPE))
105
106LIBS_standalone	= $(STANDLIBRARY)
107LIBS_library = $(DYNLIB)
108LIBS = $(LIBS_$(CURTYPE))
109
110MAPFILES =	$(COMDIR)/mapfile-vers
111
112LDLIBS +=	-lc
113
114LDFLAGS_standalone = $(ZNOVERSION) $(BREDUCE) -dy -r
115LDFLAGS = $(LDFLAGS_$(CURTYPE))
116
117ASFLAGS_standalone = -DDIS_STANDALONE
118ASFLAGS_library =
119ASFLAGS += $(ASFLAGS_$(CURTYPE)) -D_ASM
120
121CERRWARN +=	-_gcc=-Wno-parentheses
122CERRWARN +=	$(CNOWARN_UNINIT)
123
124# not linted
125SMATCH=off
126
127#
128# The standalone environment currently does not support the stack
129# protector.
130#
131STACKPROTECT = none
132
133# We want the thread-specific errno in the library, but we don't want it in
134# the standalone.  $(DTS_ERRNO) is designed to add -D_TS_ERRNO to $(CPPFLAGS),
135# in order to enable this feature.  Conveniently, -D_REENTRANT does the same
136# thing.  As such, we null out $(DTS_ERRNO) to ensure that the standalone
137# doesn't get it.
138DTS_ERRNO=
139
140CPPFLAGS_standalone = -DDIS_STANDALONE -I$(SRC)/cmd/mdb/common
141CPPFLAGS_library = -D_REENTRANT
142CPPFLAGS +=	-I$(COMDIR) $(CPPFLAGS_$(CURTYPE))
143
144# For the x86 disassembler we have to include sources from usr/src/common
145CPPFLAGS += -I$(SRC)/common/dis/i386 -DDIS_TEXT
146
147CFLAGS_standalone = $(STAND_FLAGS_32)
148CFLAGS_common =
149CFLAGS += $(CFLAGS_$(CURTYPE)) $(CFLAGS_common)
150
151CFLAGS64_standalone = $(STAND_FLAGS_64)
152CFLAGS64 += $(CCVERBOSE) $(CFLAGS64_$(CURTYPE)) $(CFLAGS64_common)
153
154CSTD = $(CSTD_GNU99)
155
156DYNFLAGS +=     $(ZINTERPOSE)
157
158.KEEP_STATE:
159