#
# SellaNMS
# Id: Makefile.in,v 2.7 2002/03/25 10:18:29 sella Exp 
# Copyright (c) 2001,2002 Digital Genesis Software, LLC. All Rights Reserved.
# Release under the GPL Version 2 License.
# http://www.digitalgenesis.com
#

# --------------------------------------
#                Source
# --------------------------------------

OBJS				= main.o
EXTOBJS			=
SUBDIRS			=
TARGET			= mkvim
LIBRARY			=
LIBRARY_MAJOR	=

# --------------------------------------
#                Programs
# --------------------------------------

CC					= gcc
CXX				= g++
CPP				= gcc -E
AR					= ar
RANLIB			= ranlib
INSTALL			= /usr/bin/install -c
SHELL				= /bin/sh
SED				= /bin/sed
STRIP				= /usr/bin/strip

# --------------------------------------
#                Flags
# --------------------------------------

MFLAGS			= SRCDIR=../../src
DEFINES			= -pipe   -DHAVE_CONFIG_H -I$(SRCDIR) -I$(SRCDIR)/common -I$(SRCDIR)/libs  -I/usr/local/include
CPPFLAGS			=  -fPIC -DPIC -D_REENTRANT
CFLAGS			= -g O0 -w $(CPPFLAGS)
CXXFLAGS			= -g -O0 -w $(CPPFLAGS)
LDFLAGS			= -Wl,-export-dynamic 
LIBS				= 
VPATH				= .

# --------------------------------------
#                Targets
# --------------------------------------

.SUFFIXES: .c .cc .cxx .c++ .cpp .o
 
.c.o:
	$(CC) $(DEFINES) -c $(CFLAGS) $<
.cc.o:
	$(CXX) $(DEFINES) -c $(CXXFLAGS) $<
.cxx.o:
	$(CXX) $(DEFINES) -c $(CXXFLAGS) $<
.c++.o:
	$(CXX) $(DEFINES) -c $(CXXFLAGS) $<
.cpp.o:
	$(CPP) $(DEFINES) -c $(CPPFLAGS) $<

all: build

build: $(OBJS) $(LIBRARY) $(TARGET)
	@SUBDIRS="$(SUBDIRS)"; \
	for DIR in $${SUBDIRS}; do \
		echo "[1m==> $${DIR}[m"; \
		(cd $${DIR} && $(MAKE) $(MFLAGS) build) || exit 1; \
		echo "[1m<== $${DIR}[m"; \
	done

$(TARGET): 
	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(EXTOBJS) $(LIBS)
 
$(LIBRARY): $(LIBRARY).so
 
$(LIBRARY).so: $(LIBRARY).so.$(LIBRARY_MAJOR)
 
$(LIBRARY).so.$(LIBRARY_MAJOR): 
	$(CXX) -shared -Wall -Wl,-soname,$@ -o $@ $(OBJS) $(EXTOBJS) $(LIBS)
 
$(LIBRARY).a: 
	$(AR) cr $@ $(OBJS) $(EXTOBJS)
	$(RANLIB) $@

sanity:
	@test -z "$(SRCDIR)" && echo "Please build from the 'src' directory." && exit 1 || exit 0

docs:
	$@echo "Not done yet.."

clean:
	rm -f $(TARGET) *.so.* *.o
	-@SUBDIRS="$(SUBDIRS)"; \
	for DIR in $${SUBDIRS}; do \
		echo "[1m==> $${DIR}[m"; \
		(cd $${DIR} && $(MAKE) $(MFLAGS) clean) || exit 1; \
		echo "[1m<== $${DIR}[m"; \
	done

distclean:
	rm -f $(TARGET) *.so.* *.o Makefile
	-@SUBDIRS="$(SUBDIRS)"; \
	for DIR in $${SUBDIRS}; do \
		echo "[1m==> $${DIR}[m"; \
		(cd $${DIR} && $(MAKE) $(MFLAGS) distclean) || exit 1; \
		echo "[1m<== $${DIR}[m"; \
	done

depend:
	$(SED) -ne '1,/^# DEPENDENCIES/p' Makefile.in > Makefile.depend && \
	$(CXX) -MM ${OBJS:.o=.c*} $(DEFINES) >> Makefile.depend && \
	mv -f Makefile.depend Makefile.in || rm Makefile.depend
	-@SUBDIRS="$(SUBDIRS)"; \
	for DIR in $${SUBDIRS}; do \
		echo "[1m==> $${DIR}[m"; \
		(cd $${DIR} && $(MAKE) $(MFLAGS) depend) || exit 1; \
		echo "[1m<== $${DIR}[m"; \
	done

install:
	./${TARGET} > sella_nms.vim.in
	cp -f sella_nms.vim.in /usr/share/vim/vim61/syntax/sella_nms.vim
	cp -f sella_nms.vim.in /usr/share/vim/vim62/syntax/sella_nms.vim
	echo INSTALLED

# --------------------------------------
#              Dependencies
# --------------------------------------

# DEPENDENCIES - DO NOT EDIT MANUALLY
mkvim: main.o
