#makefile for APRS Server 2.1.5 with STLport library support
all: aprsd aprspass
#
#User this compiler...
CC = g++
#The next line points to my g++ 3.1 compiler for testing.
#CC = /usr/local/bin/g++
#
CPU = -mcpu=i386
WARN = -Wall
#WARN = -Wno-deprecated
#GDB = -ggdb
#EFENCE = /usr/lib/libefence.so.0
#STATIC = -static
#
#Check for STLport support
STLPORT := $(shell test -f /usr/local/include/stlport/iostream && echo 1)
LDFLAGS =  -lcrypt

#Compile and link with STLport if present
ifeq ($(STLPORT), 1)
	CFLAGS += -DSTLport=1
	LDFLAGS += -lstlport_gcc
	LFLAGS = -L/usr/local/lib
	INCFLAGS = -I/usr/local/include/stlport
endif


#
DEPENDS =  servers.o httpserver.o utils.o history.o serialp.o cpqueue.o aprsString.o mic_e.o validate.o queryResp.o dupCheck.o crc32.o
DEPENDS_H = constant.h aprsString.h  dupCheck.h  servers.h mic_e.h
#
#
aprspass: aprspass.o validate.o validate.h
	$(CC) $(INCFLAGS) $(CFLAGS) $(WARN) -pthread $(CPU) $(GDB)  -o aprspass aprspass.cpp validate.o $(LFLAGS) $(LDFLAGS)
#
aprsd: aprsd.o  $(DEPENDS) $(DEPENDS_H)
	$(CC) $(INCFLAGS) $(CFLAGS) $(WARN) -pthread $(CPU) $(GDB)   -o   aprsd aprsd.cpp $(DEPENDS)  $(LFLAGS) $(LDFLAGS) $(EFENCE) $(STATIC)
       
	
aprsd.o: aprsd.cpp $(DEPENDS) servers.o  servers.h $(DEPENDS_H)
	$(CC) $(INCFLAGS) $(CFLAGS) $(WARN) -pthread $(CPU) $(GDB)   -c aprsd.cpp
	
servers.o:  servers.cpp  servers.h $(DEPENDS_H)	
	$(CC) $(INCFLAGS) $(CFLAGS) $(WARN) -pthread $(CPU) $(GDB)   -c servers.cpp
httpserver.o:  httpserver.cpp  servers.h $(DEPENDS_H)
	$(CC) $(INCFLAGS) $(CFLAGS) $(WARN) -pthread $(CPU) $(GDB)   -c httpserver.cpp
cpqueue.o: utils.o cpqueue.cpp cpqueue.h $(DEPENDS_H)
	$(CC) $(INCFLAGS) $(CFLAGS) $(WARN) -pthread $(CPU) $(GDB)  -c cpqueue.cpp
serialp.o: serialp.cpp serialp.h    $(DEPENDS_H)
	$(CC) $(INCFLAGS) $(CFLAGS) $(WARN) -pthread $(CPU) $(GDB)  -c serialp.cpp
history.o: utils.o history.cpp history.h $(DEPENDS_H)
	$(CC) $(INCFLAGS) $(CFLAGS) $(WARN) -pthread $(CPU) $(GDB)  -c history.cpp
utils.o: utils.cpp utils.h  $(DEPENDS_H)
	$(CC) $(INCFLAGS) $(CFLAGS) $(WARN) -pthread $(CPU) $(GDB)  -c utils.cpp
aprsString.o: aprsString.cpp   $(DEPENDS_H) crc.h
	$(CC) $(INCFLAGS) $(CFLAGS)  $(WARN)  -pthread $(CPU) $(GDB)  -c aprsString.cpp
mic_e.o: mic_e.cpp mic_e.h
	$(CC) $(INCFLAGS) $(CFLAGS) $(WARN) -pthread $(CPU) $(GDB)  -c mic_e.cpp
validate.o: validate.cpp validate.h
	$(CC) $(INCFLAGS) $(CFLAGS) $(WARN) -pthread $(CPU) $(GDB)  -c validate.cpp
	
dupCheck.o: dupCheck.cpp dupCheck.h $(DEPENDS_H)
	$(CC) $(INCFLAGS) $(CFLAGS) $(WARN) -pthread $(CPU) $(GDB)  -c dupCheck.cpp
	
queryResp.o: queryResp.cpp queryResp.h constant.h
	$(CC) $(INCFLAGS) $(CFLAGS) $(WARN) -pthread $(CPU) $(GDB)  -c queryResp.cpp
	
crc32.o: crc32.c crc.h
	$(CC) $(INCFLAGS) $(CFLAGS) $(WARN) -pthread $(CPU) $(GDB)  -c crc32.c
       
	

aprspass.o: aprspass.cpp
	$(CC) $(INCFLAGS) $(CFLAGS) $(WARN) $(CPU) $(GDB)  -c aprspass.cpp
	
	
clean:
	rm *.o
	rm aprsd
	rm aprspass
       	






