4 # Copyright (C) 1999 by Matteo Cavalleri
7 # This makefile is flexible enough to be used for every
8 # class of the OpenBoopsi project. You should not need to
11 # all: create the demo program and the class library
12 # with no debugging information and code
14 # lib: create just the library of the public class
15 # with no debugging information and code
17 # private: create the demo program linked with optimized version of the class
19 # debug: create the demo program linked with debug version of the class
21 # obj: create just the class object ready to be linked
22 # to a program, with no debugging information and code
24 # install: copy the demos and classes to the appropriate
28 ###########################################################
31 BOOPSI_DEPS := $(INCDIR)/BoopsiStubs.h $(INCDIR)/CompilerSpecific.h $(INCDIR)/DebugMacros.h
32 CLASSOBJ_SHARED := $(subst .c,_shared.o,$(CLASSSRC))
33 CLASSOBJ_STATIC := $(subst .c,_static.o,$(CLASSSRC))
34 CLASSOBJ_DEBUG := $(subst .c,_dbg.o,$(CLASSSRC))
35 CLASSINC := $(subst .c,.h,$(CLASSRC))
36 DEMOOBJ_STATIC := $(subst .c,_static.o,$(DEMOSRC))
37 DEMOOBJ_SHARED := $(subst .c,_shared.o,$(DEMOSRC))
38 DEMOOBJ_DEBUG := $(subst .c,_dbg.o,$(DEMOSRC))
40 # Provide a default name for the demo program
41 ifeq ($(strip $(DEMOPROG)),)
42 ifneq ($(strip $(DEMOSRC)),)
43 DEMOPROG := $(subst .c,,$(DEMOSRC))
47 # Generate the name of the debug demo
48 ifneq ($(strip $(DEMOPROG)),)
49 DEMOPROG_DEBUG := $(DEMOPROG)_debug
52 ###########################################################
53 # additional compiler flags
55 ifeq ($(strip $(COMPILER)),gcc)
56 LIB_CFLAGS := -DDATE="\"$(CLASSDATE)"\" -DNAME="\"$(CLASSLIB)"\" \
57 -DVERSION="\"$(CLASSVER).$(CLASSREV)"\"
59 LIB_CFLAGS := $(DEF) DATE=$(CLASSDATE) $(DEF) NAME="$(CLASSLIB)" \
60 $(DEF) VERSION="$(CLASSVER).$(CLASSREV)"
63 O_CFLAGS += $(LIB_CFLAGS)
64 D_CFLAGS += $(LIB_CFLAGS)
67 ###########################################################
68 # additional assembler flags
69 # do not modify the spaces in the lines below!
71 O_SFLAGS += SET "LIBVERSION=$(CLASSVER),LIBREVISION=$(CLASSREV) "
72 D_SFLAGS += SET "LIBVERSION=$(CLASSVER),LIBREVISION=$(CLASSREV) "
75 ###########################################################
77 ###########################################################
80 all: $(DEMOPROG) $(CLASSLIB)
81 ifneq ($(strip $(SUBDIRS)),)
82 for i in $(SUBDIRS); do $(MAKE) -C $$i TOP=$(TOP) ; done
86 @echo "This target will build all the classes and demo programs."; echo
90 ifneq ($(strip $(SUBDIRS)),)
91 for i in $(SUBDIRS); do $(MAKE) -C $$i TOP=$(TOP) lib ; done
95 @echo "This target will build all the classes (but not the demo programs)."; echo
98 obj: $(CLASSOBJ_STATIC)
99 ifneq ($(strip $(SUBDIRS)),)
100 for i in $(SUBDIRS); do $(MAKE) -C $$i TOP=$(TOP) obj ; done
104 @echo "This target create the classes object ready to be linked as a static"
105 @echo "library, with no debugging code."; echo
109 ifneq ($(strip $(SUBDIRS)),)
110 for i in $(SUBDIRS); do $(MAKE) -C $$i TOP=$(TOP) private ; done
114 @echo "This target will build all the demo programs with the classes linked"
115 @echo "as static libraries. No debug code and symbols are added."
117 @echo "This may be useful to let other users test new versions of the classes"
118 @echo "without the need to install them or without overwriting old versions"
119 @echo "that may have been installed."; echo
122 debug: $(DEMOPROG_DEBUG)
123 ifneq ($(strip $(SUBDIRS)),)
124 for i in $(SUBDIRS); do $(MAKE) -C $$i TOP=$(TOP) debug ; done
128 @echo "This target will build all the demo programs with the classes linked"
129 @echo "as static libraries. Debug code and symbols are added."; echo
133 ifneq ($(strip $(SUBDIRS)),)
134 for i in $(SUBDIRS); do $(MAKE) -C $$i TOP=$(TOP) install ; done
136 ifneq ($(strip $(DEMOPROG)),)
137 $(CP) $(DEMOPROG) $(PREFIX)/demos/
139 ifneq ($(strip $(CLASSLIB)),)
140 $(CP) $(CLASSLIB) $(PREFIX)/classes/$(INSTALLDIR)/
144 @echo "This target copy all the classes and the demos in the dist/ directory,"
145 @echo "placing the classes in the correct subdirectories."; echo
149 ifneq ($(strip $(SUBDIRS)),)
150 for i in $(SUBDIRS); do $(MAKE) -C $$i TOP=$(TOP) clean ; done
152 $(RM) $(DEMOPROG) $(CLASSLIB) $(CLASSOBJ_STATIC)
155 @echo "This target delete all the demoprograms, all the classes and all"
156 @echo "the objects in the sources subdirectories."; echo
160 @echo "Type 'make help-(targetname) (e.g. 'make help-all') to get"
161 @echo "a detailed help for each target"; echo
162 @echo "Current package configuration:"
163 @echo "------------------------------"
164 @echo "Defined targets: all; lib; debug; private; obj; install; clean; setup;"
165 @echo "Defined subdirs: $(patsubst %,%;,$(SUBDIRS))"; echo
166 @echo "Your OpenBoopsi root directory: $(TOP)."; echo
167 @echo "Configured compiler: $(COMPILER)."
168 @echo "Configured cpu: $(CPU)."
169 ifeq ($(strip $(NOSTDLIB)),0)
170 @echo "Configured demo linking method: standard startup code."
172 @echo "Configured demo linking method: custom startup code."
174 @echo; echo "Happy compiling!"; echo
177 ###########################################################
178 # build the class library
179 ###########################################################
181 $(CLASSLIB): ClassLib.o $(CLASSOBJ_SHARED) $(CLASSOBJ)
182 @$(ECHO) "Building class library..."
183 $(LDNOLIB) ClassLib.o $(CLASSOBJ_SHARED) $(CLASSOBJ) $(TO) $@ $(O_LFLAGS) $(ARG_LIB)
187 ###########################################################
188 # compile class source
189 ###########################################################
192 # All objects depend on their headers
193 $(CLASSOBJ_SHARED) $(CLASSOBJ_STATIC) $(CLASSOBJ_DEBUG): $(CLASSINC) $(BOOPSI_DEPS)
195 $(CLASSOBJ_SHARED): %_shared.o : %.c
196 $(CC) $< $(TO) $@ $(O_CFLAGS) -DCLASS_FLAVOUR=3
198 $(CLASSOBJ_STATIC): %_static.o : %.c
199 $(CC) $< $(TO) $@ $(O_CFLAGS) -DCLASS_FLAVOUR=0
201 $(CLASSOBJ_DEBUG): %_dbg.o : %.c
202 $(CC) $< $(TO) $@ $(D_CFLAGS) -DCLASS_FLAVOUR=0
204 ###########################################################
205 # assemble the class library init code
206 ###########################################################
208 # All this mess is required since PhxAss can't handle
209 # UNIX paths. It would also be possible to link this
210 # object without converting it, but it seems that
211 # this leads to a bigger executable...
213 ClassLib.o: $(TOP)/common/ClassLib.s Makefile
214 ifeq ($(strip $(COMPILER)),gcc)
216 $(ASM) T:ClassLib.s TO T:temp.o $(O_SFLAGS)
217 $(HUNK2AOUT) /t/temp.o >NIL:
219 $(RM) /t/ClassLib.s /t/temp.o
221 $(ASM) $< $(TO) $@ $(O_SFLAGS)
225 ###########################################################
226 # build the demo program
227 ###########################################################
229 ifneq ($(strip $(DEMOPROG)),)
231 $(DEMOPROG): $(DEMOOBJ_STATIC) $(DEMOOBJ) $(CLASSOBJ_STATIC) $(CLASSOBJ)
232 @$(ECHO) "Linking demo..."
233 ifeq ($(strip $(NOSTDLIB)),0)
234 $(LD) $(TO) $@ $(DEMOOBJ_STATIC) $(DEMOOBJ) $(CLASSOBJ_STATIC) $(CLASSOBJ) $(O_LIBS) $(O_LFLAGS)
236 $(LDNOLIB) $(TO) $@ $(APP_STARTUP) $(DEMOOBJ_STATIC) $(DEMOOBJ) $(CLASSOBJ_STATIC) $(CLASSOBJ) $(O_LIBS) $(O_LFLAGS)
239 $(DEMOPROG_DEBUG): $(DEMOOBJ_DEBUG) $(DEMOOBJ) $(CLASSOBJ_DEBUG) $(CLASSOBJ)
240 ifeq ($(strip $(NOSTDLIB)),0)
241 $(CC) $(TO) $@ $(DEMOOBJ_DEBUG) $(DEMOOBJ) $(CLASSOBJ_DEBUG) $(CLASSOBJ) $(D_LIBS) $(D_LFLAGS)
243 $(LDNOLIB) $(TO) $@ $(APP_STARTUP) $(DEMOOBJ_DEBUG) $(DEMOOBJ) $(CLASSOBJ_DEBUG) $(CLASSOBJ) $(D_LIBS) $(D_LFLAGS)
249 ###########################################################
250 # compile demo source
251 ###########################################################
254 # All objects depend on their headers
255 $(DEMOOBJ_SHARED) $(DEMOOBJ_DEBUG) $(DEMOOBJ_STATIC): $(CLASSINC)
257 $(DEMOOBJ_SHARED): %_shared.o : %.c
258 $(CC) $< $(TO) $@ $(O_CFLAGS) -DCLASS_FLAVOUR=3
260 $(DEMOOBJ_STATIC): %_static.o : %.c
261 $(CC) $< $(TO) $@ $(O_CFLAGS) -DCLASS_FLAVOUR=0
263 $(DEMOOBJ_DEBUG): %_dbg.o : %.c
264 $(CC) $< $(TO) $@ $(D_CFLAGS) -DCLASS_FLAVOUR=0
267 ###########################################################
269 ###########################################################
271 # disable all implicit rules for suffixes known to GNU make such as .c and .o
274 # Explicitly declare standard targets as phony
275 .PHONY: all lib debug private obj install clean help \
276 help-all help-lib help-debug help-private help-obj \
277 help-install help-clean