# # $Id:$ # # Copyright (C) 1999 by Matteo Cavalleri # # This makefile is flexible enough to be used for every # class of the OpenBoopsi project. You should not need to # modify anything # # all: create the demo program and the class library # with no debugging information and code # # lib: create just the library of the public class # with no debugging information and code # # private: create the demo program linked with optimized version of the class # # debug: create the demo program linked with debug version of the class # # obj: create just the class object ready to be linked # to a program, with no debugging information and code # # install: copy the demos and classes to the appropriate # directories # ########################################################### # some variables... # BOOPSI_DEPS := $(INCDIR)/BoopsiStubs.h $(INCDIR)/CompilerSpecific.h $(INCDIR)/DebugMacros.h CLASSOBJ_SHARED := $(subst .c,_shared.o,$(CLASSSRC)) CLASSOBJ_STATIC := $(subst .c,_static.o,$(CLASSSRC)) CLASSOBJ_DEBUG := $(subst .c,_dbg.o,$(CLASSSRC)) CLASSINC := $(subst .c,.h,$(CLASSRC)) DEMOOBJ_STATIC := $(subst .c,_static.o,$(DEMOSRC)) DEMOOBJ_SHARED := $(subst .c,_shared.o,$(DEMOSRC)) DEMOOBJ_DEBUG := $(subst .c,_dbg.o,$(DEMOSRC)) # Provide a default name for the demo program ifeq ($(strip $(DEMOPROG)),) ifneq ($(strip $(DEMOSRC)),) DEMOPROG := $(subst .c,,$(DEMOSRC)) endif endif # Generate the name of the debug demo ifneq ($(strip $(DEMOPROG)),) DEMOPROG_DEBUG := $(DEMOPROG)_debug endif ########################################################### # additional compiler flags # ifeq ($(strip $(COMPILER)),gcc) LIB_CFLAGS := -DDATE="\"$(CLASSDATE)"\" -DNAME="\"$(CLASSLIB)"\" \ -DVERSION="\"$(CLASSVER).$(CLASSREV)"\" else LIB_CFLAGS := $(DEF) DATE=$(CLASSDATE) $(DEF) NAME="$(CLASSLIB)" \ $(DEF) VERSION="$(CLASSVER).$(CLASSREV)" endif O_CFLAGS += $(LIB_CFLAGS) D_CFLAGS += $(LIB_CFLAGS) ########################################################### # additional assembler flags # do not modify the spaces in the lines below! # O_SFLAGS += SET "LIBVERSION=$(CLASSVER),LIBREVISION=$(CLASSREV) " D_SFLAGS += SET "LIBVERSION=$(CLASSVER),LIBREVISION=$(CLASSREV) " ########################################################### # Main targets ########################################################### # all: $(DEMOPROG) $(CLASSLIB) ifneq ($(strip $(SUBDIRS)),) for i in $(SUBDIRS); do $(MAKE) -C $$i TOP=$(TOP) ; done endif help-all: @echo "This target will build all the classes and demo programs."; echo lib: $(CLASSLIB) ifneq ($(strip $(SUBDIRS)),) for i in $(SUBDIRS); do $(MAKE) -C $$i TOP=$(TOP) lib ; done endif help-lib: @echo "This target will build all the classes (but not the demo programs)."; echo obj: $(CLASSOBJ_STATIC) ifneq ($(strip $(SUBDIRS)),) for i in $(SUBDIRS); do $(MAKE) -C $$i TOP=$(TOP) obj ; done endif help-obj: @echo "This target create the classes object ready to be linked as a static" @echo "library, with no debugging code."; echo private: $(DEMOPROG) ifneq ($(strip $(SUBDIRS)),) for i in $(SUBDIRS); do $(MAKE) -C $$i TOP=$(TOP) private ; done endif help-private: @echo "This target will build all the demo programs with the classes linked" @echo "as static libraries. No debug code and symbols are added." @echo @echo "This may be useful to let other users test new versions of the classes" @echo "without the need to install them or without overwriting old versions" @echo "that may have been installed."; echo debug: $(DEMOPROG_DEBUG) ifneq ($(strip $(SUBDIRS)),) for i in $(SUBDIRS); do $(MAKE) -C $$i TOP=$(TOP) debug ; done endif help-debug: @echo "This target will build all the demo programs with the classes linked" @echo "as static libraries. Debug code and symbols are added."; echo install: ifneq ($(strip $(SUBDIRS)),) for i in $(SUBDIRS); do $(MAKE) -C $$i TOP=$(TOP) install ; done endif ifneq ($(strip $(DEMOPROG)),) $(CP) $(DEMOPROG) $(PREFIX)/demos/ endif ifneq ($(strip $(CLASSLIB)),) $(CP) $(CLASSLIB) $(PREFIX)/classes/$(INSTALLDIR)/ endif help-install: @echo "This target copy all the classes and the demos in the dist/ directory," @echo "placing the classes in the correct subdirectories."; echo clean: ifneq ($(strip $(SUBDIRS)),) for i in $(SUBDIRS); do $(MAKE) -C $$i TOP=$(TOP) clean ; done endif $(RM) $(DEMOPROG) $(CLASSLIB) $(CLASSOBJ_STATIC) help-clean: @echo "This target delete all the demoprograms, all the classes and all" @echo "the objects in the sources subdirectories."; echo help: @echo "Type 'make help-(targetname) (e.g. 'make help-all') to get" @echo "a detailed help for each target"; echo @echo "Current package configuration:" @echo "------------------------------" @echo "Defined targets: all; lib; debug; private; obj; install; clean; setup;" @echo "Defined subdirs: $(patsubst %,%;,$(SUBDIRS))"; echo @echo "Your OpenBoopsi root directory: $(TOP)."; echo @echo "Configured compiler: $(COMPILER)." @echo "Configured cpu: $(CPU)." ifeq ($(strip $(NOSTDLIB)),0) @echo "Configured demo linking method: standard startup code." else @echo "Configured demo linking method: custom startup code." endif @echo; echo "Happy compiling!"; echo ########################################################### # build the class library ########################################################### # $(CLASSLIB): ClassLib.o $(CLASSOBJ_SHARED) $(CLASSOBJ) @$(ECHO) "Building class library..." $(LDNOLIB) ClassLib.o $(CLASSOBJ_SHARED) $(CLASSOBJ) $(TO) $@ $(O_LFLAGS) $(ARG_LIB) $(FLUSHLIBS) ########################################################### # compile class source ########################################################### # # All objects depend on their headers $(CLASSOBJ_SHARED) $(CLASSOBJ_STATIC) $(CLASSOBJ_DEBUG): $(CLASSINC) $(BOOPSI_DEPS) $(CLASSOBJ_SHARED): %_shared.o : %.c $(CC) $< $(TO) $@ $(O_CFLAGS) -DCLASS_FLAVOUR=3 $(CLASSOBJ_STATIC): %_static.o : %.c $(CC) $< $(TO) $@ $(O_CFLAGS) -DCLASS_FLAVOUR=0 $(CLASSOBJ_DEBUG): %_dbg.o : %.c $(CC) $< $(TO) $@ $(D_CFLAGS) -DCLASS_FLAVOUR=0 ########################################################### # assemble the class library init code ########################################################### # # All this mess is required since PhxAss can't handle # UNIX paths. It would also be possible to link this # object without converting it, but it seems that # this leads to a bigger executable... # ClassLib.o: $(TOP)/common/ClassLib.s Makefile ifeq ($(strip $(COMPILER)),gcc) $(CP) $< /t $(ASM) T:ClassLib.s TO T:temp.o $(O_SFLAGS) $(HUNK2AOUT) /t/temp.o >NIL: $(REN) obj.* $@ $(RM) /t/ClassLib.s /t/temp.o else $(ASM) $< $(TO) $@ $(O_SFLAGS) endif ########################################################### # build the demo program ########################################################### # ifneq ($(strip $(DEMOPROG)),) $(DEMOPROG): $(DEMOOBJ_STATIC) $(DEMOOBJ) $(CLASSOBJ_STATIC) $(CLASSOBJ) @$(ECHO) "Linking demo..." ifeq ($(strip $(NOSTDLIB)),0) $(LD) $(TO) $@ $(DEMOOBJ_STATIC) $(DEMOOBJ) $(CLASSOBJ_STATIC) $(CLASSOBJ) $(O_LIBS) $(O_LFLAGS) else $(LDNOLIB) $(TO) $@ $(APP_STARTUP) $(DEMOOBJ_STATIC) $(DEMOOBJ) $(CLASSOBJ_STATIC) $(CLASSOBJ) $(O_LIBS) $(O_LFLAGS) endif $(DEMOPROG_DEBUG): $(DEMOOBJ_DEBUG) $(DEMOOBJ) $(CLASSOBJ_DEBUG) $(CLASSOBJ) ifeq ($(strip $(NOSTDLIB)),0) $(CC) $(TO) $@ $(DEMOOBJ_DEBUG) $(DEMOOBJ) $(CLASSOBJ_DEBUG) $(CLASSOBJ) $(D_LIBS) $(D_LFLAGS) else $(LDNOLIB) $(TO) $@ $(APP_STARTUP) $(DEMOOBJ_DEBUG) $(DEMOOBJ) $(CLASSOBJ_DEBUG) $(CLASSOBJ) $(D_LIBS) $(D_LFLAGS) endif endif ########################################################### # compile demo source ########################################################### # # All objects depend on their headers $(DEMOOBJ_SHARED) $(DEMOOBJ_DEBUG) $(DEMOOBJ_STATIC): $(CLASSINC) $(DEMOOBJ_SHARED): %_shared.o : %.c $(CC) $< $(TO) $@ $(O_CFLAGS) -DCLASS_FLAVOUR=3 $(DEMOOBJ_STATIC): %_static.o : %.c $(CC) $< $(TO) $@ $(O_CFLAGS) -DCLASS_FLAVOUR=0 $(DEMOOBJ_DEBUG): %_dbg.o : %.c $(CC) $< $(TO) $@ $(D_CFLAGS) -DCLASS_FLAVOUR=0 ########################################################### # GNU make quirks ########################################################### # disable all implicit rules for suffixes known to GNU make such as .c and .o .SUFFIXES: # Explicitly declare standard targets as phony .PHONY: all lib debug private obj install clean help \ help-all help-lib help-debug help-private help-obj \ help-install help-clean