2 # Make no subdirs by default
8 .PHONY
: $(SUBDIRS
) all clean rebuild help doc
15 @echo
"*** Available targets ***"
17 @echo
"help: prints this help"
19 @echo
"doc: builds (only) the documentation"
21 @echo
"clean: cleans current directory and all subdirectories"
23 @echo
"all: make current directory and all subdirectories"
25 @echo
"rebuild: does clean and all"
27 @echo
"The default silent output could be turned off by defining"
28 @echo
"'VERBOSE' shell variable as 'VERBOSE=1 make'"
35 # Determine mode (eg do not generate anything if not in compile mode
39 ifeq ($(MAKECMDGOALS
),all)
43 ifeq ($(MAKECMDGOALS
),)
47 ifeq ($(MAKECMDGOALS
),rebuild
)
52 # 1. Generate and include dependencies for all C sources
53 # 2. Generate OBJECTS list from CSOURCES list
54 # 3. Adds OBJECTS to CLEAN list
57 DEPFILES
=$(subst .c
,.dep
,$(CSOURCES
))
61 CLEAN
+=$(subst .c
,.dep
,$(CSOURCES
))
62 OBJECTS
+=$(CSOURCES
:.c
=.o
)
67 # Automatically include library headers
74 # If there was anything in INCLUDE list, create CFLAGS for each entry
77 CFLAGS
+=$(addprefix -I
$(TOPDIR
)/include/, $(INCLUDE
))
81 # Walk trought SUBDIRS, this code works even for -jX
85 $(MAKE
) -C
$@
$(MAKECMDGOALS
)
87 @
export CURSUBDIR
="$$CURSUBDIR/$@" && echo
"DIR $$CURSUBDIR" &&\
88 $(MAKE
) --no-print-directory
-C
$@
$(MAKECMDGOALS
)
94 $(DEPFILES
): %.dep
: %.c
96 $(CC
) -MM
$(CFLAGS
) $< -o
$@
98 @echo
"DEP -I(include $(INCLUDE)) $@"
99 @
$(CC
) -MM
$(CFLAGS
) $< -o
$@
104 $(CC
) $(CFLAGS
) -c
$< -o
$@
106 @echo
"CC -I(include $(INCLUDE)) $@"
107 @
$(CC
) $(CFLAGS
) -c
$< -o
$@
120 compile
: $(DEPFILES
) $(OBJECTS
) $(ALL
)
123 @
$(MAKE
) --no-print-directory
all