1 2 # This should be set to the Sun Studio compiler... usually cc on Solaris systems 3 CC = cc 4 LD = $(CC) 5 6 # don't modify this line: -xopenmp turns on OpenMP 7 CCFLAGS = -c -xopenmp -xO3 8 LDFLAGS = -xopenmp -xO3 9 10 # add other CFLAGS here 11 # CCFLAGS += -DEXAMPLE 12 13 # list your binaries here 14 BINARIES = hello-omp hello-pthreads increment addmatrix 15 OPATH = .generated 16 LINK_MESSAGE = "\033[32;1m\n***Making binary \033[33m%s\033[32m...\n\033[m" 17 COMPILE_MESSAGE = "\033[32;1m\n*Compiling \033[33m%s\033[32m...\n\033[m" 18 19 # list OBJFILES here for each binary 20 OBJFILES_HELLO_OMP = $(OPATH)/hello-omp.o 21 OBJFILES_HELLO_PTHREADS = $(OPATH)/hello-pthreads.o 22 OBJFILES_INCREMENT = $(OPATH)/increment.o 23 OBJFILES_ADDMATRIX = $(OPATH)/matrixmain.o \ 24 $(OPATH)/addmatrix.o \ 25 $(OPATH)/printmatrix.o 26 27 all: $(OPATH) $(BINARIES) 28 @printf "\033[34;1m\nMy work here is done.\n\033[m" 29 30 $(OPATH): 31 @printf "\033[32;1m\nMaking \033[33m$(OPATH)/ \033[32mpath for object files...\n\033[m" 32 mkdir $(OPATH) 33 34 # binary targets are like this 35 hello-pthreads: $(OPATH) $(OBJFILES_HELLO_PTHREADS) 36 @printf $(LINK_MESSAGE) "hello-pthreads" 37 $(LD) $(LDFLAGS) $(OBJFILES_HELLO_PTHREADS) -o hello-pthreads 38 39 hello-omp: $(OPATH) $(OBJFILES_HELLO_OMP) 40 @printf $(LINK_MESSAGE) "hello-omp" 41 $(LD) $(LDFLAGS) $(OBJFILES_HELLO_OMP) -o hello-omp 42 43 increment: $(OPATH) $(OBJFILES_INCREMENT) 44 @printf $(LINK_MESSAGE) "increment" 45 $(LD) $(LDFLAGS) $(OBJFILES_INCREMENT) -o increment 46 47 addmatrix: $(OPATH) $(OBJFILES_ADDMATRIX) 48 @printf $(LINK_MESSAGE) "addmatrix" 49 $(LD) $(LDFLAGS) $(OBJFILES_ADDMATRIX) -o addmatrix 50 51 $(OPATH)/hello-pthreads.o: hello-omp.c 52 @printf $(CpthreadsILE_MESSAGE) "hello-omp.c" 53 $(CC) $(CCFLAGS) hello-pthreads.c -o $(OPATH)/hello-pthreads.o 54 55 $(OPATH)/hello-omp.o: hello-omp.c 56 @printf $(COMPILE_MESSAGE) "hello-omp.c" 57 $(CC) $(CCFLAGS) hello-omp.c -o $(OPATH)/hello-omp.o 58 59 $(OPATH)/increment.o: increment.c 60 @printf $(COMPILE_MESSAGE) "increment.c" 61 $(CC) $(CCFLAGS) increment.c -o $(OPATH)/increment.o 62 63 $(OPATH)/matrixmain.o: matrixmain.c 64 @printf $(COMPILE_MESSAGE) "matrixmain.c" 65 $(CC) $(CCFLAGS) matrixmain.c -o $(OPATH)/matrixmain.o 66 67 $(OPATH)/addmatrix.o: addmatrix.c 68 @printf $(COMPILE_MESSAGE) "addmatrix.c" 69 $(CC) $(CCFLAGS) addmatrix.c -o $(OPATH)/addmatrix.o 70 71 $(OPATH)/printmatrix.o: printmatrix.c 72 @printf $(COMPILE_MESSAGE) "printmatrix.c" 73 $(CC) $(CCFLAGS) printmatrix.c -o $(OPATH)/printmatrix.o 74 75 clean: 76 @printf "\033[34;1m\nCleaning up...\n\033[m" 77 -rm -rf core* $(BINARIES) 78 -rm -rf $(OPATH) 79