Makefile 3.53 KB
Newer Older
1
CC   := gcc
2
CXX  := g++
3 4 5 6 7
LD   := $(CXX)

$(info Using CC=$(CC))
$(info Using CXX=$(CXX))
$(info Using LD=$(LD))
Alan Mishchenko committed
8 9 10

PROG := abc

Alan Mishchenko committed
11
MODULES := \
12
	$(wildcard src/ext) src/misc/ext \
13 14 15 16
	src/base/abc src/base/abci src/base/cmd src/base/io \
	src/base/main src/base/ver src/base/test \
	src/bdd/cudd src/bdd/dsd src/bdd/epd src/bdd/mtr src/bdd/parse \
	src/bdd/reo src/bdd/cas \
17
	src/map/mapper src/map/mio src/map/super src/map/if \
18
	src/map/amap src/map/cov src/map/scl \
19 20 21 22 23
	src/misc/extra src/misc/mvc src/misc/st src/misc/util src/misc/nm \
	src/misc/vec src/misc/hash src/misc/tim src/misc/bzlib src/misc/zlib \
	src/misc/mem src/misc/bar src/misc/bbl \
	src/opt/cut src/opt/fxu src/opt/rwr src/opt/mfs src/opt/sim \
	src/opt/ret src/opt/res src/opt/lpk src/opt/nwk src/opt/rwt \
Alan Mishchenko committed
24
	src/opt/cgt src/opt/csw src/opt/dar src/opt/dau src/opt/sfm \
25
	src/sat/bsat src/sat/csat src/sat/msat src/sat/psat src/sat/cnf src/sat/bmc \
26 27
	src/bool/bdc src/bool/deco src/bool/dec src/bool/kit src/bool/lucky \
	src/bool/rsb src/bool/rpo \
28 29
	src/proof/pdr src/proof/int src/proof/bbr src/proof/llb src/proof/live \
	src/proof/cec src/proof/dch src/proof/fraig src/proof/fra src/proof/ssw \
30
	src/proof/abs src/proof/ssc \
31
	src/aig/aig src/aig/saig src/aig/gia src/aig/ioa src/aig/ivy src/aig/hop \
32
	src/aig/miniaig \
33
	src/python 
Alan Mishchenko committed
34

35
all: $(PROG)
Alan Mishchenko committed
36
default: $(PROG)
Alan Mishchenko committed
37

38
arch_flags : arch_flags.c
39
	$(CC) arch_flags.c -o arch_flags
40

41
ARCHFLAGS := $(shell $(CC) arch_flags.c -o arch_flags && ./arch_flags)
42
OPTFLAGS  := -g -O #-DABC_NAMESPACE=xxx
Alan Mishchenko committed
43

44 45 46 47 48 49
CFLAGS   += -Wall -Wno-unused-function -Wno-write-strings -Wno-sign-compare $(OPTFLAGS) $(ARCHFLAGS) -I$(PWD)/src

# Set -Wno-unused-bug-set-variable for GCC 4.6.0 and greater only
ifneq ($(or $(findstring gcc,$(CC)),$(findstring g++,$(CC))),)
empty:=
space:=$(empty) $(empty)
50

51 52 53 54 55 56 57 58 59
GCC_VERSION=$(shell $(CC) -dumpversion)
GCC_MAJOR=$(word 1,$(subst .,$(space),$(GCC_VERSION)))
GCC_MINOR=$(word 2,$(subst .,$(space),$(GCC_VERSION)))

$(info Found GCC_VERSION $(GCC_VERSION))
ifeq ($(findstring $(GCC_MAJOR),0 1 2 3),)
$(info Found GCC_MAJOR>=4)
ifeq ($(findstring $(GCC_MINOR),0 1 2 3 4 5),)
$(info Found GCC_MINOR>=6)
60
CFLAGS += -Wno-unused-but-set-variable
61 62 63 64
endif
endif

endif
65

66
LIBS := -ldl -lrt
Alan Mishchenko committed
67

68 69 70 71 72 73 74 75 76 77
ifneq ($(READLINE),0)
CFLAGS += -DABC_USE_READLINE
LIBS += -lreadline
endif

ifneq ($(PTHREADS),0)
CFLAGS += -DABC_USE_PTHREADS
LIBS += -lpthread
endif

78
$(info Using CFLAGS=$(CFLAGS))
79
CXXFLAGS += $(CFLAGS) 
80

Alan Mishchenko committed
81
SRC  := 
82
GARBAGE := core core.* *.stackdump ./tags $(PROG) arch_flags
Alan Mishchenko committed
83

84
.PHONY: all default tags clean docs
Alan Mishchenko committed
85 86 87 88 89 90 91 92 93 94 95 96

include $(patsubst %, %/module.make, $(MODULES))

OBJ := \
	$(patsubst %.cc, %.o, $(filter %.cc, $(SRC))) \
	$(patsubst %.c, %.o,  $(filter %.c, $(SRC)))  \
	$(patsubst %.y, %.o,  $(filter %.y, $(SRC))) 

DEP := $(OBJ:.o=.d)

# implicit rules

97 98 99 100 101 102
%.o: %.c
	@echo "\`\` Compiling:" $(LOCAL_PATH)/$<
	@$(CC) -c $(CFLAGS) $< -o $@

%.o: %.cc
	@echo "\`\` Compiling:" $(LOCAL_PATH)/$<
103
	@$(CXX) -c $(CXXFLAGS) $< -o $@
104

Alan Mishchenko committed
105
%.d: %.c
106 107
	@echo "\`\` Dependency:" $(LOCAL_PATH)/$<
	@./depends.sh $(CC) `dirname $*.c` $(CFLAGS) $*.c > $@
Alan Mishchenko committed
108 109

%.d: %.cc
110
	@echo "\`\` Generating dependency:" $(LOCAL_PATH)/$<
111
	@./depends.sh $(CXX) `dirname $*.cc` $(CXXFLAGS) $*.cc > $@
Alan Mishchenko committed
112 113 114 115 116 117 118 119

-include $(DEP)

# Actual targets

depend: $(DEP)

clean: 
120 121
	@echo "\`\` Cleaning up..."
	@rm -rvf $(PROG) lib$(PROG).a $(OBJ) $(GARBAGE) $(OBJ:.o=.d) 
Alan Mishchenko committed
122 123

tags:
124
	etags `find . -type f -regex '.*\.\(c\|h\)'`
Alan Mishchenko committed
125 126

$(PROG): $(OBJ)
127 128
	@echo "\`\` Building binary:" $(notdir $@)
	@$(LD) -o $@ $^ $(LIBS)
Alan Mishchenko committed
129

Alan Mishchenko committed
130
lib$(PROG).a: $(OBJ)
131 132 133
	@echo "\`\` Linking:" $(notdir $@)
	@ar rv $@ $?
	@ranlib $@
Alan Mishchenko committed
134

Alan Mishchenko committed
135
docs:
136 137
	@echo "\`\` Building documentation." $(notdir $@)
	@doxygen doxygen.conf