# unstuck Metamod Plugin unstuck_mm.dll and unstuck_mm.so Makefile for win32 and linux


ifeq ($(OS),Windows_NT)

	COMPILER = mingw32-gcc
	LINKER   = dllwrap

	DELCMD   = -del
	
	CFLAGS   = -mdll -mwindows
	LFLAGS   = -mdll -mwindows -lstdc++ -lwinmm -k -s
	VERSION  = version.o
	RC       = version.rc
	DLLNAME  = unstuck_mm.dll
	
else

	COMPILER = egcs
	LINKER   = egcs
	DELCMD   = -rm -f
	
	CFLAGS   = -fPIC -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -Dstrcmpi=strcasecmp
	LFLAGS   = -shared -ldl -lm -s
	VERSION  = 
	RC       = 
	DLLNAME  = unstuck_mm.so

endif


CFLAGS += -Wall -march=i586 -mcpu=i686 -O1 -g0 -ffast-math -fno-rtti
LFLAGS +=


METADIR = ../metamod


INCLUDEDIRS = -I. -I$(METADIR) -Iengine -Icommon -Idlls


OBJ =	meta_api.o		\
				\
        dllapi.o		\
        			\
        mtrand.o		\
				\
        $(VERSION)


DOCC = $(COMPILER) $(CFLAGS) $(INCLUDEDIRS) -o $@ -c $<
DOO = $(LINKER) -o $@ $(OBJ) $(LFLAGS)


$(DLLNAME) : $(OBJ) 
	$(DOO)


clean:
	$(DELCMD) $(OBJ) unstuck_mm.dll *.d


./$(VERSION): ./$(RC)
	windres -o $@ -i $<


# pull in dependency info for *existing* .o files
-include $(OBJ:.o=.d)


./%.o: ./%.cpp
	$(DOCC)
	$(COMPILER) -MM $(INCLUDEDIRS) $< > $*.d


