Skip to main content
summaryrefslogtreecommitdiffstats
blob: 251d34d6b985a4c9a4b0fda3a01d7f7c88a572a1 (plain) (blame)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
TCF_AGENT_DIR=.

include $(TCF_AGENT_DIR)/Makefile.inc

# include custom Makefile fragments if defined

ifdef MAKE_INC
include $(MAKE_INC)
endif

ifdef LIBWEBSOCKETSDIR
  OPTS += -DENABLE_LibWebSockets=1 "-I$(LIBWEBSOCKETSDIR)/include"
  LIBS += -L $(LIBWEBSOCKETSDIR)/lib -lwebsockets -lssl
endif

ifdef LUADIR
  EXECS += $(BINDIR)/tcflua$(EXTEXE)
  OPTS += -DPATH_LUA="$(LUADIR)" "-I$(LUADIR)/include"
  LUALIBS = $(LIBS) $(LUADIR)/lib/liblua$(EXTLIB)
  ifeq ($(OPSYS),Msys)
    LUALIBS += -lm
  else
    ifneq ($(OPSYS),Windows)
      LUALIBS += -lm -ldl
    endif
  endif
endif

LIBTCF		?= $(BINDIR)/libtcf$(EXTLIB)

LINK_FLAGS	+= $(LINK_OPTS)

all:	$(EXECS)

libtcf: $(LIBTCF)

CCDEPS = $(HFILES) Makefile Makefile.inc

ifdef OpenSSL
  CCDEPS += $(LIBSSL)

$(LIBSSL): $(OpenSSL)/Makefile
	bin/build-openssl "$(OpenSSL)" "$(OPSYS)" "$(MACHINE)" "$(CONF)"
endif

CCDEPS += $(EXTRA_CCDEPS)
LIBS += $(EXTRA_LIBS)

override CFLAGS += $(OPTS)

$(BINDIR)/libtcf$(EXTLIB) : $(OFILES)
	$(AR) $(AR_FLAGS) $(AR_OUT_F)$@ $^
	$(RANLIB)

$(BINDIR)/agent$(EXTEXE): $(BINDIR)/tcf/main/main$(EXTOBJ) $(LIBTCF)
	$(LINK) $(LINK_FLAGS) $(LINK_OUT_F)$@ $(BINDIR)/tcf/main/main$(EXTOBJ) \
		$(LIBTCF) $(LIBS)

$(BINDIR)/client$(EXTEXE): $(BINDIR)/tcf/main/main_client$(EXTOBJ) $(LIBTCF)
	$(LINK) $(LINK_FLAGS) $(LINK_OUT_F)$@ \
		$(BINDIR)/tcf/main/main_client$(EXTOBJ) $(LIBTCF) $(LIBS)

ifdef LUADIR
$(BINDIR)/tcflua$(EXTEXE): $(BINDIR)/tcf/main/main_lua$(EXTOBJ) $(LIBTCF)
	$(LINK) $(LINK_FLAGS) $(EXPORT_DYNAMIC) $(LINK_OUT_F)$@ \
		$(BINDIR)/tcf/main/main_lua$(EXTOBJ) $(LIBTCF) $(LUALIBS)
endif

$(BINDIR)/tcfreg$(EXTEXE): $(BINDIR)/tcf/main/main_reg$(EXTOBJ) $(LIBTCF)
	$(LINK) $(LINK_FLAGS) $(LINK_OUT_F)$@ $(BINDIR)/tcf/main/main_reg$(EXTOBJ) \
		$(LIBTCF) $(LIBS)

$(BINDIR)/valueadd$(EXTEXE): $(BINDIR)/tcf/main/main_va$(EXTOBJ) $(LIBTCF)
	$(LINK) $(LINK_FLAGS) $(LINK_OUT_F)$@ $(BINDIR)/tcf/main/main_va$(EXTOBJ) \
		$(LIBTCF) $(LIBS)

$(BINDIR)/tcflog$(EXTEXE): $(BINDIR)/tcf/main/main_log$(EXTOBJ) $(LIBTCF)
	$(LINK) $(LINK_FLAGS) $(LINK_OUT_F)$@ $(BINDIR)/tcf/main/main_log$(EXTOBJ) \
		$(LIBTCF) $(LIBS)

$(BINDIR)/tcf/main/test$(EXTOBJ): tcf/main/test.c $(CCDEPS)
	@$(call MKDIR,$(dir $@))
	$(CC) $(filter-out -O%,$(CFLAGS)) -O0 $(OUT_OBJ_F)$@ $(NO_LINK_F) $<

$(BINDIR)/%$(EXTOBJ): %.c $(CCDEPS)
	@$(call MKDIR,$(dir $@))
	$(CC) $(CFLAGS) $(OUT_OBJ_F)$@ $(NO_LINK_F) $<

clean::
	$(call RMDIR,$(BINDIR))

ifeq ($(OPSYS),GNU/Linux)

install: all
	install -d -m 755 $(INSTALLROOT)$(SBIN)
	install -d -m 755 $(INSTALLROOT)$(INIT)
	install -d -m 755 $(INSTALLROOT)$(INCLUDE)
	install -d -m 755 $(INSTALLROOT)$(INCLUDE)/tcf
	install -d -m 755 $(INSTALLROOT)$(INCLUDE)/tcf/framework
	install -d -m 755 $(INSTALLROOT)$(INCLUDE)/tcf/services
	install -c $(BINDIR)/agent -m 755 $(INSTALLROOT)$(SBIN)/tcf-agent
	install -c $(BINDIR)/client -m 755 $(INSTALLROOT)$(SBIN)/tcf-client
	install -c tcf/main/tcf-agent.init -m 755 $(INSTALLROOT)$(INIT)/tcf-agent
	install -c tcf/config.h -m 755 $(INSTALLROOT)$(INCLUDE)/tcf/config.h
	install -c -t $(INSTALLROOT)$(INCLUDE)/tcf/framework -m 644 tcf/framework/*.h
	install -c -t $(INSTALLROOT)$(INCLUDE)/tcf/services -m 644 tcf/services/*.h

ALLFILES = Makefile* *.html *.sln *.vcproj *.h bin tcf system machine

tcf-agent-$(VERSION).tar.bz2: $(HFILES) $(CFILES) Makefile Makefile.inc \
			      tcf/main/tcf-agent.spec tcf/main/tcf-agent.init
	rm -rf tcf-agent-$(VERSION) tcf-agent-$(VERSION).tar.bz2
	mkdir tcf-agent-$(VERSION)
	tar c $(ALLFILES) | tar x -C tcf-agent-$(VERSION)
	tar cjf tcf-agent-$(VERSION).tar.bz2 tcf-agent-$(VERSION)
	rm -rf tcf-agent-$(VERSION)

tar: tcf-agent-$(VERSION).tar.bz2

rpm: all tar
	rm -rf RPM
	mkdir RPM RPM/BUILD RPM/RPMS RPM/RPMS/`uname -i` \
	      RPM/RPMS/noarch RPM/SOURCES RPM/SPECS RPM/SRPMS RPM/tmp
	echo "%_topdir $(PWD)/RPM" >~/.rpmmacros
	echo "%_tmppath $(PWD)/RPM/tmp" >>~/.rpmmacros
	rpmbuild -ta tcf-agent-$(VERSION).tar.bz2
	mv RPM/RPMS/`uname -i`/*.rpm .
	mv RPM/SRPMS/*.rpm .
	rm -rf RPM ~/.rpmmacros

clean::
	rm -rf RPM *.tar *.tar.bz2 *.rpm

endif

Back to the top