[BACK]Return to bsd.prog.mk CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / share / mk

Annotation of src/share/mk/bsd.prog.mk, Revision 1.185

1.185   ! erh         1: #      $NetBSD: bsd.prog.mk,v 1.184 2003/09/12 07:44:11 lukem Exp $
1.67      mikel       2: #      @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
1.1       cgd         3:
1.166     lukem       4: .ifndef HOSTPROG
                      5:
1.138     tv          6: .include <bsd.init.mk>
1.159     thorpej     7: .include <bsd.shlib.mk>
1.167     thorpej     8: .include <bsd.gcc.mk>
1.74      mycroft     9:
1.185   ! erh        10: .if defined(PROG_CXX)
        !            11: PROG=  ${PROG_CXX}
        !            12: .endif
        !            13:
1.138     tv         14: ##### Basic targets
1.148     enami      15: .PHONY:                cleanextra cleanobjs cleanprog proginstall scriptsinstall
1.80      mycroft    16: realinstall:   proginstall scriptsinstall
1.132     tv         17: clean:         cleanprog
1.1       cgd        18:
1.185   ! erh        19: ##### PROG specific flags.
        !            20: COPTS+=    ${COPTS.${PROG}}
        !            21: CPPFLAGS+=  ${CPPFLAGS.${PROG}}
        !            22: CXXFLAGS+=  ${CXXFLAGS.${PROG}}
        !            23: LDADD+=     ${LDADD.${PROG}}
        !            24:
1.138     tv         25: ##### Default values
1.142     thorpej    26: CPPFLAGS+=     ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
1.175     mrg        27: CXXFLAGS+=     ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} ${DESTDIR}/usr/include/g++}
1.25      mycroft    28: CFLAGS+=       ${COPTS}
1.155     eeh        29: .if ${MACHINE_ARCH} == "sparc64"
                     30: CFLAGS+=       -mcmodel=medlow
                     31: .endif
1.1       cgd        32:
1.162     thorpej    33: # ELF platforms depend on crti.o, crtbegin.o, crtend.o, and crtn.o
1.100     lukem      34: .if ${OBJECT_FMT} == "ELF"
1.153     pk         35: .ifndef LIBCRTBEGIN
1.167     thorpej    36: LIBCRTBEGIN=   ${DESTDIR}/usr/lib/crti.o ${_GCC_CRTBEGIN}
1.152     christos   37: .MADE: ${LIBCRTBEGIN}
1.153     pk         38: .endif
                     39: .ifndef LIBCRTEND
1.167     thorpej    40: LIBCRTEND=     ${_GCC_CRTEND} ${DESTDIR}/usr/lib/crtn.o
1.152     christos   41: .MADE: ${LIBCRTEND}
1.153     pk         42: .endif
1.144     lukem      43: _SHLINKER=     ${SHLINKDIR}/ld.elf_so
1.69      thorpej    44: .else
                     45: LIBCRTBEGIN?=
                     46: LIBCRTEND?=
1.144     lukem      47: _SHLINKER=     ${SHLINKDIR}/ld.so
1.69      thorpej    48: .endif
                     49:
1.153     pk         50: .ifndef LIBCRT0
                     51: LIBCRT0=       ${DESTDIR}/usr/lib/crt0.o
1.152     christos   52: .MADE: ${LIBCRT0}
1.153     pk         53: .endif
1.95      ross       54:
1.153     pk         55: ##### Installed system library definitions
                     56: #     E.g. LIBC?=${DESTDIR}/usr/lib/libc.a
                     57: #     etc..
                     58: #
                     59: __bsd_prog_mk_system_libs?= \
1.158     itojun     60:        BZ2 C C_PIC CDK COM_ERR COMPAT CRYPT CRYPTO CRYPTO_IDEA CRYPTO_MDC2 \
                     61:        CRYPTO_RC5 \
