# ------------------------------------------------------------------- # /shared/ # ------------------------------------------------------------------- # Makefile for MULTI-PLATFORM development with common code base # # AUTHOR: Gary McKee #. DATE: 12 September 2003 # PURPOSE: to support MULTI-PLATFORM development (SGI, LINUX) # This version of the makefile is unique because it # builds a library, not an executable # NOTE: this makefile must be named 'makefile' in order to # work. # # DIRECTORY: ../shared/ # # ${OBJ_DIR} destination directory for object files and libraries # (either: A_linux or A_sgi) # EXECUTABLE variable that holds the name of the resulting program # # MODIFIED # 21nov03 gmckee automatically derive the OS that selects which type # of compile to do.(Linux, IRIX) # 16dec04 gmckee cleanup and test for IRIX, Linux # 09Jan04 gmckee add debug flag "-g" # 12jan04 gmckee add logic for /IRIX64/ machine (INTERCEPT, others?) # 17aug04 gmckee add '-ptused' flag for 'COMMproc.cc' & # 'PropagateList.cc' # 14Dec04 bwhatcott Made dependancies work, removed recursive make calls, # and simplified. # ################################################################################ SHELL = /bin/sh include make.sources # ------------------- GENERAL parameters ------------------- OBJ_DIR = A_${MACHINE} OBJS = ${SRCS:.cc=.o} DPEND = ${SRCS:.cc=.d} DEBUG =-g # ------------------- LINUX specific parameters ------------------- ifeq ($(OSTYPE),linux) MACHINE=Linux INC=-I../lib -I/usr/X11R6/include -I../shared \ -I/usr/include/machine CFLAGS=-fpermissive -w CFLAG2=-fpermissive -w # CFLAGS=-Wno-deprecated -fno-for-scope # CFLAG2=-Wno-deprecated -fno-for-scope # CFLAGS=-fpermissive -Wno-deprecated # CFLAG2=-fpermissive -Wno-deprecated CPLUS=g++ OSNAME=OS_IS_LINUX # ------------------- IRIX specific parameters ------------------- else MACHINE=IRIX INC=-I../lib -I/usr/include/CC -I../shared CFLAGS=-O -DSG11 -32 -ptall -DFUNCPROTO -DXTFUNCPROTO CFLAG2=-O -DSG11 -32 -ptused -DFUNCPROTO -DXTFUNCPROTO CPLUS=CC OSNAME=OS_IS_SGI endif # The command to move files into this dir must finish before DPEND and OBJS # are checked for being current. If the move command is in the rule area, # it doesn't execute until after all dependacies are checke. Putting a # target (get) as a dependency to another target (EXECUTABLE) causes # get to be called before the other dependancies are checked. $(EXECUTABLE): makedir get $(DPEND) $(OBJS) @echo "--------------------------------------------"; @echo "$(THIS_DIR) $(MACHINE)"; @echo "Linking Shared Library"; @echo "ar -rc $(EXECUTABLE) INSERT::{OBJS}"; @ar -rc $(EXECUTABLE) $(OBJS); -@mv -f *.d *.o $(EXECUTABLE) $(OBJ_DIR); @echo "--------------------------------------------"; # Make dirs for object code and links makedir: @if [ ! -d ${OBJ_DIR} ]; then \ mkdir ${OBJ_DIR}; \ fi; # Move the files from the correct subdir.. Called as a dependacy get: -@mv -f $(OBJ_DIR)/$(EXECUTABLE) $(OBJ_DIR)/*.d $(OBJ_DIR)/*.o ./; # At the command line type "make printvars" to see make vars printvars: @echo "../$(THIS_DIR) makefile diagnostics"; @echo "-------------------------"; @echo "variables for ${MACHINE}:"; @echo " EXECUTABLE=${EXECUTABLE}"; @echo " THIS_DIR=${THIS_DIR}"; @echo " OBJ_DIR=${OBJ_DIR} "; @echo " DEBUG=${DEBUG} "; @echo " INC=${INC}"; @echo " CFLAGS=${CFLAGS}"; @echo " CFLAG2=${CFLAG2}"; @echo " CPLUS=${CPLUS} "; @echo " OSNAME=${OSNAME} "; @echo " OBJS:" @echo " $(OBJS)"; @echo @echo " DPEND:" @echo " $(DPEND)"; @echo @echo "-------------------------"; # At the command line type "make diag" to print the make vars and make diag: printvars $(EXECUTABLE) .cc.o: $(CPLUS) $(CFLAGS) $(DEBUG) $(INC) -D$(OSNAME) -c $< # Compile with the -M flag to create individual *.d dependacy files for # each source file. Use sed to make both the .cc and .d file have the # same dependancies (trick from the GNU make book). .cc.d: @set -e; ${CPLUS} -M ${CFLAGS} $(DEBUG) ${INC} -D${OSNAME} -c $< | \ sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@;# COMMproc.o : COMMproc.cc $(CPLUS) $(CFLAG2) $(DEBUG) $(INC) -D$(OSNAME) -c COMMproc.cc # ------------------------------------------------------------------------------ # ------------------- RULES FOR 'make clean' ----------------------------------- clean: @echo "/shared/ make clean: " ${MACHINE}; -rm -f *.d *.o $(EXECUTABLE); -cd $(OBJ_DIR); rm -f *.d *.o $(EXECUTABLE); clean_Linux: -cd A_Linux; rm -f *.d *.o $(EXECUTABLE); clean_IRIX: -cd A_IRIX; rm -f *.d *.o $(EXECUTABLE); .SUFFIXES: .o .cc .cdt .icon .c .h .C~ .c~ .h~ .d # Include *.d files which have dependancies # -------------------------------------------------------- -include $(OBJ_DIR)/*.d