PACKAGE = 'ipc'
VERSION = '0.0.1'

PREFIX := /usr/local
BINDIR := $(PREFIX)/bin
LIBDIR := $(PREFIX)/lib
SHAREDIR := $(PREFIX)/share
INCLUDEDIR := $(PREFIX)/include
MANDIR := $(SHAREDIR)/man

CC := cc
AR := ar
RANLIB := ranlib
CFLAGS := 
LDFLAGS := 

Q := @

all: libipc
	@:

libipc: libipc.so libipc.a
	@:
libipc.install: libipc.so.install libipc.a.install

libipc.clean: libipc.so.clean libipc.a.clean

libipc.uninstall: libipc.so.uninstall libipc.a.uninstall

libipc.so: communication.o logger.o message.o process.o usocket.o utils.o 
	@echo '  LD >    libipc.so'
	$(Q)$(CC) -o libipc.so -shared $(LDFLAGS) communication.o logger.o message.o process.o usocket.o utils.o 

libipc.so.install: libipc.so
	@echo '  IN >    $(LIBDIR)/libipc.so.0.0.1'
	$(Q)mkdir -p '$(DESTDIR)$(LIBDIR)'
	$(Q)install -m0755 libipc.so $(DESTDIR)$(LIBDIR)/libipc.so.0.0.1
	@echo '  LN >    $(LIBDIR)/libipc.so.0.0'
	$(Q)ln -sf '$(LIBDIR)/libipc.so.0.0.1' '$(DESTDIR)/$(LIBDIR)/libipc.so.0.0'
	@echo '  LN >    $(LIBDIR)/libipc.so.0'
	$(Q)ln -sf '$(LIBDIR)/libipc.so.0.0.1' '$(DESTDIR)/$(LIBDIR)/libipc.so.0'
	@echo '  LN >    $(LIBDIR)/libipc.so'
	$(Q)ln -sf '$(LIBDIR)/libipc.so.0.0.1' '$(DESTDIR)/$(LIBDIR)/libipc.so'

libipc.so.clean:
	@echo '  RM >    libipc.so'
	$(Q)rm -f libipc.so

libipc.so.uninstall:
	@echo '  RM >    $(LIBDIR)/libipc.so.0.0.1'
	$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0.0.1'
	@echo '  RM >    $(LIBDIR)/libipc.so.0.0'
	$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0.0'
	@echo '  RM >    $(LIBDIR)/libipc.so.0'
	$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0'
	@echo '  RM >    $(LIBDIR)/libipc.so'
	$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so'

libipc.a: communication.o logger.o message.o process.o usocket.o utils.o 
	@echo '  LD >    libipc.a'
	$(Q)$(AR) rc 'libipc.a' communication.o logger.o message.o process.o usocket.o utils.o

libipc.a.install: libipc.a
	@echo '  IN >    $(LIBDIR)/libipc.a'
	$(Q)mkdir -p '$(DESTDIR)$(LIBDIR)'
	$(Q)install -m0755 libipc.a $(DESTDIR)$(LIBDIR)/libipc.a

libipc.a.clean:
	@echo '  RM >    libipc.a'
	$(Q)rm -f libipc.a

libipc.a.uninstall:
	@echo '  RM >    $(LIBDIR)/libipc.a'
	$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.a'

communication.o: communication.c ./communication.h ./usocket.h ./utils.h ./error.h
	@echo '  CC >    communication.o'
	$(Q)$(CC) $(CFLAGS) -fPIC  -c communication.c  -fPIC  -o communication.o

communication.o.install:

communication.o.clean:
	@echo '  RM >    communication.o'
	$(Q)rm -f communication.o

communication.o.uninstall:

logger.o: logger.c ./logger.h
	@echo '  CC >    logger.o'
	$(Q)$(CC) $(CFLAGS) -fPIC  -c logger.c  -fPIC  -o logger.o

logger.o.install:

logger.o.clean:
	@echo '  RM >    logger.o'
	$(Q)rm -f logger.o

logger.o.uninstall:

message.o: message.c ./message.h ./error.h ./usocket.h
	@echo '  CC >    msg.o'
	$(Q)$(CC) $(CFLAGS) -fPIC  -c message.c  -fPIC  -o message.o

message.o.install:

message.o.clean:
	@echo '  RM >    msg.o'
	$(Q)rm -f message.o

message.o.uninstall:

