
include ../../Makefile.common
include ../../Makefile.dirs
include ../../Makefile.config

#CFLAGS+=-ansi
INCDIR+=-I.

test: appconf.o SimpleConfig.o QConfig.o test.o 
	$(COMP) -o test $(CFLAGS) $(QT_LIB) $(QTLINK) -LX11 \
		test.o appconf.o SimpleConfig.o QConfig.o

testsimple: appconf.o SimpleConfig.o testsimple.o 
	$(COMP) -o testsimple $(CFLAGS) $(QT_LIB) -LX11 -lstdc++ \
		testsimple.o appconf.o SimpleConfig.o

testqconfig: appconf.o SimpleConfig.o QConfig.o testqconfig.o 
	$(COMP) -o testqconfig $(CFLAGS) $(QT_LIB) $(QTLINK) -LX11 \
		testqconfig.o appconf.o SimpleConfig.o QConfig.o

testlib: libraries test.o 
	$(COMP) -o testlib $(CFLAGS) $(QT_LIB) $(QTLINK) -LX11 \
		test.o libsimpleconfig.so.1 libqconfig.so.1

teststatic: static test.o 
	$(COMP) -o teststatic $(CFLAGS) $(QT_LIB) $(QTLINK) -LX11 \
		test.o libqconfig.a

demo: demo.o appconf.o
	$(COMP) -o demo $(CFLAGS) $(QT_LIB) $(QTLINK) -LX11 \
		demo.o appconf.o

objects: appconf.o SimpleConfig.o QConfig.o

libraries: libsimpleconfig.so.1 libqconfig.so.1

appconf.o: appconf.h appconf.cpp
SimpleConfig.o: SimpleConfig.h SimpleConfig.cpp
QConfig.o: QConfig.h QConfig.cpp

# Static
static: libsimpleconfig.a libqconfig.a

libsimpleconfig.a: appconf.o SimpleConfig.o
	$(AR) -crs libsimpleconfig.a appconf.o SimpleConfig.o

libqconfig.a: appconf.o SimpleConfig.o QConfig.o
	$(AR) -crs libqconfig.a appconf.o SimpleConfig.o QConfig.o

# Libraries
appconf.pic: appconf.h appconf.cpp
SimpleConfig.pic: SimpleConfig.h SimpleConfig.cpp
QConfig.pic: QConfig.h QConfig.cpp

# How to build .o-pic files
%.pic: %.cpp ; $(CCOMP) $(CFLAGS-PIC) $(INCDIR) $(QT_INC) $(KDE_INC) -c $< -o $@

# Options for compiling shared library modules
CFLAGS-PIC = $(CFLAGS) -fPIC

# Command to build a shared library
# $@ will be replaced by the name of the library, eg libpcre.so.2
MK-SHARED-LIB = $(CCOMP) -shared -Wl,-soname,$@ -o $@ -lc

libsimpleconfig.so.1: appconf.pic SimpleConfig.pic
	$(MK-SHARED-LIB) appconf.pic SimpleConfig.pic

libqconfig.so.1: libsimpleconfig.so.1 QConfig.pic
	$(MK-SHARED-LIB) $(QT_LIB) $(QTLINK) -LX11 QConfig.pic libsimpleconfig.so.1

#demo: demo.o appconf.o
#	g++ -o $@ $^ $(LIB)

doc: doc/index.html

doc/index.html: appconf.h SimpleConfig.h QConfig.h
	@#doc++ -f -j -k -u -k -H -t -o doc/appconf.tex -d doc appconf.h
	@#doc++ -f -j -k -u -k -H -d doc SimpleConfig.h QConfig.h appconf.h
	doc++ -f -j -k -u -k -H -d doc doc.h

clean:
	-rm *.o
	-rm *.pic
	-rm *.a
	-rm libsimpleconfig.so.1 
	-rm libqconfig.so.1
	-rm test
	-rm testsimple
	-rm testqconfig
	-rm testlib
	-rm teststatic
	-rm doc/*
