2005-09-15 15:03:56 -04:00
|
|
|
### The build commands and verbosity
|
|
|
|
|
|
|
|
# If we are verbose, we will show commands prefixed by $(Q) (which acts as
|
|
|
|
# @ in the non-verbose mode), and 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
|
|
|
|
Q =
|
|
|
|
quiet =
|
|
|
|
mquiet = masq_
|
|
|
|
else
|
|
|
|
Q = @
|
|
|
|
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))
|
|
|
|
|
|
|
|
quiet_cmd_compile = '[CC] $<'
|
|
|
|
masq_cmd_compile = $(COMPILE) -c $<
|
|
|
|
cmd_compile = $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
|
|
|
|
|
|
|
quiet_cmd_archive = '[AR] $@'
|
|
|
|
cmd_archive = $(AR) r $@ $^
|
|
|
|
|
|
|
|
quiet_cmd_link = '[LINK] $@'
|
2005-09-16 07:13:43 -04:00
|
|
|
cmd_link = $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
|
2005-09-15 15:03:56 -04:00
|
|
|
|
|
|
|
# Recursive make
|
|
|
|
quiet_cmd_recmake = "[MAKE $$target] $$subdir"
|
2005-09-15 20:07:36 -04:00
|
|
|
cmd_recmake = $(MAKE) -C $$subdir $$target
|
2005-09-15 15:03:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Internal build rules
|
|
|
|
|
|
|
|
DEP_FILES_1 = $(foreach src,$(OBJS),.deps/$(src))
|
|
|
|
DEP_FILES = $(DEP_FILES_1:%.o=%.P)
|
|
|
|
|
|
|
|
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
|
|
|
|
|
|
|
ifdef $(OBJS)
|
|
|
|
-include $(DEP_FILES)
|
|
|
|
endif
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(call mcmd,compile)
|
|
|
|
@-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
|
|
|
|
|
|
|
|
%.a:
|
|
|
|
$(call cmd,archive)
|
|
|
|
|
2005-09-15 17:28:56 -04:00
|
|
|
ifdef $(OBJS)
|
2005-09-15 18:52:54 -04:00
|
|
|
clean-l:
|
2005-09-15 17:28:56 -04:00
|
|
|
rm -f $(OBJS) *.a
|
|
|
|
endif
|
|
|
|
|
2005-09-15 15:03:56 -04:00
|
|
|
|
|
|
|
# Recursion:
|
|
|
|
|
|
|
|
.PHONY: all-recursive install-recursive clean-recursive
|
|
|
|
all-recursive install-recursive clean-recursive:
|
|
|
|
@target=`echo $@ | sed s/-recursive//`; \
|
|
|
|
for subdir in $(SUBDIRS); do \
|
|
|
|
$(call ncmd,recmake) || exit 1; \
|
|
|
|
done
|
|
|
|
|
2005-09-15 18:52:54 -04:00
|
|
|
all: all-recursive all-l
|
|
|
|
install: install-recursive install-l
|
|
|
|
clean: clean-recursive clean-l
|
|
|
|
|
|
|
|
all-l:
|
|
|
|
install-l:
|
|
|
|
clean-l:
|
2005-09-15 17:28:56 -04:00
|
|
|
|
2005-09-15 15:03:56 -04:00
|
|
|
|
|
|
|
# vim:syntax=make
|