# XSTEP 3.5 - Toolkit for X Window System
# Copyright (C) 1996-2000 by Marcelo Samsoniuk
#
# 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
# (at your option) 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
 
      CC  = gcc
  CFLAGS  = -Wall -O3 -funroll-loops -fomit-frame-pointer -pipe
  CFLAGS += -I/usr/X11R6/include -I/usr/X11/include
 LDFLAGS  = -L/usr/X11R6/lib -L/usr/X11/lib -lX11 -shared
    OBJS  = util.o 		\
            window.o 		\
            button.o 		\
            radio.o 		\
            check.o 		\
            edit.o 		\
            label.o   		\
            box.o 		\
            scroll.o 		\
            main.o 		\
            scroll_buttons.o 	\
            scroll_lists.o 	\
            menu.o 		\
            popup.o		\
            group.o		\
	    xyscroll.o		\
	    scan.o		\
	    fine_tune.o

 LIBRARY  = xstep
 VERSION  = 3.5
 INSTALL  = /usr/local

# CFLAGS += -DSHOWKEYSYM 	# show X11 KEYSYMs
# CFLAGS += -DSHOWEVENT 	# show X11 events
# CFLAGS += -DSHOWCACHEEXPOSE 	# show cached expose requests
# CFLAGS += -DSHOWFLUSHEXPOSE 	# show flushed expose requests
  CFLAGS += -DKEYPADBUG		# keypad bug
# CFLAGS += -DTREEWINDOW	# this is an unknow option for me! =)

all:: lib$(LIBRARY).so

lib$(LIBRARY).so:: $(OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o lib$(LIBRARY).so
	@echo "type 'make install' to install."

install: all
	@if test "`whoami`" != "root"; 					\
	then 								\
		echo "you must be 'root' to install libxstep.so.";	\
		echo "installation aborted, unable to install";		\
		false;							\
	fi
	@echo "installing XSTEP to $(INSTALL): "
	@-rm -f 	$(INSTALL)/lib/lib$(LIBRARY).so.$(VERSION) 	\
			$(INSTALL)/lib/lib$(LIBRARY).so 		\
			$(INSTALL)/include/$(LIBRARY).h 		\
			$(INSTALL)/include/$(LIBRARY)-port.h
	@-test -d 	$(INSTALL)/lib || mkdir $(INSTALL)/lib
	@-test -d 	$(INSTALL)/include || mkdir $(INSTALL)/include
	@cp 		$(LIBRARY).h 					\
			$(LIBRARY)-port.h 				\
			$(INSTALL)/include
	@echo -n 	"  $(LIBRARY).h $(LIBRARY)-port.h "
	@cp 		lib$(LIBRARY).so 				\
			$(INSTALL)/lib/lib$(LIBRARY).so.$(VERSION)
	@echo -n 	"lib$(LIBRARY).so "
	@ln -sf 	$(INSTALL)/lib/lib$(LIBRARY).so.$(VERSION) 	\
			$(INSTALL)/lib/lib$(LIBRARY).so
	@echo	 	"lib$(LIBRARY).so.$(VERSION)."
	@chown root. 	$(INSTALL)/lib/lib$(LIBRARY).so.$(VERSION) 	\
			$(INSTALL)/lib/lib$(LIBRARY).so 		\
			$(INSTALL)/include/$(LIBRARY).h 		\
			$(INSTALL)/include/$(LIBRARY)-port.h
	@chmod 755 	$(INSTALL)/lib/lib$(LIBRARY).so.$(VERSION) 	\
			$(INSTALL)/lib/lib$(LIBRARY).so 		\
			$(INSTALL)/include/$(LIBRARY).h 		\
			$(INSTALL)/include/$(LIBRARY)-port.h
	@echo 	 	"permissions: rwxr-xr-x"
	@if test -f /etc/ld.so.conf; 					\
	then 								\
		if test "`grep $(INSTALL)/lib /etc/ld.so.conf`" = ""; 	\
		then 							\
			echo '$(INSTALL)/lib' >> /etc/ld.so.conf; 	\
			echo -n "broken ld.so.conf: ";			\
			echo -n "[$(INSTALL)/lib >> /etc/ld.so.conf] ";	\
		fi; 							\
		/sbin/ldconfig && 					\
			echo "ldconfig ok, done." || 			\
			echo "ldconfig: failed, please check.";		\
	else 								\
		/sbin/ldconfig -m $(INSTALL)/lib && 			\
			echo "ldconfig ok, done." ||			\
			echo "you must run ldconfig..."; 		\
	fi

uninstall:
	-rm -f	 	$(INSTALL)/lib/lib$(LIBRARY).so.$(VERSION) 	\
			$(INSTALL)/lib/lib$(LIBRARY).so 		\
			$(INSTALL)/include/$(LIBRARY).h 		\
			$(INSTALL)/include/$(LIBRARY)-port.h

clean: 
	-rm -f 	$(OBJS) lib$(LIBRARY).so
