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 #
  23 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 # Copyright 2016 Joyent, Inc.
  26 #
  27 #       This makefile drives the production of unix (and unix.o).
  28 #
  29 #       i86pc implementation architecture dependent
  30 #
  31 
  32 #
  33 #       Path to the base of the uts directory tree (usually /usr/src/uts).
  34 #
  35 UTSBASE = ../..
  36 
  37 #
  38 #       Define the module and object file sets.
  39 #
  40 UNIX            = unix
  41 DBOOT           = dboot
  42 MULTIBOOT       = multiboot
  43 
  44 OBJECTS         = $(SPECIAL_OBJS:%=$(OBJS_DIR)/%) \
  45                   $(CORE_OBJS:%=$(OBJS_DIR)/%) \
  46                   $(KRTLD_OBJS:%=$(OBJS_DIR)/%) \
  47                   $(MACH_NOT_YET_KMODS:%=$(OBJS_DIR)/%)
  48 
  49 LINTS           = $(SPECIAL_OBJS:%.o=$(LINTS_DIR)/%.ln) \
  50                   $(CORE_OBJS:%.o=$(LINTS_DIR)/%.ln) \
  51                   $(KRTLD_OBJS:%.o=$(LINTS_DIR)/%.ln) \
  52                   $(MACH_NOT_YET_KMODS:%.o=$(LINTS_DIR)/%.ln) \
  53                   $(LINTS_DIR)/vers.ln \
  54                   $(LINTS_DIR)/modstubs.ln
  55 
  56 ROOTMODULE      = $(ROOT_PSM_KERN_DIR)/$(UNIX)
  57 ROOT_MULTIBOOT  = $(ROOT_PSM_DIR)/$(MULTIBOOT)
  58 
  59 UNIX_BIN        = $(OBJS_DIR)/$(UNIX)
  60 
  61 LIBS            = $(GENLIB)
  62 
  63 GENUNIX         = genunix
  64 GENUNIX_DIR     = ../../intel/$(GENUNIX)
  65 
  66 LIBOPTS         = -L $(GENUNIX_DIR)/$(OBJS_DIR) -l $(GENUNIX)
  67 
  68 CTFEXTRAOBJS    = $(OBJS_DIR)/vers.o $(OBJS_DIR)/comm_page_ctf.o
  69 
  70 DBOOT_OBJS_DIR  = dboot/$(OBJS_DIR)
  71 DBOOT_OBJECTS   = $(DBOOT_OBJS:%=$(DBOOT_OBJS_DIR)/%)
  72 DBOOT_BIN       = $(DBOOT_OBJS_DIR)/$(DBOOT)
  73 DBOOT_O         = $(OBJS_DIR)/$(DBOOT).o
  74 DBOOT_S         = $(DBOOT_O:%.o=%.s)
  75 DBOOT_LINTS     = $(DBOOT_OBJS:%.o=$(DBOOT_OBJS_DIR)/%.ln)
  76 DBOOT_LINT      = $(i386_LINT)
  77 DBOOT_LINTTAGS  = -erroff=E_STATIC_UNUSED
  78 
  79 #
  80 #       Include common rules.
  81 #
  82 include $(UTSBASE)/i86pc/Makefile.i86pc
  83 
  84 #
  85 #       Define targets
  86 #
  87 ALL_TARGET      = $(UNIX_BIN) $(MULTIBOOT)
  88 LINT_TARGET     = $(LINT_LIB) $(DBOOT_LINT_LIB)
  89 INSTALL_TARGET  = $(UNIX_BIN) $(MULTIBOOT) $(ROOTMODULE) $(ROOT_MULTIBOOT)
  90 
  91 #
  92 #       This is UNIX_DIR. Use a short path.
  93 #
  94 UNIX_DIR        = .
  95 
  96 #
  97 #       Overrides
  98 #
  99 CLEANFILES      +=              \
 100         $(UNIX_O) $(MODSTUBS_O) \
 101         $(OBJS_DIR)/vers.c \
 102         $(OBJS_DIR)/dtracestubs.s \
 103         $(DTRACESTUBS_O) $(DTRACESTUBS) \
 104         $(CTFEXTRAOBJS)
 105 
 106 CLEANFILES      +=              \
 107         $(DBOOT_O) $(DBOOT_S)   \
 108         $(DBOOT_OBJECTS)        \
 109         $(OBJS_DIR)/bios_call_src.o \
 110         $(OBJS_DIR)/bios_call_src \
 111         $(OBJS_DIR)/bios_call.s \
 112         $(DBOOT_BIN)
 113 
 114 CLEANFILES      +=              \
 115         $(OBJS_DIR)/fb_swtch_src.o \
 116         $(OBJS_DIR)/fb_swtch_src \
 117         $(OBJS_DIR)/fb_swtch.s
 118 
 119 CLEANFILES      += \
 120         $(ZLIB_OBJS:%.o=$(OBJS_DIR)/%.o) \
 121         $(ZLIB_OBJS:%.o=$(OBJS_DIR)/%.ln)
 122 
 123 CLOBBERFILES    = $(CLEANFILES) $(UNIX_BIN) $(MULTIBOOT)
 124 CLEANLINTFILES  += $(LINT_LIB) $(DBOOT_LINT_LIB) $(DBOOT_LINTS)
 125 
 126 # instr_size needs a special header
 127 $(OBJS_DIR)/instr_size.o :=     EXTRA_OPTIONS   = -I$(SRC)/common/dis/i386
 128 $(OBJS_DIR)/instr_size.ln :=    EXTRA_OPTIONS   = -I$(SRC)/common/dis/i386
 129 
 130 CFLAGS += -DDIS_MEM
 131 
 132 #
 133 # For now, disable these lint checks; maintainers should endeavor
 134 # to investigate and remove these for maximum lint coverage.
 135 # Please do not carry these forward to new Makefiles.
 136 #
 137 LINTTAGS        += -erroff=E_BAD_PTR_CAST_ALIGN
 138 LINTTAGS        += -erroff=E_SUSPICIOUS_COMPARISON
 139 LINTTAGS        += -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED
 140 LINTTAGS        += -erroff=E_STATIC_UNUSED
 141 LINTTAGS        += -erroff=E_PTRDIFF_OVERFLOW
 142 LINTTAGS        += -erroff=E_ASSIGN_NARROW_CONV
 143 
 144 CERRWARN        += -_gcc=-Wno-parentheses
 145 CERRWARN        += -_gcc=-Wno-uninitialized
 146 CERRWARN        += -_gcc=-Wno-char-subscripts
 147 CERRWARN        += -_gcc=-Wno-unused-variable
 148 CERRWARN        += -_gcc=-Wno-unused-function
 149 CERRWARN        += -_gcc=-Wno-unused-label
 150 CERRWARN        += -_gcc=-Wno-type-limits
 151 CERRWARN        += -_gcc=-Wno-clobbered
 152 CERRWARN        += -_gcc=-Wno-empty-body
 153 CERRWARN        += -_gcc=-Wno-unused-value
 154 
 155 # Ensure that lint sees 'struct cpu' containing a fully declared
 156 # embedded 'struct machcpu'
 157 #
 158 LINTFLAGS       += -D_MACHDEP -I../../i86pc
 159 
 160 #
 161 #       Default build targets.
 162 #
 163 .KEEP_STATE:
 164 
 165 def: $(DEF_DEPS)
 166 
 167 all: $(ALL_DEPS)
 168 
 169 clean: $(CLEAN_DEPS)
 170 
 171 clobber: $(CLOBBER_DEPS)
 172 
 173 lint: $(LINT_DEPS)
 174 
 175 clean.lint: $(CLEAN_LINT_DEPS)
 176 
 177 install: $(INSTALL_DEPS)
 178 
 179 MAPFILE_32 = $(MAPFILE)
 180 MAPFILE_64 = $(MAPFILE).amd64
 181 
 182 MAPFILE_NAME = $(MAPFILE_$(CLASS))
 183 
 184 $(UNIX_BIN):    $(UNIX_O) $(MODSTUBS_O) $(MAPFILE_NAME) \
 185                 $(GENLIB) $(DTRACESTUBS) $(DBOOT_O)
 186         $(LD) -dy -b -o $@ -e dboot_image -znointerp -M $(MAPFILE_NAME) \
 187             $(UNIX_O) $(DBOOT_O) $(MODSTUBS_O) $(LIBOPTS) \
 188             $(DTRACESTUBS)
 189         $(MBH_PATCH) $(UNIX_BIN)
 190         $(CTFMERGE_UNIQUIFY_AGAINST_GENUNIX)
 191         $(POST_PROCESS)
 192 
 193 $(UNIX_O):      $(OBJECTS) $(CTFEXTRAOBJS)
 194         $(LD) -r -o $@ $(OBJECTS) $(OBJS_DIR)/vers.o
 195 
 196 $(DBOOT_BIN):   $(DBOOT_OBJS_DIR) $(DBOOT_OBJECTS) dboot/Mapfile.dboot
 197         $(LD) -dn -e _start -M dboot/Mapfile.dboot \
 198                 -o $(DBOOT_BIN) $(DBOOT_OBJECTS)
 199 
 200 $(DBOOT_O):     $(DBOOT_BIN)
 201         @echo " .data"                                  > $(DBOOT_S)
 202         @echo " .globl  dboot_image"                    >> $(DBOOT_S)
 203         @echo "dboot_image:"                            >> $(DBOOT_S)
 204         $(ELFEXTRACT) $(DBOOT_BIN)                      >> $(DBOOT_S)
 205         $(COMPILE.s) -o $(DBOOT_O) $(DBOOT_S)
 206 
 207 $(DBOOT_OBJS_DIR):
 208         -@mkdir -p $@ 2> /dev/null
 209 
 210 $(OBJS_DIR)/comm_page_ctf.o:    $(UTSBASE)/i86pc/ml/comm_page.s
 211         $(COMPILE.c) -_gcc=-xc -D_GENCTF -o $@ $(UTSBASE)/i86pc/ml/comm_page.s
 212         $(CTFCONVERT_O)
 213 
 214 #
 215 # dboot is built as an intermediate target in dboot.o, so just make
 216 # dboot.o the dependency here.
 217 #
 218 $(MULTIBOOT):   $(DBOOT_O)
 219         $(CP)   $(DBOOT_BIN) $(MULTIBOOT)
 220         $(POST_PROCESS)
 221 
 222 #
 223 #       Special rules for generating assym.h for inclusion in assembly files.
 224 #
 225 $(DSF_DIR)/$(OBJS_DIR)/assym.h $(DSF_DIR)/$(OBJS_DIR)/kdi_assym.h:      FRC
 226         @cd $(DSF_DIR); $(MAKE) all.targ
 227 
 228 #
 229 #       The global lint target builds the kernel lint library (llib-lunix.ln)
 230 #       which is equivalent to a lint of /unix.o. Then all kernel modules for
 231 #       this architecture are linted against the kernel lint library.
 232 #
 233 #       Note:   lint errors in the kernel lint library will be repeated for
 234 #               each module. It is important that the kernel lint library
 235 #               be clean to keep the textual output to a reasonable level.
 236 #
 237 
 238 $(LINT_LIB):    $(LINT_LIB_DIR) $(LINTS)
 239         @pwd
 240         @-$(ECHO) "\n$(UNIX): (library construction):"
 241         @$(LINT) -o$(UNIX) $(LINTFLAGS) $(LINTS)
 242         @$(MV) $(@F) $@
 243 
 244 $(DBOOT_LINT_LIB):      $(LINT_LIB_DIR) $(DBOOT_LINTS)
 245         @pwd
 246         @-$(ECHO) "\n$(DBOOT): (library construction):"
 247         @$(LINT) -o$(DBOOT) $(DBOOT_LINTFLAGS) $(DBOOT_LINTS)
 248         @$(MV) $(@F) $@
 249 
 250 lintlib:        $(LINT_DEPS)
 251 
 252 #
 253 #       Include common targets.
 254 #
 255 include $(UTSBASE)/i86pc/Makefile.targ