-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgmakefile
More file actions
119 lines (96 loc) · 3.55 KB
/
gmakefile
File metadata and controls
119 lines (96 loc) · 3.55 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# -*- mode: makefile-gmake -*-
include ./conf/petigavariables
PETIGA_DIR ?= $(CURDIR)
OBJDIR := $(PETSC_ARCH)/obj
MODDIR := $(PETSC_ARCH)/include
LIBDIR := $(abspath $(PETSC_ARCH)/lib)
libpetiga_shared := $(LIBDIR)/libpetiga.$(SL_LINKER_SUFFIX)
libpetiga_static := $(LIBDIR)/libpetiga.$(AR_LIB_SUFFIX)
libpetiga := $(if $(filter-out no,$(BUILDSHAREDLIB)),$(libpetiga_shared),$(libpetiga_static))
pkgs := petiga
srcs-petiga.c := $(wildcard src/*.c)
srcs-petiga.cxx := $(wildcard src/*.cxx)
srcs-petiga.F90 := $(wildcard src/*.F90)
all : $(libpetiga)
.SECONDEXPANSION: # to expand $$(@D)/.DIR
# workarround old cygwin versions
ifeq ($(PETSC_CYGWIN_BROKEN_PIPE),1)
ifeq ($(shell basename $(AR)),ar)
V ?= 1
endif
endif
ifeq ($(V),)
quiet_HELP := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
quiet = @printf $(quiet_HELP)$(eval quiet_HELP:=)" %10s %s\n" "$1$2" "$@"; $($1)
else ifeq ($(V),0) # Same, but do not print any help
quiet = @printf " %10s %s\n" "$1$2" "$@"; $($1)
else # Show the full command line
quiet = $($1)
endif
ifndef C_DEPFLAGS
C_DEPFLAGS = $(if $(shell $(PCC) --version 2>/dev/null | grep "GCC\|clang\|ICC"),-MMD -MP)
endif
ifndef CXX_DEPFLAGS
CXX_DEPFLAGS = $(if $(shell $(CXX) --version 2>/dev/null | grep "GCC\|clang\|ICC"),-MMD -MP)
endif
ifndef FC_DEPFLAGS
FC_DEPFLAGS = $(if $(shell $(FC) --version 2>/dev/null | grep "GNU"),-MMD -MP)
endif
pcc = $(if $(findstring CONLY,$(PETSC_LANGUAGE)),CC,CXX)
PETSC_COMPILE.c = $(call quiet,$(pcc)) -c $(PCC_FLAGS) $(CFLAGS) $(CCPPFLAGS) $(C_DEPFLAGS)
PETSC_COMPILE.cxx = $(call quiet,CXX) -c $(PCC_FLAGS) $(CFLAGS) $(CCPPFLAGS) $(CXX_DEPFLAGS)
PETSC_COMPILE.F = $(call quiet,FC) -c $(FC_FLAGS) $(FFLAGS) $(FCPPFLAGS) $(FC_DEPFLAGS)
langs := c cxx F90
concatlangs = $(foreach lang, $(langs), $(srcs-$(1).$(lang):%.$(lang)=$(OBJDIR)/%.o))
srcs.o := $(foreach pkg, $(pkgs), $(call concatlangs,$(pkg)))
.SECONDARY: $(srcs.o)
$(libpetiga_shared) : objs := $(srcs.o)
$(libpetiga_shared) : libs := $(PETSC_LIB)
$(libpetiga_static) : objs := $(srcs.o)
%.$(SL_LINKER_SUFFIX) : $$(objs) | $$(@D)/.DIR
$(call quiet,CLINKER) -shared -o $@ $^ $(libs)
ifneq ($(DSYMUTIL),true)
$(call quiet,DSYMUTIL) $@
endif
%.$(AR_LIB_SUFFIX) : $$(objs) | $$(@D)/.DIR
ifeq ($(findstring win32fe lib,$(AR)),)
@$(RM) $@
$(call quiet,AR) $(AR_FLAGS) $@ $^
$(call quiet,RANLIB) $@
else
@$(RM) $@ $@.args
@cygpath -w $^ > $@.args
$(call quiet,AR) $(AR_FLAGS) $@ @$@.args
@$(RM) $@.args
endif
$(OBJDIR)/%.o : %.c | $$(@D)/.DIR
$(PETSC_COMPILE.c) $(abspath $<) -o $@
$(OBJDIR)/%.o : %.cxx | $$(@D)/.DIR
$(PETSC_COMPILE.cxx) $(abspath $<) -o $@
$(OBJDIR)/%.o : %.F90 | $(MODDIR)/.DIR $$(@D)/.DIR
ifneq ($(FC_MODULE_OUTPUT_FLAG),)
$(PETSC_COMPILE.F) $(abspath $<) -o $@ $(FC_MODULE_OUTPUT_FLAG)$(MODDIR)
else
cd $(MODDIR) && $(FC) -c $(FC_FLAGS) $(FFLAGS) $(FCPPFLAGS) $(FC_DEPFLAGS) $(abspath $<) -o $(abspath $@)
endif
# Hack: manual dependencies on object files
petiga.mod.o:= $(OBJDIR)/src/petigaftn.o
srcs-petiga.F90.o = $(srcs-petiga.F90:%.F90=$(OBJDIR)/%.o)
$(filter-out $(petiga.mod.o),$(srcs-petiga.F90.o)): | $(petiga.mod.o)
%/.DIR :
@$(MKDIR) $(@D)
@touch $@
.PRECIOUS: %/.DIR
.SUFFIXES: # Clear .SUFFIXES because we don't use implicit rules
.DELETE_ON_ERROR: # Delete likely-corrupt target file if rule fails
.PHONY: all clean print
clean:
@$(RM) -r $(OBJDIR) $(LIBDIR)/libpetiga.* $(MODDIR)/petiga.mod
# make print VAR=the-variable
print:
@echo $($(VAR))
allobj.d := $(srcs.o:%.o=%.d)
# Tell make that allobj.d are all up to date. Without
# this, the include below has quadratic complexity.
$(allobj.d) : ;
-include $(allobj.d)