
CC=mpiCC
CCFLAGS=-O2
PODFLAG=-c 'User Contributed OAR Documentation' -r 'LEGI Trokata'

DESTDIR:=/opt/oar/current


.PHONY: all clean distclean install update sync

all: mpilauncher mpilauncher.1 oar-envsh.1 oar-dispatch.1 oar-parexec.1

clean:
	rm -f *.o

distclean: clean
	rm -f mpilauncher

install: update

update:
	@install -d -m 0755 -o root -g root $(DESTDIR)/bin
	@install -d -m 0755 -o root -g root $(DESTDIR)/man/man1
	install -m 0755 -o root -g root oar-parexec $(DESTDIR)/bin
	install -m 0755 -o root -g root oar-dispatch $(DESTDIR)/bin
	install -m 0755 -o root -g root mpilauncher $(DESTDIR)/bin
	install -m 0644 -o root -g root oar-parexec.1 $(DESTDIR)/man/man1
	install -m 0644 -o root -g root oar-dispatch.1 $(DESTDIR)/man/man1
	install -m 0644 -o root -g root mpilauncher.1 $(DESTDIR)/man/man1
	install -m 0644 -o root -g root oar-envsh.1 $(DESTDIR)/man/man1

sync:
	svn update

mpilauncher: mpilauncher.o
	$(CC) $(CCFLAGS) -o $@ $<

%.o: %.cpp
	$(CC) $(CCFLAGS) -c $<

%.1: %.cpp
	sed -re 's#^[/ ]\* ?##; s#^// ?##' $< | pod2man -n $* $(PODFLAG) > $@

%.1: %
	pod2man -n $* $(PODFLAG) $< > $@

# astyle --style=banner -s3 mpilauncher.cpp
# perltidy -i=3 -ci=3 -icp -icb -pt=2 -bt=2 -bbt=2 -b oar-parexec
