Makefile 4.26 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 17
	src/base/abc src/base/abci src/base/cmd src/base/io src/base/main \
	src/base/ver src/base/wlc src/base/cba src/base/pla src/base/test \
18 19
	src/bdd/cudd src/bdd/dsd src/bdd/epd src/bdd/mtr src/bdd/parse \
	src/bdd/reo src/bdd/cas \
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 24 25 26
	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
27
	src/opt/cgt src/opt/csw src/opt/dar src/opt/dau src/opt/sfm \
28
	src/sat/bsat src/sat/csat src/sat/msat src/sat/psat src/sat/cnf src/sat/bmc \
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/bbr src/proof/llb src/proof/live \
32
	src/proof/cec src/proof/dch src/proof/fraig src/proof/fra src/proof/ssw \
33
	src/proof/ssc src/proof/int \
34
	src/aig/aig src/aig/saig src/aig/gia src/aig/ioa src/aig/ivy src/aig/hop \
35
	src/aig/miniaig \
36
	src/python 
Alan Mishchenko committed
37

38
all: $(PROG)
Alan Mishchenko committed
39
default: $(PROG)
Alan Mishchenko committed
40

41
arch_flags : arch_flags.c
42
	$(CC) arch_flags.c -o arch_flags
43

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

47
OPTFLAGS  ?= -g -O #-DABC_NAMESPACE=xxx
Alan Mishchenko committed
48

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

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

59 60 61 62
GCC_VERSION=$(shell $(CC) -dumpversion)
GCC_MAJOR=$(word 1,$(subst .,$(space),$(GCC_VERSION)))
GCC_MINOR=$(word 2,$(subst .,$(space),$(GCC_VERSION)))

Alan Mishchenko committed
63
$(info $(MSG_PREFIX)Found GCC_VERSION $(GCC_VERSION))
64
ifeq ($(findstring $(GCC_MAJOR),0 1 2 3),)
Alan Mishchenko committed
65
$(info $(MSG_PREFIX)Found GCC_MAJOR>=4)
66
ifeq ($(findstring $(GCC_MINOR),0 1 2 3 4 5),)
Alan Mishchenko committed
67
$(info $(MSG_PREFIX)Found GCC_MINOR>=6)
68
CFLAGS += -Wno-unused-but-set-variable
69 70 71 72
endif
endif

endif
73

74
# LIBS := -ldl -lrt
75
LIBS += -ldl -lm
76 77 78
ifneq ($(findstring Darwin, $(shell uname)), Darwin)
   LIBS += -lrt
endif
Alan Mishchenko committed
79

80 81 82 83 84 85 86 87 88 89
ifneq ($(READLINE),0)
CFLAGS += -DABC_USE_READLINE
LIBS += -lreadline
endif

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

Alan Mishchenko committed
90
$(info $(MSG_PREFIX)Using CFLAGS=$(CFLAGS))
91
CXXFLAGS += $(CFLAGS) 
92

Alan Mishchenko committed
93
SRC  := 
94
GARBAGE := core core.* *.stackdump ./tags $(PROG) arch_flags
Alan Mishchenko committed
95

96
.PHONY: all default tags clean docs
Alan Mishchenko committed
97 98 99 100 101

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

OBJ := \
	$(patsubst %.cc, %.o, $(filter %.cc, $(SRC))) \
Alan Mishchenko committed
102
	$(patsubst %.cpp, %.o, $(filter %.cpp, $(SRC))) \
Alan Mishchenko committed
103 104 105 106 107 108 109
	$(patsubst %.c, %.o,  $(filter %.c, $(SRC)))  \
	$(patsubst %.y, %.o,  $(filter %.y, $(SRC))) 

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

# implicit rules

110
%.o: %.c
111
	@echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$<
112 113 114
	@$(CC) -c $(CFLAGS) $< -o $@

%.o: %.cc
115
	@echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$<
116
	@$(CXX) -c $(CXXFLAGS) $< -o $@
117

118 119 120 121
%.o: %.cpp
	@echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$<
	@$(CXX) -c $(CXXFLAGS) $< -o $@

Alan Mishchenko committed
122
%.d: %.c
123
	@echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$<
124
	@./depends.sh $(CC) `dirname $*.c` $(CFLAGS) $*.c > $@
Alan Mishchenko committed
125 126

%.d: %.cc
127
	@echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$<
128
	@./depends.sh $(CXX) `dirname $*.cc` $(CXXFLAGS) $*.cc > $@
Alan Mishchenko committed
129

130 131 132 133
%.d: %.cpp
	@echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$<
	@./depends.sh $(CXX) `dirname $*.cpp` $(CXXFLAGS) $*.cpp > $@

Alan Mishchenko committed
134 135 136 137 138 139 140
-include $(DEP)

# Actual targets

depend: $(DEP)

clean: 
141
	@echo "$(MSG_PREFIX)\`\` Cleaning up..."
142
	@rm -rvf $(PROG) lib$(PROG).a $(OBJ) $(GARBAGE) $(OBJ:.o=.d) 
Alan Mishchenko committed
143 144

tags:
145
	etags `find . -type f -regex '.*\.\(c\|h\)'`
Alan Mishchenko committed
146 147

$(PROG): $(OBJ)
148
	@echo "$(MSG_PREFIX)\`\` Building binary:" $(notdir $@)
149
	@$(LD) -o $@ $^ $(LIBS)
Alan Mishchenko committed
150

Alan Mishchenko committed
151
lib$(PROG).a: $(OBJ)
152
	@echo "$(MSG_PREFIX)\`\` Linking:" $(notdir $@)
153 154
	@ar rv $@ $?
	@ranlib $@
Alan Mishchenko committed
155

Alan Mishchenko committed
156
docs:
157
	@echo "$(MSG_PREFIX)\`\` Building documentation." $(notdir $@)
158
	@doxygen doxygen.conf