Makefile 5.96 KB
Newer Older
1

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

Alan Mishchenko committed
6 7 8 9 10
MSG_PREFIX ?=

$(info $(MSG_PREFIX)Using CC=$(CC))
$(info $(MSG_PREFIX)Using CXX=$(CXX))
$(info $(MSG_PREFIX)Using LD=$(LD))
Alan Mishchenko committed
11 12 13

PROG := abc

Alan Mishchenko committed
14
MODULES := \
15
	$(wildcard src/ext*) \
16
	src/base/abc src/base/abci src/base/cmd src/base/io src/base/main src/base/exor \
17
	src/base/ver src/base/wlc src/base/bac src/base/cba src/base/pla src/base/test \
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
	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 \
22
	src/misc/mem src/misc/bar src/misc/bbl src/misc/parse \
23
	src/opt/cut src/opt/fxu src/opt/fxch src/opt/rwr src/opt/mfs src/opt/sim \
24
	src/opt/ret src/opt/fret src/opt/res src/opt/lpk src/opt/nwk src/opt/rwt \
25
	src/opt/cgt src/opt/csw src/opt/dar src/opt/dau src/opt/dsc src/opt/sfm src/opt/sbd \
26
	src/sat/bsat src/sat/xsat src/sat/satoko 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/live src/proof/ssc src/proof/int \
30
	src/proof/cec src/proof/acec src/proof/dch src/proof/fraig src/proof/fra src/proof/ssw \
31
	src/aig/aig src/aig/saig src/aig/gia src/aig/ioa src/aig/ivy src/aig/hop \
32
	src/aig/miniaig
Alan Mishchenko committed
33

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

37 38 39 40
ARCHFLAGS_EXE ?= ./arch_flags

$(ARCHFLAGS_EXE) : arch_flags.c
	$(CC) arch_flags.c -o $(ARCHFLAGS_EXE)
41

42 43
INCLUDES += -Isrc

44
ARCHFLAGS ?= $(shell $(CC) arch_flags.c -o $(ARCHFLAGS_EXE) && $(ARCHFLAGS_EXE))
45 46
ARCHFLAGS := $(ARCHFLAGS)

47
OPTFLAGS  ?= -g -O
Alan Mishchenko committed
48

49
CFLAGS    += -Wall -Wno-unused-function -Wno-write-strings -Wno-sign-compare $(ARCHFLAGS)
50 51 52
ifneq ($(findstring arm,$(shell uname -m)),)
	CFLAGS += -DABC_MEMALIGN=4
endif
53

54 55 56 57 58 59 60 61
# compile ABC using the C++ comipler and put everything in the namespace $(ABC_NAMESPACE)
ifdef ABC_USE_NAMESPACE
  CFLAGS += -DABC_NAMESPACE=$(ABC_USE_NAMESPACE) -fpermissive
  CC := $(CXX)
  $(info $(MSG_PREFIX)Compiling in namespace $(ABC_NAMESPACE))
endif

# compile CUDD with ABC
62
ifndef ABC_USE_NO_CUDD
63 64 65 66 67
  CFLAGS += -DABC_USE_CUDD=1
  MODULES += src/bdd/cudd src/bdd/extrab src/bdd/dsd src/bdd/epd src/bdd/mtr src/bdd/reo src/bdd/cas src/bdd/bbr src/bdd/llb
  $(info $(MSG_PREFIX)Compiling with CUDD)
endif

68 69 70 71 72 73 74 75 76 77
ABC_READLINE_INCLUDES ?=
ABC_READLINE_LIBRARIES ?= -lreadline

# whether to use libreadline
ifndef ABC_USE_NO_READLINE
  CFLAGS += -DABC_USE_READLINE $(ABC_READLINE_INCLUDES)
  LIBS += $(ABC_READLINE_LIBRARIES)
  $(info $(MSG_PREFIX)Using libreadline)
endif

78
# whether to compile with thread support
Alan Mishchenko committed
79
ifndef ABC_USE_NO_PTHREADS
80 81 82 83 84
  CFLAGS += -DABC_USE_PTHREADS
  LIBS += -lpthread
  $(info $(MSG_PREFIX)Using pthreads)
endif

85 86
# whether to compile into position independent code
ifdef ABC_USE_PIC
87
  CFLAGS += -fPIC
88 89 90 91 92 93 94 95 96 97 98
  LIBS += -fPIC
  $(info $(MSG_PREFIX)Compiling position independent code)
endif

# whether to echo commands while building
ifdef ABC_MAKE_VERBOSE
  VERBOSE=
else
  VERBOSE=@
endif

99 100 101 102
# 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)
103

104 105 106 107
GCC_VERSION=$(shell $(CC) -dumpversion)
GCC_MAJOR=$(word 1,$(subst .,$(space),$(GCC_VERSION)))
GCC_MINOR=$(word 2,$(subst .,$(space),$(GCC_VERSION)))

