From 2bdaf7e81c40bb62614080808c42c6a9208e0246 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Wed, 17 Apr 2002 13:49:29 +0000 Subject: [PATCH] Don't include bsd.own.mk from sys.mk, this makes it impossible to use ``.if defined()'' inside bsd.own.mk to test for defines in individual makefiles. For example, setting DEBUG_FLAGS in Makefile didn't take the desired effect on the STRIP assignment. Added bsd.init.mk (like in NetBSD) that handles the inclusion of ../Makefile.inc and bsd.own.mk from all bsd.*.mk files that "build something". Back out bsd.own.mk,v 1.15: moved OBJFORMAT initialization back to sys.mk (several source tree makefiles want to check it early) and removed MACHINE_ARCH initialization (it's hard to see from looking at the commitlogs what the problem was at the time, but now it serves no purpose). Prohibit the direct inclusion of bsd.man.mk and bsd.libnames.mk. Protect bsd.obj.mk from repetitive inclusion. Prohibiting the direct inclusion of bsd.obj.mk might be a good idea too. --- share/mk/bsd.doc.mk | 8 +------- share/mk/bsd.docb.mk | 9 +-------- share/mk/bsd.info.mk | 9 +-------- share/mk/bsd.init.mk | 14 ++++++++++++++ share/mk/bsd.lib.mk | 9 +-------- share/mk/bsd.libnames.mk | 4 ++++ share/mk/bsd.man.mk | 4 ++++ share/mk/bsd.nls.mk | 4 ++-- share/mk/bsd.obj.mk | 6 ++++++ share/mk/bsd.own.mk | 16 ---------------- share/mk/bsd.prog.mk | 8 +------- share/mk/bsd.sgml.mk | 9 +-------- share/mk/bsd.subdir.mk | 9 +-------- share/mk/sys.mk | 11 ++++++++++- 14 files changed, 47 insertions(+), 73 deletions(-) create mode 100644 share/mk/bsd.init.mk diff --git a/share/mk/bsd.doc.mk b/share/mk/bsd.doc.mk index 287a57afe56..baac64b687e 100644 --- a/share/mk/bsd.doc.mk +++ b/share/mk/bsd.doc.mk @@ -14,12 +14,7 @@ # # [incomplete] -.if !target(__initialized__) -__initialized__: -.if exists(${.CURDIR}/../Makefile.inc) -.include "${.CURDIR}/../Makefile.inc" -.endif -.endif +.include PRINTERDEVICE?= ascii @@ -87,7 +82,6 @@ COMPAT?= -C .PATH: ${.CURDIR} ${SRCDIR} -.MAIN: all all: ${DFILE} .if !target(print) diff --git a/share/mk/bsd.docb.mk b/share/mk/bsd.docb.mk index 0e5df47b4d2..7e2ce761edf 100644 --- a/share/mk/bsd.docb.mk +++ b/share/mk/bsd.docb.mk @@ -22,13 +22,7 @@ # install: # Install formated output. - -.if !target(__initialized__) -__initialized__: -.if exists(${.CURDIR}/../Makefile.inc) -.include "${.CURDIR}/../Makefile.inc" -.endif -.endif +.include # Use SGMLOPTS to pass extra flags to sgmlfmt(1). VOLUME?= ${.CURDIR:T} @@ -45,7 +39,6 @@ CLEANFILES+=${_docs} .docb.html .sgml.html: ${SRCS} ${SGMLFMT} -d docbook -f html ${SGMLOPTS} ${.IMPSRC} -.MAIN: all all: ${_docs} install: diff --git a/share/mk/bsd.info.mk b/share/mk/bsd.info.mk index f02749da376..b800e89b615 100644 --- a/share/mk/bsd.info.mk +++ b/share/mk/bsd.info.mk @@ -78,12 +78,7 @@ # # bsd.obj.mk: cleandir and obj -.if !target(__initialized__) -__initialized__: -.if exists(${.CURDIR}/../Makefile.inc) -.include "${.CURDIR}/../Makefile.inc" -.endif -.endif +.include MAKEINFO?= makeinfo MAKEINFOFLAGS+= --no-split # simplify some things, e.g., compression @@ -100,8 +95,6 @@ TEX?= tex DVIPS?= dvips DVIPS2ASCII?= dvips2ascii -.MAIN: all - .SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html .texi.info .texinfo.info: diff --git a/share/mk/bsd.init.mk b/share/mk/bsd.init.mk new file mode 100644 index 00000000000..ff6517ce160 --- /dev/null +++ b/share/mk/bsd.init.mk @@ -0,0 +1,14 @@ +# $FreeBSD$ + +# The include file includes ../Makefile.inc and +# ; this is used at the top of all files +# that actually "build something". + +.if !target(____) +____: +.if exists(${.CURDIR}/../Makefile.inc) +.include "${.CURDIR}/../Makefile.inc" +.endif +.include +.MAIN: all +.endif !target(____) diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 692cb9150cd..9b4525ebf01 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -2,12 +2,7 @@ # $FreeBSD$ # -.if !target(__initialized__) -__initialized__: -.if exists(${.CURDIR}/../Makefile.inc) -.include "${.CURDIR}/../Makefile.inc" -.endif -.endif +.include .if exists(${.CURDIR}/shlib_version) SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major @@ -49,8 +44,6 @@ STRIP?= -s .include .endif -.MAIN: all - # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries # .So used for PIC object files .SUFFIXES: diff --git a/share/mk/bsd.libnames.mk b/share/mk/bsd.libnames.mk index 2b863e74e5d..9e1ba2471f9 100644 --- a/share/mk/bsd.libnames.mk +++ b/share/mk/bsd.libnames.mk @@ -4,6 +4,10 @@ # Other include files (e.g. bsd.prog.mk, bsd.lib.mk) include this # file where necessary. +.if !target(____) +.error bsd.libnames.mk cannot be included directly. +.endif + LIBCRT0?= ${DESTDIR}${LIBDIR}/crt0.o LIBALIAS?= ${DESTDIR}${LIBDIR}/libalias.a diff --git a/share/mk/bsd.man.mk b/share/mk/bsd.man.mk index 4255915eeac..b63f61153b8 100644 --- a/share/mk/bsd.man.mk +++ b/share/mk/bsd.man.mk @@ -49,6 +49,10 @@ # Install the manual pages and their links. # +.if !target(____) +.error bsd.man.mk cannot be included directly. +.endif + MINSTALL= ${INSTALL} ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} CATDIR= ${MANDIR:H:S/$/\/cat/} diff --git a/share/mk/bsd.nls.mk b/share/mk/bsd.nls.mk index 346ee74711d..6d91d0be496 100644 --- a/share/mk/bsd.nls.mk +++ b/share/mk/bsd.nls.mk @@ -29,6 +29,8 @@ # # bsd.obj.mk: cleandir and obj +.include + GENCAT?= gencat -new NLSDIR?= ${SHAREDIR}/nls @@ -39,8 +41,6 @@ NLSOWN?= ${SHAREOWN} NLS?= NLSLINKS= -.MAIN: all - .SUFFIXES: .cat .msg .msg.cat: diff --git a/share/mk/bsd.obj.mk b/share/mk/bsd.obj.mk index 79ac5167220..cb1d7949853 100644 --- a/share/mk/bsd.obj.mk +++ b/share/mk/bsd.obj.mk @@ -43,6 +43,10 @@ # create build directory. # +.if !target(____) +____: +.include + .if defined(MAKEOBJDIRPREFIX) CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} .else @@ -174,3 +178,5 @@ _SUBDIR: .USE ${MAKE} ${.TARGET:S/realinstall/install/} DIRPRFX=${DIRPRFX}$$entry/); \ done .endif + +.endif !target(____) diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index 02256e5a433..f713e763b04 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -124,22 +124,6 @@ # # INCLUDEDIR Base path for standard C include files [/usr/include] -# This is only here for bootstrapping and is not officially exported -# from here. It has normally already been defined in sys.mk. -MACHINE_ARCH?= i386 - -# -# The build tools are indirected by /usr/bin/objformat which determines the -# object format from the OBJFORMAT environment variable and if this is not -# defined, it reads /etc/objformat. -# -.if exists(/etc/objformat) && !defined(OBJFORMAT) -.include "/etc/objformat" -.endif - -# Default executable format -OBJFORMAT?= elf - # Binaries BINOWN?= root BINGRP?= wheel diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index 883159c5636..9d55834cd3e 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -1,12 +1,7 @@ # from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 # $FreeBSD$ -.if !target(__initialized__) -__initialized__: -.if exists(${.CURDIR}/../Makefile.inc) -.include "${.CURDIR}/../Makefile.inc" -.endif -.endif +.include .SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .s .S @@ -78,7 +73,6 @@ MAN1= ${MAN} .endif .endif -.MAIN: all all: objwarn ${PROG} ${SCRIPTS} ${FILES} .if !defined(NOMAN) all: all-man diff --git a/share/mk/bsd.sgml.mk b/share/mk/bsd.sgml.mk index 33548701ccd..1b7a88450b6 100644 --- a/share/mk/bsd.sgml.mk +++ b/share/mk/bsd.sgml.mk @@ -50,13 +50,7 @@ # bsd.obj.mk: clean, cleandir, obj # - -.if !target(__initialized__) -__initialized__: -.if exists(${.CURDIR}/../Makefile.inc) -.include "${.CURDIR}/../Makefile.inc" -.endif -.endif +.include # FORMATS indicates which output formats will be generated. See # the sgmlfmt(1) man page for a list of valid formats. @@ -110,7 +104,6 @@ strip: ${_strip} .endif -.MAIN: all all: ${_docs} # If FORMATS is empty, do nothing diff --git a/share/mk/bsd.subdir.mk b/share/mk/bsd.subdir.mk index f169f0a806b..9f2b8900083 100644 --- a/share/mk/bsd.subdir.mk +++ b/share/mk/bsd.subdir.mk @@ -29,14 +29,7 @@ # obj, objlink, realinstall, regress, tags # -.if !target(__initialized__) -__initialized__: -.if exists(${.CURDIR}/../Makefile.inc) -.include "${.CURDIR}/../Makefile.inc" -.endif -.endif - -.MAIN: all +.include _SUBDIRUSE: .USE @for entry in ${SUBDIR}; do \ diff --git a/share/mk/sys.mk b/share/mk/sys.mk index 89ef00c8669..030c852b3d9 100644 --- a/share/mk/sys.mk +++ b/share/mk/sys.mk @@ -259,5 +259,14 @@ __MAKE_CONF?=/etc/make.conf .include .endif +# +# The build tools are indirected by /usr/bin/objformat which determines the +# object format from the OBJFORMAT environment variable and if this is not +# defined, it reads /etc/objformat. +# +.if exists(/etc/objformat) && !defined(OBJFORMAT) +.include "/etc/objformat" +.endif -.include +# Default executable format +OBJFORMAT?= elf