###############################################################################
# Makefile for the project oscilloscope
###############################################################################

## General Flags
PROJECT = microthreads
TARGET = ./microthreads
CC = gcc

CPP = g++

## Options common to compile, link and assembly rules
COMMON = -march=i586

## Compile options common for all C compilation units.
CFLAGS = $(COMMON) -D_LINUX -DSTACK_SIZE=5000
CFLAGS += -Wall -O2 -funsigned-char -funsigned-bitfields
CFLAGS += -MD -MP -MT $(*F).o

## Linker flags
LDFLAGS = $(COMMON)
LDFLAGS += 

# Includes
INCLUDES = -I ../..

## Objects that must be built in order to link
OBJECTS = microthreads_pc.o microthreads.o

## Objects explicitly added by the user
LINKONLYOBJECTS = 

## Build
all: $(TARGET) ## Compile
microthreads.o: ../../microthreads.c
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
microthreads_pc.o: microthreads_pc.c
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<

##Link
$(TARGET): $(OBJECTS)
	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)

## Clean target
clean:
	-rm -rf $(OBJECTS) ./*.d ./microthreads dep/*