process.o: process.c ./process.h
	@echo '  CC >    process.o'
	$(Q)$(CC) $(CFLAGS) -fPIC  -c process.c  -fPIC  -o process.o

process.o.install:

process.o.clean:
	@echo '  RM >    process.o'
	$(Q)rm -f process.o

process.o.uninstall:

usocket.o: usocket.c ./usocket.h ./utils.h ./error.h
	@echo '  CC >    usocket.o'
	$(Q)$(CC) $(CFLAGS) -fPIC  -c usocket.c  -fPIC  -o usocket.o

usocket.o.install:

usocket.o.clean:
	@echo '  RM >    usocket.o'
	$(Q)rm -f usocket.o

usocket.o.uninstall:

utils.o: utils.c ./utils.h
	@echo '  CC >    utils.o'
	$(Q)$(CC) $(CFLAGS) -fPIC  -c utils.c  -fPIC  -o utils.o

utils.o.install:

utils.o.clean:
	@echo '  RM >    utils.o'
	$(Q)rm -f utils.o

utils.o.uninstall:

$(DESTDIR)$(PREFIX):
	@echo '  DIR >   $(PREFIX)'
	$(Q)mkdir -p $(DESTDIR)$(PREFIX)
$(DESTDIR)$(BINDIR):
	@echo '  DIR >   $(BINDIR)'
	$(Q)mkdir -p $(DESTDIR)$(BINDIR)
$(DESTDIR)$(LIBDIR):
	@echo '  DIR >   $(LIBDIR)'
	$(Q)mkdir -p $(DESTDIR)$(LIBDIR)
$(DESTDIR)$(SHAREDIR):
	@echo '  DIR >   $(SHAREDIR)'
	$(Q)mkdir -p $(DESTDIR)$(SHAREDIR)
$(DESTDIR)$(INCLUDEDIR):
	@echo '  DIR >   $(INCLUDEDIR)'
	$(Q)mkdir -p $(DESTDIR)$(INCLUDEDIR)
$(DESTDIR)$(MANDIR):
	@echo '  DIR >   $(MANDIR)'
	$(Q)mkdir -p $(DESTDIR)$(MANDIR)
install: subdirs.install libipc.install libipc.so.install libipc.a.install communication.o.install logger.o.install message.o.install process.o.install usocket.o.install utils.o.install communication.o.install logger.o.install message.o.install process.o.install usocket.o.install utils.o.install
	@:

subdirs.install:

uninstall: subdirs.uninstall libipc.uninstall libipc.so.uninstall libipc.a.uninstall communication.o.uninstall logger.o.uninstall message.o.uninstall process.o.uninstall usocket.o.uninstall utils.o.uninstall communication.o.uninstall logger.o.uninstall message.o.uninstall process.o.uninstall usocket.o.uninstall utils.o.uninstall
	@:

subdirs.uninstall:

test: all subdirs subdirs.test
	@:

subdirs.test:

clean: libipc.clean libipc.so.clean libipc.a.clean communication.o.clean logger.o.clean message.o.clean process.o.clean usocket.o.clean utils.o.clean communication.o.clean logger.o.clean message.o.clean process.o.clean usocket.o.clean utils.o.clean

distclean: clean

dist: dist-gz dist-xz dist-bz2
	$(Q)rm -- $(PACKAGE)-$(VERSION)

distdir:
	$(Q)rm -rf -- $(PACKAGE)-$(VERSION)
	$(Q)ln -s -- . $(PACKAGE)-$(VERSION)

dist-gz: $(PACKAGE)-$(VERSION).tar.gz
$(PACKAGE)-$(VERSION).tar.gz: distdir
	@echo '  TAR >   $(PACKAGE)-$(VERSION).tar.gz'
	$(Q)tar czf $(PACKAGE)-$(VERSION).tar.gz \
		$(PACKAGE)-$(VERSION)/Makefile \
		$(PACKAGE)-$(VERSION)/project.zsh \
		$(PACKAGE)-$(VERSION)/error.h \
		$(PACKAGE)-$(VERSION)/communication.c \
		$(PACKAGE)-$(VERSION)/logger.c \
		$(PACKAGE)-$(VERSION)/message.c \
		$(PACKAGE)-$(VERSION)/process.c \
		$(PACKAGE)-$(VERSION)/usocket.c \
		$(PACKAGE)-$(VERSION)/utils.c \
		$(PACKAGE)-$(VERSION)/communication.h \
		$(PACKAGE)-$(VERSION)/logger.h \
		$(PACKAGE)-$(VERSION)/message.h \
		$(PACKAGE)-$(VERSION)/process.h \
		$(PACKAGE)-$(VERSION)/usocket.h \
		$(PACKAGE)-$(VERSION)/utils.h

