####################################################################################################

CC =		g++

BASEFLAGS =	-c -O1 -Wall
CFLAGS =	`gnome-config --cflags gnomeui` -DVERSION=\"1.0\"

OUTFILE =	test

LIBS =		$(X11LIBS) $(GNOMELIBS)
X11LIBS =	-L/usr/X11R6/lib/ -lXmu -lXi -lXext -lX11
GNOMELIBS =	`gnome-config --libs gnomeui`

SRC =		glade_callbacks.cpp \
		glade_interface.cpp \
		glade_support.cpp \
		main.cpp
		
OBJ =		$(SRC:.cpp=.o)

####################################################################################################

### before doing anything else, manually bring the sources to a state where it compiles with g++.
### you just have to add some conversions from (void *) -> (GtkWidget *), if anything at all...

$(OUTFILE):	$(OBJ)
		$(CC) -o $(OUTFILE) $(OBJ) $(LIBS)
		
%.o: %.cpp
		$(CC) $(BASEFLAGS) $(CFLAGS) $(@:.o=.cpp)
		
clean:
		rm -f *.o *~
		
main:
		mv main.c main.cpp
		
####################################################################################################

### ok, glade seems to retain changes (at least) in "callbacks"-files automatically, but it
### seems that we still have to make some manual modifications also to "interface"-files. this
### system will store changes to diffs and then restore them to the main tree files. this way
### it's also quick and easy to study how the GLADE code works, and how to best implement
### certain things there.

### just run "make diffs" *before* you issue the rebuild-command in GLADE, which then updates
### the GLADE code in this directory. *after* the rebuild run "make update"; this will make
### backups from the files in the main tree, copy the new sources there, and apply the patches
### to the files in main tree. if everything went fine, you can then "make diffs" again and
### repeat the cycle...

### this system will *not* work if you change the names of widgets/callbacks in GLADE?!?!?!
### then just try to make the changes manually?!?!?!?!

diffs:		# values returned by diff seems to confuse make -> just force to run all...
		diff -c3p glade_callbacks.cpp ../../glade_callbacks.cpp > callbacks.cpp.diff; \
		diff -c3p glade_callbacks.h ../../glade_callbacks.h > callbacks.h.diff; \
		diff -c3p glade_interface.cpp ../../glade_interface.cpp > interface.cpp.diff; \
		diff -c3p glade_interface.h ../../glade_interface.h > interface.h.diff
		
update:
		cp ../../glade_callbacks.cpp ../../glade_callbacks.cpp~
		cp ../../glade_callbacks.h ../../glade_callbacks.h~
		cp ../../glade_interface.cpp ../../glade_interface.cpp~
		cp ../../glade_interface.h ../../glade_interface.h~
		
		cp glade_callbacks.cpp ../../
		cp glade_callbacks.h ../../
		cp glade_interface.cpp ../../
		cp glade_interface.h ../../
		
		cd ../../; patch --ignore-whitespace --fuzz=3 -p2 < glade/src/callbacks.cpp.diff
		cd ../../; patch --ignore-whitespace --fuzz=3 -p2 < glade/src/callbacks.h.diff
		cd ../../; patch --ignore-whitespace --fuzz=3 -p2 < glade/src/interface.cpp.diff
		cd ../../; patch --ignore-whitespace --fuzz=3 -p2 < glade/src/interface.h.diff
		
####################################################################################################
