Skip to content
Snippets Groups Projects
Makefile.proxy 1.25 KiB
Newer Older
  • Learn to ignore specific revisions
  • toole1's avatar
    toole1 committed
    CC = g++
    
    WARNINGS := -Wchar-subscripts -Wparentheses -Wreturn-type -Wmissing-braces -Wundef -Wshadow
    CFLAGS += $(WARNINGS)
    
    toole1's avatar
    toole1 committed
    TESTEXE := proxy
    # This order is necessary for security. Always include student code last!
    
    # TODO (toole1): I wish I knew why this was; doing unit_tests first is slow if the student code doesn't compile
    
    toole1's avatar
    toole1 committed
    TESTOBJS := $(TESTEXE).o util.o unit_tests.o monad_shared.o $(TESTOBJS)
    OPTIMIZE := off
    
    ifeq ($(strip $(OPTIMIZE)),on)
    CFLAGS += -O2 -DOPTIMIZE
    else ifeq ($(strip $(OPTIMIZE)),off)
    CFLAGS += -g -O0
    else
    $(warning Invalid value specified for OPTIMIZE. Should be on or off)
    CFLAGS += -g -O0
    endif
    
    ifndef ALL_TARGET
    ALL_TARGET = all
    all: $(TESTEXE)
    endif
    
    
    toole1's avatar
    toole1 committed
    LIBS:=
    IS_LIBRT:=$(shell echo "int main(){}" | g++ -o /dev/null -x c++ - -lrt &>/dev/null ; echo $$?)
    IS_LIBPNG:=$(shell echo "int main(){}" | g++ -o /dev/null -x c++ - -lpng &>/dev/null ; echo $$?)
    
    toole1's avatar
    toole1 committed
    ifeq ($(IS_LIBRT),0)
    
    toole1's avatar
    toole1 committed
    LIBS+= -lrt
    endif
    ifeq ($(IS_LIBPNG),0)
    LIBS+= -lpng 
    
    toole1's avatar
    toole1 committed
    endif
    
    
    toole1's avatar
    toole1 committed
    $(TESTEXE): $(TESTOBJS)
    
    toole1's avatar
    toole1 committed
    	$(CC) $(LIBS) $(TESTOBJS) -o $@
    
    unit_tests.o : unit_tests.cpp $(wildcard *.h)
    	../ccmonad $(CC) $(CFLAGS) -c $(@:.o=.cpp) -o $@
    
    
    toole1's avatar
    toole1 committed
    %.o : %.cpp $(wildcard *.h)
    
    toole1's avatar
    toole1 committed
    	$(CC) $(CFLAGS) -c $(@:.o=.cpp) -o $@
    
    ifndef CLEAN_TARGET
    CLEAN_TARGET = clean
    .PHONY: clean
    clean:
    	-rm -f *.o $(TESTEXE)
    endif