Alan Mishchenko committed
108
$(info $(MSG_PREFIX)Found GCC_VERSION $(GCC_VERSION))
109
ifeq ($(findstring $(GCC_MAJOR),0 1 2 3),)
Alan Mishchenko committed
110
$(info $(MSG_PREFIX)Found GCC_MAJOR>=4)
111
ifeq ($(findstring $(GCC_MINOR),0 1 2 3 4 5),)
Alan Mishchenko committed
112
$(info $(MSG_PREFIX)Found GCC_MINOR>=6)
113
CFLAGS += -Wno-unused-but-set-variable
114 115 116 117
endif
endif

endif
118

119
# LIBS := -ldl -lrt
120
LIBS += -ldl -lm
121 122 123
ifneq ($(findstring Darwin, $(shell uname)), Darwin)
   LIBS += -lrt
endif
Alan Mishchenko committed
124

125

Alan Mishchenko committed
126
$(info $(MSG_PREFIX)Using CFLAGS=$(CFLAGS))
127
CXXFLAGS += $(CFLAGS)
128

129
SRC  :=
130
GARBAGE := core core.* *.stackdump ./tags $(PROG) arch_flags
Alan Mishchenko committed
131

132
.PHONY: all default tags clean docs cmake_info
Alan Mishchenko committed
133 134 135 136 137

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

OBJ := \
	$(patsubst %.cc, %.o, $(filter %.cc, $(SRC))) \
Alan Mishchenko committed
138
	$(patsubst %.cpp, %.o, $(filter %.cpp, $(SRC))) \
Alan Mishchenko committed
139
	$(patsubst %.c, %.o,  $(filter %.c, $(SRC)))  \
140
	$(patsubst %.y, %.o,  $(filter %.y, $(SRC)))
Alan Mishchenko committed
141

142 143
LIBOBJ := $(filter-out src/base/main/main.o,$(OBJ))

Alan Mishchenko committed
144 145 146 147
DEP := $(OBJ:.o=.d)

# implicit rules

148
%.o: %.c
149
	@echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$<
150
	$(VERBOSE)$(CC) -c $(OPTFLAGS) $(INCLUDES) $(CFLAGS) $< -o $@
151 152

%.o: %.cc
153
	@echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$<
154
	$(VERBOSE)$(CXX) -c $(OPTFLAGS) $(INCLUDES) $(CXXFLAGS) $< -o $@
155

156 157
%.o: %.cpp
	@echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$<
158
	$(VERBOSE)$(CXX) -c $(OPTFLAGS) $(INCLUDES) $(CXXFLAGS) $< -o $@
159

Alan Mishchenko committed
160
%.d: %.c
161
	@echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$<
162
	$(VERBOSE)./depends.sh $(CC) `dirname $*.c` $(OPTFLAGS) $(INCLUDES) $(CFLAGS) $*.c > $@
Alan Mishchenko committed
163 164

%.d: %.cc
165
	@echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$<
166
	$(VERBOSE)./depends.sh $(CXX) `dirname $*.cc` $(OPTFLAGS) $(INCLUDES) $(CXXFLAGS) $*.cc > $@
Alan Mishchenko committed
167

168 169
%.d: %.cpp
	@echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$<
170
	$(VERBOSE)./depends.sh $(CXX) `dirname $*.cpp` $(OPTFLAGS) $(INCLUDES) $(CXXFLAGS) $*.cpp > $@
171

172
ifndef ABC_MAKE_NO_DEPS
Alan Mishchenko committed
173
-include $(DEP)
174
endif
Alan Mishchenko committed
175 176 177 178 179

# Actual targets

depend: $(DEP)

180
clean:
181
	@echo "$(MSG_PREFIX)\`\` Cleaning up..."
182
	$(VERBOSE)rm -rvf $(PROG) lib$(PROG).a $(OBJ) $(GARBAGE) $(OBJ:.o=.d)
Alan Mishchenko committed
183 184

tags:
185
	etags `find . -type f -regex '.*\.\(c\|h\)'`
Alan Mishchenko committed
186 187

$(PROG): $(OBJ)
188
	@echo "$(MSG_PREFIX)\`\` Building binary:" $(notdir $@)
189
	$(VERBOSE)$(LD) -o $@ $^ $(LIBS)
Alan Mishchenko committed
190

191
lib$(PROG).a: $(LIBOBJ)
192
	@echo "$(MSG_PREFIX)\`\` Linking:" $(notdir $@)
193 194
	$(VERBOSE)ar rv $@ $?
	$(VERBOSE)ranlib $@
Alan Mishchenko committed
195

196 197 198 199
lib$(PROG).so: $(LIBOBJ)
	@echo "$(MSG_PREFIX)\`\` Linking:" $(notdir $@)
	$(VERBOSE)$(CXX) -shared -o $@ $^ $(LIBS)

Alan Mishchenko committed
200
docs:
201
	@echo "$(MSG_PREFIX)\`\` Building documentation." $(notdir $@)
202
	$(VERBOSE)doxygen doxygen.conf
203 204 205

cmake_info:
	@echo SEPARATOR_CFLAGS $(CFLAGS) SEPARATOR_CFLAGS
206
	@echo SEPARATOR_CXXFLAGS $(CXXFLAGS) SEPARATOR_CXXFLAGS
207 208
	@echo SEPARATOR_LIBS $(LIBS) SEPARATOR_LIBS
	@echo SEPARATOR_SRC $(SRC) SEPARATOR_SRC