summaryrefslogtreecommitdiff
path: root/samples/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'samples/Makefile')
-rw-r--r--samples/Makefile39
1 files changed, 11 insertions, 28 deletions
diff --git a/samples/Makefile b/samples/Makefile
index addfc49..3da3580 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -32,33 +32,22 @@ UTILS_MK_DIR ?= ..
include $(UTILS_MK_DIR)/utils.mk
+XNVCTRL_DIR ?= ../src/libXNVCtrl
+
+include $(XNVCTRL_DIR)/xnvctrl.mk
+
##############################################################################
# The calling Makefile may export any of the following variables; we
# assign default values if they are not exported by the caller
##############################################################################
-ifndef X_LDFLAGS
- ifeq ($(TARGET_OS)-$(TARGET_ARCH),Linux-x86_64)
- X_LDFLAGS = -L/usr/X11R6/lib64
- else
- X_LDFLAGS = -L/usr/X11R6/lib
- endif
-endif
-
-X_CFLAGS ?=
-
-XNVCTRL_DIR ?= ../src/libXNVCtrl
-XNVCTRL_MAKEFILE ?= Makefile
-XNVCTRL_ARCHIVE ?= $(XNVCTRL_DIR)/libXNVCtrl.a
-
-CFLAGS += $(X_CFLAGS)
+CFLAGS += $(XNVCTRL_CFLAGS)
CFLAGS += -I $(XNVCTRL_DIR)
CFLAGS += -I $(OUTPUTDIR)
-LDFLAGS += $(X_LDFLAGS)
-LDFLAGS += -L $(XNVCTRL_DIR)
-LIBS += -lXNVCtrl -lXext -lX11
+LDFLAGS += $(XNVCTRL_LDFLAGS)
+LIBS += -lXext -lX11
##############################################################################
@@ -79,30 +68,24 @@ SAMPLE_SOURCES += nv-control-warpblend.c
# build rules
##############################################################################
-.PHONY: all clean clobber install build-xnvctrl
+.PHONY: all clean clobber install
# define the rule to build each object file
$(foreach src, $(SAMPLE_SOURCES), $(eval $(call DEFINE_OBJECT_RULE,TARGET,$(src))))
# define the rule to link each sample app from its corresponding object file
define link_sample_from_object
- $$(OUTPUTDIR)/$(1:.c=): $$(call BUILD_OBJECT_LIST,$(1)) $(XNVCTRL_ARCHIVE)
- $$(call quiet_cmd,LINK) $$(CFLAGS) $$(LDFLAGS) $$(BIN_LDFLAGS) -o $$@ $$< $$(LIBS)
+ $$(OUTPUTDIR)/$(1:.c=): $$(call BUILD_OBJECT_LIST,$(1)) $$(LIBXNVCTRL)
+ $$(call quiet_cmd,LINK) $$(CFLAGS) $$(LDFLAGS) $$(BIN_LDFLAGS) -o $$@ $$< $$(LIBXNVCTRL) $$(LIBS)
all:: $$(OUTPUTDIR)/$(1:.c=)
SAMPLES += $$(OUTPUTDIR)/$(1:.c=)
endef
$(foreach sample,$(SAMPLE_SOURCES),$(eval $(call link_sample_from_object,$(sample))))
-# define the rule to build $(XNVCTRL_ARCHIVE)
-$(XNVCTRL_ARCHIVE): build-xnvctrl
-
-build-xnvctrl:
- @$(MAKE) -C $(XNVCTRL_DIR) -f $(XNVCTRL_MAKEFILE)
clean clobber:
- rm -rf *~ $(OUTPUTDIR)/*.o $(OUTPUTDIR)/*.d $(SAMPLES)
- @$(MAKE) -C $(XNVCTRL_DIR) -f $(XNVCTRL_MAKEFILE) clean
+ rm -rf *~ $(OUTPUTDIR)/*.o $(OUTPUTDIR)/*.d $(SAMPLES) $(LIBXNVCTRL)
install:
@# don't install samples, this is just to satisfy the top-level