aboutsummaryrefslogtreecommitdiffstats
path: root/GNUmakefile
blob: 79ef2b781a6bbea5c6687761c889e32def544e7a (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
# config
-include Make.config
include mk/Variables.mk

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

# build
TARGETS		:= xenlog xenscreen
BUILD_GTK	:= xenwatch mdns-browser
BUILD_AVAHI	:= mdns-publish-xendom mdns-publish-vnc
BUILD_VNCCLIENT := vnc-client

NEEDS_XENSTORE	:= xenlog xenscreen xenwatch mdns-publish-xendom mdns-publish-vnc
NEEDS_LIBVIRT	:= xenscreen
NEEDS_GTK	:= xenwatch mdns-browser vnc-client
NEEDS_AVAHI	:= xenwatch mdns-browser mdns-publish-xendom mdns-publish-vnc
NEEDS_VNCCLIENT	:= 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_XENSTORE	:= $(call ac_lib,xs_daemon_open,xenstore)
HAVE_VNCCLIENT	:= $(call ac_lib,rfbGetClient,vncclient,-lz -ljpeg)
HAVE_VNC_TEXT   := $(call ac_lib,TextChatSend,vncclient,-lz -ljpeg)
endef


# gtk stuff
ifeq ($(HAVE_GTK),yes)
  $(NEEDS_GTK) : CFLAGS += -Wno-strict-prototypes
  $(NEEDS_GTK) : pkglst += gtk+-x11-2.0
  TARGETS += $(BUILD_GTK)
  ifeq ($(HAVE_VNCCLIENT),yes)
    TARGETS += $(BUILD_VNCCLIENT)
    $(NEEDS_VNCCLIENT) : LDLIBS += -lvncclient -lz -ljpeg -lGL
  endif
endif

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

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

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

# xenstore
ifneq ($(XENSRC),)
  $(NEEDS_XENSTORE) : CFLAGS += -I $(XENSRC)/dist/install/usr/include
  $(NEEDS_XENSTORE) : LDLIBS += -I $(XENSRC)/dist/install/usr/$(LIB)
endif
$(NEEDS_XENSTORE)   : LDLIBS += -lxenstore


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

build: $(TARGETS) xenscreenrc

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

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

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

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

xenlog: xenlog.o xenstore.o
xenscreen: xenscreen.o xenstore.o apps.o
xenwatch: xenwatch.o xs_view.o xs_store.o xd_view.o xd_store.o \
	apps.o apps-x11.o tcp.o mdns.o vnc.o x11.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 xenstore.o
vnc-client: vnc-client.o vnc.o x11.o

xenscreenrc: xenscreen
	./xenscreen -b > $@

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