diff --git a/ChangeLog b/ChangeLog index ee8011d7e362..fe6b0d949383 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2018-05-12 Simon J. Gerraty + + * VERSION: 20180512 + Merge with NetBSD make, pick up + o job.c: skip polling job token pipe + +2018-04-05 Simon J. Gerraty + + * VERSION: 20180405 + Merge with NetBSD make, pick up + o parse.c: be more cautious about detecting depenency line + rather than sysV style include. + 2018-02-22 Simon J. Gerraty * VERSION: 20180222 diff --git a/VERSION b/VERSION index 6550722f3e6a..d29d946c9039 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ # keep this compatible with sh and make -_MAKE_VERSION=20180222 +_MAKE_VERSION=20180512 diff --git a/bmake.1 b/bmake.1 index 03747459a967..1ee14bad6717 100644 --- a/bmake.1 +++ b/bmake.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.271 2017/07/03 21:34:20 wiz Exp $ +.\" $NetBSD: make.1,v 1.272 2018/04/02 04:26:17 dholland Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -1865,7 +1865,8 @@ expression is applied. Similarly, if the form is .Ql Ic .ifmake or -.Ql Ic .ifnmake , the +.Ql Ic .ifnmake , +the .Dq make expression is applied. .Pp diff --git a/job.c b/job.c index 12e8712f7661..ddf9d4084a4f 100644 --- a/job.c +++ b/job.c @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.192 2018/02/08 09:05:21 dholland Exp $ */ +/* $NetBSD: job.c,v 1.195 2018/05/13 22:13:28 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: job.c,v 1.192 2018/02/08 09:05:21 dholland Exp $"; +static char rcsid[] = "$NetBSD: job.c,v 1.195 2018/05/13 22:13:28 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: job.c,v 1.192 2018/02/08 09:05:21 dholland Exp $"); +__RCSID("$NetBSD: job.c,v 1.195 2018/05/13 22:13:28 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -2969,7 +2969,6 @@ Job_TokenWithdraw(void) } if (DEBUG(JOB)) fprintf(debug_file, "(%d) blocked for token\n", getpid()); - wantToken = 1; return FALSE; } diff --git a/make.1 b/make.1 index 8da5f679e6f2..a83fb588c5d2 100644 --- a/make.1 +++ b/make.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.271 2017/07/03 21:34:20 wiz Exp $ +.\" $NetBSD: make.1,v 1.272 2018/04/02 04:26:17 dholland Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -1865,7 +1865,8 @@ expression is applied. Similarly, if the form is .Ql Ic .ifmake or -.Ql Ic .ifnmake , the +.Ql Ic .ifnmake , +the .Dq make expression is applied. .Pp diff --git a/mk/ChangeLog b/mk/ChangeLog index f47300ecfe0a..3bc1976fcfc3 100644 --- a/mk/ChangeLog +++ b/mk/ChangeLog @@ -1,3 +1,20 @@ +2018-04-20 Simon J Gerraty + + * install-mk (MK_VERSION): 20180420 + * dirdeps.mk: include local.dirdeps-build.mk when .MAKE.LEVEL > 0 + ie. we are building something. + +2018-04-14 Simon J Gerraty + + * FILES: add dirdeps-options.mk to deal with optional DIRDEPS. + +2018-04-05 Simon J Gerraty + + * install-mk (MK_VERSION): 20180405 + + * ldorder.mk: describe how to use LDORDER_EXTERN_BARRIER + if needed. + 2018-01-18 Simon J Gerraty * install-mk (MK_VERSION): 20180118 diff --git a/mk/FILES b/mk/FILES index 0629699ab712..a6bf9a27a8b7 100644 --- a/mk/FILES +++ b/mk/FILES @@ -59,6 +59,7 @@ warnings.mk whats.mk yacc.mk dirdeps.mk +dirdeps-options.mk gendirdeps.mk install-new.mk meta2deps.py diff --git a/mk/cython.mk b/mk/cython.mk index 7d9b8cd6a5b5..c1318b2174e9 100644 --- a/mk/cython.mk +++ b/mk/cython.mk @@ -1,5 +1,5 @@ # RCSid: -# $Id: cython.mk,v 1.6 2014/10/15 06:23:51 sjg Exp $ +# $Id: cython.mk,v 1.7 2018/03/25 18:46:11 sjg Exp $ # # @(#) Copyright (c) 2014, Simon J. Gerraty # @@ -14,15 +14,6 @@ # sjg@crufty.net # -# this is what we build -CYTHON_MODULE = ${CYTHON_MODULE_NAME}${CYTHON_PYVERSION}.so - -CYTHON_MODULE_NAME?= it -CYTHON_SRCS?= ${CYTHON_MODULE_NAME}.pyx - -# this is where we save generated src -CYTHON_SAVEGENDIR?= ${.CURDIR}/gen - # pyprefix is where python bits are # which may not be where we want to put ours (prefix) .if exists(/usr/pkg/include) @@ -34,13 +25,36 @@ PYTHON_VERSION?= 2.7 PYTHON_H?= ${pyprefix}/include/python${PYTHON_VERSION}/Python.h PYVERSION:= ${PYTHON_VERSION:C,\..*,,} +CFLAGS+= -I${PYTHON_H:H} + +# conf.host_target() is limited to uname -m rather than uname -p +_HOST_MACHINE!= uname -m +.if ${HOST_TARGET:M*${_HOST_MACHINE}} == "" +PY_HOST_TARGET:= ${HOST_TARGET:S,${_HOST_ARCH:U${uname -p:L:sh}}$,${_HOST_MACHINE},} +.endif + +COMPILE.c?= ${CC} -c ${CFLAGS} +PICO?= .pico + +.SUFFIXES: ${PICO} .c + +.c${PICO}: + ${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET} + +# this is what we build +.if !empty(CYTHON_MODULE_NAME) +CYTHON_MODULE = ${CYTHON_MODULE_NAME}${CYTHON_PYVERSION}.so + +CYTHON_SRCS?= ${CYTHON_MODULE_NAME}.pyx + +# this is where we save generated src +CYTHON_SAVEGENDIR?= ${.CURDIR}/gen + # set this empty if you don't want to handle multiple versions .if !defined(CYTHON_PYVERSION) CYTHON_PYVERSION:= ${PYVERSION} .endif -CFLAGS+= -I${PYTHON_H:H} - CYTHON_GENSRCS= ${CYTHON_SRCS:R:S,$,${CYTHON_PYVERSION}.c,} SRCS+= ${CYTHON_GENSRCS} @@ -70,19 +84,8 @@ save-gen: ${CYTHON_GENSRCS} .endif -COMPILE.c?= ${CC} -c ${CFLAGS} - -.c.So: - ${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET} - -${CYTHON_MODULE}: ${SRCS:S,.c,.So,} - ${CC} ${CC_SHARED:U-shared} -o ${.TARGET} ${.ALLSRC:M*.So} ${LDADD} - -# conf.host_target() is limited to uname -m rather than uname -p -_HOST_MACHINE!= uname -m -.if ${HOST_TARGET:M*${_HOST_MACHINE}} == "" -PY_HOST_TARGET:= ${HOST_TARGET:S,${_HOST_ARCH:U${uname -p:L:sh}}$,${_HOST_MACHINE},} -.endif +${CYTHON_MODULE}: ${SRCS:S,.c,${PICO},} + ${CC} ${CC_SHARED:U-shared} -o ${.TARGET} ${.ALLSRC:M*${PICO}} ${LDADD} MODULE_BINDIR?= ${.CURDIR:H}/${PY_HOST_TARGET:U${HOST_TARGET}} @@ -93,4 +96,6 @@ install-cython-module: ${CYTHON_MODULE} ${INSTALL} -d ${DESTDIR}${MODULE_BINDIR} ${INSTALL} -m 755 ${.ALLSRC} ${DESTDIR}${MODULE_BINDIR} -CLEANFILES+= *.So ${CYTHON_MODULE} +CLEANFILES+= *${PICO} ${CYTHON_MODULE} + +.endif diff --git a/mk/dirdeps-options.mk b/mk/dirdeps-options.mk new file mode 100644 index 000000000000..b6164cfa299a --- /dev/null +++ b/mk/dirdeps-options.mk @@ -0,0 +1,70 @@ +# $Id: dirdeps-options.mk,v 1.5 2018/04/18 15:53:57 sjg Exp $ +# +# @(#) Copyright (c) 2018, Simon J. Gerraty +# +# This file is provided in the hope that it will +# be of use. There is absolutely NO WARRANTY. +# Permission to copy, redistribute or otherwise +# use this file is hereby granted provided that +# the above copyright notice and this notice are +# left intact. +# +# Please send copies of changes and bug-fixes to: +# sjg@crufty.net +# + +## +# +# This makefile is used to deal with optional DIRDEPS. +# +# It is to be included by Makefile.depend.options in a +# directory which has DIRDEPS affected by optional features. +# Makefile.depend.options should set DIRDEPS_OPTIONS and +# may also set specific DIRDEPS.* for those options. +# +# If a Makefile.depend.options file exists, it will be included by +# dirdeps.mk and meta.autodep.mk +# +# We include local.dirdeps-option.mk which may also define DIRDEPS.* +# for options. +# +# Thus a directory, that is affected by an option FOO would have +# a Makefile.depend.options that sets +# DIRDEPS_OPTIONS= FOO +# It can also set either/both of +# DIRDEPS.FOO.yes +# DIRDEPS.FOO.no +# to whatever applies for that dir, or it can rely on globals +# set in local.dirdeps-option.mk +# Either way, we will .undef DIRDEPS.* when done. + +# This should have been set by Makefile.depend.options +# before including us +DIRDEPS_OPTIONS ?= + +# pickup any DIRDEPS.* we need +.-include + +.if ${.MAKE.LEVEL} == 0 +# :U below avoids potential errors when we := +.for o in ${DIRDEPS_OPTIONS:tu} +DIRDEPS += ${DIRDEPS.$o.${MK_$o:U}:U} +.endfor +DIRDEPS := ${DIRDEPS:O:u} +# avoid cross contamination +.undef ${DIRDEPS_OPTIONS:tu:@o@DIRDEPS.$o.yes DIRDEPS.$o.no@} +.else +# whether options are enabled or not, +# we want to filter out the relevant DIRDEPS.* +# we should only be included by meta.autodep.mk +# if dependencies are to be updated +.for o in ${DIRDEPS_OPTIONS:tu} +.for d in ${DIRDEPS.$o.yes} ${DIRDEPS.$o.no} +.if exists(${SRCTOP}/$d) +GENDIRDEPS_FILTER += N$d* +.elif exists(${SRCTOP}/${d:R}) +GENDIRDEPS_FILTER += N${d:R}* +.endif +.endfor +.endfor +.endif diff --git a/mk/dirdeps.mk b/mk/dirdeps.mk index 2ff875770660..5df66e58f7ff 100644 --- a/mk/dirdeps.mk +++ b/mk/dirdeps.mk @@ -1,17 +1,17 @@ -# $Id: dirdeps.mk,v 1.90 2017/10/25 23:44:20 sjg Exp $ +# $Id: dirdeps.mk,v 1.95 2018/04/23 17:53:56 sjg Exp $ # Copyright (c) 2010-2013, Juniper Networks, Inc. # All rights reserved. -# +# # Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: +# modification, are permitted provided that the following conditions +# are met: # 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. +# notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# +# documentation and/or other materials provided with the distribution. +# # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -22,7 +22,7 @@ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Much of the complexity here is for supporting cross-building. # If a tree does not support that, simply using plain Makefile.depend @@ -56,7 +56,7 @@ # .MAKE.DEPENDFILE_PREFIX) to refer to these makefiles to # distinguish them from others. # -# Before each Makefile.depend file is read, we set +# Before each Makefile.depend file is read, we set # DEP_RELDIR to be the RELDIR (path relative to SRCTOP) for # its directory, and DEP_MACHINE etc according to the . # represented by the suffix of the corresponding target. @@ -89,7 +89,7 @@ # # For example: # -# # Always list MACHINE first, +# # Always list MACHINE first, # # other variables might be optional. # TARGET_SPEC_VARS = MACHINE TARGET_OS # .if ${TARGET_SPEC:Uno:M*,*} != "" @@ -101,7 +101,7 @@ # # and deal with MACHINE=${TARGET_SPEC} in the environment. # TARGET_SPEC = # # export but do not track -# .export-env TARGET_SPEC +# .export-env TARGET_SPEC # .export ${TARGET_SPEC_VARS} # .for v in ${TARGET_SPEC_VARS:O:u} # .if empty($v) @@ -328,7 +328,7 @@ _DEP_RELDIR := ${DEP_RELDIR} .endif # DIRDEPS_CACHE can be very handy for debugging. -# Also if repeatedly building the same target, +# Also if repeatedly building the same target, # we can avoid the overhead of re-computing the tree dependencies. MK_DIRDEPS_CACHE ?= no BUILD_DIRDEPS_CACHE ?= no @@ -441,7 +441,7 @@ _only_machines := ${_only_machines:O:u} # make sure we have a starting place? DIRDEPS ?= ${RELDIR} -.endif # target +.endif # target .if !defined(NO_DIRDEPS) && !defined(NO_DIRDEPS_BELOW) .if ${MK_DIRDEPS_CACHE} == "yes" @@ -451,7 +451,7 @@ build-dirdeps: M_oneperline = @x@\\${.newline} $$x@ -.if ${BUILD_DIRDEPS_CACHE} == "no" +.if ${BUILD_DIRDEPS_CACHE} == "no" .if !target(dirdeps-cached) # we do this via sub-make BUILD_DIRDEPS = no @@ -469,7 +469,7 @@ dirdeps-cached: ${DIRDEPS_CACHE} .MAKE BUILD_DIRDEPS_MAKEFILE ?= ${MAKEFILE} BUILD_DIRDEPS_TARGETS ?= ${.TARGETS} -# we need the .meta file to ensure we update if +# we need the .meta file to ensure we update if # any of the Makefile.depend* changed. # We do not want to compare the command line though. ${DIRDEPS_CACHE}: .META .NOMETA_CMP @@ -528,6 +528,7 @@ _this_dir := ${SRCTOP}/${DEP_RELDIR} # on rare occasions, there can be a need for extra help _dep_hack := ${_this_dir}/${.MAKE.DEPENDFILE_PREFIX}.inc .-include <${_dep_hack}> +.-include <${_dep_hack:R}.options> .if ${DEP_RELDIR} != ${_DEP_RELDIR} || ${DEP_TARGET_SPEC} != ${TARGET_SPEC} # this should be all @@ -581,7 +582,7 @@ _build_dirs += ${_machines:N${DEP_TARGET_SPEC}:@m@${_CURDIR}.$m@} .if ${_debug_reldir} .info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: DIRDEPS='${DIRDEPS}' -.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: _machines='${_machines}' +.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: _machines='${_machines}' .endif .if !empty(DIRDEPS) @@ -589,7 +590,7 @@ _build_dirs += ${_machines:N${DEP_TARGET_SPEC}:@m@${_CURDIR}.$m@} DEP_DIRDEPS_FILTER = \ ${DIRDEPS_FILTER.${DEP_TARGET_SPEC}:U} \ ${TARGET_SPEC_VARS:@v@${DIRDEPS_FILTER.${DEP_$v}:U}@} \ - ${DIRDEPS_FILTER:U} + ${DIRDEPS_FILTER:U} .if empty(DEP_DIRDEPS_FILTER) # something harmless DEP_DIRDEPS_FILTER = U @@ -598,7 +599,7 @@ DEP_DIRDEPS_FILTER = U # this is what we start with __depdirs := ${DIRDEPS:${NSkipDir}:${DEP_DIRDEPS_FILTER:ts:}:C,//+,/,g:O:u:@d@${SRCTOP}/$d@} -# some entries may be qualified with . +# some entries may be qualified with . # the :M*/*/*.* just tries to limit the dirs we check to likely ones. # the ${d:E:M*/*} ensures we don't consider junos/usr.sbin/mgd __qual_depdirs := ${__depdirs:M*/*/*.*:@d@${exists($d):?:${"${d:E:M*/*}":?:${exists(${d:R}):?$d:}}}@} @@ -606,7 +607,8 @@ __unqual_depdirs := ${__depdirs:${__qual_depdirs:Uno:${M_ListToSkip}}} .if ${DEP_RELDIR} == ${_DEP_RELDIR} # if it was called out - we likely need it. -__hostdpadd := ${DPADD:U.:M${HOST_OBJTOP}/*:S,${HOST_OBJTOP}/,,:H:${NSkipDir}:${DIRDEPS_FILTER:ts:}:S,$,.host,:N.*:@d@${SRCTOP}/$d@} +__hostdpadd := ${DPADD:U.:M${HOST_OBJTOP}/*:S,${HOST_OBJTOP}/,,:H:${NSkipDir}:${DIRDEPS_FILTER:ts:}:S,$,.host,:N.*:@d@${SRCTOP}/$d@} \ + ${DPADD:U.:M${HOST_OBJTOP32:Uno}/*:S,${HOST_OBJTOP32:Uno}/,,:H:${NSkipDir}:${DIRDEPS_FILTER:ts:}:S,$,.host32,:N.*:@d@${SRCTOP}/$d@} __qual_depdirs += ${__hostdpadd} .endif @@ -710,7 +712,7 @@ DEP_${TARGET_SPEC_VARS:[$i]} := ${_dtspec:[$i]} .else DEP_MACHINE := ${_DEP_MACHINE} .endif -# Warning: there is an assumption here that MACHINE is always +# Warning: there is an assumption here that MACHINE is always # the first entry in TARGET_SPEC_VARS. # If TARGET_SPEC and MACHINE are insufficient, you have a problem. _m := ${.MAKE.DEPENDFILE_PREFERENCE:T:S;${TARGET_SPEC}$;${d:E};:S;${MACHINE};${d:E:C/,.*//};:@m@${exists(${d:R}/$m):?${d:R}/$m:}@:[1]} @@ -720,7 +722,7 @@ _qm := ${_m:C;(\.depend)$;\1.${d:E};:${M_dep_qual_fixes:ts:}} .if ${_debug_search} .info Looking for ${_qm} .endif -# set this "just in case" +# set this "just in case" # we can skip :tA since we computed the path above DEP_RELDIR := ${_m:H:S,${SRCTOP}/,,} # and reset this @@ -743,6 +745,10 @@ DIRDEPS = # we are building something DEP_RELDIR := ${RELDIR} _DEP_RELDIR := ${RELDIR} +# Since we are/should be included by .MAKE.DEPENDFILE +# is is a final opportunity to add/hook global rules. +.-include + # pickup local dependencies .if ${MAKE_VERSION} < 20160220 .-include <.depend> diff --git a/mk/gendirdeps.mk b/mk/gendirdeps.mk index 6a1ce92a8e47..d8f900630ac4 100644 --- a/mk/gendirdeps.mk +++ b/mk/gendirdeps.mk @@ -1,4 +1,4 @@ -# $Id: gendirdeps.mk,v 1.37 2018/01/31 19:06:46 sjg Exp $ +# $Id: gendirdeps.mk,v 1.38 2018/03/10 00:53:52 sjg Exp $ # Copyright (c) 2010-2013, Juniper Networks, Inc. # All rights reserved. @@ -160,6 +160,12 @@ META2DEPS_CMD += -S ${SB_BACKING_SB}/src M2D_OBJROOTS += ${SB_BACKING_SB}/${SB_OBJPREFIX} .endif +GENDIRDEPS_SEDCMDS += \ + -e 's,//*$$,,;s,\.${HOST_TARGET:Uhost}$$,.host,' \ + -e 's,\.${HOST_TARGET32:Uhost32}$$,.host32,' \ + -e 's,\.${MACHINE}$$,,' \ + -e 's:\.${TARGET_SPEC:U${MACHINE}}$$::' + # we are only interested in the dirs # specifically those we read something from. # we canonicalize them to keep things simple @@ -170,7 +176,7 @@ dir_list != cd ${_OBJDIR} && \ SRCTOP=${SRCTOP} RELDIR=${RELDIR} CURDIR=${_CURDIR} \ ${META2DEPS_ARGS} \ ${META_FILES:O:u} | ${META2DEPS_FILTER} ${_skip_gendirdeps} \ - sed 's,//*$$,,;s,\.${HOST_TARGET}$$,.host,' + sed ${GENDIRDEPS_SEDCMDS} .if ${dir_list:M*ERROR\:*} != "" .warning ${dir_list:tW:C,.*(ERROR),\1,} @@ -194,7 +200,7 @@ dpadd_dir_list += ${f:H:tA} .endfor .if !empty(ddep_list) ddeps != cat ${ddep_list:O:u} | ${META2DEPS_FILTER} ${_skip_gendirdeps} \ - sed 's,//*$$,,;s,\.${HOST_TARGET:Uhost}$$,.host,;s,\.${HOST_TARGET32:Uhost32}$$,.host32,;s,\.${MACHINE}$$,,' + sed ${GENDIRDEPS_SEDCMDS} .if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != "" .info ${RELDIR}: raw_dir_list='${dir_list}' diff --git a/mk/install-mk b/mk/install-mk index 4b9ed253fd8a..70233fc23ed8 100644 --- a/mk/install-mk +++ b/mk/install-mk @@ -55,7 +55,7 @@ # Simon J. Gerraty # RCSid: -# $Id: install-mk,v 1.153 2018/01/24 22:57:11 sjg Exp $ +# $Id: install-mk,v 1.156 2018/04/22 04:42:47 sjg Exp $ # # @(#) Copyright (c) 1994 Simon J. Gerraty # @@ -70,7 +70,7 @@ # sjg@crufty.net # -MK_VERSION=20180118 +MK_VERSION=20180420 OWNER= GROUP= MODE=444 diff --git a/mk/ldorder.mk b/mk/ldorder.mk index 38d9359914ae..3d44df5874fe 100644 --- a/mk/ldorder.mk +++ b/mk/ldorder.mk @@ -1,14 +1,14 @@ -# $Id: ldorder.mk,v 1.18 2018/02/11 18:27:59 sjg Exp $ +# $Id: ldorder.mk,v 1.25 2018/04/24 23:50:26 sjg Exp $ # # @(#) Copyright (c) 2015, Simon J. Gerraty # # This file is provided in the hope that it will # be of use. There is absolutely NO WARRANTY. # Permission to copy, redistribute or otherwise -# use this file is hereby granted provided that +# use this file is hereby granted provided that # the above copyright notice and this notice are -# left intact. -# +# left intact. +# # Please send copies of changes and bug-fixes to: # sjg@crufty.net # @@ -27,7 +27,13 @@ .if !target(_LDORDER_USE) # does caller want to use ldorder? # yes for prog, normally no for lib -_ldorder_use := ${.ALLTARGETS:Mldorder} +.if ${.ALLTARGETS:Mldorder} != "" +_ldorder_use: +.endif + +# define this if we need a barrier between local and external libs +# see below +LDORDER_EXTERN_BARRIER ?= .ldorder-extern-barrier .-include @@ -35,6 +41,7 @@ _ldorder_use := ${.ALLTARGETS:Mldorder} LDORDER_INC_FILTER += S,+,PLUS,g S,.so$$,,g LDORDER_LIBS_FILTER += O:u LDORDER_INC ?= ldorder.inc +# for meta mode REFERENCE_FILE ?= : _LDORDER_USE: .ldorder-rm .USE .NOTMAIN @@ -72,9 +79,27 @@ LDADD_LDORDER ?= `cat ldorder` # for debug below _ldorder = ${RELDIR}.${TARGET_SPEC} +# we make have some libs that exist outside of $SB +# and want to insert a barrier +.if target(${LDORDER_EXTERN_BARRIER}) +# eg. in local.ldorder.mk +# ${LDORDER_EXTERN_BARRIER}: +# @test -z "${extern_ldorders}" || \ +# echo -Wl,-Bdynamic >> .ldorder +# +# feel free to put more suitable version in local.ldorder.mk if needed +# we do *not* count host libs in extern_ldorders +extern_ldorders ?= ${__dpadd_libs:tA:N/lib*:N/usr/lib*:N${SB}/*:N${SB_OBJROOT:tA}*:T:${LDORDER_LIBS_FILTER:ts:}:R:C/\.so.*//:S,^,.ldorder-,:N.ldorder-} +sb_ldorders ?= ${.ALLTARGETS:M.ldorder-*:N${LDORDER_EXTERN_BARRIER}:N.ldorder-rm:${extern_ldorders:${M_ListToSkip}}:N.ldorder-} + +# finally in Makefile after include of *.mk put +# .ldorder ${sb_ldorders}: ${LDORDER_EXTERN_BARRIER} +# ${LDORDER_EXTERN_BARRIER}: ${extern_ldorders} +.endif + .endif # !target(_LDORDER_USE) -.if !empty(LDORDER_LIBS) && !empty(_ldorder_use) +.if !empty(LDORDER_LIBS) && target(_ldorder_use) # canonicalize - these are just tokens anyway LDORDER_LIBS := ${LDORDER_LIBS:${LDORDER_LIBS_FILTER:ts:}:R:C/\.so.*//} _ldorders := ${LDORDER_LIBS:T:Mlib*:S,^,.ldorder-,} @@ -108,6 +133,7 @@ ${_ldorder}: ${_ldorders} __${__inc}__: # make sure this is reset LDORDER_LIBS = +_ldorders = .-include <${__inc}> .endif .endfor @@ -119,9 +145,12 @@ LDORDER_LIBS = # to add extra content - like CFLAGS libLDORDER_INC = lib${LIB}.${LDORDER_INC} .if !commands(${libLDORDER_INC}) +.if target(ldorder-header) +${libLDORDER_INC}: ldorder-header +.endif ${libLDORDER_INC}: @(cat /dev/null ${.ALLSRC:M*ldorder*}; \ - echo 'LDORDER_LIBS= ${_LDORDER_LIBS:T:R:${LDORDER_INC_FILTER:ts:}:tu:C,.*,_{&},}'; \ + echo 'LDORDER_LIBS= ${_LDORDER_LIBS:T:R:${LDORDER_INC_FILTER:ts:}:tu:C,.*,_{&},:N_{}}'; \ echo; echo '.include ' ) | sed 's,_{,$${,g' > ${.TARGET} .endif .endif diff --git a/mk/meta.autodep.mk b/mk/meta.autodep.mk index 10f9ca307762..c33c5d809447 100644 --- a/mk/meta.autodep.mk +++ b/mk/meta.autodep.mk @@ -1,4 +1,4 @@ -# $Id: meta.autodep.mk,v 1.46 2017/10/25 23:44:20 sjg Exp $ +# $Id: meta.autodep.mk,v 1.48 2018/04/15 06:30:04 sjg Exp $ # # @(#) Copyright (c) 2010, Simon J. Gerraty @@ -6,10 +6,10 @@ # This file is provided in the hope that it will # be of use. There is absolutely NO WARRANTY. # Permission to copy, redistribute or otherwise -# use this file is hereby granted provided that +# use this file is hereby granted provided that # the above copyright notice and this notice are -# left intact. -# +# left intact. +# # Please send copies of changes and bug-fixes to: # sjg@crufty.net # @@ -39,7 +39,7 @@ ${s:T:R}$e: $s # you are supposed to know what you are doing! UPDATE_DEPENDFILE = yes .elif !empty(.TARGETS) && !make(all) -# do not update the *depend* files +# do not update the *depend* files # unless we are building the entire directory or the default target. # NO means don't update .depend - or Makefile.depend* # no means update .depend but not Makefile.depend* @@ -119,7 +119,7 @@ META_FILE_FILTER ?= N.meta META_FILE_FILTER += Ndirdeps.cache* .if !empty(DPADD) -# if we have any non-libs in DPADD, +# if we have any non-libs in DPADD, # they probably need to be paid attention to .if !empty(DPLIBS) FORCE_DPADD = ${DPADD:${DPLIBS:${M_ListToSkip}}:${DPADD_LAST:${M_ListToSkip}}} @@ -138,8 +138,8 @@ FORCE_DPADD += ${_nonlibs:@x@${DPADD:M*/$x}@} # if we don't have OBJS, then .depend isn't useful .if !target(.depend) && (!empty(OBJS) || ${.ALLTARGETS:M*.o} != "") # some makefiles and/or targets contain -# circular dependencies if you dig too deep -# (as meta mode is apt to do) +# circular dependencies if you dig too deep +# (as meta mode is apt to do) # so we provide a means of suppressing them. # the input to the loop below is target: dependency # with just one dependency per line. @@ -155,13 +155,13 @@ SUPPRESS_DEPEND += \ # we use ${.MAKE.META.CREATED} to trigger an update but # we process using ${.MAKE.META.FILES} # the double $$ defers initial evaluation -# if necessary, we fake .po dependencies, just so the result +# if necessary, we fake .po dependencies, just so the result # in Makefile.depend* is stable # The current objdir may be referred to in various ways OBJDIR_REFS += ${.OBJDIR} ${.OBJDIR:tA} ${_OBJDIR} ${RELOBJTOP}/${RELDIR} _depend = .depend # it would be nice to be able to get .SUFFIXES as ${.SUFFIXES} -# we actually only care about the .SUFFIXES of files that might be +# we actually only care about the .SUFFIXES of files that might be # generated by tools like yacc. DEPEND_SUFFIXES += .c .h .cpp .hpp .cxx .hxx .cc .hh .depend: .NOMETA $${.MAKE.META.CREATED} ${_this} @@ -253,9 +253,14 @@ META_FILES = ${.MAKE.META.FILES:T:N.depend*:N*o.meta:O:u} \ .info ${_DEPENDFILE:S,${SRCTOP}/,,}: ${_depend} ${.PARSEDIR}/gendirdeps.mk ${META2DEPS} xtras=${META_XTRAS} .endif -.if ${.MAKE.LEVEL} > 0 && !empty(GENDIRDEPS_FILTER) +.if ${.MAKE.LEVEL} > 0 +.if ${UPDATE_DEPENDFILE} == "yes" +.-include <${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.options> +.endif +.if !empty(GENDIRDEPS_FILTER) .export GENDIRDEPS_FILTER .endif +.endif # we might have .../ in MAKESYSPATH _makesyspath:= ${_PARSEDIR} diff --git a/mk/own.mk b/mk/own.mk index e80f72e0427f..4c8425b0ee7c 100644 --- a/mk/own.mk +++ b/mk/own.mk @@ -1,4 +1,4 @@ -# $Id: own.mk,v 1.39 2018/01/26 20:08:16 sjg Exp $ +# $Id: own.mk,v 1.40 2018/04/23 04:53:57 sjg Exp $ .if !target(__${.PARSEFILE}__) __${.PARSEFILE}__: @@ -91,7 +91,7 @@ OPTIONS_DEFAULT_NO+= DPADD_MK OPTIONS_DEFAULT_NO+= \ INSTALL_AS_USER \ GPROF \ - LDORDER_MK \ + PROG_LDORDER_MK \ LIBTOOL \ LINT \ @@ -114,7 +114,7 @@ OPTIONS_DEFAULT_YES+= \ OPTIONS_DEFAULT_DEPENDENT+= \ CATPAGES/MAN \ - PROG_LDORDER_MK/LDORDER_MK \ + LDORDER_MK/PROG_LDORDER_MK \ OBJDIRS/OBJ \ PICINSTALL/LINKLIB \ PICLIB/PIC \ diff --git a/parse.c b/parse.c index 983b96f14755..7f18fdc91433 100644 --- a/parse.c +++ b/parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.227 2018/02/22 01:59:28 sjg Exp $ */ +/* $NetBSD: parse.c,v 1.229 2018/04/05 16:31:54 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: parse.c,v 1.227 2018/02/22 01:59:28 sjg Exp $"; +static char rcsid[] = "$NetBSD: parse.c,v 1.229 2018/04/05 16:31:54 christos Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: parse.c,v 1.227 2018/02/22 01:59:28 sjg Exp $"); +__RCSID("$NetBSD: parse.c,v 1.229 2018/04/05 16:31:54 christos Exp $"); #endif #endif /* not lint */ #endif @@ -371,9 +371,6 @@ static void ParseHasCommands(void *); static void ParseDoInclude(char *); static void ParseSetParseFile(const char *); static void ParseSetIncludedFile(void); -#ifdef SYSVINCLUDE -static void ParseTraditionalInclude(char *); -#endif #ifdef GMAKEEXPORT static void ParseGmakeExport(char *); #endif @@ -2519,7 +2516,72 @@ Parse_SetInput(const char *name, int line, int fd, ParseSetParseFile(name); } +/*- + *----------------------------------------------------------------------- + * IsInclude -- + * Check if the line is an include directive + * + * Results: + * TRUE if it is. + * + * Side Effects: + * None + * + *----------------------------------------------------------------------- + */ +static Boolean +IsInclude(const char *line, Boolean sysv) +{ + static const char inc[] = "include"; + static const size_t inclen = sizeof(inc) - 1; + + // 'd' is not valid for sysv + int o = strchr(&("ds-"[sysv]), *line) != NULL; + + if (strncmp(line + o, inc, inclen) != 0) + return FALSE; + + // Space is not mandatory for BSD .include + return !sysv || isspace((unsigned char)line[inclen + o]); +} + + #ifdef SYSVINCLUDE +/*- + *----------------------------------------------------------------------- + * IsSysVInclude -- + * Check if the line is a SYSV include directive + * + * Results: + * TRUE if it is. + * + * Side Effects: + * None + * + *----------------------------------------------------------------------- + */ +static Boolean +IsSysVInclude(const char *line) +{ + const char *p; + + if (!IsInclude(line, TRUE)) + return FALSE; + + /* Avoid interpeting a dependency line as an include */ + for (p = line; (p = strchr(p, ':')) != NULL;) { + if (*++p == '\0') { + /* end of line -> dependency */ + return FALSE; + } + if (*p == ':' || isspace((unsigned char)*p)) { + /* :: operator or ': ' -> dependency */ + return FALSE; + } + } + return TRUE; +} + /*- *--------------------------------------------------------------------- * ParseTraditionalInclude -- @@ -3019,9 +3081,7 @@ Parse_File(const char *name, int fd) for (cp = line + 1; isspace((unsigned char)*cp); cp++) { continue; } - if (strncmp(cp, "include", 7) == 0 || - ((cp[0] == 'd' || cp[0] == 's' || cp[0] == '-') && - strncmp(&cp[1], "include", 7) == 0)) { + if (IsInclude(cp, FALSE)) { ParseDoInclude(cp); continue; } @@ -3083,12 +3143,7 @@ Parse_File(const char *name, int fd) } #ifdef SYSVINCLUDE - if (((strncmp(line, "include", 7) == 0 && - isspace((unsigned char) line[7])) || - ((line[0] == 's' || line[0] == '-') && - strncmp(&line[1], "include", 7) == 0 && - isspace((unsigned char) line[8]))) && - strchr(line, ':') == NULL) { + if (IsSysVInclude(line)) { /* * It's an S3/S5-style "include". */