# Sample Makefile
# IMPORTANT! this file contains TABs ('\t') and they must not be converted to spaces (' ') by your text editor

# the following macros are predefined
# there will be something in them even if you do not redefine them
CC      =g++
CFLAGS  =-Wall -O2
AR      =ar  # standard program to create libraries is ar
ARFLAGS =    # none at this time
LD      =g++ # standard linker is ld and it would not work for us with CC as g++!!
LDFLAGS =-O2 # -lxnet

# make all is the default make "target" to run
all: http_one http_echo

# for example in order to do http_one 
# - you need to have current tnplib.o http_one.o
# - if/after you have them current you need to run command(s) from next indented lines
http_one: tnplib.o http_one.o
	$(LD) tnplib.o http_one.o $(LDFLAGS) -o http_one

http_echo: tnplib.o http_echo.o
	$(LD) tnplib.o http_echo.o $(LDFLAGS) -o http_echo

tnplib.o: tnplib.cpp tnplib.h
	$(CC) $(CFLAGS) -c tnplib.cpp -o tnplib.o
# this line above that specifies the rule is not necessary because of macro rule %.o:%.cpp below

# you can list all dependencies in one line
http_one.o: tnplib.h http_one.cpp

# or you can list them one by one OR a few at a time and they will be merged together
http_echo.o: tnplib.h
# what happened to the rule what to do? it is burried in the macro %.o:%.cpp

http_echo.o: http_echo.cpp
# what happened to the rule what to do? it is burried in the macro %.o:%.cpp

# or you can make them as macros like in the two examples below.
# in that case it will be tested for each xxx.o if there is xxx.c or xxx.cpp 
# and it/they not need to be processed
%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

%.o: %.cpp
	$(CC) $(CFLAGS) -c $< -o $@

# actually these .o.c and .o.cpp and many more macros are predefined. Run "make -p" to find out more

	rm -rf *.o *~ http_one http_echo

	tar cf code.tar  Makefile *.cpp *.h
	gzip -f code.tar
# more than one command may be specified as long as they are intended with a TAB/TABs, no space ' '!!!