File: Makefile

package info (click to toggle)
nvidia-settings 195.36.24-1
  • links: PTS
  • area: contrib
  • in suites: squeeze
  • size: 8,148 kB
  • ctags: 6,136
  • sloc: ansic: 113,460; pascal: 435; makefile: 270; sh: 77
file content (276 lines) | stat: -rw-r--r-- 7,045 bytes parent folder | download
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#
# nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
# and Linux systems.
#
# Copyright (C) 2004 NVIDIA Corporation.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of Version 2 of the GNU General Public
# License as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See Version 2
# of 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, write to the:
#
#           Free Software Foundation, Inc.
#           59 Temple Place - Suite 330
#           Boston, MA 02111-1307, USA
#

#
# This is the top level Makefile for the nvidia-settings utility
#

# Below are variables that users can override, either here or on the
# make commandline
#
# CC = gcc
# CFLAGS = -Wall
# PKG_CONFIG = pkg-config
# X11R6_DIR = /usr/X11R6

DESTDIR =
ROOT = $(DESTDIR)
X11R6_LIB_DIR = /usr/lib

# default build target

default: all


# default definitions; can be overwritten by users

SHELL = /bin/sh
INSTALL = install
BUILD_OS := $(shell uname)
BUILD_ARCH := $(shell uname -m)
M4 := m4

ifndef CC
  CC = gcc
endif

ifndef PKG_CONFIG
  PKG_CONFIG = pkg-config
endif

ifndef X11_LIB_DIRS
  ifeq ($(BUILD_OS)-$(BUILD_ARCH),Linux-x86_64)
    X11_LIB_DIRS = -L/usr/X11R6/lib64
  else
    X11_LIB_DIRS = -L/usr/X11R6/lib
  endif
endif

ifndef X11_INC_DIRS
  X11_INC_DIRS = -I/usr/X11R6/include
endif

# define local variables

LOCAL_CFLAGS = -Wall

# the NVDEBUG environment variable controls whether we build debug or retail

ifeq ($(NVDEBUG),1)
  STRIP = true
  LOCAL_CFLAGS += -g -DDEBUG
else
  ifndef STRIP
    STRIP = strip
  endif
  LOCAL_CFLAGS += -O -DNDEBUG
endif

# default prefix
ifdef ROOT
  prefix = $(ROOT)/usr
else
  prefix = /usr/local
endif

# default echo within SunOS sh does not have -n option. Use /usr/ucb/echo instead.
# Solaris install has a different argument syntax 
ifeq ($(BUILD_OS),SunOS)
ECHO=/usr/ucb/echo
define INSTALL_RULE
	$(INSTALL) -m 755 -f $(bindir) $(NVIDIA_SETTINGS)
	mkdir -p $(mandir)
	$(INSTALL) -m 644 -f $(mandir) doc/$(MANPAGE)
endef
LD_RUN_FLAG=-R/usr/X11R6/lib
else
ECHO=echo
define INSTALL_RULE
	$(INSTALL) -m 755 $(NVIDIA_SETTINGS) $(bindir)/$(NVIDIA_SETTINGS)
	mkdir -p $(mandir)
	$(INSTALL) -m 644 doc/$(MANPAGE) $(mandir)
	gzip -9f $(mandir)/$(MANPAGE)
endef
endif

exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
mandir = $(exec_prefix)/share/man/man1

X11_CFLAGS = $(X11_INC_DIRS)

GTK_CFLAGS := $(shell $(PKG_CONFIG) --cflags gtk+-2.0)
GTK_LDFLAGS := $(shell $(PKG_CONFIG) --libs gtk+-2.0)

X11_LIBS := $(X11_LIB_DIRS) -Wl,-Bstatic -lXxf86vm -Wl,-Bdynamic -lX11 -lXext

XNVCTRL_LIB := src/libXNVCtrl/libXNVCtrl.a
XNVCTRL_DIR := src/libXNVCtrl

XF86PARSER_LIB := src/XF86Config-parser/libXF86Config-parser.a
XF86PARSER_DIR := src/XF86Config-parser

CURDIR := $(shell pwd)

RELATIVE_SRCDIRS = \
	doc \
	src \
	src/image_data \
	src/xpm_data \
	src/gtk+-2.x \
	src/libXNVCtrl \
	src/libXNVCtrlAttributes \
	src/XF86Config-parser \
	samples


SRCDIRS := $(addprefix $(CURDIR)/, $(RELATIVE_SRCDIRS))

INC_FLAGS := $(addprefix -I , $(RELATIVE_SRCDIRS))

ALL_CFLAGS = $(CFLAGS) $(LOCAL_CFLAGS) $(X11_CFLAGS) $(GTK_CFLAGS) $(INC_FLAGS)
ALL_LDFLAGS = $(LD_RUN_FLAG) $(LDFLAGS) $(GTK_LDFLAGS) $(X11_LIBS) -ldl

CPPFLAGS = $(ALL_CFLAGS)


NVIDIA_SETTINGS = nvidia-settings
NVIDIA_SETTINGS_VERSION = 1.0

NVIDIA_SETTINGS_DISTDIR = $(NVIDIA_SETTINGS)-$(NVIDIA_SETTINGS_VERSION)
NVIDIA_SETTINGS_DISTDIR_DIRS := \
	$(addprefix $(NVIDIA_SETTINGS_DISTDIR)/, $(RELATIVE_SRCDIRS))

STAMP_C = g_stamp.c

MANPAGE = nvidia-settings.1


