Skip to content

Instantly share code, notes, and snippets.

@samvit
Created June 30, 2014 00:46
Show Gist options
  • Save samvit/2709c838ae18bb9bc0c1 to your computer and use it in GitHub Desktop.
Save samvit/2709c838ae18bb9bc0c1 to your computer and use it in GitHub Desktop.
ARCH := $(shell uname -m)
OS := $(shell uname)
ifndef LIBHOME
ifdef MASTERDIR
LIBHOME := $(MASTERDIR)/pkg/$(ARCH)/horn2
else
LIBHOME := $(HOME)/pkg/$(ARCH)/horn2
endif
endif
HORN = $(LIBHOME)/bin/horn
APYC = $(shell echo `pwd`/../apyc)
CXXFLAGS = -g -Wall
INCLUDES = -I$(LIBHOME)/include
ifeq "$(OS)" "Darwin"
OTHER_LIBS = -lpthread
else
OTHER_LIBS = -lpthread -lrt
endif
LOADLIBS = -L$(LIBHOME)/lib -lgc $(OTHER_LIBS)
CXXFLAGS = -g -Wall $(INCLUDES)
# List of normal C++ sources. Add any new ones here
SRCS = apyc.cc ast.cc decls.cc environ.cc exprs.cc modules.cc \
stmts.cc tokens.cc types.cc
# C++ top-level (i.e., as opposed to #included) sources that are generated
# by other rules in this Makefile.
GENERATED_SRCS = apyc-parser.cc
# List of all C++ object files
OBJS = $(SRCS:.cc=.o) $(GENERATED_SRCS:.cc=.o)
# List of all C++ sources generated by tools
OTHER_SRCS = $(GENERATED_SRCS) \
apyc-lexer.l apyc-lexer.cc apyc-lexer.hh \
apyc-parser.y apyc-parser.hh
.PHONY: default compile check check1 check2 clean really-clean depend
default: compile
compile: ../apyc
$(OTHER_SRCS): parser-sentinel
# The parser-sentinel file is a device that is used to group all the files
# generated by horn into one dependency. Each time we generate these files,
# we update the modify date on parser-sentinel. The generated files in turn
# depend on parser-sentinel, and it depends on apyc.hn. So, whenever apyc.hn
# is changed, any compilation that depends on a generated file will cause
# horn to rebuild the generated files (OTHER_SRCS).
parser-sentinel: apyc.hn
$(HORN) $<
touch parser-sentinel
../apyc: $(OBJS)
$(CXX) -g -o $@ $(OBJS) $(LOADLIBS)
check:
$(MAKE) -C .. APYC=$(APYC) check
check1:
$(MAKE) -C .. APYC=$(APYC) check1
check2:
$(MAKE) -C .. APYC=$(APYC) check2
check3:
$(MAKE) -C .. APYC=$(APYC) check3
clean:
$(RM) *~ *.o *.pyc *.ast *.tab.c *.output
$(RM) tests/*~ tests/*/*~
$(RM) $(OTHER_SRCS) parser-sentinel
really-clean: clean
$(RM) .depend
# Dependencies
.depend:
touch .depend
$(MAKE) depend
depend: $(OTHER_SRCS)
$(RM) .depend
$(CXX) -MM $(INCLUDES) $(OBJS:.o=.cc) > .depend
-include .depend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment