Makefile 7.73 KB
Newer Older
Michel Kaempf's avatar
Michel Kaempf committed
1
################################################################################
2
# vls (VideoLAN Server) main Makefile
3 4
#-------------------------------------------------------------------------------
# (c)1999-2001 VideoLAN
5
# $Id: Makefile,v 1.106 2003/02/16 15:41:28 tooney Exp $
Michel Kaempf's avatar
Michel Kaempf committed
6 7 8
################################################################################


9 10 11
ifeq ($(shell [ ! -r Makefile.opts ] && echo 1),)
    include Makefile.opts
endif
12

13

Michel Kaempf's avatar
Michel Kaempf committed
14
################################################################################
15
# Common options
Michel Kaempf's avatar
Michel Kaempf committed
16 17
################################################################################

18
LCFLAGS += $(VLS_LCFLAGS)
19 20


21 22 23
################################################################################
# Files description
################################################################################
Michel Kaempf's avatar
Michel Kaempf committed
24 25 26 27

#
# Source files
#
28 29 30

ifeq ($(NEEDSRC_core),1)
SRC+=		src/core/application.cpp \
31 32
		src/core/exception.cpp \
		src/core/file.cpp \
33
		src/core/lexer.cpp \
34 35 36 37 38 39 40 41 42
		src/core/log.cpp \
		src/core/parsers.cpp \
		src/core/reflect.cpp \
		src/core/serialization.cpp \
		src/core/settings.cpp \
		src/core/socket.cpp \
		src/core/string.cpp \
		src/core/system.cpp \
		src/core/thread.cpp \
43
		src/core/module.cpp \
44
		src/core/iso_lang.cpp \
45

46
endif
47

48 49
ifeq ($(NEEDSRC_server),1)
SRC+=		src/server/buffer.cpp \
50 51 52
		src/server/directory.cpp \
		src/server/input.cpp \
		src/server/output.cpp \
53
		src/server/channel.cpp \
54
		src/server/request.cpp \
55
		src/server/admin.cpp \
56 57 58 59
		src/server/broadcast.cpp \
		src/server/manager.cpp \
		src/server/program.cpp \
		src/server/tsstreamer.cpp \
60
		src/server/interface.cpp \
61
		src/server/vls.cpp \
62

63 64
endif

65 66 67 68 69
ifeq ($(NEEDSRC_daemon),1)
SRC+=		src/server/daemon.cpp \

endif

70 71
ifeq ($(NEEDSRC_mpegbase),1)
SRC+=		src/mpeg/ts.cpp \
72
		src/mpeg/rtp.cpp \
73
		src/mpeg/pes.cpp \
74 75 76 77 78 79 80 81 82 83 84 85 86
		src/mpeg/streamdescr.cpp \
		src/mpeg/reader.cpp \
		src/mpeg/converter.cpp \

endif

ifeq ($(NEEDSRC_mpegmux),1)
SRC+=		src/mpeg/dvbpsi.cpp \
		src/mpeg/tsdemux.cpp \
		src/mpeg/tsmux.cpp \

endif

87
ifeq ($(NEEDSRC_getopt),1)
88
C_SRC+=        src/extras/getopt.c \
89 90 91
               src/extras/getopt1.c \

endif
92

93 94 95
#
# Module libraries
#
96 97 98 99
MODULE_LIST:=	filereader \
		dvdreader \
		ts2ts \
		ps2ts \
100
		raw2ts \
101
		filechannel \
102
		netchannel \
103
		localinput \
104
		videoinput \
105
		dvbinput \
Damien Lucas's avatar
Damien Lucas committed
106
                dvbreader \
107 108
		v4linput \
		v4lreader \
109
		dummyinterface \
110 111
		telnetinterface \
		nativeinterface \
112 113

BUILTINSTARGETS:=$(BUILTINS:%:bin/%.a)
114
PLUGINSTARGETS:=$(PLUGINS:%:bin/%.so)
115

116

Michel Kaempf's avatar
Michel Kaempf committed
117 118 119
#
# Object files
# 
120
OBJ:=$(SRC:src/%.cpp=obj/%.o)
121
C_OBJ:=$(C_SRC:src/%.c=obj/%.o)
122

Michel Kaempf's avatar
Michel Kaempf committed
123 124

#
125
# Dependencies
Michel Kaempf's avatar
Michel Kaempf committed
126
#
127 128
DEP:=$(SRC:src/%.cpp=dep/%.dpp)
C_DEP:=$(C_SRC:src/%.c=dep/%.d)
Michel Kaempf's avatar
Michel Kaempf committed
129 130


