I have a FORTRAN code which needs a C routine to calculate a measure. The C routine includes .c and .h files and in the documentation it is written:
If you want to embed the hypervolume function into your own C/C++ code, the main function for computing the hypervolume (
fpli_hv
) is self-contained in the filehv.c
. A simple way to add it to your own code is to include Makefile.lib into your Makefile and link againstfpli_hv.a
. The exported function is:"
double fpli_hv(double *front, int d, int n, double *ref);
The makefile.lib is also as follows:
VARIANT ?= 4
HV_SRCS = hv.c
HV_HDRS = hv.h
HV_OBJS = $(HV_SRCS:.c=.o)
HV_LIB = fpli_hv.a
$(HV_LIB): $(HV_OBJS)
@$(RM) $@
$(QUIET_AR)$(AR) rcs $@ $^
## Augment CFLAGS for hv.[co] objects
hv.o: CPPFLAGS += -D VARIANT=$(VARIANT)
## Dependencies:
$(HV_OBJS): $(HV_HDRS)
How can I embed this C routine in FORTRAN makefiles? Could you please help me, perhaps by providing an illustrative example. I searched for this issue and found a number of examples, but they all showed simple examples which did not require manipulating makefiles.