Makefile 6.56 KB
Newer Older
1

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

Alan Mishchenko committed
6
MSG_PREFIX ?=
7
ABCSRC = .
Alan Mishchenko committed
8 9 10 11

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

PROG := abc
14
OS := $(shell uname -s)
Alan Mishchenko committed
15

Alan Mishchenko committed
16
MODULES := \
17
	$(wildcard src/ext*) \
18
	src/base/abc src/base/abci src/base/cmd src/base/io src/base/main src/base/exor \
19
	src/base/ver src/base/wlc src/base/wln src/base/acb src/base/bac src/base/cba src/base/pla src/base/test \
20
	src/map/mapper src/map/mio src/map/super src/map/if \
Alan Mishchenko committed
21
	src/map/amap src/map/cov src/map/scl src/map/mpm \
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 \
24
	src/misc/mem src/misc/bar src/misc/bbl src/misc/parse \
25
	src/opt/cut src/opt/fxu src/opt/fxch src/opt/rwr src/opt/mfs src/opt/sim \
26
	src/opt/ret src/opt/fret src/opt/res src/opt/lpk src/opt/nwk src/opt/rwt \
27
	src/opt/cgt src/opt/csw src/opt/dar src/opt/dau src/opt/dsc src/opt/sfm src/opt/sbd \
28
	src/sat/bsat src/sat/xsat src/sat/satoko src/sat/csat src/sat/msat src/sat/psat src/sat/cnf src/sat/bmc src/sat/glucose \
29 30
	src/bool/bdc src/bool/deco src/bool/dec src/bool/kit src/bool/lucky \
	src/bool/rsb src/bool/rpo \
31
	src/proof/pdr src/proof/abs src/proof/live src/proof/ssc src/proof/int \
32
	src/proof/cec src/proof/acec src/proof/dch src/proof/fraig src/proof/fra src/proof/ssw \
33
	src/aig/aig src/aig/saig src/aig/gia src/aig/ioa src/aig/ivy src/aig/hop \
34
	src/aig/miniaig
Alan Mishchenko committed
35

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

39 40 41 42
ARCHFLAGS_EXE ?= ./arch_flags

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

44
INCLUDES += -I$(ABCSRC)/src
45

46 47 48 49 50 51 52
# Use C99 stdint.h header for platform-dependent types
ifdef ABC_USE_STDINT_H
    ARCHFLAGS ?= -DABC_USE_STDINT_H=1
else
    ARCHFLAGS ?= $(shell $(CC) $(ABCSRC)/arch_flags.c -o $(ARCHFLAGS_EXE) && $(ARCHFLAGS_EXE))
endif

53 54
ARCHFLAGS := $(ARCHFLAGS)

55
OPTFLAGS  ?= -g -O
Alan Mishchenko committed
56

57
CFLAGS    += -Wall -Wno-unused-function -Wno-write-strings -Wno-sign-compare $(ARCHFLAGS)
58 59 60
ifneq ($(findstring arm,$(shell uname -m)),)
	CFLAGS += -DABC_MEMALIGN=4
endif
61

62 63 64 65 66 67 68 69
# 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
70
ifndef ABC_USE_NO_CUDD
71 72 73 74 75
  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

76 77 78 79 80 81 82
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)
83 84 85 86
  ifeq ($(OS), FreeBSD)
    CFLAGS += -I/usr/local/include
    LDFLAGS += -L/usr/local/lib
  endif
87 88 89
  $(info $(MSG_PREFIX)Using libreadline)
endif

90
# whether to compile with thread support
Alan Mishchenko committed
91
ifndef ABC_USE_NO_PTHREADS
92 93 94 95 96
  CFLAGS += -DABC_USE_PTHREADS
  LIBS += -lpthread
  $(info $(MSG_PREFIX)Using pthreads)
endif

97 98
# whether to compile into position independent code
ifdef ABC_USE_PIC
99
  CFLAGS += -fPIC
100 101 102 103 104 105 106 107 108 109 110
  LIBS += -fPIC
  $(info $(MSG_PREFIX)Compiling position independent code)
endif

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

111 112 113 114
# 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)
115

116 117 118 119
GCC_VERSION=$(shell $(CC) -dumpversion)
GCC_MAJOR=$(word 1,$(subst .,$(space),$(GCC_VERSION)))
GCC_MINOR=$(word 2,$(subst .,$(space),$(GCC_VERSION)))

Alan Mishchenko committed
120
$(info $(MSG_PREFIX)Found GCC_VERSION $(GCC_VERSION))
121
ifeq ($(findstring $(GCC_MAJOR),0 1 2 3),)
122 123
ifeq ($(GCC_MAJOR),4)
$(info $(MSG_PREFIX)Found GCC_MAJOR==4)
124
ifeq ($(findstring $(GCC_MINOR),0 1 2 3 4 5),)
Alan Mishchenko committed
125
$(info $(MSG_PREFIX)Found GCC_MINOR>=6)
126
CFLAGS += -Wno-unused-but-set-variable
127
endif
128 129 130 131
else
$(info $(MSG_PREFIX)Found GCC_MAJOR>=5)
CFLAGS += -Wno-unused-but-set-variable
endif
132 133 134
endif

