Makefile 3.74 KB
Newer Older
1

2
CC   := gcc
3
CXX  := g++
4 5 6 7 8
LD   := $(CXX)

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

PROG := abc

Alan Mishchenko committed
12
MODULES := \
13
	$(wildcard src/ext) src/misc/ext \
14 15 16 17
	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 \
18
	src/map/mapper src/map/mio src/map/super src/map/if \
Alan Mishchenko committed
19
	src/map/amap src/map/cov src/map/scl src/map/mpm \
20 21 22 23 24
	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
25
	src/opt/cgt src/opt/csw src/opt/dar src/opt/dau src/opt/sfm \
26
	src/sat/bsat src/sat/csat src/sat/msat src/sat/psat src/sat/cnf src/sat/bmc \
27 28
	src/bool/bdc src/bool/deco src/bool/dec src/bool/kit src/bool/lucky \
	src/bool/rsb src/bool/rpo \
29
	src/proof/pdr src/proof/abs src/proof/bbr src/proof/llb src/proof/live \
30
	src/proof/cec src/proof/dch src/proof/fraig src/proof/fra src/proof/ssw \
31
	src/proof/ssc src/proof/int \
32
	src/aig/aig src/aig/saig src/aig/gia src/aig/ioa src/aig/ivy src/aig/hop \
33
	src/aig/miniaig \
34
	src/python 
Alan Mishchenko committed
35

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

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

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

46
CFLAGS   += -Wall -Wno-unused-function -Wno-write-strings -Wno-sign-compare $(OPTFLAGS) $(ARCHFLAGS) -Isrc
47 48 49 50 51

# 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)
52

53 54 55 56 57 58 59 60 61
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)
62
CFLAGS += -Wno-unused-but-set-variable
63 64 65 66
endif
endif

endif
67

68 69 70 71 72
# LIBS := -ldl -lrt
LIBS := -ldl
ifneq ($(findstring Darwin, $(shell uname)), Darwin)
   LIBS += -lrt
endif
Alan Mishchenko committed
73

74 75 76 77 78 79 80 81 82 83
ifneq ($(READLINE),0)
CFLAGS += -DABC_USE_READLINE
LIBS += -lreadline
endif

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

84
$(info Using CFLAGS=$(CFLAGS))
85
CXXFLAGS += $(CFLAGS) 
86

Alan Mishchenko committed
87
SRC  := 
88
GARBAGE := core core.* *.stackdump ./tags $(PROG) arch_flags
Alan Mishchenko committed
89

90
.PHONY: all default tags clean docs
Alan Mishchenko committed
91 92 93 94 95 96 97 98 99 100 101 102

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

103
%.o: %.c
104
	@echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$<
105 106 107
	@$(CC) -c $(CFLAGS) $< -o $@

%.o: %.cc
108
	@echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$<
109
	@$(CXX) -c $(CXXFLAGS) $< -o $@
110

Alan Mishchenko committed
111
%.d: %.c
112
	@echo "$(MSG_PREFIX)\`\` Dependency:" $(LOCAL_PATH)/$<
113
	@./depends.sh $(CC) `dirname $*.c` $(CFLAGS) $*.c > $@
Alan Mishchenko committed
114 115

%.d: %.cc
116
	@echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$<
117
	@./depends.sh $(CXX) `dirname $*.cc` $(CXXFLAGS) $*.cc > $@
Alan Mishchenko committed
118 119 120 121 122 123 124 125

-include $(DEP)

# Actual targets

depend: $(DEP)

clean: 
126
	@echo "$(MSG_PREFIX)\`\` Cleaning up..."
127
	@rm -rvf $(PROG) lib$(PROG).a $(OBJ) $(GARBAGE) $(OBJ:.o=.d) 
Alan Mishchenko committed
128 129

tags:
130
	etags `find . -type f -regex '.*\.\(c\|h\)'`
Alan Mishchenko committed
131 132

$(PROG): $(OBJ)
133
	@echo "$(MSG_PREFIX)\`\` Building binary:" $(notdir $@)
Jiang Long committed
134
	$(LD) -o $@ $^ $(LIBS)
Alan Mishchenko committed
135

Alan Mishchenko committed
136
lib$(PROG).a: $(OBJ)
137
	@echo "$(MSG_PREFIX)\`\` Linking:" $(notdir $@)
138 139
	@ar rv $@ $?
	@ranlib $@
Alan Mishchenko committed
140

Alan Mishchenko committed
141
docs:
142
	@echo "$(MSG_PREFIX)\`\` Building documentation." $(notdir $@)
143
	@doxygen doxygen.conf