include install.mk
include resource.mk

MAJOR=1
MINOR=0

SHARE = shared
PIC = -PIC -E -DHCLONLY

# The default settings  ( bin lib include man )

NAME=hcl
LIB=lib$(NAME)

## no changes needed in principle

INCDIRS= hush widgets handlers adt tcl-tk

# Objects -- hush

EXT=hush-external.o

OBJECTS = hush-hcl.o hush-kit.o hush-event.o \
          hush-action.o hush-handler.o hush-session.o \
          hush-init.o hush-tk.o hush-startup.o  hush-adt.o

MAIN=main.o 

all: it

it: main
	du -s a.out

main: $(MAIN) 
	$(CC) $(CFLAGS) $(MAIN) $(LDFLAGS)

hclib: 
	cp hush-*.c *.mk Makefile hcl
	cd hcl; make lib NAME=hcl

lib: $(SHARE)
	@echo $(SHARE) libraries

shared: $(OBJECTS)
	rm -f $(LIB).so.* 
	ld -o $(LIB).so.$(MAJOR).$(MINOR) $(OBJECTS)
	cp $(LIB).so.$(MAJOR).$(MINOR) $(HUSH)/lib

nonshared: $(OBJECTS)
	rm -f $(LIB).a
	ar cr $(LIB).a $(OBJECTS)
	#ranlib $(LIB).a
	mv $(LIB).a  $(HUSH)/lib
	cd $(HUSH)/lib; ranlib $(LIB).a

install: lib
	if [ ! -d $(HUSH)/bin ]; then mkdir $(HUSH)/bin; fi
	if [ ! -d $(HUSH)/include ]; then mkdir $(HUSH)/include; fi
	@set -x; for i in $(INCDIRS); do \
	   if [ ! -d $(HUSH)/include/$$i ]; then \
		      mkdir $(HUSH)/include/$$i; \
		      fi; \
		      cp $$i/* $(HUSH)/include/$$i; \
		      done

clean:
	rm -f core *.a *.o out *.out lib*.so.* 
	rm -f -r ptrepository
