#
# This is the Makefile for xbmbrowser (Version 5.0)
#
# Remove the  -DDO_XPMS  and the  -lXpm  to remove X pixmap features
#
#CC     = cc
CC      = gcc

# Location of X stuff
X_INC = -I/usr/X11R6/includes
X_LIB = -L/usr/X11R6/libs

# X Pixmap Library (change for your system / comment out to disable)
XPM_INC = -I/usr/include/X11
XPM_LIB = -L$(LIBDIR)/xpm -lXpm
DO_XPMS = -DDO_XPMS #-DNO_TRANS_COLOR


CFLAGS  = -O -DNDEBUG $(DO_XPMS) $(XPM_INC)
LIBS    = $(XPM_LIB) $(X_LIB) -lXaw -lXt -lXmu -lX11 -lXext 

SRCS = xbmbrowser.c images.c IconLabel.c callbacks.c misc.c \
       user_menu.c user_functs.c
OBJS = xbmbrowser.o images.o IconLabel.o callbacks.o misc.o \
       user_menu.o user_functs.o
DATA = XbmBrowser.ad.sed XbmBrowser.ad XbmBrowser-color.ad \
       xbmbrowser.menu xbmbrowser.menu.tut

#   CDEBUGFLAGS = -O -DNDEBUG
    CDEBUGFLAGS = -g
#   CDEBUGFLAGS = -g -DPARSE
#ifdef HPArchitecture
    CCOPTIONS = -Aa -D_HPUX_SOURCE
#endif

# Sed substitions rule
.sed: 
	@echo 'SED SUBSTITUTIONS "$@.sed" ==> "$@"'
	@sed -e 's|==BROWSERDIR==|$(BROWSERDIR)|' \
	     -e 's|==LIBRARY_RC==|$(LIBRARY_RC)|' \
	     -e 's|==USERS_RC==|$(USERS_RC)|'     \
	     -e 's|==X_BITMAPS==|$(X_BITMAPS)|'   \
	     -e '/==COLOR_SETTINGS_DIVIDER==/d'   \
	     < $@.sed  >$@
.SUFFIXES: .sed

# -------------------------------------------------------
# Actual build rules begin

all: xbmbrowser $(DATA)

xbmbrowser: $(OBJS)
	$(CC) $(CFLAGS) -o xbmbrowser $(OBJS) $(LIBS)
	strip xbmbrowser

$(OBJS): xbmbrowser.h
xbmbrowser.o: patchlevel.h
IconLabel.o images.o: IconLabel.h IconLabelP.h

XbmBrowser.ad.sed: XbmBrowser-color.ad.sed
	@echo 'DIVIDING COLOR AD "XbmBrowser-color.ad.sed" ==> "$@"'
	@sed -n '1,/==COLOR_SETTINGS_DIVIDER==/p' \
	     <XbmBrowser-color.ad.sed >$@

dataclean:
	rm -f $(DATA)

clean: dataclean
	rm -f xbmbrowser
	rm -f core  *.o *~ #*

