#======================================================================== # # NAME # # makefile # # DESCRIPTION # # Makefile for UNIX systems and Windows + Cygwin for compiling # and testing Primpoly. # # Run from a command window by calling # # make # # For a Mac OS X system just call make. On a Windows platform use # # make PLATFORM=cygwin # # To compile and test the C version of the program, type # # make testc # # and for the C++ version, # # make test # # LEGAL # # Primpoly Version 6.0 - A Program for Computing Primitive Polynomials. # 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 #============================== Configuration ================================ # 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++" CYGWIN_C_INC = -I "C:/cygwin/lib/gcc/i686-pc-mingw32/3.4.4/include" CPP_LIBS = -L"C:/cygwin/lib" C_LIBS = -L"C:/cygwin/lib" endif # GNU standard C and C++ compilers. ifeq ($(PLATFORM), mac) CPP= /Developer/usr/bin/g++-4.0 CC= /Developer/usr/bin/gcc-4.0 else CPP = g++ CC = gcc endif #============================== Compile and Link Flags ======================= # Architecture. ARCH = -arch i386 # Debug and optimization switches. CPP_DEBUG_FLAGS = -Os $(ARCH) # -g3 -D DEBUG_PP_FACTOR -D DEBUG_PP_PARSER \ # -D DEBUG_PP_BIGINT -D DEBUG_PP_ARITH \ # -D DEBUG_PP_POLYNOMIAL C_DEBUG_FLAGS = -Os $(ARCH) # -g # Turn on C++ exceptions, and collect the other flags. CPP_FLAGS = -fexceptions $(CPP_DEBUG_FLAGS) $(MAC_SDK) C_FLAGS = $(C_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} C_INC = -I /usr/include ${CYGWIN_C_INC} # Link flags. ifeq ($(PLATFORM), mac) LFLAGS = $(ARCH) -isysroot ${SDK} endif #============================== Root directories ============================= # Source file root directories. CPP_SRC_DIR = ../SourceCode/Primpoly C_SRC_DIR = ../SourceCode/PrimpolyC # Object file root directories. CPP_OBJ_DIR = Bin C_OBJ_DIR = BinC # Executable file root directories. CPP_BIN_DIR = Bin C_BIN_DIR = BinC #============================== List of Files ================================ # Object files. CPP_OBJ = $(CPP_OBJ_DIR)/ppArith.o \ $(CPP_OBJ_DIR)/ppBigInt.o \ $(CPP_OBJ_DIR)/ppFactor.o \ $(CPP_OBJ_DIR)/ppParser.o \ $(CPP_OBJ_DIR)/ppPolynomial.o \ $(CPP_OBJ_DIR)/ppUnitTest.o C_OBJ = $(C_OBJ_DIR)/ppArith.o \ $(C_OBJ_DIR)/ppFactor.o \ $(C_OBJ_DIR)/ppHelperFunc.o \ $(C_OBJ_DIR)/ppIO.o \ $(C_OBJ_DIR)/ppOrder.o \ $(C_OBJ_DIR)/ppPolyArith.o # Main program object files. CPP_OBJ_MAIN = $(CPP_OBJ_DIR)/Primpoly.o C_OBJ_MAIN = $(C_OBJ_DIR)/Primpoly.o # Main program executables. CPP_BIN_MAIN = $(CPP_BIN_DIR)/Primpoly.exe C_BIN_MAIN = $(C_BIN_DIR)/PrimpolyC.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_BIN_MAIN): $(C_OBJ_MAIN) $(C_OBJ) $(CC) $(LFLAGS) $(C_OBJ_MAIN) $(C_OBJ) -o $(C_BIN_MAIN) $(C_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 $@ $(C_BIN_DIR)/%.o : $(C_SRC_DIR)/%.c $(CC) -c $(C_FLAGS) $(C_INC) $< -o $@ # List of all file.o : file.h dependencies. Primpoly.o: Primpoly.h ppArith.h ppBigInt.h ppFactor.h ppParser.h ppPolynomial.h ppUnitTest.h ppArith.o: Primpoly.h ppArith.h ppBigInt.h ppFactor.h ppParser.h ppPolynomial.h ppUnitTest.h ppBigInt.o: Primpoly.h ppBigInt.h ppArith.h ppFactor.h ppParser.h ppPolynomial.h ppUnitTest.h ppFactor.o: Primpoly.h ppFactor.h ppArith.h ppBigInt.h ppParser.h ppPolynomial.h ppUnitTest.h ppParser.o: Primpoly.h ppParser.h ppArith.h ppBigInt.h ppFactor.h ppPolynomial.h ppUnitTest.h ppPolynomial.o: Primpoly.h ppPolynomial.h ppArith.h ppBigInt.h ppFactor.h ppParser.h ppUnitTest.h ppUnitTest.o: Primpoly.h ppUnitTest.h ppArith.h ppBigInt.h ppFactor.h ppParser.h ppPolynomial.h #============================== Targets ====================================== # Make all the executables. makeAllExes: $(C_BIN_MAIN) $(CPP_BIN_MAIN) # Run tests for C++ Primpoly. test: $(CPP_BIN_MAIN) $(C_BIN_MAIN) $(CPP_BIN_MAIN) 2 60 $(C_BIN_MAIN) 2 60 # Run tests for C Primpoly. testc: $(C_BIN_MAIN) $(C_BIN_MAIN) -sc 2 4 $(C_BIN_MAIN) -sc 3 5 $(C_BIN_MAIN) -a 2 5 $(C_BIN_MAIN) 2 62 $(C_BIN_MAIN) -sc 4 4 # Remove all C and C++ object files and binaries. clean: rm $(CPP_OBJ) $(CPP_OBJ_MAIN) $(CPP_BIN_MAIN) $(CPP_OBJ_TEST) rm $(C_OBJ) $(C_OBJ_MAIN) $(C_BIN_MAIN)