aboutsummaryrefslogtreecommitdiffstats
path: root/GNUmakefile
blob: 6a6054fff94c82ada8a59807f0feb61806d24b00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# config
-include Make.config
include mk/Variables.mk

# add our flags + libs
CFLAGS	+= -DVERSION='"$(VERSION)"' -DLIB='"$(LIB)"'

# build
TARGETS		:= xenlog xenscreen xenwatch xenstore \
		   mdns-browser mdns-publish-xendom mdns-publish-vnc \
		   vnc-client
BUILD_XENSTORE	:= xenlog xenwatch xenstore \
		   mdns-publish-xendom mdns-publish-vnc
BUILD_GTK	:= xenwatch xenstore mdns-browser vnc-client
BUILD_AVAHI	:= mdns-browser mdns-publish-xendom mdns-publish-vnc
BUILD_GTK_VNC   := vnc-client

NEEDS_XENSTORE	:= xenlog xenscreen xenwatch xenstore mdns-publish-xendom mdns-publish-vnc
NEEDS_LIBVIRT	:= xenscreen
NEEDS_GTK	:= xenwatch xenstore mdns-browser vnc-client
NEEDS_AVAHI	:= mdns-browser mdns-publish-xendom mdns-publish-vnc
NEEDS_GTK_VNC	:= xenwatch mdns-browser vnc-client

# default target
all: build


#################################################################
# poor man's autoconf ;-)

include mk/Autoconf.mk

define make-config
LIB		:= $(LIB)
HAVE_GTK	:= $(call ac_pkg_config,gtk+-x11-2.0)
HAVE_AVAHI	:= $(call ac_pkg_config,avahi-glib)
HAVE_LIBVIRT	:= $(call ac_pkg_config,libvirt)
HAVE_GTK_VNC	:= $(call ac_pkg_config,gtk-vnc-1.0)
HAVE_XENSTORE	:= $(call ac_lib,xs_daemon_open,xenstore)
endef

# gtk
ifeq ($(HAVE_GTK),yes)
  $(NEEDS_GTK) : CFLAGS += -Wno-strict-prototypes
  $(NEEDS_GTK) : pkglst += gtk+-x11-2.0
else
  TARGETS := $(filter-out $(BUILD_GTK), $(TARGETS))
endif

# gtk-vnc
ifeq ($(HAVE_GTK_VNC),yes)
  $(NEEDS_GTK_VNC) : pkglst += gtk-vnc-1.0
else
  TARGETS := $(filter-out $(BUILD_GTK_VNC), $(TARGETS))
endif

# avahi
ifeq ($(HAVE_AVAHI),yes)
  $(NEEDS_AVAHI) : pkglst += avahi-client avahi-glib
else
  TARGETS := $(filter-out $(BUILD_AVAHI), $(TARGETS))
endif

# xenstore
ifeq ($(HAVE_XENSTORE),yes)
  $(NEEDS_XENSTORE)   : LDLIBS += -lxenstore
else
  TARGETS := $(filter-out $(BUILD_XENSTORE), $(TARGETS))
endif

# libvirt
ifeq ($(HAVE_LIBVIRT),yes)
  $(NEEDS_LIBVIRT) : pkglst += libvirt libxml-2.0
endif

# compile flags
CFLAGS += $(call ac_inc_cflags,XENSTORE LIBVIRT AVAHI GTK_VNC)
CFLAGS += $(shell test "$(pkglst)" != "" && pkg-config --cflags $(pkglst))
LDLIBS += $(shell test "$(pkglst)" != "" && pkg-config --libs   $(pkglst))

# desktop files
DESKTOP := $(wildcard $(patsubst %,%.desktop,$(TARGETS)))


########################################################################
# rules

build: $(TARGETS) xenscreenrc

install: build
	$(INSTALL_DIR) -d $(DESTDIR)/etc/xen $(bindir) $(appdir)
	$(INSTALL_DATA) xenscreenrc $(DESTDIR)/etc/xen
	$(INSTALL_BINARY) $(TARGETS) $(bindir)
	$(INSTALL_DATA) $(DESKTOP) $(appdir)

clean:
	-rm -f *.o *~ $(depfiles)

realclean distclean: clean
	-rm -f Make.config
	-rm -f $(TARGETS) *~ xpm/*~ *.bak

#############################################

xenlog: xenlog.o xs_tools.o
xenscreen: xenscreen.o xs_tools.o apps.o
xenwatch: xenwatch.o xd_view.o xd_store.o apps.o apps-x11.o tcp.o vnc.o x11.o
xenstore: xenstore.o xs_view.o xs_store.o
mdns-browser: mdns-browser.o mdns.o vnc.o x11.o apps.o apps-x11.o
mdns-publish-xendom: mdns-publish-xendom.o mdns-publish.o
mdns-publish-vnc: mdns-publish-vnc.o mdns-publish.o xs_tools.o
vnc-client: vnc-client.o vnc.o x11.o

xenscreenrc: xenscreen
	./xenscreen -b > $@

include mk/Compile.mk
include mk/Maintainer.mk
-include $(depfiles)