1.169     itojun     62:        CURSES DBM DES EDIT EVENT FORM GCC GNUMALLOC GSSAPI HDB INTL IPSEC \
1.153     pk         63:        KADM KADM5CLNT KADM5SRV KAFS KDB KRB KRB5 KSTREAM KVM L M MENU \
1.163     thorpej    64:        OBJC OSSAUDIO PCAP PCI PMC POSIX PTHREAD PTHREAD_DBG RESOLV RMT \
1.171     itojun     65:        ROKEN RPCSVC RT SKEY SS SSL SL TERMCAP USBHID UTIL WRAP Y Z
1.153     pk         66:
                     67: .for _n in ${__bsd_prog_mk_system_libs}
                     68: .ifndef LIB${_n}
                     69: LIB${_n}= ${DESTDIR}/usr/lib/lib${_n:tl}.a
1.184     lukem      70: # Note: ${DESTDIR} will be expanded in the following rule
1.153     pk         71: .MADE: ${LIB${_n}}
                     72: .endif
                     73: .endfor
                     74: .undef __bsd_prog_mk_system_libs
1.184     lukem      75:
                     76: ##### Installed X11R6 library definitions
                     77: #     E.g. LIBX11?=${DESTDIR}/usr/X11R6/lib/libX11.a
                     78: #     etc..
                     79: #
                     80: __bsd_prog_mk_x11r6_libs?= \
                     81:        dps expat fntstubs fontcache fontconfig fontenc freetype FS \
                     82:        GL GLU ICE lbxutil SM X11 Xau Xaw Xdmcp Xext Xfont Xft \
                     83:        Xi Xinerama xkbfile Xmu Xmuu Xpm Xrandr Xrender Xss Xt \
                     84:        XTrap Xtst Xv Xxf86dga Xxf86misc Xxf86vm
                     85:
                     86: .for _n in ${__bsd_prog_mk_x11r6_libs}
                     87: .ifndef LIB${_n:tu}
                     88: LIB${_n:tu}= ${DESTDIR}/usr/X11R6/lib/lib${_n}.a
                     89: # Note: ${DESTDIR} will be expanded in the following rule
                     90: .MADE: ${LIB${_n:tu}}
                     91: .endif
                     92: .endfor
                     93: .undef __bsd_prog_mk_x11r6_libs
1.1       cgd        94:
1.138     tv         95: ##### Build and install rules
1.1       cgd        96: .if defined(SHAREDSTRINGS)
                     97: CLEANFILES+=strings
                     98: .c.o:
                     99:        ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
                    100:        @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
                    101:        @rm -f x.c
1.18      mycroft   102:
1.173     lukem     103: .cc.o .cpp.o .cxx.o .C.o:
1.18      mycroft   104:        ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
                    105:        @mv -f x.c x.cc
                    106:        @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
1.26      mycroft   107:        @rm -f x.cc
1.146     thorpej   108: .endif
1.38      jtc       109:
1.1       cgd       110: .if defined(PROG)
1.146     thorpej   111: .if defined(PROG_CXX)
                    112: SRCS?=         ${PROG}.cc
                    113: .else
1.80      mycroft   114: SRCS?=         ${PROG}.c
1.146     thorpej   115: .endif
1.80      mycroft   116:
1.178     lukem     117: DPSRCS+=       ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
1.182     lukem     118: DPSRCS+=       ${YHEADER:D${SRCS:M*.y:.y=.h}}
                    119: CLEANFILES+=   ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
                    120: CLEANFILES+=   ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.80      mycroft   121:
1.108     eeh       122: .if !empty(SRCS:N*.h:N*.sh:N*.fth)
                    123: OBJS+=         ${SRCS:N*.h:N*.sh:N*.fth:R:S/$/.o/g}
1.80      mycroft   124: LOBJS+=                ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
1.45      cgd       125: .endif
1.1       cgd       126:
1.47      cgd       127: .if defined(OBJS) && !empty(OBJS)
1.141     tv        128: .NOPATH: ${OBJS} ${PROG} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.137     tv        129:
1.144     lukem     130: _PROGLDOPTS=
                    131: .if ${SHLINKDIR} != "/usr/libexec"     # XXX: change or remove if ld.so moves
