mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
0955086a6f
Stick a note near the OBJS sorting that it is there also to filter out duplicates, which are now occuring with SMB and FSP compiled in.
248 lines
7.1 KiB
Makefile
248 lines
7.1 KiB
Makefile
### The build commands and verbosity
|
|
|
|
# Colorize the build.
|
|
ifdef MAKE_COLOR
|
|
INFO_COLOR = $(shell tput setaf 5)
|
|
CC_COLOR = $(shell tput setaf 6)
|
|
LD_COLOR = $(shell tput setaf 2)
|
|
PO_COLOR = $(shell tput setaf 6)
|
|
LINK_COLOR = $(shell tput bold;tput setaf 4)
|
|
INSTALL_COLOR = $(shell tput setaf 3)
|
|
END_COLOR = $(shell tput sgr0)
|
|
endif
|
|
|
|
# sparse is architecture-neutral, which means that we need to tell it
|
|
# explicitly what architecture to check for. Fix this up for yours..
|
|
SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
|
|
|
|
|
|
#############################################################################
|
|
# Build recipies
|
|
|
|
# If we are verbose, we will show the "real" cmds instead of
|
|
# their quiet versions (which are used in the non-verbose mode).
|
|
# Inspired by the Linux kernel build system.
|
|
ifdef V
|
|
quiet =
|
|
mquiet = masq_
|
|
else
|
|
quiet = quiet_
|
|
mquiet = quiet_
|
|
endif
|
|
|
|
# Show the command (quiet or non-quiet version based on the assignment
|
|
# just above) and then execute it.
|
|
ncmd = $(if $($(quiet)cmd_$(1)),echo $($(quiet)cmd_$(1)) &&) $(cmd_$(1))
|
|
cmd = @$(if $($(quiet)cmd_$(1)),echo $($(quiet)cmd_$(1)) &&) $(cmd_$(1))
|
|
mcmd = @$(if $($(mquiet)cmd_$(1)),echo $($(mquiet)cmd_$(1)) &&) $(cmd_$(1))
|
|
ecmd = @$(if $($(mquiet)cmd_$(1)),printf "%-38s " $($(mquiet)cmd_$(1)) &&) $(cmd_$(1))
|
|
|
|
quiet_cmd_compile = ' [$(CC_COLOR)CC$(END_COLOR)] $(RELPATH)$@'
|
|
masq_cmd_compile = $(COMPILE) -o $(@) -c $< $(2)
|
|
cmd_compile = $(COMPILE) -o $(@) -Wp,-MD,.deps/$(*F).pp -c $< $(2)
|
|
|
|
# Rule to compile a set of .o files into one .o file
|
|
quiet_cmd_ld_objs = " [$(LD_COLOR)LD$(END_COLOR)] $(RELPATH)$@"
|
|
cmd_ld_objs = $(LD) -r -o $@ $(filter $(OBJS), $^) \
|
|
$(foreach subdir,$(sort $(filter-out src,$(SUBDIRS))), \
|
|
`test -e $(subdir)/$(LIB_O_NAME) && echo $(subdir)/$(LIB_O_NAME)`)
|
|
|
|
quiet_cmd_link = ' [$(LINK_COLOR)LINK$(END_COLOR)] $(RELPATH)$@'
|
|
cmd_link = $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(2) $(LIBS)
|
|
|
|
quiet_cmd_sparse = ' [SPARSE] $(RELPATH)$(2)'
|
|
cmd_sparse = $(SPARSE) $(DEFS) $(INCLUDES) $(AM_CFLAGS) $(CFLAGS) $(SPARSE_FLAGS) $(2)
|
|
|
|
# Recursive make
|
|
quiet_cmd_recmake = "[$(INFO_COLOR)MAKE $(3)$(END_COLOR)] $(RELPATH)$(2)"
|
|
cmd_recmake = $(MAKE) -C $(2) $(3)
|
|
|
|
quiet_cmd_installdata = " [$(INSTALL_COLOR)INSTALL$(END_COLOR)] $(RELPATH)$(2) -> $(3)"
|
|
cmd_installdata = $(INSTALL_DATA) $(2) $(3)
|
|
|
|
quiet_cmd_installprog = " [$(INSTALL_COLOR)INSTALL$(END_COLOR)] $(RELPATH)$(2) -> $(3)"
|
|
cmd_installprog = $(INSTALL_PROGRAM) $(2) $(3)
|
|
|
|
|
|
#############################################################################
|
|
# Special handling of conditional variables
|
|
|
|
SUBDIRS += $(SUBDIRS-yes)
|
|
OBJS += $(OBJS-yes)
|
|
|
|
ALTDIRS = $(SUBDIRS-no) $(SUBDIRS-)
|
|
ALTOBJS = $(OBJS-no) $(OBJS-)
|
|
|
|
ifneq ($(findstring cleanall,$(MAKECMDGOALS)),)
|
|
INCLUDE_ALL=1
|
|
endif
|
|
|
|
ifneq ($(findstring init,$(MAKECMDGOALS)),)
|
|
INCLUDE_ALL=1
|
|
ifndef SRC
|
|
SRC = $(shell cd $(top_srcdir) && pwd)
|
|
endif
|
|
endif
|
|
|
|
ifdef INCLUDE_ALL
|
|
SUBDIRS += $(ALTDIRS)
|
|
OBJS += $(ALTOBJS)
|
|
endif
|
|
|
|
|
|
#############################################################################
|
|
# Internal build rules
|
|
|
|
# All files in $(OBJS) and any $(subdir)/lib.o are linked into lib.o.
|
|
# Sort them to filter out duplicated and get uniform order.
|
|
LIB_O_DEPS = \
|
|
$(sort $(filter-out $(LIB_O_NAME),$(OBJS))) \
|
|
$(foreach subdir,$(sort $(SUBDIRS)),$(wildcard $(subdir)/$(LIB_O_NAME)))
|
|
|
|
$(LIB_O_NAME): $(LIB_O_DEPS)
|
|
$(call cmd,ld_objs)
|
|
|
|
DEP_FILES_1 = $(foreach src,$(OBJS),.deps/$(src))
|
|
DEP_FILES = $(DEP_FILES_1:%.o=%.P)
|
|
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
|
|
|
ifneq ($(strip $(OBJS)),)
|
|
-include $(DEP_FILES)
|
|
OBJS += $(LIB_O_NAME)
|
|
endif
|
|
|
|
%.o: $(srcdir)%.c
|
|
$(call mcmd,compile)
|
|
@-if test -e .deps/$(*F).pp; then \
|
|
cp .deps/$(*F).pp .deps/$(*F).P; \
|
|
tr ' ' '\012' < .deps/$(*F).pp \
|
|
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
|
>> .deps/$(*F).P; \
|
|
rm .deps/$(*F).pp; \
|
|
fi
|
|
|
|
CLEAN += $(PROG) $(OBJS)
|
|
|
|
|
|
#############################################################################
|
|
# The main default rules
|
|
|
|
all-default: $(OBJS) $(PROGS) $(MAN1) $(MAN5) .vimrc
|
|
|
|
# Ensure that Makefiles in subdirs are created before we recursive into them
|
|
init-recursive: init-default
|
|
|
|
init-default: .vimrc
|
|
@$(foreach subdir,$(sort $(SUBDIRS)), \
|
|
$(MKINSTALLDIRS) $(subdir) >/dev/null; \
|
|
test -e "$(subdir)/Makefile" \
|
|
|| echo 'include $(SRC)/$(RELPATH)/$(subdir)/Makefile' > $(subdir)/Makefile;)
|
|
|
|
clean-default cleanall-default:
|
|
@-test -z "$(CLEAN)" || $(RM) $(CLEAN)
|
|
|
|
check-default:
|
|
ifneq ($(SPARSE),)
|
|
@$(foreach file, $(wildcard *.c), \
|
|
$(call ncmd,sparse,$(file));)
|
|
endif
|
|
|
|
install-default: all-default
|
|
ifdef PROGS
|
|
@$(MKINSTALLDIRS) $(DESTDIR)$(bindir)
|
|
@$(foreach file,$(PROGS), \
|
|
$(call ncmd,installprog,$(file),$(DESTDIR)$(bindir));)
|
|
endif
|
|
ifdef MAN1
|
|
@$(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man1
|
|
@$(foreach file,$(MAN1), \
|
|
$(call ncmd,installdata,$(file),$(DESTDIR)$(mandir)/man1);)
|
|
endif
|
|
ifdef MAN5
|
|
@$(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man5
|
|
@$(foreach file,$(MAN5), \
|
|
$(call ncmd,installdata,$(file),$(DESTDIR)$(mandir)/man5);)
|
|
endif
|
|
|
|
.vimrc: $(top_srcdir)/Makefile.lib
|
|
@{ echo ':set runtimepath+=.'; \
|
|
echo ':runtime $(top_srcdir)/config/vimrc'; \
|
|
} > .vimrc
|
|
|
|
##############################################################################
|
|
# Auto-testing infrastructure
|
|
|
|
test-default:
|
|
|
|
ifdef TEST_PROGS
|
|
TESTDEPS-$(CONFIG_DEBUG) += $(top_builddir)/src/util/memdebug.o
|
|
TESTDEPS += $(TESTDEPS-yes)
|
|
|
|
TESTS = $(wildcard $(srcdir)test-*)
|
|
|
|
$(TEST_PROGS): $(TESTDEPS)
|
|
$(call cmd,link,$@.o)
|
|
|
|
# We cannot use $$@.o in the rule above so ensure that all test programs are
|
|
# built before linking.
|
|
$(TESTS): $(addsuffix .o,$(TEST_PROGS)) $(TEST_PROGS)
|
|
@echo "*** $(notdir $@) ***"; \
|
|
$(call shellquote,$(SHELL)) $@ $(TEST_OPTS)
|
|
|
|
test-default: $(TESTS)
|
|
|
|
clean-test:
|
|
@rm -fr trash
|
|
|
|
CLEAN += $(TEST_PROGS) $(addsuffix .o,$(TEST_PROGS))
|
|
clean-default: clean-test
|
|
endif
|
|
|
|
.PHONY: $(TESTS)
|
|
.NOPARALLEL:
|
|
|
|
|
|
#############################################################################
|
|
# Basic recursion and dependencies setup
|
|
|
|
RULES = all install clean cleanall init check test
|
|
|
|
RULES_LOCAL = $(addsuffix -local,$(RULES))
|
|
RULES_REC = $(addsuffix -recursive,$(RULES))
|
|
|
|
.PHONY: $(RULES) $(RULES_LOCAL) $(RULES_REC) $(addsuffix -default,$(RULES))
|
|
|
|
# The -recursive rules decend all subdirs.
|
|
$(RULES_REC):
|
|
@$(foreach subdir,$(sort $(SUBDIRS)), \
|
|
$(call ncmd,recmake,$(subdir),$(subst -recursive,,$@)) || exit 1;)
|
|
|
|
# Dummy -local rules
|
|
$(RULES_LOCAL):
|
|
|
|
# Default deps
|
|
rule_deps = $(1)-recursive $(1)-default $(1)-local
|
|
all: $(call rule_deps,all)
|
|
install: $(call rule_deps,install)
|
|
clean: $(call rule_deps,clean)
|
|
cleanall: $(call rule_deps,cleanall)
|
|
init: $(call rule_deps,init)
|
|
check: $(call rule_deps,check)
|
|
test: $(call rule_deps,test)
|
|
|
|
#############################################################################
|
|
# Misc
|
|
|
|
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
|
# Otherwise a system limit (for SysV at least) may be exceeded.
|
|
.NOEXPORT:
|
|
|
|
# Shell quote;
|
|
# Result of this needs to be placed inside ''
|
|
# XXX: Placed here because Vim cannot highlight things right afterwards
|
|
shq = $(subst ','\'',$(1))
|
|
# This has surrounding ''
|
|
shellquote = '$(call shq,$(1))'
|
|
|
|
# vim:syntax=make
|