# apachemod/Makefile
# This file is part of Anyterm; see http://anyterm.org/
# (C) 2005 Philip Endecott

# This is version $Name: V1-1-4 $
#   (if there is no version (e.g. V0-1) mentioned in the previous line,
#    this is probably a snapshot from between "official" releases.)

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.



default_target: compile

# If apxs2 or apr-config is not on your path, edit the following lines
# to give a complete path:
APXS2=apxs2
APR_CONFIG=apr-config


# You shouldn't need to change anything below here.


CPP_FLAGS=$(shell rote-config --cflags) \
	$(shell $(APR_CONFIG) --cppflags --includes) \
	-I$(shell $(APXS2) -q INCLUDEDIR)

COMPILE_FLAGS=$(CPP_FLAGS) $(shell $(APR_CONFIG) --cflags) -Wall -O

C_COMPILE_FLAGS=$(COMPILE_FLAGS) -std=gnu99

CC_COMPILE_FLAGS=$(COMPILE_FLAGS)

LINK_FLAGS=$(shell rote-config --libs) -lstdc++

C_SRCS=$(wildcard *.c)
CC_SRCS=$(wildcard *.cc)

OBJS=$(addsuffix .lo,$(basename $(C_SRCS) $(CC_SRCS)))


%.lo: %.cc
	libtool --mode=compile g++ $(CC_COMPILE_FLAGS) -o $@ -c $<

%.lo: %.c
	libtool --mode=compile gcc $(C_COMPILE_FLAGS) -o $@ -c $<


compile: $(OBJS)
	$(APXS2) -c -o anyterm.la $(OBJS) $(LINK_FLAGS)

install: FORCE
	$(APXS2) -n anyterm -i anyterm.la

%.d: %.cc
	g++ -MM -MG -MT $@ -MT $(<:%.cc=%.lo) $(CPP_FLAGS) -o $@ $<

%.d: %.c
	gcc -MM -MG -MT $@ -MT $(<:%.c=%.lo) $(CPP_FLAGS) -o $@ $<

DEPENDS=$(addsuffix .d,$(basename $(OBJS)))

-include $(DEPENDS)

clean: FORCE
	rm -f *.lo *.la *.slo *.o .libs/*.o


.PHONY: default_target compile install FORCE
