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