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