forked from ESCOMP/CMEPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (61 loc) · 1.96 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# BASE_DIR points to root of CMEPS clone
BASE_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
ifneq ($(origin ESMFMKFILE), environment)
$(error Environment variable ESMFMKFILE was not set.)
endif
include $(ESMFMKFILE)
ifndef FC
$(error FC not defined)
endif
ifndef CC
$(error CC not defined)
endif
ifndef CXX
$(error CXX not defined)
endif
ifndef PIO_LIBDIR
$(error PIO_LIBDIR should point to PIO library directory.)
endif
ifndef PIO_INC
$(error PIO_INC should point to PIO include directory.)
endif
ifndef INTERNAL_PIO_INIT
INTERNAL_PIO_INIT := 1
endif
$(info INTERNAL_PIO_INIT is set to $(INTERNAL_PIO_INIT))
MEDIATOR_DIR := $(BASE_DIR)/mediator
LIBRARY_MEDIATOR := $(MEDIATOR_DIR)/libcmeps.a
LIBRARY_UTIL := $(BASE_DIR)/util/libcmeps_util.a
all default: install
install: $(LIBRARY_MEDIATOR)
ifndef INSTALLDIR
$(error INSTALLDIR not defined for CMEPS installation location)
else
rm -f cmeps.mk.install
@echo "# ESMF self-describing build dependency makefile fragment" > cmeps.mk.install
@echo "# src location: $(PWD)" >> cmeps.mk.install
@echo >> cmeps.mk.install
@echo "ESMF_DEP_FRONT = MED" >> cmeps.mk.install
@echo "ESMF_DEP_INCPATH = $(INSTALLDIR)/include" >> cmeps.mk.install
@echo "ESMF_DEP_CMPL_OBJS = " >> cmeps.mk.install
@echo "ESMF_DEP_LINK_OBJS = $(INSTALLDIR)/libcmeps.a $(INSTALLDIR)/libcmeps_util.a $(PIO_LIBDIR)/libpiof.a $(PIO_LIBDIR)/libpioc.a $(PNETCDF_LD_OPTS)" >> cmeps.mk.install
mkdir -p $(INSTALLDIR)
mkdir -p $(INSTALLDIR)/include
cp -f $(LIBRARY_UTIL) $(INSTALLDIR)
cp -f $(LIBRARY_MEDIATOR) $(INSTALLDIR)
cp -f mediator/*.mod $(INSTALLDIR)/include
cp -f util/*.mod $(INSTALLDIR)/include
cp -f cmeps.mk.install $(INSTALLDIR)/cmeps.mk
endif
$(LIBRARY_MEDIATOR): $(LIBRARY_UTIL) .FORCE
cd mediator ;\
exec $(MAKE) PIO_INC=$(PIO_INC) INTERNAL_PIO_INIT=$(INTERNAL_PIO_INIT)
$(LIBRARY_UTIL): .FORCE
cd util ;\
exec $(MAKE) PIO_INC=$(PIO_INC)
.FORCE:
clean:
cd mediator; \
exec $(MAKE) clean
cd util; \
exec $(MAKE) clean