1# Copyright (C) Internet Systems Consortium, Inc. ("ISC") 2# 3# SPDX-License-Identifier: MPL-2.0 4# 5# This Source Code Form is subject to the terms of the Mozilla Public 6# License, v. 2.0. If a copy of the MPL was not distributed with this 7# file, you can obtain one at https://mozilla.org/MPL/2.0/. 8# 9# See the COPYRIGHT file distributed with this work for additional 10# information regarding copyright ownership. 11 12### 13### Common Makefile rules for BIND 9. 14### 15 16### 17### Paths 18### 19### Note: paths that vary by Makefile MUST NOT be listed 20### here, or they won't get expanded correctly. 21 22prefix = @prefix@ 23exec_prefix = @exec_prefix@ 24bindir = @bindir@ 25sbindir = @sbindir@ 26includedir = @includedir@ 27libdir = @libdir@ 28sysconfdir = @sysconfdir@ 29localstatedir = @localstatedir@ 30mandir = @mandir@ 31datarootdir = @datarootdir@ 32 33plugindir = ${libdir}/named 34 35DESTDIR = 36 37@SET_MAKE@ 38 39top_builddir = @BIND9_TOP_BUILDDIR@ 40 41### 42### All 43### 44### Makefile may define: 45### PREREQS 46### TARGETS 47 48all: ${PREREQS} subdirs ${TARGETS} testdirs 49 50### 51### Subdirectories 52### 53### Makefile may define: 54### SUBDIRS 55### DEPDIRS 56 57ALL_SUBDIRS = ${SUBDIRS} nulldir 58ALL_TESTDIRS = ${TESTDIRS} nulldir 59 60# 61# We use a single-colon rule so that additional dependencies of 62# subdirectories can be specified after the inclusion of this file. 63# The "depend" and "testdirs" targets are treated the same way. 64# 65subdirs: 66 @for i in ${ALL_SUBDIRS}; do \ 67 if [ "$$i" != "nulldir" -a -d $$i ]; then \ 68 echo "making all in `pwd`/$$i"; \ 69 (cd $$i; ${MAKE} ${MAKEDEFS} DESTDIR="${DESTDIR}" all) || exit 1; \ 70 fi; \ 71 done 72 73# 74# Tests are built after the targets instead of before 75# 76testdirs: subdirs ${TARGETS} 77 @for i in ${ALL_TESTDIRS}; do \ 78 if [ "$$i" != "nulldir" -a -d $$i ]; then \ 79 echo "making all in `pwd`/$$i"; \ 80 (cd $$i; ${MAKE} ${MAKEDEFS} DESTDIR="${DESTDIR}" all) || exit 1; \ 81 fi; \ 82 done 83 84install:: all 85 86install uninstall clean distclean maintainer-clean doc docclean man manclean:: 87 @for i in ${ALL_SUBDIRS} ${ALL_TESTDIRS}; do \ 88 if [ "$$i" != "nulldir" -a -d $$i -a -f $$i/Makefile ]; then \ 89 echo "making $@ in `pwd`/$$i"; \ 90 (cd $$i; ${MAKE} ${MAKEDEFS} DESTDIR="${DESTDIR}" $@) || exit 1; \ 91 fi; \ 92 done 93 94### 95### C Programs 96### 97### Makefile must define 98### CC 99### Makefile may define 100### CFLAGS 101### LDFLAGS 102### CINCLUDES 103### CDEFINES 104### CWARNINGS 105### User may define externally 106### EXT_CFLAGS 107 108CC = @CC@ 109CFLAGS = @CFLAGS@ 110LDFLAGS = @LDFLAGS@ 111STD_CINCLUDES = @STD_CINCLUDES@ 112STD_CDEFINES = @STD_CDEFINES@ 113STD_CWARNINGS = @STD_CWARNINGS@ 114 115BUILD_CC = @BUILD_CC@ 116BUILD_CFLAGS = @BUILD_CFLAGS@ 117BUILD_CPPFLAGS = @BUILD_CPPFLAGS@ 118BUILD_LDFLAGS = @BUILD_LDFLAGS@ 119BUILD_LIBS = @BUILD_LIBS@ 120 121FSTRM_CFLAGS = @FSTRM_CFLAGS@ 122FSTRM_LIBS = @FSTRM_LIBS@ 123 124GSSAPI_LIBS = @DNS_CRYPTO_LIBS@ 125 126JSON_C_CFLAGS = @JSON_C_CFLAGS@ 127JSON_C_LIBS = @JSON_C_LIBS@ 128 129LFS_CFLAGS = @LFS_CFLAGS@ 130LFS_LDFLAGS = @LFS_LDFLAGS@ 131LFS_LIBS = @LFS_LIBS@ 132 133LIBUV_CFLAGS = @LIBUV_CFLAGS@ 134LIBUV_LIBS = @LIBUV_LIBS@ 135 136LIBXML2_CFLAGS = @LIBXML2_CFLAGS@ 137LIBXML2_LIBS = @LIBXML2_LIBS@ 138 139LMDB_CFLAGS = @LMDB_CFLAGS@ 140LMDB_LIBS = @LMDB_LIBS@ 141 142MAXMINDDB_CFLAGS = @MAXMINDDB_CFLAGS@ 143MAXMINDDB_LIBS = @MAXMINDDB_LIBS@ 144 145OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ 146OPENSSL_LIBS = @OPENSSL_LIBS@ 147 148PROTOBUF_C_CFLAGS = @PROTOBUF_C_CFLAGS@ 149PROTOBUF_C_LIBS = @PROTOBUF_C_LIBS@ 150 151ZLIB_CFLAGS = @ZLIB_CFLAGS@ 152ZLIB_LIBS = @ZLIB_LIBS@ 153 154NO_LIBTOOL_ISCLIBS = ${OPENSSL_LIBS} ${JSON_C_LIBS} ${LIBXML2_LIBS} ${ZLIB_LIBS} ${LIBUV_LIBS} 155NO_LIBTOOL_DNSLIBS = ${LMDB_LIBS} ${MAXMINDDB_LIBS} ${GSSAPI_LIBS} ${PROTOBUF_C_LIBS} ${FSTRM_LIBS} 156 157.SUFFIXES: 158.SUFFIXES: .c .@O@ 159 160ALWAYS_INCLUDES = -include ${top_builddir}/config.h -I${top_builddir} -I${top_srcdir} 161ALWAYS_DEFINES = @ALWAYS_DEFINES@ 162ALWAYS_WARNINGS = 163 164ALL_CPPFLAGS = \ 165 ${ALWAYS_INCLUDES} ${CINCLUDES} ${STD_CINCLUDES} \ 166 ${ALWAYS_DEFINES} ${CDEFINES} ${STD_CDEFINES} 167 168ALL_CFLAGS = ${EXT_CFLAGS} ${ALL_CPPFLAGS} ${CFLAGS} \ 169 ${ALWAYS_WARNINGS} ${STD_CWARNINGS} ${CWARNINGS} 170 171@BIND9_CO_RULE@ 172 ${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c $< 173 174SHELL = @SHELL@ 175LIBTOOL = @LIBTOOL@ 176LIBTOOL_MODE_COMPILE = ${LIBTOOL} @LIBTOOL_MODE_COMPILE@ 177LIBTOOL_MODE_INSTALL = ${LIBTOOL} @LIBTOOL_MODE_INSTALL@ 178LIBTOOL_MODE_LINK = ${LIBTOOL} @LIBTOOL_MODE_LINK@ 179LIBTOOL_MODE_UNINSTALL = ${LIBTOOL} @LIBTOOL_MODE_UNINSTALL@ 180PURIFY = @PURIFY@ 181 182MKDEP = ${SHELL} ${top_builddir}/make/mkdep 183 184### 185### This is a template compound command to build an executable binary with 186### an internal symbol table. 187### This process is tricky. We first link all objects including a tentative 188### empty symbol table, then get a tentative list of symbols from the resulting 189### binary ($@tmp0). Next, we re-link all objects, but this time with the 190### symbol table just created ($tmp@1). The set of symbols should be the same, 191### but the corresponding addresses would be changed due to the difference on 192### the size of symbol tables. So we create the symbol table and re-create the 193### objects once again. Finally, we check the symbol table embedded in the 194### final binaryis consistent with the binary itself; otherwise the process is 195### terminated. 196### 197### To minimize the overhead of creating symbol tables, the autoconf switch 198### --enable-symtable takes an argument so that the symbol table can be created 199### on a per application basis: unless the argument is set to "all", the symbol 200### table is created only when a shell (environment) variable "MAKE_SYMTABLE" is 201### set to a non-null value in the rule to build the executable binary. 202### 203### Each Makefile.in that uses this macro is expected to define "LIBS" and 204### "NOSYMLIBS"; the former includes libisc with an empty symbol table, and 205### the latter includes libisc without the definition of a symbol table. 206### The rule to make the executable binary will look like this 207### binary@EXEEXT@: ${OBJS} 208### #export MAKE_SYMTABLE="yes"; \ <- enable if symtable is always needed 209### export BASEOBJS="${OBJS}"; \ 210### ${FINALBUILDCMD} 211### 212### Normally, ${LIBS} includes all necessary libraries to build the binary; 213### there are some exceptions however, where the rule lists some of the 214### necessary libraries explicitly in addition to (or instead of) ${LIBS}, 215### like this: 216### binary@EXEEXT@: ${OBJS} 217### cc -o $@ ${OBJS} ${OTHERLIB1} ${OTHERLIB2} ${LIBS} 218### in order to modify such a rule to use this compound command, a separate 219### variable "LIBS0" should be deinfed for the explicitly listed libraries, 220### while making sure ${LIBS} still includes libisc. So the above rule would 221### be modified as follows: 222### binary@EXEEXT@: ${OBJS} 223### export BASEOBJS="${OBJS}"; \ 224### export LIBS0="${OTHERLIB1} ${OTHERLIB2}"; \ 225### ${FINALBUILDCMD} 226### See bin/check/Makefile.in for a complete example of the use of LIBS0. 227### 228FINALBUILDCMD = if [ X"${MKSYMTBL_PROGRAM}" = X -o X"$${MAKE_SYMTABLE:-${ALWAYS_MAKE_SYMTABLE}}" = X ] ; then \ 229 ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${ALL_CFLAGS} ${LDFLAGS} \ 230 -o $@ $${BASEOBJS} $${LIBS0} ${LIBS}; \ 231 else \ 232 rm -f $@tmp0; \ 233 ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${ALL_CFLAGS} ${LDFLAGS} \ 234 -o $@tmp0 $${BASEOBJS} $${LIBS0} ${LIBS} || exit 1; \ 235 rm -f $@-symtbl.c $@-symtbl.@O@; \ 236 ${MKSYMTBL_PROGRAM} ${top_srcdir}/util/mksymtbl.pl \ 237 -o $@-symtbl.c $@tmp0 || exit 1; \ 238 $(MAKE) $@-symtbl.@O@ || exit 1; \ 239 rm -f $@tmp1; \ 240 ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${ALL_CFLAGS} ${LDFLAGS} \ 241 -o $@tmp1 $${BASEOBJS} $@-symtbl.@O@ $${LIBS0} ${NOSYMLIBS} || exit 1; \ 242 rm -f $@-symtbl.c $@-symtbl.@O@; \ 243 ${MKSYMTBL_PROGRAM} ${top_srcdir}/util/mksymtbl.pl \ 244 -o $@-symtbl.c $@tmp1 || exit 1; \ 245 $(MAKE) $@-symtbl.@O@ || exit 1; \ 246 ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${ALL_CFLAGS} ${LDFLAGS} \ 247 -o $@tmp2 $${BASEOBJS} $@-symtbl.@O@ $${LIBS0} ${NOSYMLIBS}; \ 248 ${MKSYMTBL_PROGRAM} ${top_srcdir}/util/mksymtbl.pl \ 249 -o $@-symtbl2.c $@tmp2; \ 250 count=0; \ 251 until diff $@-symtbl.c $@-symtbl2.c > /dev/null ; \ 252 do \ 253 count=`expr $$count + 1` ; \ 254 test $$count = 42 && exit 1 ; \ 255 rm -f $@-symtbl.c $@-symtbl.@O@; \ 256 ${MKSYMTBL_PROGRAM} ${top_srcdir}/util/mksymtbl.pl \ 257 -o $@-symtbl.c $@tmp2 || exit 1; \ 258 $(MAKE) $@-symtbl.@O@ || exit 1; \ 259 ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${ALL_CFLAGS} \ 260 ${LDFLAGS} -o $@tmp2 $${BASEOBJS} $@-symtbl.@O@ \ 261 $${LIBS0} ${NOSYMLIBS}; \ 262 ${MKSYMTBL_PROGRAM} ${top_srcdir}/util/mksymtbl.pl \ 263 -o $@-symtbl2.c $@tmp2; \ 264 done ; \ 265 mv $@tmp2 $@; \ 266 rm -f $@tmp0 $@tmp1 $@tmp2 $@-symtbl2.c; \ 267 fi 268 269cleandir: distclean 270superclean: maintainer-clean 271 272clean distclean maintainer-clean:: 273 rm -f *.@O@ *.o *.lo *.la core *.core *-symtbl.c *tmp0 *tmp1 *tmp2 274 rm -rf .depend .libs 275 276distclean maintainer-clean:: 277 rm -f Makefile 278 279depend: 280 @for i in ${ALL_SUBDIRS} ${ALL_TESTDIRS}; do \ 281 if [ "$$i" != "nulldir" -a -d $$i ]; then \ 282 echo "making depend in `pwd`/$$i"; \ 283 (cd $$i; ${MAKE} ${MAKEDEFS} DESTDIR="${DESTDIR}" $@) || exit 1; \ 284 fi; \ 285 done 286 @if [ X"${srcdir}" != X. ] ; then \ 287 if [ X"${SRCS}" != X -a X"${PSRCS}" != X ] ; then \ 288 echo ${MKDEP} -vpath ${srcdir} ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${SRCS}; \ 289 ${MKDEP} -vpath ${srcdir} ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${SRCS}; \ 290 echo ${MKDEP} -vpath ${srcdir} -ap ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${PSRCS}; \ 291 ${MKDEP} -vpath ${srcdir} -ap ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${PSRCS}; \ 292 ${DEPENDEXTRA} \ 293 elif [ X"${SRCS}" != X ] ; then \ 294 echo ${MKDEP} -vpath ${srcdir} ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${SRCS}; \ 295 ${MKDEP} -vpath ${srcdir} ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${SRCS}; \ 296 ${DEPENDEXTRA} \ 297 elif [ X"${PSRCS}" != X ] ; then \ 298 echo ${MKDEP} -vpath ${srcdir} ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${PSRCS}; \ 299 ${MKDEP} -vpath ${srcdir} -p ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${PSRCS}; \ 300 ${DEPENDEXTRA} \ 301 fi \ 302 else \ 303 if [ X"${SRCS}" != X -a X"${PSRCS}" != X ] ; then \ 304 echo ${MKDEP} ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${SRCS}; \ 305 ${MKDEP} ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${SRCS}; \ 306 echo ${MKDEP} -ap ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${PSRCS}; \ 307 ${MKDEP} -ap ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${PSRCS}; \ 308 ${DEPENDEXTRA} \ 309 elif [ X"${SRCS}" != X ] ; then \ 310 echo ${MKDEP} ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${SRCS}; \ 311 ${MKDEP} ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${SRCS}; \ 312 ${DEPENDEXTRA} \ 313 elif [ X"${PSRCS}" != X ] ; then \ 314 echo ${MKDEP} ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${PSRCS}; \ 315 ${MKDEP} -p ${ALL_CPPFLAGS} ${ALL_CFLAGS} ${PSRCS}; \ 316 ${DEPENDEXTRA} \ 317 fi \ 318 fi 319 320FORCE: 321 322### 323### Libraries 324### 325 326AR = @AR@ 327ARFLAGS = @ARFLAGS@ 328RANLIB = @RANLIB@ 329 330### 331### Installation 332### 333 334INSTALL = @INSTALL@ 335INSTALL_PROGRAM = @INSTALL_PROGRAM@ 336LINK_PROGRAM = @LN_S@ 337INSTALL_SCRIPT = @INSTALL_SCRIPT@ 338INSTALL_DATA = @INSTALL_DATA@ 339INSTALL_LIBRARY = @INSTALL_LIBRARY@ 340 341PERL = @PERL@ 342 343### 344### Script language program used to create internal symbol tables 345### 346MKSYMTBL_PROGRAM = @MKSYMTBL_PROGRAM@ 347 348### 349### Switch to create internal symbol table selectively 350### 351ALWAYS_MAKE_SYMTABLE = @ALWAYS_MAKE_SYMTABLE@ 352 353### 354### DocBook -> HTML 355### DocBook -> man page 356### 357 358.SUFFIXES: .docbook .html .1 .2 .3 .4 .5 .6 .7 .8 359 360.docbook.html: 361 ${XSLTPROC} -o $@ ${top_srcdir}/doc/xsl/isc-docbook-html.xsl $< 362 363.docbook.1: 364 ${XSLTPROC} -o $@ ${top_srcdir}/doc/xsl/isc-manpage.xsl $< 365 366.docbook.2: 367 ${XSLTPROC} -o $@ ${top_srcdir}/doc/xsl/isc-manpage.xsl $< 368 369.docbook.3: 370 ${XSLTPROC} -o $@ ${top_srcdir}/doc/xsl/isc-manpage.xsl $< 371 372.docbook.4: 373 ${XSLTPROC} -o $@ ${top_srcdir}/doc/xsl/isc-manpage.xsl $< 374 375.docbook.5: 376 ${XSLTPROC} -o $@ ${top_srcdir}/doc/xsl/isc-manpage.xsl $< 377 378.docbook.6: 379 ${XSLTPROC} -o $@ ${top_srcdir}/doc/xsl/isc-manpage.xsl $< 380 381.docbook.7: 382 ${XSLTPROC} -o $@ ${top_srcdir}/doc/xsl/isc-manpage.xsl $< 383 384.docbook.8: 385 ${XSLTPROC} -o $@ ${top_srcdir}/doc/xsl/isc-manpage.xsl $< 386 387