-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
162 lines (120 loc) · 5.4 KB
/
Makefile
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
#
# Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms and conditions of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# include common variables and functions
##############################################################################
include utils.mk
##############################################################################
# assign variables
##############################################################################
NVIDIA_MODPROBE = $(OUTPUTDIR)/nvidia-modprobe
NVIDIA_MODPROBE_PROGRAM_NAME = "nvidia-modprobe"
NVIDIA_MODPROBE_VERSION := $(NVIDIA_VERSION)
MANPAGE_GZIP ?= 1
MANPAGE_not_gzipped = $(OUTPUTDIR)/nvidia-modprobe.1
MANPAGE_gzipped = $(OUTPUTDIR)/nvidia-modprobe.1.gz
ifeq ($(MANPAGE_GZIP),1)
MANPAGE = $(MANPAGE_gzipped)
else
MANPAGE = $(MANPAGE_not_gzipped)
endif
GEN_MANPAGE_OPTS = $(OUTPUTDIR_ABSOLUTE)/gen-manpage-opts
OPTIONS_1_INC = $(OUTPUTDIR)/options.1.inc
##############################################################################
# The common-utils directory may be in one of two places: either
# elsewhere in the driver source tree when building nvidia-modprobe as
# part of the NVIDIA driver build (in which case, COMMON_UTILS_DIR
# should be defined by the calling makefile), or directly in the
# source directory when building from the nvidia-modprobe source
# tarball (in which case, the below conditional assignment should be
# used)
##############################################################################
COMMON_UTILS_DIR ?= common-utils
##############################################################################
# The modprobe-utils directory may be in one of two places: either
# elsewhere in the driver source tree when building as part of the
# NVIDIA driver build (in which case, MODPROBE_UTILS_DIR should be
# defined by the calling makefile), or directly in the source
# directory when building from source tarball (in which case, the
# below conditional assignment should be used)
##############################################################################
MODPROBE_UTILS_DIR ?= modprobe-utils
# include the list of source files; defines SRC
include dist-files.mk
include $(COMMON_UTILS_DIR)/src.mk
SRC += $(addprefix $(COMMON_UTILS_DIR)/,$(COMMON_UTILS_SRC))
include $(MODPROBE_UTILS_DIR)/nvidia-modprobe-utils.mk
SRC += $(addprefix $(MODPROBE_UTILS_DIR)/,$(MODPROBE_UTILS_SRC))
OBJS = $(call BUILD_OBJECT_LIST,$(SRC))
common_cflags += -I $(OUTPUTDIR)
common_cflags += -I $(COMMON_UTILS_DIR)
common_cflags += -I $(MODPROBE_UTILS_DIR)
common_cflags += -DPROGRAM_NAME=\"$(NVIDIA_MODPROBE_PROGRAM_NAME)\"
# Enable gnu99 for use of functions like snprintf(3).
common_cflags += -std=gnu99
common_cflags += -pedantic
CFLAGS += $(common_cflags)
HOST_CFLAGS += $(common_cflags)
##############################################################################
# build rules
##############################################################################
.PHONY: all
all: $(NVIDIA_MODPROBE) $(MANPAGE)
.PHONY: install
install: NVIDIA_MODPROBE_install MANPAGE_install
.PHONY: NVIDIA_MODPROBE_install
NVIDIA_MODPROBE_install: $(NVIDIA_MODPROBE)
$(MKDIR) $(BINDIR)
$(INSTALL) $(INSTALL_BIN_ARGS) $< $(BINDIR)/$(notdir $<)
.PHONY: MANPAGE_install
MANPAGE_install: $(MANPAGE)
$(MKDIR) $(MANDIR)
$(INSTALL) $(INSTALL_BIN_ARGS) $< $(MANDIR)/$(notdir $<)
$(eval $(call DEBUG_INFO_RULES, $(NVIDIA_MODPROBE)))
$(NVIDIA_MODPROBE).unstripped: $(OBJS)
$(call quiet_cmd,LINK) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@ \
$(BIN_LDFLAGS)
# define the rule to build each object file
$(foreach src,$(SRC),$(eval $(call DEFINE_OBJECT_RULE,TARGET,$(src))))
.PHONY: clean clobber
clean clobber:
rm -rf $(NVIDIA_MODPROBE) $(MANPAGE) *~ \
$(OUTPUTDIR)/*.o $(OUTPUTDIR)/*.d \
$(GEN_MANPAGE_OPTS) $(OPTIONS_1_INC)
##############################################################################
# Documentation
##############################################################################
AUTO_TEXT = ".\\\" WARNING: THIS FILE IS AUTO-GENERATED! Edit $< instead."
.PHONY: doc
doc: $(MANPAGE)
GEN_MANPAGE_OPTS_SRC = gen-manpage-opts.c
GEN_MANPAGE_OPTS_SRC += $(COMMON_UTILS_DIR)/gen-manpage-opts-helper.c
GEN_MANPAGE_OPTS_OBJS = $(call BUILD_OBJECT_LIST,$(GEN_MANPAGE_OPTS_SRC))
$(foreach src,$(GEN_MANPAGE_OPTS_SRC), \
$(eval $(call DEFINE_OBJECT_RULE,HOST,$(src))))
$(GEN_MANPAGE_OPTS): $(GEN_MANPAGE_OPTS_OBJS)
$(call quiet_cmd,HOST_LINK) \
$(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_BIN_LDFLAGS) $^ -o $@
$(OPTIONS_1_INC): $(GEN_MANPAGE_OPTS)
@$< > $@
$(MANPAGE_not_gzipped): nvidia-modprobe.1.m4 $(OPTIONS_1_INC) $(VERSION_MK)
$(call quiet_cmd,M4) -D__HEADER__=$(AUTO_TEXT) -I $(OUTPUTDIR) \
-D__VERSION__=$(NVIDIA_VERSION) \
-D__DATE__="`$(DATE) +%F`" \
-D__BUILD_OS__=$(TARGET_OS) \
$< > $@
$(MANPAGE_gzipped): $(MANPAGE_not_gzipped)
$(GZIP_CMD) -9nf < $< > $@