ports/mk/targets.mk

126 lines
3.2 KiB
Makefile

# targets.mk - hhl - /usr/include/mk
# Copyright 2020 Nathan Fisher <nfisher.sr@gmail.com>
#
ifeq ($(no_objdir),1)
clean_cmd ?= $(MAKE) -C $(srcdir) clean distclean
else
clean_cmd ?= rm -rf $(objdir)
endif
distclean_cmd ?= rm -rf $(objdir) $(srcdir)
ifeq ($(distext),gz)
tarflags += -xzf
endif
ifeq ($(distext),bz2)
tarflags += -xjf
endif
ifeq ($(distext),xz)
tarflags += -xJf
endif
install_cmd ?= $(MAKE) DESTDIR=$(DESTDIR) -C $(objdir) install
all: $(all_deps)
.PHONY: all
install: $(workdir)/.installed
$(info $(grn)=== $(distfullname) installed ===$(reset))
.PHONY: install
package: $(pkglocal)
$(info $(grn)=== $(pkgfullname) created ===$(reset))
.PHONY: package
$(pkglocal): $(pkgdeps) | $(pkgdir)
$(info $(grn)=== creating package $(pkgfullname) ===$(reset))
hpk create -o $(pkgdir) -s package.specs $(DESTDIR)
$(workdir)/.installed: $(pkglocal)
$(info $(grn)=== Installing $(distlocal) ===$(reset))
pkg_add $<
touch $@
$(workdir)/.stripped: $(workdir)/.staged
find $(bindir) -type f -exec strip -s '{}' \; 2>&1 > /dev/null || true
find $(sbindir) -type f -exec strip -s '{}' \; 2>&1 > /dev/null || true
find $(libdir) -type f -exec strip -s '{}' \; 2>&1 > /dev/null || true
find $(libexecdir) -type f -exec strip -s '{}' \; 2>&1 > /dev/null || true
touch $@
$(workdir)/.staged: $(workdir)/.built
$(info $(grn)=== $(distfullname) built ===$(reset))
$(info $(grn)=== Installing for $(distfullname) ===$(reset))
$(pre_install)
$(install_cmd)
$(post_install)
touch $@
$(installdirs):
install -d $@
$(workdir)/.built: $(build_deps) | $(pre_dirs)
$(info $(grn)=== Building for $(distfullname)$(reset))
$(pre_build)
$(build_cmd)
$(post_build)
touch $@
$(config_tgt): $(config_deps) | $(pre_dirs)
$(info $(grn)=== Configuring for $(distfullname) ===$(reset))
$(pre_configure)
$(config_cmd)
$(post_configure)
touch $@
$(srcdir)/.patched: $(patches) $(srcdir)/.dirstamp
$(info $(grn)=== Patching $(srcdir) ===$(reset))
for patch in $(patches) ; do cd $(srcdir) && \
patch -p1 < $(portdir)/$${patch} ; done
touch $@
$(srcdir)/.dirstamp: $(distlocal) $(workdir)/.dependencies_installed | $(workdir)
$(info $(grn)=== Extracting $(distlocal) ===$(reset))
[ "$$(sha512sum $(distlocal) | awk '{ print $$1 }')" == "$(sha512_sum)" ]
tar $(tarflags) $(distlocal) -C work/
touch $@
install_dependencies: $(workdir)/.dependencies_installed
.PHONY: install_dependencies
$(workdir)/.dependencies_installed: | $(workdir)
for dep in $(dependencies) ; \
do depname=$$(basename $${dep}) ; \
if [ $$(pkg_info -qe $${depname}) ] ; \
then make -C /usr/ports/$${dep} install; \
fi ; done
touch $@
ifeq ($(use_configure),1)
show-config_opts:
$(info $(grn)$(config_opts)$(reset))
else
show-config_opts:
$(info $(red)Package does not use configure$(reset))
endif
config.mk: config.mk.in
$(info $(grn)Creating config.mk with default options$(reset))
$(info If you wish to modify the defaults, press Control-C and edit config.mk and then restart the build)
cp config.mk.in config.mk
$(distlocal): | $(distdir)
$(info $(grn)=== Fetching $(distfile) ===$(reset))
wget -c $(dist_remote) -O $@
clean:
$(info $(grn)=== Cleaning for $(distname) ===$(reset))
rm -rf $(portdir)/work
.PHONY: clean