# Makefile
# Based on the sample Makefile for CSC326F, located on the
# web at ...
# http://www.eecg.toronto.edu/~jayw/csc326f/sample_make

# The file should be named Makefile in your directory
# Compiles separate components file1 and file2, and links
# them together in an executable file. This file also creates
# a directory called DISTRIBUTION and coppies the executable
# and the protocol document to this new directory. 

# This sets the program and component names

COMPONENTS	= Control.o Request.o RequestInternal.o Grpscheduler.o Scheduler.o Perscheduler.o Filesys.o Socket.o Parser.o Login.o Admin.o

# Compiler name and flags; ordinarily the default
# is cc
CC		= g++
CFLAGS	= -g -Wall

# Linker flags
LFLAGS	= -g -lsocket -lnsl

# This compiles the program
# The first line is the name of each separate component
# The second line performs the linking
# This is the default action when make is run, since the program
# variable has been defined

# Make the server, create the DISTRIBUTION directory, copy the executable and
# the PROTOCOL document to this new directory.
all:	server dist copy


server:		$(COMPONENTS)
	        $(CC) $(COMPONENTS) $(LFLAGS) -o server
		$(CC) reset.cpp Filesys.o -o reset


# Suffix rule defined. Tells make what to do with out-of-date
# object files.
.SUFFIXES: .cpp .o
.cpp.o: 
	$(CC) $(CFLAGS) -c $*.cpp -o $*.o
	
# The following lines explain what files to compile for each object file
Request.o: 		Request.cpp Socket.cpp Filesys.cpp RequestInternal.cpp
RequestInternal.o: 	RequestInternal.cpp
Scheduler.o:            Scheduler.cpp Socket.cpp Filesys.cpp
Perscheduler.o:         Perscheduler.cpp Scheduler.cpp
Grpscheduler.o:         Grpscheduler.cpp Scheduler.cpp
Parser.o:               Parser.cpp Socket.cpp
Filesys.o:              Filesys.cpp 
Socket.o:               Socket.cpp
Admin.o:                Admin.cpp Filesys.cpp Socket.cpp
Login.o:                Login.cpp Admin.cpp Filesys.cpp
Control.o:              Control.cpp Filesys.cpp Socket.cpp Parser.cpp

######
# Here we list the headers that each object file is dependent
# on (and their locations if necessary)
Request.o: 		Request.h Socket.h Filesys.h RequestInternal.h
RequestInternal.o: 	RequestInternal.h
Scheduler.o:            Scheduler.h Socket.h Filesys.h
Perscheduler.o:         Perscheduler.h Scheduler.h
Grpscheduler.o:         Grpscheduler.h Scheduler.h
Parser.o:               Parser.h Socket.h
Filesys.o:              Filesys.h 
Socket.o:               Socket.h
Admin.o:                Admin.h Filesys.h Socket.h
Login.o:                Login.h Admin.h Filesys.h
Control.o:              Filesys.h Socket.h Parser.h


dist:		
	mkdir DISTRIBUTION

copy:
	cp server PROTOCOL startup reset DISTRIBUTION 
