Skip to content
Snippets Groups Projects
Makefile 1.21 KiB
Newer Older
  • Learn to ignore specific revisions
  • toole1's avatar
    toole1 committed
    CC = g++
    
    toole1's avatar
    toole1 committed
    CFLAGS = -Wall -Wshadow
    
    toole1's avatar
    toole1 committed
    EXENAME = monad
    OBJS = $(EXENAME).o help.o util.o monad_shared.o
    IDFILE = .monadid
    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
    
    
    toole1's avatar
    toole1 committed
    IS_LIBRT:=$(shell locate -l 1 -c librt.so)
    ifeq ($(IS_LIBRT),0)
    LIBRT=
    else
    LIBRT=-lrt
    endif
    
    
    toole1's avatar
    toole1 committed
    all: $(EXENAME) $(IDFILE)
    
    $(IDFILE): $(OBJS)
    	echo -e '$(EXENAME) identification file\n'\
    'This file is used for $(EXENAME) directory identification\n'\
    'Built by' `whoami` 'on' `hostname`'\n'\
    'Build Date:' `date`> $(IDFILE)
    
    $(EXENAME): $(OBJS) $(IDFILE)
    
    toole1's avatar
    toole1 committed
    	$(CC) $(CFLAGS) $(LIBRT) $(OBJS) -o $@
    
    toole1's avatar
    toole1 committed
    
    
    toole1's avatar
    toole1 committed
    help.cpp: $(wildcard *.h) README.cg LICENSE.cg
    
    CONVERT_TXT_TO_CG=sed -e 's/"/\\"/g' -e 's/^/    << "/' -e 's/$$/" << endl/'
    
    toole1's avatar
    toole1 committed
    
    README.cg: README.txt
    
    toole1's avatar
    toole1 committed
    	$(CONVERT_TXT_TO_CG) README.txt > README.cg
    
    LICENSE.cg: LICENSE.txt
    	$(CONVERT_TXT_TO_CG) LICENSE.txt > LICENSE.cg
    
    toole1's avatar
    toole1 committed
    
    
    toole1's avatar
    toole1 committed
    %.o : %.cpp $(wildcard *.h)
    
    toole1's avatar
    toole1 committed
    	$(CC) $(CFLAGS) -c $(@:.o=.cpp) -o $@
    
    .PHONY: clean
    clean:
    	rm -f $(wildcard *.o) $(wildcard *.cg) $(EXENAME) $(IDFILE) $(wildcard $(EXENAME)$(EXENAME)*)
    
    .PHONY: clean.sh
    clean.sh: $(EXENAME)
    	./clean.sh