-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.in
209 lines (173 loc) · 6.25 KB
/
Makefile.in
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#-------------------------------------------------------------------------
# File : Makefile
#-------------------------------------------------------------------------
#
# Purpose : Makefile template
#
# Remarks :
#
# References :
#
# Revisions :
#-------------------------------------------------------------------------
# Identity of this package.
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
PACKAGE_STRING=@PACKAGE_STRING@
PACKAGE_BUGREPORT=@PACKAGE_BUGREPORT@
PACKAGE_URL=@PACKAGE_URL@
#----------------------------------------------------------------------
# METIS Library
#----------------------------------------------------------------------
METISDIR=@METISDIR@
#----------------------------------------------------------------------
# PPM Library
#----------------------------------------------------------------------
PPMDIR=@PPMDIR@
#----------------------------------------------------------------------
# LibTIFF
#----------------------------------------------------------------------
TIFFDIR=@TIFFDIR@
#----------------------------------------------------------------------
# BOOST
#----------------------------------------------------------------------
BOOSTDIR=@BOOSTDIR@
#----------------------------------------------------------------------
# PPM_RC
#----------------------------------------------------------------------
srcdir=@srcdir@
builddir=@builddir@
prefix=@prefix@
LIBS=@LIBS@
CLIBS=@CLIBS@
CFLAGS=@CFLAGS@
CXXFLAGS=@CXXFLAGS@
FCFLAGS=@FCFLAGS@
LDFLAGS=@LDFLAGS@
CPPFLAGS=@CPPFLAGS@
MODFLAGS=@MODFLAGS@
CDEBUG=@CDEBUG@
DEBUG=@DEBUG@
FC=@FC@
CC=@CC@
CXX=@CXX@
SED=@SED@
CPP=@CPP@
SHELL=@SHELL@
# These are important build directories
SRC_DIR := $(srcdir)
OBJ_DIR := $(builddir)/objects
MODULES_DIR := $(builddir)/include
RUN_DIR := $(builddir)/run
# These variables are standard
PROGRAM := ppm_rc
TARGET := $(RUN_DIR)/$(PROGRAM)
CG := ppm pp -M $(PPMDIR)/$(srcdir)/macros/:$(srcdir)/macros/
DEPS := $(builddir)/utils/deps.sh
RUN := $(builddir)/utils/runcmd.sh
LOG := compile.log
# These are paths that get included during pre-processing
CPPVPATH := $(SRC_DIR):
CPPVPATH += $(MODULES_DIR):
CPPINCLS := $(patsubst %,-I%, $(subst :, ,$(CPPVPATH)))
# These are paths that get included during compilation
VPATH := $(patsubst %,-I%, $(subst :, ,$(SRC_DIR))):
VPATH += $(patsubst %,$(MODFLAGS)%, $(subst :, ,$(MODULES_DIR))):
INCLS := $(subst :, ,$(VPATH))
# These are the files that get generated and used during compilation
FSOURCES := $(notdir $(wildcard $(SRC_DIR)/ppm_rc*.f))
CSOURCES := $(notdir $(wildcard $(SRC_DIR)/**/ppm_rc*.c))
CVPATH := src/cutil
#$(dir $(wildcard $(SRC_DIR)/**/ppm_rc*.c))
CXXSOURCES := $(notdir $(wildcard $(SRC_DIR)/**/ppm_rc*.cc))
CXXVPATH := src/ccutil
#$(dir $(wildcard $(SRC_DIR)/**/ppm_rc*.cc))
FOBJECTS := $(FSOURCES:%.f=$(OBJ_DIR)/%.o)
COBJECTS := $(CSOURCES:%.c=$(OBJ_DIR)/%.o)
CXXOBJECTS := $(CXXSOURCES:%.cc=$(OBJ_DIR)/%.o)
MODULES := $(FSOURCES:%.f=$(MODULES_DIR)/%.mod)
DEPENDENCIES := $(CSOURCES:%.c=$(OBJ_DIR)/%.d)
DEPENDENCIES += $(CXXSOURCES:%.cc=$(OBJ_DIR)/%.d)
DEPENDENCIES += $(FSOURCES:%.f=$(OBJ_DIR)/%.d)
# This creates the install directories if they don't exist
ifneq ($(MAKECMDGOALS),clean)
$(warning Checking for directories...)
$(shell test -d $(OBJ_DIR) || mkdir $(OBJ_DIR))
$(shell test -d $(MODULES_DIR) || mkdir -p $(MODULES_DIR))
$(shell test -d $(RUN_DIR) || mkdir -p $(RUN_DIR))
$(warning done.)
else
$(warning Removing the '$(LOG)' file)
$(shell test -e $(LOG) && rm $(LOG))
$(warning Clean up the files created by make)
endif
.PHONY: all clean install uninstall
.DEFAULT: ;
all: $(PROGRAM)
# Dont delete the given intermediate files
#$(DEPENDENCIES)
.SECONDARY:
# Implicit rules
ifneq ($(MAKECMDGOALS),clean)
CPPCMD = $(CPP) $(CPPFLAGS) $(CPPINCLS) -traditional-cpp -P $< | $(CG) > $@
$(OBJ_DIR)/%.f : $(SRC_DIR)/%.f
@printf " PPM %-42s" $<; \
$(RUN) "$(CPPCMD)" $(LOG) "Preprocessing Error"
ENV = CPP="$(CPP)" SED="$(SED)" INC="$(CPPINCLS)" DEFINE="$(CPPFLAGS)" OBJDIR="$(OBJ_DIR)" SRCDIR="$(SRC_DIR)"
DEPCMD = $(DEPS) --ppm_rc $< $@
$(OBJ_DIR)/%.d : $(SRC_DIR)/%.f $(OBJ_DIR)/%.f
@printf " DEP %-42s" $<; \
$(ENV) $(RUN) "$(DEPCMD)" $(LOG) "Dependency Error"
CPCMD = cp $< $@
$(OBJ_DIR)/%.c : $(CVPATH)/%.c
@printf " PPM %-42s" $<; \
$(RUN) "$(CPCMD)" $(LOG) "Error copying C File"
$(OBJ_DIR)/%.d : $(CVPATH)/%.c $(OBJ_DIR)/%.c
@printf " DEP %-42s" $<; \
$(ENV) $(RUN) "$(DEPCMD)" $(LOG) "Dependency Error"
CXXPCMD = cp $< $@
$(OBJ_DIR)/%.cc : $(CXXVPATH)/%.cc
@printf " PPM %-42s" $<; \
$(RUN) "$(CXXPCMD)" $(LOG) "Error copying CXX File"
$(OBJ_DIR)/%.d : $(CXXVPATH)/%.cc $(OBJ_DIR)/%.cc
@printf " DEP %-42s" $<; \
$(ENV) $(RUN) "$(DEPCMD)" $(LOG) "Dependency Error"
endif
CCOMPILECMD = $(CC) $(CPPFLAGS) $(CFLAGS) -I$(CVPATH) $(CDEBUG) -Llib -c -o $@ $<
$(OBJ_DIR)/%.o : $(OBJ_DIR)/%.c
@printf " CC %-42s" $<; \
$(RUN) "$(CCOMPILECMD)" $(LOG) "Compile Error"
CLINKCMD = $(CC) $(COBJECTS) -o $@ $(LDFLAGS) $(CLIBS)
CXXCOMPILECMD = $(CXX) $(CPPFLAGS) $(CXXFLAGS) -I$(CXXVPATH) $(CDEBUG) -Llib -c -o $@ $<
$(OBJ_DIR)/%.o : $(OBJ_DIR)/%.cc
@printf " CXX %-42s" $<; \
$(RUN) "$(CXXCOMPILECMD)" $(LOG) "Compile Error"
CXXLINKCMD = $(CXX) $(CXXOBJECTS) -o $@ $(LDFLAGS) $(CLIBS)
COMPILECMD = $(FC) $(INCLS) $(FCFLAGS) $(DEBUG) -Llib -c -o $@ $<
$(OBJ_DIR)/%.o : $(OBJ_DIR)/%.f $(OBJ_DIR)/%.d
@printf " FC %-42s" $<; \
$(RUN) "$(COMPILECMD)" $(LOG) "Compile Error" \
FLINKCMD = $(FC) $(FOBJECTS) $(COBJECTS) $(CXXOBJECTS) -o $@ $(LDFLAGS) $(LIBS) $(CLIBS)
$(PROGRAM): $(FOBJECTS) $(COBJECTS) $(CXXOBJECTS)
@printf " LINK %-42s" $@; \
$(RUN) "$(FLINKCMD)" $(LOG) "Linking Error"\
$(RUN) "$(CLINKCMD)" $(LOG) "Linking Error"\
$(RUN) "$(CXXLINKCMD)" $(LOG) "Linking Error"\
&& mv $(builddir)/*.mod $(MODULES_DIR) 2>/dev/null; \
mv $(PROGRAM) $(TARGET)
# This is used to clean up the files created when running make
clean:
rm -fR $(OBJ_DIR)
rm -fR $(MODULES_DIR)
rm -fR $(builddir)/lib
rm -fR $(builddir)/*.mod
install:
mkdir -p $(prefix)/bin
cp $(TARGET) $(prefix)/bin
unintsall:
rm $(prefix)/bin/$(PROGRAM)
# This ensures all dependency files are up-to-date
# WARNING: The directive below will fail silently, in case of problems
# remove the leading s: include $(DEPENDENCIES)
sinclude $(DEPENDENCIES)