diff --git a/src/share/mk/Makefile b/src/share/mk/Makefile new file mode 100644 index 0000000..4e3f81e --- /dev/null +++ b/src/share/mk/Makefile @@ -0,0 +1,20 @@ +NOOBJ= # defined + +.include + +.if ${MKSHARE} != "no" +FILES= ubix.README ubix.buildinstall.mk ubix.clang-analyze.mk ubix.clean.mk \ + ubix.dep.mk ubix.doc.mk ubix.endian.mk ubix.files.mk ubix.gcc.mk \ + ubix.host.mk ubix.hostlib.mk ubix.hostprog.mk ubix.inc.mk ubix.info.mk \ + ubix.init.mk ubix.ioconf.mk ubix.kernobj.mk ubix.kinc.mk ubix.klinks.mk \ + ubix.kmodule.mk ubix.lib.mk ubix.links.mk ubix.lua.mk \ + ubix.man.mk ubix.nls.mk \ + ubix.obj.mk ubix.own.mk ubix.prog.mk ubix.rpc.mk ubix.shlib.mk \ + ubix.subdir.mk ubix.sys.mk ubix.syscall.mk ubix.test.mk ubix.x11.mk sys.mk + +FILESDIR=/usr/share/mk +.endif + +FILESMODE=444 + +.include diff --git a/src/share/mk/sys.mk b/src/share/mk/sys.mk new file mode 100644 index 0000000..d412938 --- /dev/null +++ b/src/share/mk/sys.mk @@ -0,0 +1,264 @@ +# This variable should be used to differentiate Minix builds in Makefiles. +__MINIX= yes + +.if !defined(__MINIX) +unix?= We run NetBSD. + +.SUFFIXES: .a .o .ln .s .S .c .cc .cpp .cxx .C .f .F .r .p .l .y .sh +.else +unix?= We run MINIX. + +.SUFFIXES: .a .o .bc .ln .s .S .c .cc .cpp .cxx .C .f .F .r .p .l .y .sh + +.if ${MKSMALL:U} == "yes" +CPPFLAGS+= -DNDEBUG +DBG= -Os +.endif + +.if ${MKMAGIC:Uno} == "yes" || ${MKASR:Uno} == "yes" +CPPFLAGS+= -D_MINIX_MAGIC=1 +STRIPFLAG= -s +DBG=-g +.endif + +#LSC: Be a bit smarter about the default compiler +.if exists(/usr/pkg/bin/cc) || exists(/usr/bin/cc) +CC?= cc +.endif + +.if exists(/usr/pkg/bin/gcc) || exists(/usr/bin/gcc) +CC?= gcc +.endif +.endif # defined(__MINIX) + +.LIBS: .a + +AR?= ar +ARFLAGS?= rl +RANLIB?= ranlib + +AS?= as +AFLAGS?= +COMPILE.s?= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} -c +LINK.s?= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${LDFLAGS} +_ASM_TRADITIONAL_CPP= -x assembler-with-cpp +COMPILE.S?= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} ${_ASM_TRADITIONAL_CPP} -c +LINK.S?= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} ${LDFLAGS} + +CC?= cc +.if ${MACHINE_ARCH} == "sh3el" || ${MACHINE_ARCH} == "sh3eb" +# -O2 is too -falign-* zealous for low-memory sh3 machines +DBG?= -Os -freorder-blocks +.elif ${MACHINE_ARCH} == "m68k" || ${MACHINE_ARCH} == "m68000" +# -freorder-blocks (enabled by -O2) produces much bigger code +DBG?= -O2 -fno-reorder-blocks +.elif ${MACHINE_ARCH} == "coldfire" +DBG?= -O1 +.elif !empty(MACHINE_ARCH:Maarch64*) +DBG?= -O2 ${"${.TARGET:M*.po}" == "":? -fomit-frame-pointer:} +.elif ${MACHINE_ARCH} == "vax" +DBG?= -O1 -fgcse -fstrength-reduce -fgcse-after-reload +.else +DBG?= -O2 +.endif +.if !defined(__MINIX) +CFLAGS?= ${DBG} +.else +CFLAGS+= ${DBG} +.endif # !defined(__MINIX) +LDFLAGS?= +COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c +LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} + +# C Type Format data is required for DTrace +CTFFLAGS ?= -g -L VERSION +CTFMFLAGS ?= -t -g -L VERSION + +CXX?= c++ +CXXFLAGS?= ${CFLAGS:N-Wno-traditional:N-Wstrict-prototypes:N-Wmissing-prototypes:N-Wno-pointer-sign:N-ffreestanding:N-std=gnu[0-9][0-9]:N-Wold-style-definition:N-Wno-format-zero-length} + +__ALLSRC1= ${empty(DESTDIR):?${.ALLSRC}:${.ALLSRC:S|^${DESTDIR}|^destdir|}} +__ALLSRC2= ${empty(MAKEOBJDIR):?${__ALLSRC1}:${__ALLSRC1:S|^${MAKEOBJDIR}|^obj|}} +__ALLSRC3= ${empty(NETBSDSRCDIR):?${__ALLSRC2}:${__ALLSRC2:S|^${NETBSDSRCDIR}|^src|}} +__BUILDSEED= ${BUILDSEED}/${__ALLSRC3:O}/${.TARGET} +_CXXSEED?= ${BUILDSEED:D-frandom-seed=${__BUILDSEED:hash}} + +COMPILE.cc?= ${CXX} ${_CXXSEED} ${CXXFLAGS} ${CPPFLAGS} -c +LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} + +OBJC?= ${CC} +OBJCFLAGS?= ${CFLAGS} +COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c +LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CPP?= cpp +CPPFLAGS?= + +FC?= f77 +FFLAGS?= -O +RFLAGS?= +COMPILE.f?= ${FC} ${FFLAGS} -c +LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS} +COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c +LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c +LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} + +INSTALL?= install + +LD?= ld + +LEX?= lex +LFLAGS?= +LEX.l?= ${LEX} ${LFLAGS} + +LINT?= lint +LINTFLAGS?= -chapbxzgFS + +LORDER?= lorder + +MAKE?= make + +NM?= nm + +PC?= pc +PFLAGS?= +COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c +LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} + +SHELL?= sh + +SIZE?= size + +TSORT?= tsort -q + +YACC?= yacc +YFLAGS?= +YACC.y?= ${YACC} ${YFLAGS} + +# C +.c: + ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +# XXX: disable for now +# ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:} +.c.o: + ${COMPILE.c} ${.IMPSRC} + ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:} +.c.a: + ${COMPILE.c} ${.IMPSRC} + ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o + rm -f ${.PREFIX}.o +.c.ln: + ${LINT} ${LINTFLAGS} \ + ${CPPFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ + -i ${.IMPSRC} + +# C++ +.cc .cpp .cxx .C: + ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.cc.o .cpp.o .cxx.o .C.o: + ${COMPILE.cc} ${.IMPSRC} +.cc.a .cpp.a .cxx.a .C.a: + ${COMPILE.cc} ${.IMPSRC} + ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o + rm -f ${.PREFIX}.o + +# Fortran/Ratfor +.f: + ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.f.o: + ${COMPILE.f} ${.IMPSRC} + ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:} +.f.a: + ${COMPILE.f} ${.IMPSRC} + ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o + rm -f ${.PREFIX}.o + +.F: + ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} + ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:} +.F.o: + ${COMPILE.F} ${.IMPSRC} + ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:} +.F.a: + ${COMPILE.F} ${.IMPSRC} + ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o + rm -f ${.PREFIX}.o + +.r: + ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.r.o: + ${COMPILE.r} ${.IMPSRC} + ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:} +.r.a: + ${COMPILE.r} ${.IMPSRC} + ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o + rm -f ${.PREFIX}.o + +# Pascal +.p: + ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} + ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:} +.p.o: + ${COMPILE.p} ${.IMPSRC} + ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:} +.p.a: + ${COMPILE.p} ${.IMPSRC} + ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o + rm -f ${.PREFIX}.o + +# Assembly +.s: + ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} + ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:} +.s.o: + ${COMPILE.s} ${.IMPSRC} + ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:} +.s.a: + ${COMPILE.s} ${.IMPSRC} + ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o + rm -f ${.PREFIX}.o +.S: + ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} + ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:} +.S.o: + ${COMPILE.S} ${.IMPSRC} + ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:} +.S.a: + ${COMPILE.S} ${.IMPSRC} + ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o + rm -f ${.PREFIX}.o + +# Lex +.l: + ${LEX.l} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll + rm -f lex.yy.c +.l.c: + ${LEX.l} ${.IMPSRC} + mv lex.yy.c ${.TARGET} +.l.o: + ${LEX.l} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} lex.yy.c + ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:} + rm -f lex.yy.c + +# Yacc +.y: + ${YACC.y} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS} + rm -f y.tab.c +.y.c: + ${YACC.y} ${.IMPSRC} + mv y.tab.c ${.TARGET} +.y.o: + ${YACC.y} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} y.tab.c + ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:} + rm -f y.tab.c + +# Shell +.sh: + rm -f ${.TARGET} + cp ${.IMPSRC} ${.TARGET} + chmod a+x ${.TARGET} diff --git a/src/share/mk/ubix.clang-analyze.mk b/src/share/mk/ubix.clang-analyze.mk new file mode 100644 index 0000000..81912be --- /dev/null +++ b/src/share/mk/ubix.clang-analyze.mk @@ -0,0 +1,40 @@ +# $NetBSD: bsd.clang-analyze.mk,v 1.3 2012/04/04 10:37:18 joerg Exp $ + +.ifndef CLANG_ANALYZE_SRCS + +CLANG_ANALYZE_FLAGS+= --analyze + +CLANG_ANALYZE_CHECKERS+= core deadcode security unix + +.for checker in ${CLANG_ANALYZE_CHECKERS} +CLANG_ANALYZE_FLAGS+= -Xanalyzer -analyzer-checker=${checker} +.endfor + +.SUFFIXES: .c .cc .cpp .cxx .C .clang-analyzer + +CLANG_ANALYZE_CFLAGS= ${CFLAGS:N-Wa,--fatal-warnings} +CLANG_ANALYZE_CXXFLAGS= ${CXXFLAGS:N-Wa,--fatal-warnings} + +.c.clang-analyzer: + ${TOOL_CC.clang} ${CLANG_ANALYZE_FLAGS} \ + ${CLANG_ANALYZE_CFLAGS} ${CPPFLAGS} \ + ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \ + ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} +.cc.clang-analyzer .cpp.clang-analyzer .cxx.clang-analyzer .C.clang-analyzer: + ${TOOL_CXX.clang} ${CLANG_ANALYZE_FLAGS} \ + ${CLANG_ANALYZE_CXXFLAGS} ${CPPFLAGS} \ + ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \ + ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} + +CLANG_ANALYZE_SRCS= \ + ${SRCS:M*.[cC]} ${SRCS:M*.cc} \ + ${SRCS:M*.cpp} ${SRCS:M*.cxx} \ + ${DPSRCS:M*.[cC]} ${DPSRCS:M*.cc} \ + ${DPSRCS:M*.cpp} ${DPSRCS:M*.cxx} +.if !empty(CLANG_ANALYZE_SRCS) +CLANG_ANALYZE_OUTPUT= ${CLANG_ANALYZE_SRCS:R:S,$,.clang-analyzer,} +.endif + +analyze: ${CLANG_ANALYZE_OUTPUT} + +.endif diff --git a/src/share/mk/ubix.clean.mk b/src/share/mk/ubix.clean.mk new file mode 100644 index 0000000..1102698 --- /dev/null +++ b/src/share/mk/ubix.clean.mk @@ -0,0 +1,91 @@ +# $NetBSD: ubix.clean.mk,v 1.8 2012/11/19 16:04:54 apb Exp $ + +# +# +# Public targets: +# +# clean: Delete files listed in ${CLEANFILES}. +# cleandir: Delete files listed in ${CLEANFILES} and ${CLEANDIRFILES}. +# +# Public variables: +# +# CLEANFILES Files to remove for both the clean and cleandir targets. +# +# CLEANDIRFILES Files to remove for the cleandir target, but not for +# the clean target. +# +# MKCLEANSRC Whether or not to clean the source directory +# in addition to the object directory. Defaults to "yes". +# +# MKCLEANVERIFY Whether or not to verify that the file deletion worked. +# Defaults to "yes". +# +# The files listed in CLEANFILES and CLEANDIRFILES must not be +# directories, because the potential risk from running "rm -rf" commands +# in ubix.clean.mk is considered too great. If you want to recursively +# delete a directory as part of "make clean" or "make cleandir" then you +# need to provide your own target. + +.if !defined(_BSD_CLEAN_MK_) +_BSD_CLEAN_MK_=1 + +.include + +MKCLEANSRC?= yes +MKCLEANVERIFY?= yes + +clean: .PHONY __doclean +__doclean: .PHONY .MADE __cleanuse CLEANFILES +cleandir: .PHONY clean __docleandir +__docleandir: .PHONY .MADE __cleanuse CLEANDIRFILES + +# __cleanuse is invoked with ${.ALLSRC} as the name of a variable +# (such as CLEANFILES or CLEANDIRFILES), or possibly a list of +# variable names. ${.ALLSRC:@v@${${v}}@} will be the list of +# files to delete. (We pass the variable name, e.g. CLEANFILES, +# instead of the file names, e.g. ${CLEANFILES}, because we don't +# want make to replace any of the file names with the result of +# searching .PATH.) +# +# If the list of files is empty, then the commands +# reduce to "true", with an "@" prefix to prevent echoing. +# +# The use of :M* is needed to handle the case that CLEANFILES +# or CLEANDIRFILES is not completely empty but contains spaces. +# This can easily happen when CLEANFILES or CLEANDIRFILES is set +# from other variables that happen to be empty.) +# +# The use of :Q is needed to handle the case that CLEANFILES +# or CLEANDIRFILES contains quoted strings, such as +# CLEANFILES = "filename with spaces". +# +__cleanuse: .USE +.if 0 # print "# clean CLEANFILES" for debugging + ${"${.ALLSRC:@v@${${v}:M*}@:Q}" == "":?@true:${_MKMSG} \ + "clean" ${.ALLSRC} } +.endif +.for _d in ${"${.OBJDIR}" == "${.CURDIR}" || "${MKCLEANSRC}" == "no" \ + :? ${.OBJDIR} \ + : ${.OBJDIR} ${.CURDIR} } + ${"${.ALLSRC:@v@${${v}:M*}@:Q}" == "":?@true: \ + (cd ${_d} && rm -f ${.ALLSRC:@v@${${v}}@} || true) } +.if "${MKCLEANVERIFY}" == "yes" + @${"${.ALLSRC:@v@${${v}:M*}@:Q}" == "":?true: \ + bad="\$(cd ${_d} && ls -1d ${.ALLSRC:@v@${${v}}@} 2>/dev/null)"; \ + if test -n "\$bad"; then \ + echo "Failed to remove the following files from ${_d}:" ; \ + echo "\$bad" | while read file ; do \ + echo " \$file" ; \ + done ; \ + false ; \ + fi } +.endif +.endfor + +# Don't automatically load ".depend" files during "make clean" +# or "make cleandir". +.if make(clean) || make(cleandir) +.MAKE.DEPENDFILE := .depend.no-such-file +.endif + +.endif # !defined(_BSD_CLEAN_MK) diff --git a/src/share/mk/ubix.dep.mk b/src/share/mk/ubix.dep.mk new file mode 100644 index 0000000..6c89f0b --- /dev/null +++ b/src/share/mk/ubix.dep.mk @@ -0,0 +1,126 @@ +##### Basic targets +realdepend: beforedepend .depend afterdepend +.ORDER: beforedepend .depend afterdepend + +beforedepend .depend afterdepend: # ensure existence + +##### Default values +MKDEP?= mkdep +MKDEPCXX?= mkdep +MKDEP_SUFFIXES?= .o .d + +##### Build rules +# some of the rules involve .h sources, so remove them from mkdep line + +.if defined(SRCS) && !empty(SRCS) +__acpp_flags= ${_ASM_TRADITIONAL_CPP} + +.if defined(NODPSRCS) +.for f in ${SRCS} ${DPSRCS} +.if "${NODPSRCS:M${f}}" == "" +__DPSRCS.all+= ${f:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} +.endif +.endfor +beforedepend: ${DPSRCS} +.else +__DPSRCS.all+= ${SRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} \ + ${DPSRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} +.endif +__DPSRCS.d= ${__DPSRCS.all:O:u:M*.d} +__DPSRCS.notd= ${__DPSRCS.all:O:u:N*.d} + +.if defined(__MINIX) +__DPSRCS.bcd= ${"${USE_BITCODE:Uno}" == "yes":? ${SRCS:M*.c:O:u:.c=.bcd}:} +__DPSRCS.d+= ${__DPSRCS.bcd} +.endif # defined(__MINIX) + +.NOPATH: .depend ${__DPSRCS.d} + +.if !empty(__DPSRCS.d) # { +${__DPSRCS.d}: ${__DPSRCS.notd} ${DPSRCS} +.endif # } + +MKDEPSUFFLAGS=-s ${MKDEP_SUFFIXES:Q} + +.if defined(MKDEPINCLUDES) && ${MKDEPINCLUDES} != "no" +.STALE: + @echo Rebuilding dependency file: ${.ALLSRC} + @rm -f ${.ALLSRC} + @(cd ${.CURDIR} && ${MAKE} depend) +_MKDEP_MERGEFLAGS=-i +_MKDEP_FILEFLAGS=${MKDEPSUFFLAGS} +.else +_MKDEP_MERGEFLAGS=${MKDEPSUFFLAGS} +_MKDEP_FILEFLAGS= +.endif + +.depend: ${__DPSRCS.d} + ${_MKTARGET_CREATE} + rm -f .depend + ${MKDEP} ${_MKDEP_MERGEFLAGS} -d -f ${.TARGET} ${__DPSRCS.d} + +.if !defined(__MINIX) +.SUFFIXES: .d .s .S .c .C .cc .cpp .cxx .m +.else +.SUFFIXES: .bcd .d .s .S .c .C .cc .cpp .cxx .m + +.if ${USE_BITCODE:Uno} == "yes" +.c.bcd: + ${_MKTARGET_CREATE} + ${MKDEP} -f ${.TARGET} -s .bc -- ${MKDEPFLAGS} \ + ${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ + ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} +.endif # ${USE_BITCODE:Uno} == "yes" +.endif # !defined(__MINIX) + +.c.d: + ${_MKTARGET_CREATE} + ${MKDEP} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ + ${CFLAGS:M-std=*} ${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ + ${CPPFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \ + ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} && \ + mv ${.TARGET}.tmp ${.TARGET} + +.m.d: + ${_MKTARGET_CREATE} + ${MKDEP} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ + ${OBJCFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ + ${CPPFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \ + ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} && \ + mv ${.TARGET}.tmp ${.TARGET} + +.s.d .S.d: + ${_MKTARGET_CREATE} + ${MKDEP} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ + ${AFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ + ${CPPFLAGS} ${AFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} \ + ${__acpp_flags} ${.IMPSRC} && \ + mv ${.TARGET}.tmp ${.TARGET} + +.C.d .cc.d .cpp.d .cxx.d: + ${_MKTARGET_CREATE} + ${MKDEPCXX} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ + ${CXXFLAGS:M-std=*} ${CXXFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ + ${CPPFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \ + ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} && \ + mv ${.TARGET}.tmp ${.TARGET} + +.endif # defined(SRCS) && !empty(SRCS) # } + +##### Clean rules +.if defined(SRCS) && !empty(SRCS) +CLEANDIRFILES+= .depend ${__DPSRCS.d} ${__DPSRCS.d:.d=.d.tmp} ${.CURDIR}/tags ${CLEANDEPEND} +.endif + +##### Custom rules +.if !target(tags) +tags: ${SRCS} +.if defined(SRCS) && !empty(SRCS) + ${_MKTARGET_CREATE} + -cd "${.CURDIR}"; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \ + ${TOOL_SED} "s;\${.CURDIR}/;;" > tags +.endif +.endif + +##### Pull in related .mk logic +.include diff --git a/src/share/mk/ubix.files.mk b/src/share/mk/ubix.files.mk new file mode 100644 index 0000000..651fdeb --- /dev/null +++ b/src/share/mk/ubix.files.mk @@ -0,0 +1,162 @@ +# $NetBSD: ubix.files.mk,v 1.43 2013/04/06 15:39:19 uebayasi Exp $ + +.if !defined(_BSD_FILES_MK_) +_BSD_FILES_MK_=1 + +.include + +.if !target(__fileinstall) +##### Basic targets +realinstall: filesinstall +realall: filesbuild + +##### Default values +FILESDIR?= ${BINDIR} +FILESOWN?= ${BINOWN} +FILESGRP?= ${BINGRP} +FILESMODE?= ${NONBINMODE} + +##### Build rules +filesbuild: +.PHONY: filesbuild + +##### Install rules +filesinstall:: # ensure existence +.PHONY: filesinstall + +configfilesinstall:: .PHONY + +__fileinstall: .USE + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} \ + -o ${FILESOWN_${.ALLSRC:T}:U${FILESOWN}} \ + -g ${FILESGRP_${.ALLSRC:T}:U${FILESGRP}} \ + -m ${FILESMODE_${.ALLSRC:T}:U${FILESMODE}} \ + ${SYSPKGTAG} ${.ALLSRC} ${.TARGET} + +.endif # !target(__fileinstall) + + +.for F in ${FILES:O:u} +_FDIR:= ${FILESDIR_${F}:U${FILESDIR}} # dir override +_FNAME:= ${FILESNAME_${F}:U${FILESNAME:U${F:T}}} # name override +_F:= ${DESTDIR}${_FDIR}/${_FNAME} # installed path +_FDOBUILD:= ${FILESBUILD_${F}:U${FILESBUILD:Uno}} + +.if ${MKUPDATE} == "no" +${_F}! ${F} __fileinstall # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no") +${_F}! .MADE # no build at install +.endif +.else +${_F}: ${F} __fileinstall # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no") +${_F}: .MADE # no build at install +.endif +.endif + +.if ${_FDOBUILD} != "no" +filesbuild: ${F} +CLEANFILES+= ${F} +.endif + +filesinstall:: ${_F} +.PRECIOUS: ${_F} # keep if install fails +.endfor + + +# +# CONFIGFILES +# +configinstall: configfilesinstall + +.for F in ${CONFIGFILES:O:u} +_FDIR:= ${FILESDIR_${F}:U${FILESDIR}} # dir override +_FNAME:= ${FILESNAME_${F}:U${FILESNAME:U${F:T}}} # name override +_F:= ${DESTDIR}${_FDIR}/${_FNAME} # installed path +_FDOBUILD:= ${FILESBUILD_${F}:U${FILESBUILD:Uno}} + +.if ${MKUPDATE} == "no" +${_F}! ${F} __fileinstall # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no") +${_F}! .MADE # no build at install +.endif +.else +${_F}: ${F} __fileinstall # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no") +${_F}: .MADE # no build at install +.endif +.endif + +.if ${_FDOBUILD} != "no" +filesbuild: ${F} +CLEANFILES+= ${F} +.endif + +configfilesinstall:: ${_F} +.PRECIOUS: ${_F} # keep if install fails +.endfor + +.undef _FDIR +.undef _FNAME +.undef _F + + +# +# BUILDSYMLINKS +# +.if defined(BUILDSYMLINKS) # { + +.for _SL _TL in ${BUILDSYMLINKS} +BUILDSYMLINKS.s+= ${_SL} +BUILDSYMLINKS.t+= ${_TL} +${_TL}: ${_SL} + ${_MKMSG} "symlink " ${.CURDIR:T}/${.TARGET} + rm -f ${.TARGET} + ln -s ${.ALLSRC} ${.TARGET} +.endfor + +realall: ${BUILDSYMLINKS.t} + +CLEANDIRFILES+= ${BUILDSYMLINKS.t} + +.endif # } + +# +# .uue -> "" handling (i.e. decode a given binary/object) +# +# UUDECODE_FILES - List of files which are stored in the source tree +# as .uue and should be uudecoded. +# +# UUDECODE_FILES_RENAME_fn - For this file, rename its output to the provided +# name (handled via -p and redirecting stdout) + +.if defined(UUDECODE_FILES) # { +.SUFFIXES: .uue + +.uue: + ${_MKTARGET_CREATE} + rm -f ${.TARGET} + ${TOOL_UUDECODE} -p ${.IMPSRC} > ${.TARGET} + +.if defined(UUDECODE_FILES_RENAME_${UUDECODE_FILES}) +${UUDECODE_FILES_RENAME_${UUDECODE_FILES}}: ${UUDECODE_FILES} + cp ${.ALLSRC} ${.TARGET} +.endif + +realall: ${UUDECODE_FILES} + +CLEANUUDECODE_FILES=${UUDECODE_FILES} +.for i in ${UUDECODE_FILES} +CLEANUUDECODE_FILES+=${UUDECODE_FILES_RENAME_${i}} +.endfor + +CLEANFILES+= ${CLEANUUDECODE_FILES} +.endif # } + +##### Pull in related .mk logic +.include +.include +.include + +.endif # !defined(_BSD_FILES_MK_) diff --git a/src/share/mk/ubix.gcc.mk b/src/share/mk/ubix.gcc.mk new file mode 100644 index 0000000..c315615 --- /dev/null +++ b/src/share/mk/ubix.gcc.mk @@ -0,0 +1,34 @@ +# $NetBSD: ubix.gcc.mk,v 1.11 2015/06/07 15:04:28 matt Exp $ + +.if !defined(_BSD_GCC_MK_) +_BSD_GCC_MK_=1 + +.if defined(EXTERNAL_TOOLCHAIN) +_GCC_CRTBEGIN!= ${CC} --print-file-name=crtbegin.o +.ifndef _GCC_CRTBEGINS +_GCC_CRTBEGINS!= ${CC} --print-file-name=crtbeginS.o +.endif +_GCC_CRTEND!= ${CC} --print-file-name=crtend.o +.ifndef _GCC_CRTENDS +_GCC_CRTENDS!= ${CC} --print-file-name=crtendS.o +.endif +.ifndef _GCC_CRTI +_GCC_CRTI!= ${CC} --print-file-name=crti.o +.endif +.ifndef _GCC_CRTN +_GCC_CRTN!= ${CC} --print-file-name=crtn.o +.endif +_GCC_CRTDIR!= dirname ${_GCC_CRTBEGIN} +_GCC_LIBGCCDIR!= dirname `${CC} --print-libgcc-file-name` +.else +_GCC_CRTBEGIN?= ${DESTDIR}/usr/lib/${MLIBDIR:D${MLIBDIR}/}crtbegin.o +_GCC_CRTBEGINS?= ${DESTDIR}/usr/lib/${MLIBDIR:D${MLIBDIR}/}crtbeginS.o +_GCC_CRTEND?= ${DESTDIR}/usr/lib/${MLIBDIR:D${MLIBDIR}/}crtend.o +_GCC_CRTENDS?= ${DESTDIR}/usr/lib/${MLIBDIR:D${MLIBDIR}/}crtendS.o +_GCC_CRTI?= ${DESTDIR}/usr/lib/${MLIBDIR:D${MLIBDIR}/}crti.o +_GCC_CRTN?= ${DESTDIR}/usr/lib/${MLIBDIR:D${MLIBDIR}/}crtn.o +_GCC_CRTDIR?= ${DESTDIR}/usr/lib${MLIBDIR:D/${MLIBDIR}} +_GCC_LIBGCCDIR?= ${DESTDIR}/usr/lib${MLIBDIR:D/${MLIBDIR}} +.endif + +.endif # ! defined(_BSD_GCC_MK_) diff --git a/src/share/mk/ubix.gcov.mk b/src/share/mk/ubix.gcov.mk new file mode 100644 index 0000000..42ae988 --- /dev/null +++ b/src/share/mk/ubix.gcov.mk @@ -0,0 +1,51 @@ +LCOV=lcov.$(PROG) +CLEANFILES+= *.gcno *.gcda $(LCOV) + +# Right now we support obtaining coverage information for system services only, +# and for their main program code (not including their libraries) only. +# +# Why not userland as well: because we do not care as much, and it should be +# possible to produce coverage information for system services without +# recompiling the entire system with coverage support. Moreover, as of writing +# we do not have libprofile_rt, making it impossible to compile regular +# programs with coverage support altogether. +# +# Why not system service libraries (eg libsys) as well: practical concerns.. +# 1) As of writing, even for such libraries we make a regular and a PIC +# version, both producing a .gcno file for each object. The PIC version is +# compiled last, while the regular version is used for the library archive. +# The result is a potential mismatch between the compile-time coverage +# metadata and the run-time coverage counts. +# 2) The kernel has no coverage support, and with its self-relocation it would +# be tricky to add support for it. As a result, libraries used by the +# kernel would have to be excluded from being compiled with coverage support +# so as not to create problems. One could argue that that is a good thing +# because eg libminc and libsys create too many small result units (see also +# the current hardcoded limit in libsys/llvm_gcov.c). +# 3) gcov-pull(8) strips paths, which results in lots of manual work to figure +# out what file belongs to which library, even ignoring object name +# conflicts, for example between libraries. +# 4) In order to produce practically useful results ("how much of libsockevent +# is covered by the combination of LWIP and UDS" etc), gcov-pull(8) would +# have to be extended with support for merging .gcda files. The standard +# LLVM libprofile_rt implementation supports this, but we do not. +# All of these issues are solvable, but for now anyone interested in coverage +# for a particular system service library will have to mess with individual +# makefiles themselves. + +.if ${MKCOVERAGE:Uno} == "yes" +.if ${ACTIVE_CC} == "gcc" +# Leftovers for GCC. It is not clear whether these still work at all. +COVCPPFLAGS?= -fno-builtin -fprofile-arcs -ftest-coverage +COVLDADD?= -lgcov +.else # ${ACTIVE_CC} != "gcc" +# We assume LLVM/clang here. For other compilers this will likely break the +# MKCOVERAGE compilation, which is a good indication that support for them +# should be added here. +COVCPPFLAGS?= --coverage -g -O0 +COVLDADD?= +.endif # ${ACTIVE_CC} != "gcc" +.endif # ${MKCOVERAGE:Uno} == "yes" + +lcov: + lcov -c -d . >$(LCOV) diff --git a/src/share/mk/ubix.host.mk b/src/share/mk/ubix.host.mk new file mode 100644 index 0000000..f6cacb4 --- /dev/null +++ b/src/share/mk/ubix.host.mk @@ -0,0 +1,74 @@ +.if !defined(_UBIX_HOST_MK_) +_UBIX_HOST_MK_=1 + +.if ${HOST_OSTYPE:C/\-.*//:U} == "Minix" +HOST_LDFLAGS?= -static + +#LSC: Be a bit smarter about the default compiler +.if exists(/usr/pkg/bin/clang) || exists(/usr/bin/clang) +HOST_CC?= clang +.endif + +.if exists(/usr/pkg/bin/gcc) || exists(/usr/bin/gcc) +HOST_CC?= gcc +.endif +.endif # ${HOST_OSTYPE:C/\-.*//:U} == "Minix" + +# Helpers for cross-compiling +HOST_CC?= cc +HOST_CFLAGS?= -O +HOST_COMPILE.c?=${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} -c +HOST_COMPILE.cc?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} -c +HOST_LINK.cc?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS} +.if defined(HOSTPROG_CXX) +HOST_LINK.c?= ${HOST_LINK.cc} +.else +HOST_LINK.c?= ${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS} +.endif + +HOST_CXX?= c++ +HOST_CXXFLAGS?= -O + +HOST_CPP?= cpp +HOST_CPPFLAGS?= + +HOST_LD?= ld +HOST_LDFLAGS?= + +HOST_AR?= ar +HOST_RANLIB?= ranlib + +HOST_LN?= ln + +# HOST_SH must be an absolute path +HOST_SH?= /bin/sh + +.if !defined(HOST_OSTYPE) +_HOST_OSNAME!= uname -s +_HOST_OSREL!= uname -r +# For _HOST_ARCH, if uname -p fails, or prints "unknown", or prints +# something that does not look like an identifier, then use uname -m. +_HOST_ARCH!= uname -p 2>/dev/null +_HOST_ARCH:= ${HOST_ARCH:tW:C/.*[^-_A-Za-z0-9].*//:S/unknown//} +.if empty(_HOST_ARCH) +_HOST_ARCH!= uname -m +.endif +HOST_OSTYPE:= ${_HOST_OSNAME}-${_HOST_OSREL:C/\([^\)]*\)//g:[*]:C/ /_/g}-${_HOST_ARCH:C/\([^\)]*\)//g:[*]:C/ /_/g} +.MAKEOVERRIDES+= HOST_OSTYPE +.endif # !defined(HOST_OSTYPE) + +.if ${USETOOLS} == "yes" +HOST_MKDEP?= ${TOOLDIR}/bin/${_TOOL_PREFIX}host-mkdep +HOST_MKDEPCXX?= ${TOOLDIR}/bin/${_TOOL_PREFIX}host-mkdep +.else +HOST_MKDEP?= CC=${HOST_CC:Q} mkdep +HOST_MKDEPCXX?= CC=${HOST_CXX:Q} mkdep +.endif + +.if ${NEED_OWN_INSTALL_TARGET} != "no" +HOST_INSTALL_FILE?= ${INSTALL} ${COPY} ${PRESERVE} ${RENAME} +HOST_INSTALL_DIR?= ${INSTALL} -d +HOST_INSTALL_SYMLINK?= ${INSTALL} ${SYMLINK} ${RENAME} +.endif + +.endif diff --git a/src/share/mk/ubix.inc.mk b/src/share/mk/ubix.inc.mk new file mode 100644 index 0000000..c0b4238 --- /dev/null +++ b/src/share/mk/ubix.inc.mk @@ -0,0 +1,57 @@ +# $NetBSD: ubix.inc.mk,v 1.32 2006/03/16 18:43:34 jwise Exp $ + +.include + +##### Basic targets +includes: ${INCS} incinstall inclinkinstall + +##### Default values +INCSYMLINKS?= + +##### Install rules +incinstall:: # ensure existence +.PHONY: incinstall + +# -c is forced on here, in order to preserve modtimes for "make depend" +__incinstall: .USE + @cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \ + (${_MKSHMSG_INSTALL} ${.TARGET}; \ + ${_MKSHECHO} "${INSTALL_FILE} -c -o ${BINOWN} -g ${BINGRP} \ + -m ${NONBINMODE} ${.ALLSRC} ${.TARGET}" && \ + ${INSTALL_FILE} -c -o ${BINOWN} -g ${BINGRP} \ + -m ${NONBINMODE} ${.ALLSRC} ${.TARGET}) + +.for F in ${INCS:O:u} +_FDIR:= ${INCSDIR_${F:C,/,_,g}:U${INCSDIR}} # dir override +_FNAME:= ${INCSNAME_${F:C,/,_,g}:U${INCSNAME:U${F}}} # name override +_F:= ${DESTDIR}${_FDIR}/${_FNAME} # installed path + +.if ${MKUPDATE} == "no" +${_F}! ${F} __incinstall # install rule +.else +${_F}: ${F} __incinstall # install rule +.endif + +incinstall:: ${_F} +.PRECIOUS: ${_F} # keep if install fails +.endfor + +.undef _FDIR +.undef _FNAME +.undef _F + +inclinkinstall: .PHONY +.if !empty(INCSYMLINKS) + @(set ${INCSYMLINKS}; \ + while test $$# -ge 2; do \ + l=$$1; shift; \ + t=${DESTDIR}$$1; shift; \ + if ttarg=`${TOOL_STAT} -qf '%Y' $$t` && \ + [ "$$l" = "$$ttarg" ]; then \ + continue ; \ + fi ; \ + ${_MKSHMSG_INSTALL} $$t; \ + ${_MKSHECHO} ${INSTALL_SYMLINK} $$l $$t; \ + ${INSTALL_SYMLINK} $$l $$t; \ + done; ) +.endif diff --git a/src/share/mk/ubix.init.mk b/src/share/mk/ubix.init.mk new file mode 100644 index 0000000..f14f497 --- /dev/null +++ b/src/share/mk/ubix.init.mk @@ -0,0 +1,9 @@ +.if !defined(_UBIX_INIT_MK_) +_UBIX_INIT_MK_=1 + +.-include "${.CURDIR}/../Makefile.inc" +.include +.MAIN: all + +.endif # !defined(_UBIX_INIT_MK_) + diff --git a/src/share/mk/ubix.kernobj.mk b/src/share/mk/ubix.kernobj.mk new file mode 100644 index 0000000..ba3c9ed --- /dev/null +++ b/src/share/mk/ubix.kernobj.mk @@ -0,0 +1,33 @@ +# $NetBSD: bsd.kernobj.mk,v 1.14 2013/06/03 07:39:07 mrg Exp $ + +# KERNSRCDIR Is the location of the top of the kernel src. +# It defaults to `${NETBSDSRCDIR}/sys'. +# +# KERNARCHDIR Is the location of the machine dependent kernel sources. +# It defaults to `arch/${MACHINE}', but may be overridden +# in case ${MACHINE} is not correct. +# +# KERNCONFDIRDEFAULT Is the default for ${KERNCONFDIR}. +# It defaults to `${KERNSRCDIR}/${KERNARCHDIR}/conf'. +# +# KERNCONFDIR Is where the configuration files for kernels are found. +# Users can set this to have build.sh find kernel +# configurations in another directory. +# It defaults to `${KERNCONFDIRDEFAULT}'. +# +# KERNOBJDIR Is the kernel build directory. The kernel GENERIC for +# instance will be compiled in ${KERNOBJDIR}/GENERIC. +# The default is the .OBJDIR of +# `${KERNSRCDIR}/${KERNARCHDIR}/compile'. +# + +.include + +KERNSRCDIR?= ${NETBSDSRCDIR}/sys +KERNARCHDIR?= arch/${MACHINE} +KERNCONFDIRDEFAULT?= ${KERNSRCDIR}/${KERNARCHDIR}/conf +KERNCONFDIR?= ${KERNCONFDIRDEFAULT} + +.if !defined(KERNOBJDIR) && exists(${KERNSRCDIR}/${KERNARCHDIR}/compile) +KERNOBJDIR!= cd "${KERNSRCDIR}/${KERNARCHDIR}/compile" && ${PRINTOBJDIR} +.endif diff --git a/src/share/mk/ubix.lib.mk b/src/share/mk/ubix.lib.mk new file mode 100644 index 0000000..73867e3 --- /dev/null +++ b/src/share/mk/ubix.lib.mk @@ -0,0 +1,968 @@ +# $NetBSD: bsd.lib.mk,v 1.362 2015/09/08 16:06:42 uebayasi Exp $ +# @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 + +.include +.include +.include +# Pull in here so we can override its .c.o rule +.include + +LIBISMODULE?= no +LIBISPRIVATE?= no +LIBISCXX?= no + +.if ${LIBISMODULE} != "no" +_LIB_PREFIX?= # empty +MKDEBUGLIB:= no +MKLINT:= no +MKPICINSTALL:= no +MKPROFILE:= no +MKSTATICLIB:= no +.else +_LIB_PREFIX?= lib +.endif + +.if ${LIBISPRIVATE} != "no" +MKDEBUGLIB:= no +MKLINT:= no +MKPICINSTALL:= no +. if defined(NOSTATICLIB) && ${MKPICLIB} != "no" +MKSTATICLIB:= no +. else +MKPIC:= no +. endif +MKPROFILE:= no +.endif + +##### Basic targets +.PHONY: checkver libinstall +realinstall: checkver libinstall + +##### LIB specific flags. +# XXX: This is needed for programs that link with .a libraries +# Perhaps a more correct solution is to always generate _pic.a +# files or always have a shared library. +.if defined(MKPIE) && (${MKPIE} != "no") +CFLAGS+= ${PIE_CFLAGS} +AFLAGS+= ${PIE_AFLAGS} +.endif + +##### Libraries that this may depend upon. +.if defined(LIBDPLIBS) && ${MKPIC} != "no" # { +.for _lib _dir in ${LIBDPLIBS} +.if !defined(LIBDO.${_lib}) +LIBDO.${_lib}!= cd "${_dir}" && ${PRINTOBJDIR} +.MAKEOVERRIDES+=LIBDO.${_lib} +.endif +.if ${LIBDO.${_lib}} == "_external" +LDADD+= -l${_lib} +.else +LDADD+= -L${LIBDO.${_lib}} -l${_lib} +DPADD+= ${LIBDO.${_lib}}/lib${_lib}.so # Don't use _LIB_PREFIX +.endif +.endfor +.endif # } + +##### Build and install rules +MKDEP_SUFFIXES?= .o .po .pico .go .ln .d + +.if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE}) # { +SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major +SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor +SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny + +DPADD+= ${SHLIB_VERSION_FILE} + +# Check for higher installed library versions. +.if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \ + exists(${NETBSDSRCDIR}/lib/checkver) +checkver: + @(cd "${.CURDIR}" && \ + HOST_SH=${HOST_SH:Q} AWK=${TOOL_AWK:Q} \ + ${HOST_SH} ${NETBSDSRCDIR}/lib/checkver -v ${SHLIB_VERSION_FILE} \ + -d ${_DEST.OBJ} ${LIB}) +.endif +.endif # } + +.if !target(checkver) +checkver: +.endif + +print-shlib-major: +.if defined(SHLIB_MAJOR) && ${MKPIC} != "no" + @echo ${SHLIB_MAJOR} +.else + @false +.endif + +print-shlib-minor: +.if defined(SHLIB_MINOR) && ${MKPIC} != "no" + @echo ${SHLIB_MINOR} +.else + @false +.endif + +print-shlib-teeny: +.if defined(SHLIB_TEENY) && ${MKPIC} != "no" + @echo ${SHLIB_TEENY} +.else + @false +.endif + +.if defined(SHLIB_MAJOR) && !empty(SHLIB_MAJOR) # { +.if defined(SHLIB_MINOR) && !empty(SHLIB_MINOR) +.if defined(SHLIB_TEENY) && !empty(SHLIB_TEENY) +SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY} +.else +SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR} +.endif +.else +SHLIB_FULLVERSION=${SHLIB_MAJOR} +.endif +.endif # } + +# add additional suffixes not exported. +# .po is used for profiling object files. +# .pico is used for PIC object files. +.SUFFIXES: .out .a .ln .pico .po .go .o .s .S .c .cc .cpp .cxx .C .m .F .f .r .y .l .cl .p .h +.SUFFIXES: .sh .m4 .m + + +# Set PICFLAGS to cc flags for producing position-independent code, +# if not already set. + +# Data-driven table using make variables to control how shared libraries +# are built for different platforms and object formats. +# SHLIB_MAJOR, SHLIB_MINOR, SHLIB_TEENY: Major, minor, and teeny version +# numbers of shared library +# SHLIB_SOVERSION: version number to be compiled into a shared library +# via -soname. Usualy ${SHLIB_MAJOR} on ELF. +# NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR} +# [.${SHLIB_TEENY}]] +# SHLIB_SHFLAGS: Flags to tell ${LD} to emit shared library. +# with ELF, also set shared-lib version for ld.so. +# SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors +# SHLIB_LDENDFILE: support .o file, call C++ file-level destructors + +PICFLAGS ?= -fPIC + +.if ${MKPICLIB} != "no" +CSHLIBFLAGS+= ${PICFLAGS} +.endif + +.if defined(CSHLIBFLAGS) && !empty(CSHLIBFLAGS) +MKSHLIBOBJS= yes +.else +MKSHLIBOBJS= no +.endif + +.if (defined(MKDEBUG) && (${MKDEBUG} != "no")) || \ + (defined(CFLAGS) && !empty(CFLAGS:M*-g*)) +# We only add -g to the shared library objects +# because we don't currently split .a archives. +CSHLIBFLAGS+= -g +.if ${LIBISPRIVATE} == "yes" +CFLAGS+= -g +.endif +.endif + +# Platform-independent linker flags for ELF shared libraries +SHLIB_SOVERSION= ${SHLIB_MAJOR} +SHLIB_SHFLAGS= -Wl,-soname,${_LIB}.so.${SHLIB_SOVERSION} +.if !defined(SHLIB_WARNTEXTREL) || ${SHLIB_WARNTEXTREL} != "no" +SHLIB_SHFLAGS+= -Wl,--warn-shared-textrel +.endif +.if !defined(SHLIB_MKMAP) || ${SHLIB_MKMAP} != "no" +SHLIB_SHFLAGS+= -Wl,-Map=${_LIB}.so.${SHLIB_SOVERSION}.map +.endif +CLEANFILES+= ${_LIB}.so.${SHLIB_SOVERSION}.map +SHLIB_LDSTARTFILE?= ${_GCC_CRTI} ${_GCC_CRTBEGINS} +SHLIB_LDENDFILE?= ${_GCC_CRTENDS} ${_GCC_CRTN} + +CFLAGS+= ${COPTS} +OBJCFLAGS+= ${OBJCOPTS} +AFLAGS+= ${COPTS} +FFLAGS+= ${FOPTS} + +.if defined(CTFCONVERT) +.if defined(CFLAGS) && !empty(CFLAGS:M*-g*) +CTFFLAGS+= -g +.if defined(HAVE_GCC) && ${HAVE_GCC} >= 48 +#CFLAGS+= -gdwarf-2 +.endif +.endif +.endif + +LIBSTRIPAOBJS= yes +.if !defined(CFLAGS) || empty(CFLAGS:M*-g*) +LIBSTRIPCOBJS= yes +.endif +.if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*) +LIBSTRIPOBJCOBJS= yes +.endif +.if !defined(FFLAGS) || empty(FFLAGS:M*-g*) +LIBSTRIPFOBJS= yes +.endif +.if !defined(CSHLIBFLAGS) || empty(CSHLIBFLAGS:M*-g*) +LIBSTRIPSHLIBOBJS= yes +.endif + +.if defined(__MINIX) && ${USE_BITCODE:Uno} == "yes" +SHLIB_SHFLAGS+= -L ${DESTDIR}/usr/lib +SHLIB_SHFLAGS+= -Wl,-plugin=${GOLD_PLUGIN} \ + -Wl,-plugin-opt=-disable-opt + +SECTIONIFYPASS?=${NETBSDSRCDIR}/minix/llvm/bin/sectionify.so +# dcvmoole: the following construction is a hack for libmagicrt. For reasons +# not entirely under our control, clang refuses to take .bc objects even when +# using the gold linker, saying that LLVM IR code cannot be linked. In order +# to sidestep this, libmagicrt uses the name "foo.bc.o" instead of "foo.bc" to +# link the its LLVM IR objects. As all libmagicrt modules use the sectionify +# pass below, and this step needs temporary files, we give the temporary files +# the .o suffix (while anything would do!), and allow the libmagicrt makefile +# to override the rename to the real file name to perform a copy instead. As +# a result, libmagicrt ends up with both the .bc and .bc.o objects, and it can +# pass the latter set to clang, bypassing clang's overly strict checks. +SECTIONIFYMV?=mv -f + +.S.bc: ${.TARGET:.bc=.o} + rm -f ${.TARGET} + ln ${.TARGET:.bc=.o} ${.TARGET} +.c.bc: + ${_MKTARGET_COMPILE} + ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} -flto + if [ -n '${SECTIONIFY.${.IMPSRC:T}:U${SECTIONIFY}}' ]; then \ + ${OPT} -load ${SECTIONIFYPASS} -sectionify ${SECTIONIFY.${.IMPSRC:T}:U${SECTIONIFY}} -o ${.TARGET}.o ${.TARGET} && ${SECTIONIFYMV} ${.TARGET}.o ${.TARGET}; \ + fi + +.cc.bc .cxx.bc .cpp.bc: + ${_MKTARGET_COMPILE} + ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} -flto +.endif # defined(__MINIX) && ${USE_BITCODE:Uno} == "yes" +.c.o: + ${_MKTARGET_COMPILE} + ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif +.if defined(LIBSTRIPCOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.c.po: + ${_MKTARGET_COMPILE} + ${COMPILE.c} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif +.if defined(LIBSTRIPCOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.c.go: + ${_MKTARGET_COMPILE} + ${COMPILE.c} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET} + +.c.pico: + ${_MKTARGET_COMPILE} + ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET} +.if defined(LIBSTRIPSHLIBOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.cc.o .cpp.o .cxx.o .C.o: + ${_MKTARGET_COMPILE} + ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +.if defined(LIBSTRIPCOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.cc.po .cpp.po .cxx.po .C.po: + ${_MKTARGET_COMPILE} + ${COMPILE.cc} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET} +.if defined(LIBSTRIPCOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.cc.go .cpp.go .cxx.go .C.go: + ${_MKTARGET_COMPILE} + ${COMPILE.cc} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET} + +.cc.pico .cpp.pico .cxx.pico .C.pico: + ${_MKTARGET_COMPILE} + ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET} +.if defined(LIBSTRIPSHLIBOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.f.o: + ${_MKTARGET_COMPILE} + ${COMPILE.f} ${.IMPSRC} -o ${.TARGET} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif +.if defined(LIBSTRIPFOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.f.po: + ${_MKTARGET_COMPILE} + ${COMPILE.f} ${PROFFLAGS} -pg ${.IMPSRC} -o ${.TARGET} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif +.if defined(LIBSTRIPFOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.f.go: + ${_MKTARGET_COMPILE} + ${COMPILE.f} ${DEBUGFLAGS} -g ${.IMPSRC} -o ${.TARGET} + +.f.pico: + ${_MKTARGET_COMPILE} + ${COMPILE.f} ${PICFLAGS} ${.IMPSRC} -o ${.TARGET} +.if defined(LIBSTRIPFOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.f.ln: + ${_MKTARGET_COMPILE} + @echo Skipping lint for Fortran libraries. + +.m.o: + ${_MKTARGET_COMPILE} + ${COMPILE.m} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif +.if defined(LIBSTRIPOBJCOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.m.po: + ${_MKTARGET_COMPILE} + ${COMPILE.m} ${PROFFLAGS} -pg ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif +.if defined(LIBSTRIPOBJCOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.m.go: + ${_MKTARGET_COMPILE} + ${COMPILE.m} ${DEBUGFLAGS} -g ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +.if defined(LIBSTRIPOBJCOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.m.pico: + ${_MKTARGET_COMPILE} + ${COMPILE.m} ${CSHLIBFLAGS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +.if defined(LIBSTRIPOBJCOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.s.o: + ${_MKTARGET_COMPILE} + ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif +.if defined(LIBSTRIPAOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.S.o: + ${_MKTARGET_COMPILE} + ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif +.if defined(LIBSTRIPAOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.s.po: + ${_MKTARGET_COMPILE} + ${COMPILE.s} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif +.if defined(LIBSTRIPAOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.S.po: + ${_MKTARGET_COMPILE} + ${COMPILE.S} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif +.if defined(LIBSTRIPAOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.s.go: + ${_MKTARGET_COMPILE} + ${COMPILE.s} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} + +.S.go: + ${_MKTARGET_COMPILE} + ${COMPILE.S} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} + +.s.pico: + ${_MKTARGET_COMPILE} + ${COMPILE.s} ${PICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +.if defined(LIBSTRIPAOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +.S.pico: + ${_MKTARGET_COMPILE} + ${COMPILE.S} ${PICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +.if defined(LIBSTRIPAOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +# Declare a few variables to make our life easier later. +_LIB:=${_LIB_PREFIX}${LIB} +_LIB.a:=${_LIB}.a +_LIB_p.a:=${_LIB}_p.a +_LIB_g.a:=${_LIB}_g.a +_LIB_pic.a:=${_LIB}_pic.a +_LIB.ln:=llib-l${LIB}.ln +.if defined(__MINIX) && ${USE_BITCODE:Uno} == "yes" +_LIB_bc.a:=${_LIB}_bc.a +.endif # defined(__MINIX) + +.if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION) +_LIB.so:=${_LIB}.so +_LIB.so.major:=${_LIB}.so.${SHLIB_MAJOR} +_LIB.so.full:=${_LIB}.so.${SHLIB_FULLVERSION} +_LIB.so.link:=${_LIB}.so.${SHLIB_FULLVERSION}.link +.if ${MKDEBUG} != "no" +_LIB.so.debug:=${_LIB.so.full}.debug +.endif +.endif + +_DEST.LIB:=${DESTDIR}${LIBDIR} +_DEST.OBJ:=${DESTDIR}${_LIBSODIR} +_DEST.LINT:=${DESTDIR}${LINTLIBDIR} +_DEST.DEBUG:=${DESTDIR}${DEBUGDIR}${LIBDIR} +_DEST.ODEBUG:=${DESTDIR}${DEBUGDIR}${_LIBSODIR} + +.if defined(LIB) # { +.if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \ + || ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no" +_LIBS=${_LIB.a} +.else +_LIBS= +.endif + +.if ${LIBISPRIVATE} != "no" \ + && (defined(USE_COMBINE) && ${USE_COMBINE} == "yes" \ + && !defined(NOCOMBINE)) # { +.for f in ${SRCS:N*.h:N*.sh:C/\.[yl]$/.c/g} +COMBINEFLAGS.${LIB}.$f := ${CPPFLAGS.$f:D1} ${CPUFLAGS.$f:D2} ${COPTS.$f:D3} ${OBJCOPTS.$f:D4} ${CXXFLAGS.$f:D5} +.if empty(COMBINEFLAGS.${LIB}.${f}) && !defined(NOCOMBINE.$f) +COMBINESRCS+= ${f} +NODPSRCS+= ${f} +.else +OBJS+= ${f:R:S/$/.o/} +.endif +.endfor + +.if !empty(COMBINESRCS) +OBJS+= ${_LIB}_combine.o +${_LIB}_combine.o: ${COMBINESRCS} + ${_MKTARGET_COMPILE} + ${COMPILE.c} -MD --combine ${.ALLSRC} -o ${.TARGET} +.if defined(LIBSTRIPOBJS) + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} +.endif + +CLEANFILES+= ${_LIB}_combine.d + +.if exists("${_LIB}_combine.d") +.include "${_LIB}_combine.d" +.endif +.endif # empty(XSRCS.${LIB}) +.else # } { +OBJS+=${SRCS:N*.h:N*.sh:R:S/$/.o/g} +.endif # } + +STOBJS+=${OBJS} + +LOBJS+=${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln} + +.if ${LIBISPRIVATE} != "no" +# No installation is required +libinstall:: +.endif + +.if ${MKDEBUGLIB} != "no" +_LIBS+=${_LIB_g.a} +GOBJS+=${OBJS:.o=.go} +DEBUGFLAGS?=-DDEBUG +.endif + +.if ${MKPROFILE} != "no" +_LIBS+=${_LIB_p.a} +POBJS+=${OBJS:.o=.po} +PROFFLAGS?=-DGPROF -DPROF +.endif + +.if ${MKPIC} != "no" # { +.if ${MKPICLIB} == "no" +.if ${MKSHLIBOBJS} != "no" +# make _pic.a, which isn't really pic, +# since it's needed for making shared lib. +# but don't install it. +SOLIB=${_LIB_pic.a} +SOBJS+=${OBJS:.o=.pico} +.else +SOLIB=${_LIB.a} +.endif +.else +SOLIB=${_LIB_pic.a} +_LIBS+=${SOLIB} +SOBJS+=${OBJS:.o=.pico} +.endif +.if defined(SHLIB_FULLVERSION) +_LIBS+=${_LIB.so.full} +.endif +.endif # } + +.if ${MKLINT} != "no" && !empty(LOBJS) +_LIBS+=${_LIB.ln} +.endif + +ALLOBJS= +.if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \ + || ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no" +ALLOBJS+=${STOBJS} +.endif +ALLOBJS+=${POBJS} ${SOBJS} +.if ${MKLINT} != "no" && !empty(LOBJS) +ALLOBJS+=${LOBJS} +.endif +.else # !defined(LIB) # } { +LOBJS= +SOBJS= +.endif # !defined(LIB) # } + +_YLSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}} + +.if ${USE_BITCODE:Uno} == "yes" +.if defined(LIB) +_LIBS+=${_LIB_bc.a} +.endif +.endif # ${USE_BITCODE:Uno} == "yes" + +.NOPATH: ${ALLOBJS} ${_LIBS} ${_YLSRCS} + +realall: ${SRCS} ${ALLOBJS:O} ${_LIBS} ${_LIB.so.debug} + +MKARZERO?= ${MKREPRO:Uno} + +.if ${MKARZERO} == "yes" +_ARFL=crsD +_ARRANFL=sD +_INSTRANLIB= +.else +_ARFL=crs +_ARRANFL=s +.if ${USE_BITCODE:Uno} == "yes" +_INSTRANLIB=${empty(PRESERVE):?-a "${AR} --plugin ${GOLD_PLUGIN} -s":} +.else +_INSTRANLIB=${empty(PRESERVE):?-a "${RANLIB} -t":} +.endif # ${USE_BITCODE:Uno} == "yes" +.endif + +# If you change this, please consider reflecting the change in +# the override in sys/rump/Makefile.rump. +.if !target(__archivebuild) +__archivebuild: .USE + ${_MKTARGET_BUILD} + rm -f ${.TARGET} + ${AR} ${_ARFL} ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}` +.endif + +.if !target(__archiveinstall) +__archiveinstall: .USE + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${_INSTRANLIB} ${.ALLSRC} ${.TARGET} +.endif + +__archivesymlinkpic: .USE + ${_MKTARGET_INSTALL} + ${INSTALL_SYMLINK} ${.ALLSRC} ${.TARGET} + +DPSRCS+= ${_YLSRCS} +CLEANFILES+= ${_YLSRCS} + +${STOBJS} ${POBJS} ${GOBJS} ${SOBJS} ${LOBJS}: ${DPSRCS} + +.if ${USE_BITCODE:Uno} == "yes" + +.if !target(__archivebuildbc) +__archivebuildbc: .USE + ${_MKTARGET_BUILD} + rm -f ${.TARGET} + ${AR} ${_ARFL} --plugin ${GOLD_PLUGIN} ${.TARGET} ${.ALLSRC:M*bc} +.endif + +# LSC: Ignore libunwind in the bitcode archive, otherwise final linking chokes +# on libunwind hidden assembly symbols. +BCOBJS+=${OBJS:Nlibunwind.*:.o=.bc} +ALLOBJS+=${BCOBJS} +${_LIB_bc.a}:: ${BCOBJS} __archivebuildbc + +.endif # ${USE_BITCODE:Uno} == "yes" + +${_LIB.a}:: ${STOBJS} __archivebuild + +${_LIB_p.a}:: ${POBJS} __archivebuild + +${_LIB_pic.a}:: ${SOBJS} __archivebuild + +${_LIB_g.a}:: ${GOBJS} __archivebuild + + +_LIBLDOPTS= +.if ${SHLIBDIR} != "/usr/lib" +_LIBLDOPTS+= -Wl,-rpath,${SHLIBDIR} \ + -L=${SHLIBDIR} +.elif ${SHLIBINSTALLDIR} != "/usr/lib" +_LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR} \ + -L=${SHLIBINSTALLDIR} +.endif + +# gcc -shared now adds -lc automatically. For libraries other than libc and +# libgcc* we add as a dependency the installed shared libc. For libc and +# libgcc* we avoid adding libc as a dependency by using -nostdlib. Note that +# -Xl,-nostdlib is not enough because we want to tell the compiler-driver not +# to add standard libraries, not the linker. +.if !defined(LIB) +.if !empty(LIBC_SO) +DPLIBC ?= ${DESTDIR}${LIBC_SO} +.endif +.else +.if ${LIB} != "c" && ${LIB:Mgcc*} == "" \ + && ${LIB} != "sys" && ${LIB} != "minc" && ${LIB} != "mthread" # Minix-specific libs +.if !empty(LIBC_SO) +DPLIBC ?= ${DESTDIR}${LIBC_SO} +.endif +.else +LDLIBC ?= -nodefaultlibs +.if ${HAVE_LIBGCC} == "yes" && (${LIB} == "c" || ${LIB} == "minc") +.if !defined(__MINIX) +LDADD+= -lgcc +.else +LDADD+= ${${ACTIVE_CC} == "gcc":? -lgcc:} +.if ${MACHINE_ARCH} == "earm" +LDADD+= ${${ACTIVE_CC} == "gcc":? -lgcc_eh:} +.endif # ${MACHINE_ARCH} == "earm" +.endif # !defined(__MINIX) +.endif +.endif +.endif + +.if ${LIBISCXX} != "no" +LIBCC:= ${CXX} +. if ${MKLIBCXX} == "yes" +LIBDPLIBS+= c++ ${.CURDIR}/../../../../../external/bsd/libc++/lib +. else +LIBDPLIBS+= stdc++ ${.CURDIR}/../../../../../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libstdc++-v3 +. endif +.else +LIBCC:= ${CC} +.endif + +_LDADD.${_LIB}= ${LDADD} ${LDADD.${_LIB}} +_LDFLAGS.${_LIB}= ${LDFLAGS} ${LDFLAGS.${_LIB}} + +_MAINLIBDEPS= ${SOLIB} ${DPADD} ${DPLIBC} \ + ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE} + +.if defined(_LIB.so.debug) +${_LIB.so.debug}: ${_LIB.so.link} + ${_MKTARGET_CREATE} + ( ${OBJCOPY} --only-keep-debug \ + ${_LIB.so.link} ${_LIB.so.debug} \ + ) || (rm -f ${.TARGET}; false) +${_LIB.so.full}: ${_LIB.so.link} ${_LIB.so.debug} + ${_MKTARGET_CREATE} + ( ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \ + --add-gnu-debuglink=${_LIB.so.debug} \ + ${_LIB.so.link} ${_LIB.so.full} \ + ) || (rm -f ${.TARGET}; false) +${_LIB.so.link}: ${_MAINLIBDEPS} +.else # aka no MKDEBUG +${_LIB.so.full}: ${_MAINLIBDEPS} +.endif + ${_MKTARGET_BUILD} + rm -f ${.TARGET} + ${LIBCC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS} \ + ${_LDFLAGS.${_LIB}} -o ${.TARGET} ${_LIBLDOPTS} \ + -Wl,--whole-archive ${SOLIB} \ + -Wl,--no-whole-archive ${_LDADD.${_LIB}} +# We don't use INSTALL_SYMLINK here because this is just +# happening inside the build directory/objdir. XXX Why does +# this spend so much effort on libraries that aren't live??? XXX +# XXX Also creates dead symlinks until the .full rule runs +# above and creates the main link +.if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \ + "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}" + ${HOST_LN} -sf ${_LIB.so.full} ${_LIB.so.major}.tmp + mv -f ${_LIB.so.major}.tmp ${_LIB.so.major} +.endif + ${HOST_LN} -sf ${_LIB.so.full} ${_LIB.so}.tmp + mv -f ${_LIB.so}.tmp ${_LIB.so} +.if ${MKSTRIPIDENT} != "no" + ${OBJCOPY} -R .ident ${.TARGET} +.endif + +.if !empty(LOBJS) # { +LLIBS?= -lc +${_LIB.ln}: ${LOBJS} + ${_MKTARGET_COMPILE} + rm -f ${.TARGET} +.if defined(DESTDIR) + ${LINT} -C${LIB} ${.ALLSRC} -L${DESTDIR}/usr/libdata ${LLIBS} +.else + ${LINT} -C${LIB} ${.ALLSRC} ${LLIBS} +.endif +.endif # } + +lint: ${LOBJS} +.if defined(LOBJS) && !empty(LOBJS) + ${LINT} ${LINTFLAGS} ${LOBJS} +.endif + + +# If the number of entries in CLEANFILES is too large, then the +# commands in bsd.clean.mk encounter errors like "exec(/bin/sh) +# failed (Argument list too long)". Avoid that by splitting the +# files to clean into several lists using different variable names. +# __cleanuse is an internal target in bsd.clean.mk; the way we +# use it here mimics the way it's used by the clean target in +# bsd.clean.mk. +# +clean: libclean1 libclean2 libclean3 libclean4 libclean5 +libclean1: .PHONY .MADE __cleanuse LIBCLEANFILES1 +libclean2: .PHONY .MADE __cleanuse LIBCLEANFILES2 +libclean3: .PHONY .MADE __cleanuse LIBCLEANFILES3 +libclean4: .PHONY .MADE __cleanuse LIBCLEANFILES4 +libclean5: .PHONY .MADE __cleanuse LIBCLEANFILES5 +.if defined(__MINIX) +# MINIX: core conflicts with core/ in lib/liblwip +CLEANFILES+= a.out [Ee]rrs mklog *.core +.else +CLEANFILES+= a.out [Ee]rrs mklog core *.core +.endif # defined(__MINIX) +LIBCLEANFILES1+= ${_LIB.a} ${STOBJS} ${STOBJS:=.tmp} +LIBCLEANFILES2+= ${_LIB_p.a} ${POBJS} ${POBJS:=.tmp} +LIBCLEANFILES3+= ${_LIB_g.a} ${GOBJS} ${GOBJS:=.tmp} +LIBCLEANFILES4+= ${_LIB_pic.a} +.if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION) +LIBCLEANFILES4+= ${_LIB.so}.* ${_LIB.so} ${_LIB.so.debug} +.endif +LIBCLEANFILES4+= ${SOBJS} ${SOBJS:=.tmp} +LIBCLEANFILES5+= ${_LIB.ln} ${LOBJS} + +.if defined(__MINIX) +clean: libclean6 +libclean6: .PHONY .MADE __cleanuse LIBCLEANFILES6 +LIBCLEANFILES6+= ${_LIB_bc.a} ${BCOBJS} ${BCOBJS:=.tmp} +.endif + +.if !target(libinstall) # { +# Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no +libinstall:: + +.if ${USE_BITCODE:Uno} == "yes" +libinstall:: ${_DEST.LIB}/bc/${_LIB.a} +.PRECIOUS: ${_DEST.LIB}/bc/${_LIB.a} + +.if ${MKUPDATE} == "no" +.if !defined(BUILD) && !make(all) && !make(${_LIB_bc.a}) +${_DEST.LIB}/bc/${_LIB.a}! .MADE +.endif +${_DEST.LIB}/bc/${_LIB.a}! ${_LIB_bc.a} __archiveinstall +.else +.if !defined(BUILD) && !make(all) && !make(${_LIB_bc.a}) +${_DEST.LIB}/bc/${_LIB.a}: .MADE +.endif +${_DEST.LIB}/bc/${_LIB.a}: ${_LIB_bc.a} __archiveinstall +.endif +.endif # ${USE_BITCODE:Uno} == "yes" + +.if ${MKLINKLIB} != "no" && ${MKSTATICLIB} != "no" +libinstall:: ${_DEST.LIB}/${_LIB.a} +.PRECIOUS: ${_DEST.LIB}/${_LIB.a} + +.if ${MKUPDATE} == "no" +.if !defined(BUILD) && !make(all) && !make(${_LIB.a}) +${_DEST.LIB}/${_LIB.a}! .MADE +.endif +${_DEST.LIB}/${_LIB.a}! ${_LIB.a} __archiveinstall +.else +.if !defined(BUILD) && !make(all) && !make(${_LIB.a}) +${_DEST.LIB}/${_LIB.a}: .MADE +.endif +${_DEST.LIB}/${_LIB.a}: ${_LIB.a} __archiveinstall +.endif +.endif + +.if ${MKPROFILE} != "no" +libinstall:: ${_DEST.LIB}/${_LIB_p.a} +.PRECIOUS: ${_DEST.LIB}/${_LIB_p.a} + +.if ${MKUPDATE} == "no" +.if !defined(BUILD) && !make(all) && !make(${_LIB_p.a}) +${_DEST.LIB}/${_LIB_p.a}! .MADE +.endif +${_DEST.LIB}/${_LIB_p.a}! ${_LIB_p.a} __archiveinstall +.else +.if !defined(BUILD) && !make(all) && !make(${_LIB_p.a}) +${_DEST.LIB}/${_LIB_p.a}: .MADE +.endif +${_DEST.LIB}/${_LIB_p.a}: ${_LIB_p.a} __archiveinstall +.endif +.endif + +.if ${MKDEBUGLIB} != "no" +libinstall:: ${_DEST.LIB}/${_LIB_g.a} +.PRECIOUS: ${_DEST.LIB}/${_LIB_g.a} + +.if ${MKUPDATE} == "no" +.if !defined(BUILD) && !make(all) && !make(${_LIB_g.a}) +${_DEST.LIB}/${_LIB_g.a}! .MADE +.endif +${_DEST.LIB}/${_LIB_g.a}! ${_LIB_g.a} __archiveinstall +.else +.if !defined(BUILD) && !make(all) && !make(${LIB_g.a}) +${_DEST.LIB}/${_LIB_g.a}: .MADE +.endif +${_DEST.LIB}/${_LIB_g.a}: ${_LIB_g.a} __archiveinstall +.endif +.endif + +.if ${MKPIC} != "no" && ${MKPICINSTALL} != "no" +libinstall:: ${_DEST.LIB}/${_LIB_pic.a} +.PRECIOUS: ${_DEST.LIB}/${_LIB_pic.a} + +.if ${MKUPDATE} == "no" +.if !defined(BUILD) && !make(all) && !make(${_LIB_pic.a}) +${_DEST.LIB}/${_LIB_pic.a}! .MADE +.endif +.if ${MKPICLIB} == "no" +${_DEST.LIB}/${_LIB_pic.a}! ${_LIB.a} __archivesymlinkpic +.else +${_DEST.LIB}/${_LIB_pic.a}! ${_LIB_pic.a} __archiveinstall +.endif +.else +.if !defined(BUILD) && !make(all) && !make(${_LIB_pic.a}) +${_DEST.LIB}/${_LIB_pic.a}: .MADE +.endif +.if ${MKPICLIB} == "no" +${_DEST.LIB}/${_LIB_pic.a}: ${_LIB.a} __archivesymlinkpic +.else +${_DEST.LIB}/${_LIB_pic.a}: ${_LIB_pic.a} __archiveinstall +.endif +.endif +.endif + +.if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION) + +libinstall:: ${_DEST.OBJ}/${_LIB.so.full} +.PRECIOUS: ${_DEST.OBJ}/${_LIB.so.full} + +.if ${MKUPDATE} == "no" +.if !defined(BUILD) && !make(all) && !make(${_LIB.so.full}) +${_DEST.OBJ}/${_LIB.so.full}! .MADE +.endif +${_DEST.OBJ}/${_LIB.so.full}! ${_LIB.so.full} +.else +.if !defined(BUILD) && !make(all) && !make(${_LIB.so.full}) +${_DEST.OBJ}/${_LIB.so.full}: .MADE +.endif +${_DEST.OBJ}/${_LIB.so.full}: ${_LIB.so.full} +.endif + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${.ALLSRC} ${.TARGET} +.if ${_LIBSODIR} != ${LIBDIR} + ${INSTALL_SYMLINK} -l r ${_DEST.OBJ}/${_LIB.so.full} \ + ${_DEST.LIB}/${_LIB.so.full} +.endif +.if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \ + "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}" + ${INSTALL_SYMLINK} ${_LIB.so.full} ${_DEST.OBJ}/${_LIB.so.major} +.if ${_LIBSODIR} != ${LIBDIR} + ${INSTALL_SYMLINK} -l r ${_DEST.OBJ}/${_LIB.so.full} \ + ${_DEST.LIB}/${_LIB.so.major} +.endif +.endif +.if ${MKLINKLIB} != "no" + ${INSTALL_SYMLINK} ${_LIB.so.full} ${_DEST.OBJ}/${_LIB.so} +.if ${_LIBSODIR} != ${LIBDIR} + ${INSTALL_SYMLINK} -l r ${_DEST.OBJ}/${_LIB.so.full} \ + ${_DEST.LIB}/${_LIB.so} +.endif +.endif +.endif + +.if defined(_LIB.so.debug) +libinstall:: ${_DEST.DEBUG}/${_LIB.so.debug} +.PRECIOUS: ${_DEST.DEBUG}/${_LIB.so.debug} + +${_DEST.DEBUG}/${_LIB.so.debug}: ${_LIB.so.debug} + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} -o ${DEBUGOWN} -g ${DEBUGGRP} -m ${DEBUGMODE} \ + ${.ALLSRC} ${.TARGET} +.if ${_LIBSODIR} != ${LIBDIR} + ${INSTALL_SYMLINK} -l r ${_DEST.DEBUG}/${_LIB.so.debug} \ + ${_DEST.ODEBUG}/${_LIB.so.debug} +.endif +.endif + +.if ${MKLINT} != "no" && !empty(LOBJS) +libinstall:: ${_DEST.LINT}/${_LIB.ln} +.PRECIOUS: ${_DEST.LINT}/${_LIB.ln} + +.if ${MKUPDATE} == "no" +.if !defined(BUILD) && !make(all) && !make(${_LIB.ln}) +${_DEST.LINT}/${_LIB.ln}! .MADE +.endif +${_DEST.LINT}/${_LIB.ln}! ${_LIB.ln} +.else +.if !defined(BUILD) && !make(all) && !make(${_LIB.ln}) +${_DEST.LINT}/${_LIB.ln}: .MADE +.endif +${_DEST.LINT}/${_LIB.ln}: ${_LIB.ln} +.endif + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${.ALLSRC} ${_DEST.LINT} +.endif +.endif # !target(libinstall) # } + +##### Pull in related .mk logic +LINKSOWN?= ${LIBOWN} +LINKSGRP?= ${LIBGRP} +LINKSMODE?= ${LIBMODE} +.include +.include +.include +.include +.include +.include +.include +.include + +${TARGETS}: # ensure existence diff --git a/src/share/mk/ubix.links.mk b/src/share/mk/ubix.links.mk new file mode 100644 index 0000000..ffb695f --- /dev/null +++ b/src/share/mk/ubix.links.mk @@ -0,0 +1,96 @@ +# $NetBSD: ubix.links.mk,v 1.34 2009/04/10 16:16:12 apb Exp $ + +.include + +##### Basic targets +install: linksinstall + +##### Default values +LINKS?= +SYMLINKS?= +LINKSOWN?= ${BINOWN} +LINKSGRP?= ${BINGRP} +LINKSMODE?= ${NONBINMODE} + +__linkinstall: .USE + ${_MKSHMSG_INSTALL} ${.TARGET}; \ + ${_MKSHECHO} "${INSTALL_LINK} \ + -o ${LINKSOWN_${.ALLSRC:T}:U${LINKSOWN}} \ + -g ${LINKSGRP_${.ALLSRC:T}:U${LINKSGRP}} \ + -m ${LINKSMODE_${.ALLSRC:T}:U${LINKSMODE}} \ + ${.ALLSRC} ${.TARGET}" && \ + ${INSTALL_LINK} \ + -o ${LINKSOWN_${.ALLSRC:T}:U${LINKSOWN}} \ + -g ${LINKSGRP_${.ALLSRC:T}:U${LINKSGRP}} \ + -m ${LINKSMODE_${.ALLSRC:T}:U${LINKSMODE}} \ + ${.ALLSRC} ${.TARGET} + +##### Install rules +.PHONY: linksinstall +linksinstall:: realinstall +.if !empty(SYMLINKS) + @(set ${SYMLINKS}; \ + while test $$# -ge 2; do \ + l=$$1; shift; \ + t=${DESTDIR}$$1; shift; \ + if ttarg=`${TOOL_STAT} -qf '%Y' $$t` && \ + [ "$$l" = "$$ttarg" ]; then \ + continue ; \ + fi ; \ + ${_MKSHMSG_INSTALL} $$t; \ + ${_MKSHECHO} ${INSTALL_SYMLINK} $$l $$t; \ + ${INSTALL_SYMLINK} $$l $$t; \ + done; ) +.endif + +.for _src _dst in ${LINKS} +_l:=${DESTDIR}${_src} +_t:=${DESTDIR}${_dst} + +# Handle case conflicts carefully, when _dst occurs +# more than once after case flattening +.if ${MKUPDATE} == "no" || ${LINKS:tl:M${_dst:tl:Q}:[\#]} > 1 +${_t}! ${_l} __linkinstall +.else +${_t}: ${_l} __linkinstall +.endif + +linksinstall:: ${_t} +.PRECIOUS: ${_t} +.endfor + +configinstall: configlinksinstall +.PHONY: configlinksinstall +configlinksinstall:: configfilesinstall +.if !empty(CONFIGSYMLINKS) + @(set ${CONFIGSYMLINKS}; \ + while test $$# -ge 2; do \ + l=$$1; shift; \ + t=${DESTDIR}$$1; shift; \ + if ttarg=`${TOOL_STAT} -qf '%Y' $$t` && \ + [ "$$l" = "$$ttarg" ]; then \ + continue ; \ + fi ; \ + ${_MKSHMSG_INSTALL} $$t; \ + ${_MKSHECHO} ${INSTALL_SYMLINK} $$l $$t; \ + ${INSTALL_SYMLINK} $$l $$t; \ + done; ) +.endif + +.for _src _dst in ${CONFIGLINKS} +_l:=${DESTDIR}${_src} +_t:=${DESTDIR}${_dst} + +# Handle case conflicts carefully, when _dst occurs +# more than once after case flattening +.if ${MKUPDATE} == "no" || ${CONFIGLINKS:tl:M${_dst:tl:Q}:[\#]} > 1 +${_t}! ${_l} __linkinstall +.else +${_t}: ${_l} __linkinstall +.endif + +configlinksinstall:: ${_t} +.PRECIOUS: ${_t} +.endfor + +.include diff --git a/src/share/mk/ubix.man.mk b/src/share/mk/ubix.man.mk new file mode 100644 index 0000000..373870e --- /dev/null +++ b/src/share/mk/ubix.man.mk @@ -0,0 +1,302 @@ +# $NetBSD: ubix.man.mk,v 1.117 2014/12/19 22:25:39 christos Exp $ +# @(#)ubix.man.mk 8.1 (Berkeley) 6/8/93 + +.include + +##### Basic targets +.PHONY: catinstall maninstall catpages manpages catlinks manlinks +.PHONY: htmlinstall htmlpages htmllinks +.PHONY: lintmanpages +realinstall: ${MANINSTALL} + +# If our install destination is case-preserving, but case-insensitive +# then we do filesystem comparisons in lower case to make sure that +# we always refresh the target when needed. In general we don't +# want to do this, otherwise things like _exit.2 -> _Exit.2 get +# installed on each build even when they don't need to. Note that +# the CASE_INSENSITIVE_DEST macro is currently not defined anywhere, +# and the expansion does not really work because of make(1). +.if defined(CASE_INSENSITIVE_DEST) +_FLATTEN?=tl: +.endif + +##### Default values +.if ${USETOOLS} == "yes" +TMACDEPDIR?= ${TOOLDIR}/share/groff/tmac +.else +TMACDEPDIR?= /usr/share/tmac +.endif + +HTMLDIR?= ${DESTDIR}${MANDIR} +.if ${MKMANDOC} == yes && !defined(NOMANDOC) +CATDEPS?= +.else +CATDEPS?= ${TMACDEPDIR}/andoc.tmac \ + ${TMACDEPDIR}/doc.tmac \ + ${TMACDEPDIR}/mdoc/doc-common \ + ${TMACDEPDIR}/mdoc/doc-ditroff \ + ${TMACDEPDIR}/mdoc/doc-nroff \ + ${TMACDEPDIR}/mdoc/doc-syms +.endif +MANTARGET?= cat + +MAN?= +MLINKS?= +_MSECTIONS= 1 2 3 4 5 6 7 8 9 +_MSECTIONS+= 3lua 9lua +_MSECTIONREGEX= ${_MSECTIONS:ts|} # e.g. 1|2|3|... +.SUFFIXES: ${_MSECTIONS:@N@.$N@} + +.if ${MKMANZ} == "no" +MANCOMPRESS?= +MANSUFFIX?= +.else +MANCOMPRESS?= ${TOOL_GZIP_N} -cf +MANSUFFIX?= .gz +.endif + +# make MANCOMPRESS a filter, so it can be inserted on an as-needed basis +.if !empty(MANCOMPRESS) +MANCOMPRESS:= | ${MANCOMPRESS} +.endif + +__installpage: .USE + @cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \ + (${_MKSHMSG_INSTALL} ${.TARGET}; \ + ${_MKSHECHO} "${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \ + ${.ALLSRC} ${.TARGET}" && \ + ${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \ + ${.ALLSRC} ${.TARGET}) + +# XXX consider including ubix.links.mk and using __linkinstall instead +__linkinstallpage: .USE + ${_MKSHMSG_INSTALL} ${.TARGET}; \ + ${_MKSHECHO} "${INSTALL_LINK} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \ + ${.ALLSRC} ${.TARGET}" && \ + ${INSTALL_LINK} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \ + ${.ALLSRC} ${.TARGET} + +##### Build and install rules (source form pages) + +.if ${MKMAN} != "no" +maninstall: manpages manlinks +manpages:: # ensure target exists +MANPAGES= ${MAN:C/.$/&${MANSUFFIX}/} + +realall: ${MANPAGES} +.if !empty(MANSUFFIX) +.NOPATH: ${MANPAGES} +.SUFFIXES: ${_MSECTIONS:@N@.$N${MANSUFFIX}@} + +${_MSECTIONS:@N@.$N.$N${MANSUFFIX}@}: # build rule + ${_MKTARGET_FORMAT} + cat ${.IMPSRC} ${MANCOMPRESS} > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET} +.endif # !empty(MANSUFFIX) + +.for F in ${MANPAGES:S/${MANSUFFIX}$//:O:u} +_F:= ${DESTDIR}${MANDIR}/man${F:T:E}${MANSUBDIR}/${F}${MANSUFFIX} + +.if ${MKUPDATE} == "no" +${_F}! ${F}${MANSUFFIX} __installpage # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) +${_F}! .MADE # no build at install +.endif +.else +${_F}: ${F}${MANSUFFIX} __installpage # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) +${_F}: .MADE # no build at install +.endif +.endif + +manpages:: ${_F} +.PRECIOUS: ${_F} # keep if install fails +.endfor + +manlinks:: # link install + +.for _src _dst in ${MLINKS} +_l:=${DESTDIR}${MANDIR}/man${_src:T:E}${MANSUBDIR}/${_src}${MANSUFFIX} +_t:=${DESTDIR}${MANDIR}/man${_dst:T:E}${MANSUBDIR}/${_dst}${MANSUFFIX} + +# Handle case conflicts carefully, when _dst occurs +# more than once after case flattening +.if ${MKUPDATE} == "no" || ${MLINKS:${_FLATTEN}M${_dst:${_FLATTEN}Q}:[\#]} > 1 +${_t}! ${_l} __linkinstallpage +.else +${_t}: ${_l} __linkinstallpage +.endif + +manlinks:: ${_t} +.PRECIOUS: ${_t} +.endfor +.endif # ${MKMAN} != "no" + +##### Build and install rules (plaintext pages) + +.if (${MKCATPAGES} != "no") && (${MKMAN} != "no") +catinstall: catpages catlinks +catpages:: # ensure target exists +CATPAGES= ${MAN:C/\.(${_MSECTIONREGEX})\$/.cat\1${MANSUFFIX}/} + +realall: ${CATPAGES} +.NOPATH: ${CATPAGES} +.SUFFIXES: ${_MSECTIONS:@N@.cat$N${MANSUFFIX}@} +.MADE: ${CATDEPS} + +${_MSECTIONS:@N@.$N.cat$N${MANSUFFIX}@}: ${CATDEPS} # build rule + ${_MKTARGET_FORMAT} +.if ${MKMANDOC} == yes && !defined(NOMANDOC) + if test ""${NOMANDOC.${.IMPSRC:T}:tl:Q} != "yes"; then \ + ${TOOL_MANDOC_ASCII} ${.IMPSRC} ${MANCOMPRESS} \ + > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}; \ + else \ + ${TOOL_ROFF_ASCII} -mandoc ${.IMPSRC} ${MANCOMPRESS} \ + > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}; \ + fi +.elif defined(USETBL) + ${TOOL_TBL} ${.IMPSRC} | ${TOOL_ROFF_ASCII} -mandoc ${MANCOMPRESS} \ + > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET} +.else + ${TOOL_ROFF_ASCII} -mandoc ${.IMPSRC} ${MANCOMPRESS} \ + > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET} +.endif + +.for F in ${CATPAGES:S/${MANSUFFIX}$//:O:u} +_F:= ${DESTDIR}${MANDIR}/${F:T:E}${MANSUBDIR}/${F:R}.0${MANSUFFIX} + +.if ${MKUPDATE} == "no" +${_F}! ${F}${MANSUFFIX} __installpage # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) +${_F}! .MADE # no build at install +.endif +.else +${_F}: ${F}${MANSUFFIX} __installpage # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) +${_F}: .MADE # no build at install +.endif +.endif + +catpages:: ${_F} +.PRECIOUS: ${_F} # keep if install fails +.endfor + +catlinks:: # link install + +.for _src _dst in ${MLINKS} +_l:=${DESTDIR}${MANDIR}/cat${_src:T:E}${MANSUBDIR}/${_src:R}.0${MANSUFFIX} +_t:=${DESTDIR}${MANDIR}/cat${_dst:T:E}${MANSUBDIR}/${_dst:R}.0${MANSUFFIX} + +# Handle case conflicts carefully, when _dst occurs +# more than once after case flattening +.if ${MKUPDATE} == "no" || ${MLINKS:${_FLATTEN}M${_dst:${_FLATTEN}Q}:[\#]} > 1 +${_t}! ${_l} __linkinstallpage +.else +${_t}: ${_l} __linkinstallpage +.endif + +catlinks:: ${_t} +.PRECIOUS: ${_t} +.endfor +.endif # (${MKCATPAGES} != "no") && (${MKMAN} != "no") + +##### Build and install rules (HTML pages) + +.if (${MKHTML} != "no") && (${MKMAN} != "no") # { +htmlinstall: htmlpages htmllinks +htmlpages:: # ensure target exists +HTMLPAGES= ${MAN:C/\.(${_MSECTIONREGEX})\$/.html\1/} + +HTMLLINKS= ${MANSUBDIR:?../:}../html%S/%N.html +HTMLSTYLE= ${MANSUBDIR:?../:}../style.css + +realall: ${HTMLPAGES} +.NOPATH: ${HTMLPAGES} +.SUFFIXES: ${_MSECTIONS:@N@.html$N@} + +${_MSECTIONS:@N@.$N.html$N@}: # build rule + ${_MKTARGET_FORMAT} +.if ${MKMANDOC} == yes && !defined(NOMANDOC) + if test ""${NOMANDOC.${.IMPSRC:T}:tl:Q} != "yes"; then \ + ${TOOL_MANDOC_HTML} -Oman=${HTMLLINKS} -Ostyle=${HTMLSTYLE} \ + ${.IMPSRC} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET}; \ + else \ + ${TOOL_ROFF_HTML} ${.IMPSRC} ${MANCOMPRESS} \ + > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}; \ + fi +.elif defined(USETBL) + ${TOOL_TBL} ${.IMPSRC} | ${TOOL_ROFF_HTML} ${MANCOMPRESS} \ + > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET} +.else + ${TOOL_ROFF_HTML} ${.IMPSRC} ${MANCOMPRESS} \ + > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET} +.endif + +.for F in ${HTMLPAGES:O:u} +# construct installed path +_F:= ${HTMLDIR}/${F:T:E}${MANSUBDIR}/${F:R:S-/index$-/x&-}.html + +.if ${MKUPDATE} == "no" +${_F}! ${F} __installpage # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) +${_F}! .MADE # no build at install +.endif +.else +${_F}: ${F} __installpage # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) +${_F}: .MADE # no build at install +.endif +.endif + +htmlpages:: ${_F} +.PRECIOUS: ${_F} # keep if install fails +.endfor + +htmllinks:: # link install + +.for _src _dst in ${MLINKS} +_l:=${HTMLDIR}/html${_src:T:E}${MANSUBDIR}/${_src:R:S-/index$-/x&-}.html +_t:=${HTMLDIR}/html${_dst:T:E}${MANSUBDIR}/${_dst:R:S-/index$-/x&-}.html + +# Handle case conflicts carefully, when _dst occurs +# more than once after case flattening +.if ${MKUPDATE} == "no" || ${MLINKS:${_FLATTEN}M${_dst:${_FLATTEN}Q}:[\#]} > 1 +${_t}! ${_l} __linkinstallpage +.else +${_t}: ${_l} __linkinstallpage +.endif + +htmllinks:: ${_t} +.PRECIOUS: ${_t} +.endfor + +.endif # } + +##### Clean rules +.undef _F + +.if !empty(MAN) && (${MKMAN} != "no") +.if (${MKCATPAGES} != "no") +CLEANDIRFILES+= ${CATPAGES} +.endif +.if !empty(MANSUFFIX) +CLEANDIRFILES+= ${MANPAGES} ${CATPAGES:S/${MANSUFFIX}$//} +.endif +.if ${MKHTML} != "no" +CLEANDIRFILES+= ${HTMLPAGES} +.endif +.endif +# (XXX ${CATPAGES:S...} cleans up old .catN files where .catN.gz now used) + +.if !empty(MANPAGES) +lintmanpages: ${MANPAGES} + ${TOOL_MANDOC_LINT} -Tlint -fstrict -Wall,stop ${.ALLSRC} +.endif + +##### Pull in related .mk logic +.include +.include +.include +.include + +${TARGETS} catinstall maninstall htmlinstall: # ensure existence diff --git a/src/share/mk/ubix.nls.mk b/src/share/mk/ubix.nls.mk new file mode 100644 index 0000000..04dec18 --- /dev/null +++ b/src/share/mk/ubix.nls.mk @@ -0,0 +1,71 @@ +# $NetBSD: ubix.nls.mk,v 1.47 2011/09/10 16:57:35 apb Exp $ + +.include + +##### Basic targets +realinstall: nlsinstall + +##### Default values +NLSNAME?= ${PROG:Ulib${LIB}} + +NLS?= + +##### Build rules +.if ${MKNLS} != "no" + +NLSALL= ${NLS:.msg=.cat} + +realall: ${NLSALL} +.NOPATH: ${NLSALL} + +.SUFFIXES: .cat .msg + +.msg.cat: + @rm -f ${.TARGET} + ${_MKTARGET_CREATE} + ${TOOL_GENCAT} ${.TARGET} ${.IMPSRC} + +.endif # ${MKNLS} != "no" + +##### Install rules +nlsinstall:: # ensure existence +.PHONY: nlsinstall + +.if ${MKNLS} != "no" + +__nlsinstall: .USE + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} -o ${NLSOWN} -g ${NLSGRP} -m ${NLSMODE} \ + ${.ALLSRC} ${.TARGET} + +.for F in ${NLSALL:O:u} +_F:= ${DESTDIR}${NLSDIR}/${F:T:R}/${NLSNAME}.cat # installed path + +.if ${MKUPDATE} == "no" +${_F}! ${F} __nlsinstall # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) +${_F}! .MADE # no build at install +.endif +.else +${_F}: ${F} __nlsinstall # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) +${_F}: .MADE # no build at install +.endif +.endif + +nlsinstall:: ${_F} +.PRECIOUS: ${_F} # keep if install fails +.endfor + +.undef _F +.endif # ${MKNLS} != "no" + +##### Clean rules +.if ${MKNLS} != "no" && !empty(NLS) +CLEANDIRFILES+= ${NLSALL} +.endif + +##### Pull in related .mk logic +.include +.include +.include diff --git a/src/share/mk/ubix.obj.mk b/src/share/mk/ubix.obj.mk new file mode 100644 index 0000000..60c87a8 --- /dev/null +++ b/src/share/mk/ubix.obj.mk @@ -0,0 +1,109 @@ +# $NetBSD: ubix.obj.mk,v 1.49 2010/01/25 00:43:00 christos Exp $ + +.if !defined(_BSD_OBJ_MK_) +_BSD_OBJ_MK_=1 + +.include + +__curdir:= ${.CURDIR} + +.if ${MKOBJ} == "no" +obj: +.else +.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR) +.if defined(MAKEOBJDIRPREFIX) +__objdir:= ${MAKEOBJDIRPREFIX}${__curdir} +.else +__objdir:= ${MAKEOBJDIR} +.endif +# MAKEOBJDIR and MAKEOBJDIRPREFIX are env variables supported +# by make(1). We simply mkdir -p the specified path. +# If that fails - we do a mkdir to get the appropriate error message +# before bailing out. +obj: +.if defined(MAKEOBJDIRPREFIX) + @if [ ! -d ${MAKEOBJDIRPREFIX} ]; then \ + echo "MAKEOBJDIRPREFIX ${MAKEOBJDIRPREFIX} does not exist, bailing..."; \ + exit 1; \ + fi; +.endif + @if [ ! -d ${__objdir} ]; then \ + mkdir -p ${__objdir}; \ + if [ ! -d ${__objdir} ]; then \ + mkdir ${__objdir}; exit 1; \ + fi; \ + ${_MKSHMSG} " objdir ${__objdir}"; \ + fi +.else +PAWD?= /bin/pwd + +__objdir= obj${OBJMACHINE:D.${MACHINE}} + +__usrobjdir= ${BSDOBJDIR}${USR_OBJMACHINE:D.${MACHINE}} +__usrobjdirpf= ${USR_OBJMACHINE:D:U${OBJMACHINE:D.${MACHINE}}} + +.if defined(BUILDID) +__objdir:= ${__objdir}.${BUILDID} +__usrobjdirpf:= ${__usrobjdirpf}.${BUILDID} +__need_objdir_target=yes +.endif + +.if defined(OBJHOSTMACHINE) && (${MKHOSTOBJ:Uno} != "no") +# In case .CURDIR has been twiddled by a .mk file and is now relative, +# make it absolute again. +.if ${__curdir:M/*} == "" +__curdir!= cd "${__curdir}" && ${PAWD} +.endif + +__objdir:= ${__objdir}.${HOST_OSTYPE} +__usrobjdirpf:= ${__usrobjdirpf}.${HOST_OSTYPE} +__need_objdir_target=yes +.endif + +.if defined(__need_objdir_target) +# Get make to change its internal definition of .OBJDIR +.OBJDIR: ${__objdir} +.endif + +obj: + @cd "${__curdir}"; \ + here=`${PAWD}`/; subdir=$${here#${BSDSRCDIR}/}; \ + if [ "$$here" != "$$subdir" ]; then \ + if [ ! -d ${__usrobjdir} ]; then \ + echo "BSDOBJDIR ${__usrobjdir} does not exist, bailing..."; \ + exit 1; \ + fi; \ + subdir=$${subdir%/}; \ + dest=${__usrobjdir}/$$subdir${__usrobjdirpf}; \ + if [ -x ${TOOL_STAT} ] && \ + ttarg=`${TOOL_STAT} -qf '%Y' $${here}${__objdir}` && \ + [ "$$dest" = "$$ttarg" ]; then \ + : ; \ + else \ + ${_MKSHMSG} " objdir $$dest"; \ + rm -rf ${__objdir}; \ + ln -s $$dest ${__objdir}; \ + fi; \ + if [ ! -d $$dest ]; then \ + mkdir -p $$dest; \ + else \ + true; \ + fi; \ + else \ + true ; \ + dest=$${here}${__objdir} ; \ + if [ ! -d ${__objdir} ] || [ -h ${__objdir} ]; then \ + ${_MKSHMSG} " objdir $$dest"; \ + rm -f ${__objdir}; \ + mkdir $$dest; \ + fi ; \ + fi; +.endif +.endif + +print-objdir: + @echo ${.OBJDIR} + +.include + +.endif # !defined(_BSD_OBJ_MK_) diff --git a/src/share/mk/ubix.own.mk b/src/share/mk/ubix.own.mk new file mode 100644 index 0000000..272c545 --- /dev/null +++ b/src/share/mk/ubix.own.mk @@ -0,0 +1,1730 @@ +# This needs to be before ubix.init.mk +.if defined(UBIX_MK_COMPAT_FILE) +.include <${UBIX_MK_COMPAT_FILE}> +.endif + +.if !defined(_UBIX_OWN_MK_) +_UBIX_OWN_MK_=1 + +.if defined(__MINIX) + +LDSTATIC?= -static +MKDYNAMICROOT?= no +NO_LIBGOMP?= yes + +BINMODE?= 755 +NONBINMODE?= 644 +MANDIR?= /usr/man + +MKKYUA?= yes +MKMCLINKER?= no +MKCLANGRT?= no +MKGCC?= no +MKGCCCMDS?= no +MKPROFILE?= no +MKSLJIT?= no + +#MINIX-specific variables +MKCOVERAGE?= no + +# LSC MINIX does not support these features ATM. +USE_FORT:= no +USE_SSP:= no +MKCOMPAT:= no +MKGDB:= no +MKGROFF:= no +MKHESIOD:= no +MKHTML:= no +MKIPFILTER:= no +MKISCSI:= no +MKKERBEROS:= no +MKKMOD:= no +MKLDAP:= no +MKLINT:= no +MKLVM:= no +MKMDNS:= no +MKNPF:= no +MKPAM:= no +MKPF:= no +MKPOSTFIX:= no +MKRUMP:= no +MKSKEY:= no +MKYP:= no +MKCROSSGDB:= no + +WEAKALIASOVERRIDEPASS?=${UBIXSRCDIR}/minix/llvm/bin/weak-alias-module-override.so +GOLD_PLUGIN?=${UBIXSRCDIR}/minix/llvm/bin/LLVMgold.so + +# By default when running LLVM passes: +# - do not run optimization while running LLVM passes +# - run the passe which allows assembly weak symbols to be +# overriden by bitcode functions +OPTFLAGS?= -disable-opt \ + -disable-inlining \ + -load ${WEAKALIASOVERRIDEPASS} -weak-alias-module-override + +BITCODE_LD_FLAGS_1ST?= \ + -Wl,-plugin=${GOLD_PLUGIN} \ + -Wl,-plugin-opt=-disable-opt \ + -Wl,-plugin-opt=-disable-inlining + +BITCODE_LD_FLAGS_2ND?=${BITCODE_LD_FLAGS_1ST} + +.ifdef CONFIG_SMP +SMP_FLAGS += -DCONFIG_SMP +.ifdef CONFIG_MAX_CPUS +SMP_FLAGS += -DCONFIG_MAX_CPUS=${CONFIG_MAX_CPUS} +.endif +.endif + +CPPFLAGS+= ${SMP_FLAGS} + +__uname_s!= uname -s +.if ${__uname_s:Uunknown} == "Minix" +USETOOLS?= never +. if ${USETOOLS:Uno} != "yes" + HAVE_LLVM?= yes + +# If DESTDIR was specified, and we are not using the tools, then make sure to +# build out-of-tree and to refer only DESTDIR for target binaries +# The case when using tools is already handled below. +. if ${DESTDIR:U} != "" + CPPFLAGS+= --sysroot=${DESTDIR} + LDFLAGS+= --sysroot=${DESTDIR} +. endif # ${DESTDIR:U} != "" + + MKTOOLS?=no +. endif # ${USETOOLS:Uno} != "yes" + +. if !defined(HOSTPROG) && !defined(HOSTLIB) +# LSC FIXME: Override MACHINE as the native minix host make command will set +# it to i686. +. if ${MACHINE_ARCH} == "i386" + MACHINE:= i386 +. endif +# LSC FIXME: On a native ARM system MACHINE_ARCH is earmv7 instead of earm... +. if !empty(MACHINE_ARCH:Mearm*) + MACHINE_ARCH:= earm +. endif +. endif # !defined(HOSTPROG) && !defined(HOSTLIB) +.endif # __uname_s == "Minix" + +# LSC FIXME: RELEASEMACHINEDIR is set to evbarm, instead of evbearm-el +.if !empty(MACHINE:Mevbarm*) +RELEASEMACHINEDIR:= evbearm-el +.endif + +.if ${HAVE_GCC:Dyes} == "yes" || \ + (${MKGCCCMDS:Uno} == "yes" && ${MKLLVM:Uyes} == "no") +# We are building with GCC, means we cannot build LIBCXX, and need LIBSTDCXX +MKLIBCXX?= no # Can't compile with GCC. + +. if ${USETOOLS:Uno} == "yes" || ${MKLIBSTDCXX:Uno} == "yes" +# When cross-compiling, or building MKLIBSTDCXX, use the in-tree LIBSTDCXX +MKLIBSTDCXX?= yes +CXXFLAGS+= -I${DESTDIR}/usr/include/g++ +. endif # ${USETOOLS:Uno} == "yes" + +. if ${MKLIBSTDCXX:Uno} == "no" +# Specify the C++ system header for the host libstdc++, as we are not building +# LIBSTDCXX +CXXFLAGS+= -I/usr/include/g++ +. endif # ${MKLIBSTDCXX:Uno} == "no" + +.endif # ${HAVE_GCC:Dyes} == "yes" || \ + # (${MKGCCCMDS:Uno} == "yes" && ${MKLLVM:Uyes} == "no") + +# MKGCCCMDS == yes implies MKGCC == yes +.if ${MKGCCCMDS} == "yes" +MKGCC= yes +MKBINUTILS?= yes # We are installing GCC, so trigger binutils. +MKLIBSTDCXX?= yes # Also install the GNU C++ library +.endif # ${MKGCCCMDS} == "yes" + +# The default value of MKLIBSTDCXX cannot be set before the previous test. +MKLIBSTDCXX?= no + +.if ${MKGCC} == "yes" +HAVE_GCC?= 5 # Not really, but that's the setting. +HAVE_LIBGCC?= yes +HAVE_LIBGCC_EH?= yes +.endif # ${MKGCC} == "yes" + +.if ${USETOOLS:Uno} == "yes" +MKLLVM?= yes +.endif # ${USETOOLS:Uno} == "yes" + +.if ${MKLLVM:Uno} == "yes" +HAVE_LLVM?= yes +MKBINUTILS?= yes # We are installing clang, so trigger binutils. +.endif # ${MKLLVM:Uno} == "yes" + +.if ${HAVE_LLVM:Dyes} == "yes" +HAVE_LIBGCC?= no +.endif # ${HAVE_LLVM:Dyes} == "yes" + +# The default value has to be set after we have figured out if we are using GCC +# or not. +MKLIBCXX?= yes # Build by default libc++ + +# The default value of MKBINUTILS cannot be set before the previous test. +MKBINUTILS?= no + +.endif # defined(__MINIX) + +MAKECONF?= /etc/mk.conf +.-include "${MAKECONF}" + +# +# CPU model, derived from MACHINE_ARCH +# +MACHINE_CPU= ${MACHINE_ARCH:C/mipse[bl]/mips/:C/mips64e[bl]/mips/:C/sh3e[bl]/sh3/:S/coldfire/m68k/:S/m68000/m68k/:C/arm.*/arm/:C/earm.*/arm/:S/earm/arm/:S/powerpc64/powerpc/:S/aarch64eb/aarch64/:S/or1knd/or1k/:C/riscv../riscv/} + +# +# Subdirectory used below ${RELEASEDIR} when building a release +# +RELEASEMACHINEDIR?= ${MACHINE} + +# +# Subdirectory or path component used for the following paths: +# distrib/${RELEASEMACHINE} +# distrib/notes/${RELEASEMACHINE} +# etc/etc.${RELEASEMACHINE} +# Used when building a release. +# +RELEASEMACHINE?= ${MACHINE} + +# +# NEED_OWN_INSTALL_TARGET is set to "no" by pkgsrc/mk/ubix.pkg.mk to +# ensure that things defined by (default targets, +# INSTALL_FILE, etc.) are not conflicting with ubix.pkg.mk. +# +NEED_OWN_INSTALL_TARGET?= yes + +# +# This lists the platforms which do not have working in-tree toolchains. For +# the in-tree gcc toolchain, this list is empty. +# +# If some future port is not supported by the in-tree toolchain, this should +# be set to "yes" for that port only. +# +.if ${MACHINE} == "playstation2" +TOOLCHAIN_MISSING?= yes +.endif + +TOOLCHAIN_MISSING?= no + +.if ${MACHINE_CPU} == "aarch64" && !defined(EXTERNAL_TOOLCHAIN) && ${MKLLVM:Uyes} != "no" +MKLLVM?= yes +HAVE_LLVM?= yes +MKGCC?= no +.endif + +# +# GCC Using platforms. +# +.if ${MKGCC:Uyes} != "no" + +.if ${MACHINE} == "playstation2" || ${MACHINE_CPU} == "aarch64" +HAVE_GCC?= 0 +.else +# Otherwise, default to GCC4.8 +HAVE_GCC?= 48 +.endif + +# +# Platforms that can't run a modern GCC natively +.if ${MACHINE_ARCH} == "m68000" +MKGCCCMDS?= no +.endif + +# +# We import the old gcc as "gcc.old" when upgrading. EXTERNAL_GCC_SUBDIR is +# set to the relevant subdirectory in src/external/gpl3 for his HAVE_GCC. +# +.if ${HAVE_GCC} == 5 +EXTERNAL_GCC_SUBDIR= gcc +.elif ${HAVE_GCC} == 48 +EXTERNAL_GCC_SUBDIR= gcc.old +.else +EXTERNAL_GCC_SUBDIR= /does/not/exist +.endif +.else +MKGCCCMDS?= no +.endif + +.if !empty(MACHINE_ARCH:Mearm*) +_LIBC_COMPILER_RT.${MACHINE_ARCH}= yes +.endif + +_LIBC_COMPILER_RT.aarch64= yes +_LIBC_COMPILER_RT.i386= yes +_LIBC_COMPILER_RT.powerpc= yes +_LIBC_COMPILER_RT.powerpc64= yes +_LIBC_COMPILER_RT.x86_64= yes + +.if ${HAVE_LLVM:Uno} == "yes" && ${_LIBC_COMPILER_RT.${MACHINE_ARCH}:Uno} == "yes" +HAVE_LIBGCC?= no +.else +HAVE_LIBGCC?= yes +.endif + + +# ia64 is not support +.if ${HAVE_LLVM:Uno} == "yes" || !empty(MACHINE_ARCH:Mearm*) +HAVE_LIBGCC_EH?= no +.else +HAVE_LIBGCC_EH?= yes +.endif + +HAVE_GDB?= 79 + +.if (${MACHINE_ARCH} == "alpha") || \ + (${MACHINE_ARCH} == "hppa") || \ + (${MACHINE_ARCH} == "ia64") || \ + (${MACHINE_CPU} == "mips") +HAVE_SSP?= no +.else +HAVE_SSP?= yes +.if ${USE_FORT:Uno} != "no" +USE_SSP?= yes +.endif +.endif + +.if empty(.MAKEFLAGS:tW:M*-V .OBJDIR*) +.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR) +PRINTOBJDIR= ${MAKE} -r -V .OBJDIR -f /dev/null xxx +.else +PRINTOBJDIR= ${MAKE} -V .OBJDIR +.endif +.else +PRINTOBJDIR= echo /error/ubix.own.mk/PRINTOBJDIR # avoid infinite recursion +.endif + +# +# Determine if running in the NetUBIX source tree by checking for the +# existence of build.sh and tools/ in the current or a parent directory, +# and setting _SRC_TOP_ to the result. +# +.if !defined(_SRC_TOP_) # { +_SRC_TOP_!= cd "${.CURDIR}"; while :; do \ + here=`pwd`; \ + [ -f build.sh ] && [ -d tools ] && { echo $$here; break; }; \ + case $$here in /) echo ""; break;; esac; \ + cd ..; done + +.MAKEOVERRIDES+= _SRC_TOP_ + +.endif # } + +# +# If _SRC_TOP_ != "", we're within the NetUBIX source tree. +# * Set defaults for UBIXSRCDIR and _SRC_TOP_OBJ_. +# * Define _UBIX_VERSION_DEPENDS. Targets that depend on the +# NetUBIX version, or on variables defined at build time, can +# declare a dependency on ${_UBIX_VERSION_DEPENDS}. +# +.if (${_SRC_TOP_} != "") # { + +UBIXSRCDIR?= ${_SRC_TOP_} + +.if !defined(_SRC_TOP_OBJ_) +_SRC_TOP_OBJ_!= cd "${_SRC_TOP_}" && ${PRINTOBJDIR} +.MAKEOVERRIDES+= _SRC_TOP_OBJ_ +.endif + +_UBIX_VERSION_DEPENDS= ${_SRC_TOP_OBJ_}/params +_UBIX_VERSION_DEPENDS+= ${UBIXSRCDIR}/sys/sys/param.h +_UBIX_VERSION_DEPENDS+= ${UBIXSRCDIR}/sys/conf/newvers.sh +_UBIX_VERSION_DEPENDS+= ${UBIXSRCDIR}/sys/conf/osrelease.sh +${_SRC_TOP_OBJ_}/params: .NOTMAIN .OPTIONAL # created by top level "make build" + +.endif # _SRC_TOP_ != "" # } + + +.if (${_SRC_TOP_} != "") && \ + (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)) +USETOOLS?= yes +.endif +USETOOLS?= no + + +.if ${MACHINE_ARCH} == "mips" || ${MACHINE_ARCH} == "mips64" || \ + ${MACHINE_ARCH} == "sh3" +.BEGIN: + @echo "Must set MACHINE_ARCH to one of ${MACHINE_ARCH}eb or ${MACHINE_ARCH}el" + @false +.elif defined(REQUIRETOOLS) && \ + (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)) && \ + ${USETOOLS} == "no" +.BEGIN: + @echo "USETOOLS=no, but this component requires a version-specific host toolchain" + @false +.endif + +# +# Host platform information; may be overridden +# +.include + +.if ${USETOOLS} == "yes" # { + +# +# Provide a default for TOOLDIR. +# +.if !defined(TOOLDIR) +TOOLDIR:= ${_SRC_TOP_OBJ_}/tooldir.${HOST_OSTYPE} +.MAKEOVERRIDES+= TOOLDIR +.endif + +# +# This is the prefix used for the NetUBIX-sourced tools. +# +_TOOL_PREFIX?= nb + +# +# If an external toolchain base is specified, use it. +# +.if defined(EXTERNAL_TOOLCHAIN) # { +AR= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ar +AS= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-as +LD= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ld +NM= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-nm +OBJCOPY= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objcopy +OBJDUMP= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objdump +RANLIB= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ranlib +READELF= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-readelf +SIZE= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-size +STRINGS= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-strings +STRIP= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-strip + +TOOL_CC.gcc= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc +TOOL_CPP.gcc= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-cpp +TOOL_CXX.gcc= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-c++ +TOOL_FC.gcc= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-g77 +TOOL_OBJC.gcc= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc + +TOOL_CC.clang= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang +TOOL_CPP.clang= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang-cpp +TOOL_CXX.clang= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang++ +TOOL_OBJC.clang= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang +TOOL_OPT.clang= ${EXTERNAL_TOOLCHAIN}/bin/opt +TOOL_LLC.clang= ${EXTERNAL_TOOLCHAIN}/bin/llc +.else # } { +# Define default locations for common tools. +.if ${USETOOLS_BINUTILS:Uyes} == "yes" # { +AR= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ar +AS= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-as +LD= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ld +NM= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-nm +OBJCOPY= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objcopy +OBJDUMP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objdump +RANLIB= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ranlib +READELF= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-readelf +SIZE= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-size +STRINGS= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strings +STRIP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strip + +# GCC supports C, C++, Fortran and Objective C +TOOL_CC.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc +TOOL_CPP.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-cpp +TOOL_CXX.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-c++ +TOOL_FC.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-g77 +TOOL_OBJC.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc +.endif # } + +# Clang supports C, C++ and Objective C +TOOL_CC.clang= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang +TOOL_CPP.clang= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang-cpp +TOOL_CXX.clang= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang++ +TOOL_OBJC.clang= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang +TOOL_OPT.clang= ${TOOLDIR}/bin/opt +TOOL_LLC.clang= ${TOOLDIR}/bin/llc + +# PCC supports C and Fortran +TOOL_CC.pcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcc +TOOL_CPP.pcc= ${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-cpp +TOOL_CXX.pcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-p++ + +# +# Make sure DESTDIR is set, so that builds with these tools always +# get appropriate -nostdinc, -nostdlib, etc. handling. The default is +# , meaning start from /, the root directory. +# +DESTDIR?= + +.if !defined(HOSTPROG) && !defined(HOSTLIB) +. if ${DESTDIR} != "" +CPPFLAGS+= --sysroot=${DESTDIR} +LDFLAGS+= --sysroot=${DESTDIR} +. else +CPPFLAGS+= --sysroot=/ +LDFLAGS+= --sysroot=/ +. endif +.endif +.endif # EXTERNAL_TOOLCHAIN # } + +DBSYM= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-dbsym +ELF2AOUT= ${TOOLDIR}/bin/${_TOOL_PREFIX}m68k-elf2aout +ELF2ECOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff +INSTALL= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-install +LEX= ${TOOLDIR}/bin/${_TOOL_PREFIX}lex +LINT= CC=${CC:Q} ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-lint +LORDER= NM=${NM:Q} MKTEMP=${TOOL_MKTEMP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}lorder +MKDEP= CC=${CC:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}mkdep +MKDEPCXX= CC=${CXX:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}mkdep +PAXCTL= ${TOOLDIR}/bin/${_TOOL_PREFIX}paxctl +TSORT= ${TOOLDIR}/bin/${_TOOL_PREFIX}tsort -q +YACC= ${TOOLDIR}/bin/${_TOOL_PREFIX}yacc + +TOOL_AMIGAAOUT2BB= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-aout2bb +TOOL_AMIGAELF2BB= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-elf2bb +TOOL_AMIGATXLT= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-txlt +TOOL_ASN1_COMPILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}asn1_compile +TOOL_AWK= ${TOOLDIR}/bin/${_TOOL_PREFIX}awk +TOOL_CAP_MKDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}cap_mkdb +TOOL_CAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}cat +TOOL_CKSUM= ${TOOLDIR}/bin/${_TOOL_PREFIX}cksum +TOOL_CLANG_TBLGEN= ${TOOLDIR}/bin/${_TOOL_PREFIX}clang-tblgen +TOOL_COMPILE_ET= ${TOOLDIR}/bin/${_TOOL_PREFIX}compile_et +TOOL_CONFIG= ${TOOLDIR}/bin/${_TOOL_PREFIX}config +TOOL_CRUNCHGEN= MAKE=${.MAKE:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}crunchgen +TOOL_CTAGS= ${TOOLDIR}/bin/${_TOOL_PREFIX}ctags +TOOL_CTFCONVERT= ${TOOLDIR}/bin/${_TOOL_PREFIX}ctfconvert +TOOL_CTFMERGE= ${TOOLDIR}/bin/${_TOOL_PREFIX}ctfmerge +TOOL_DB= ${TOOLDIR}/bin/${_TOOL_PREFIX}db +TOOL_DISKLABEL= ${TOOLDIR}/bin/nbdisklabel +TOOL_EQN= ${TOOLDIR}/bin/${_TOOL_PREFIX}eqn +TOOL_FDISK= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-fdisk +TOOL_FGEN= ${TOOLDIR}/bin/${_TOOL_PREFIX}fgen +TOOL_GENASSYM= ${TOOLDIR}/bin/${_TOOL_PREFIX}genassym +TOOL_GENCAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}gencat +TOOL_GMAKE= ${TOOLDIR}/bin/${_TOOL_PREFIX}gmake +TOOL_GREP= ${TOOLDIR}/bin/${_TOOL_PREFIX}grep +TOOL_GROFF= PATH=${TOOLDIR}/lib/groff:$${PATH} ${TOOLDIR}/bin/${_TOOL_PREFIX}groff +TOOL_HEXDUMP= ${TOOLDIR}/bin/${_TOOL_PREFIX}hexdump +TOOL_HP300MKBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}hp300-mkboot +TOOL_HPPAMKBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}hppa-mkboot +TOOL_INDXBIB= ${TOOLDIR}/bin/${_TOOL_PREFIX}indxbib +TOOL_INSTALLBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}installboot +TOOL_INSTALL_INFO= ${TOOLDIR}/bin/${_TOOL_PREFIX}install-info +TOOL_JOIN= ${TOOLDIR}/bin/${_TOOL_PREFIX}join +TOOL_LLVM_TBLGEN= ${TOOLDIR}/bin/${_TOOL_PREFIX}llvm-tblgen +TOOL_M4= ${TOOLDIR}/bin/${_TOOL_PREFIX}m4 +TOOL_MACPPCFIXCOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}macppc-fixcoff +TOOL_MAKEFS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makefs +TOOL_MAKEINFO= ${TOOLDIR}/bin/${_TOOL_PREFIX}makeinfo +TOOL_MAKEKEYS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makekeys +TOOL_MAKESTRS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makestrs +TOOL_MAKEWHATIS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makewhatis +TOOL_MANDOC_ASCII= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tascii +TOOL_MANDOC_HTML= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Thtml +TOOL_MANDOC_LINT= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tlint +TOOL_MDSETIMAGE= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-mdsetimage +TOOL_MENUC= MENUDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}menuc +TOOL_M68KELF2AOUT= ${TOOLDIR}/bin/${_TOOL_PREFIX}m68k-elf2aout +TOOL_MIPSELF2ECOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff +TOOL_MKCSMAPPER= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkcsmapper +TOOL_MKESDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkesdb +TOOL_MKFSMFS= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkfs.mfs +TOOL_MKLOCALE= ${TOOLDIR}/bin/${_TOOL_PREFIX}mklocale +TOOL_MKMAGIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}file +TOOL_MKNOD= ${TOOLDIR}/bin/${_TOOL_PREFIX}mknod +TOOL_MKTEMP= ${TOOLDIR}/bin/${_TOOL_PREFIX}mktemp +TOOL_MKUBOOTIMAGE= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkubootimage +TOOL_ELFTOSB= ${TOOLDIR}/bin/${_TOOL_PREFIX}elftosb +TOOL_MSGC= MSGDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}msgc +TOOL_MTREE= ${TOOLDIR}/bin/${_TOOL_PREFIX}mtree +TOOL_NBPERF= ${TOOLDIR}/bin/${_TOOL_PREFIX}perf +TOOL_NCDCS= ${TOOLDIR}/bin/${_TOOL_PREFIX}ibmnws-ncdcs +TOOL_PAX= ${TOOLDIR}/bin/${_TOOL_PREFIX}pax +TOOL_PIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}pic +TOOL_PIGZ= ${TOOLDIR}/bin/${_TOOL_PREFIX}pigz +TOOL_PKG_CREATE= ${TOOLDIR}/bin/${_TOOL_PREFIX}pkg_create +TOOL_POWERPCMKBOOTIMAGE=${TOOLDIR}/bin/${_TOOL_PREFIX}powerpc-mkbootimage +TOOL_PWD_MKDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}pwd_mkdb +TOOL_REFER= ${TOOLDIR}/bin/${_TOOL_PREFIX}refer +TOOL_ROFF_ASCII= PATH=${TOOLDIR}/lib/groff:$${PATH} ${TOOLDIR}/bin/${_TOOL_PREFIX}nroff +TOOL_ROFF_DOCASCII= ${TOOL_GROFF} -Tascii +TOOL_ROFF_DOCHTML= ${TOOL_GROFF} -Thtml +TOOL_ROFF_DVI= ${TOOL_GROFF} -Tdvi +TOOL_ROFF_HTML= ${TOOL_GROFF} -Tlatin1 -mdoc2html +TOOL_ROFF_PS= ${TOOL_GROFF} -Tps +TOOL_ROFF_RAW= ${TOOL_GROFF} -Z +TOOL_RPCGEN= RPCGEN_CPP=${CPP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}rpcgen +TOOL_SED= ${TOOLDIR}/bin/${_TOOL_PREFIX}sed +TOOL_SLC= ${TOOLDIR}/bin/${_TOOL_PREFIX}slc +TOOL_SOELIM= ${TOOLDIR}/bin/${_TOOL_PREFIX}soelim +TOOL_SPARKCRC= ${TOOLDIR}/bin/${_TOOL_PREFIX}sparkcrc +TOOL_STAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}stat +TOOL_STRFILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}strfile +TOOL_SUNLABEL= ${TOOLDIR}/bin/${_TOOL_PREFIX}sunlabel +TOOL_TBL= ${TOOLDIR}/bin/${_TOOL_PREFIX}tbl +TOOL_TIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}tic +TOOL_TOPROTO= ${TOOLDIR}/bin/${_TOOL_PREFIX}toproto +TOOL_UUDECODE= ${TOOLDIR}/bin/${_TOOL_PREFIX}uudecode +TOOL_VGRIND= ${TOOLDIR}/bin/${_TOOL_PREFIX}vgrind -f +TOOL_VFONTEDPR= ${TOOLDIR}/libexec/${_TOOL_PREFIX}vfontedpr +TOOL_ZIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}zic + +.else # USETOOLS != yes # } { + +# Clang supports C, C++ and Objective C +TOOL_CC.clang= clang +.if defined(__MINIX) +TOOL_CPP.clang= clang -E +.else +TOOL_CPP.clang= clang-cpp +.endif # defined(__MINIX) +TOOL_CXX.clang= clang++ +TOOL_OBJC.clang= clang +TOOL_OPT.clang= opt +TOOL_LLC.clang= llc + +# GCC supports C, C++, Fortran and Objective C +TOOL_CC.gcc= gcc +TOOL_CPP.gcc= cpp +TOOL_CXX.gcc= c++ +TOOL_FC.gcc= g77 +TOOL_OBJC.gcc= gcc + +# PCC supports C and Fortran +TOOL_CC.pcc= pcc +TOOL_CPP.pcc= /usr/libexec/pcpp +TOOL_CXX.pcc= p++ + +TOOL_AMIGAAOUT2BB= amiga-aout2bb +TOOL_AMIGAELF2BB= amiga-elf2bb +TOOL_AMIGATXLT= amiga-txlt +TOOL_ASN1_COMPILE= asn1_compile +TOOL_AWK= awk +TOOL_CAP_MKDB= cap_mkdb +TOOL_CAT= cat +TOOL_CKSUM= cksum +.if defined(__MINIX) +# LSC: A full path has to be provided, as this is also used as a make +# target. +. if exists(/usr/pkg/bin/clang-tblgen) +TOOL_CLANG_TBLGEN= /usr/pkg/bin/clang-tblgen +. else +TOOL_CLANG_TBLGEN= /usr/bin/clang-tblgen +. endif # exists(/usr/pkg/bin/clang-tblgen) +.else +TOOL_CLANG_TBLGEN= clang-tblgen +.endif # defined(__MINIX) +TOOL_COMPILE_ET= compile_et +TOOL_CONFIG= config +TOOL_CRUNCHGEN= crunchgen +TOOL_CTAGS= ctags +TOOL_CTFCONVERT= ctfconvert +TOOL_CTFMERGE= ctfmerge +TOOL_DB= db +TOOL_DISKLABEL= disklabel +TOOL_EQN= eqn +TOOL_FDISK= fdisk +TOOL_FGEN= fgen +TOOL_GENASSYM= genassym +TOOL_GENCAT= gencat +TOOL_GMAKE= gmake +TOOL_GREP= grep +TOOL_GROFF= groff +TOOL_HEXDUMP= hexdump +TOOL_HP300MKBOOT= hp300-mkboot +TOOL_HPPAMKBOOT= hppa-mkboot +TOOL_INDXBIB= indxbib +TOOL_INSTALLBOOT= installboot +TOOL_INSTALL_INFO= install-info +TOOL_JOIN= join +.if defined(__MINIX) +# LSC: A full path has to be provided, as this is also used as a make +# target. +. if exists(/usr/pkg/bin/llvm-tblgen) +TOOL_LLVM_TBLGEN= /usr/pkg/bin/llvm-tblgen +. else +TOOL_LLVM_TBLGEN= /usr/bin/llvm-tblgen +. endif # exists(/usr/pkg/bin/llvm-tblgen) +.else +TOOL_LLVM_TBLGEN= llvm-tblgen +.endif # defined(__MINIX) +TOOL_M4= m4 +TOOL_MACPPCFIXCOFF= macppc-fixcoff +TOOL_MAKEFS= makefs +TOOL_MAKEINFO= makeinfo +.if defined(__MINIX) +# LSC: A full path has to be provided, as this is also used as a make +# target. +TOOL_MAKEKEYS= /usr/X11R7/bin/makekeys +.else +TOOL_MAKEKEYS= makekeys +.endif # defined(__MINIX) +.if defined(__MINIX) +# LSC: A full path has to be provided, as this is also used as a make +# target. +TOOL_MAKESTRS= /usr/X11R7/bin/makestrs +.else +TOOL_MAKESTRS= makestrs +.endif # defined(__MINIX) +TOOL_MAKEWHATIS= /usr/libexec/makewhatis +TOOL_MANDOC_ASCII= mandoc -Tascii +TOOL_MANDOC_HTML= mandoc -Thtml +TOOL_MANDOC_LINT= mandoc -Tlint +TOOL_MDSETIMAGE= mdsetimage +TOOL_MENUC= menuc +TOOL_M68KELF2AOUT= m68k-elf2aout +TOOL_MIPSELF2ECOFF= mips-elf2ecoff +TOOL_MKCSMAPPER= mkcsmapper +TOOL_MKESDB= mkesdb +TOOL_MKFSMFS= mkfs.mfs +TOOL_MKLOCALE= mklocale +TOOL_MKMAGIC= file +TOOL_MKNOD= mknod +TOOL_MKTEMP= mktemp +TOOL_MKUBOOTIMAGE= mkubootimage +TOOL_ELFTOSB= elftosb +TOOL_MSGC= msgc +TOOL_MTREE= mtree +TOOL_NBPERF= nbperf +TOOL_NCDCS= ncdcs +TOOL_PAX= pax +TOOL_PIC= pic +TOOL_PIGZ= pigz +TOOL_PKG_CREATE= pkg_create +TOOL_POWERPCMKBOOTIMAGE= powerpc-mkbootimage +TOOL_PWD_MKDB= pwd_mkdb +TOOL_REFER= refer +TOOL_ROFF_ASCII= nroff +TOOL_ROFF_DOCASCII= ${TOOL_GROFF} -Tascii +TOOL_ROFF_DOCHTML= ${TOOL_GROFF} -Thtml +TOOL_ROFF_DVI= ${TOOL_GROFF} -Tdvi +TOOL_ROFF_HTML= ${TOOL_GROFF} -Tlatin1 -mdoc2html +TOOL_ROFF_PS= ${TOOL_GROFF} -Tps +TOOL_ROFF_RAW= ${TOOL_GROFF} -Z +TOOL_RPCGEN= rpcgen +TOOL_SED= sed +TOOL_SOELIM= soelim +TOOL_SPARKCRC= sparkcrc +TOOL_STAT= stat +.if defined(__MINIX) +TOOL_STRFILE= /usr/games/strfile +.else +TOOL_STRFILE= strfile +.endif # defined(__MINIX) +TOOL_SUNLABEL= sunlabel +TOOL_TBL= tbl +.if defined(__MINIX) +# LSC: There is a tic packaged, which has a completly different set of +# options, so make sure to use the base system one, always. +TOOL_TIC= /usr/bin/tic +.else +TOOL_TIC= tic +.endif # defined(__MINIX) +TOOL_TOPROTO= toproto +TOOL_UUDECODE= uudecode +TOOL_VGRIND= vgrind -f +TOOL_VFONTEDPR= /usr/libexec/vfontedpr +TOOL_ZIC= zic + +.endif # USETOOLS != yes # } + +# Fallback to ensure that all variables are defined to something +TOOL_CC.false= false +TOOL_CPP.false= false +TOOL_CXX.false= false +TOOL_FC.false= false +TOOL_OBJC.false= false +TOOL_OPT.false= false +TOOL_LLC.false= false + +AVAILABLE_COMPILER?= ${HAVE_PCC:Dpcc} ${HAVE_LLVM:Dclang} ${HAVE_GCC:Dgcc} ${EXTERNAL_TOOLCHAIN:Dgcc} false + +.for _t in CC CPP CXX FC OBJC OPT LLC +ACTIVE_${_t}= ${AVAILABLE_COMPILER:@.c.@ ${ !defined(UNSUPPORTED_COMPILER.${.c.}) && defined(TOOL_${_t}.${.c.}) :? ${.c.} : }@:[1]} +SUPPORTED_${_t}=${AVAILABLE_COMPILER:Nfalse:@.c.@ ${ !defined(UNSUPPORTED_COMPILER.${.c.}) && defined(TOOL_${_t}.${.c.}) :? ${.c.} : }@} +.endfor +# make bugs prevent moving this into the .for loop +CC= ${TOOL_CC.${ACTIVE_CC}} +CPP= ${TOOL_CPP.${ACTIVE_CPP}} +CXX= ${TOOL_CXX.${ACTIVE_CXX}} +FC= ${TOOL_FC.${ACTIVE_FC}} +OBJC= ${TOOL_OBJC.${ACTIVE_OBJC}} +OPT= ${TOOL_OPT.${ACTIVE_OPT}} +LLC= ${TOOL_LLC.${ACTIVE_LLC}} + +# Override with tools versions if needed +.if ${MKCTF:Uno} != "no" && !defined(NOCTF) +CTFCONVERT= ${TOOL_CTFCONVERT} +CTFMERGE= ${TOOL_CTFMERGE} +.endif + +# For each ${MACHINE_CPU}, list the ports that use it. +MACHINES.aarch64= evbarm64 +MACHINES.alpha= alpha +MACHINES.arm= acorn26 acorn32 cats epoc32 evbarm hpcarm \ + iyonix netwinder shark zaurus +MACHINES.coldfire= evbcf +MACHINES.i386= i386 +MACHINES.ia64= ia64 +MACHINES.hppa= hppa +MACHINES.m68000= sun2 +MACHINES.m68k= amiga atari cesfic hp300 luna68k mac68k \ + news68k next68k sun3 x68k +MACHINES.mips= arc cobalt algor cobalt emips evbmips ews4800mips \ + hpcmips mipsco newsmips pmax sbmips sgimips +MACHINES.or1k= or1k +MACHINES.powerpc= amigappc bebox evbppc ibmnws macppc mvmeppc \ + ofppc prep rs6000 sandpoint +MACHINES.riscv= riscv +MACHINES.sh3= dreamcast evbsh3 hpcsh landisk mmeye +MACHINES.sparc= sparc sparc64 +MACHINES.sparc64= sparc64 +MACHINES.vax= vax +MACHINES.x86_64= amd64 + +# for crunchide & ldd, define the OBJECT_FMTS used by a MACHINE_ARCH +# +OBJECT_FMTS= +.if ${MACHINE_ARCH} != "alpha" +OBJECT_FMTS+= elf32 +.endif +.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH:M*64*} != "" +OBJECT_FMTS+= elf64 +.endif + +# OBJCOPY flags to create a.out binaries for old firmware +# shared among src/distrib and ${MACHINE}/conf/Makefile.${MACHINE}.inc +.if ${MACHINE_CPU} == "arm" +OBJCOPY_ELF2AOUT_FLAGS?= \ + -O a.out-arm-netubix \ + -R .ident \ + -R .ARM.attributes \ + -R .ARM.exidx \ + -R .ARM.extab \ + -R .arm.atpcs \ + -R .comment \ + -R .debug_abbrev \ + -R .debug_aranges \ + -R .debug_info \ + -R .debug_line \ + -R .debug_frame \ + -R .debug_loc \ + -R .debug_pubnames \ + -R .debug_pubtypes \ + -R .debug_ranges \ + -R .debug_str \ + -R .eh_frame \ + -R .note.netubix.ident +.endif + +# +# Targets to check if DESTDIR or RELEASEDIR is provided +# +.if !target(check_DESTDIR) +check_DESTDIR: .PHONY .NOTMAIN +.if !defined(DESTDIR) + @echo "setenv DESTDIR before doing that!" + @false +.else + @true +.endif +.endif + +.if !target(check_RELEASEDIR) +check_RELEASEDIR: .PHONY .NOTMAIN +.if !defined(RELEASEDIR) + @echo "setenv RELEASEDIR before doing that!" + @false +.else + @true +.endif +.endif + +# +# Build a dynamically linked /bin and /sbin, with the necessary shared +# libraries moved from /usr/lib to /lib and the shared linker moved +# from /usr/libexec to /lib +# +# Note that if the BINDIR is not /bin or /sbin, then we always use the +# non-DYNAMICROOT behavior (i.e. it is only enabled for programs in /bin +# and /sbin). See . +# +MKDYNAMICROOT?= yes + +# +# Where the system object and source trees are kept; can be configurable +# by the user in case they want them in ~/foosrc and ~/fooobj (for example). +# +UBIXSRCDIR?= /usr/src +UBIXOBJDIR?= /usr/obj +UBIXSRCDIR?= ${UBIXSRCDIR} + +BINGRP?= wheel +BINOWN?= root +BINMODE?= 555 +NONBINMODE?= 444 + +# These are here mainly because we don't want suid root in case +# a Makefile defines BINMODE. +RUMPBINGRP?= wheel +RUMPBINOWN?= root +RUMPBINMODE?= 555 +RUMPNONBINMODE?=444 + +MANDIR?= /usr/share/man +MANGRP?= wheel +MANOWN?= root +MANMODE?= ${NONBINMODE} +MANINSTALL?= ${_MANINSTALL} + +INFODIR?= /usr/share/info +INFOGRP?= wheel +INFOOWN?= root +INFOMODE?= ${NONBINMODE} + +LIBDIR?= /usr/lib + +LINTLIBDIR?= /usr/libdata/lint +LIBGRP?= ${BINGRP} +LIBOWN?= ${BINOWN} +LIBMODE?= ${NONBINMODE} + +DOCDIR?= /usr/share/doc +DOCGRP?= wheel +DOCOWN?= root +DOCMODE?= ${NONBINMODE} + +NLSDIR?= /usr/share/nls +NLSGRP?= wheel +NLSOWN?= root +NLSMODE?= ${NONBINMODE} + +KMODULEGRP?= wheel +KMODULEOWN?= root +KMODULEMODE?= ${NONBINMODE} + +LOCALEDIR?= /usr/share/locale +LOCALEGRP?= wheel +LOCALEOWN?= root +LOCALEMODE?= ${NONBINMODE} + +FIRMWAREDIR?= /libdata/firmware +FIRMWAREGRP?= wheel +FIRMWAREOWN?= root +FIRMWAREMODE?= ${NONBINMODE} + +DEBUGDIR?= /usr/libdata/debug +DEBUGGRP?= wheel +DEBUGOWN?= root +DEBUGMODE?= ${NONBINMODE} + +# +# Data-driven table using make variables to control how +# toolchain-dependent targets and shared libraries are built +# for different platforms and object formats. +# +# OBJECT_FMT: currently either "ELF" or "a.out". +# +# All platforms are ELF. +# +OBJECT_FMT= ELF + +# +# If this platform's toolchain is missing, we obviously cannot build it. +# +.if ${TOOLCHAIN_MISSING} != "no" +MKBINUTILS:= no +MKGDB:= no +MKGCC:= no +.endif + +# +# If we are using an external toolchain, we can still build the target's +# binutils, but we cannot build GCC's support libraries, since those are +# tightly-coupled to the version of GCC being used. +# +.if defined(EXTERNAL_TOOLCHAIN) +MKGCC:= no +.endif + +# No GDB support for aarch64 +MKGDB.aarch64= no +MKGDB.or1k= no +MKGDB.riscv32= no +MKGDB.riscv64= no + +# No kernel modules for or1k (yet) +MKKMOD.or1k= no +MKKMOD.riscv32= no +MKKMOD.riscv64= no + +# No profiling for or1k (yet) +MKPROFILE.or1k= no +MKPROFILE.riscv32=no +MKPROFILE.riscv64=no + +# +# The m68000 port is incomplete. +# +.if ${MACHINE_ARCH} == "m68000" +NOPIC= # defined +MKISCSI= no +# XXX GCC 4 outputs mcount() calling sequences that try to load values +# from over 64KB away and this fails to assemble. +.if defined(HAVE_GCC) +NOPROFILE= # defined +.endif +.endif + +# +# The ia64 port is incomplete. +# +MKLINT.ia64= no +MKGDB.ia64= no + +# +# On the MIPS, all libs are compiled with ABIcalls (and are thus PIC), +# not just shared libraries, so don't build the _pic version. +# +.if ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \ + ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb" +MKPICLIB:= no +.endif + +# PowerPC64 and AArch64 ABI's are PIC +MKPICLIB.powerpc64= no +#MKPICLIB.aarch64= no + +# +# On VAX using ELF, all objects are PIC, not just shared libraries, +# so don't build the _pic version. +# +MKPICLIB.vax= no + +# +# Location of the file that contains the major and minor numbers of the +# version of a shared library. If this file exists a shared library +# will be built by . +# +SHLIB_VERSION_FILE?= ${.CURDIR}/shlib_version + +# +# GNU sources and packages sometimes see architecture names differently. +# +GNU_ARCH.aarch64eb=aarch64_be +GNU_ARCH.coldfire=m5407 +GNU_ARCH.earm=arm +GNU_ARCH.earmhf=arm +GNU_ARCH.earmeb=armeb +GNU_ARCH.earmhfeb=armeb +GNU_ARCH.earmv4=armv4 +GNU_ARCH.earmv4eb=armv4eb +GNU_ARCH.earmv5=arm +GNU_ARCH.earmv5eb=armeb +GNU_ARCH.earmv6=armv6 +GNU_ARCH.earmv6hf=armv6 +GNU_ARCH.earmv6eb=armv6eb +GNU_ARCH.earmv6hfeb=armv6eb +GNU_ARCH.earmv7=armv7 +GNU_ARCH.earmv7hf=armv7 +GNU_ARCH.earmv7eb=armv7eb +GNU_ARCH.earmv7hfeb=armv7eb +GNU_ARCH.i386=i486 +GCC_CONFIG_ARCH.i386=i486 +GCC_CONFIG_TUNE.i386=nocona +GCC_CONFIG_TUNE.x86_64=nocona +GNU_ARCH.m68000=m68010 +GNU_ARCH.sh3eb=sh +GNU_ARCH.sh3el=shle +GNU_ARCH.mips64eb=mips64 + +.if defined(__MINIX) +# MINIX/arm default +GCC_CONFIG_ARCH.earm=armv7-a + +# MINIX/intel default +GNU_ARCH.i386=i586 +GCC_CONFIG_ARCH.i386=i586 + +.endif # defined(__MINIX) + +MACHINE_GNU_ARCH=${GNU_ARCH.${MACHINE_ARCH}:U${MACHINE_ARCH}} + +# +# In order to identify NetUBIX to GNU packages, we sometimes need +# an "elf" tag for historically a.out platforms. +# +.if (!empty(MACHINE_ARCH:Mearm*)) +MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netubixelf-${MACHINE_ARCH:C/eb//:C/v[4-7]//:S/earm/eabi/} +.elif (${MACHINE_GNU_ARCH} == "arm" || \ + ${MACHINE_GNU_ARCH} == "armeb" || \ + ${MACHINE_ARCH} == "i386" || \ + ${MACHINE_CPU} == "m68k" || \ + ${MACHINE_GNU_ARCH} == "sh" || \ + ${MACHINE_GNU_ARCH} == "shle" || \ + ${MACHINE_ARCH} == "sparc" || \ + ${MACHINE_ARCH} == "vax") +MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netubixelf +.else +MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netubix +.endif + +.if defined(__MINIX) +# We have a simpler toolchain naming scheme +MACHINE_GNU_PLATFORM:=${MACHINE_GNU_ARCH}-elf32-minix + +# We need to check for HAVE_GOLD after LD has been set +. if ${_HAVE_GOLD:U} == "" + _HAVE_GOLD!= (exec 2>&1; ${LD} --version || echo "") + _GOLD_MATCH:=${_HAVE_GOLD:Mgold} + _HAVE_GOLD:= ${_HAVE_GOLD:M[0-9]\.[0-9][0-9]} + +. if ${_GOLD_MATCH} != "" && ${_HAVE_GOLD} != "" + HAVE_GOLD?= ${_HAVE_GOLD} + +# Without -Wl,--no-ctors-in-init-array, gold moves the constructors out of +# .ctors into .init_array, which is bad on intel. + LDFLAGS+= -Wl,--no-ctors-in-init-array +. else + USE_BITCODE:=no +. endif +. endif # ${_HAVE_GOLD:U} == "" +.endif # defined(__MINIX) + +.if !empty(MACHINE_ARCH:M*arm*) +# Flags to pass to CC for using the old APCS ABI on ARM for compat or stand. +ARM_APCS_FLAGS= -mabi=apcs-gnu -mfloat-abi=soft +ARM_APCS_FLAGS+=${${ACTIVE_CC} == "gcc":? -marm :} +ARM_APCS_FLAGS+=${${ACTIVE_CC} == "clang":? -target ${MACHINE_GNU_ARCH}--netubixelf -B ${TOOLDIR}/${MACHINE_GNU_PLATFORM}/bin :} +.endif + +GENASSYM_CPPFLAGS+= ${${ACTIVE_CC} == "clang":? -no-integrated-as :} + +TARGETS+= all clean cleandir depend dependall includes \ + install lint obj regress tags html analyze +PHONY_NOTMAIN = all clean cleandir depend dependall distclean includes \ + install lint obj regress beforedepend afterdepend \ + beforeinstall afterinstall realinstall realdepend realall \ + html subdir-all subdir-install subdir-depend analyze +.PHONY: ${PHONY_NOTMAIN} +.NOTMAIN: ${PHONY_NOTMAIN} + +.if ${NEED_OWN_INSTALL_TARGET} != "no" +.if !target(install) +install: beforeinstall .WAIT subdir-install realinstall .WAIT afterinstall +beforeinstall: +subdir-install: +realinstall: +afterinstall: +.endif +all: realall subdir-all +subdir-all: +realall: +depend: realdepend subdir-depend +subdir-depend: +realdepend: +distclean: cleandir +cleandir: clean + +dependall: .NOTMAIN realdepend .MAKE + @cd "${.CURDIR}"; ${MAKE} realall +.endif + +# +# Define MKxxx variables (which are either yes or no) for users +# to set in /etc/mk.conf and override in the make environment. +# These should be tested with `== "no"' or `!= "no"'. +# The NOxxx variables should only be set by Makefiles. +# +# Please keep etc/Makefile and share/man/man5/mk.conf.5 in sync +# with changes to the MK* variables here. +# + +# +# Supported NO* options (if defined, MK* will be forced to "no", +# regardless of user's mk.conf setting). +# +# Source makefiles should set NO*, and not MK*, and must do so before +# including ubix.own.mk. +# +.for var in \ + NOCRYPTO NODOC NOHTML NOINFO NOLINKLIB NOLINT NOMAN NONLS NOOBJ NOPIC \ + NOPICINSTALL NOPROFILE NOSHARE NOSTATICLIB +.if defined(${var}) +MK${var:S/^NO//}:= no +.endif +.endfor + +# +# Older-style variables that enabled behaviour when set. +# +.for var in MANZ UNPRIVED UPDATE +.if defined(${var}) +MK${var}:= yes +.endif +.endfor + +# +# MK* options which have variable defaults. +# +.if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "sparc64" \ + || ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el" \ + || ${MACHINE_ARCH} == "powerpc64" || ${MACHINE_CPU} == "aarch64" \ + || ${MACHINE_ARCH} == "riscv64" \ + || !empty(MACHINE_ARCH:Mearm*) +MKCOMPAT?= yes +.else +# Don't let this build where it really isn't supported. +MKCOMPAT:= no +MKCOMPATTESTS:= no +MKCOMPATX11:= no +.endif + +.if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "i386" \ + || ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el" \ + || (${MACHINE} == "evbppc" && ${MACHINE_ARCH} == "powerpc") +MKCOMPATMODULES?= yes +.else +MKCOMPATMODULES:= no +.endif + +# +# Default mips64 to softfloat now. +# arm is always softfloat unless it isn't +# emips is always softfloat. +# coldfire is always softfloat +# or1k is always softfloat +# +.if ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el" || \ + (${MACHINE_CPU} == "arm" && ${MACHINE_ARCH:M*hf*} == "") || \ + ${MACHINE_ARCH} == "coldfire" || ${MACHINE_CPU} == "or1k" || \ + ${MACHINE} == "emips" +MKSOFTFLOAT?= yes +.endif + +.if ${MACHINE} == "emips" +SOFTFLOAT_BITS= 32 +.endif + +.if ${MACHINE_ARCH} == "i386" || \ + ${MACHINE_ARCH} == "x86_64" || \ + ${MACHINE_ARCH} == "sparc" +MKSLJIT?= yes +.else +MKSLJIT?= no +.endif + +# +# MK* backward compatibility. +# +.if defined(MKBFD) +MKBINUTILS?= ${MKBFD} +.endif + +# +# We want to build zfs only for amd64 by default for now. +# +.if ${MACHINE} == "amd64" +MKZFS?= yes +.endif + +# +# MK* options which default to "yes". +# +_MKVARS.yes= \ + MKATF \ + MKBINUTILS \ + MKCRYPTO MKCOMPLEX MKCVS MKCXX \ + MKDOC \ + MKGCC MKGDB MKGROFF \ + MKHESIOD MKHTML \ + MKIEEEFP MKINET6 MKINFO MKIPFILTER MKISCSI \ + MKKERBEROS \ + MKKMOD \ + MKLDAP MKLIBSTDCXX MKLINKLIB MKLVM \ + MKMAN MKMANDOC \ + MKMDNS \ + MKMAKEMANDB \ + MKNLS \ + MKNPF \ + MKOBJ \ + MKPAM MKPERFUSE \ + MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX MKPROFILE \ + MKRUMP \ + MKSHARE MKSKEY MKSTATICLIB \ + MKX11FONTS \ + MKYP + +#MINIX-specific vars +_MKVARS.yes+= \ + MKSYSDEBUG MKLIVEUPDATE MKLLVMCMDS +.if (${MACHINE_ARCH} == "i386") +_MKVARS.yes+= \ + MKWATCHDOG MKACPI MKAPIC MKDEBUGREG MKINSTALLBOOT MKPCI +.endif + +.for var in ${_MKVARS.yes} +${var}?= ${${var}.${MACHINE_ARCH}:Uyes} +.endfor + +# +# MKGCCCMDS is only valid if we are building GCC so make it dependent on that. +# +_MKVARS.yes += MKGCCCMDS +MKGCCCMDS?= ${MKGCC} + +# +# Exceptions to the above: +# +.if ${MACHINE} == "acorn26" # page size is prohibitive +MKKMOD= no +.endif + +# +# MK* options which default to "no". Note that MKZFS has a different +# default for some platforms, see above. +# +_MKVARS.no= \ + MKUBIXGREP MKUBIXTAR \ + MKCATPAGES MKCOMPATTESTS MKCOMPATX11 MKCRYPTO_RC5 MKCTF MKDEBUG \ + MKDEBUGLIB MKDTRACE MKEXTSRC MKGROFFHTMLDOC \ + MKKYUA MKLLD MKLLDB MKLINT \ + MKMANZ MKMCLINKER MKOBJDIRS \ + MKLIBCXX MKLLVM MKPCC \ + MKPIGZGZIP \ + MKREPRO \ + MKSOFTFLOAT MKSTRIPIDENT MKTPM \ + MKUNPRIVED MKUPDATE MKX11 MKX11MOTIF MKZFS + +#MINIX-specific vars +_MKVARS.no+= \ + MKIMAGEONLY MKSMALL MKBITCODE MKMAGIC MKPAE MKASR MKSRC +.if !empty(MACHINE_ARCH:Mearm*) +_MKVARS.no+= \ + MKWATCHDOG MKPAE MKACPI MKAPIC MKDEBUGREG MKINSTALLBOOT MKPCI +.endif + +.for var in ${_MKVARS.no} +${var}?= ${${var}.${MACHINE_ARCH}:Uno} +.endfor + +# +# Which platforms build the xorg-server drivers (as opposed +# to just Xnest and Xvfb.) +# +.if ${MACHINE} == "alpha" || \ + ${MACHINE} == "amd64" || \ + ${MACHINE} == "bebox" || \ + ${MACHINE} == "cats" || \ + ${MACHINE} == "dreamcast" || \ + ${MACHINE} == "ews4800mips" || \ + ${MACHINE} == "evbarm" || \ + ${MACHINE} == "evbmips" || \ + ${MACHINE} == "hp300" || \ + ${MACHINE} == "hpcarm" || \ + ${MACHINE} == "hpcmips" || \ + ${MACHINE} == "hpcsh" || \ + ${MACHINE} == "i386" || \ + ${MACHINE} == "luna68k" || \ + ${MACHINE} == "mac68k" || \ + ${MACHINE} == "macppc" || \ + ${MACHINE} == "netwinder" || \ + ${MACHINE} == "newsmips" || \ + ${MACHINE} == "prep" || \ + ${MACHINE} == "ofppc" || \ + ${MACHINE} == "sgimips" || \ + ${MACHINE} == "shark" || \ + ${MACHINE} == "sparc" || \ + ${MACHINE} == "sparc64" || \ + ${MACHINE} == "vax" || \ + ${MACHINE} == "zaurus" +MKXORG_SERVER?=yes +.else +MKXORG_SERVER?=no +.endif + +# +# Force some options off if their dependencies are off. +# + +.if ${MKCXX} == "no" +MKATF:= no +MKGROFF:= no +MKKYUA:= no +.endif + +.if ${MKCRYPTO} == "no" +MKKERBEROS:= no +MKLDAP:= no +.endif + +.if ${MKMAN} == "no" +MKCATPAGES:= no +MKHTML:= no +.endif + +_MANINSTALL= maninstall +.if ${MKCATPAGES} != "no" +_MANINSTALL+= catinstall +.endif +.if ${MKHTML} != "no" +_MANINSTALL+= htmlinstall +.endif + +.if ${MKLINKLIB} == "no" +MKLINT:= no +MKPICINSTALL:= no +MKPROFILE:= no +.endif + +.if ${MKPIC} == "no" +MKPICLIB:= no +.endif + +.if ${MKOBJ} == "no" +MKOBJDIRS:= no +.endif + +.if ${MKSHARE} == "no" +MKCATPAGES:= no +MKDOC:= no +MKINFO:= no +MKHTML:= no +MKMAN:= no +MKNLS:= no +.endif + +# MINIX +.if ${MKSMALL} == "yes" +MKWATCHDOG:= no +MKACPI:= no +MKAPIC:= no +MKDEBUGREG:= no +MKSYSDEBUG:= no +MKLIVEUPDATE:= no +.endif + +# MINIX: MKASR implies MKMAGIC +.if ${MKASR} == "yes" +MKMAGIC:= yes +.endif + +# MINIX: MKMAGIC implies MKBITCODE +.if ${MKMAGIC} == "yes" +MKBITCODE:= yes +.endif + +.if !empty(MACHINE_ARCH:Mearm*) +_NEEDS_LIBCXX.${MACHINE_ARCH}= yes +.endif +_NEEDS_LIBCXX.i386= yes +_NEEDS_LIBCXX.powerpc= yes +_NEEDS_LIBCXX.powerpc64= yes +_NEEDS_LIBCXX.x86_64= yes +_NEEDS_LIBCXX.aarch64= yes + +.if ${MKLLVM} == "yes" && ${_NEEDS_LIBCXX.${MACHINE_ARCH}:Uno} == "yes" +MKLIBCXX:= yes +.endif + +# +# install(1) parameters. +# +COPY?= -c +.if ${MKUPDATE} == "no" +PRESERVE?= +.else +PRESERVE?= -p +.endif +RENAME?= -r +HRDLINK?= -l h +SYMLINK?= -l s + +METALOG?= ${DESTDIR}/METALOG +METALOG.add?= ${TOOL_CAT} -l >> ${METALOG} +.if (${_SRC_TOP_} != "") # only set INSTPRIV if inside ${UBIXSRCDIR} +.if ${MKUNPRIVED} != "no" +INSTPRIV.unpriv=-U -M ${METALOG} -D ${DESTDIR} -h sha256 +.else +INSTPRIV.unpriv= +.endif +INSTPRIV?= ${INSTPRIV.unpriv} -N ${UBIXSRCDIR}/etc +.endif +STRIPFLAG?= + +.if ${NEED_OWN_INSTALL_TARGET} != "no" +INSTALL_DIR?= ${INSTALL} ${INSTPRIV} -d +INSTALL_FILE?= ${INSTALL} ${INSTPRIV} ${COPY} ${PRESERVE} ${RENAME} +INSTALL_LINK?= ${INSTALL} ${INSTPRIV} ${HRDLINK} ${RENAME} +INSTALL_SYMLINK?= ${INSTALL} ${INSTPRIV} ${SYMLINK} ${RENAME} +.endif + +# +# Set defaults for the USE_xxx variables. +# + +# +# USE_* options which default to "no" and will be forced to "no" if their +# corresponding MK* variable is set to "no". +# +.for var in USE_SKEY +.if (${${var:S/USE_/MK/}} == "no") +${var}:= no +.else +${var}?= no +.endif +.endfor + +# +# USE_* options which default to "yes" unless their corresponding MK* +# variable is set to "no". +# +.for var in USE_HESIOD USE_INET6 USE_KERBEROS USE_LDAP USE_PAM USE_YP +.if (${${var:S/USE_/MK/}} == "no") +${var}:= no +.else +${var}?= yes +.endif +.endfor + +#MINIX-specific vars +.for var in \ + USE_WATCHDOG USE_ACPI USE_PAE USE_APIC USE_DEBUGREG USE_SYSDEBUG \ + USE_LIVEUPDATE USE_PCI USE_BITCODE USE_MAGIC USE_ASR +.if ${var:S/USE_/MK/} == "no" +${var}:= no +.else +${var}?= yes +.endif +.endfor + +# +# USE_* options which default to "yes". +# +.for var in USE_JEMALLOC +${var}?= yes +.endfor + +# +# USE_* options which default to "no". +# +# For now, disable pigz as compressor by default +.for var in USE_PIGZGZIP USE_LIBTRE +${var}?= no +.endfor + +# +# TOOL_GZIP and friends. These might refer to TOOL_PIGZ or to the host gzip. +# +.if ${USE_PIGZGZIP} != "no" +TOOL_GZIP= ${TOOL_PIGZ} +GZIP_N_FLAG?= -nT +.else +TOOL_GZIP= gzip +GZIP_N_FLAG?= -n +.endif +TOOL_GZIP_N= ${TOOL_GZIP} ${GZIP_N_FLAG} + +# +# Where X11 sources are and where it is installed to. +# +.if !defined(X11SRCDIR) +.if exists(${UBIXSRCDIR}/../xsrc) +X11SRCDIR!= cd "${UBIXSRCDIR}/../xsrc" && pwd +.else +X11SRCDIR= /usr/xsrc +.endif +.endif # !defined(X11SRCDIR) + +X11SRCDIR.local?= ${X11SRCDIR}/local +X11ROOTDIR?= /usr/X11R7 +X11BINDIR?= ${X11ROOTDIR}/bin +X11ETCDIR?= /etc/X11 +X11FONTDIR?= ${X11ROOTDIR}/lib/X11/fonts +X11INCDIR?= ${X11ROOTDIR}/include +X11LIBDIR?= ${X11ROOTDIR}/lib/X11 +X11MANDIR?= ${X11ROOTDIR}/man +X11SHAREDIR?= ${X11ROOTDIR}/share +X11USRLIBDIR?= ${X11ROOTDIR}/lib${MLIBDIR:D/${MLIBDIR}} + +# +# New modular-xorg based builds +# +X11SRCDIRMIT?= ${X11SRCDIR}/external/mit +.for _lib in \ + FS ICE SM X11 XScrnSaver XTrap Xau Xcomposite Xcursor Xdamage \ + Xdmcp Xevie Xext Xfixes Xfont Xft Xi Xinerama Xmu Xpresent Xpm \ + Xrandr Xrender Xres Xt Xtst Xv XvMC Xxf86dga Xxf86misc Xxf86vm drm \ + fontenc xkbfile xkbui Xaw Xfontcache pciaccess xcb \ + pthread-stubs +X11SRCDIR.${_lib}?= ${X11SRCDIRMIT}/lib${_lib}/dist +.endfor + +.for _proto in \ + xcmisc xext xf86bigfont bigreqs input kb x fonts fixes scrnsaver \ + xinerama dri2 dri3 render resource record video xf86dga xf86misc \ + xf86vidmode composite damage trap gl randr fontcache xf86dri \ + present xcb- +X11SRCDIR.${_proto}proto?= ${X11SRCDIRMIT}/${_proto}proto/dist +.endfor + +.for _dir in \ + xtrans fontconfig freetype evieext mkfontscale bdftopcf \ + xkbcomp xorg-cf-files imake xorg-server xbiff xkeyboard-config \ + xbitmaps appres xeyes xev xedit sessreg pixman \ + beforelight bitmap editres makedepend fonttosfnt fslsfonts fstobdf \ + glu glw mesa-demos MesaGLUT MesaLib MesaLib7 \ + ico iceauth listres lndir \ + luit xproxymanagementprotocol mkfontdir oclock proxymngr rgb \ + rstart setxkbmap showfont smproxy twm viewres \ + x11perf xauth xcalc xclipboard \ + xclock xcmsdb xconsole xditview xdpyinfo xdriinfo xdm \ + xfd xf86dga xfindproxy xfontsel xfwp xgamma xgc xhost xinit \ + xkill xload xlogo xlsatoms xlsclients xlsfonts xmag xmessage \ + xmh xmodmap xmore xman xprop xrandr xrdb xrefresh xset \ + xsetmode xsetpointer xsetroot xsm xstdcmap xvidtune xvinfo \ + xwininfo xwud xkbprint xkbevd \ + xterm xwd xfs xfsinfo xtrap xkbutils xkbcomp \ + xkeyboard-config xinput xcb-util xorg-docs \ + font-adobe-100dpi font-adobe-75dpi font-adobe-utopia-100dpi \ + font-adobe-utopia-75dpi font-adobe-utopia-type1 \ + font-alias \ + font-bh-100dpi font-bh-75dpi font-bh-lucidatypewriter-100dpi \ + font-bh-lucidatypewriter-75dpi font-bh-ttf font-bh-type1 \ + font-bitstream-100dpi font-bitstream-75dpi font-bitstream-type1 \ + font-cursor-misc font-daewoo-misc font-dec-misc font-ibm-type1 \ + font-isas-misc font-jis-misc font-misc-misc font-mutt-misc \ + font-sony-misc font-util ttf-bitstream-vera encodings +X11SRCDIR.${_dir}?= ${X11SRCDIRMIT}/${_dir}/dist +.endfor + +.for _i in \ + elographics keyboard mouse synaptics vmmouse void ws +X11SRCDIR.xf86-input-${_i}?= ${X11SRCDIRMIT}/xf86-input-${_i}/dist +.endfor + +.for _v in \ + ag10e apm ark ast ati ati-kms chips cirrus crime \ + geode glint i128 i740 igs imstt intel intel-old mach64 mga \ + neomagic newport nsc nv nvxbox openchrome pnozz \ + r128 radeonhd rendition \ + s3 s3virge savage siliconmotion sis suncg14 \ + suncg6 sunffb sunleo suntcx \ + tdfx tga trident tseng vesa vga vmware wsfb xgi +X11SRCDIR.xf86-video-${_v}?= ${X11SRCDIRMIT}/xf86-video-${_v}/dist +.endfor + +# Only install the radeon firmware on DRM-happy systems. +.if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "i386" +MKRADEONFIRMWARE?= yes +.endif +MKRADEONFIRMWARE?= no + +X11DRI?= yes +X11LOADABLE?= yes + + +# +# Where extsrc sources are and where it is installed to. +# +.if !defined(EXTSRCSRCDIR) +.if exists(${UBIXSRCDIR}/../extsrc) +EXTSRCSRCDIR!= cd "${UBIXSRCDIR}/../extsrc" && pwd +.else +EXTSRCSRCDIR= /usr/extsrc +.endif +.endif # !defined(EXTSRCSRCDIR) + +EXTSRCROOTDIR?= /usr/ext +EXTSRCBINDIR?= ${EXTSRCROOTDIR}/bin +EXTSRCETCDIR?= /etc/ext +EXTSRCINCDIR?= ${EXTSRCROOTDIR}/include +EXTSRCLIBDIR?= ${EXTSRCROOTDIR}/lib/ext +EXTSRCMANDIR?= ${EXTSRCROOTDIR}/man +EXTSRCUSRLIBDIR?= ${EXTSRCROOTDIR}/lib + +# +# MAKEDIRTARGET dir target [extra make(1) params] +# run "cd $${dir} && ${MAKEDIRTARGETENV} ${MAKE} [params] $${target}", with a pretty message +# +MAKEDIRTARGETENV?= +MAKEDIRTARGET=\ + @_makedirtarget() { \ + dir="$$1"; shift; \ + target="$$1"; shift; \ + case "$${dir}" in \ + /*) this="$${dir}/"; \ + real="$${dir}" ;; \ + .) this="${_THISDIR_}"; \ + real="${.CURDIR}" ;; \ + *) this="${_THISDIR_}$${dir}/"; \ + real="${.CURDIR}/$${dir}" ;; \ + esac; \ + show=$${this:-.}; \ + echo "$${target} ===> $${show%/}$${1:+ (with: $$@)}"; \ + cd "$${real}" \ + && ${MAKEDIRTARGETENV} ${MAKE} _THISDIR_="$${this}" "$$@" $${target}; \ + }; \ + _makedirtarget + +# +# MAKEVERBOSE support. Levels are: +# 0 Minimal output ("quiet") +# 1 Describe what is occurring +# 2 Describe what is occurring and echo the actual command +# 3 Ignore the effect of the "@" prefix in make commands +# 4 Trace shell commands using the shell's -x flag +# +MAKEVERBOSE?= 2 + +.if ${MAKEVERBOSE} == 0 +_MKMSG?= @\# +_MKSHMSG?= : echo +_MKSHECHO?= : echo +.SILENT: +.elif ${MAKEVERBOSE} == 1 +_MKMSG?= @echo ' ' +_MKSHMSG?= echo ' ' +_MKSHECHO?= : echo +.SILENT: +.else # MAKEVERBOSE >= 2 +_MKMSG?= @echo '\# ' +_MKSHMSG?= echo '\# ' +_MKSHECHO?= echo +.SILENT: __makeverbose_dummy_target__ +.endif # MAKEVERBOSE >= 2 +.if ${MAKEVERBOSE} >= 3 +.MAKEFLAGS: -dl +.endif # ${MAKEVERBOSE} >= 3 +.if ${MAKEVERBOSE} >= 4 +.MAKEFLAGS: -dx +.endif # ${MAKEVERBOSE} >= 4 + +_MKMSG_BUILD?= ${_MKMSG} " build " +_MKMSG_CREATE?= ${_MKMSG} " create " +_MKMSG_COMPILE?= ${_MKMSG} "compile " +_MKMSG_FORMAT?= ${_MKMSG} " format " +_MKMSG_INSTALL?= ${_MKMSG} "install " +_MKMSG_LINK?= ${_MKMSG} " link " +_MKMSG_LEX?= ${_MKMSG} " lex " +_MKMSG_REMOVE?= ${_MKMSG} " remove " +_MKMSG_YACC?= ${_MKMSG} " yacc " + +_MKSHMSG_CREATE?= ${_MKSHMSG} " create " +_MKSHMSG_INSTALL?= ${_MKSHMSG} "install " + +_MKTARGET_BUILD?= ${_MKMSG_BUILD} ${.CURDIR:T}/${.TARGET} +_MKTARGET_CREATE?= ${_MKMSG_CREATE} ${.CURDIR:T}/${.TARGET} +_MKTARGET_COMPILE?= ${_MKMSG_COMPILE} ${.CURDIR:T}/${.TARGET} +_MKTARGET_FORMAT?= ${_MKMSG_FORMAT} ${.CURDIR:T}/${.TARGET} +_MKTARGET_INSTALL?= ${_MKMSG_INSTALL} ${.TARGET} +_MKTARGET_LINK?= ${_MKMSG_LINK} ${.CURDIR:T}/${.TARGET} +_MKTARGET_LEX?= ${_MKMSG_LEX} ${.CURDIR:T}/${.TARGET} +_MKTARGET_REMOVE?= ${_MKMSG_REMOVE} ${.TARGET} +_MKTARGET_YACC?= ${_MKMSG_YACC} ${.CURDIR:T}/${.TARGET} + +.if ${MKMANDOC} == "yes" +TARGETS+= lintmanpages +.endif + +TESTSBASE= /usr/tests${MLIBDIR:D/${MLIBDIR}} + +.endif # !defined(_UBIX_OWN_MK_) diff --git a/src/share/mk/ubix.prog.mk b/src/share/mk/ubix.prog.mk new file mode 100644 index 0000000..af22409 --- /dev/null +++ b/src/share/mk/ubix.prog.mk @@ -0,0 +1,786 @@ +.ifndef HOSTPROG + +.include +.include +.include +.include + +# +# Definitions and targets shared among all programs built by a single +# Makefile. +# + +##### Basic targets +realinstall: proginstall scriptsinstall + +.gdbinit: + rm -f .gdbinit +.if defined(DESTDIR) && !empty(DESTDIR) + echo "set solib-absolute-prefix ${DESTDIR}" > .gdbinit +.else + touch .gdbinit +.endif +.for __gdbinit in ${GDBINIT} + echo "source ${__gdbinit}" >> .gdbinit +.endfor + +CLEANFILES+= a.out [Ee]rrs mklog core *.core .gdbinit + +.if defined(SHAREDSTRINGS) +CLEANFILES+=strings +.c.o: + ${CC} -E ${CPPFLAGS} ${CFLAGS} ${.IMPSRC} | xstr -c - + @${CC} ${CPPFLAGS} ${CFLAGS} -c x.c -o ${.TARGET} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif + @rm -f x.c + +.cc.o .cpp.o .cxx.o .C.o: + ${CXX} -E ${CPPFLAGS} ${CXXFLAGS} ${.IMPSRC} | xstr -c - + @mv -f x.c x.cc + @${CXX} ${CPPFLAGS} ${CXXFLAGS} -c x.cc -o ${.TARGET} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif + @rm -f x.cc +.endif + +.if defined(MKPIE) && (${MKPIE} != "no") +CFLAGS+= ${PIE_CFLAGS} +AFLAGS+= ${PIE_AFLAGS} +LDFLAGS+= ${PIE_LDFLAGS} +.endif + +CFLAGS+= ${COPTS} +.if defined(MKDEBUG) && (${MKDEBUG} != "no") +CFLAGS+= -g +.endif +OBJCFLAGS+= ${OBJCOPTS} +MKDEP_SUFFIXES?= .o .ln .d + +# CTF preserve debug symbols +.if (${MKCTF:Uno} != "no") && (${CFLAGS:M-g} != "") +CTFFLAGS+= -g +CTFMFLAGS+= -g +.if defined(HAVE_GCC) && ${HAVE_GCC} >= 48 +#CFLAGS+=-gdwarf-2 +.endif +.endif + +# ELF platforms depend on crti.o, crtbegin.o, crtend.o, and crtn.o +.ifndef LIBCRTBEGIN +LIBCRTBEGIN= ${DESTDIR}/usr/lib/${MLIBDIR:D${MLIBDIR}/}crti.o ${_GCC_CRTBEGIN} +.MADE: ${LIBCRTBEGIN} +.endif +.ifndef LIBCRTEND +LIBCRTEND= ${_GCC_CRTEND} ${DESTDIR}/usr/lib/${MLIBDIR:D${MLIBDIR}/}crtn.o +.MADE: ${LIBCRTEND} +.endif +_SHLINKER= ${SHLINKDIR}/ld.elf_so + +.ifndef LIBCRT0 +LIBCRT0= ${DESTDIR}/usr/lib/${MLIBDIR:D${MLIBDIR}/}crt0.o +.MADE: ${LIBCRT0} +.endif + +.ifndef LIBCRTI +LIBCRTI= ${DESTDIR}/usr/lib/${MLIBDIR:D${MLIBDIR}/}crti.o +.MADE: ${LIBCRTI} +.endif + +##### Installed system library definitions +# +# E.g. +# LIBC?=${DESTDIR}/usr/lib/libc.a +# LIBX11?=${DESTDIR}/usr/X11R7/lib/libX11.a +# etc.. +# NB: If you are a library here, add it in ubix.README + +.for _lib in \ + archive \ + asn1 \ + atf_c \ + atf_cxx \ + bind9 \ + bluetooth \ + ubixmalloc \ + bz2 \ + c \ + c_pic \ + com_err \ + compat \ + crypt \ + crypto \ + crypto_idea \ + crypto_mdc2 \ + crypto_rc5 \ + curses \ + dbm \ + des \ + dns \ + edit \ + event \ + expat \ + fetch \ + fl \ + form \ + g2c \ + gcc \ + gnumalloc \ + gssapi \ + hdb \ + heimbase \ + heimntlm \ + hx509 \ + intl \ + ipsec \ + isc \ + isccc \ + isccfg \ + kadm5clnt \ + kadm5srv \ + kafs \ + krb5 \ + kvm \ + l \ + lber \ + ldap \ + ldap_r \ + lua \ + lwres \ + m \ + magic \ + menu \ + objc \ + ossaudio \ + pam \ + pcap \ + pci \ + pmc \ + posix \ + pthread \ + pthread_dbg \ + puffs \ + quota \ + radius \ + resolv \ + rmt \ + roken \ + rpcsvc \ + rt \ + rump \ + rumpfs_cd9660fs \ + rumpfs_efs \ + rumpfs_ext2fs \ + rumpfs_ffs \ + rumpfs_hfs \ + rumpfs_lfs \ + rumpfs_msdosfs \ + rumpfs_nfs \ + rumpfs_ntfs \ + rumpfs_syspuffs \ + rumpfs_tmpfs \ + rumpfs_udf \ + rumpfs_ufs \ + rumpuser \ + saslc \ + skey \ + sl \ + sqlite3 \ + ss \ + ssh \ + ssl \ + ssp \ + stdcxx \ + supcxx \ + terminfo \ + tre \ + usbhid \ + util \ + wind \ + wrap \ + y \ + z + +.ifndef LIB${_lib:tu} +LIB${_lib:tu}= ${DESTDIR}/usr/lib/lib${_lib:S/xx/++/:S/atf_c/atf-c/}.a +.MADE: ${LIB${_lib:tu}} # Note: ${DESTDIR} will be expanded +.endif +.endfor + +# Minix libraries +.for _lib in \ + audiodriver \ + bdev \ + blockdriver \ + chardriver \ + clkconf \ + ddekit \ + ddekit_usb_client \ + ddekit_usb_server \ + devman \ + elf \ + exec \ + fsdriver \ + gpio \ + hgfs \ + i2cdriver \ + inputdriver \ + lwip \ + minc \ + minixfs \ + mthread \ + netdriver \ + sffs \ + sockdriver \ + sockevent \ + sys \ + timers \ + usb \ + vboxfs \ + virtio \ + vtreefs +.ifndef LIB${_lib:tu} +LIB${_lib:tu}= ${DESTDIR}/usr/lib/lib${_lib:S/xx/++/:S/atf_c/atf-c/}.a +.MADE: ${LIB${_lib:tu}} # Note: ${DESTDIR} will be expanded +.endif +.endfor + +# PAM applications, if linked statically, need more libraries +.if (${MKPIC} == "no") +.if (${MKCRYPTO} != "no") +PAM_STATIC_LDADD+= -lssh +PAM_STATIC_DPADD+= ${LIBSSH} +.endif +.if (${MKKERBEROS} != "no") +PAM_STATIC_LDADD+= -lkafs -lkrb5 -lhx509 -lwind -lasn1 \ + -lroken -lcom_err -lheimbase -lcrypto +PAM_STATIC_DPADD+= ${LIBKAFS} ${LIBKRB5} ${LIBHX509} ${LIBWIND} ${LIBASN1} \ + ${LIBROKEN} ${LIBCOM_ERR} ${LIBHEIMBASE} ${LIBCRYPTO} +.endif +.if (${MKSKEY} != "no") +PAM_STATIC_LDADD+= -lskey +PAM_STATIC_DPADD+= ${LIBSKEY} +.endif +PAM_STATIC_LDADD+= -lradius -lcrypt -lrpcsvc -lutil +PAM_STATIC_DPADD+= ${LIBRADIUS} ${LIBCRYPT} ${LIBRPCSVC} ${LIBUTIL} +.else +PAM_STATIC_LDADD= +PAM_STATIC_DPADD= +.endif + +.if defined(__MINIX) && ${MACHINE_ARCH} == "earm" +# LSC: On ARM, when compiling statically, with gcc, lgcc_eh is required +LDFLAGS+= ${${ACTIVE_CC} == "gcc":? -lgcc_eh:} +.endif # defined(__MINIX) && ${MACHINE_ARCH} == "earm" + +# NB: If you are a library here, add it in ubix.README +.for _lib in \ + FS \ + GL \ + GLU \ + ICE \ + SM \ + X11 \ + XTrap \ + Xau \ + Xaw \ + Xdmcp \ + Xext \ + Xfont \ + Xft \ + Xi \ + Xinerama \ + Xmu \ + Xmuu \ + Xpm \ + Xrandr \ + Xrender \ + Xss \ + Xt \ + Xtst \ + Xv \ + Xxf86dga \ + Xxf86misc \ + Xxf86vm \ + dps \ + fntstubs \ + fontcache \ + fontconfig \ + fontenc \ + freetype \ + lbxutil \ + xkbfile +.ifndef LIB${_lib:tu} +LIB${_lib:tu}= ${DESTDIR}${X11USRLIBDIR}/lib${_lib}.a +.MADE: ${LIB${_lib:tu}} # Note: ${DESTDIR} will be expanded +.endif +.endfor + +# Ugly one-offs +LIBX11_XCB= ${DESTDIR}${X11USRLIBDIR}/libX11-xcb.a +LIBXCB= ${DESTDIR}${X11USRLIBDIR}/libxcb.a + +.if defined(RESCUEDIR) +CPPFLAGS+= -DRESCUEDIR=\"${RESCUEDIR}\" +.endif + +_PROGLDOPTS= +.if ${SHLINKDIR} != "/usr/libexec" # XXX: change or remove if ld.so moves +_PROGLDOPTS+= -Wl,-dynamic-linker=${_SHLINKER} +.endif +.if ${SHLIBDIR} != "/usr/lib" +_PROGLDOPTS+= -Wl,-rpath,${SHLIBDIR} \ + -L=${SHLIBDIR} +.elif ${SHLIBINSTALLDIR} != "/usr/lib" +_PROGLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR} \ + -L=${SHLIBINSTALLDIR} +.endif + +__proginstall: .USE + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + ${STRIPFLAG} ${.ALLSRC} ${.TARGET} + +__progrumpinstall: .USE + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} -o ${RUMPBINOWN} -g ${RUMPBINGRP} -m ${RUMPBINMODE} \ + ${STRIPFLAG} ${.ALLSRC} ${.TARGET} + +__progdebuginstall: .USE + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} -o ${DEBUGOWN} -g ${DEBUGGRP} -m ${DEBUGMODE} \ + ${.ALLSRC} ${.TARGET} + + + +# +# Backwards compatibility with Makefiles that assume that ubix.prog.mk +# can only build a single binary. +# + +_APPEND_MANS=yes +_APPEND_SRCS=yes + +_CCLINKFLAGS= + +.if defined(PROG_CXX) +PROG= ${PROG_CXX} +_CCLINK= ${CXX} ${_CCLINKFLAGS} + +.if defined(__MINIX) +# BJG - stack unwinding (for C++ exceptions) doesn't work on static executables when built with llvm. +LDSTATIC= -dynamic +.endif # defined(__MINIX) +.endif + +.if defined(RUMPPRG) +PROG= ${RUMPPRG} +. ifndef CRUNCHEDPROG +. if (${MKRUMP} != "no") +PROGS= ${RUMPPRG} rump.${RUMPPRG} +. else +PROGS= ${RUMPPRG} +. endif +. if defined(SRCS) +. if (${MKRUMP} != "no") +SRCS.rump.${PROG}:= ${SRCS} ${PROG}_rumpops.c ${RUMPSRCS} +. endif +SRCS+= ${PROG}_hostops.c +. else +SRCS= ${PROG}.c ${PROG}_hostops.c +. if (${MKRUMP} != "no") +SRCS.rump.${PROG}= ${PROG}.c ${PROG}_rumpops.c ${RUMPSRCS} +. endif +. endif +. if (${MKRUMP} != "no") +DPSRCS+= ${PROG}_rumpops.c ${RUMPSRCS} +LDADD.rump.${PROG}+= -lrumpclient +DPADD.rump.${PROG}+= ${LIBRUMPCLIENT} +MAN.rump.${PROG}= # defined but feeling empty +_RUMPINSTALL.rump.${PROG}=# defined +. endif +. else # CRUNCHEDPROG +PROGS= ${PROG} +CPPFLAGS+= -DCRUNCHOPS +. endif +.endif + +.if defined(PROG) +_CCLINK?= ${CC} ${_CCLINKFLAGS} +. if defined(MAN) +MAN.${PROG}= ${MAN} +_APPEND_MANS= no +. endif +. if !defined(OBJS) +OBJS= ${OBJS.${PROG}} +. endif +. if defined(PROGNAME) +PROGNAME.${PROG}= ${PROGNAME} +. endif +. if defined(SRCS) +SRCS.${PROG}= ${SRCS} +_APPEND_SRCS= no +. endif +.endif + +# Turn the single-program PROG and PROG_CXX variables into their multi-word +# counterparts, PROGS and PROGS_CXX. +.if !defined(RUMPPRG) +. if defined(PROG_CXX) && !defined(PROGS_CXX) +PROGS_CXX= ${PROG_CXX} +. elif defined(PROG) && !defined(PROGS) +PROGS= ${PROG} +. endif +.endif + +##### Libraries that this may depend upon. +.if defined(PROGDPLIBS) # { +.for _lib _dir in ${PROGDPLIBS} +.if !defined(BINDO.${_lib}) +PROGDO.${_lib}!= cd "${_dir}" && ${PRINTOBJDIR} +.MAKEOVERRIDES+=PROGDO.${_lib} +.endif +LDADD+= -L${PROGDO.${_lib}} -l${_lib} +.if exists(${PROGDO.${_lib}}/lib${_lib}_pic.a) +DPADD+= ${PROGDO.${_lib}}/lib${_lib}_pic.a +.elif exists(${PROGDO.${_lib}}/lib${_lib}.so) +DPADD+= ${PROGDO.${_lib}}/lib${_lib}.so +.else +DPADD+= ${PROGDO.${_lib}}/lib${_lib}.a +.endif +.endfor +.endif # } +# +# Per-program definitions and targets. +# + +_CCLINK.CDEFAULT= ${CC} ${_CCLINKFLAGS} +# Definitions specific to C programs. +.for _P in ${PROGS} +SRCS.${_P}?= ${_P}.c +_CCLINK.${_P}= ${CC} ${_CCLINKFLAGS} +_CFLAGS.${_P}= ${CFLAGS} ${CPUFLAGS} +_CPPFLAGS.${_P}= ${CPPFLAGS} +_COPTS.${_P}= ${COPTS} +.endfor + +_CCLINK.CXXDEFAULT= ${CXX} ${_CCLINKFLAGS} +# Definitions specific to C++ programs. +.for _P in ${PROGS_CXX} +SRCS.${_P}?= ${_P}.cc +_CCLINK.${_P}= ${CXX} ${_CCLINKFLAGS} +.endfor + +# Language-independent definitions. +.if defined(__MINIX) +.if ${USE_BITCODE:Uno} == "yes" +CFLAGS+= -flto +.endif # ${USE_BITCODE:Uno} == "yes" + +.if ${USE_BITCODE:Uyes} == "no" +#LSC Gold linker seems to require the library directory to be set up if +# a sysroot parameter has been given. +LDFLAGS+= -L ${DESTDIR}/usr/lib +.endif # ${USE_BITCODE:U} == "no" +.endif # defined(__MINIX) + +.for _P in ${PROGS} ${PROGS_CXX} # { + +BINDIR.${_P}?= ${BINDIR} +PROGNAME.${_P}?= ${_P} + +.if ${MKDEBUG} != "no" && !commands(${_P}) +_PROGDEBUG.${_P}:= ${PROGNAME.${_P}}.debug +.endif + +.if defined(PAXCTL_FLAGS) +PAXCTL_FLAGS.${_P}?= ${PAXCTL_FLAGS} +.endif + +##### PROG specific flags. + +_DPADD.${_P}= ${DPADD} ${DPADD.${_P}} +_LDADD.${_P}= ${LDADD} ${LDADD.${_P}} +_LDFLAGS.${_P}= ${LDFLAGS} ${LDFLAGS.${_P}} +_LDSTATIC.${_P}= ${LDSTATIC} ${LDSTATIC.${_P}} + +##### Build and install rules +.if !empty(_APPEND_SRCS:M[Yy][Ee][Ss]) +SRCS+= ${SRCS.${_P}} # For ubix.dep.mk +.endif + +_YPSRCS.${_P}= ${SRCS.${_P}:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS.${_P}:M*.y:.y=.h}} + +DPSRCS+= ${_YPSRCS.${_P}} +CLEANFILES+= ${_YPSRCS.${_P}} + +.if !empty(SRCS.${_P}:N*.h:N*.sh:N*.fth) +OBJS.${_P}+= ${SRCS.${_P}:N*.h:N*.sh:N*.fth:R:S/$/.o/g} +LOBJS.${_P}+= ${LSRCS:.c=.ln} ${SRCS.${_P}:M*.c:.c=.ln} +.endif + +.if defined(OBJS.${_P}) && !empty(OBJS.${_P}) # { +.NOPATH: ${OBJS.${_P}} ${_P} ${_YPSRCS.${_P}} + +.if (defined(USE_COMBINE) && ${USE_COMBINE} != "no" && !commands(${_P}) \ + && (${_CCLINK.${_P}} == ${_CCLINK.CDEFAULT} \ + || ${_CCLINK.${_P}} == ${_CCLINK.CXXDEFAULT}) \ + && !defined(NOCOMBINE.${_P}) && !defined(NOCOMBINE)) +.for f in ${SRCS.${_P}:N*.h:N*.sh:N*.fth:C/\.[yl]$/.c/g} +#_XFLAGS.$f := ${CPPFLAGS.$f:D1} ${CPUFLAGS.$f:D2} \ +# ${COPTS.$f:D3} ${OBJCOPTS.$f:D4} ${CXXFLAGS.$f:D5} +.if (${CPPFLAGS.$f:D1} == "1" || ${CPUFLAGS.$f:D2} == "2" \ + || ${COPTS.$f:D3} == "3" || ${OBJCOPTS.$f:D4} == "4" \ + || ${CXXFLAGS.$f:D5} == "5") \ + || ("${f:M*.[cyl]}" == "" || commands(${f:R:S/$/.o/})) +XOBJS.${_P}+= ${f:R:S/$/.o/} +.else +XSRCS.${_P}+= ${f} +NODPSRCS+= ${f} +.endif +.endfor + +${_P}: .gdbinit ${LIBCRT0} ${LIBCRTI} ${XOBJS.${_P}} ${SRCS.${_P}} \ + ${DPSRCS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${_DPADD.${_P}} + ${_MKTARGET_LINK} +.if defined(DESTDIR) + ${_CCLINK.${_P}} -Wl,-nostdlib \ + ${_LDFLAGS.${_P}} ${_LDSTATIC.${_P}} -o ${.TARGET} ${_PROGLDOPTS} \ + -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/ \ + -MD --combine ${_CPPFLAGS.${_P}} ${_CFLAGS.${_P}} ${_COPTS.${_P}} \ + ${XSRCS.${_P}:@.SRC.@${.ALLSRC:M*.c:M*${.SRC.}}@:O:u} ${XOBJS.${_P}} \ + ${_LDADD.${_P}} -L${_GCC_LIBGCCDIR} -L${DESTDIR}/usr/lib +.else + ${_CCLINK.${_P}} ${_LDFLAGS.${_P}} ${_LDSTATIC.${_P}} -o ${.TARGET} ${_PROGLDOPTS} \ + -MD --combine ${_CPPFLAGS.${_P}} ${_COPTS.${_P}} + ${XSRCS.${_P}:@.SRC.@${.ALLSRC:M*.c:M*${.SRC.}}@:O:u} ${XOBJS.${_P}} \ + ${_LDADD.${_P}} +.endif # defined(DESTDIR) +.if defined(CTFMERGE) + ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${OBJS.${_P}} +.endif +.if defined(PAXCTL_FLAGS.${_P}) + ${PAXCTL} ${PAXCTL_FLAGS.${_P}} ${.TARGET} +.endif +.if ${MKSTRIPIDENT} != "no" + ${OBJCOPY} -R .ident ${.TARGET} +.endif + +CLEANFILES+= ${_P}.d +.if exists(${_P}.d) +.include "${_P}.d" # include -MD depend for program. +.endif +.else # USE_COMBINE + +${OBJS.${_P}} ${LOBJS.${_P}}: ${DPSRCS} + +.if defined(__MINIX) && ${USE_BITCODE:Uno} == "yes" +CLEANFILES+= ${_P}.opt.bcl ${_P}.bcl ${_P}.bcl.o + +OPTFLAGS.${_P}?= ${OPTFLAGS} +BITCODE_LD_FLAGS_1ST.${_P}+= ${BITCODE_LD_FLAGS_1ST} +BITCODE_LD_FLAGS_2ND.${_P}+= ${BITCODE_LD_FLAGS_2ND} + +${_P}.bcl: .gdbinit ${LIBCRT0} ${LIBCRTI} ${OBJS.${_P}} ${LIBC} ${LIBCRTBEGIN} \ + ${LIBCRTEND} ${_DPADD.${_P}} + ${_MKTARGET_LINK} + ${_CCLINK.${_P}} \ + -o ${.TARGET} \ + -nostartfiles \ + -L${DESTDIR}/usr/lib/bc \ + ${OBJS.${_P}} ${LLVM_LINK_ARGS} ${_LDADD.${_P}:N-shared} \ + ${_LDSTATIC.${_P}} ${_PROGLDOPTS} \ + -Wl,-r \ + ${BITCODE_LD_FLAGS_1ST.${_P}} \ + -Wl,-plugin-opt=emit-llvm + +${_P}.opt.bcl: ${_P}.bcl ${LLVM_PASS} + ${_MKTARGET_LINK} + ${OPT} ${OPTFLAGS.${_P}} -o ${.TARGET} ${_P}.bcl + +${_P}.bcl.o: ${_P}.opt.bcl + ${_MKTARGET_LINK} + ${LLC} -O1 -march=x86 -mcpu=i586 -filetype=obj -o ${.TARGET} ${.ALLSRC} + +${_P}: ${_P}.bcl.o +.if !commands(${_P}) + ${_MKTARGET_LINK} + ${_CCLINK.${_P}} \ + ${_LDFLAGS.${_P}} \ + -L${DESTDIR}/usr/lib \ + ${_LDSTATIC.${_P}} -o ${.TARGET} \ + ${.TARGET}.bcl.o ${_PROGLDOPTS} ${_LDADD.${_P}} \ + ${BITCODE_LD_FLAGS_2ND.${_P}} \ + -Wl,--allow-multiple-definition +.endif # !commands(${_P}) + +.else +${_P}: .gdbinit ${LIBCRT0} ${LIBCRTI} ${OBJS.${_P}} ${LIBC} ${LIBCRTBEGIN} \ + ${LIBCRTEND} ${_DPADD.${_P}} +.if !commands(${_P}) + ${_MKTARGET_LINK} + ${_CCLINK.${_P}} \ + ${_LDFLAGS.${_P}} ${_LDSTATIC.${_P}} -o ${.TARGET} \ + ${OBJS.${_P}} ${_PROGLDOPTS} ${_LDADD.${_P}} +.if defined(CTFMERGE) + ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${OBJS.${_P}} +.endif +.if defined(PAXCTL_FLAGS.${_P}) + ${PAXCTL} ${PAXCTL_FLAGS.${_P}} ${.TARGET} +.endif +.if ${MKSTRIPIDENT} != "no" + ${OBJCOPY} -R .ident ${.TARGET} +.endif +.endif # !commands(${_P}) +.endif # defined(__MINIX) && ${USE_BITCODE:Uno} == "yes" +.endif # USE_COMBINE + +${_P}.ro: ${OBJS.${_P}} ${_DPADD.${_P}} + ${_MKTARGET_LINK} + ${CC} ${LDFLAGS:N-Wl,-pie} -nostdlib -r -Wl,-dc -o ${.TARGET} ${OBJS.${_P}} + +.if defined(_PROGDEBUG.${_P}) +${_PROGDEBUG.${_P}}: ${_P} + ${_MKTARGET_CREATE} + ( ${OBJCOPY} --only-keep-debug ${_P} ${_PROGDEBUG.${_P}} \ + && ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \ + --add-gnu-debuglink=${_PROGDEBUG.${_P}} ${_P} \ + ) || (rm -f ${_PROGDEBUG.${_P}}; false) +.endif + +.endif # defined(OBJS.${_P}) && !empty(OBJS.${_P}) # } + +.if !defined(MAN.${_P}) +MAN.${_P}= ${_P}.1 +.endif # !defined(MAN.${_P}) +.if !empty(_APPEND_MANS:M[Yy][Ee][Ss]) +MAN+= ${MAN.${_P}} +.endif + +realall: ${_P} ${_PROGDEBUG.${_P}} + +CLEANFILES+= ${_P} ${_PROGDEBUG.${_P}} + +.if defined(OBJS.${_P}) && !empty(OBJS.${_P}) +CLEANFILES+= ${OBJS.${_P}} ${LOBJS.${_P}} +.endif + +_PROG_INSTALL+= proginstall-${_P} + +.if !target(proginstall-${_P}) # { +proginstall-${_P}:: ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}} \ + ${_PROGDEBUG.${_P}:D${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}} +.PRECIOUS: ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}} \ + ${_PROGDEBUG.${_P}:D${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}} + +.if ${MKUPDATE} == "no" +.if defined(_RUMPINSTALL.${_P}) +${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}! ${_P} __progrumpinstall +.else +${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}! ${_P} __proginstall +.endif +.if !defined(BUILD) && !make(all) && !make(${_P}) +${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}! .MADE +.endif +.if defined(_PROGDEBUG.${_P}) +${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}! ${_PROGDEBUG.${_P}} __progdebuginstall +.if !defined(BUILD) && !make(all) && !make(${_P}) +${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}! .MADE +.endif +.endif # define(_PROGDEBUG.${_P}) +.else # MKUPDATE != no +.if defined(_RUMPINSTALL.${_P}) +${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}: ${_P} __progrumpinstall +.else +${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}: ${_P} __proginstall +.endif +.if !defined(BUILD) && !make(all) && !make(${_P}) +${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}: .MADE +.endif +.if defined(_PROGDEBUG.${_P}) +${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}: ${_PROGDEBUG.${_P}} __progdebuginstall +.if !defined(BUILD) && !make(all) && !make(${_P}) +${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}: .MADE +.endif +.endif # defined(_PROGDEBUG.${_P}) +.endif # MKUPDATE != no + +.endif # !target(proginstall-${_P}) # } + +lint: lint-${_P} +lint-${_P}: ${LOBJS.${_P}} +.if defined(LOBJS.${_P}) && !empty(LOBJS.${_P}) + ${LINT} ${LINTFLAGS} ${_LDFLAGS.${_P}:C/-L[ ]*/-L/Wg:M-L*} ${LOBJS.${_P}} ${_LDADD.${_P}} +.endif + +.endfor # _P in ${PROGS} ${PROGS_CXX} # } + +.if defined(OBJS) && !empty(OBJS) && \ + (empty(PROGS) && empty(PROGS_CXX)) +CLEANFILES+= ${OBJS} ${LOBJS} +.endif + +.if !target(proginstall) +proginstall:: ${_PROG_INSTALL} +.endif +.PHONY: proginstall + + + +realall: ${SCRIPTS} +.if defined(SCRIPTS) && !target(scriptsinstall) # { +SCRIPTSDIR?=${BINDIR} +SCRIPTSOWN?=${BINOWN} +SCRIPTSGRP?=${BINGRP} +SCRIPTSMODE?=${BINMODE} + +scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@} +.PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@} + +__scriptinstall: .USE + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} \ + -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \ + -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \ + -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \ + ${.ALLSRC} ${.TARGET} + +.for S in ${SCRIPTS:O:u} +.if ${MKUPDATE} == "no" +${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! ${S} __scriptinstall +.if !defined(BUILD) && !make(all) && !make(${S}) +${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! .MADE +.endif +.else +${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: ${S} __scriptinstall +.if !defined(BUILD) && !make(all) && !make(${S}) +${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE +.endif +.endif +.endfor +.endif # } + +.if !target(scriptsinstall) +scriptsinstall:: +.endif +.PHONY: scriptsinstall + +##### Pull in related .mk logic +LINKSOWN?= ${BINOWN} +LINKSGRP?= ${BINGRP} +LINKSMODE?= ${BINMODE} +.include +.include +.include +.include +.include +.include +.include +.include +.include + +${TARGETS}: # ensure existence + +.endif # HOSTPROG diff --git a/src/share/mk/ubix.shlib.mk b/src/share/mk/ubix.shlib.mk new file mode 100644 index 0000000..bb058c2 --- /dev/null +++ b/src/share/mk/ubix.shlib.mk @@ -0,0 +1,40 @@ +# $NetBSD: bsd.shlib.mk,v 1.8 2012/08/23 21:21:17 joerg Exp $ + +.if !defined(_BSD_SHLIB_MK_) +_BSD_SHLIB_MK_=1 + +.if ${MKDYNAMICROOT} == "no" +SHLIBINSTALLDIR?= /usr/lib +.else +SHLIBINSTALLDIR?= /lib +.endif + +.if ${MKDYNAMICROOT} == "no" || \ + (${BINDIR:Ux} != "/bin" && ${BINDIR:Ux} != "/sbin" && \ + ${BINDIR:Ux} != "/libexec" && ${USE_SHLIBDIR:Uno} == "no") +SHLIBDIR?= /usr/lib +.else +SHLIBDIR?= /lib +.endif + +.if ${USE_SHLIBDIR:Uno} != "no" +_LIBSODIR?= ${SHLIBINSTALLDIR} +.else +_LIBSODIR?= ${LIBDIR} +.endif + +.if ${MKDYNAMICROOT} == "no" +SHLINKINSTALLDIR?= /usr/libexec +.else +SHLINKINSTALLDIR?= /libexec +.endif + +.if ${MKDYNAMICROOT} == "no" || \ + (${BINDIR:Ux} != "/bin" && ${BINDIR:Ux} != "/sbin" && \ + ${BINDIR:Ux} != "/libexec") +SHLINKDIR?= /usr/libexec +.else +SHLINKDIR?= /libexec +.endif + +.endif # !defined(_BSD_SHLIB_MK_) diff --git a/src/share/mk/ubix.subdir.mk b/src/share/mk/ubix.subdir.mk new file mode 100644 index 0000000..b3bea80 --- /dev/null +++ b/src/share/mk/ubix.subdir.mk @@ -0,0 +1,51 @@ +.include + +.if !defined(NOSUBDIR) + +.for dir in ${SUBDIR} + +.if "${dir:H}" != "" + +.if exists(${.CURDIR}/${dir}.${MACHINE}) +__REALSUBDIR+=${dir}.${MACHINE} +.else +__REALSUBDIR+=${dir} +.endif + +.else +.if exists(${dir}.${MACHINE}) +__REALSUBDIR+=${dir}.${MACHINE} +.else +__REALSUBDIR+=${dir} +.endif + +.endif +.endfor + +__recurse: .USE + @${MAKEDIRTARGET} ${.TARGET:C/^[^-]*-//} ${.TARGET:C/-.*$//} + +.if make(cleandir) +__RECURSETARG= ${TARGETS:Nclean} +clean: +.else +__RECURSETARG= ${TARGETS} +.endif + +.for targ in ${__RECURSETARG} + +.for dir in ${__REALSUBDIR} +__TARGDIR := ${dir} +.if !commands(${targ}-${dir}) +${targ}-${dir}: .PHONY .MAKE __recurse +SUBDIR_${targ} += ${targ}-${dir} +.endif +.endfor + +subdir-${targ}: .PHONY ${SUBDIR_${targ}} +${targ}: subdir-${targ} +.endfor + +.endif + +${TARGETS}: diff --git a/src/share/mk/ubix.sys.mk b/src/share/mk/ubix.sys.mk new file mode 100644 index 0000000..6ef2746 --- /dev/null +++ b/src/share/mk/ubix.sys.mk @@ -0,0 +1,285 @@ +.if !defined(_BSD_SYS_MK_) +_BSD_SYS_MK_=1 + +.if !empty(.INCLUDEDFROMFILE:MMakefile*) +error1: + @(echo "bsd.sys.mk should not be included from Makefiles" >& 2; exit 1) +.endif +.if !defined(_BSD_OWN_MK_) +error2: + @(echo "bsd.own.mk must be included before bsd.sys.mk" >& 2; exit 1) +.endif + +.if defined(__MINIX) +#LSC: Be a bit smarter about the default compiler +.if exists(/usr/pkg/bin/clang) || exists(/usr/bin/clang) +CC?= clang +.endif + +.if exists(/usr/pkg/bin/gcc) || exists(/usr/bin/gcc) +CC?= gcc +.endif + +MKDEP?= CC=${CC:Q} mkdep +MKDEPCXX?= CC=${CXX:Q} mkdep +.endif # defined(__MINIX) + +.if ${MKREPRO:Uno} == "yes" +CPPFLAGS+= -Wp,-iremap,${NETBSDSRCDIR}:/usr/src +CPPFLAGS+= -Wp,-iremap,${DESTDIR}/:/ +CPPFLAGS+= -Wp,-iremap,${X11SRCDIR}:/usr/xsrc +.endif + +# NetBSD sources use C99 style, with some GCC extensions. +CFLAGS+= ${${ACTIVE_CC} == "clang":? -std=gnu99 :} +CFLAGS+= ${${ACTIVE_CC} == "gcc":? -std=gnu99 :} +CFLAGS+= ${${ACTIVE_CC} == "pcc":? -std=gnu99 :} + +.if defined(WARNS) +CFLAGS+= ${${ACTIVE_CC} == "clang":? -Wno-sign-compare -Wno-pointer-sign :} +.if ${WARNS} > 0 +CFLAGS+= -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith +#CFLAGS+= -Wmissing-declarations -Wredundant-decls -Wnested-externs +# Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3, +# but our sources aren't up for it yet. Also, add -Wno-traditional because +# gcc includes #elif in the warnings, which is 'this code will not compile +# in a traditional environment' warning, as opposed to 'this code behaves +# differently in traditional and ansi environments' which is the warning +# we wanted, and now we don't get anymore. +CFLAGS+= -Wno-sign-compare +CFLAGS+= ${${ACTIVE_CC} == "gcc" :? -Wno-traditional :} +.if !defined(NOGCCERROR) && !defined(USE_BITCODE) +# Set assembler warnings to be fatal +CFLAGS+= -Wa,--fatal-warnings +.endif +# Set linker warnings to be fatal +# XXX no proper way to avoid "FOO is a patented algorithm" warnings +# XXX on linking static libs +.if (!defined(MKPIC) || ${MKPIC} != "no") && \ + (!defined(LDSTATIC) || ${LDSTATIC} != "-static") +# XXX there are some strange problems not yet resolved +. if defined(HAVE_LLVM) && !defined(USE_BITCODE) +LDFLAGS+= -Wl,--fatal-warnings +. endif +.endif +.endif +.if ${WARNS} > 1 +CFLAGS+= -Wreturn-type -Wswitch -Wshadow +.endif +.if ${WARNS} > 2 +CFLAGS+= -Wcast-qual -Wwrite-strings +CFLAGS+= -Wextra -Wno-unused-parameter +# Readd -Wno-sign-compare to override -Wextra with clang +CFLAGS+= -Wno-sign-compare +CXXFLAGS+= -Wabi +CXXFLAGS+= -Wold-style-cast +CXXFLAGS+= -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder \ + -Wno-deprecated -Woverloaded-virtual -Wsign-promo -Wsynth +CXXFLAGS+= ${${ACTIVE_CXX} == "gcc":? -Wno-non-template-friend -Wno-pmf-conversions :} +.endif +.if ${WARNS} > 3 && (defined(HAVE_GCC) || defined(HAVE_LLVM)) +.if ${WARNS} > 4 +CFLAGS+= -Wold-style-definition +.endif +.if ${WARNS} > 5 && !(defined(HAVE_GCC) && ${HAVE_GCC} <= 45) +CFLAGS+= -Wconversion +.endif +CFLAGS+= -Wsign-compare -Wformat=2 +CFLAGS+= ${${ACTIVE_CC} == "gcc":? -Wno-format-zero-length :} +.endif +.if ${WARNS} > 3 && defined(HAVE_LLVM) +CFLAGS+= ${${ACTIVE_CC} == "clang":? -Wpointer-sign -Wmissing-noreturn :} +.endif +.if (defined(HAVE_GCC) \ + && (${MACHINE_ARCH} == "coldfire" || \ + ${MACHINE_ARCH} == "sh3eb" || \ + ${MACHINE_ARCH} == "sh3el" || \ + ${MACHINE_ARCH} == "m68k" || \ + ${MACHINE_ARCH} == "m68000")) +# XXX GCC 4.5 for sh3 and m68k (which we compile with -Os) is extra noisy for +# cases it should be better with +CFLAGS+= -Wno-uninitialized +.if ${HAVE_GCC} >= 48 +CFLAGS+= -Wno-maybe-uninitialized +.endif +.endif +.endif + +CWARNFLAGS+= ${CWARNFLAGS.${ACTIVE_CC}} + +CPPFLAGS+= ${AUDIT:D-D__AUDIT__} +_NOWERROR= ${defined(NOGCCERROR) || (${ACTIVE_CC} == "clang" && defined(NOCLANGERROR)):?yes:no} +.if defined(__MINIX) && ${USE_BITCODE:Uno} == "yes" +_NOWERROR= yes +.endif # defined(__MINIX) && ${USE_BITCODE} == "yes" +CFLAGS+= ${${_NOWERROR} == "no" :?-Werror:} ${CWARNFLAGS} +LINTFLAGS+= ${DESTDIR:D-d ${DESTDIR}/usr/include} + +.if (${USE_SSP:Uno} != "no") && (${BINDIR:Ux} != "/usr/mdec") +.if !defined(KERNSRCDIR) && !defined(KERN) # not for kernels nor kern modules +CPPFLAGS+= -D_FORTIFY_SOURCE=2 +.endif +COPTS+= -fstack-protector -Wstack-protector + +# gcc 4.8 on m68k erroneously does not protect functions with +# variables needing special alignement, see +# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59674 +# (the underlying issue for sh and vax may be different, needs more +# investigation, symptoms are similar but for different sources) +.if "${ACTIVE_CC}" == "gcc" && "${HAVE_GCC}" == "48" && \ + ( ${MACHINE_CPU} == "sh3" || \ + ${MACHINE_ARCH} == "vax" || \ + ${MACHINE_CPU} == "m68k" || \ + ${MACHINE_CPU} == "or1k" ) +COPTS+= -Wno-error=stack-protector +.endif + +COPTS+= ${${ACTIVE_CC} == "clang":? --param ssp-buffer-size=1 :} +COPTS+= ${${ACTIVE_CC} == "gcc":? --param ssp-buffer-size=1 :} +.endif + +.if ${MKSOFTFLOAT:Uno} != "no" +COPTS+= ${${ACTIVE_CC} == "gcc":? -msoft-float :} +FOPTS+= -msoft-float +.elif ${MACHINE_ARCH} == "coldfire" +COPTS+= -mhard-float +FOPTS+= -mhard-float +.endif + +.if ${MKIEEEFP:Uno} != "no" +.if ${MACHINE_ARCH} == "alpha" +CFLAGS+= -mieee +FFLAGS+= -mieee +.endif +.endif + +.if ${MACHINE} == "sparc64" && ${MACHINE_ARCH} == "sparc" +CFLAGS+= -Wa,-Av8plus +.endif + +.if !defined(NOGCCERROR) +.if (${MACHINE_ARCH} == "mips64el") || (${MACHINE_ARCH} == "mips64eb") +CPUFLAGS+= -Wa,--fatal-warnings +.endif +.endif + +#.if ${MACHINE} == "sbmips" +#CFLAGS+= -mips64 -mtune=sb1 +#.endif + +#.if (${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb") && \ +# (defined(MKPIC) && ${MKPIC} == "no") +#CPUFLAGS+= -mno-abicalls -fno-PIC +#.endif +CFLAGS+= ${CPUFLAGS} +AFLAGS+= ${CPUFLAGS} + +.if !defined(LDSTATIC) || ${LDSTATIC} != "-static" +# Position Independent Executable flags +PIE_CFLAGS?= -fPIC +PIE_LDFLAGS?= -Wl,-pie ${${ACTIVE_CC} == "gcc":? -shared-libgcc :} +PIE_AFLAGS?= -fPIC +.endif + +ELF2ECOFF?= elf2ecoff +MKDEP?= mkdep +MKDEPCXX?= mkdep +OBJCOPY?= objcopy +OBJDUMP?= objdump +PAXCTL?= paxctl +STRIP?= strip + +.SUFFIXES: .o .ln .lo .c .cc .cpp .cxx .C .m ${YHEADER:D.h} + +# C +.c.o: + ${_MKTARGET_COMPILE} + ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif + +.c.ln: + ${_MKTARGET_COMPILE} + ${LINT} ${LINTFLAGS} ${LINTFLAGS.${.IMPSRC:T}} \ + ${CPPFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ + ${CPPFLAGS.${.IMPSRC:T}:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ + -i ${.IMPSRC} + +# C++ +.cc.o .cpp.o .cxx.o .C.o: + ${_MKTARGET_COMPILE} + ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} + +# Objective C +# (Defined here rather than in because `.m' is not just +# used for Objective C source) +.m.o: + ${_MKTARGET_COMPILE} + ${COMPILE.m} ${OBJCOPTS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif + +# Host-compiled C objects +# The intermediate step is necessary for Sun CC, which objects to calling +# object files anything but *.o +.c.lo: + ${_MKTARGET_COMPILE} + ${HOST_COMPILE.c} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} + mv ${.TARGET}.o ${.TARGET} + +# C++ +.cc.lo .cpp.lo .cxx.lo .C.lo: + ${_MKTARGET_COMPILE} + ${HOST_COMPILE.cc} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} + mv ${.TARGET}.o ${.TARGET} + +# Assembly +.s.o: + ${_MKTARGET_COMPILE} + ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif + +.S.o: + ${_MKTARGET_COMPILE} + ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} +.if defined(CTFCONVERT) + ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.endif + +# Lex +LFLAGS+= ${LPREFIX.${.IMPSRC:T}:D-P${LPREFIX.${.IMPSRC:T}}} +LFLAGS+= ${LPREFIX:D-P${LPREFIX}} + +.l.c: + ${_MKTARGET_LEX} + ${LEX.l} -o${.TARGET} ${.IMPSRC} + +# Yacc +YFLAGS+= ${YPREFIX.${.IMPSRC:T}:D-p${YPREFIX.${.IMPSRC:T}}} ${YHEADER.${.IMPSRC:T}:D-d} +YFLAGS+= ${YPREFIX:D-p${YPREFIX}} ${YHEADER:D-d} + +.y.c: + ${_MKTARGET_YACC} + ${YACC.y} -o ${.TARGET} ${.IMPSRC} + +.ifdef YHEADER +.if empty(.MAKEFLAGS:M-n) +.y.h: ${.TARGET:.h=.c} +.endif +.endif + +# Objcopy +.if ${MACHINE_ARCH} == aarch64eb +# AARCH64 big endian needs to preserve $x/$d symbols for the linker. +OBJCOPYLIBFLAGS_EXTRA=-w -K '[$$][dx]' -K '[$$][dx]\.*' +.elif !empty(MACHINE_ARCH:M*arm*eb) +# ARM big endian needs to preserve $a/$d/$t symbols for the linker. +OBJCOPYLIBFLAGS_EXTRA=-w -K '[$$][adt]' -K '[$$][adt]\.*' +.endif +OBJCOPYLIBFLAGS?=${"${.TARGET:M*.po}" != "":?-X:-x} ${OBJCOPYLIBFLAGS_EXTRA} + +.endif # !defined(_BSD_SYS_MK_)