
CC = gcc
CFLAGS += -Wall -O6
INCLUDES += -I../include

ifdef DEBUG
CFLAGS += -g -pg
endif


# building directory
BUILD = ../bin


default: all

all: pre $(BUILD)/libold $(BUILD)/libold.so

pre:
	@if [ ! -d $(BUILD) ]; then mkdir $(BUILD); fi

$(BUILD)/libold: libold.o
	$(CC) $(CFLAGS) -o $(BUILD)/libold libold.o $(INCLUDES) $(LIBS)

$(BUILD)/libold.so: libold.o
	$(CC) $(CFLAGS) --shared -o $(BUILD)/libold.so libold.o $(INCLUDES) $(LIBS)

.c.o:
	$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@


.PHONY: clean cleanobj
cleanobj:
	rm -f libold.o

clean: cleanobj
	rm -f $(BUILD)/libold
	rm -f $(BUILD)/libold.so

