# define cc flag. The default is Intel icc if not specified.
ifdef cc
   ifeq ($(cc),icc)
         ccflags = -O3 -openmp
   endif
   ifeq ($(cc),pgcc)
         ccflags = -O2 -mp 
   endif
   ifeq ($(cc),gcc)
         ccflags = -O2 -fopenmp -lm
   endif
else
         cc = icc
         ccflags = -O3 -openmp  -mkl 
         $(info The default compiler is Intel icc ...)
endif


LDFLAGS=$(ccflags)

SRCS =  hello_c.c              \
	mapping_threads_c.c    \
	data_racing_c.c        \
	threadprivate_v0_c.c   \
	threadprivate_v1_c.c   \
	threadprivate_v2_c.c   \
	nested_loops_v0_c.c    \
	nested_loops_v1_c.c    \
	nested_loops_v2_c.c    \
	sections_c.c           \
	single_c.c             \
	atomic_c.c             \
	privatevar_c.c         \
	firstprivate_v0_c.c    \
	firstprivate_v1_c.c    \
	false_sharing_v0_c.c   \
	false_sharing_v1_c.c   \
	false_sharing_v2_c.c   \
	false_sharing_v3_c.c   \
	false_sharing_v4_c.c   \
	loops_c.c              \
	loops_out_c.c          \
	sum_order_c.c          \
	threaded_dgemm_mkl_c.c \


OBJS =	$(SRCS:.c=.o)
PROG =  $(SRCS:.c=)

all: $(PROG)


clean:
	rm -f $(PROG) $(OBJS) *.mod *~

# clenaomod only remove *.o, *.mod, and *~ file. 
# Executable file is not removed.
cleanomod:
	rm -f $(OBJS) *.mod *~


%:%.c
	$(cc) $(ccflags) -o $@  $<

