demos: Particle demo update.
[gfxprim.git] / include.mk
blobc8f8b189ea86646fd73c1375971558d2d6239060
2 # Make no subdirs by default
4 ifndef SUBDIRS
5 SUBDIRS=
6 endif
8 .PHONY: $(SUBDIRS) all clean help
10 all: $(SUBDIRS)
11 clean: $(SUBDIRS)
13 help:
14 @echo "*** Available targets ***"
15 @echo ""
16 @echo "help: prints this help"
17 @echo ""
18 @echo "clean: cleans current directory and all subdirectories"
19 @echo ""
20 @echo "all: make current directory and all subdirectories"
21 @echo ""
22 @echo "The default silent output could be turned off by defining"
23 @echo "'VERBOSE' shell variable as 'VERBOSE=1 make'"
24 @echo ""
26 include $(TOPDIR)/config.mk
29 # Determine mode (eg do not generate anything if not in compile mode
31 COMPILE=no
33 ifeq ($(MAKECMDGOALS),all)
34 COMPILE=yes
35 endif
37 ifeq ($(MAKECMDGOALS),)
38 COMPILE=yes
39 endif
42 # Potential python dependencies for generated files and scripts
44 PYTHON_FILES=$(shell find "${PYLIBSDIR}" -name '*.py')
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
51 ifdef CSOURCES
52 DEPFILES=$(subst .c,.dep,$(CSOURCES))
53 ifeq ($(COMPILE),yes)
54 -include $(DEPFILES)
55 endif
56 CLEAN+=$(subst .c,.dep,$(CSOURCES))
57 OBJECTS=$(CSOURCES:.c=.o)
58 CLEAN+=$(OBJECTS)
59 endif
62 # Automatically include library headers
64 ifdef LIBNAME
65 INCLUDE+=$(LIBNAME)
66 endif
69 # If there was anything in INCLUDE list, create CFLAGS for each entry
71 ifdef INCLUDE
72 CFLAGS+=$(addprefix -I$(TOPDIR)/include/, $(INCLUDE))
73 endif
76 # Walk trought SUBDIRS, this code works even for -jX
78 $(SUBDIRS):
79 ifdef VERBOSE
80 $(MAKE) -C $@ $(MAKECMDGOALS)
81 else
82 @export CURSUBDIR="$$CURSUBDIR/$@" && echo "DIR $$CURSUBDIR" &&\
83 $(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS)
84 endif
87 # Actual make rules
89 $(DEPFILES): %.dep: %.c
90 ifdef VERBOSE
91 $(CC) -MM $(CFLAGS) $< -o $@
92 else
93 @echo "DEP -I(include $(INCLUDE)) $@"
94 @$(CC) -MM $(CFLAGS) $< -o $@
95 endif
97 $(OBJECTS): %.o: %.c
98 ifdef VERBOSE
99 $(CC) $(CFLAGS) -c $< -o $@
100 else
101 @echo "CC -I(include $(INCLUDE)) $@"
102 @$(CC) $(CFLAGS) -c $< -o $@
103 endif
105 ifdef CLEAN
106 clean:
107 ifdef VERBOSE
108 rm -f $(CLEAN)
109 else
110 @echo "RM $(CLEAN)"
111 @rm -f $(CLEAN)
112 endif
113 endif