1XEN_ROOT=$(CURDIR)/../../.. 2include $(XEN_ROOT)/tools/Rules.mk 3 4# Standing boldly against convention, we insist on installing the 5# package source under $(prefix)/share/gocode 6GOCODE_DIR ?= $(prefix)/share/gocode/ 7GOXL_INSTALL_DIR = $(GOCODE_DIR)/src/$(XEN_GOCODE_URL)/xenlight/ 8 9GO ?= go 10 11LIBXL_SRC_DIR = ../../libxl 12 13.PHONY: all 14all: build 15 16GOXL_GEN_FILES = types.gen.go helpers.gen.go 17 18# NOTE: This target is called from libxl/Makefile:all. Since that 19# target must finish before golang/Makefile is called, this is 20# currently safe. It must not be called from anywhere else in the 21# Makefile system without careful thought about races with 22# xenlight/Makefile:all 23idl-gen: $(GOXL_GEN_FILES) 24 25%.gen.go: gengotypes.py $(LIBXL_SRC_DIR)/libxl_types.idl $(LIBXL_SRC_DIR)/idl.py 26 XEN_ROOT=$(XEN_ROOT) $(PYTHON) gengotypes.py $(LIBXL_SRC_DIR)/libxl_types.idl 27 28# Go will do its own dependency checking, and not actuall go through 29# with the build if none of the input files have changed. 30# 31# NB that because the users of this library need to be able to 32# recompile the library from source, it needs to include '-lxenlight' 33# in the LDFLAGS; and thus we need to add -L$(XEN_XENLIGHT) here 34# so that it can find the actual library. 35.PHONY: build 36build: xenlight.go $(GOXL_GEN_FILES) 37 CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog)" CGO_LDFLAGS="$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_XENLIGHT) -L$(XEN_LIBXENTOOLLOG)" $(GO) build -x 38 39.PHONY: install 40install: build 41 $(INSTALL_DIR) $(DESTDIR)$(GOXL_INSTALL_DIR) 42 $(INSTALL_DATA) xenlight.go $(DESTDIR)$(GOXL_INSTALL_DIR) 43 $(INSTALL_DATA) types.gen.go $(DESTDIR)$(GOXL_INSTALL_DIR) 44 $(INSTALL_DATA) helpers.gen.go $(DESTDIR)$(GOXL_INSTALL_DIR) 45 46.PHONY: uninstall 47 rm -rf $(DESTDIR)$(GOXL_INSTALL_DIR) 48 49.PHONY: clean 50clean: 51 52.PHONY: distclean 53distclean: clean 54 55-include $(DEPS_INCLUDE) 56