2 # Make no subdirs by default
8 .PHONY
: $(SUBDIRS
) all clean rebuild help doc
install
17 @echo
"*** Available targets ***"
19 @echo
"help: prints this help"
21 @echo
"doc: builds (only) the documentation"
23 @echo
"clean: cleans current directory and all subdirectories"
25 @echo
"distclean: cleans all generated files including possible"
26 @echo
" leftovers caused by deleted files"
28 @echo
"all: make current directory and all subdirectories"
30 @echo
"rebuild: does clean and all"
32 @echo
"The default silent output could be turned off by defining"
33 @echo
"'VERBOSE' shell variable as 'VERBOSE=1 make'"
40 # Determine mode (eg do not generate anything if not in compile mode
44 ifeq ($(MAKECMDGOALS
),all)
48 ifeq ($(MAKECMDGOALS
),)
52 ifeq ($(MAKECMDGOALS
),rebuild
)
57 # 1. Generate and include dependencies for all C sources
58 # 2. Generate OBJECTS list from CSOURCES list
59 # 3. Adds OBJECTS to CLEAN list
62 DEPFILES
=$(subst .c
,.dep
,$(CSOURCES
))
66 CLEAN
+=$(subst .c
,.dep
,$(CSOURCES
))
67 OBJECTS
+=$(CSOURCES
:.c
=.o
)
72 # Automatically include library headers
79 # If there was anything in INCLUDE list, create CFLAGS for each entry
82 CFLAGS
+=$(addprefix -I
$(TOPDIR
)/include/, $(INCLUDE
))
86 # Walk trought SUBDIRS, this code works even for -jX
90 $(MAKE
) -C
$@
$(MAKECMDGOALS
) TOP_MAKE
=$(TOP_MAKE
)
92 @
export CURSUBDIR
="$$CURSUBDIR/$@" && echo
"DIR $$CURSUBDIR" &&\
93 $(MAKE
) --no-print-directory
-C
$@
$(MAKECMDGOALS
) TOP_MAKE
=$(TOP_MAKE
)
99 $(DEPFILES
): %.dep
: %.c
101 $(CC
) -MM
$(CFLAGS
) $< -o
$@
103 @echo
"DEP -I(include $(INCLUDE)) $@"
104 @
$(CC
) -MM
$(CFLAGS
) $< -o
$@
109 $(CC
) $(CFLAGS
) -c
$< -o
$@
111 @echo
"CC -I(include $(INCLUDE)) $@"
112 @
$(CC
) $(CFLAGS
) -c
$< -o
$@
117 ifeq ($(MAKECMDGOALS
),distclean)
118 CLEAN
+=*.o
*.dep
*.gen.c
*.gen.h
132 compile
: $(DEPFILES
) $(OBJECTS
) $(ALL
)
135 @
$(MAKE
) --no-print-directory
all