131 132 133 134 135 136 137 138 139
#
# Misc variables
#
VLS_QUICKVERSION := $(shell grep '^ *VLS_VERSION=' configure.in | cut -f2 -d=)

# export symbols for recursive Makefiles
export


Michel Kaempf's avatar
Michel Kaempf committed
140 141 142 143 144 145 146
################################################################################
# Targets definition
################################################################################

#
# Build rules
#
147
all:		Makefile.opts vls $(PLUGINS)
Michel Kaempf's avatar
Michel Kaempf committed
148

149 150 151 152
Makefile.opts:
		@echo "**** No configuration found, please run ./configure..."
		@exit 1

153
vls_clean:
154
		rm -Rf obj
155 156

module_clean:
157
		for module in $(MODULE_LIST) ; do \
158
			( cd src/modules/$$module && $(MAKE) clean ) ; done
Michel Kaempf's avatar
Michel Kaempf committed
159

160 161 162
clean:		module_clean vls_clean

distclean:	vls_clean
163
		rm -f bin/vls
164
		rm -f bin/vlsd
165
		rm -f config*status config*cache config*log
166
		rm -f Makefile.opts src/core/defs.h src/server/config.h
167
		rm -f src/server/vls_builtins.cpp
168
		rm -Rf dep
Michel Kaempf's avatar
Michel Kaempf committed
169
		rm -Rf *.log *.dbg
170
		for module in $(MODULE_LIST) ; do \
171
			( cd src/modules/$$module && $(MAKE) distclean ) ; done
Michel Kaempf's avatar
Michel Kaempf committed
172

173
install:
174 175
	mkdir -p $(DESTDIR)$(bindir)
	$(INSTALL) bin/vls $(DESTDIR)$(bindir)
176
	$(INSTALL) bin/vlsd $(DESTDIR)$(bindir)
177
	mkdir -p $(DESTDIR)$(libdir)/videolan/vls
178 179 180
ifneq (,$(PLUGINS))
	$(INSTALL) -m 644 $(PLUGINS:%=bin/%.so) $(DESTDIR)$(libdir)/videolan/vls
endif
181
	mkdir -p $(DESTDIR)$(sysconfdir)/videolan/vls
182 183
	test -r $(DESTDIR)$(sysconfdir)/videolan/vls/vls.cfg || $(INSTALL) -m 644 vls.cfg $(DESTDIR)$(sysconfdir)/videolan/vls
	@echo "Installation succeeded."
184 185

uninstall:
186
	rm -f $(DESTDIR)$(bindir)/vls
187
	rm -f $(DESTDIR)$(bindir)/vlsd