# initialize SRC and EXTRA_DIST, then include each of the subdirectory
# Makefiles so that they can append to SRC and EXTRA_DIST

SRC =
EXTRA_DIST =

include $(patsubst %,%/Makefile.inc,$(RELATIVE_SRCDIRS))


# set VPATH 

VPATH = $(RELATIVE_SRCDIRS)


# additional sources (eg: generated sources) can be appended to ALL_SRC

ALL_SRC = $(SRC) $(STAMP_C)


# OBJS and DEPS are constructed such that they are placed into special
# ".objs" and ".deps" subdirectories

OBJS_DIR = .objs
DEPS_DIR = .deps

OBJS := $(patsubst %.c,$(OBJS_DIR)/%.o,$(ALL_SRC))
DEPS := $(patsubst %.c,$(DEPS_DIR)/%.d,$(SRC))

# and now, the build rules:

all: $(NVIDIA_SETTINGS) doc/$(MANPAGE)

install: all
	$(STRIP) $(NVIDIA_SETTINGS)
	$(INSTALL_RULE)

$(OBJS_DIR)/%.o: %.c
	@ mkdir -p $(OBJS_DIR)
	$(CC) -c $(ALL_CFLAGS) $< -o $@

# to generate the dependency files, use the compiler's "-MM" option to
# generate output of the form "foo.o : foo.c foo.h"; then, use sed to
# replace the target with "$(OBJS_DIR)/foo.o $(DEPS_DIR)/foo.d", and
# wrap the prerequisites with $(wildcard ...); the wildcard function
# serves as an existence filter, so that files that are later removed
# from the build do not cause stale references.

$(DEPS_DIR)/%.d: %.c
	@ mkdir -p $(DEPS_DIR)
	@ set -e; b=`basename $* .c` ; \
	$(CC) -MM $(CPPFLAGS) $< \
	| sed \
	-e "s%\\($$b\\)\\.o[ :]*%$(OBJS_DIR)/\\1.o $(DEPS_DIR)/\\1.d : $$\(wildcard %g" \
	-e "s,\([^\\]\)$$,\1)," > $@; \
	[ -s $@ ] || rm -f $@

$(STAMP_C): $(filter-out $(OBJS_DIR)/$(STAMP_C:.c=.o), $(OBJS))
	@ rm -f $@
	@ $(ECHO) -n "const char NV_ID[] = \"nvidia id: " >> $@
	@ $(ECHO) -n "$(NVIDIA_SETTINGS):  " >> $@
	@ $(ECHO) -n "version $(NVIDIA_SETTINGS_VERSION)  " >> $@
	@ $(ECHO) -n "($(shell whoami)@$(shell hostname))  " >> $@
	@ echo    "$(shell date)\";" >> $@
	@ echo    "const char *pNV_ID = NV_ID + 11;" >> $@


%.i : %.c
	$(CC) $(CPPFLAGS) -E -dD $< | sed -e 's/^ $$//' > $@
	indent -kr -nbbo -l96 -sob $@

$(XF86PARSER_LIB):
	$(MAKE) NV_CFLAGS='$(NV_CFLAGS)' -C $(XF86PARSER_DIR)

$(XNVCTRL_LIB):
	$(MAKE) CFLAGS='$(ALL_CFLAGS) -fPIC' LDFLAGS='$(ALL_LDFLAGS)' -C $(XNVCTRL_DIR)

$(NVIDIA_SETTINGS): $(OBJS) $(XNVCTRL_LIB) $(XF86PARSER_LIB)
	$(CC) $(OBJS) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(XNVCTRL_LIB) $(XF86PARSER_LIB) -o $@

.PHONY: $(XF86PARSER_LIB) dist clean clobber

dist: $(XNVCTRL_LIB)
	@ if [ -d $(NVIDIA_SETTINGS_DISTDIR) ]; then \
		chmod 755 $(NVIDIA_SETTINGS_DISTDIR); \
	fi
	@ if [ -f $(NVIDIA_SETTINGS_DISTDIR).tar.gz ]; then \
		chmod 644 $(NVIDIA_SETTINGS_DISTDIR).tar.gz; \
	fi
	rm -rf $(NVIDIA_SETTINGS_DISTDIR) $(NVIDIA_SETTINGS_DISTDIR).tar.gz
	mkdir -p $(NVIDIA_SETTINGS_DISTDIR_DIRS)
	@ for inc_dir in $(RELATIVE_SRCDIRS) .; do \
		EXTRA_DIST=; \
		SRC=; \
		mkdir -p $(NVIDIA_SETTINGS_DISTDIR)/$$inc_dir; \
		for inc_file in `$(MAKE) --makefile $$inc_dir/Makefile.inc dist_list`; do \
			file="$$inc_dir/$$inc_file"; \
			cp $$file $(NVIDIA_SETTINGS_DISTDIR)/$$file; \
			chmod 644 $(NVIDIA_SETTINGS_DISTDIR)/$$file; \
		done; \
	done
	tar czf $(NVIDIA_SETTINGS_DISTDIR).tar.gz $(NVIDIA_SETTINGS_DISTDIR)
	rm -rf $(NVIDIA_SETTINGS_DISTDIR)

clean clobber:
	rm -rf $(OBJS_DIR) $(DEPS_DIR) $(STAMP_C) $(NVIDIA_SETTINGS) $(XNVCTRL_LIB)
	find . -name "*~" -exec rm -f \{\} \;

-include $(DEPS)