input: X11: Load some KeyCodes dynamically.
[gfxprim.git] / post.mk
blob881a42f8d4654191cf55a6533bf8eca0004b2038
2 # Make no subdirs by default
4 ifndef SUBDIRS
5 SUBDIRS=
6 endif
8 .PHONY: $(SUBDIRS) all clean rebuild help doc
10 all: $(SUBDIRS)
11 clean: $(SUBDIRS)
12 rebuild: $(SUBDIRS)
14 help:
15 @echo "*** Available targets ***"
16 @echo ""
17 @echo "help: prints this help"
18 @echo ""
19 @echo "doc: builds (only) the documentation"
20 @echo ""
21 @echo "clean: cleans current directory and all subdirectories"
22 @echo ""
23 @echo "all: make current directory and all subdirectories"
24 @echo ""
25 @echo "rebuild: does clean and all"
26 @echo ""
27 @echo "The default silent output could be turned off by defining"
28 @echo "'VERBOSE' shell variable as 'VERBOSE=1 make'"
29 @echo ""
31 doc:
32 cd doc && make
35 # Determine mode (eg do not generate anything if not in compile mode
37 COMPILE=no
39 ifeq ($(MAKECMDGOALS),all)
40 COMPILE=yes
41 endif
43 ifeq ($(MAKECMDGOALS),)
44 COMPILE=yes
45 endif
47 ifeq ($(MAKECMDGOALS),rebuild)
48 COMPILE=yes
49 endif
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
56 ifdef CSOURCES
57 DEPFILES=$(subst .c,.dep,$(CSOURCES))
58 ifeq ($(COMPILE),yes)
59 -include $(DEPFILES)
60 endif
61 CLEAN+=$(subst .c,.dep,$(CSOURCES))
62 OBJECTS+=$(CSOURCES:.c=.o)
63 CLEAN+=$(OBJECTS)
64 endif
67 # Automatically include library headers
69 ifdef LIBNAME
70 INCLUDE+=$(LIBNAME)
71 endif
74 # If there was anything in INCLUDE list, create CFLAGS for each entry
76 ifdef INCLUDE
77 CFLAGS+=$(addprefix -I$(TOPDIR)/include/, $(INCLUDE))
78 endif
81 # Walk trought SUBDIRS, this code works even for -jX
83 $(SUBDIRS):
84 ifdef VERBOSE
85 $(MAKE) -C $@ $(MAKECMDGOALS) TOP_MAKE=$(TOP_MAKE)
86 else
87 @export CURSUBDIR="$$CURSUBDIR/$@" && echo "DIR $$CURSUBDIR" &&\
88 $(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS) TOP_MAKE=$(TOP_MAKE)
89 endif
92 # Actual make rules
94 $(DEPFILES): %.dep: %.c
95 ifdef VERBOSE
96 $(CC) -MM $(CFLAGS) $< -o $@
97 else
98 @echo "DEP -I(include $(INCLUDE)) $@"
99 @$(CC) -MM $(CFLAGS) $< -o $@
100 endif
102 $(OBJECTS): %.o: %.c
103 ifdef VERBOSE
104 $(CC) $(CFLAGS) -c $< -o $@
105 else
106 @echo "CC -I(include $(INCLUDE)) $@"
107 @$(CC) $(CFLAGS) -c $< -o $@
108 endif
110 ifdef CLEAN
111 clean:
112 ifdef VERBOSE
113 rm -f $(CLEAN)
114 else
115 @echo "RM $(CLEAN)"
116 @rm -f $(CLEAN)
117 endif
118 endif
120 compile: $(DEPFILES) $(OBJECTS) $(ALL)
122 rebuild: clean
123 @$(MAKE) --no-print-directory all