1*51ee2c1cSSimon J. Gerraty# $Id: prog.mk,v 1.25 2013/07/18 05:46:24 sjg Exp $ 23cbdda60SSimon J. Gerraty 33cbdda60SSimon J. Gerraty.if !target(__${.PARSEFILE}__) 43cbdda60SSimon J. Gerraty__${.PARSEFILE}__: 53cbdda60SSimon J. Gerraty 63cbdda60SSimon J. Gerraty.include <init.mk> 73cbdda60SSimon J. Gerraty 83cbdda60SSimon J. Gerraty# FreeBSD at least expects MAN8 etc. 93cbdda60SSimon J. Gerraty.if defined(MAN) && !empty(MAN) 103cbdda60SSimon J. Gerraty_sect:=${MAN:E} 113cbdda60SSimon J. GerratyMAN${_sect}=${MAN} 123cbdda60SSimon J. Gerraty.endif 133cbdda60SSimon J. Gerraty 143cbdda60SSimon J. Gerraty.SUFFIXES: .out .o .c .cc .C .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0 153cbdda60SSimon J. Gerraty 163cbdda60SSimon J. GerratyCFLAGS+= ${COPTS} 173cbdda60SSimon J. Gerraty 183cbdda60SSimon J. Gerraty.if ${TARGET_OSNAME} == "NetBSD" 193cbdda60SSimon J. Gerraty.if ${MACHINE_ARCH} == "sparc64" 203cbdda60SSimon J. GerratyCFLAGS+= -mcmodel=medlow 213cbdda60SSimon J. Gerraty.endif 223cbdda60SSimon J. Gerraty 233cbdda60SSimon J. Gerraty# ELF platforms depend on crtbegin.o and crtend.o 243cbdda60SSimon J. Gerraty.if ${OBJECT_FMT} == "ELF" 253cbdda60SSimon J. Gerraty.ifndef LIBCRTBEGIN 263cbdda60SSimon J. GerratyLIBCRTBEGIN= ${DESTDIR}/usr/lib/crtbegin.o 273cbdda60SSimon J. Gerraty.MADE: ${LIBCRTBEGIN} 283cbdda60SSimon J. Gerraty.endif 293cbdda60SSimon J. Gerraty.ifndef LIBCRTEND 303cbdda60SSimon J. GerratyLIBCRTEND= ${DESTDIR}/usr/lib/crtend.o 313cbdda60SSimon J. Gerraty.MADE: ${LIBCRTEND} 323cbdda60SSimon J. Gerraty.endif 333cbdda60SSimon J. Gerraty_SHLINKER= ${SHLINKDIR}/ld.elf_so 343cbdda60SSimon J. Gerraty.else 353cbdda60SSimon J. GerratyLIBCRTBEGIN?= 363cbdda60SSimon J. GerratyLIBCRTEND?= 373cbdda60SSimon J. Gerraty_SHLINKER= ${SHLINKDIR}/ld.so 383cbdda60SSimon J. Gerraty.endif 393cbdda60SSimon J. Gerraty 403cbdda60SSimon J. Gerraty.ifndef LIBCRT0 413cbdda60SSimon J. GerratyLIBCRT0= ${DESTDIR}/usr/lib/crt0.o 423cbdda60SSimon J. Gerraty.MADE: ${LIBCRT0} 433cbdda60SSimon J. Gerraty.endif 443cbdda60SSimon J. Gerraty.endif # NetBSD 453cbdda60SSimon J. Gerraty 463cbdda60SSimon J. Gerraty# here is where you can define what LIB* are 473cbdda60SSimon J. Gerraty.-include <libnames.mk> 483cbdda60SSimon J. Gerraty.if ${MK_DPADD_MK} == "yes" 493cbdda60SSimon J. Gerraty# lots of cool magic, but might not suit everyone. 503cbdda60SSimon J. Gerraty.include <dpadd.mk> 513cbdda60SSimon J. Gerraty.endif 523cbdda60SSimon J. Gerraty 53*51ee2c1cSSimon J. Gerraty.if ${MK_GPROF} == "yes" 54*51ee2c1cSSimon J. GerratyCFLAGS+= ${CC_PG} ${PROFFLAGS} 55*51ee2c1cSSimon J. GerratyLDADD+= ${CC_PG} 56*51ee2c1cSSimon J. Gerraty.if ${MK_DPADD_MK} == "no" 57*51ee2c1cSSimon J. GerratyLDADD_LIBC_P?= -lc_p 58*51ee2c1cSSimon J. GerratyLDADD_LAST+= ${LDADD_LIBC_P} 59*51ee2c1cSSimon J. Gerraty.endif 60*51ee2c1cSSimon J. Gerraty.endif 61*51ee2c1cSSimon J. Gerraty 623cbdda60SSimon J. Gerraty.if defined(SHAREDSTRINGS) 633cbdda60SSimon J. GerratyCLEANFILES+=strings 643cbdda60SSimon J. Gerraty.c.o: 653cbdda60SSimon J. Gerraty ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c - 663cbdda60SSimon J. Gerraty @${CC} ${CFLAGS} -c x.c -o ${.TARGET} 673cbdda60SSimon J. Gerraty @rm -f x.c 683cbdda60SSimon J. Gerraty 693cbdda60SSimon J. Gerraty.cc.o: 703cbdda60SSimon J. Gerraty ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c - 713cbdda60SSimon J. Gerraty @mv -f x.c x.cc 723cbdda60SSimon J. Gerraty @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET} 733cbdda60SSimon J. Gerraty @rm -f x.cc 743cbdda60SSimon J. Gerraty 753cbdda60SSimon J. Gerraty.C.o: 763cbdda60SSimon J. Gerraty ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c - 773cbdda60SSimon J. Gerraty @mv -f x.c x.C 783cbdda60SSimon J. Gerraty @${CXX} ${CXXFLAGS} -c x.C -o ${.TARGET} 793cbdda60SSimon J. Gerraty @rm -f x.C 803cbdda60SSimon J. Gerraty.endif 813cbdda60SSimon J. Gerraty 823cbdda60SSimon J. Gerraty 833cbdda60SSimon J. Gerraty.if defined(PROG) 843cbdda60SSimon J. GerratySRCS?= ${PROG}.c 853cbdda60SSimon J. Gerraty.for s in ${SRCS:N*.h:N*.sh:M*/*} 863cbdda60SSimon J. Gerraty${.o .po .lo:L:@o@${s:T:R}$o@}: $s 873cbdda60SSimon J. Gerraty.endfor 883cbdda60SSimon J. Gerraty.if !empty(SRCS:N*.h:N*.sh) 893cbdda60SSimon J. GerratyOBJS+= ${SRCS:T:N*.h:N*.sh:R:S/$/.o/g} 903cbdda60SSimon J. GerratyLOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln} 913cbdda60SSimon J. Gerraty.endif 923cbdda60SSimon J. Gerraty 933cbdda60SSimon J. Gerraty.if defined(OBJS) && !empty(OBJS) 943cbdda60SSimon J. Gerraty.NOPATH: ${OBJS} ${PROG} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}} 953cbdda60SSimon J. Gerraty 963cbdda60SSimon J. Gerraty# this is known to work for NetBSD 1.6 and FreeBSD 4.2 973cbdda60SSimon J. Gerraty.if ${TARGET_OSNAME} == "NetBSD" || ${TARGET_OSNAME} == "FreeBSD" 983cbdda60SSimon J. Gerraty_PROGLDOPTS= 993cbdda60SSimon J. Gerraty.if ${SHLINKDIR} != "/usr/libexec" # XXX: change or remove if ld.so moves 1003cbdda60SSimon J. Gerraty_PROGLDOPTS+= -Wl,-dynamic-linker=${_SHLINKER} 1013cbdda60SSimon J. Gerraty.endif 1023cbdda60SSimon J. Gerraty.if defined(LIBDIR) && ${SHLIBDIR} != ${LIBDIR} 1033cbdda60SSimon J. Gerraty_PROGLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \ 1043cbdda60SSimon J. Gerraty -L${DESTDIR}${SHLIBDIR} 1053cbdda60SSimon J. Gerraty.endif 1063cbdda60SSimon J. Gerraty_PROGLDOPTS+= -Wl,-rpath,${SHLIBDIR}:/usr/lib 1073cbdda60SSimon J. Gerraty 1083cbdda60SSimon J. Gerraty.if defined(PROG_CXX) 1093cbdda60SSimon J. Gerraty_CCLINK= ${CXX} 1103cbdda60SSimon J. Gerraty_SUPCXX= -lstdc++ -lm 1113cbdda60SSimon J. Gerraty.endif 1123cbdda60SSimon J. Gerraty.endif # NetBSD 1133cbdda60SSimon J. Gerraty 1143cbdda60SSimon J. Gerraty_CCLINK?= ${CC} 1153cbdda60SSimon J. Gerraty 1163cbdda60SSimon J. Gerraty.if defined(DESTDIR) && exists(${LIBCRT0}) && ${LIBCRT0} != "/dev/null" 1173cbdda60SSimon J. Gerraty 1183cbdda60SSimon J. Gerraty${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD} 1193cbdda60SSimon J. Gerraty ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib ${_PROGLDOPTS} -L${DESTDIR}/usr/lib ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -L${DESTDIR}/usr/lib ${_SUPCXX} -lgcc -lc -lgcc ${LIBCRTEND} 1203cbdda60SSimon J. Gerraty 1213cbdda60SSimon J. Gerraty.else 1223cbdda60SSimon J. Gerraty 1233cbdda60SSimon J. Gerraty${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD} 1243cbdda60SSimon J. Gerraty ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD} 1253cbdda60SSimon J. Gerraty 1263cbdda60SSimon J. Gerraty.endif # defined(DESTDIR) 1273cbdda60SSimon J. Gerraty.endif # defined(OBJS) && !empty(OBJS) 1283cbdda60SSimon J. Gerraty 1293cbdda60SSimon J. Gerraty.if !defined(MAN) 1303cbdda60SSimon J. GerratyMAN= ${PROG}.1 1313cbdda60SSimon J. Gerraty.endif # !defined(MAN) 1323cbdda60SSimon J. Gerraty.endif # defined(PROG) 1333cbdda60SSimon J. Gerraty 1343cbdda60SSimon J. Gerraty.if !defined(_SKIP_BUILD) 1353cbdda60SSimon J. Gerratyall: ${PROG} 1363cbdda60SSimon J. Gerraty.endif 1373cbdda60SSimon J. Gerratyall: _SUBDIRUSE 1383cbdda60SSimon J. Gerraty 1393cbdda60SSimon J. Gerraty.if !target(clean) 1403cbdda60SSimon J. Gerratycleanprog: 1413cbdda60SSimon J. Gerraty rm -f a.out [Ee]rrs mklog core *.core \ 1423cbdda60SSimon J. Gerraty ${PROG} ${OBJS} ${LOBJS} ${CLEANFILES} 1433cbdda60SSimon J. Gerraty 1443cbdda60SSimon J. Gerratyclean: _SUBDIRUSE cleanprog 1453cbdda60SSimon J. Gerratycleandir: _SUBDIRUSE cleanprog 1463cbdda60SSimon J. Gerraty.else 1473cbdda60SSimon J. Gerratycleandir: _SUBDIRUSE clean 1483cbdda60SSimon J. Gerraty.endif 1493cbdda60SSimon J. Gerraty 1503cbdda60SSimon J. Gerraty.if defined(SRCS) && (!defined(MKDEP) || ${MKDEP} != autodep) 1513cbdda60SSimon J. Gerratyafterdepend: .depend 1523cbdda60SSimon J. Gerraty @(TMP=/tmp/_depend$$$$; \ 1533cbdda60SSimon J. Gerraty sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \ 1543cbdda60SSimon J. Gerraty < .depend > $$TMP; \ 1553cbdda60SSimon J. Gerraty mv $$TMP .depend) 1563cbdda60SSimon J. Gerraty.endif 1573cbdda60SSimon J. Gerraty 1583cbdda60SSimon J. Gerraty.if !target(install) 1593cbdda60SSimon J. Gerraty.if !target(beforeinstall) 1603cbdda60SSimon J. Gerratybeforeinstall: 1613cbdda60SSimon J. Gerraty.endif 1623cbdda60SSimon J. Gerraty.if !target(afterinstall) 1633cbdda60SSimon J. Gerratyafterinstall: 1643cbdda60SSimon J. Gerraty.endif 1653cbdda60SSimon J. Gerraty 1663cbdda60SSimon J. Gerraty.if !empty(BINOWN) 1673cbdda60SSimon J. GerratyPROG_INSTALL_OWN ?= -o ${BINOWN} -g ${BINGRP} 1683cbdda60SSimon J. Gerraty.endif 1693cbdda60SSimon J. Gerraty 1703cbdda60SSimon J. Gerraty.if !target(realinstall) 1713cbdda60SSimon J. Gerratyrealinstall: proginstall 1723cbdda60SSimon J. Gerraty.endif 1733cbdda60SSimon J. Gerraty.if !target(proginstall) 1743cbdda60SSimon J. Gerratyproginstall: 1753cbdda60SSimon J. Gerraty.if defined(PROG) 1763cbdda60SSimon J. Gerraty [ -d ${DESTDIR}${BINDIR} ] || \ 1773cbdda60SSimon J. Gerraty ${INSTALL} -d ${PROG_INSTALL_OWN} -m 775 ${DESTDIR}${BINDIR} 1783cbdda60SSimon J. Gerraty ${INSTALL} ${COPY} ${STRIP_FLAG} ${PROG_INSTALL_OWN} -m ${BINMODE} \ 1793cbdda60SSimon J. Gerraty ${PROG} ${DESTDIR}${BINDIR}/${PROG_NAME} 1803cbdda60SSimon J. Gerraty.endif 1813cbdda60SSimon J. Gerraty.if defined(HIDEGAME) 1823cbdda60SSimon J. Gerraty (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}) 1833cbdda60SSimon J. Gerraty.endif 1843cbdda60SSimon J. Gerraty.endif 1853cbdda60SSimon J. Gerraty 1863cbdda60SSimon J. Gerraty.include <links.mk> 1873cbdda60SSimon J. Gerraty 1883cbdda60SSimon J. Gerratyinstall: maninstall install_links _SUBDIRUSE 1893cbdda60SSimon J. Gerraty 1903cbdda60SSimon J. Gerratyinstall_links: 1913cbdda60SSimon J. Gerraty.if !empty(SYMLINKS) 1923cbdda60SSimon J. Gerraty @set ${SYMLINKS}; ${_SYMLINKS_SCRIPT} 1933cbdda60SSimon J. Gerraty.endif 1943cbdda60SSimon J. Gerraty.if !empty(LINKS) 1953cbdda60SSimon J. Gerraty @set ${LINKS}; ${_LINKS_SCRIPT} 1963cbdda60SSimon J. Gerraty.endif 1973cbdda60SSimon J. Gerraty 1983cbdda60SSimon J. Gerratymaninstall: afterinstall 1993cbdda60SSimon J. Gerratyafterinstall: realinstall 2003cbdda60SSimon J. Gerratyrealinstall: beforeinstall 2013cbdda60SSimon J. Gerraty.endif 2023cbdda60SSimon J. Gerraty 2033cbdda60SSimon J. Gerraty.if !target(lint) 2043cbdda60SSimon J. Gerratylint: ${LOBJS} 2053cbdda60SSimon J. Gerraty.if defined(LOBJS) && !empty(LOBJS) 2063cbdda60SSimon J. Gerraty @${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD} 2073cbdda60SSimon J. Gerraty.endif 2083cbdda60SSimon J. Gerraty.endif 2093cbdda60SSimon J. Gerraty 2103cbdda60SSimon J. Gerraty.NOPATH: ${PROG} 2113cbdda60SSimon J. Gerraty.if defined(OBJS) && !empty(OBJS) 2123cbdda60SSimon J. Gerraty.NOPATH: ${OBJS} 2133cbdda60SSimon J. Gerraty.endif 2143cbdda60SSimon J. Gerraty 2153cbdda60SSimon J. Gerraty.if ${MK_MAN} != "no" 2163cbdda60SSimon J. Gerraty.include <man.mk> 2173cbdda60SSimon J. Gerraty.endif 2183cbdda60SSimon J. Gerraty 2193cbdda60SSimon J. Gerraty.if ${MK_NLS} != "no" 2203cbdda60SSimon J. Gerraty.include <nls.mk> 2213cbdda60SSimon J. Gerraty.endif 2223cbdda60SSimon J. Gerraty 2233cbdda60SSimon J. Gerraty.include <obj.mk> 2243cbdda60SSimon J. Gerraty.include <dep.mk> 2253cbdda60SSimon J. Gerraty.include <subdir.mk> 2263cbdda60SSimon J. Gerraty.include <final.mk> 2273cbdda60SSimon J. Gerraty 2283cbdda60SSimon J. Gerraty.endif 229