2 # Make no subdirs by default
8 .PHONY
: $(SUBDIRS
) all clean rebuild help
15 @echo
"*** Available targets ***"
17 @echo
"help: prints this help"
19 @echo
"clean: cleans current directory and all subdirectories"
21 @echo
"all: make current directory and all subdirectories"
23 @echo
"rebuild: does clean and all"
25 @echo
"The default silent output could be turned off by defining"
26 @echo
"'VERBOSE' shell variable as 'VERBOSE=1 make'"
30 # Determine mode (eg do not generate anything if not in compile mode
34 ifeq ($(MAKECMDGOALS
),all)
38 ifeq ($(MAKECMDGOALS
),)
42 ifeq ($(MAKECMDGOALS
),rebuild
)
47 # 1. Generate and include dependencies for all C sources
48 # 2. Generate OBJECTS list from CSOURCES list
49 # 3. Adds OBJECTS to CLEAN list
52 DEPFILES
=$(subst .c
,.dep
,$(CSOURCES
))
56 CLEAN
+=$(subst .c
,.dep
,$(CSOURCES
))
57 OBJECTS
+=$(CSOURCES
:.c
=.o
)
62 # Automatically include library headers
69 # If there was anything in INCLUDE list, create CFLAGS for each entry
72 CFLAGS
+=$(addprefix -I
$(TOPDIR
)/include/, $(INCLUDE
))
76 # Walk trought SUBDIRS, this code works even for -jX
80 $(MAKE
) -C
$@
$(MAKECMDGOALS
)
82 @
export CURSUBDIR
="$$CURSUBDIR/$@" && echo
"DIR $$CURSUBDIR" &&\
83 $(MAKE
) --no-print-directory
-C
$@
$(MAKECMDGOALS
)
89 $(DEPFILES
): %.dep
: %.c
91 $(CC
) -MM
$(CFLAGS
) $< -o
$@
93 @echo
"DEP -I(include $(INCLUDE)) $@"
94 @
$(CC
) -MM
$(CFLAGS
) $< -o
$@
99 $(CC
) $(CFLAGS
) -c
$< -o
$@
101 @echo
"CC -I(include $(INCLUDE)) $@"
102 @
$(CC
) $(CFLAGS
) -c
$< -o
$@
115 compile
: $(DEPFILES
) $(OBJECTS
) $(ALL
)
118 @
$(MAKE
) --no-print-directory
all