Skip to content

Commit

Permalink
Makefile, src/Makefile, src/yajl/Makefile: fixes
Browse files Browse the repository at this point in the history
- mostly to et the SUBDIR += .WAIT in the right place for older sjg
  Mk-files
- also to support pkgsrc bootstrap-mk-files with bmake.
  • Loading branch information
robohack committed Mar 23, 2024
1 parent b34fb37 commit fbd4afb
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 29 deletions.
57 changes: 35 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,17 @@
# more or less, but it doesn't support .WAIT in the ${SUBDIR} list, so parallel
# builds are impossible with it.
#
# Old macOS systems with "bsdmake" may not have "mkdep" in the installed SDK
# even though the wrapper in /usr/bin/mkdep exists (and "xcrun -find mkdep"
# fails). This can be worked around with: MKDEPCMD=/Developer/usr/bin/mkdep
#
#
# OpenBSD:
#
# So note OpenBSD's make since 5.5 (and before 2.1) does NOT support
# $MAKEOBJDIRPREFIX at all. For recent OpenBSD, just use ${MAKEOBJDIR} instead.
#
#
# FreeBSD:
#
# FreeBSD's mk-files don't work reliably with "obj" in the dependency list for
Expand All @@ -130,10 +136,11 @@
# "WITH_AUTO_OBJ=yes" ON THE COMMAND LINE OR IN THE ENVIRONMENT! (Having it set
# in /etc/src-env.conf DOES NOT WORK for an out-of-/usr/src project.)
#
#
# Other BMake ports:
#
# See the first use of .WAIT below for comments about really old BMakes and
# mk-files that don't deal with it properly.
# Mk-files that don't deal with it properly.
#
#####################
#
Expand Down Expand Up @@ -212,6 +219,14 @@

bmake_topdir = .

#####################
#
# Sub-directories of the project
#
# xxx this must come after <bsd.own.mk> and thus after Makefile.inc because of
# the ugly hacks here to try to sort out wether or not a .WAIT is needed and can
# be included in the list.

SUBDIR = src

# Some variants of Mk-files (e.g. NetBSD's) build subdirs in parallel (when
Expand All @@ -220,8 +235,9 @@ SUBDIR = src
# quite make up for it because of the fact these directories always exist prior
# to starting make).
#
# BMake with pkgsrc's bootstrap-mk-files is equivalent to NetBSD's native
# mk-files, so work fine with '-j' so long as this .WAIT is present.
# BMake with pkgsrc's bootstrap-mk-files are equivalent to NetBSD's native
# Mk-files, so work fine with '-j' so long as this .WAIT is present. These set
# "unix" to "We Run Unix" in <sys.mk>.
#
# BMake with sjg's Mk-files doesn't build subdirs in parallel at all yet, and
# until 20240212 it does not support .WAIT in the SUBDIR list, but older
Expand All @@ -240,17 +256,15 @@ SUBDIR = src
# invoke parallel builds (no -j)!
#
.if !defined(MAKE_VERSION) || \
(defined(MAKE_VERSION) && defined(_BSD_OWN_MK_) && ${_BSD_OWN_MK_} == 1) || \
(defined(MAKE_VERSION) && ${MAKE_VERSION} >= 20240212 && ${MAKE} != "bsdmake") || \
(defined(unix) && ${unix} == "We run Unix"&& ${MAKE} != "bsdmake") || \
(${MAKE_VERSION} >= 20240212 && ${MAKE} != "bsdmake") || \
(defined(.FreeBSD) && ${.FreeBSD} == "true")
SUBDIR += .WAIT
SUBDIR_PARALLEL = 1 # defined, for FreeBSD....
.elif defined(.MAKE.JOBS) && (${.MAKE.JOBS} > 1) && \
!defined(MAKE_VERSION)
#
# xxx: only more recent bmake's define .MAKE.JOBS. Maybe to support ancient
# OSx bsdmake maybe the .WAIT should be left in so the user has to manually
# remove it and thus see that parallel builds are unsupported?
# xxx: only more recent bmake's define .MAKE.JOBS.
#
. error "Parallel builds not supported without .WAIT in SUBDIR list."
.endif
Expand All @@ -266,7 +280,7 @@ SUBDIR += test
#
# The next section is mostly just default boilerplate for stand-alone project
# builds. It could/should be in a separate included file. (Except for some of
# the ${bmake_install_dirs}.)
# the setting of ${SUBDIR} and ${bmake_install_dirs}.)
#
# Yes, "make obj" is forced -- it is stupid to build in the source directory)
#
Expand Down Expand Up @@ -307,19 +321,6 @@ BUILDTARGETS += docs_subdir_${__dir}
. endfor
.endif

# this ("all") must be the VERY first target
# (there shouldn't be any .includes above, including Makefile.inc!)
#
# (Remove the .WAIT if your build blows up.)
#
all: .PHONY .MAKE bmake-test-obj .WAIT ${BUILDTARGETS}

