Commit c03ed380 authored by Aaron Plattner's avatar Aaron Plattner

Embed the .png files into the libnvidia-gtk[23] libraries

These will be used later to decompress the images at runtime.

Generate headers that define the start and end symbols for these.
parent 4e75f74b
......@@ -219,6 +219,8 @@ XCP_OBJS = $(call BUILD_OBJECT_LIST,$(XCP_SRC))
GTK2_OBJS = $(call BUILD_OBJECT_LIST_WITH_DIR,$(GTK_SRC),$(GTK2LIB_DIR))
GTK3_OBJS = $(call BUILD_OBJECT_LIST_WITH_DIR,$(GTK_SRC),$(GTK3LIB_DIR))
IMAGE_OBJS = $(addprefix $(OUTPUTDIR)/,$(addsuffix .o,$(notdir $(IMAGE_FILES))))
IMAGE_HEADERS = $(addprefix $(OUTPUTDIR)/,$(addsuffix .h,$(notdir $(IMAGE_FILES))))
CFLAGS += -I .
CFLAGS += -I image_data
......@@ -252,6 +254,13 @@ ifneq ($(NV_USE_BUNDLED_LIBJANSSON),0)
$(call BUILD_OBJECT_LIST,$(JANSSON_SRC)): CFLAGS += $(JANSSON_CFLAGS)
endif
define BINARY_DATA_HEADER_RULE
$$(OUTPUTDIR)/$(notdir $(1)).h:
$(at_if_quiet){ \
$$(PRINTF) "extern const char _binary_$(subst .,_,$(notdir $(1)))_start[];\n"; \
$$(PRINTF) "extern const char _binary_$(subst .,_,$(notdir $(1)))_end[];\n"; \
} > $$@
endef
##############################################################################
# build rules
......@@ -282,21 +291,21 @@ $(NVIDIA_SETTINGS).unstripped: $(OBJS) $(XNVCTRL_ARCHIVE)
-rdynamic -o $@ $(OBJS) $(XNVCTRL_ARCHIVE) $(LIBS)
$(eval $(call DEBUG_INFO_RULES, $(GTK2LIB)))
$(GTK2LIB).unstripped: $(GTK2_OBJS) $(XCP_OBJS) $(VERSION_MK)
$(GTK2LIB).unstripped: $(GTK2_OBJS) $(XCP_OBJS) $(IMAGE_OBJS) $(VERSION_MK)
$(call quiet_cmd,LINK) -shared $(CFLAGS) $(LDFLAGS) $(BIN_LDFLAGS) \
$(XNVCTRL_ARCHIVE) $(LIBS) $(GTK2_LIBS) \
-Wl,--unresolved-symbols=ignore-all -o $@ \
-Wl,-soname -Wl,$(GTK2LIB_SONAME) \
$(GTK2_OBJS) $(XCP_OBJS)
$(GTK2_OBJS) $(IMAGE_OBJS) $(XCP_OBJS)
ifdef BUILD_GTK3LIB
$(eval $(call DEBUG_INFO_RULES, $(GTK3LIB)))
$(GTK3LIB).unstripped: $(GTK3_OBJS) $(XCP_OBJS) $(VERSION_MK)
$(GTK3LIB).unstripped: $(GTK3_OBJS) $(XCP_OBJS) $(IMAGE_OBJS) $(VERSION_MK)
$(call quiet_cmd,LINK) -shared $(CFLAGS) $(LDFLAGS) $(BIN_LDFLAGS) \
$(XNVCTRL_ARCHIVE) $(LIBS) $(GTK3_LIBS) \
-Wl,--unresolved-symbols=ignore-all -o $@ \
-Wl,-soname -Wl,$(GTK3LIB_SONAME) \
$(GTK3_OBJS) $(XCP_OBJS)
$(GTK3_OBJS) $(XCP_OBJS) $(IMAGE_OBJS)
endif
# define the rule to build each object file
......@@ -315,7 +324,8 @@ build-xnvctrl:
clean clobber:
rm -rf $(NVIDIA_SETTINGS) *~ $(STAMP_C) \
$(OUTPUTDIR)/*.o $(OUTPUTDIR)/*.d \
$(GTK2LIB) $(GTK3LIB) $(GTK2LIB_DIR) $(GTK3LIB_DIR)
$(GTK2LIB) $(GTK3LIB) $(GTK2LIB_DIR) $(GTK3LIB_DIR) \
$(IMAGE_HEADERS)
@$(MAKE) -C $(XNVCTRL_DIR) -f $(XNVCTRL_MAKEFILE) clean
$(foreach src,$(GTK_SRC), \
......@@ -326,3 +336,14 @@ $(foreach src,$(GTK_SRC), \
$(eval $(call DEFINE_OBJECT_RULE_WITH_DIR,TARGET,$(src),$(GTK3LIB_DIR))))
endif
# Build $(IMAGE_OBJS)
$(foreach png,$(IMAGE_FILES), \
$(eval $(call READ_ONLY_OBJECT_FROM_FILE_RULE,$(png))))
# Build $(IMAGE_HEADERS)
$(foreach png,$(IMAGE_FILES), \
$(eval $(call BINARY_DATA_HEADER_RULE,$(png))))
$(GTK2_OBJS): $(IMAGE_HEADERS)
ifdef BUILD_GTK3LIB
$(GTK3_OBJS): $(IMAGE_HEADERS)
endif
......@@ -80,6 +80,7 @@ HOSTNAME_CMD ?= hostname
DATE ?= date
GZIP_CMD ?= gzip
CHMOD ?= chmod
OBJCOPY ?= objcopy
NV_AUTO_DEPEND ?= 1
NV_VERBOSE ?= 0
......@@ -271,10 +272,14 @@ endif
NV_MODULE_LOGGING_NAME ?=
ifeq ($(NV_VERBOSE),0)
quiet_cmd = @$(PRINTF) \
at_if_quiet := @
quiet_cmd_no_at = $(PRINTF) \
" $(if $(NV_MODULE_LOGGING_NAME),[ %-17.17s ],%s) $(quiet_$(1))\n" \
"$(NV_MODULE_LOGGING_NAME)" && $($(1))
quiet_cmd = @$(quiet_cmd_no_at)
else
at_if_quiet :=
quiet_cmd_no_at = $($(1))
quiet_cmd = $($(1))
endif
......@@ -295,6 +300,8 @@ quiet_HOST_LINK = $(call define_quiet_cmd,HOST_LINK ,$@)
quiet_M4 = $(call define_quiet_cmd,M4 ,$<)
quiet_STRIP_CMD = $(call define_quiet_cmd,STRIP ,$@)
quiet_HARDLINK = $(call define_quiet_cmd,HARDLINK ,$@)
quiet_LD = $(call define_quiet_cmd,LD ,$@)
quiet_OBJCOPY = $(call define_quiet_cmd,OBJCOPY ,$@)
##############################################################################
# Tell gmake to delete the target of a rule if it has changed and its
......@@ -447,3 +454,30 @@ define DEFINE_STAMP_C_RULE
@ $$(PRINTF) "%s\n" "const char *pNV_ID = NV_ID + 11;" >> $$@
endef
##############################################################################
# Define rules that can be used for embedding a file into an ELF object that
# contains the raw contents of that file and symbols pointing to the embedded
# data.
#
# Note that objcopy will name the symbols in the resulting object file based on
# the filename specified in $(1). For example,
#
# $(eval $(call $(READ_ONLY_OBJECT_FROM_FILE_RULE),a/b/c))
#
# will create an object named $(OUTPUTDIR)/c.o with the symbols _binary_c_start,
# _binary_c_end, and _binary_c_size.
#
# Arguments:
# $(1): Path to the file to convert
##############################################################################
define READ_ONLY_OBJECT_FROM_FILE_RULE
$$(OUTPUTDIR)/$$(notdir $(1)).o: $(1)
$(at_if_quiet)cd $$(dir $(1)); \
$$(call quiet_cmd_no_at,LD) -r -z noexecstack --format=binary \
$$(notdir $(1)) -o $$(OUTPUTDIR_ABSOLUTE)/$$(notdir $$@)
$$(call quiet_cmd,OBJCOPY) \
--rename-section .data=.rodata,contents,alloc,load,data,readonly \
$$@
endef
......@@ -42,84 +42,86 @@ NVIDIA_SETTINGS_EXTRA_DIST += $(SRC_EXTRA_DIST)
#
IMAGE_DATA_SRC +=
IMAGE_FILES += image_data/antialias.png
IMAGE_FILES += image_data/background.png
IMAGE_FILES += image_data/background_tall.png
IMAGE_FILES += image_data/bnc_cable.png
IMAGE_FILES += image_data/bsd.png
IMAGE_FILES += image_data/clock.png
IMAGE_FILES += image_data/color.png
IMAGE_FILES += image_data/config.png
IMAGE_FILES += image_data/crt.png
IMAGE_FILES += image_data/dfp.png
IMAGE_FILES += image_data/display_config.png
IMAGE_FILES += image_data/framelock.png
IMAGE_FILES += image_data/glx.png
IMAGE_FILES += image_data/gpu.png
IMAGE_FILES += image_data/gvi.png
IMAGE_FILES += image_data/help.png
IMAGE_FILES += image_data/led_green.png
IMAGE_FILES += image_data/led_grey.png
IMAGE_FILES += image_data/led_red.png
IMAGE_FILES += image_data/logo.png
IMAGE_FILES += image_data/logo_tall.png
IMAGE_FILES += image_data/nvidia_icon.png
IMAGE_FILES += image_data/opengl.png
IMAGE_FILES += image_data/penguin.png
IMAGE_FILES += image_data/rj45_input.png
IMAGE_FILES += image_data/rj45_output.png
IMAGE_FILES += image_data/rj45_unused.png
IMAGE_FILES += image_data/sdi.png
IMAGE_FILES += image_data/sdi_shared_sync_bnc.png
IMAGE_FILES += image_data/server_licensing.png
IMAGE_FILES += image_data/slimm.png
IMAGE_FILES += image_data/solaris.png
IMAGE_FILES += image_data/svp_3dvp.png
IMAGE_FILES += image_data/thermal.png
IMAGE_FILES += image_data/vcs.png
IMAGE_FILES += image_data/vdpau.png
IMAGE_FILES += image_data/x.png
IMAGE_FILES += image_data/xvideo.png
NVIDIA_SETTINGS_EXTRA_DIST += $(IMAGE_FILES)
IMAGE_DATA_EXTRA_DIST += image_data/HOWTO-ADD-IMAGES
IMAGE_DATA_EXTRA_DIST += image_data/antialias.png
IMAGE_DATA_EXTRA_DIST += image_data/antialias_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/background.png
IMAGE_DATA_EXTRA_DIST += image_data/background_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/background_tall.png
IMAGE_DATA_EXTRA_DIST += image_data/background_tall_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/bnc_cable.png
IMAGE_DATA_EXTRA_DIST += image_data/bnc_cable_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/bsd.png
IMAGE_DATA_EXTRA_DIST += image_data/bsd_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/clock.png
IMAGE_DATA_EXTRA_DIST += image_data/clock_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/color.png
IMAGE_DATA_EXTRA_DIST += image_data/color_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/config.png
IMAGE_DATA_EXTRA_DIST += image_data/config_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/crt.png
IMAGE_DATA_EXTRA_DIST += image_data/crt_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/dfp.png
IMAGE_DATA_EXTRA_DIST += image_data/dfp_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/display_config.png
IMAGE_DATA_EXTRA_DIST += image_data/display_config_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/framelock.png
IMAGE_DATA_EXTRA_DIST += image_data/framelock_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/glx.png
IMAGE_DATA_EXTRA_DIST += image_data/glx_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/gpu.png
IMAGE_DATA_EXTRA_DIST += image_data/gpu_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/gvi.png
IMAGE_DATA_EXTRA_DIST += image_data/gvi_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/help.png
IMAGE_DATA_EXTRA_DIST += image_data/help_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/led_green.png
IMAGE_DATA_EXTRA_DIST += image_data/led_green_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/led_grey.png
IMAGE_DATA_EXTRA_DIST += image_data/led_grey_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/led_red.png
IMAGE_DATA_EXTRA_DIST += image_data/led_red_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/logo.png
IMAGE_DATA_EXTRA_DIST += image_data/logo_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/logo_tall.png
IMAGE_DATA_EXTRA_DIST += image_data/logo_tall_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/nvidia_icon.png
IMAGE_DATA_EXTRA_DIST += image_data/nvidia_icon_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/opengl.png
IMAGE_DATA_EXTRA_DIST += image_data/opengl_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/penguin.png
IMAGE_DATA_EXTRA_DIST += image_data/penguin_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/png_to_c_header.sh
IMAGE_DATA_EXTRA_DIST += image_data/rj45_input.png
IMAGE_DATA_EXTRA_DIST += image_data/rj45_input_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/rj45_output.png
IMAGE_DATA_EXTRA_DIST += image_data/rj45_output_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/rj45_unused.png
IMAGE_DATA_EXTRA_DIST += image_data/rj45_unused_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/sdi.png
IMAGE_DATA_EXTRA_DIST += image_data/sdi_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/sdi_shared_sync_bnc.png
IMAGE_DATA_EXTRA_DIST += image_data/sdi_shared_sync_bnc_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/server_licensing.png
IMAGE_DATA_EXTRA_DIST += image_data/server_licensing_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/slimm.png
IMAGE_DATA_EXTRA_DIST += image_data/slimm_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/solaris.png
IMAGE_DATA_EXTRA_DIST += image_data/solaris_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/svp_3dvp.png
IMAGE_DATA_EXTRA_DIST += image_data/svp_3dvp_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/thermal.png
IMAGE_DATA_EXTRA_DIST += image_data/thermal_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/vcs.png
IMAGE_DATA_EXTRA_DIST += image_data/vcs_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/vdpau.png
IMAGE_DATA_EXTRA_DIST += image_data/vdpau_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/x.png
IMAGE_DATA_EXTRA_DIST += image_data/x_pixdata.h
IMAGE_DATA_EXTRA_DIST += image_data/xvideo.png
IMAGE_DATA_EXTRA_DIST += image_data/xvideo_pixdata.h
NVIDIA_SETTINGS_EXTRA_DIST += $(IMAGE_DATA_EXTRA_DIST)
......
......@@ -80,6 +80,7 @@ HOSTNAME_CMD ?= hostname
DATE ?= date
GZIP_CMD ?= gzip
CHMOD ?= chmod
OBJCOPY ?= objcopy
NV_AUTO_DEPEND ?= 1
NV_VERBOSE ?= 0
......@@ -271,10 +272,14 @@ endif
NV_MODULE_LOGGING_NAME ?=
ifeq ($(NV_VERBOSE),0)
quiet_cmd = @$(PRINTF) \
at_if_quiet := @
quiet_cmd_no_at = $(PRINTF) \
" $(if $(NV_MODULE_LOGGING_NAME),[ %-17.17s ],%s) $(quiet_$(1))\n" \
"$(NV_MODULE_LOGGING_NAME)" && $($(1))
quiet_cmd = @$(quiet_cmd_no_at)
else
at_if_quiet :=
quiet_cmd_no_at = $($(1))
quiet_cmd = $($(1))
endif
......@@ -295,6 +300,8 @@ quiet_HOST_LINK = $(call define_quiet_cmd,HOST_LINK ,$@)
quiet_M4 = $(call define_quiet_cmd,M4 ,$<)
quiet_STRIP_CMD = $(call define_quiet_cmd,STRIP ,$@)
quiet_HARDLINK = $(call define_quiet_cmd,HARDLINK ,$@)
quiet_LD = $(call define_quiet_cmd,LD ,$@)
quiet_OBJCOPY = $(call define_quiet_cmd,OBJCOPY ,$@)
##############################################################################
# Tell gmake to delete the target of a rule if it has changed and its
......@@ -447,3 +454,30 @@ define DEFINE_STAMP_C_RULE
@ $$(PRINTF) "%s\n" "const char *pNV_ID = NV_ID + 11;" >> $$@
endef
##############################################################################
# Define rules that can be used for embedding a file into an ELF object that
# contains the raw contents of that file and symbols pointing to the embedded
# data.
#
# Note that objcopy will name the symbols in the resulting object file based on
# the filename specified in $(1). For example,
#
# $(eval $(call $(READ_ONLY_OBJECT_FROM_FILE_RULE),a/b/c))
#
# will create an object named $(OUTPUTDIR)/c.o with the symbols _binary_c_start,
# _binary_c_end, and _binary_c_size.
#
# Arguments:
# $(1): Path to the file to convert
##############################################################################
define READ_ONLY_OBJECT_FROM_FILE_RULE
$$(OUTPUTDIR)/$$(notdir $(1)).o: $(1)
$(at_if_quiet)cd $$(dir $(1)); \
$$(call quiet_cmd_no_at,LD) -r -z noexecstack --format=binary \
$$(notdir $(1)) -o $$(OUTPUTDIR_ABSOLUTE)/$$(notdir $$@)
$$(call quiet_cmd,OBJCOPY) \
--rename-section .data=.rodata,contents,alloc,load,data,readonly \
$$@
endef
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment