#21/01/04 Parts copy/pasted from original ~/asss-1.1.7/src/Makefile
#Edit this stuff below
MODULENAME = noanti
OBJS = noanti.o

# default options:
debug = no
opt = no
prof = no
link_db_statically = no

# uncomment any of these lines if you're missing some libraries:
#
# if you're missing berkeley db:
no_bdb = yes
#
# if you're missing mysql:
no_mysql = yes
#
# if you're missing python:
#no_python = yes


#Do not edit below this line
SYS_NAME := $(shell uname -s)

ifeq ($(SYS_NAME),Linux)
UTIL_LIB = -lutil
DL_LIB = -ldl
ZLIB_LIB = -lz
PTHREAD_LIB = -lpthread
DASH_F_PIC = -fPIC
EXPORT_SYMBOLS = -rdynamic
SO = so
SYS_NAME := ok
endif
ifeq ($(SYS_NAME),FreeBSD)
UTIL_LIB = -lutil
ZLIB_LIB = -lz
DASH_F_PIC = -fPIC
DASH_PTHREAD = -pthread
EXPORT_SYMBOLS = -rdynamic
SO = so
SYS_NAME := ok
endif
ifeq ($(findstring CYGWIN,$(SYS_NAME)),CYGWIN)
PTHREAD_LIB = -lpthread
EXE = .exe
SO = so
SYS_NAME := ok
endif
ifeq ($(findstring MINGW,$(SYS_NAME)),MINGW)
run_dlltool = yes
PTHREAD_LIB = -L$(ASSSHOME)/bin -lpthreadGC -lwsock32
ZLIB_LIB = -L$(ASSSHOME)/bin -lzdll
SO_LDFLAGS = import.imp $(PTHREAD_LIB)
EXPORT_SYMBOLS = export.exp
EXE = .exe
SO = dll
W32COMPAT = win32compat.o
SYS_NAME := ok
endif
ifneq ($(SYS_NAME),ok)
$(error Unknown operating system, you'll have to edit the makefile yourself)
endif

# apply build options
ifeq ($(debug),yes)
DEBUG_CFLAGS = -g -Wall -fpedantic
endif

ifeq ($(prof),yes)
PROF_FLAGS = -pg
endif

ifeq ($(opt),yes)
OPT_CFLAGS = -O2 -fomit-frame-pointer -Wall -fpedantic -DNDEBUG
endif

CC = gcc -pipe
STD_CFLAGS = -I. -D_REENTRANT -D_GNU_SOURCE $(DASH_F_PIC)
CFLAGS = $(STD_CFLAGS) $(DEBUG_CFLAGS) $(PROF_FLAGS) $(OPT_CFLAGS)
LDFLAGS = $(DASH_PTHREAD) $(DASH_F_PIC) $(PROF_FLAGS)

UTIL_OBJS = util.o pathutil.o protutil.o region.o rwlock.o app.o md5.o $(W32COMPAT)

all: $(MODULENAME).so

$(MODULENAME).so: $(OBJS) $(DL_UTIL_OBJS)

%.$(SO):
	$(CC) $(LDFLAGS) -shared -o $@ $^ $(SO_LDFLAGS) $(LIBS)

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

clean: $(OBJS)
	rm $(OBJS)