# just in case old habits prevail
#
dependall: .PHONY all

.ORDER: bmake-test-obj bmake-do-obj bmake-do-depend ${SUBDIR} bmake-do-docs

.for targ in ${BUILDTARGETS:N.WAIT:N*_subdir_*}
${targ}: .PHONY .MAKE ${targ:S/bmake-do-//}
.endfor
Expand All @@ -334,6 +335,18 @@ ${__dir}: ${__targ}_subdir_${__dir} .PHONY .MAKE
. endfor
.endif

# this ("all") must be the VERY first target
# (there shouldn't be any .includes above, including Makefile.inc!)
#
all: .PHONY .MAKE bmake-test-obj .WAIT ${BUILDTARGETS}

# just in case old habits prevail
#
dependall: .PHONY all

# xxx the .WAIT's in here are probably not necessary???
.ORDER: bmake-test-obj .WAIT ${BUILDTARGETS}

# XXX this is just a very crude check... not as complete as the FreeBSD check
#
bmake-test-obj: .PHONY
Expand Down
16 changes: 10 additions & 6 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -165,24 +165,26 @@ incinstall: .PHONY
#
.if ((defined(TARGET_OSNAME) && (${TARGET_OSNAME} == "Linux")) || \
(defined(OS) && (${OS} == "Linux")))
#
# XXX stupid GNU BinUtils LD changed its command line syntax recently,
# apparently without concern for backward compatability.
#
# N.B.: also apparently on Linux BMake currently (20200710) doesn't use
# SHLIB_SHFLAGS for the final command, but instead LD_shared, and for non-BSD
# platforms the value of LD_shared directly overridden without consulting
# SHLIB_SHFLAGS.
# N.B.: also apparently on Linux BMake currently (20200710 on ubuntu-latest,
# 20181221 on ubuntu-20.04) doesn't use SHLIB_SHFLAGS for the final command, but
# instead LD_shared, and for non-BSD platforms the value of LD_shared directly
# overridden without consulting SHLIB_SHFLAGS.
#
# So, override LD_shared to use more portable '-h' instead of the apparently now
# dead '-soname' (we could use '--soname', but '-h' is probably more canonical).
#
LD_shared=-shared -Wl,-h,lib${LIB}.so.${SHLIB_MAJOR}
.endif

# Some hacks to try to get a lib*.dylib file built and installed on macos....
#
# We'll still link our own programs and tests with the static library as that
# makes testing during build possible, but providing a dylib might be useful for
# other uses....
# other uses and may make packager's jobs easier....
#
.if ${MAKE} != "bsdmake" && \
((defined(TARGET_OSNAME) && (${TARGET_OSNAME} == "Darwin")) || \
Expand All @@ -206,7 +208,7 @@ SHLIB_FULLVERSION ?= ${SHLIB_MAJOR}
SHLIB_FULLVERSION ?= ${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY}
. endif
SHLIB_INSTALL_VERSION ?= ${SHLIB_MAJOR}
# hmmm..... should compat be just SHLIB_MAJOR? (not according to Simon G.)
# hmmm..... should compat be just SHLIB_MAJOR? (not according to sjg)
SHLIB_COMPATABILITY_VERSION ?= ${SHLIB_MAJOR}.${SHLIB_MINOR}
# XXX do we need "-install_name=${PREFIX}/lib/lib${LIB}.dylib" too?
# xxx -dylib_*_version might be too new for macos-10.x
Expand All @@ -223,8 +225,10 @@ lib${LIB}.dylib: lib${LIB}.so.${SHLIB_FULLVERSION}
# @echo fixing up shared library name for macos: ${.TARGET}
# ln -sf lib${LIB}.so.${SHLIB_FULLVERSION} ${.TARGET}

# xxx why does this have realall too?
realall all: lib${LIB}.dylib

# xxx this
afterinstall: ${DESTDIR}${LIBDIR}/lib${LIB}.dylib

${DESTDIR}${LIBDIR}/lib${LIB}.dylib:
Expand Down
5 changes: 4 additions & 1 deletion src/yajl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ yajl_INCS += yajl_tree.h
# bsdmake! Probably not needed after there was a <bsd.inc.mk> symlink to
# <inc.mk>! Does no harm though.
#
.if defined(MAKE_VERSION) && (${MAKE_VERSION} < 5200408120)
# but must be avoided with pkgsrc bootstrap-mk-files...
#
.if defined(MAKE_VERSION) && (${MAKE_VERSION} < 5200408120) && \
(defined(unix) && ${unix} != "We run Unix")
INCS += ${yajl_INCS:S|^|${.CURDIR}/|}
.else
INCS += ${yajl_INCS}
Expand Down

0 comments on commit fbd4afb

Please sign in to comment.