提交 e51207f0 编写于 作者: T Thomas Renninger 提交者: Rafael J. Wysocki

cpupower: Provide STATIC variable in Makefile for debug builds

When working on cpupower code, you often want to compile library code into the
binary.

This allows to execute modified cpupower code, even with library changes
without doing "make install"
Signed-off-by: NThomas Renninger <trenn@suse.com>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 7b0e1bf1
...@@ -47,6 +47,11 @@ NLS ?= true ...@@ -47,6 +47,11 @@ NLS ?= true
# cpufreq-bench benchmarking tool # cpufreq-bench benchmarking tool
CPUFREQ_BENCH ?= true CPUFREQ_BENCH ?= true
# Do not build libraries, but build the code in statically
# Libraries are still built, otherwise the Makefile code would
# be rather ugly.
export STATIC ?= false
# Prefix to the directories we're installing to # Prefix to the directories we're installing to
DESTDIR ?= DESTDIR ?=
...@@ -161,6 +166,12 @@ ifeq ($(strip $(CPUFREQ_BENCH)),true) ...@@ -161,6 +166,12 @@ ifeq ($(strip $(CPUFREQ_BENCH)),true)
COMPILE_BENCH += compile-bench COMPILE_BENCH += compile-bench
endif endif
ifeq ($(strip $(STATIC)),true)
UTIL_OBJS += $(LIB_OBJS)
UTIL_HEADERS += $(LIB_HEADERS)
UTIL_SRC += $(LIB_SRC)
endif
CFLAGS += $(WARNINGS) CFLAGS += $(WARNINGS)
ifeq ($(strip $(V)),false) ifeq ($(strip $(V)),false)
...@@ -209,7 +220,11 @@ $(OUTPUT)%.o: %.c ...@@ -209,7 +220,11 @@ $(OUTPUT)%.o: %.c
$(OUTPUT)cpupower: $(UTIL_OBJS) $(OUTPUT)libcpupower.so.$(LIB_MAJ) $(OUTPUT)cpupower: $(UTIL_OBJS) $(OUTPUT)libcpupower.so.$(LIB_MAJ)
$(ECHO) " CC " $@ $(ECHO) " CC " $@
ifeq ($(strip $(STATIC)),true)
$(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lrt -lpci -L$(OUTPUT) -o $@
else
$(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lcpupower -lrt -lpci -L$(OUTPUT) -o $@ $(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lcpupower -lrt -lpci -L$(OUTPUT) -o $@
endif
$(QUIET) $(STRIPCMD) $@ $(QUIET) $(STRIPCMD) $@
$(OUTPUT)po/$(PACKAGE).pot: $(UTIL_SRC) $(OUTPUT)po/$(PACKAGE).pot: $(UTIL_SRC)
...@@ -291,7 +306,11 @@ install-bench: ...@@ -291,7 +306,11 @@ install-bench:
@#DESTDIR must be set from outside to survive @#DESTDIR must be set from outside to survive
@sbindir=$(sbindir) bindir=$(bindir) docdir=$(docdir) confdir=$(confdir) $(MAKE) -C bench O=$(OUTPUT) install @sbindir=$(sbindir) bindir=$(bindir) docdir=$(docdir) confdir=$(confdir) $(MAKE) -C bench O=$(OUTPUT) install
ifeq ($(strip $(STATIC)),true)
install: all install-tools install-man $(INSTALL_NLS) $(INSTALL_BENCH)
else
install: all install-lib install-tools install-man $(INSTALL_NLS) $(INSTALL_BENCH) install: all install-lib install-tools install-man $(INSTALL_NLS) $(INSTALL_BENCH)
endif
uninstall: uninstall:
- rm -f $(DESTDIR)${libdir}/libcpupower.* - rm -f $(DESTDIR)${libdir}/libcpupower.*
......
...@@ -5,9 +5,15 @@ ifneq ($(O),) ...@@ -5,9 +5,15 @@ ifneq ($(O),)
endif endif
endif endif
ifeq ($(strip $(STATIC)),true)
LIBS = -L../ -L$(OUTPUT) -lm
OBJS = $(OUTPUT)main.o $(OUTPUT)parse.o $(OUTPUT)system.o $(OUTPUT)benchmark.o \
$(OUTPUT)../lib/cpufreq.o $(OUTPUT)../lib/sysfs.o
else
LIBS = -L../ -L$(OUTPUT) -lm -lcpupower LIBS = -L../ -L$(OUTPUT) -lm -lcpupower
OBJS = $(OUTPUT)main.o $(OUTPUT)parse.o $(OUTPUT)system.o $(OUTPUT)benchmark.o OBJS = $(OUTPUT)main.o $(OUTPUT)parse.o $(OUTPUT)system.o $(OUTPUT)benchmark.o
endif
CFLAGS += -D_GNU_SOURCE -I../lib -DDEFAULT_CONFIG_FILE=\"$(confdir)/cpufreq-bench.conf\" CFLAGS += -D_GNU_SOURCE -I../lib -DDEFAULT_CONFIG_FILE=\"$(confdir)/cpufreq-bench.conf\"
$(OUTPUT)%.o : %.c $(OUTPUT)%.o : %.c
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册