build: config.mk: Fix python-config switch
[gfxprim/pasky.git] / post.mk
blob0b9fc905c1efe93ca0f7edbfa64c189cec451fc2
2 # Make no subdirs by default
4 ifndef SUBDIRS
5 SUBDIRS=
6 endif
8 .PHONY: $(SUBDIRS) all clean rebuild help doc install
10 all: $(SUBDIRS)
11 clean: $(SUBDIRS)
12 distclean: $(SUBDIRS)
13 rebuild: $(SUBDIRS)
14 install: $(SUBDIRS)
16 help:
17 @echo "*** Available targets ***"
18 @echo ""
19 @echo "help: prints this help"
20 @echo ""
21 @echo "doc: builds (only) the documentation"
22 @echo ""
23 @echo "clean: cleans current directory and all subdirectories"
24 @echo ""
25 @echo "distclean: cleans all generated files including possible"
26 @echo " leftovers caused by deleted files"
27 @echo ""
28 @echo "all: make current directory and all subdirectories"
29 @echo ""
30 @echo "rebuild: does clean and all"
31 @echo ""
32 @echo "The default silent output could be turned off by defining"
33 @echo "'VERBOSE' shell variable as 'VERBOSE=1 make'"
34 @echo ""
36 doc:
37 cd doc && make
40 # Determine mode (eg do not generate anything if not in compile mode
42 COMPILE=no
44 ifeq ($(MAKECMDGOALS),all)
45 COMPILE=yes
46 endif
48 ifeq ($(MAKECMDGOALS),)
49 COMPILE=yes
50 endif
52 ifeq ($(MAKECMDGOALS),rebuild)
53 COMPILE=yes
54 endif
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
61 ifdef CSOURCES
62 DEPFILES=$(subst .c,.dep,$(CSOURCES))
63 ifeq ($(COMPILE),yes)
64 -include $(DEPFILES)
65 endif
66 CLEAN+=$(subst .c,.dep,$(CSOURCES))
67 OBJECTS+=$(CSOURCES:.c=.o)
68 CLEAN+=$(OBJECTS)
69 endif
72 # Automatically include library headers
74 ifdef LIBNAME
75 INCLUDE+=$(LIBNAME)
76 endif
79 # If there was anything in INCLUDE list, create CFLAGS for each entry
81 ifdef INCLUDE
82 CFLAGS+=$(addprefix -I$(TOPDIR)/include/, $(INCLUDE))
83 endif
86 # Walk trought SUBDIRS, this code works even for -jX
88 $(SUBDIRS):
89 ifdef VERBOSE
90 $(MAKE) -C $@ $(MAKECMDGOALS) TOP_MAKE=$(TOP_MAKE)
91 else
92 @export CURSUBDIR="$$CURSUBDIR/$@" && echo "DIR $$CURSUBDIR" &&\
93 $(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS) TOP_MAKE=$(TOP_MAKE)
94 endif
97 # Actual make rules
99 $(DEPFILES): %.dep: %.c
100 ifdef VERBOSE
101 $(CC) -MM $(CFLAGS) $< -o $@
102 else
103 @echo "DEP -I(include $(INCLUDE)) $@"
104 @$(CC) -MM $(CFLAGS) $< -o $@
105 endif
107 $(OBJECTS): %.o: %.c
108 ifdef VERBOSE
109 $(CC) $(CFLAGS) -c $< -o $@
110 else
111 @echo "CC -I(include $(INCLUDE)) $@"
112 @$(CC) $(CFLAGS) -c $< -o $@
113 endif
115 ifdef CLEAN
117 ifeq ($(MAKECMDGOALS),distclean)
118 CLEAN+=*.o *.dep *.gen.c *.gen.h
119 endif
121 distclean: clean
123 clean:
124 ifdef VERBOSE
125 rm -f $(CLEAN)
126 else
127 @echo "RM $(CLEAN)"
128 @rm -f $(CLEAN)
129 endif
130 endif
132 compile: $(DEPFILES) $(OBJECTS) $(ALL)
134 rebuild: clean
135 @$(MAKE) --no-print-directory all