1494N/A#
1607N/A# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
1494N/A#
1494N/A# Permission is hereby granted, free of charge, to any person obtaining a
1494N/A# copy of this software and associated documentation files (the "Software"),
1494N/A# to deal in the Software without restriction, including without limitation
1494N/A# the rights to use, copy, modify, merge, publish, distribute, sublicense,
1494N/A# and/or sell copies of the Software, and to permit persons to whom the
1494N/A# Software is furnished to do so, subject to the following conditions:
1494N/A#
1494N/A# The above copyright notice and this permission notice (including the next
1494N/A# paragraph) shall be included in all copies or substantial portions of the
1494N/A# Software.
1494N/A#
1494N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1494N/A# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1494N/A# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1494N/A# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1494N/A# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1494N/A# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1494N/A# DEALINGS IN THE SOFTWARE.
1494N/A#
1494N/A#
1494N/A###############################################################################
1494N/A#
1494N/A# Makefile.inc - rules common to the kernel directory
1494N/A#
1494N/A###############################################################################
1494N/A
1494N/APWD:sh=pwd
1494N/ATOP:sh=hg root
1494N/A
1494N/AMODTYPE=driver
1494N/A
1494N/A# Hierarchical parent for pkg names in this area
1494N/A# Note that each driver needs to set the MODULE_PKGTAIL
1494N/A# value so that it can be appropriately installed in that package
1494N/A# e.g. i915/drm define this as "MODULE_PKGTAIL = drm"
1494N/AMODTYPE_PKGHIER = driver/graphics
1494N/AMODTYPE_PKGHIER_SET = yes
1494N/A
1500N/A# PKGCLASS - Drivers/Display for framebuffers.
1500N/AMODULE_PKGCLASS = Drivers/Display
1494N/AMODULE_PKGCLASS_SET = yes
1494N/A
1494N/A# The package that this belongs in - must match the name in pkg/manifests
1494N/A# This is something that should be a bit more dynamic.
1494N/AMODULE_PKG = driver-graphics-drm
1494N/A
1494N/A# Default module description for packages in this area
1494N/AMODTYPE_DESC = the $(MODULE_NAME) driver
1494N/A
1494N/A### Include common definitions
1494N/Ainclude $(TOP)/open-src/common/Makefile.init
1494N/A
1494N/A#
1494N/A# Default build types, driver is only 64 bit, and this one is x86 only.
1494N/A#
1494N/ABUILD_TYPES_DEFAULT = $(BUILD_TYPES_SET:yes=$(POUND_SIGN))
1494N/A# debug isn't working quite right yet
1494N/A# $(BUILD_TYPES_DEFAULT) BUILD_TYPES=64 debug
1494N/A$(BUILD_TYPES_DEFAULT) BUILD_TYPES=64
1494N/A# $(BUILD_TYPES_DEFAULT) BUILD_TYPES=64
1494N/A$(BUILD_TYPES_DEFAULT) BUILD_TYPES_SET=yes
1494N/A
1494N/A
1494N/A# Set comments in ELF binaries to help identify versions/builds
1494N/A# XXXX - We probably need something here, but not sure what.
1494N/A# MODTYPE_ADD_BUILD_TARGETS=set-elf-comments
1494N/A
1494N/A# Define common LDFLAGS
1494N/AMODTYPE_LDFLAGS = -zstrip-class=comment -zstrip-class=exclude
1494N/A
1494N/A#
1494N/A# Defines that are specific to kernel drivers
1494N/A#
1494N/A# Default build options
1494N/AUSE_DEFAULT_CONFIG_LDFLAGS = no
1494N/AUSE_DEFAULT_CONFIG_CPPFLAGS = no
1494N/AUSE_DEFAULT_CONFIG_ENV = no
1494N/A
1494N/A#
1494N/A# Much of the below is the redefinition of defines in the common
1494N/A# Makefiles. It was changed here as the environment is sufficiently
1494N/A# different for kernel modules that it introduced a fair amount of
1494N/A# changed code. So it was initially decided to separate the work
1494N/A# and figure later how to move this into common code (which can be
1494N/A# accomplished in smaller increments).
1494N/A
1494N/A#
1494N/A# Due to the common Makefile's use of DEFAULT_LD_OPTIONS, we clear it here.
1494N/A#
1494N/ADEFAULT_LD_OPTIONS =
1494N/A
1494N/A#
1494N/A# Define CONFIG_ENV for kernel modules here.
1494N/A# Note that _anything_ needed to build these modules must be listed here
1494N/A# as they are not retained from the common Makefiles.
1494N/A#
1494N/ACONFIG_ENV = CC="$(CC)" CXX="$(CXX)" AR="$(AR)"
1494N/ACONFIG_ENV += LD="$(LD)"
1494N/ACONFIG_ENV += CFLAGS="$(MODTYPE_CFLAGS) $(MODULE_CFLAGS)"
1494N/ACONFIG_ENV += CXXFLAGS="$(MODTYPE_CXXFLAGS) $(MODULE_CXXFLAGS)"
1494N/ACONFIG_ENV += CPPFLAGS="$(DEFAULT_CONFIG_CPPFLAGS) $(MODTYPE_CPPFLAGS) $(MODULE_CPPFLAGS)"
1494N/ACONFIG_ENV += LDFLAGS="$(MODULE_LDFLAGS) $(MODTYPE_LDFLAGS)"
1494N/ACONFIG_ENV += PKG_CONFIG_PATH="$(DEFAULT_PKG_CONFIG_PATH)"
1494N/ACONFIG_ENV += INSTALL="$(INSTALL_SCRIPT)" CPPROG="cp -p"
1494N/ACONFIG_ENV += MAKE="$(MODULE_MAKE)" CONFIG_SHELL="$(CONFIG_SHELL)"
1494N/ACONFIG_ENV += NM="/usr/gnu/bin/nm"
1494N/ACONFIG_ENV += POUND_SIGN="$(POUND_SIGN)"
1494N/ACONFIG_ENV += PROTOMETA="$(PROTOMETA)/$(MODULE_PKG)"
1611N/A$(LICENSE_FILE_DEFAULT) CONFIG_ENV += LICENSE_FILE="$(LICENSE_FILE)"
1494N/A
1611N/A
1611N/A###############################################################
1512N/A# Where to find the common include files
1611N/A# Search first in kernel/sys
1611N/ADRM_INCL = -I$(TOP)/open-src/kernel/sys
1611N/A# sys/drm should be removed after all includes properly expand to <drm/...>
1611N/ADRM_INCL += -I$(TOP)/open-src/kernel/sys/drm
1637N/A# Point to the build PROTODIR
1637N/ADRM_INCL += -I$(PROTODIR)/usr/include
1637N/ADRM_INCL += -I$(PROTODIR)/usr/include/drm
1494N/A
1611N/A
1611N/A###############################################################
1494N/A# CFLAGS for modules in open-src/kernel
1494N/A#
1611N/A# Standard defines needed for this driver on solaris independent of compiler
1611N/AKDEFINES = -D_KERNEL -D_ELF64 -D_DDI_STRICT -Dsun -D__sun \
1611N/A -D__SVR4 -D_SYSCALL32 -D_SYSCALL32_IMPL -D_ASM_INLINES
1611N/A
1611N/A# Don't use defines based on MACH.
1611N/AKDEFINES += -U$(MACH) -U__$(MACH)
1611N/A
1611N/A# Debug flags
1611N/AKDEFINES_DEBUG += -DDEBUG
1611N/A
1611N/A# Driver features.
1611N/A
1611N/A###############################################################
1611N/A# Studio flags
1611N/A# Note: KFLAGS without a "compiler" extension are common across
1611N/A# all compilers.
1611N/A# Use C11
1611N/AKFLAGS_suncc += -std=c11
1611N/AKFLAGS_suncc += -features=extensions
1611N/A
1611N/A# Create 64bit code
1611N/AKFLAGS_suncc += -m64
1611N/A
1611N/A# Be verbose
1611N/AKFLAGS_suncc += -v
1611N/A
1611N/A# Use optimizer level 3
1611N/AKFLAGS_suncc += -xO3
1611N/A
1611N/A# Generate code for the "kernel" model
1611N/AKFLAGS_suncc += -xmodel=kernel
1611N/A
1611N/A# Pass "save_args" to code generator
1611N/AKFLAGS_suncc += -Wu,-save_args
1611N/A
1611N/A# Use STABS for debug tags (or mdb won't be useful).
1611N/AKFLAGS_suncc += -xdebugformat=stabs
1611N/A
1611N/A# Don't use a vector library
1611N/AKFLAGS_suncc += -xvector=none
1611N/A
1611N/A# Don't optimize if it increases size
1611N/AKFLAGS_suncc += -xspace
1611N/A
1611N/A# Error flags
1611N/A# Display the tag associated with the error
1611N/AKFLAGS_suncc += -errtags=yes
1611N/A
1611N/A# Exit on all warnings except specified
1611N/A# e.g.: KFLAGS_suncc += -errwarn=%all,no%E_PTR_TO_VOID_IN_ARITHMETIC
1611N/AKFLAGS_suncc += -errwarn=%all
1611N/A
1611N/A# Print only tags when displaying warnings
1611N/AKFLAGS_suncc += -errshort=tags
1611N/A
1611N/A# Errors/Warnings that can be ignored
1611N/A# e.g.: KFLAGS_suncc += -erroff=E_PTR_TO_VOID_IN_ARITHMETIC
1611N/AKFLAGS_suncc += -erroff=E_EMPTY_INITIALIZER
1611N/AKFLAGS_suncc += -erroff=E_ZERO_SIZED_STRUCT_UNION
1494N/A
1494N/A# Architecture specific flags
1611N/A# Do not allow float in passed args for kernel modules
1611N/AKFLAGS_suncc_i386 += -W2,-xregs=no%float
1611N/AKFLAGS_suncc_i386 += -Wu,-xregs=no%float
1611N/AKFLAGS_suncc_i386 += -W0,-y-xregs=no%float
1611N/A
1611N/A# To make sure ctfconvert has STABS/Dwarf data and doesn't
1611N/A# "globalize"
1611N/ACTF_FLAGS = -g
1611N/ACTF_FLAGS += -xglobalize=no
1611N/A
1494N/A
1611N/A###############################################################
1611N/A# Add GCC flags here.
1611N/A#
1611N/AKFLAGS_gcc += -std=gnu11
1611N/AKFLAGS_gcc += -m64
1611N/AKFLAGS_gcc += -FPIC
1611N/AKFLAGS_gcc += -mtune=generic
1611N/AKFLAGS_gcc += -mcmodel=kernel
1611N/AKFLAGS_gcc += -Werror
1611N/AKFLAGS_gcc += -Wfatal-errors
1611N/AKFLAGS_gcc += -gdwarf-2
1611N/AKFLAGS_gcc += -feliminate-unused-debug-symbols
1611N/AKFLAGS_gcc += -gno-strict-dwarf
1611N/AKFLAGS_gcc += -feliminate-dwarf2-dups
1611N/A
1611N/A###############################################################
1494N/A
1512N/AINC_PATH = -I. $(DRM_INCL) -I/usr/include
1494N/A
1611N/A
1611N/A# Debug, anyone???
1611N/APROG_FLAGS += $(KDEFINES_$(DEBUG)) $(KFLAGS_$(DEBUG))
1611N/A
1611N/A# KFLAGS based on compiler
1611N/AKFLAGS += $(KFLAGS_$(MODULE_COMPILER))
1611N/A#KFLAGS based on compiler and machine
1615N/AKFLAGS += $(KFLAGS_$(MODULE_COMPILER)_$(MACH))
1494N/A
1512N/AMODTYPE_CPPFLAGS = $(INC_PATH)
1611N/AMODTYPE_CFLAGS = $(INC_PATH) $(KDEFINES) $(KFLAGS) $(CTF_FLAGS) $(PROG_FLAGS)
1494N/A
1494N/A#
1494N/A# Define the MODTYPE environment
1494N/A#
1494N/AMODTYPE_BUILD_ENV = CFLAGS='$(MODTYPE_CFLAGS)'
1494N/AMODTYPE_BUILD_ENV += CC='$(CC)' LD='$(LD)' LINT='$(LINT)'
1494N/A
1494N/A### Include common file
1494N/Ainclude $(TOP)/open-src/common/Makefile.inc