summaryrefslogtreecommitdiff
path: root/makefile.nvmk
blob: 7ee1fb51001cdc76d81749a3ce73435b4a8e7814 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
##############################################################################
# drivers/setup/linux/nvidia-installer/makefile.nvmk
##############################################################################

##############################################################################
# Identify this module to nvCommon.nvmk so it can decide the build type
##############################################################################

NV_MODULE_BUILD_TYPE_ALIASES = utils

include $(NV_SOURCE)/drivers/common/build/nvCommon.nvmk


##############################################################################
# string to prepend in unix builds when executing rules in this gmake instance
##############################################################################

export NV_MODULE_LOGGING_NAME = "nvidia-installer"


##############################################################################
# export the appropriate variables from nvmake to the gmake that we're
# going to invoke
##############################################################################

$(eval $(EXPORT_VARIABLES_TO_PUBLIC_MAKEFILE))

_ncurses_dir = $(NV_TOOLS)/unix/targets/$(NV_TARGET_OS)-$(NV_TARGET_ARCH_UNIX_TOOLS)/ncurses-5.5

NCURSES_INCLUDE_DIR = $(_ncurses_dir)/include
NCURSES_LIB_DIR     = $(_ncurses_dir)/lib

export NCURSES_CFLAGS = -I$(NCURSES_INCLUDE_DIR)
export NCURSES_LDFLAGS = -L$(NCURSES_LIB_DIR)

_pci_dir = $(NV_TOOLS)/unix/targets/$(NV_TARGET_OS)-$(NV_TARGET_ARCH_UNIX_TOOLS)/pciutils-2.2.1

PCI_INCLUDE_DIR = $(_pci_dir)/include
PCI_LIB_DIR = $(_pci_dir)/lib

export PCI_CFLAGS = -I$(PCI_INCLUDE_DIR)
export PCI_LDFLAGS = -L$(PCI_LIB_DIR)

export OUTPUTDIR

export NV_AUTO_DEPEND
export NV_VERBOSE

# for utils.mk
NV_MAKE_ARGS = -I $(NV_SOURCE)/drivers/setup/linux/common


##############################################################################
# check that all the directories that we exported above actually
# exist; trigger a warning if any of them don't exist
##############################################################################

_extra_dirs += $(NCURSES_INCLUDE_DIR)
_extra_dirs += $(NCURSES_LIB_DIR)
_extra_dirs += $(PCI_INCLUDE_DIR)
_extra_dirs += $(PCI_LIB_DIR)

build :: $(_extra_dirs)

$(sort $(_extra_dirs)) :
	@$(ECHO) WARNING: nvidia-installer extra directory does not exist: $@


##############################################################################
# generate the legacy GPU header file
##############################################################################

_nv_common_inc = $(NV_SOURCE)/drivers/common/inc
_nv_sdk_inc    = $(NV_SOURCE)/sdk/nvidia/inc

NV_NAME_H      = $(_nv_common_inc)/nv_name.h
NV_CHIPFLAGS_H = $(_nv_common_inc)/nvChipFlags.h
NV_CHIPUTILS_H = $(_nv_common_inc)/nvChipUtils.h
NV_MISC_H      = $(_nv_sdk_inc)/nvmisc.h

NV_LEGACY_H    = $(OUTPUTDIR)/nvLegacy.h

NV_LEGACY_GENERATOR = $(OUTPUTDIR)/nvLegacyGenerator

NV_LEGACY_GENERATOR_HEADER_DEPS = \
  $(NV_NAME_H) $(NV_CHIPFLAGS_H) $(NV_CHIPUTILS_H) $(NV_MISC_H)

NV_LEGACY_GENERATOR_INCLUDE_CFLAGS = \
  $(addprefix -I,$(sort $(dir $(NV_LEGACY_GENERATOR_HEADER_DEPS))))

$(NV_LEGACY_GENERATOR): ../nvLegacy.c $(NV_LEGACY_GENERATOR_HEADER_DEPS)
	$(call quiet_cmd,HOST_CC) $< -o $@ \
	  $(NV_LEGACY_GENERATOR_INCLUDE_CFLAGS) $(HOST_LDFLAGS) $(HOST_BIN_LDFLAGS)

$(NV_LEGACY_H): $(NV_LEGACY_GENERATOR)
	./$(NV_LEGACY_GENERATOR) > $@

