# A good place to get information on 
# how to create a Makefile is at
# http://vertigo.hsrl.rutgers.edu/ug/make_help.html
#
# Define the Compiler and Linker variables
CC = g++
LD = g++

# Define the archiver and indexer
AR = /usr/bin/ar
RANLIB = /usr/bin/ranlib

# Define program's object files
PROG_OBJS = test.o

# Define program's executable
PROG = ./test

# library's archive file
LIB_FILE = libutil.a 

# library to use when linking the main program
# the '-L.' option is used to tell the compiler to look for libraries
# in the current directory, as well as the normal system library locations.
LIBS = -L.

INCLUDE = -I. 

# top-level rule
all: $(LIB_FILE) $(PROG)

# create our library
$(LIB_FILE): $(LIB_OBJS)
	$(AR) rc $(LIB_FILE) $(LIB_OBJS)
	$(RANLIB) $(LIB_FILE)

$(PROG): $(PROG_OBJS)
	$(LD) -O2 -fno-automatic -finit-local-zero -ffixed-line-length-none -fno-second-underscore \
	 $(PROG_OBJS) $(INCLUDE) $(LIBS)  -o $(PROG)

# compile source files into object files.
%.o: %.cpp
	$(CC) -O2 -DLinux $(INCLUDE) -c $<

# Define variable RM
RM = /bin/rm -f

# define the standard input variable clean
clean:
	$(RM) $(PROG_OBJS) $(PROG) $(LIB_FILE) $(LIB_OBJS)


