-
Notifications
You must be signed in to change notification settings - Fork 2
/
NAM_rules.mk.in
348 lines (296 loc) · 14.4 KB
/
NAM_rules.mk.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
################################################################################
# NAM (Not AutoMake) included defaults. #
################################################################################
# Copyright (C) 2005 Jason But, Centre for Advanced Internet Architectures, #
# Swinburne University #
# #
# This library is free software; you can redistribute it and/or modify it under#
# the terms of the GNU Lesser General Public License as published by the Free #
# Software Foundation; either version 2.1 of the License, or (at your option) #
# any later version. #
# #
# This library 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 Lesser General Public License for more#
# details. #
# #
# You should have received a copy of the GNU Lesser General Public License along
# along with this library; if not, write to the Free Software Foundation, Inc.,#
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
################################################################################
################################################################################
# Set Makefile variables (based on results of "configure") #
################################################################################
##########
# Compiler default parameters.
# CXX - Compiler to use as determined by running "configure".
# CFLAGS - Compiler flags as determined by running "configure".
# CXXFLAGS - Compiler flags as determined by running "configure".
# DEFS - Pre-processor macros as defined by running "configure".
# DEPDIR - Subdirectory of where to place the dependency file
# CPPDEPFLAGS - Flags required to build the corresponding dependency file.
# DEFAULT_INCLUDES - Default include directories to specify during build
##########
CC = @CC@
CXX = @CXX@
CFLAGS = @CFLAGS@
CXXFLAGS = @CXXFLAGS@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
CPPDEPFLAGS = @CPPDEPFLAGS@
DEFAULT_INCLUDES = -I. -I$(SRCDIR)
LDFLAGS = @LDFLAGS@
##########
# Linker default parameters.
# LD - Linker to use.
# LIBS - List of libraries to link in as checked by running "configure"
##########
LD = @CXX@
LIBS = @LIBS@
SHAREDLIBEXT = @SHAREDLIBEXT@
SHAREDLDFLAGS = @SHAREDLDFLAGS@
##########
# Programs used by NAM
##########
RM = rm -f
AUTOCONF = autoconf
RANLIB = @RANLIB@
AR = ar
ARFLAGS = @ARFLAGS@
PYTHON3 = @PYTHON3@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_BINDIR = @prefix@@bindir@
INSTALL_SBINDIR = @prefix@@sbindir@
INSTALL_MANDIR = @prefix@@mandir@
##########
# sed script to transform a program name as defined during configure
##########
transform = @program_transform_name@
##########
# Set the variable OFFSETDIR to a string representation of the offset of the
# current directory from the top build directory (equal to the offset of the
# current source directory to the top level source directory.
##########
OFFSETDIR = `echo $(SRCDIR)/ | sed 's|$(TOPSRCDIR)/||'`
################################################################################
# Set default target. #
# Ensure that "all" is the default target prior to including gnu/bsd.mk which #
# will dynamically define other targets. #
################################################################################
.PHONY: all clean clean-default install uninstall
all:
################################################################################
# Support for different types of 'make' #
################################################################################
##########
# Set MAKEINCLUDE to either bsd.mk or gnu.mk based on the type of 'make' being
# executed. If BSD make is being executed then the first assignment will
# evaluate to setting the variable to bsd.mk. If we are running GNU make
# instead, this command will achieve nothing and the variable will not be set,
# and so the second command will conditionally set it to gnu.mk.
##########
# This is failing on ubuntu to GNU make (it's being included)
#MAKEINCLUDE != echo bsd.mk
MAKEINCLUDE ?= gnu.mk
##########
# Include the MAKEINCLUDE makefile with 'make' type specific instruction. This file:
# - Defines xxx_OBJS as a list of all object files for each target to be built.
# - Updates CLEANFILES with all object files to remove.
# - Update DEPFILES as a list of all dependency files to include.
# - Creates rule pre-requisites for each target to be linked
# - Includes all the dependency files
# - Creates DEPDIRS as a list of all directories where the dependency files live
##########
include $(TOPSRCDIR)/$(MAKEINCLUDE)
################################################################################
# Update variables. #
################################################################################
NOPRECOMP = @NOPRECOMP@
ifeq ($(NOPRECOMP),1)
PRECOMP_HEADER=
endif
##########
# Append all targets and precompiled headers to list of files to clean.
##########
CLEANFILES += $(PRECOMP_HEADER:.h=.h.gch)
CLEANFILES += $(PROGRAMS:=$(EXEEXT))
CLEANFILES += $(ARCHIVES:=.a)
CLEANFILES += $(SHAREDLIBS:=.$(SHAREDLIBEXT))
##########
# Suffixes used in rules listed below.
##########
.SUFFIXES: .h.gch .h
################################################################################
# Define pre-requisites for basic targets. #
################################################################################
ALL_TARGETS = $(DEPDIRS) $(PRECOMP_HEADER:.h=.h.gch) $(ARCHIVES:=.a) $(SHAREDLIBS:=.$(SHAREDLIBEXT)) $(PROGRAMS:=$(EXEEXT))
all: $(SUBDIRS) $(ALL_TARGETS)
clean:: $(SUBDIRS:%=%/__clean__) clean-default
dist:: $(SUBDIRS:%=%/__dist__) $(ALL_TARGETS)
install:: $(SUBDIRS:%=%/__install__) $(ALL_TARGETS) $(INSTALL_BIN:%=%__install__) $(INSTALL_SBIN:%=%__install__) $(INSTALL_MAN:%=%__install__)
uninstall:: $(SUBDIRS:%=%/__uninstall__) $(INSTALL_BIN:%=%__uninstall__) $(INSTALL_SBIN:%=%__uninstall__) $(INSTALL_MAN:%=%__uninstall__)
clean-default:
@$(RM) $(CLEANFILES)
################################################################################
# Support for compiling C++ code. #
################################################################################
##########
# Generic rule to generate precompiled headers.
##########
.h.h.gch:
$(NICE_ECHO) " Generating:\t$@"
$(CXX) $(CXXFLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ $<
##########
# Generic rule to generate the compiled object file.
##########
.c.o:
$(NICE_ECHO) " Compiling:\t`echo $< | sed 's|$(SRCDIR)/||'`"
$(CC) -x c $(CFLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CPPDEPFLAGS) -c -o $@ $<
##########
# Generic rule to generate the compiled object file.
##########
.cc.o:
$(NICE_ECHO) " Compiling:\t`echo $< | sed 's|$(SRCDIR)/||'`"
$(CXX) $(CXXFLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CPPDEPFLAGS) -c -o $@ $<
##########
# Generic rule to generate the compiled object file.
##########
.cpp.o:
$(NICE_ECHO) " Compiling:\t`echo $< | sed 's|$(SRCDIR)/||'`"
$(CXX) $(CXXFLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CPPDEPFLAGS) -c -o $@ $<
##########
# Generic rule to link the executable.
##########
$(PROGRAMS:=$(EXEEXT)):
$(NICE_ECHO) " Linking:\t$@"
$(LD) $($(@:$(EXEEXT)=)_OBJS) $($(@:$(EXEEXT)=)_LIBS) $(LIBS) $(LDFLAGS) $($(@:$(EXEEXT)=)_LDFLAGS) -o $@
##########
# Generic rule to link an archive (static library)
##########
$(ARCHIVES:=.a):
$(NICE_ECHO) " Archiving:\t$@"
$(AR) $(ARFLAGS) $@ $($(@:.a=)_OBJS)
$(NICE_ECHO) " Indexing:\t$@"
$(RANLIB) $@
##########
# Generic rule to link a shared library
##########
$(SHAREDLIBS:=.so):
$(NICE_ECHO) " Creating shared library:\t$@"
$(CXX) $(LDFLAGS) $($(@:.so=)_LDFLAGS) -shared -W1,-soname,$@ -o $@ -lc $($(@:.so=)_OBJS)
$(SHAREDLIBS:=.dylib):
$(NICE_ECHO) " Creating shared library:\t$@"
$(CXX) -prebind -bundle $($(@:.$(SHAREDLIBEXT)=)_LDFLAGS) -o $@ -lc $($(@:.$(SHAREDLIBEXT)=)_OBJS)
################################################################################
# Default Install and Uninstall rules. #
################################################################################
.PHONY: $(INSTALL_SBIN:%=%__install__) $(INSTALL_BIN:%=%__install__) $(INSTALL_MAN:%=%__install__)
.PHONY: $(INSTALL_SBIN:%=%__uninstall__) $(INSTALL_BIN:%=%__uninstall__) $(INSTALL_MAN:%=%__uninstall__)
##########
# Install rules
##########
$(INSTALL_SBIN:%=%__install__)::
source_file=$(@:%__install__=%)$(EXEEXT); \
install_file=$(INSTALL_SBINDIR)/`echo $(@:%__install__=%) | sed 's/$(EXEEXT)$$//;s,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo -e " Installing:\t\t$$install_file"; \
$(INSTALL_PROGRAM) "$$source_file" "$$install_file" || exit 1;
$(INSTALL_BIN:%=%__install__):
source_file=$(@:%__install__=%)$(EXEEXT); \
install_file=$(INSTALL_BINDIR)/`echo $(@:%__install__=%) | sed 's/$(EXEEXT)$$//;s,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo -e " Installing:\t\t$$install_file"; \
$(INSTALL_PROGRAM) "$$file" "$$install_file" || exit 1;
$(INSTALL_MAN:%=%__install__):
source_file=$(@:%__install__=%); \
man_section=`echo $(@:%__install__=%) | sed 's/^.*\.//'`; \
install_file=$(INSTALL_MANDIR)/man$$man_section/`echo $(@:%__install__=%) | sed 's,^.*/,,;$(transform)'`; \
echo -e " Installing:\t\t$$install_file"; \
$(INSTALL_DATA) "$(SRCDIR)/$$source_file" "$$install_file" || exit 1
##########
# Uninstall rules
##########
$(INSTALL_SBIN:%=%__uninstall__):
install_file=$(INSTALL_SBINDIR)/`echo $(@:%__uninstall__=%) | sed 's/$(EXEEXT)$$//;s,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo -e " Removing:\t\t$$install_file"; \
rm -f "$$install_file" || exit 1;
$(INSTALL_BIN:%=%__uninstall__):
install_file=$(INSTALL_BINDIR)/`echo $(@:%__uninstall__=%) | sed 's/$(EXEEXT)$$//;s,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo -e " Removing:\t\t$$install_file"; \
rm -f "$$install_file" || exit 1;
$(INSTALL_MAN:%=%__uninstall__):
man_section=`echo $(@:%__uninstall__=%) | sed 's/^.*\.//'`; \
install_file=$(INSTALL_MANDIR)/man$$man_section/`echo $(@:%__uninstall__=%) | sed 's,^.*/,,;$(transform)'`; \
echo -e " Removing:\t\t$$install_file"; \
rm -f "$$install_file" "$$install_file.gz" || exit 1;
################################################################################
# Support for make in subdirectories. #
################################################################################
##########
# Recursive calls to make.
# Echo a nice output of the directory that we enter before entering that
# directory and executing make with the required target.
##########
.PHONY: $(SUBDIRS) $(SUBDIRS:%=%/__clean__) $(SUBDIRS:%=%/__install__) $(SUBDIRS:%=%/__dist__) $(SUBDIRS:%=%/__uninstall__)
$(SUBDIRS)::
$(NICE_ECHO) " Making in\t$(OFFSETDIR)$@"
@cd $@ && $(MAKE)
$(NICE_ECHO) " Leaving\t$(OFFSETDIR)$@\n"
$(SUBDIRS:%=%/__clean__):
$(NICE_ECHO) " Cleaning in\t$(OFFSETDIR)`dirname $@`"
cd `dirname $@` && $(MAKE) clean
$(SUBDIRS:%=%/__dist__):
$(NICE_ECHO) " Creating distribution from\t$(OFFSETDIR)`dirname $@`"
cd `dirname $@` && $(MAKE) dist
$(NICE_ECHO) " Leaving\t\t$(OFFSETDIR)`dirname $@`\n"
$(SUBDIRS:%=%/__install__):
$(NICE_ECHO) " Installing from\t$(OFFSETDIR)`dirname $@`"
cd `dirname $@` && $(MAKE) install
$(NICE_ECHO) " Leaving\t\t$(OFFSETDIR)`dirname $@`\n"
$(SUBDIRS:%=%/__uninstall__):
$(NICE_ECHO) " Uninstalling from\t$(OFFSETDIR)`dirname $@`"
cd `dirname $@` && $(MAKE) uninstall
$(NICE_ECHO) " Leaving\t\t$(OFFSETDIR)`dirname $@`\n"
################################################################################
# Support for creating dependency subdirectories. #
################################################################################
.PHONY: $(DEPDIRS)
$(DEPDIRS)::
if test ! -d $@; then mkdir -p $@; fi
################################################################################
# Support for re-making Makefiles (and friends). #
################################################################################
##########
# The actual Makefile depends on its source Makefile.in and the config.status
# script in the top build directory. It is regenerated through executing the
# config.status script with the name of the Makefile as a parameter.
##########
Makefile: $(SRCDIR)/Makefile.in $(TOPBUILDDIR)/NAM_rules.mk $(TOPBUILDDIR)/config.status
$(NICE_ECHO) " Regenerating:\t$(OFFSETDIR)$@"
cd $(TOPBUILDDIR) && ./config.status $(OFFSETDIR)$@
##########
# The included NAM_rules.mk depends on its source NAM_rules.mk.in and the
# config.status script in the top build directory. It is regenerated through
# executing the config.status script with NAM_rules.mk as a parameter.
##########
$(TOPBUILDDIR)/NAM_rules.mk: $(TOPSRCDIR)/NAM_rules.mk.in $(TOPBUILDDIR)/config.status
$(NICE_ECHO) " Regenerating:\tNAM_rules.mk"
cd $(TOPBUILDDIR) && ./config.status NAM_rules.mk
#cd $(TOPBUILDDIR) && ./config.status NAM_rules.mk
##########
# The config.status script in the top build directory depends on the configure
# script in the top source directory. It is regenerated through executing the
# config.status script with the "--recheck" flag.
##########
$(TOPBUILDDIR)/config.status: $(TOPSRCDIR)/configure
$(NICE_ECHO) " Re-running\tconfigure"
cd $(TOPBUILDDIR) && ./config.status --recheck
##########
# The configure script in the top source directory depends on the source
# configure.in/ac script in the same directory. To regenerate it we need to
# run autoconf on it.
##########
$(TOPSRCDIR)/configure: $(TOPSRCDIR)/configure.in
$(NICE_ECHO) " Regenerating:\t$@"
cd $(TOPSRCDIR) && $(AUTOCONF)