188
	rm -f $(DESTDIR)$(libdir)/videolan/vls/*.so
189

190 191 192 193
# Build lexer.cpp with flex
lexer:
	flex -i -osrc/core/lexer.cpp src/core/lexer.lex

194
dep:		Makefile.opts $(DEP)
195

196
vls:		Makefile.opts $(OBJ) $(C_OBJ) $(BUILTINS)
197 198
		@echo "Linking $@..."
		@test -d bin || mkdir -p bin
199
		$(CXX) $(LCFLAGS) -o bin/$@ $(OBJ) $(C_OBJ) $(BUILTINS:%=obj/%.a) $(VLS_LIB)
200
		@test -f bin/vlsd || ln -s $@ bin/$@d
Benoit Steiner's avatar
Benoit Steiner committed
201
		chmod 755 bin/$@
Michel Kaempf's avatar
Michel Kaempf committed
202

203
dep/server/vls.dpp:	src/server/vls_builtins.cpp
204 205 206

src/server/vls_builtins.cpp:	Makefile.opts
		rm -f $@
207
ifneq (,$(BUILTINS))
208 209 210
		for builtin in $(BUILTINS) ; do \
		echo "extern C_Module* NewBuiltin_"$$builtin"(handle hLog);" >> $@ ; \
		done
211
endif
212 213 214
		echo "" >> $@
		echo "void C_Vls::LoadBuiltins()" >> $@
		echo "{" >> $@
215
ifneq (,$(BUILTINS))
216 217 218 219
		for builtin in $(BUILTINS) ; do \
		echo "  C_Module* pModule_"$$builtin" = NewBuiltin_"$$builtin"(m_hLog);" >> $@ ; \
		echo "  m_pModuleManager->RegisterModule(pModule_"$$builtin");" >> $@ ; \
		done
220
endif
221 222 223
		echo "}" >> $@
		echo "" >> $@

224 225
$(PLUGINS):	%: Makefile.opts
$(PLUGINS):	%: src/modules/%/Makefile
226 227
		cd src/modules/$* && $(MAKE) ../../../bin/$*.so

228 229 230 231
$(BUILTINS):	%: Makefile.opts
$(BUILTINS):	%: src/modules/%/Makefile
		cd src/modules/$* && $(MAKE) ../../../obj/$*.a

232
$(OBJ):		obj/%.o: Makefile.opts
233
$(OBJ):		obj/%.o: dep/%.dpp
234
$(OBJ):		obj/%.o: src/%.cpp
Michel Kaempf's avatar
Michel Kaempf committed
235 236
		@test -d obj/$(dir $*) || mkdir -p obj/$(dir $*)
		@echo "Compiling $<..."
237
		$(CXX) $(CCFLAGS) $(INCLUDE) -o $@ -c $< 
Michel Kaempf's avatar
Michel Kaempf committed
238

239 240 241 242 243 244 245
$(C_OBJ):	obj/%.o: Makefile.opts
$(C_OBJ):	obj/%.o: dep/%.d
$(C_OBJ):	obj/%.o: src/%.c
		@test -d obj/$(dir $*) || mkdir -p obj/$(dir $*)
		@echo "Compiling $<..."
		$(CC) $(CCFLAGS) $(INCLUDE) -o $@ -c $< 

246
$(DEP):		Makefile.opts Makefile FORCE
247 248 249 250 251
$(DEP):		dep/%.dpp: src/%.cpp
		@$(MAKE) -s --no-print-directory -f Makefile.dep $@

$(C_DEP):	Makefile.opts Makefile FORCE
$(C_DEP):	dep/%.d: src/%.c
252
		@$(MAKE) -s --no-print-directory -f Makefile.dep $@
Michel Kaempf's avatar
Michel Kaempf committed
253

254
FORCE:
255

Michel Kaempf's avatar
Michel Kaempf committed
256
#
257
# Package generation rules
Michel Kaempf's avatar
Michel Kaempf committed
258
#
259
dist:
260 261 262 263
	# Check that tmp isn't in the way
	@if test -e tmp; then \
		echo "Error: please remove ./tmp, it is in the way"; false; \
	else \
264
		echo "Starting dist's build."; mkdir tmp; \
265 266 267 268 269 270
	fi
	# Copy directory structure in tmp
	find -type d | grep -v '\(snapshot\|CVS\)' | while read i ; \
		do mkdir -p tmp/vls/$$i ; \
	done
	rm -Rf tmp/vls/tmp
271 272
	find debian -mindepth 1 -maxdepth 1 -type d | \
		while read i ; do rm -Rf tmp/vls/$$i ; done
273
	mkdir -p tmp/vls/doc
274
	mkdir -p tmp/vls/doc/developer
275
	# Copy .c .h .in .cpp and .def files
276 277
	find src -type f -name '*.[chi]*' | while read i ; \
		do cp $$i tmp/vls/$$i ; done
278
	cp src/core/iso-639.def tmp/vls/src/core
279 280 281
	# Copy module Makefiles
	find src/modules -type f -name Makefile | while read i ; \
		do cp $$i tmp/vls/$$i ; done
282
	# Copy documentation
283 284 285 286 287
	cp doc/Makefile doc/vls-guide.sgml tmp/vls/doc 
	for file in doc/developer/*.sgml doc/developer/*.dia \
		doc/developer/*.eps doc/developer/*.jpg \
		doc/developer/*.dsl doc/developer/*.sda ; \
			do cp $$file tmp/vls/doc/developer ; done
288
	# Copy misc files
289
	cp AUTHORS COPYING TODO todo.pl ChangeLog* README* INSTALL* \
290
		vls.cfg Makefile Makefile.dep Makefile.module \
Christophe Massiot's avatar
Christophe Massiot committed
291
		Makefile.module.dep Makefile.opts.in \
292 293
		configure configure.in install-sh config.sub config.guess \
		tmp/vls/
294 295 296 297 298 299
	# Copy Debian control files
	for file in debian/*dirs debian/*docs debian/*menu debian/*desktop \
		debian/*copyright debian/*conffiles ; \
			do cp $$file tmp/vls/debian ; done
	for file in control changelog rules vls.1 ; do \
		cp debian/$$file tmp/vls/debian/ ; done
300 301
	# Copy rpm spec file
	cp vls.spec tmp/vls
302 303 304 305 306 307 308
	# Build archives
	F=vls-${VLS_QUICKVERSION}; \
		mv tmp/vls tmp/$$F; (cd tmp ; tar cf $$F.tar $$F); \
		bzip2 -f -9 < tmp/$$F.tar > $$F.tar.bz2; \
		gzip -f -9 tmp/$$F.tar ; mv tmp/$$F.tar.gz .
	# Clean up
	rm -Rf tmp
Michel Kaempf's avatar
Michel Kaempf committed
309