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