# Makefile 
#####parte da editare###########################

#nome dell'eseguibile da generare
PROG = ippo-lib

PROGMT = mt-ippo-lib

# lista dei sorgenti separati da spazi
SOURCES = main.cpp lib/checksum.cpp lib/generaloption.cpp lib/ippolib.cpp lib/probereply.cpp lib/util.cpp
SOURCESMT = mt-main.cpp lib/checksum.cpp lib/generaloption.cpp lib/ippolib.cpp lib/probereply.cpp lib/util.cpp
                  
# librerie da includere (-lnomelib1 -lnomelib2 ...)
# ed eventuali library path non standard (-L/path/ ...)
LIBS = 

# flags del compilatore (-Wall, ecc.)
# ed eventuali include path non standard (-I/path/)
ALLFLAGS = -Wall

# flag specifici per release
RELEASE = -O2

# flag specifici per debug
DEBUG = -g

#comando compilatore e linker (gcc, g++, ecc)
CC = g++

#####fine parte da editare######################

CFLAGS=$(ALLFLAGS) $(DEBUG) -pthread
CXXFLAGS=$(CFLAGSMT)

TOBJ = $(SOURCES:.cpp=.o)
TOBJMT = $(SOURCESMT:.cpp=.o)
OBJS = $(TOBJ:.c=.o)
OBJSMT = $(TOBJMT:.c=.o)

release: CFLAGS = $(ALLFLAGS) $(RELEASE)
release: CXXFLAGS=$(CFLAGS)

#all release: depend $(PROG)
#	@echo $@ DONE

all : depend $(PROG) $(PROGMT)
	@echo " BUILD DONE"

release: clean depend $(PROG)
	@echo " RELEASE DONE"
	
debug: clean depend $(PROG)
	@echo " DEBUG DONE"
	
$(PROG) : $(OBJS)
	$(CC) $(CFLAGS) -o $(PROG) $(OBJS) $(LIBS) 
	
$(PROGMT) : $(OBJSMT)
	$(CC) $(CFLAGS) -o $(PROGMT) $(OBJSMT) $(LIBS) 
	
.PHONY: clean depend help
	
clean: 
	rm -f $(PROG) $(PROGMT) $(OBJS) $(OBJSMT) .depend
	@echo " SOURCES CLEAN"

depend:
	$(CC) -MM $(INCS) $(SOURCES) $(SOURCESMT) >.depend
	
help:
	@ echo
	@ echo "Standard Makefile for C/C++ code"	
	@ echo "  make/make all: compile all (default is debug mode)"
	@ echo "  make release : clean and release compile"
	@ echo "  make debug   : clean and debug compile"
	@ echo "  make clean   : clean sources"
	@ echo "Current settings are:"
	@ echo "  executable   :" $(PROG)
	@ echo "  sources      :" $(SOURCES)
	@ echo "  libraries    :" $(LIBS)
	@ echo "  debug flags  :" $(ALLFLAGS) $(DEBUG)
	@ echo "  release flags:" $(ALLFLAGS) $(RELEASE)
	@ echo

ifeq ($(wildcard .depend), .depend)
include .depend
endif