1.161     itohy     132: .if ${OBJECT_FMT} == "ELF"
1.144     lukem     133: _PROGLDOPTS+=  -Wl,-dynamic-linker=${_SHLINKER}
1.161     itohy     134: .endif
                    135: .if ${OBJECT_FMT} == "a.out"
                    136: LIBCRT0=       ${DESTDIR}/lib/crt0.o
                    137: .endif
1.144     lukem     138: .endif
                    139: .if ${SHLIBDIR} != ${LIBDIR}
                    140: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
1.179     lukem     141:                -R${SHLIBDIR} \
1.144     lukem     142:                -L${DESTDIR}${SHLIBDIR}
1.159     thorpej   143: .elif ${SHLIBINSTALLDIR} != ${LIBDIR}
                    144: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
                    145:                -L${DESTDIR}${SHLIBINSTALLDIR}
1.144     lukem     146: .endif
                    147:
1.145     thorpej   148: .if defined(PROG_CXX)
                    149: _CCLINK=       ${CXX}
1.177     lukem     150: .if ${USE_LIBSTDCXX} == "no"
1.174     mrg       151: _SUPCXX=       -lsupc++ -lm
                    152: .else
1.145     thorpej   153: _SUPCXX=       -lstdc++ -lm
1.174     mrg       154: .endif
1.145     thorpej   155: .else
                    156: _CCLINK=       ${CC}
                    157: .endif
                    158:
1.157     thorpej   159: .gdbinit:
                    160:        rm -f .gdbinit
                    161: .if defined(DESTDIR) && !empty(DESTDIR)
                    162:        echo "set solib-absolute-prefix ${DESTDIR}" > .gdbinit
                    163: .else
                    164:        touch .gdbinit
                    165: .endif
                    166: .for __gdbinit in ${GDBINIT}
                    167:        echo "source ${__gdbinit}" >> .gdbinit
                    168: .endfor
                    169:
1.182     lukem     170: ${OBJS} ${LOBJS}: ${DPSRCS}
                    171:
                    172: ${PROG}: .gdbinit ${LIBCRT0} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
1.127     christos  173: .if !commands(${PROG})
1.181     lukem     174: .if defined(DESTDIR)
1.167     thorpej   175:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib ${_PROGLDOPTS} ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -L${_GCC_LIBGCCDIR} -L${DESTDIR}/usr/lib ${_SUPCXX} -lgcc -lc -lgcc ${LIBCRTEND}
1.46      mycroft   176: .else
1.145     thorpej   177:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}
1.181     lukem     178: .endif # defined(DESTDIR)
                    179: .endif # !commands(${PROG})
1.183     dsl       180:
                    181: ${PROG}.ro: ${OBJS} ${DPADD}
                    182:        ${LD} -r -dc -o ${.TARGET} ${OBJS}
1.1       cgd       183:
1.47      cgd       184: .endif # defined(OBJS) && !empty(OBJS)
1.1       cgd       185:
1.100     lukem     186: .if !defined(MAN)
1.49      cgd       187: MAN=   ${PROG}.1
                    188: .endif # !defined(MAN)
                    189: .endif # defined(PROG)
1.11      mycroft   190:
1.107     mycroft   191: realall: ${PROG} ${SCRIPTS}
1.1       cgd       192:
1.134     tls       193: cleanprog: cleanobjs cleanextra
1.157     thorpej   194:        rm -f a.out [Ee]rrs mklog core *.core .gdbinit ${PROG}
1.134     tls       195:
                    196: cleanobjs:
1.135     lukem     197: .if defined(OBJS) && !empty(OBJS)
1.134     tls       198:        rm -f ${OBJS} ${LOBJS}
1.135     lukem     199: .endif
1.134     tls       200:
                    201: cleanextra:
1.135     lukem     202: .if defined(CLEANFILES) && !empty(CLEANFILES)
1.134     tls       203:        rm -f ${CLEANFILES}
1.135     lukem     204: .endif
1.1       cgd       205:
1.129     jmc       206: .if defined(SRCS) && !target(afterdepend)
1.59      cgd       207: afterdepend: .depend
1.168     msaitoh   208:        @(TMP=/tmp/_depend$$$$; trap 'rm -f $$TMP ; exit 1' 1 2 3 13 15; \
1.59      cgd       209:            sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \
                    210:              < .depend > $$TMP; \
                    211:            mv $$TMP .depend)
                    212: .endif
