# Makefile for parallel package for Octave
#
# Copyright (C) 2015, 2016 Olaf Till
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see .
DEBUG := no
MKOCTFILE ?= @MKOCTFILE@
PKG_CONFIG ?= @PKG_CONFIG@
CC ?= @CC@
CXX ?= @CXX@
CFLAGS ?= -g -O2
ifeq ($(DEBUG), yes)
CXXFLAGS ?= -g -O0
CLUSTER_CXXFLAGS = $(CXXFLAGS)
else
CXXFLAGS ?= -g -O2
# no reason anymore to be different, but leave them extra just in case
CLUSTER_CXXFLAGS = $(CXXFLAGS)
endif
HAVE_GNUTLS := @HAVE_GNUTLS@
HAVE_GNUTLS_EXTRA := @HAVE_GNUTLS_EXTRA@
HAVE_GETPASS := @HAVE_GETPASS@
REDUCED_BUILD := @REDUCED_BUILD@
ifeq ($(REDUCED_BUILD), yes)
octs = $(local_octs_set1)
else
octs = $(cluster_oct) $(generate_srp_data_oct) $(local_octs)
ms = install_vars.m netarrayfun.m __netcellfun_guardfun__.m \
netcellfun.m __pserver_exit__.m rfeval.m scloseall.m server.m
endif
# All compiled user functions for parallel cluster must be in one
# file, otherwise registration of new octave_base_value derived type
# is not seen by the other functions.
cluster_oct := parallel_interface.oct
local_octs_set1 := fload.oct fsave.oct __exit__.oct
local_octs_set2 := select.oct __visglobal__.oct
local_octs := $(local_octs_set1) $(local_octs_set2)
cluster_objs = $(cluster_oobjs) $(cluster_lobjs)
cluster_oobjs := pconnect.o pserver.o sclose.o \
reval.o precv.o psend.o select_sockets.o \
network_get_info.o network_set.o
cluster_lobjs := p-connection.o p-streams.o
ifeq ($(HAVE_GNUTLS), yes)
generate_srp_data_oct := parallel_generate_srp_data.oct
cluster_oobjs := $(cluster_oobjs) parallel_generate_srp_data.o
cluster_lobjs := $(cluster_lobjs) gnutls-callbacks.o sensitive-data.o
ifneq ($(HAVE_GETPASS), yes)
getpass_obj := getpass.o
endif
ifeq ($(HAVE_GNUTLS_EXTRA), yes)
GNUTLS_CFLAGS := $(shell $(PKG_CONFIG) --cflags gnutls-extra) -Wno-int-to-pointer-cast
GNUTLS_LIBS := $(shell $(PKG_CONFIG) --libs gnutls-extra)
else
GNUTLS_CFLAGS := $(shell $(PKG_CONFIG) --cflags gnutls) -Wno-int-to-pointer-cast
GNUTLS_LIBS := $(shell $(PKG_CONFIG) --libs gnutls)
endif
endif
all: $(octs) $(ms)
getpass.o: getpass.c
$(CC) -c getpass.c $(CFLAGS) -fPIC
error-helpers.o: error-helpers.cc error-helpers.h
CXX=$(CXX) CXXFLAGS="$(CXXFLAGS)" $(MKOCTFILE) -c error-helpers.cc
$(octs): error-helpers.h
$(cluster_objs): parallel-gnutls.h p-connection.h p-streams.h sensitive-data.h \
p-sighandler.h
$(cluster_objs): %.o: %.cc config.h
CXX=$(CXX) CXXFLAGS="$(CLUSTER_CXXFLAGS) $(GNUTLS_CFLAGS)" $(MKOCTFILE) -c $<
%.o: %.cc config.h
CXX=$(CXX) CXXFLAGS="$(CXXFLAGS)" $(MKOCTFILE) -c $<
$(generate_srp_data_oct): %.oct: %.o $(cluster_lobjs) $(getpass_obj) \
error-helpers.o
CXX=$(CXX) $(MKOCTFILE) $< $(cluster_lobjs) $(getpass_obj) error-helpers.o $(GNUTLS_LIBS)
$(cluster_oct): $(cluster_objs) $(getpass_obj) error-helpers.o
CXX=$(CXX) $(MKOCTFILE) -o $(cluster_oct) $(cluster_objs) $(getpass_obj) error-helpers.o $(GNUTLS_LIBS)
%.oct: %.o error-helpers.o
CXX=$(CXX) $(MKOCTFILE) $< error-helpers.o
$(ms): %.rename_to_m %.m
mv $< $(addsuffix .m,$(basename $<))
.PHONY: clean
clean: ; rm -f *.o *.oct