
TARGETS = cginfo

UNAME := $(shell uname)


CGINFO_C = cginfo.c

CGINFO_OBJS = $(CGINFO_C:.c=.o) 

CC         =  gcc
CFLAGS     += -Wall
ifdef CG_INC_PATH
  CFLAGS   += -I"$(CG_INC_PATH)"
endif


ifeq ($(UNAME), Darwin)
else
  ifeq ($(findstring CYGWIN, $(UNAME)), CYGWIN)
    CFLAGS     += -D_WIN32
    CFLAGS     += -I"C:\Program Files\NVIDIA Corporation\Cg\include"
    EXE = .exe
  else
    ifeq ($(UNAME), SunOS)
      CLINKFLAGS += -lpthread
    else
      # unfortunately, older versions of Cg have a dependency on the C++ stdlib
      CLINKFLAGS += -lstdc++
      CLINKFLAGS += -lpthread
      CLINKFLAGS += -ldl
    endif
  endif
endif

BINARIES := $(TARGETS:=$(EXE))

all: $(BINARIES)


cginfo$(EXE): $(CGINFO_OBJS)
	$(CC) $(CFLAGS) $(CGINFO_OBJS) -o $@ $(CLINKFLAGS)

run: all
	./cginfo$(EXE)

clean:
	$(RM) $(BINARIES) $(CGINFO_OBJS) 

clobber: clean
	$(RM) *.bak *.o *~

.PHONY: all run clean clobber
