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
"check: do pre-commit check"
33 @echo
" (currently checks for exported symbols)"
35 @echo
"The default silent output could be turned off by defining"
36 @echo
"'VERBOSE' shell variable as 'VERBOSE=1 make'"
40 @cd
$(TOPDIR
)/doc
&& make
43 @cd
$(TOPDIR
)/build
&& .
/check_symbols.sh
46 # Determine mode (eg do not generate anything if not in compile mode
50 ifeq ($(MAKECMDGOALS
),all)
54 ifeq ($(MAKECMDGOALS
),)
58 ifeq ($(MAKECMDGOALS
),rebuild
)
63 # 1. Generate and include dependencies for all C sources
64 # 2. Generate OBJECTS list from CSOURCES list
65 # 3. Adds OBJECTS to CLEAN list
68 DEPFILES
=$(subst .c
,.dep
,$(CSOURCES
))
72 CLEAN
+=$(subst .c
,.dep
,$(CSOURCES
))
73 OBJECTS
+=$(CSOURCES
:.c
=.o
)
78 # Automatically include library headers
85 # If there was anything in INCLUDE list, create CFLAGS for each entry
88 CFLAGS
+=$(addprefix -I
$(TOPDIR
)/include/, $(INCLUDE
))
92 # Walk trought SUBDIRS, this code works even for -jX
96 $(MAKE
) -C
$@
$(MAKECMDGOALS
) TOP_MAKE
=$(TOP_MAKE
)
98 @
export CURSUBDIR
="$$CURSUBDIR/$@" && echo
"DIR $$CURSUBDIR" &&\
99 $(MAKE
) --no-print-directory
-C
$@
$(MAKECMDGOALS
) TOP_MAKE
=$(TOP_MAKE
)
105 $(DEPFILES
): %.dep
: %.c
107 $(CC
) -MM
$(CFLAGS
) $< -o
$@
109 @echo
"DEP -I(include $(INCLUDE)) $@"
110 @
$(CC
) -MM
$(CFLAGS
) $< -o
$@
115 $(CC
) $(CFLAGS
) -c
$< -o
$@
117 @echo
"CC -I(include $(INCLUDE)) $@"
118 @
$(CC
) $(CFLAGS
) -c
$< -o
$@
123 ifeq ($(MAKECMDGOALS
),distclean)
124 CLEAN
+=*.o
*.dep
*.gen.c
*.gen.h
138 compile
: $(DEPFILES
) $(OBJECTS
) $(ALL
)
141 @
$(MAKE
) --no-print-directory
all