Home | History | Annotate | Line # | Download | only in mk
      1 #	$NetBSD: bsd.prog.mk,v 1.306 2017/05/21 14:24:05 riastradh Exp $
      2 #	@(#)bsd.prog.mk	8.2 (Berkeley) 4/2/94
      3 
      4 .ifndef HOSTPROG
      5 
      6 .include <bsd.init.mk>
      7 .include <bsd.shlib.mk>
      8 .include <bsd.gcc.mk>
      9 
     10 #
     11 # Definitions and targets shared among all programs built by a single
     12 # Makefile.
     13 #
     14 
     15 ##### Basic targets
     16 realinstall:	proginstall scriptsinstall
     17 
     18 .gdbinit:
     19 	rm -f .gdbinit
     20 .if defined(DESTDIR) && !empty(DESTDIR)
     21 	echo "set solib-absolute-prefix ${DESTDIR}" > .gdbinit
     22 .else
     23 	touch .gdbinit
     24 .endif
     25 .for __gdbinit in ${GDBINIT}
     26 	echo "source ${__gdbinit}" >> .gdbinit
     27 .endfor
     28 
     29 CLEANFILES+= a.out [Ee]rrs mklog core *.core .gdbinit
     30 
     31 .if defined(SHAREDSTRINGS)
     32 CLEANFILES+=strings
     33 .c.o:
     34 	${CC} -E ${CPPFLAGS} ${CFLAGS} ${.IMPSRC} | xstr -c -
     35 	@${CC} ${CPPFLAGS} ${CFLAGS} -c x.c -o ${.TARGET}
     36 .if defined(CTFCONVERT)
     37 	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
     38 .endif
     39 	@rm -f x.c
     40 
     41 .cc.o .cpp.o .cxx.o .C.o:
     42 	${CXX} -E ${CPPFLAGS} ${CXXFLAGS} ${.IMPSRC} | xstr -c -
     43 	@mv -f x.c x.cc
     44 	@${CXX} ${CPPFLAGS} ${CXXFLAGS} -c x.cc -o ${.TARGET}
     45 .if defined(CTFCONVERT)
     46 	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
     47 .endif
     48 	@rm -f x.cc
     49 .endif
     50 
     51 .if defined(MKPIE) && (${MKPIE} != "no") && !defined(NOPIE)
     52 CFLAGS+=	${PIE_CFLAGS}
     53 AFLAGS+=	${PIE_AFLAGS}
     54 LDFLAGS+=	${"${LDSTATIC.${.TARGET}}" == "-static" :? : ${PIE_LDFLAGS}}
     55 .endif
     56 
     57 CFLAGS+=	${COPTS}
     58 .if ${MKDEBUG:Uno} != "no" && !defined(NODEBUG)
     59 CFLAGS+=	-g
     60 .endif
     61 OBJCFLAGS+=	${OBJCOPTS}
     62 MKDEP_SUFFIXES?=	.o .ln .d
     63 
     64 # CTF preserve debug symbols
     65 .if (${MKCTF:Uno} != "no") && (${CFLAGS:M-g} != "")
     66 CTFFLAGS+= -g
     67 CTFMFLAGS+= -g
     68 .if defined(HAVE_GCC)
     69 #CFLAGS+=-gdwarf-2
     70 .endif
     71 .endif
     72 
     73 # ELF platforms depend on crti.o, crtbegin.o, crtend.o, and crtn.o
     74 .ifndef LIBCRTBEGIN
     75 LIBCRTBEGIN=	${DESTDIR}/usr/lib/${MLIBDIR:D${MLIBDIR}/}crti.o ${_GCC_CRTBEGIN}
     76 .MADE: ${LIBCRTBEGIN}
     77 .endif
     78 .ifndef LIBCRTEND
     79 LIBCRTEND=	${_GCC_CRTEND} ${DESTDIR}/usr/lib/${MLIBDIR:D${MLIBDIR}/}crtn.o
     80 .MADE: ${LIBCRTEND}
     81 .endif
     82 _SHLINKER=	${SHLINKDIR}/ld.elf_so
     83 
     84 .ifndef LIBCRT0
     85 LIBCRT0=	${DESTDIR}/usr/lib/${MLIBDIR:D${MLIBDIR}/}crt0.o
     86 .MADE: ${LIBCRT0}
     87 .endif
     88 
     89 .ifndef LIBCRTI
     90 LIBCRTI=	${DESTDIR}/usr/lib/${MLIBDIR:D${MLIBDIR}/}crti.o
     91 .MADE: ${LIBCRTI}
     92 .endif
     93 
     94 ##### Installed system library definitions
     95 #
     96 #	E.g.
     97 #		LIBC?=${DESTDIR}/usr/lib/libc.a
     98 #		LIBX11?=${DESTDIR}/usr/X11R7/lib/libX11.a
     99 #	etc..
    100 #	NB:	If you are a library here, add it in bsd.README
    101 
    102 .for _lib in \
    103 	archive \
    104 	asn1 \
    105 	atf_c \
    106 	atf_cxx \
    107 	bind9 \
    108 	bluetooth \
    109 	bsdmalloc \
    110 	bz2 \
    111 	c \
    112 	c_pic \
    113 	com_err \
    114 	compat \
    115 	crypt \
    116 	crypto \
    117 	curses \
    118 	cxx \
    119 	dbm \
    120 	des \
    121 	dns \
    122 	edit \
    123 	event \
    124 	expat \
    125 	execinfo \
    126 	fetch \
    127 	fl \
    128 	form \
    129 	g2c \
    130 	gcc \
    131 	gnumalloc \
    132 	gssapi \
    133 	hdb \
    134 	heimbase \
    135 	heimntlm \
    136 	hx509 \
    137 	intl \
    138 	ipsec \
    139 	isc \
    140 	isccc \
    141 	isccfg \
    142 	kadm5clnt \
    143 	kadm5srv \
    144 	kafs \
    145 	krb5 \
    146 	kvm \
    147 	l \
    148 	lber \
    149 	ldap \
    150 	ldap_r \
    151 	lua \
    152 	lwres \
    153 	m \
    154 	magic \
    155 	menu \
    156 	netpgpverify \
    157 	objc \
    158 	ossaudio \
    159 	pam \
    160 	pcap \
    161 	pci \
    162 	pmc \
    163 	posix \
    164 	pthread \
    165 	puffs \
    166 	quota \
    167 	radius \
    168 	resolv \
    169 	rmt \
    170 	roken \
    171 	rpcsvc \
    172 	rt \
    173 	rump \
    174 	rumpfs_cd9660fs \
    175 	rumpfs_efs \
    176 	rumpfs_ext2fs \
    177 	rumpfs_ffs \
    178 	rumpfs_hfs \
    179 	rumpfs_lfs \
    180 	rumpfs_msdosfs \
    181 	rumpfs_nfs \
    182 	rumpfs_ntfs \
    183 	rumpfs_syspuffs \
    184 	rumpfs_tmpfs \
    185 	rumpfs_udf \
    186 	rumpfs_ufs \
    187 	rumpuser \
    188 	saslc \
    189 	skey \
    190 	sl \
    191 	sqlite3 \
    192 	ss \
    193 	ssh \
    194 	ssl \
    195 	ssp \
    196 	stdcxx \
    197 	supcxx \
    198 	terminfo \
    199 	tre \
    200 	unbound \
    201 	usbhid \
    202 	util \
    203 	wind \
    204 	wrap \
    205 	y \
    206 	z 
    207 .ifndef LIB${_lib:tu}
    208 LIB${_lib:tu}=	${DESTDIR}/usr/lib/lib${_lib:S/xx/++/:S/atf_c/atf-c/}.a
    209 .MADE:		${LIB${_lib:tu}}	# Note: ${DESTDIR} will be expanded
    210 .endif
    211 .endfor
    212 
    213 # PAM applications, if linked statically, need more libraries
    214 .if (${MKPIC} == "no")
    215 PAM_STATIC_LDADD+= -lssh
    216 PAM_STATIC_DPADD+= ${LIBSSH}
    217 .if (${MKKERBEROS} != "no")
    218 PAM_STATIC_LDADD+= -lkafs -lkrb5 -lhx509 -lwind -lasn1 \
    219 	-lroken -lcom_err -lheimbase -lcrypto -lsqlite3
    220 PAM_STATIC_DPADD+= ${LIBKAFS} ${LIBKRB5} ${LIBHX509} ${LIBWIND} ${LIBASN1} \
    221 	${LIBROKEN} ${LIBCOM_ERR} ${LIBHEIMBASE} ${LIBCRYPTO} ${LIBSQLITE3}
    222 .endif
    223 .if (${MKSKEY} != "no")
    224 PAM_STATIC_LDADD+= -lskey
    225 PAM_STATIC_DPADD+= ${LIBSKEY}
    226 .endif
    227 PAM_STATIC_LDADD+= -lradius -lcrypt -lrpcsvc -lutil
    228 PAM_STATIC_DPADD+= ${LIBRADIUS} ${LIBCRYPT} ${LIBRPCSVC} ${LIBUTIL}
    229 .else
    230 PAM_STATIC_LDADD=
    231 PAM_STATIC_DPADD=
    232 .endif
    233 
    234 #	NB:	If you are a library here, add it in bsd.README
    235 .for _lib in \
    236 	FS \
    237 	GL \
    238 	GLU \
    239 	ICE \
    240 	SM \
    241 	X11 \
    242 	XTrap \
    243 	Xau \
    244 	Xaw \
    245 	Xdmcp \
    246 	Xext \
    247 	Xfont \
    248 	Xft \
    249 	Xi \
    250 	Xinerama \
    251 	Xmu \
    252 	Xmuu \
    253 	Xpm \
    254 	Xrandr \
    255 	Xrender \
    256 	Xss \
    257 	Xt \
    258 	Xtst \
    259 	Xv \
    260 	Xxf86dga \
    261 	Xxf86misc \
    262 	Xxf86vm \
    263 	dps \
    264 	fntstubs \
    265 	fontcache \
    266 	fontconfig \
    267 	fontenc \
    268 	freetype \
    269 	lbxutil \
    270 	xkbfile
    271 .ifndef LIB${_lib:tu}
    272 LIB${_lib:tu}=	${DESTDIR}${X11USRLIBDIR}/lib${_lib}.a
    273 .MADE:		${LIB${_lib:tu}}	# Note: ${DESTDIR} will be expanded
    274 .endif
    275 .endfor
    276 
    277 # Ugly one-offs
    278 LIBX11_XCB=	${DESTDIR}${X11USRLIBDIR}/libX11-xcb.a
    279 LIBXCB=	${DESTDIR}${X11USRLIBDIR}/libxcb.a
    280 
    281 .if defined(RESCUEDIR)
    282 CPPFLAGS+=	-DRESCUEDIR=\"${RESCUEDIR}\"
    283 .endif
    284 
    285 _PROGLDOPTS=
    286 .if ${SHLINKDIR} != "/usr/libexec"	# XXX: change or remove if ld.so moves
    287 _PROGLDOPTS+=	-Wl,-dynamic-linker=${_SHLINKER}
    288 .endif
    289 .if ${SHLIBDIR} != "/usr/lib"
    290 _PROGLDOPTS+=	-Wl,-rpath,${SHLIBDIR} \
    291 		-L=${SHLIBDIR}
    292 .elif ${SHLIBINSTALLDIR} != "/usr/lib"
    293 _PROGLDOPTS+=	-Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR} \
    294 		-L=${SHLIBINSTALLDIR}
    295 .endif
    296 
    297 __proginstall: .USE
    298 	${_MKTARGET_INSTALL}
    299 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
    300 		${STRIPFLAG} ${.ALLSRC} ${.TARGET}
    301 
    302 __progrumpinstall: .USE
    303 	${_MKTARGET_INSTALL}
    304 	${INSTALL_FILE} -o ${RUMPBINOWN} -g ${RUMPBINGRP} -m ${RUMPBINMODE} \
    305 		${STRIPFLAG} ${.ALLSRC} ${.TARGET}
    306 
    307 __progdebuginstall: .USE
    308 	${_MKTARGET_INSTALL}
    309 	${INSTALL_FILE} -o ${DEBUGOWN} -g ${DEBUGGRP} -m ${DEBUGMODE} \
    310 		${.ALLSRC} ${.TARGET}
    311 
    312 
    313 
    314 #
    315 # Backwards compatibility with Makefiles that assume that bsd.prog.mk
    316 # can only build a single binary.
    317 #
    318 
    319 _APPEND_MANS=yes
    320 _APPEND_SRCS=yes
    321 
    322 _CCLINKFLAGS=
    323 
    324 .if defined(PROG_CXX)
    325 PROG=		${PROG_CXX}
    326 _CCLINK=	${CXX} ${_CCLINKFLAGS}
    327 .endif
    328 
    329 .if defined(RUMPPRG)
    330 CPPFLAGS+=	-D_KERNTYPES
    331 PROG=			${RUMPPRG}
    332 . ifndef CRUNCHEDPROG
    333 .  if (${MKRUMP} != "no")
    334 PROGS=			${RUMPPRG} rump.${RUMPPRG}
    335 .  else
    336 PROGS=			${RUMPPRG}
    337 .  endif
    338 .  if defined(SRCS)
    339 .   if (${MKRUMP} != "no")
    340 SRCS.rump.${PROG}:=	${SRCS} ${PROG}_rumpops.c ${RUMPSRCS}
    341 .   endif
    342 SRCS+=			${PROG}_hostops.c
    343 .  else
    344 SRCS=			${PROG}.c ${PROG}_hostops.c
    345 .   if (${MKRUMP} != "no")
    346 SRCS.rump.${PROG}=	${PROG}.c ${PROG}_rumpops.c ${RUMPSRCS}
    347 .   endif
    348 .  endif
    349 .   if (${MKRUMP} != "no")
    350 DPSRCS+=		${PROG}_rumpops.c ${RUMPSRCS}
    351 LDADD.rump.${PROG}+=	-lrumpclient
    352 DPADD.rump.${PROG}+=	${LIBRUMPCLIENT}
    353 MAN.rump.${PROG}=	# defined but feeling empty
    354 _RUMPINSTALL.rump.${PROG}=# defined
    355 .   endif
    356 . else # CRUNCHEDPROG
    357 PROGS=			${PROG}
    358 CPPFLAGS+=		-DCRUNCHOPS
    359 . endif
    360 .endif
    361 
    362 .if defined(PROG)
    363 _CCLINK?=	${CC} ${_CCLINKFLAGS}
    364 .  if defined(MAN)
    365 MAN.${PROG}=	${MAN}
    366 _APPEND_MANS=	no
    367 .  endif
    368 .  if !defined(OBJS)
    369 OBJS=		${OBJS.${PROG}}
    370 .  endif
    371 .  if defined(PROGNAME)
    372 PROGNAME.${PROG}=	${PROGNAME}
    373 .  endif
    374 .  if defined(SRCS)
    375 SRCS.${PROG}=	${SRCS}
    376 _APPEND_SRCS=	no
    377 .  endif
    378 .endif
    379 
    380 # Turn the single-program PROG and PROG_CXX variables into their multi-word
    381 # counterparts, PROGS and PROGS_CXX.
    382 .if !defined(RUMPPRG)
    383 .  if defined(PROG_CXX) && !defined(PROGS_CXX)
    384 PROGS_CXX=	${PROG_CXX}
    385 .  elif defined(PROG) && !defined(PROGS)
    386 PROGS=		${PROG}
    387 .  endif
    388 .endif
    389 
    390 ##### Libraries that this may depend upon.
    391 .if defined(PROGDPLIBS) 						# {
    392 .for _lib _dir in ${PROGDPLIBS}
    393 .if !defined(BINDO.${_lib})
    394 PROGDO.${_lib}!=	cd "${_dir}" && ${PRINTOBJDIR}
    395 .MAKEOVERRIDES+=PROGDO.${_lib}
    396 .endif
    397 LDADD+=		-L${PROGDO.${_lib}} -l${_lib}
    398 .if exists(${PROGDO.${_lib}}/lib${_lib}_pic.a)
    399 DPADD+=		${PROGDO.${_lib}}/lib${_lib}_pic.a
    400 .elif exists(${PROGDO.${_lib}}/lib${_lib}.so)
    401 DPADD+=		${PROGDO.${_lib}}/lib${_lib}.so
    402 .else
    403 DPADD+=		${PROGDO.${_lib}}/lib${_lib}.a
    404 .endif
    405 .endfor
    406 .endif									# }
    407 #
    408 # Per-program definitions and targets.
    409 #
    410 
    411 _CCLINK.CDEFAULT= ${CC} ${_CCLINKFLAGS}
    412 # Definitions specific to C programs.
    413 .for _P in ${PROGS}
    414 SRCS.${_P}?=	${_P}.c
    415 _CCLINK.${_P}=	${CC} ${_CCLINKFLAGS}
    416 _CFLAGS.${_P}=	${CFLAGS} ${CPUFLAGS}
    417 _CPPFLAGS.${_P}=	${CPPFLAGS}
    418 _COPTS.${_P}=	${COPTS}
    419 .endfor
    420 
    421 _CCLINK.CXXDEFAULT= ${CXX} ${_CCLINKFLAGS}
    422 # Definitions specific to C++ programs.
    423 .for _P in ${PROGS_CXX}
    424 SRCS.${_P}?=	${_P}.cc
    425 _CCLINK.${_P}=	${CXX} ${_CCLINKFLAGS}
    426 .endfor
    427 
    428 # Language-independent definitions.
    429 .for _P in ${PROGS} ${PROGS_CXX}					# {
    430 
    431 BINDIR.${_P}?=		${BINDIR}
    432 PROGNAME.${_P}?=	${_P}
    433 
    434 .if ${MKDEBUG:Uno} != "no" && !defined(NODEBUG) && !commands(${_P})
    435 _PROGDEBUG.${_P}:=	${PROGNAME.${_P}}.debug
    436 .endif
    437 
    438 .if defined(PAXCTL_FLAGS)
    439 PAXCTL_FLAGS.${_P}?= ${PAXCTL_FLAGS}
    440 .endif
    441 
    442 ##### PROG specific flags.
    443 
    444 _DPADD.${_P}=		${DPADD}    ${DPADD.${_P}}
    445 _LDADD.${_P}=		${LDADD}    ${LDADD.${_P}}
    446 _LDFLAGS.${_P}=		${LDFLAGS}  ${LDFLAGS.${_P}}
    447 _LDSTATIC.${_P}=	${LDSTATIC} ${LDSTATIC.${_P}}
    448 
    449 ##### Build and install rules
    450 .if !empty(_APPEND_SRCS:M[Yy][Ee][Ss])
    451 SRCS+=		${SRCS.${_P}}	# For bsd.dep.mk
    452 .endif
    453 
    454 _YPSRCS.${_P}=	${SRCS.${_P}:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS.${_P}:M*.y:.y=.h}}
    455 
    456 DPSRCS+=		${_YPSRCS.${_P}}
    457 CLEANFILES+=		${_YPSRCS.${_P}}
    458 
    459 .if !empty(SRCS.${_P}:N*.h:N*.sh:N*.fth)
    460 OBJS.${_P}+=	${SRCS.${_P}:N*.h:N*.sh:N*.fth:R:S/$/.o/g}
    461 LOBJS.${_P}+=	${LSRCS:.c=.ln} ${SRCS.${_P}:M*.c:.c=.ln}
    462 .endif
    463 
    464 .if defined(OBJS.${_P}) && !empty(OBJS.${_P})			# {
    465 .NOPATH: ${OBJS.${_P}} ${_P} ${_YPSRCS.${_P}}
    466 
    467 .if (defined(USE_COMBINE) && ${USE_COMBINE} != "no" && !commands(${_P}) \
    468    && (${_CCLINK.${_P}} == ${_CCLINK.CDEFAULT} \
    469        || ${_CCLINK.${_P}} == ${_CCLINK.CXXDEFAULT}) \
    470    && !defined(NOCOMBINE.${_P}) && !defined(NOCOMBINE))
    471 .for f in ${SRCS.${_P}:N*.h:N*.sh:N*.fth:C/\.[yl]$/.c/g}
    472 #_XFLAGS.$f := ${CPPFLAGS.$f:D1} ${CPUFLAGS.$f:D2} \
    473 #     ${COPTS.$f:D3} ${OBJCOPTS.$f:D4} ${CXXFLAGS.$f:D5}
    474 .if (${CPPFLAGS.$f:D1} == "1" || ${CPUFLAGS.$f:D2} == "2" \
    475      || ${COPTS.$f:D3} == "3" || ${OBJCOPTS.$f:D4} == "4" \
    476      || ${CXXFLAGS.$f:D5} == "5") \
    477     || ("${f:M*.[cyl]}" == "" || commands(${f:R:S/$/.o/}))
    478 XOBJS.${_P}+=	${f:R:S/$/.o/}
    479 .else
    480 XSRCS.${_P}+=	${f}
    481 NODPSRCS+=	${f}
    482 .endif
    483 .endfor
    484 
    485 ${_P}: .gdbinit ${LIBCRT0} ${LIBCRTI} ${XOBJS.${_P}} ${SRCS.${_P}} \
    486     ${DPSRCS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${_DPADD.${_P}}
    487 	${_MKTARGET_LINK}
    488 .if defined(DESTDIR)
    489 	${_CCLINK.${_P}} -Wl,-nostdlib \
    490 	    ${_LDFLAGS.${_P}} ${_LDSTATIC.${_P}} -o ${.TARGET} ${_PROGLDOPTS} \
    491 	    -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/ \
    492 	    -MD --combine ${_CPPFLAGS.${_P}} ${_CFLAGS.${_P}} ${_COPTS.${_P}} \
    493 	    ${XSRCS.${_P}:@.SRC.@${.ALLSRC:M*.c:M*${.SRC.}}@:O:u} ${XOBJS.${_P}} \
    494 	    ${_LDADD.${_P}} -L${_GCC_LIBGCCDIR} -L${DESTDIR}/usr/lib
    495 .else
    496 	${_CCLINK.${_P}} ${_LDFLAGS.${_P}} ${_LDSTATIC.${_P}} -o ${.TARGET} ${_PROGLDOPTS} \
    497 	    -MD --combine ${_CPPFLAGS.${_P}} ${_COPTS.${_P}}
    498 	    ${XSRCS.${_P}:@.SRC.@${.ALLSRC:M*.c:M*${.SRC.}}@:O:u} ${XOBJS.${_P}} \
    499 	    ${_LDADD.${_P}}
    500 .endif	# defined(DESTDIR)
    501 .if defined(CTFMERGE)
    502 	${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${OBJS.${_P}}
    503 .endif
    504 .if defined(PAXCTL_FLAGS.${_P})
    505 	${PAXCTL} ${PAXCTL_FLAGS.${_P}} ${.TARGET}
    506 .endif
    507 .if ${MKSTRIPIDENT} != "no"
    508 	${OBJCOPY} -R .ident ${.TARGET}
    509 .endif
    510 
    511 CLEANFILES+=	${_P}.d
    512 .if exists(${_P}.d)
    513 .include "${_P}.d"		# include -MD depend for program.
    514 .endif
    515 .else	# USE_COMBINE
    516 
    517 ${OBJS.${_P}} ${LOBJS.${_P}}: ${DPSRCS}
    518 
    519 ${_P}: .gdbinit ${LIBCRT0} ${LIBCRTI} ${OBJS.${_P}} ${LIBC} ${LIBCRTBEGIN} \
    520     ${LIBCRTEND} ${_DPADD.${_P}}
    521 .if !commands(${_P})
    522 	${_MKTARGET_LINK}
    523 	${_CCLINK.${_P}} \
    524 	    ${_LDFLAGS.${_P}} ${_LDSTATIC.${_P}} -o ${.TARGET} \
    525 	    ${OBJS.${_P}} ${_PROGLDOPTS} ${_LDADD.${_P}}
    526 .if defined(CTFMERGE)
    527 	${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${OBJS.${_P}}
    528 .endif
    529 .if defined(PAXCTL_FLAGS.${_P})
    530 	${PAXCTL} ${PAXCTL_FLAGS.${_P}} ${.TARGET}
    531 .endif
    532 .if ${MKSTRIPIDENT} != "no"
    533 	${OBJCOPY} -R .ident ${.TARGET}
    534 .endif
    535 .endif	# !commands(${_P})
    536 .endif	# USE_COMBINE
    537 
    538 ${_P}.ro: ${OBJS.${_P}} ${_DPADD.${_P}}
    539 	${_MKTARGET_LINK}
    540 	${CC} ${LDFLAGS:N-pie} -nostdlib -r -Wl,-dc -o ${.TARGET} ${OBJS.${_P}}
    541 
    542 .if defined(_PROGDEBUG.${_P})
    543 ${_PROGDEBUG.${_P}}: ${_P}
    544 	${_MKTARGET_CREATE}
    545 	(  ${OBJCOPY} --only-keep-debug ${_P} ${_PROGDEBUG.${_P}} \
    546 	&& ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \
    547 		--add-gnu-debuglink=${_PROGDEBUG.${_P}} ${_P} \
    548 	) || (rm -f ${_PROGDEBUG.${_P}}; false)
    549 .endif
    550 
    551 .endif	# defined(OBJS.${_P}) && !empty(OBJS.${_P})			# }
    552 
    553 .if !defined(MAN.${_P})
    554 MAN.${_P}=	${_P}.1
    555 .endif	# !defined(MAN.${_P})
    556 .if !empty(_APPEND_MANS:M[Yy][Ee][Ss])
    557 MAN+=		${MAN.${_P}}
    558 .endif
    559 
    560 realall: ${_P} ${_PROGDEBUG.${_P}}
    561 
    562 CLEANFILES+= ${_P} ${_PROGDEBUG.${_P}}
    563 
    564 .if defined(OBJS.${_P}) && !empty(OBJS.${_P})
    565 CLEANFILES+= ${OBJS.${_P}} ${LOBJS.${_P}}
    566 .endif
    567 
    568 _PROG_INSTALL+=	proginstall-${_P}
    569 
    570 .if !target(proginstall-${_P})						# {
    571 proginstall-${_P}::	${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}} \
    572 		${_PROGDEBUG.${_P}:D${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}}
    573 .PRECIOUS:	${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}} \
    574 		${_PROGDEBUG.${_P}:D${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}}
    575 
    576 .if ${MKUPDATE} == "no"
    577 .if defined(_RUMPINSTALL.${_P})
    578 ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}! ${_P} __progrumpinstall
    579 .else
    580 ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}! ${_P} __proginstall
    581 .endif
    582 .if !defined(BUILD) && !make(all) && !make(${_P})
    583 ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}! .MADE
    584 .endif
    585 .if defined(_PROGDEBUG.${_P})
    586 ${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}! ${_PROGDEBUG.${_P}} __progdebuginstall
    587 .if !defined(BUILD) && !make(all) && !make(${_P})
    588 ${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}! .MADE
    589 .endif
    590 .endif	#  define(_PROGDEBUG.${_P})
    591 .else	# MKUPDATE != no
    592 .if defined(_RUMPINSTALL.${_P})
    593 ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}: ${_P} __progrumpinstall
    594 .else
    595 ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}: ${_P} __proginstall
    596 .endif
    597 .if !defined(BUILD) && !make(all) && !make(${_P})
    598 ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}: .MADE
    599 .endif
    600 .if defined(_PROGDEBUG.${_P})
    601 ${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}: ${_PROGDEBUG.${_P}} __progdebuginstall
    602 .if !defined(BUILD) && !make(all) && !make(${_P})
    603 ${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}: .MADE
    604 .endif
    605 .endif	#  defined(_PROGDEBUG.${_P})
    606 .endif	# MKUPDATE != no
    607 
    608 .endif	# !target(proginstall-${_P})					# }
    609 
    610 lint: lint-${_P}
    611 lint-${_P}: ${LOBJS.${_P}}
    612 .if defined(LOBJS.${_P}) && !empty(LOBJS.${_P})
    613 	${LINT} ${LINTFLAGS} ${_LDFLAGS.${_P}:C/-L[  ]*/-L/Wg:M-L*} ${LOBJS.${_P}} ${_LDADD.${_P}}
    614 .endif
    615 
    616 .endfor # _P in ${PROGS} ${PROGS_CXX}					# }
    617 
    618 .if defined(OBJS) && !empty(OBJS) && \
    619     (empty(PROGS) && empty(PROGS_CXX))
    620 CLEANFILES+= ${OBJS} ${LOBJS}
    621 .endif
    622 
    623 .if !target(proginstall)
    624 proginstall:: ${_PROG_INSTALL}
    625 .endif
    626 .PHONY:		proginstall
    627 
    628 
    629 
    630 realall: ${SCRIPTS}
    631 .if defined(SCRIPTS) && !target(scriptsinstall)				# {
    632 SCRIPTSDIR?=${BINDIR}
    633 SCRIPTSOWN?=${BINOWN}
    634 SCRIPTSGRP?=${BINGRP}
    635 SCRIPTSMODE?=${BINMODE}
    636 
    637 scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
    638 .PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
    639 
    640 __scriptinstall: .USE
    641 	${_MKTARGET_INSTALL}
    642 	${INSTALL_FILE} \
    643 	    -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \
    644 	    -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \
    645 	    -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \
    646 	    ${.ALLSRC} ${.TARGET}
    647 
    648 .for S in ${SCRIPTS:O:u}
    649 .if ${MKUPDATE} == "no"
    650 ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! ${S} __scriptinstall
    651 .if !defined(BUILD) && !make(all) && !make(${S})
    652 ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! .MADE
    653 .endif
    654 .else
    655 ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: ${S} __scriptinstall
    656 .if !defined(BUILD) && !make(all) && !make(${S})
    657 ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE
    658 .endif
    659 .endif
    660 .endfor
    661 .endif									# }
    662 
    663 .if !target(scriptsinstall)
    664 scriptsinstall::
    665 .endif
    666 .PHONY:		scriptsinstall
    667 
    668 ##### Pull in related .mk logic
    669 LINKSOWN?= ${BINOWN}
    670 LINKSGRP?= ${BINGRP}
    671 LINKSMODE?= ${BINMODE}
    672 .include <bsd.man.mk>
    673 .include <bsd.nls.mk>
    674 .include <bsd.files.mk>
    675 .include <bsd.inc.mk>
    676 .include <bsd.links.mk>
    677 .include <bsd.sys.mk>
    678 .include <bsd.dep.mk>
    679 .include <bsd.clang-analyze.mk>
    680 .include <bsd.clean.mk>
    681 
    682 ${TARGETS}:	# ensure existence
    683 
    684 .endif	# HOSTPROG
    685