#
include ../config.mak

VPATH=$(SRC_PATH)/fftv

OPTFLAGS = -O3

CFLAGS= $(OPTFLAGS) -Wall -g -I.. -I$(SRC_PATH) -I$(SRC_PATH)/fftv \
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE \
-DFFTV_LIRC=\"$(FFTV_LIRC)\" -DFFTV_X11=\"$(FFTV_X11)\" $(GTKINC) \
-DICON_BASENAME=\"$(ICON_BASENAME)\" -DFFTV_VERSION=\"$(FFTV_VERSION)\" \
-DFFTV_CONF=\"$(FFTV_CONF)\"

.SUFFIXES:	.c .o .E


# mux and demuxes
OBJS+= tv-freq.o video-source.o fftv.o tv-scan.o tv-sound.o tv-win.o tv-cmd.o \
       sock-path.o rem-srv.o xkey.o monitor.o status-button.o radio-ui.o \
       radio-list.o tv-freq-table.o radio-scan.o tv-list.o tv-sys.o tv-ui.o \
       about.o fftv-conf.o codec-ui.o tv-www-schedule.o tv-win-grab.o not-rect.o \
       tv-disp-opt.o tv-win-preview.o qstr.o fftv-env.o
OBJS_REM = sock-path.o reminder.o fftv-env.o

ifeq ($(LIRC),yes)
CFLAGS+=-DLIRC=1
OBJS+=lirc.o
endif

ifeq ($(CONFIG_TCRON),yes)
CFLAGS+=-DTCRON=1
OBJS+=cron-ui.o cron-file.o
endif


#DEPS= $(OBJS:.o=.d)

all: $(LIB) reminder

$(LIB): $(OBJS)
	rm -f $@
	$(AR) rc $@ $(OBJS)
ifneq ($(CONFIG_OS2),yes)
	$(RANLIB) $@
endif

%.o: %.c
	$(CC) $(CFLAGS) -c -o $@ $<
.c.E:
	$(CC) $(CFLAGS) -E -o $@ $<

#%.d: %.c
#	@echo $@ \\ > $@
#	$(CC) $(CFLAGS) -MM $< >> $@

#-include $(DEPS)

# BeOS: remove -Wall to get rid of all the "multibyte constant" warnings
%.o: %.cpp
	g++ $(subst -Wall,,$(CFLAGS)) -c -o $@ $<

all:	fftv.a reminder

fftv.a: $(OBJS)
	rm -f $@
	$(AR) rc $@ $(OBJS)
	ranlib $@
	make -C ..

reminder: $(OBJS_REM)
	$(CC) $(OBJS_REM) -o $@

install:
	install -s reminder $(prefix)/bin
	install -d $(prefix)/bin
	cd $(prefix)/bin; rm -f fftv ffradio ffrecord; ln -s ffmpeg fftv; ln -s ffmpeg ffradio ; ln -s reminder ffrecord
	install -d $(FFTV_X11)
	install -d $(ICON_BASENAME)
	install icons/* $(ICON_BASENAME)
	make -C conf install
	make -C key-map install

clean:
	rm -f *.o *.d *~ *.a *.E $(LIB) reminder *.mpg *.ogg tags core.* \
	.depend .ted* *.rm *.vob *.avi *.asf *.mp3
	rm -fr .xvpics/*
	make -C key-map clean
	make -C conf clean

.depend:
	$(CC) $(CFLAGS) -MM *.c > $@

include .depend
