include ../Makefile.defs

INCLDIR = -I${prefix}/include
LIBDIR  =
LIBS    = -lical -lpthread

SRC     = ical2pal.c

OBJ     = $(SRC:.c=.o)

$(NAME): $(OBJ)
	$(CC) $(CFLAGS) $(OBJ) $(LDFLAGS) -o $(NAME)
ifneq ($(DEBUG),1)
	strip $(NAME)
endif

help:
	@echo "Please use one of the following targets:"
	@echo "  ical           Make ical <--> pal conversion utilities (requires libical)"
	@echo "  ical-install   Install ical <--> pal conversion utilities (requires libical)"
	@echo ""

# make dependency files
%.d: %.c
	@echo "Creating/recreating dependency file: $(@)"
	@set -e; $(CC) -MM $(CFLAGS) $< \
        | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
        [ -s $@ ] ||  rm -f $@


# Include dependency files here.
# If the files don't exist, this will fail silently and remake the dep files.
-include $(SRC:.c=.d)


ical: ical2pal


ical-debug: clean
	@$(MAKE) ical DEBUG=1


# Install binary file
ical-install:
	@echo " --- Installing binary --- "
	@mkdir -p ${DESTDIR}${prefix}/bin;
	install -m 0755 -o root ical2pal ${DESTDIR}${prefix}/bin;
	@echo


# try to uninstall pal
ical-uninstall:
	@echo " --- Removing binary --- "
	rm -f ${prefix}/bin/ical2pal;
	@echo


# Remove binay, object files and emacs backup files
clean:
	rm -f ical2pal $(OBJ) *~

# Remove object files and dependency files
cleandeps: clean
	rm -f $(SRC:.c=.d)

cleandep: cleandeps

splint:
	splint $(INCLDIR) $(SRC)