OTHER_FILES_TO_REMOVE += $(NV_LEGACY_H) $(NV_LEGACY_GENERATOR)


##############################################################################
# define how to package the nvidia-installer source tarball
##############################################################################

.PHONY: dist-tarball

# include the list of nvidia-installer source files; defines DIST_FILES
include dist-files.mk

NVIDIA_INSTALLER_DISTDIR_NO_OUTPUTDIR = nvidia-installer-$(NV_VERSION_STRING)
NVIDIA_INSTALLER_DISTDIR = $(OUTPUTDIR)/$(NVIDIA_INSTALLER_DISTDIR_NO_OUTPUTDIR)
NVIDIA_INSTALLER_TARBALL_NO_OUTPUTDIR = $(NVIDIA_INSTALLER_DISTDIR_NO_OUTPUTDIR).tar.bz2
NVIDIA_INSTALLER_TARBALL = $(NVIDIA_INSTALLER_DISTDIR).tar.bz2

ifeq ($(NV_VERBOSE),1)
  _tar_verbose_arg = -v
else
  _tar_verbose_arg =
endif

# define rules to copy files from the source tree to
# $(NVIDIA_INSTALLER_DISTDIR)

$(eval $(call ADD_FILE_TO_TARBALL_RULE,                 \
  public.mk,                                            \
  $(NVIDIA_INSTALLER_DISTDIR)/Makefile,                 \
  $(NVIDIA_INSTALLER_TARBALL)))

$(eval $(call ADD_FILE_TO_TARBALL_RULE,                 \
  $(OUTPUTDIR)/version.mk,                              \
  $(NVIDIA_INSTALLER_DISTDIR)/version.mk,               \
  $(NVIDIA_INSTALLER_TARBALL)))

$(eval $(call ADD_FILE_TO_TARBALL_RULE,                 \
  $(NV_SOURCE)/drivers/setup/linux/common/utils.mk,     \
  $(NVIDIA_INSTALLER_DISTDIR)/utils.mk,                 \
  $(NVIDIA_INSTALLER_TARBALL)))

$(eval $(call ADD_FILE_TO_TARBALL_RULE,                 \
  $(NV_LEGACY_H),                                       \
  $(NVIDIA_INSTALLER_DISTDIR)/$(notdir $(NV_LEGACY_H)), \
  $(NVIDIA_INSTALLER_TARBALL)))

$(foreach src, $(DIST_FILES),                           \
  $(eval $(call ADD_FILE_TO_TARBALL_RULE,               \
    $(src),                                             \
    $(NVIDIA_INSTALLER_DISTDIR)/$(src),                 \
    $(NVIDIA_INSTALLER_TARBALL))))

$(NVIDIA_INSTALLER_TARBALL):
	@$(ECHO) "Generating $(OUTPUTDIR)/$(NVIDIA_INSTALLER_TARBALL)"
	$(RM) $(OUTPUTDIR)/tar-file-list.txt
	for i in $(patsubst $(OUTPUTDIR)/%,%,$(TARBALL_FILE_LIST_$@)); do \
	  $(ECHO) $${i} >> $(OUTPUTDIR)/tar-file-list.txt; \
	done
	cd $(OUTPUTDIR) && \
	PATH=/bin $(TAR) -c -j $(_tar_verbose_arg) -f \
	  $(NVIDIA_INSTALLER_TARBALL_NO_OUTPUTDIR) \
	  --files-from=tar-file-list.txt
	$(RM) $(OUTPUTDIR)/tar-file-list.txt

dist-tarball: $(NVIDIA_INSTALLER_TARBALL)

OTHER_FILES_TO_REMOVE += $(NVIDIA_INSTALLER_DISTDIR)
OTHER_FILES_TO_REMOVE += $(NVIDIA_INSTALLER_TARBALL)


##############################################################################
# to actually build nvidia-settings, hand off control to the public makefile
##############################################################################

$(eval $(DEFINE_VERSION_MK_RULE))

build:: $(OUTPUTDIR)/version.mk $(NV_LEGACY_H)
	$(MAKE) $(NV_MAKE_ARGS) -f public.mk $@


##############################################################################
# define the compiler and include the common rules
##############################################################################

include $(NV_SOURCE)/drivers/common/build/gcc-4.1.1as2.nvmk
include $(NV_SOURCE)/drivers/common/build/nvCommonRules.nvmk