.PHONY: all install clean

INCDIR  = /usr/local/include
MKDIR_P = install -m 755 -d
INSTALL = install
TARGET  = x86_64-unknown-linux-gnu
CREATE_HEADERS = xmp_coarray_put.h xmp_coarray_get.h xmp_coarray_getsub.h xmp_coarray_alloc.h xmp_coarray_reduction.h
HEADERS = xmp_coarray.h xmp_lib.h xmp_coarray_atomic.h

FALSE      = 1
TRUE       = 0
IS_SUPERUX = @SUPERUX@
ifeq ($(IS_SUPERUX), $(TRUE))
  COARRAY_SYNC_H = xmp_coarray_sync_sxace.h
else
  COARRAY_SYNC_H = xmp_coarray_sync.h
endif

%.h:	%.h.sh
	bash $< $(TARGET) > $@

all: $(CREATE_HEADERS)

install: $(CREATE_HEADERS) $(HEADERS)
	$(MKDIR_P) $(DESTDIR)$(INCDIR)
	$(INSTALL) $(COARRAY_SYNC_H) $(DESTDIR)$(INCDIR)/xmp_coarray_sync.h
	$(INSTALL) $(HEADERS) $(DESTDIR)$(INCDIR)
	$(INSTALL) $^ $(DESTDIR)$(INCDIR)

clean:
	rm -f $(CREATE_HEADERS)
