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