Makefile 4.3 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 \
17
	src/base/ver src/base/wlc src/base/bac src/base/cba src/base/pla src/base/test \
18 19
	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 \
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 26
	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/live src/proof/ssc src/proof/int \
32 33
	src/proof/cec src/proof/dch src/proof/fraig src/proof/fra src/proof/ssw \
	src/aig/aig src/aig/saig src/aig/gia src/aig/ioa src/aig/ivy src/aig/hop \
34
	src/aig/miniaig \
35
	src/python 
Alan Mishchenko committed
36

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

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

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

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

48 49 50 51
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
52 53 54 55 56

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

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

endif
72

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

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

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

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

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

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

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

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

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

# implicit rules

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

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

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

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

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

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

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

# Actual targets

depend: $(DEP)

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

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

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

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

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