Source

ptorrent / Makefile

# ptorrent - pico torrent

include config.mk

BIN = ptorrent
SRC = ptorrent.c sha1.c bencode.c
OBJ = ${SRC:.c=.o}

all: options ${BIN}

options:
	@echo ptorrent build options:
	@echo "CFLAGS	= ${CFLAGS}"
	@echo "LDFLAGS	= ${LDFLAGS}"
	@echo "CC	= ${CC}"

.c.o:
	@echo CC $<
	@${CC} -c ${CFLAGS} $<

.o:
	@echo CC -o $@
	@${CC} -o $@ $< ${LDFLAGS}

${OBJ}: config.mk

${BIN}: ${OBJ}
	@echo CC -o $@
	@${CC} -o $@ ${OBJ} ${LDFLAGS}

clean:
	@echo cleaning
	@rm -f ${BIN} ${OBJ} ptorrent-${VERSION}.tar.gz 

dist: clean
	@echo creating ptorrent-${VERSION}.tar.gz
	@mkdir -p ptorrent-${VERSION}
	@cp -r LICENSE Makefile README config.mk ptorrent.1 ptorrent-${VERSION}
	@tar -cf ptorrent-${VERSION}.tar ptorrent-${VERSION}
	@gzip ptorrent-${VERSION}.tar
	@rm -rf ptorrent-${VERSION}

install: all
	@echo installing executable files to ${DESTDIR}${PREFIX}/bin
	@mkdir -p ${DESTDIR}${PREFIX}/bin
	@for bin in ${BIN}; do cp -f $$bin ${DESTDIR}${PREFIX}/bin/$$bin; done
	@for bin in ${BIN}; do chmod 755   ${DESTDIR}${PREFIX}/bin/$$bin; done
	@echo installing man pages to ${DESTDIR}${MANPREFIX}/man1
	@mkdir -p ${DESTDIR}${MANPREFIX}/man1
	@sed "s/VERSION/${VERSION}/g" < ptorrent.1 > ${DESTDIR}${MANPREFIX}/man1/ptorrent.1
	@chmod 644 ${DESTDIR}${MANPREFIX}/man1/ptorrent.1

uninstall:
	@echo removing executable friles from ${DESTDIR}${PREFIX}/bin
	@for bin in ${BIN}; do rm -f ${DESTDIR}${PREFIX}/bin/$$bin; done
	@echo removing man pages from ${DESTDIR}${MANPREFIX}/man1
	@rm -rf ${DESTDIR}${MANPREFIX}/man1/ptorrent.1

.PHONY: all options clean dist install uninstall