#----------------------------------------------------------------------
#
# Makefile - A makefile for the RTSP Proxy Reference Implementation.
#
#----------------------------------------------------------------------

#
# Choose the compiler and linker to use.  Gcc works well if you have it.
#
CC = gcc -Wall
LD = gcc
#CC = cc
#LD = ld
#LD = cc

#
# For Solaris 2.6:
#
#LOCAL_DEFINES  = 
#LOCAL_LIBS     = -lsocket -lnsl

#
# For Solaris 2.5:
#
#LOCAL_DEFINES  = -DUSE__SNPRINTF -DUSE_RAND
#LOCAL_LIBS     = -lsocket -lnsl

#
# For SCO OpenServer, and SCO Unixware 7:
#
#LOCAL_DEFINES  = -DNEED_STRING_H -DADDRESS_LENGTH=size_t
#LOCAL_LIBS     = -lsocket -lnsl

#
# For IRIX:
#
# (Important: On this platform you'll need to find a real snprintf()
# and vsnprintf().  Don't use the ones provided.)
# If you don't have gcc, try using cc as both the compiler and linker (above).
#LOCAL_DEFINES  = -DNEED_SNPRINTF -DNEED_VSNPRINTF -D_BSD_COMPAT
#LOCAL_LIBS     = -lbsd

#
# For Ultrix (this build has not been tested but should be close):
#
# (Important: On this platform you'll need to find a real snprintf()
# and vsnprintf().  Don't use the ones provided.)
#LOCAL_DEFINES  = -DNEED_EXTRA_PROTOTYPES -DUSE_SYS_SYSLOG_H -DUSE_SYS_TYPES_H \
#		-DNEED_SNPRINTF -DNEED_VSNPRINTF
#LOCAL_LIBS     =



#
# You might want to add -DONCE_ONLY while in development to have
# the proxy handle one RTSP connection without forking, and exit
# upon completion.  Very helpful in running the proxy in a debugger.
#


#
# For Linux and FreeBSD we don't have any special flags,
# and should be able to use this Makefile as is.
#

#
# Use the first CFLAGS line for a normal build, the second
# for a debug build.  Additional messages will be logged,
# in addition, all RTSP packets will be dumped to stderr.
# (Also, see DEBUG_TO_SYSLOG in setup.h.)
#
#CFLAGS = -O2
CFLAGS = -g -DDEBUG

#
# You can create either a dynamic or a static binary (default: dynamic).
#
STATIC_LDFLAGS = -static

#
# List of libraries to link our executable with.  Look above for
# a section for your OS if you need to adjust this.
#
LIBS = $(LOCAL_LIBS) -lc
#LIBS = $(LOCAL_LIBS)


# Only used to create a preformatted manpage, if you want it
# (via 'make rtspd.8.txt').
NROFF = nroff
#NROFF = groff
SED = sed

#----------------------------------------------------------------------
# In theory you won't need to touch anything from here on down.
#----------------------------------------------------------------------

DEFINES =
INCLUDES = -I.
LDFLAGS =
PROG = rtspd

MANSECT = 8
MANSRC = $(PROG).$(MANSECT)
MANTXT = $(PROG).$(MANSECT).txt

SRCS = child-main.c daemon.c main.c rtsp.c simplib.c util.c $(LOCAL_SRCS)
HDRS = child-main.h daemon.h rtsp.h setup.h simplib.h util.h $(LOCAL_HDRS)
OBJS = child-main.o daemon.o main.o rtsp.o simplib.o util.o $(LOCAL_OBJS)


.c.o:
	$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $(LOCAL_DEFINES) $<

all: $(PROG)

$(PROG): $(OBJS)
	$(LD) $(LDFLAGS) -o $(PROG) $(OBJS) $(LIBS)

$(PROG)-static: $(OBJS)
	$(LD) $(STATIC_LDFLAGS) -o $(PROG)-static $(OBJS) $(LIBS)

$(MANTXT): $(MANSRC)
	$(NROFF) -man $(MANSRC) | $(SED) -e '1,$$s/.//g' > $(MANTXT)

SRCFILES = ../license.txt $(SRCS) $(HDRS) $(MANSRC) $(MANTXT) \
		Makefile README rtspv2r2.pdf
# Rule to make rtspd-src-{date}.tar.gz:
$(PROG)-src:
	( x="`date +%y%m%d`" && \
	  mkdir $(PROG)-src-$$x && \
	  cp $(SRCFILES) $(PROG)-src-$$x && \
	  tar czvf $(PROG)-src-$$x.tar.gz $(PROG)-src-$$x )


clean:
	rm -f $(OBJS) $(PROG) core *.core core.*

depend:
	makedepend $(SRCS)

install:
	@echo "See the README for installation information."


child-main.o: child-main.c rtsp.h util.h simplib.h setup.h
daemon.o: daemon.c daemon.h util.h
main.o: main.c daemon.h child-main.h util.h simplib.h setup.h
rtsp.o: rtsp.c rtsp.h simplib.h util.h setup.h
simplib.o: simplib.c simplib.h util.h
util.o: util.c util.h setup.h


#----------------------------------------------------------------------
# Do not edit below this line if you use makedepend or you will lose
# your changes.
#
# DO NOT DELETE