dist-xz: $(PACKAGE)-$(VERSION).tar.xz
$(PACKAGE)-$(VERSION).tar.xz: distdir
	@echo '  TAR >   $(PACKAGE)-$(VERSION).tar.xz'
	$(Q)tar cJf $(PACKAGE)-$(VERSION).tar.xz \
		$(PACKAGE)-$(VERSION)/Makefile \
		$(PACKAGE)-$(VERSION)/project.zsh \
		$(PACKAGE)-$(VERSION)/error.h \
		$(PACKAGE)-$(VERSION)/communication.c \
		$(PACKAGE)-$(VERSION)/logger.c \
		$(PACKAGE)-$(VERSION)/message.c \
		$(PACKAGE)-$(VERSION)/process.c \
		$(PACKAGE)-$(VERSION)/usocket.c \
		$(PACKAGE)-$(VERSION)/utils.c \
		$(PACKAGE)-$(VERSION)/communication.h \
		$(PACKAGE)-$(VERSION)/logger.h \
		$(PACKAGE)-$(VERSION)/message.h \
		$(PACKAGE)-$(VERSION)/process.h \
		$(PACKAGE)-$(VERSION)/usocket.h \
		$(PACKAGE)-$(VERSION)/utils.h

dist-bz2: $(PACKAGE)-$(VERSION).tar.bz2
$(PACKAGE)-$(VERSION).tar.bz2: distdir
	@echo '  TAR >   $(PACKAGE)-$(VERSION).tar.bz2'
	$(Q)tar cjf $(PACKAGE)-$(VERSION).tar.bz2 \
		$(PACKAGE)-$(VERSION)/Makefile \
		$(PACKAGE)-$(VERSION)/project.zsh \
		$(PACKAGE)-$(VERSION)/error.h \
		$(PACKAGE)-$(VERSION)/communication.c \
		$(PACKAGE)-$(VERSION)/logger.c \
		$(PACKAGE)-$(VERSION)/message.c \
		$(PACKAGE)-$(VERSION)/process.c \
		$(PACKAGE)-$(VERSION)/usocket.c \
		$(PACKAGE)-$(VERSION)/utils.c \
		$(PACKAGE)-$(VERSION)/communication.h \
		$(PACKAGE)-$(VERSION)/logger.h \
		$(PACKAGE)-$(VERSION)/message.h \
		$(PACKAGE)-$(VERSION)/process.h \
		$(PACKAGE)-$(VERSION)/usocket.h \
		$(PACKAGE)-$(VERSION)/utils.h

help:
	@echo ' :: ipc-0.0.1'
	@echo ''
	@echo 'Generic targets:'
	@echo '    - help           Prints this help message.'
	@echo '    - all            Builds all targets.'
	@echo '    - dist           Creates tarballs of the files of the project.'
	@echo '    - install        Installs the project.'
	@echo '    - clean          Removes compiled files.'
	@echo '    - uninstall      Deinstalls the project.'
	@echo ''
	@echo 'CLI-modifiable variables:'
	@echo '    - CC             ${CC}'
	@echo '    - CFLAGS         ${CFLAGS}'
	@echo '    - LDFLAGS        ${LDFLAGS}'
	@echo '    - DESTDIR        ${DESTDIR}'
	@echo '    - PREFIX         ${PREFIX}'
	@echo '    - BINDIR         ${BINDIR}'
	@echo '    - LIBDIR         ${LIBDIR}'
	@echo '    - SHAREDIR       ${SHAREDIR}'
	@echo '    - INCLUDEDIR     ${INCLUDEDIR}'
	@echo '    - MANDIR         ${MANDIR}'
	@echo ''
	@echo 'Project targets: '
	@echo '    - libipc         library'
	@echo ''
	@echo 'Makefile options:'
	@echo '    - gnu:           false'
	@echo '    - colors:        true'
	@echo ''
	@echo 'Rebuild the Makefile with:'
	@echo '    zsh ./build.zsh -c'
.PHONY: all subdirs clean distclean dist install uninstall help