endif
135

136
# LIBS := -ldl -lrt
137 138 139 140 141
LIBS += -lm
ifneq ($(OS), FreeBSD)
  LIBS += -ldl
endif

142 143 144
ifneq ($(findstring Darwin, $(shell uname)), Darwin)
   LIBS += -lrt
endif
Alan Mishchenko committed
145

146 147 148 149
ifdef ABC_USE_LIBSTDCXX
   LIBS += -lstdc++
   $(info $(MSG_PREFIX)Using explicit -lstdc++)
endif
150

Alan Mishchenko committed
151
$(info $(MSG_PREFIX)Using CFLAGS=$(CFLAGS))
152
CXXFLAGS += $(CFLAGS)
153

154
SRC  :=
155
GARBAGE := core core.* *.stackdump ./tags $(PROG) arch_flags
Alan Mishchenko committed
156

157
.PHONY: all default tags clean docs cmake_info
Alan Mishchenko committed
158

159
include $(patsubst %, $(ABCSRC)/%/module.make, $(MODULES))
Alan Mishchenko committed
160 161 162

OBJ := \
	$(patsubst %.cc, %.o, $(filter %.cc, $(SRC))) \
Alan Mishchenko committed
163
	$(patsubst %.cpp, %.o, $(filter %.cpp, $(SRC))) \
Alan Mishchenko committed
164
	$(patsubst %.c, %.o,  $(filter %.c, $(SRC)))  \
165
	$(patsubst %.y, %.o,  $(filter %.y, $(SRC)))
Alan Mishchenko committed
166

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

Alan Mishchenko committed
169 170 171 172
DEP := $(OBJ:.o=.d)

# implicit rules

173
%.o: %.c
174
	@echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$<
175
	$(VERBOSE)$(CC) -c $(OPTFLAGS) $(INCLUDES) $(CFLAGS) $< -o $@
176 177

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

181 182
%.o: %.cpp
	@echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$<
183
	$(VERBOSE)$(CXX) -c $(OPTFLAGS) $(INCLUDES) $(CXXFLAGS) $< -o $@
184

Alan Mishchenko committed
185
%.d: %.c
186
	@echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$<
187
	$(VERBOSE)$(ABCSRC)/depends.sh $(CC) `dirname $*.c` $(OPTFLAGS) $(INCLUDES) $(CFLAGS) $< > $@
Alan Mishchenko committed
188 189

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

193 194
%.d: %.cpp
	@echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$<
195
	$(VERBOSE)$(ABCSRC)/depends.sh $(CXX) `dirname $*.cpp` $(OPTFLAGS) $(INCLUDES) $(CXXFLAGS) $< > $@
196

197
ifndef ABC_MAKE_NO_DEPS
Alan Mishchenko committed
198
-include $(DEP)
199
endif
Alan Mishchenko committed
200 201 202 203 204

# Actual targets

depend: $(DEP)

205
clean:
206
	@echo "$(MSG_PREFIX)\`\` Cleaning up..."
207
	$(VERBOSE)rm -rvf $(PROG) lib$(PROG).a $(OBJ) $(GARBAGE) $(OBJ:.o=.d)
Alan Mishchenko committed
208 209

tags:
210
	etags `find . -type f -regex '.*\.\(c\|h\)'`
Alan Mishchenko committed
211 212

$(PROG): $(OBJ)
213
	@echo "$(MSG_PREFIX)\`\` Building binary:" $(notdir $@)
214
	$(VERBOSE)$(LD) -o $@ $^ $(LDFLAGS) $(LIBS)
Alan Mishchenko committed
215

216
lib$(PROG).a: $(LIBOBJ)
217
	@echo "$(MSG_PREFIX)\`\` Linking:" $(notdir $@)
218 219
	$(VERBOSE)ar rv $@ $?
	$(VERBOSE)ranlib $@
Alan Mishchenko committed
220

221 222 223 224
lib$(PROG).so: $(LIBOBJ)
	@echo "$(MSG_PREFIX)\`\` Linking:" $(notdir $@)
	$(VERBOSE)$(CXX) -shared -o $@ $^ $(LIBS)

Alan Mishchenko committed
225
docs:
226
	@echo "$(MSG_PREFIX)\`\` Building documentation." $(notdir $@)
227
	$(VERBOSE)doxygen doxygen.conf
228 229 230

cmake_info:
	@echo SEPARATOR_CFLAGS $(CFLAGS) SEPARATOR_CFLAGS
231
	@echo SEPARATOR_CXXFLAGS $(CXXFLAGS) SEPARATOR_CXXFLAGS
232 233
	@echo SEPARATOR_LIBS $(LIBS) SEPARATOR_LIBS
	@echo SEPARATOR_SRC $(SRC) SEPARATOR_SRC