diff options
Diffstat (limited to 'tools/power')
-rw-r--r-- | tools/power/cpupower/Makefile | 87 | ||||
-rw-r--r-- | tools/power/cpupower/bench/Makefile | 23 |
2 files changed, 71 insertions, 39 deletions
diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile index 19526054d72..a93e06cfcc2 100644 --- a/tools/power/cpupower/Makefile +++ b/tools/power/cpupower/Makefile | |||
@@ -19,6 +19,16 @@ | |||
19 | # along with this program; if not, write to the Free Software | 19 | # along with this program; if not, write to the Free Software |
20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | # | 21 | # |
22 | OUTPUT=./ | ||
23 | ifeq ("$(origin O)", "command line") | ||
24 | OUTPUT := $(O)/ | ||
25 | endif | ||
26 | |||
27 | ifneq ($(OUTPUT),) | ||
28 | # check that the output directory actually exists | ||
29 | OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd) | ||
30 | $(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist)) | ||
31 | endif | ||
22 | 32 | ||
23 | # --- CONFIGURATION BEGIN --- | 33 | # --- CONFIGURATION BEGIN --- |
24 | 34 | ||
@@ -87,6 +97,7 @@ AR = $(CROSS)ar | |||
87 | STRIP = $(CROSS)strip | 97 | STRIP = $(CROSS)strip |
88 | RANLIB = $(CROSS)ranlib | 98 | RANLIB = $(CROSS)ranlib |
89 | HOSTCC = gcc | 99 | HOSTCC = gcc |
100 | MKDIR = mkdir | ||
90 | 101 | ||
91 | 102 | ||
92 | # Now we set up the build system | 103 | # Now we set up the build system |
@@ -95,7 +106,7 @@ HOSTCC = gcc | |||
95 | # set up PWD so that older versions of make will work with our build. | 106 | # set up PWD so that older versions of make will work with our build. |
96 | PWD = $(shell pwd) | 107 | PWD = $(shell pwd) |
97 | 108 | ||
98 | GMO_FILES = ${shell for HLANG in ${LANGUAGES}; do echo po/$$HLANG.gmo; done;} | 109 | GMO_FILES = ${shell for HLANG in ${LANGUAGES}; do echo $(OUTPUT)po/$$HLANG.gmo; done;} |
99 | 110 | ||
100 | export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS | 111 | export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS |
101 | 112 | ||
@@ -122,15 +133,18 @@ UTIL_OBJS = utils/helpers/amd.o utils/helpers/topology.o utils/helpers/msr.o \ | |||
122 | utils/cpupower.o utils/cpufreq-info.o utils/cpufreq-set.o \ | 133 | utils/cpupower.o utils/cpufreq-info.o utils/cpufreq-set.o \ |
123 | utils/cpupower-set.o utils/cpupower-info.o utils/cpuidle-info.o | 134 | utils/cpupower-set.o utils/cpupower-info.o utils/cpuidle-info.o |
124 | 135 | ||
136 | UTIL_SRC := $(UTIL_OBJS:.o=.c) | ||
137 | |||
138 | UTIL_OBJS := $(addprefix $(OUTPUT),$(UTIL_OBJS)) | ||
139 | |||
125 | UTIL_HEADERS = utils/helpers/helpers.h utils/idle_monitor/cpupower-monitor.h \ | 140 | UTIL_HEADERS = utils/helpers/helpers.h utils/idle_monitor/cpupower-monitor.h \ |
126 | utils/helpers/bitmask.h \ | 141 | utils/helpers/bitmask.h \ |
127 | utils/idle_monitor/idle_monitors.h utils/idle_monitor/idle_monitors.def | 142 | utils/idle_monitor/idle_monitors.h utils/idle_monitor/idle_monitors.def |
128 | 143 | ||
129 | UTIL_SRC := $(UTIL_OBJS:.o=.c) | ||
130 | |||
131 | LIB_HEADERS = lib/cpufreq.h lib/sysfs.h | 144 | LIB_HEADERS = lib/cpufreq.h lib/sysfs.h |
132 | LIB_SRC = lib/cpufreq.c lib/sysfs.c | 145 | LIB_SRC = lib/cpufreq.c lib/sysfs.c |
133 | LIB_OBJS = lib/cpufreq.o lib/sysfs.o | 146 | LIB_OBJS = lib/cpufreq.o lib/sysfs.o |
147 | LIB_OBJS := $(addprefix $(OUTPUT),$(LIB_OBJS)) | ||
134 | 148 | ||
135 | CFLAGS += -pipe | 149 | CFLAGS += -pipe |
136 | 150 | ||
@@ -168,79 +182,90 @@ endif | |||
168 | 182 | ||
169 | # the actual make rules | 183 | # the actual make rules |
170 | 184 | ||
171 | all: libcpupower cpupower $(COMPILE_NLS) $(COMPILE_BENCH) | 185 | all: libcpupower $(OUTPUT)cpupower $(COMPILE_NLS) $(COMPILE_BENCH) |
172 | 186 | ||
173 | lib/%.o: $(LIB_SRC) $(LIB_HEADERS) | 187 | $(OUTPUT)lib/%.o: $(LIB_SRC) $(LIB_HEADERS) |
174 | $(ECHO) " CC " $@ | 188 | $(ECHO) " CC " $@ |
175 | $(QUIET) $(CC) $(CFLAGS) -fPIC -o $@ -c lib/$*.c | 189 | $(QUIET) $(CC) $(CFLAGS) -fPIC -o $@ -c lib/$*.c |
176 | 190 | ||
177 | libcpupower.so.$(LIB_MAJ): $(LIB_OBJS) | 191 | $(OUTPUT)libcpupower.so.$(LIB_MAJ): $(LIB_OBJS) |
178 | $(ECHO) " LD " $@ | 192 | $(ECHO) " LD " $@ |
179 | $(QUIET) $(CC) -shared $(CFLAGS) $(LDFLAGS) -o $@ \ | 193 | $(QUIET) $(CC) -shared $(CFLAGS) $(LDFLAGS) -o $@ \ |
180 | -Wl,-soname,libcpupower.so.$(LIB_MIN) $(LIB_OBJS) | 194 | -Wl,-soname,libcpupower.so.$(LIB_MIN) $(LIB_OBJS) |
181 | @ln -sf $@ libcpupower.so | 195 | @ln -sf $(@F) $(OUTPUT)libcpupower.so |
182 | @ln -sf $@ libcpupower.so.$(LIB_MIN) | 196 | @ln -sf $(@F) $(OUTPUT)libcpupower.so.$(LIB_MIN) |
183 | 197 | ||
184 | libcpupower: libcpupower.so.$(LIB_MAJ) | 198 | libcpupower: $(OUTPUT)libcpupower.so.$(LIB_MAJ) |
185 | 199 | ||
186 | # Let all .o files depend on its .c file and all headers | 200 | # Let all .o files depend on its .c file and all headers |
187 | # Might be worth to put this into utils/Makefile at some point of time | 201 | # Might be worth to put this into utils/Makefile at some point of time |
188 | $(UTIL_OBJS): $(UTIL_HEADERS) | 202 | $(UTIL_OBJS): $(UTIL_HEADERS) |
189 | 203 | ||
190 | .c.o: | 204 | $(OUTPUT)%.o: %.c |
191 | $(ECHO) " CC " $@ | 205 | $(ECHO) " CC " $@ |
192 | $(QUIET) $(CC) $(CFLAGS) -I./lib -I ./utils -o $@ -c $*.c | 206 | $(QUIET) $(CC) $(CFLAGS) -I./lib -I ./utils -o $@ -c $*.c |
193 | 207 | ||
194 | cpupower: $(UTIL_OBJS) libcpupower.so.$(LIB_MAJ) | 208 | $(OUTPUT)cpupower: $(UTIL_OBJS) $(OUTPUT)libcpupower.so.$(LIB_MAJ) |
195 | $(ECHO) " CC " $@ | 209 | $(ECHO) " CC " $@ |
196 | $(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lcpupower -lrt -lpci -L. -o $@ | 210 | $(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lcpupower -lrt -lpci -L$(OUTPUT) -o $@ |
197 | $(QUIET) $(STRIPCMD) $@ | 211 | $(QUIET) $(STRIPCMD) $@ |
198 | 212 | ||
199 | po/$(PACKAGE).pot: $(UTIL_SRC) | 213 | $(OUTPUT)po/$(PACKAGE).pot: $(UTIL_SRC) |
200 | $(ECHO) " GETTEXT " $@ | 214 | $(ECHO) " GETTEXT " $@ |
201 | $(QUIET) xgettext --default-domain=$(PACKAGE) --add-comments \ | 215 | $(QUIET) xgettext --default-domain=$(PACKAGE) --add-comments \ |
202 | --keyword=_ --keyword=N_ $(UTIL_SRC) -p $(@D) -o $(@F) | 216 | --keyword=_ --keyword=N_ $(UTIL_SRC) -p $(@D) -o $(@F) |
203 | 217 | ||
204 | po/%.gmo: po/%.po | 218 | $(OUTPUT)po/%.gmo: po/%.po |
205 | $(ECHO) " MSGFMT " $@ | 219 | $(ECHO) " MSGFMT " $@ |
206 | $(QUIET) msgfmt -o $@ po/$*.po | 220 | $(QUIET) msgfmt -o $@ po/$*.po |
207 | 221 | ||
208 | create-gmo: ${GMO_FILES} | 222 | create-gmo: ${GMO_FILES} |
209 | 223 | ||
210 | update-po: po/$(PACKAGE).pot | 224 | update-po: $(OUTPUT)po/$(PACKAGE).pot |
211 | $(ECHO) " MSGMRG " $@ | 225 | $(ECHO) " MSGMRG " $@ |
212 | $(QUIET) @for HLANG in $(LANGUAGES); do \ | 226 | $(QUIET) @for HLANG in $(LANGUAGES); do \ |
213 | echo -n "Updating $$HLANG "; \ | 227 | echo -n "Updating $$HLANG "; \ |
214 | if msgmerge po/$$HLANG.po po/$(PACKAGE).pot -o \ | 228 | if msgmerge po/$$HLANG.po $< -o \ |
215 | po/$$HLANG.new.po; then \ | 229 | $(OUTPUT)po/$$HLANG.new.po; then \ |
216 | mv -f po/$$HLANG.new.po po/$$HLANG.po; \ | 230 | mv -f $(OUTPUT)po/$$HLANG.new.po $(OUTPUT)po/$$HLANG.po; \ |
217 | else \ | 231 | else \ |
218 | echo "msgmerge for $$HLANG failed!"; \ | 232 | echo "msgmerge for $$HLANG failed!"; \ |
219 | rm -f po/$$HLANG.new.po; \ | 233 | rm -f $(OUTPUT)po/$$HLANG.new.po; \ |
220 | fi; \ | 234 | fi; \ |
221 | done; | 235 | done; |
222 | 236 | ||
223 | compile-bench: libcpupower.so.$(LIB_MAJ) | 237 | compile-bench: $(OUTPUT)libcpupower.so.$(LIB_MAJ) |
224 | @V=$(V) confdir=$(confdir) $(MAKE) -C bench | 238 | @V=$(V) confdir=$(confdir) $(MAKE) -C bench O=$(OUTPUT) |
239 | |||
240 | # we compile into subdirectories. if the target directory is not the | ||
241 | # source directory, they might not exists. So we depend the various | ||
242 | # files onto their directories. | ||
243 | DIRECTORY_DEPS = $(LIB_OBJS) $(UTIL_OBJS) $(GMO_FILES) | ||
244 | $(DIRECTORY_DEPS): | $(sort $(dir $(DIRECTORY_DEPS))) | ||
245 | |||
246 | # In the second step, we make a rule to actually create these directories | ||
247 | $(sort $(dir $(DIRECTORY_DEPS))): | ||
248 | $(ECHO) " MKDIR " $@ | ||
249 | $(QUIET) $(MKDIR) -p $@ 2>/dev/null | ||
225 | 250 | ||
226 | clean: | 251 | clean: |
227 | -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \ | 252 | -find $(OUTPUT) \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \ |
228 | | xargs rm -f | 253 | | xargs rm -f |
229 | -rm -f cpupower | 254 | -rm -f $(OUTPUT)cpupower |
230 | -rm -f libcpupower.so* | 255 | -rm -f $(OUTPUT)libcpupower.so* |
231 | -rm -rf po/*.gmo po/*.pot | 256 | -rm -rf $(OUTPUT)po/*.{gmo,pot} |
232 | $(MAKE) -C bench clean | 257 | $(MAKE) -C bench O=$(OUTPUT) clean |
233 | 258 | ||
234 | 259 | ||
235 | install-lib: | 260 | install-lib: |
236 | $(INSTALL) -d $(DESTDIR)${libdir} | 261 | $(INSTALL) -d $(DESTDIR)${libdir} |
237 | $(CP) libcpupower.so* $(DESTDIR)${libdir}/ | 262 | $(CP) $(OUTPUT)libcpupower.so* $(DESTDIR)${libdir}/ |
238 | $(INSTALL) -d $(DESTDIR)${includedir} | 263 | $(INSTALL) -d $(DESTDIR)${includedir} |
239 | $(INSTALL_DATA) lib/cpufreq.h $(DESTDIR)${includedir}/cpufreq.h | 264 | $(INSTALL_DATA) lib/cpufreq.h $(DESTDIR)${includedir}/cpufreq.h |
240 | 265 | ||
241 | install-tools: | 266 | install-tools: |
242 | $(INSTALL) -d $(DESTDIR)${bindir} | 267 | $(INSTALL) -d $(DESTDIR)${bindir} |
243 | $(INSTALL_PROGRAM) cpupower $(DESTDIR)${bindir} | 268 | $(INSTALL_PROGRAM) $(OUTPUT)cpupower $(DESTDIR)${bindir} |
244 | 269 | ||
245 | install-man: | 270 | install-man: |
246 | $(INSTALL_DATA) -D man/cpupower.1 $(DESTDIR)${mandir}/man1/cpupower.1 | 271 | $(INSTALL_DATA) -D man/cpupower.1 $(DESTDIR)${mandir}/man1/cpupower.1 |
@@ -253,13 +278,13 @@ install-man: | |||
253 | install-gmo: | 278 | install-gmo: |
254 | $(INSTALL) -d $(DESTDIR)${localedir} | 279 | $(INSTALL) -d $(DESTDIR)${localedir} |
255 | for HLANG in $(LANGUAGES); do \ | 280 | for HLANG in $(LANGUAGES); do \ |
256 | echo '$(INSTALL_DATA) -D po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo'; \ | 281 | echo '$(INSTALL_DATA) -D $(OUTPUT)po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo'; \ |
257 | $(INSTALL_DATA) -D po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \ | 282 | $(INSTALL_DATA) -D $(OUTPUT)po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \ |
258 | done; | 283 | done; |
259 | 284 | ||
260 | install-bench: | 285 | install-bench: |
261 | @#DESTDIR must be set from outside to survive | 286 | @#DESTDIR must be set from outside to survive |
262 | @sbindir=$(sbindir) bindir=$(bindir) docdir=$(docdir) confdir=$(confdir) $(MAKE) -C bench install | 287 | @sbindir=$(sbindir) bindir=$(bindir) docdir=$(docdir) confdir=$(confdir) $(MAKE) -C bench O=$(OUTPUT) install |
263 | 288 | ||
264 | install: all install-lib install-tools install-man $(INSTALL_NLS) $(INSTALL_BENCH) | 289 | install: all install-lib install-tools install-man $(INSTALL_NLS) $(INSTALL_BENCH) |
265 | 290 | ||
diff --git a/tools/power/cpupower/bench/Makefile b/tools/power/cpupower/bench/Makefile index 2b67606fc3e..7ec7021a29c 100644 --- a/tools/power/cpupower/bench/Makefile +++ b/tools/power/cpupower/bench/Makefile | |||
@@ -1,29 +1,36 @@ | |||
1 | LIBS = -L../ -lm -lcpupower | 1 | OUTPUT := ./ |
2 | ifeq ("$(origin O)", "command line") | ||
3 | ifneq ($(O),) | ||
4 | OUTPUT := $(O)/ | ||
5 | endif | ||
6 | endif | ||
2 | 7 | ||
3 | OBJS = main.o parse.o system.o benchmark.o | 8 | LIBS = -L../ -L$(OUTPUT) -lm -lcpupower |
9 | |||
10 | OBJS = $(OUTPUT)main.o $(OUTPUT)parse.o $(OUTPUT)system.o $(OUTPUT)benchmark.o | ||
4 | CFLAGS += -D_GNU_SOURCE -I../lib -DDEFAULT_CONFIG_FILE=\"$(confdir)/cpufreq-bench.conf\" | 11 | CFLAGS += -D_GNU_SOURCE -I../lib -DDEFAULT_CONFIG_FILE=\"$(confdir)/cpufreq-bench.conf\" |
5 | 12 | ||
6 | %.o : %.c | 13 | $(OUTPUT)%.o : %.c |
7 | $(ECHO) " CC " $@ | 14 | $(ECHO) " CC " $@ |
8 | $(QUIET) $(CC) -c $(CFLAGS) $< -o $@ | 15 | $(QUIET) $(CC) -c $(CFLAGS) $< -o $@ |
9 | 16 | ||
10 | cpufreq-bench: $(OBJS) | 17 | $(OUTPUT)cpufreq-bench: $(OBJS) |
11 | $(ECHO) " CC " $@ | 18 | $(ECHO) " CC " $@ |
12 | $(QUIET) $(CC) -o $@ $(CFLAGS) $(OBJS) $(LIBS) | 19 | $(QUIET) $(CC) -o $@ $(CFLAGS) $(OBJS) $(LIBS) |
13 | 20 | ||
14 | all: cpufreq-bench | 21 | all: $(OUTPUT)cpufreq-bench |
15 | 22 | ||
16 | install: | 23 | install: |
17 | mkdir -p $(DESTDIR)/$(sbindir) | 24 | mkdir -p $(DESTDIR)/$(sbindir) |
18 | mkdir -p $(DESTDIR)/$(bindir) | 25 | mkdir -p $(DESTDIR)/$(bindir) |
19 | mkdir -p $(DESTDIR)/$(docdir) | 26 | mkdir -p $(DESTDIR)/$(docdir) |
20 | mkdir -p $(DESTDIR)/$(confdir) | 27 | mkdir -p $(DESTDIR)/$(confdir) |
21 | install -m 755 cpufreq-bench $(DESTDIR)/$(sbindir)/cpufreq-bench | 28 | install -m 755 $(OUTPUT)cpufreq-bench $(DESTDIR)/$(sbindir)/cpufreq-bench |
22 | install -m 755 cpufreq-bench_plot.sh $(DESTDIR)/$(bindir)/cpufreq-bench_plot.sh | 29 | install -m 755 cpufreq-bench_plot.sh $(DESTDIR)/$(bindir)/cpufreq-bench_plot.sh |
23 | install -m 644 README-BENCH $(DESTDIR)/$(docdir)/README-BENCH | 30 | install -m 644 README-BENCH $(DESTDIR)/$(docdir)/README-BENCH |
24 | install -m 755 cpufreq-bench_script.sh $(DESTDIR)/$(docdir)/cpufreq-bench_script.sh | 31 | install -m 755 cpufreq-bench_script.sh $(DESTDIR)/$(docdir)/cpufreq-bench_script.sh |
25 | install -m 644 example.cfg $(DESTDIR)/$(confdir)/cpufreq-bench.conf | 32 | install -m 644 example.cfg $(DESTDIR)/$(confdir)/cpufreq-bench.conf |
26 | 33 | ||
27 | clean: | 34 | clean: |
28 | rm -f *.o | 35 | rm -f $(OUTPUT)*.o |
29 | rm -f cpufreq-bench | 36 | rm -f $(OUTPUT)cpufreq-bench |