]> Dogcows Code - chaz/yoink/blob - Makefile
testing new non-autotools build system
[chaz/yoink] / Makefile
1
2 #
3 # Yoink
4 # Use this file with make to compile and install Yoink.
5 #
6 # This makefile supports these targets:
7 # all, install, clean, cleandist, run, debug
8 #
9 # This build system incorporates the ideas written by Emile van Bergen:
10 # http://www.xs4all.nl/~evbergen/nonrecursive-make.html
11 #
12
13 #
14 # Define some options.
15 #
16
17 # Set this to `yes' to echo each build command.
18 verbose := no
19
20
21 #
22 # Include the configuration file, config.mk.
23 #
24
25 have_config := $(wildcard config.mk)
26 ifneq ($(strip $(have_config)),)
27 include config.mk
28 else
29 no_config:
30 @echo "You must run the configure script before you can make anything."
31 @exit 1
32 endif
33
34
35 #
36 # Some standard stuff.
37 #
38
39 .SUFFIXES:
40 .SUFFIXES: .a .c .cc .cpp .o .rc
41
42 all: targets
43
44
45 #
46 # Include the subdirectories--order is not important.
47 #
48
49 dir := src
50 include $(dir)/rules.mk
51
52 dir := data
53 include $(dir)/rules.mk
54
55 dir := doc
56 include $(dir)/rules.mk
57
58
59 #
60 # Define some common rules.
61 #
62
63 CC_WRAPPER = ./build/compile.sh $(CC)
64 CXX_WRAPPER = ./build/compile.sh $(CXX)
65
66 ifeq ($(verbose),no)
67 DO_CC = @echo " CC $@";
68 DO_CXX = @echo " CXX $@";
69 DO_LD = @echo " LD $@";
70 DO_LDX = @echo " LD $@";
71 DO_CCLD = @echo " CCLD $@";
72 DO_CXXLD = @echo " CXXLD $@";
73 DO_AR = @echo " AR $@";
74 DO_RC = @echo " RC $@";
75 endif
76
77 DO_CC += $(CC_WRAPPER) $(CFLAGS) $(CF_TGT) -o $@ -c $<
78 DO_CXX += $(CXX_WRAPPER) $(CXXFLAGS) $(CF_TGT) -o $@ -c $<
79 DO_LD += $(CC_WRAPPER) $(LDFLAGS) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LIBS)
80 DO_LDX += $(CXX_WRAPPER) $(LDFLAGS) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LIBS)
81 DO_CCLD += $(CC_WRAPPER) $(CFLAGS) $(CF_TGT) $(LDFLAGS) $(LF_TGT) -o $@ $< $(LL_TGT) $(LIBS)
82 DO_CXXLD += $(CXX_WRAPPER) $(CXXFLAGS) $(CF_TGT) $(LDFLAGS) $(LF_TGT) -o $@ $< $(LL_TGT) $(LIBS)
83 DO_AR += $(AR) rcs $@ $^; $(RANLIB) $@
84 DO_RC += $(WINDRES) $(DDEFINES) $(DF_TGT) -o $@ -i $<
85
86 %.o: %.c
87 $(DO_CC)
88 %.o: %.cc
89 $(DO_CXX)
90 %.o: %.cpp
91 $(DO_CXX)
92 %.o: %.rc
93 $(DO_RC)
94 %: %.o
95 $(DO_LD)
96 %: %.c
97 $(DO_CCLD)
98 %: %.cc
99 $(DO_CXXLD)
100 %: %.cpp
101 $(DO_CXXLD)
102 %.a: %.o
103 $(DO_AR)
104
105
106 #
107 # Stuff.
108 #
109
110 #TGT_BIN := $(addsuffix $(EXEEXT),$(TGT_BIN))
111
112
113 #
114 # Define the phony targets.
115 #
116
117 .PHONY: targets
118 targets: $(TGT_BIN) $(TGT_LIB)
119
120 .PHONY: clean
121 clean:
122 ifeq ($(verbose),yes)
123 rm -f $(CLEAN)
124 else
125 @echo " CLEAN"; rm -f $(CLEAN)
126 endif
127
128 .PHONY: distclean
129 distclean: clean
130 ifeq ($(verbose),yes)
131 rm -f config.mk
132 else
133 @rm -f config.mk
134 endif
135
136 .PHONY: install
137 install: targets
138 $(INSTALL) $(TGT_BIN) -m 755 -d $(DESTDIR)$(bindir)
139 $(INSTALL) $(TGT_DATA) -m 644 -d $(DESTDIR)$(datadir)
140 $(INSTALL) $(TGT_LIB) -m 750 -d $(DESTDIR)$(libdir)
141 $(INSTALL) $(TGT_MAN) -m 644 -d $(DESTDIR)$(mandir)
142
143
144 #
145 # Prevent make from removing any build targets.
146 #
147
148 .SECONDARY: $(CLEAN)
149
This page took 0.039426 seconds and 4 git commands to generate.