1.27      mycroft   213:
1.74      mycroft   214: .if defined(PROG) && !target(proginstall)
1.114     mycroft   215: PROGNAME?=${PROG}
                    216:
1.63      christos  217: proginstall:: ${DESTDIR}${BINDIR}/${PROGNAME}
1.114     mycroft   218: .PRECIOUS: ${DESTDIR}${BINDIR}/${PROGNAME}
                    219:
1.115     mycroft   220: __proginstall: .USE
1.139     tv        221:        ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1.160     perry     222:                ${STRIPFLAG} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   223:
1.172     lukem     224: .if ${MKUPDATE} == "no"
1.154     mycroft   225: ${DESTDIR}${BINDIR}/${PROGNAME}! ${PROG} __proginstall
                    226: .if !defined(BUILD) && !make(all) && !make(${PROG})
                    227: ${DESTDIR}${BINDIR}/${PROGNAME}! .MADE
                    228: .endif
                    229: .else
                    230: ${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG} __proginstall
1.103     fredb     231: .if !defined(BUILD) && !make(all) && !make(${PROG})
1.63      christos  232: ${DESTDIR}${BINDIR}/${PROGNAME}: .MADE
                    233: .endif
1.154     mycroft   234: .endif
1.23      mycroft   235: .endif
                    236:
1.74      mycroft   237: .if !target(proginstall)
                    238: proginstall::
                    239: .endif
                    240:
                    241: .if defined(SCRIPTS) && !target(scriptsinstall)
1.65      mycroft   242: SCRIPTSDIR?=${BINDIR}
                    243: SCRIPTSOWN?=${BINOWN}
                    244: SCRIPTSGRP?=${BINGRP}
                    245: SCRIPTSMODE?=${BINMODE}
1.113     mycroft   246:
                    247: scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.114     mycroft   248: .PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.113     mycroft   249:
1.115     mycroft   250: __scriptinstall: .USE
1.139     tv        251:        ${INSTALL_FILE} \
1.116     mycroft   252:            -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \
                    253:            -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \
                    254:            -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \
1.160     perry     255:            ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   256:
1.130     sommerfe  257: .for S in ${SCRIPTS:O:u}
1.172     lukem     258: .if ${MKUPDATE} == "no"
1.154     mycroft   259: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! ${S} __scriptinstall
                    260: .if !defined(BUILD) && !make(all) && !make(${S})
                    261: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! .MADE
                    262: .endif
                    263: .else
                    264: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: ${S} __scriptinstall
1.103     fredb     265: .if !defined(BUILD) && !make(all) && !make(${S})
1.113     mycroft   266: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE
1.63      christos  267: .endif
1.154     mycroft   268: .endif
1.63      christos  269: .endfor
1.14      mycroft   270: .endif
1.1       cgd       271:
1.74      mycroft   272: .if !target(scriptsinstall)
                    273: scriptsinstall::
1.1       cgd       274: .endif
                    275:
1.52      cgd       276: lint: ${LOBJS}
                    277: .if defined(LOBJS) && !empty(LOBJS)
1.90      cgd       278:        ${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD}
1.1       cgd       279: .endif
                    280:
1.138     tv        281: ##### Pull in related .mk logic
1.1       cgd       282: .include <bsd.man.mk>
1.50      jtc       283: .include <bsd.nls.mk>
1.66      christos  284: .include <bsd.files.mk>
1.63      christos  285: .include <bsd.inc.mk>
1.83      mycroft   286: .include <bsd.links.mk>
1.180     lukem     287: .include <bsd.sys.mk>
1.26      mycroft   288: .include <bsd.dep.mk>
1.88      mycroft   289:
1.138     tv        290: ${TARGETS}:    # ensure existence
1.166     lukem     291:
                    292: .endif # HOSTPROG

CVSweb <webmaster@jp.NetBSD.org>