# $Copyright:	$
# Copyright (c) 2000 by Steve Baker (ice@mama.indstate.edu)
# All rights reserved
#  
# This software is provided as is without any express or implied
# warranties, including, without limitation, the implied warranties
# of merchantability and fitness for a particular purpose.

CC=gcc

# Suggested optimizations:
# For AMD Athlon:
OPT=-O3 -march=i386 -export-dynamic -funroll-loops -finline -fomit-frame-pointer -fstrength-reduce -ffast-math

export CLAMROOT=/usr/lib/clam

#export CFLAGS=-ggdb -export-dynamic -finline-functions
#export CFLAGS=-O -p -export-dynamic -finline-functions
export CFLAGS=-Wall $(OPT)

#-Wall -O3 -funroll-loops -finline -fomit-frame-pointer -fstrength-reduce -ffast-math
#export SFLAGS=-ggdb -shared -fPIC
#export SFLAGS=-O -p -shared -fPIC
export SFLAGS=-Wall -p -shared -fPIC $(OPT)

# LDFLAGS=-s
# LDFLAGS=-pg
LIBS=-ldl

OBJS=clam.o main.o lex.o expr.o fmtstr.o run.o eval.o sym.o resolve.o input.o
export SHARED=io.so stdlib.so

DEST=clam
PREFIX=/usr/bin

all:	$(OBJS) lib
	$(CC) $(CFLAGS) $(OPTS) -o $(DEST) $(OBJS) $(LIBS)

%.so: %.c clam.h
	$(CC) $(SFLAGS) -o $@ $<

%.o: %.c clam.h
	$(CC) $(CFLAGS) -c $< -o $@ -DCLAMROOT=\"$(CLAMROOT)\"

lib:	clam.h dummy
	make -C lib libs

clean:
	rm -f *.o lib/*.so clam

install:
	install -d $(CLAMROOT)/include; \
	install -d $(CLAMROOT)/lib; \
	cp -ar include $(CLAMROOT); \
	cp -ar lib/*.so $(CLAMROOT)/lib; \
	install -s $(DEST) $(PREFIX);

dummy:

