view mk/lib.mk @ 21:1c9dac05d040

Add lint-style FALLTHROUGH annotations to fallthrough cases. (in the parse engine and thus the output code) Document this, because the old output causes warnings with gcc10.
author David A. Holland
date Mon, 13 Jun 2022 00:04:38 -0400
parents bb115deb6fb2
children
line wrap: on
line source

#
# lib.mk - build a library, in portable make.
#
# Before including, set:
#    LIB                         library to build
#    LIBTYPE                     LIB or SHLIB (or $(AGLIBTYPE))
#
# and set:
#    SRCS                        sources
#    RCFILES (optional)          Windows resource files
#    SYNS (optional)             AG syntax files
#    SYNOUTPUTEXT (optional)     output suffix for AG files
#    AGFILEDEST (optional)       destination for AG files ("here" or "srcdir")
#

SYNOUTPUTEXT?=.cpp
AGFILEDEST?=srcdir

include $(BUILDTOP)/config.mk

# beforeall used by: cg46.h in anagram
# afterall used by: none

all: beforeall doall afterall
beforeall doall afterall:;

# BSD make has .WAIT to make beforeall/afterall work, but gmake doesn't.
.NOTPARALLEL:

doall: all.$(LIBTYPE)
all.LIB: $(LIB)$(LIBEXT)
all.SHLIB: $(LIB)$(SHLIBEXT)
TYPE=$(LIBTYPE)

include rules.mk
include depend.mk

$(LIB)$(LIBEXT): $(OBJS) $(MYLIBS)
	@echo '        [DEP]'
	@$(MKDEP)
	@echo '        [LIB]     $@'
	@$(LDR) $(LIB)$(LIBEXT) $(OBJS) $(RESFILES) $(MYLIBS)

$(LIB)$(SHLIBEXT): $(OBJS) $(MYLIBS)
	@echo '        [DEP]'
	@$(MKDEP)
	@echo '        [SHLIB]   $@'
	@$(SHLDCC) $(OBJS) $(RESFILES) $(MYLIBS) -o $@

rules:
	@$(TOP)/mk/include-defs.sh '$(INCDIRS)' > rules.mk
	@$(TOP)/mk/compile-rules.sh '$(SRCS)' '$(RCFILES)' >> rules.mk
	@$(TOP)/mk/agfile-rules.sh $(AGFILEDEST) '$(SYNS)' '$(SYNOUTPUTEXT)' \
	    $(MAINTAINER) >> rules.mk
#	@echo '        [RULES]'

depend:
	@echo '        [DEP]'
	@$(MKDEP)

clean:
	@echo '        [RM]      $(CLEANFILES) *~'
	@rm -f $(CLEANFILES) *~

distclean: clean
	@echo '        [RM]      $(DISTCLEANFILES) *~'
	@rm -f $(DISTCLEANFILES) *~

.PHONY: all rules depend clean distclean
.PHONY: beforeall doall afterall
.PHONY: beforedepend dodepend afterdepend
.PHONY: all.LIB all.SHLIB