#======================================================================== # # NAME # # makefile # # DESCRIPTION # # Makefile for UNIX systems and Windows + Cygwin for compiling # and testing CRCDemo. # # Run from a command window by calling # # make # # To compile and test the program, type # # make test # # # LEGAL # # CRCDemo Verision 2.1 - A Program for generating and checking CRC codes. # Copyright (C) 1999-2008 by Sean Erik O'Connor. All Rights Reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; version 2 # of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, # USA. # # The author's address is artifex@seanerikoconnor.freeservers.com. # #============================================================================= # Put this pseudo-target first so make without command line options executes it. all: makeAllExes configure #============================== Configuration ================================ # Get the name of the host and figure out if we are on a Windows/PC/Cygwin # platform. configure: HOSTNAME=`python -c "import platform; print platform.node()"` echo Hostname = $(HOSTNAME) ifeq ($(HOSTNAME), seanwinimac) PLATFORM = cygwin endif # Default platform is Mac OS X ifndef PLATFORM PLATFORM = mac endif # Mac OS X Leopard SDK. ifeq ($(PLATFORM), mac) SDK = /Developer/SDKs/MacOSX10.5.sdk MAC_SDK = -isysroot ${SDK} endif # Cygwin include files and libraries. ifeq ($(PLATFORM), cygwin) CYGWIN_CPP_INC = -I "C:/cygwin/lib/gcc/i686-pc-mingw32/3.4.4/include/c++" CPP_LIBS = -L"C:/cygwin/lib" endif # GNU standard C and C++ compilers. ifeq ($(PLATFORM), mac) CPP= /Developer/usr/bin/g++-4.0 else CPP = g++ endif #============================== Compile and Link Flags ======================= # On the Mac, create a universal binary architectures for both ppc7400 and i386. ifeq ($(PLATFORM), mac) ARCH = -arch ppc -arch i386 endif # Debug and optimization switches. CPP_DEBUG_FLAGS = -O3 $(ARCH) #CPP_DEBUG_FLAGS = -g3 $(ARCH) # Turn on C++ exceptions, and collect the other flags. CPP_FLAGS = -fexceptions $(CPP_DEBUG_FLAGS) $(MAC_SDK) # Location of C++ and C Libraries. ifeq ($(PLATFORM), cygwin) endif # C++ and C include files. CPP_INC = -I /usr/include ${CYGWIN_CPP_INC} # Link flags. ifeq ($(PLATFORM), mac) LFLAGS = $(ARCH) -isysroot ${SDK} endif #============================== Root directories ============================= # Source file root directories. CPP_SRC_DIR = ../SourceCode # Object file root directories. CPP_OBJ_DIR = Bin # Executable file root directories. CPP_BIN_DIR = Bin #============================== List of Files ================================ # Object files. CPP_OBJ = $(CPP_OBJ_DIR)/shiftRegister.o \ $(CPP_OBJ_DIR)/crcCode.o # Main program object files. CPP_OBJ_MAIN = $(CPP_OBJ_DIR)/testCRC.o # Main program executables. CPP_BIN_MAIN = $(CPP_BIN_DIR)/testCRC.exe #============================== Implicit Rules =============================== # Link all object files to executables. $(CPP_BIN_MAIN): $(CPP_OBJ_MAIN) $(CPP_OBJ) $(CPP) $(LFLAGS) $(CPP_OBJ_MAIN) $(CPP_OBJ) -o $(CPP_BIN_MAIN) $(CPP_LIBS) # C++ and C source file compilation to object files. $(CPP_BIN_DIR)/%.o : $(CPP_SRC_DIR)/%.cpp $(CPP) -c $(CPP_FLAGS) $(CPP_INC) $< -o $@ # List of all file.o : file.h dependencies. crcCode.o: crcCode.cpp crcCode.h shiftRegister.o: shiftRegister.c crcCode.h testCRC.o: testCRC.cpp crcCode.h #============================== Targets ====================================== # Make all the executables. makeAllExes: $(CPP_BIN_MAIN) # Run tests for C++ Primpoly. test: $(CPP_BIN_MAIN) $(CPP_BIN_MAIN) # Remove all C and C++ object files and binaries. clean: rm $(CPP_OBJ) $(CPP_OBJ_MAIN) $(CPP_BIN_MAIN)