Makefile 4.14 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 \
17
	src/base/main src/base/ver src/base/wlc src/base/cba 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
ARCHFLAGS ?= $(shell $(CC) arch_flags.c -o arch_flags && ./arch_flags)
45
OPTFLAGS  ?= -g -O #-DABC_NAMESPACE=xxx
Alan Mishchenko committed
46

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

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

54 55 56 57
GCC_VERSION=$(shell $(CC) -dumpversion)
GCC_MAJOR=$(word 1,$(subst .,$(space),$(GCC_VERSION)))
GCC_MINOR=$(word 2,$(subst .,$(space),$(GCC_VERSION)))

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

endif
68

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

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

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

Alan Mishchenko committed
85
$(info $(MSG_PREFIX)Using CFLAGS=$(CFLAGS))
86
CXXFLAGS += $(CFLAGS) 
87

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

91
.PHONY: all default tags clean docs
Alan Mishchenko committed
92 93 94 95 96

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

OBJ := \
	$(patsubst %.cc, %.o, $(filter %.cc, $(SRC))) \
Alan Mishchenko committed
97
	$(patsubst %.cpp, %.o, $(filter %.cpp, $(SRC))) \
Alan Mishchenko committed
98 99 100 101 102 103 104
	$(patsubst %.c, %.o,  $(filter %.c, $(SRC)))  \
	$(patsubst %.y, %.o,  $(filter %.y, $(SRC))) 

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

# implicit rules

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

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

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

Alan Mishchenko committed
117
%.d: %.c
118
	@echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$<
119
	@./depends.sh $(CC) `dirname $*.c` $(CFLAGS) $*.c > $@
Alan Mishchenko committed
120 121

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

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

Alan Mishchenko committed
129 130 131 132 133 134 135
-include $(DEP)

# Actual targets

depend: $(DEP)

clean: 
136
	@echo "$(MSG_PREFIX)\`\` Cleaning up..."
137
	@rm -rvf $(PROG) lib$(PROG).a $(OBJ) $(GARBAGE) $(OBJ:.o=.d) 
Alan Mishchenko committed
138 139

tags:
140
	etags `find . -type f -regex '.*\.\(c\|h\)'`
Alan Mishchenko committed
141 142

$(PROG): $(OBJ)
143
	@echo "$(MSG_PREFIX)\`\` Building binary:" $(notdir $@)
144
	@$(LD) -o $@ $^ $(LIBS)
Alan Mishchenko committed
145

Alan Mishchenko committed
146
lib$(PROG).a: $(OBJ)
147
	@echo "$(MSG_PREFIX)\`\` Linking:" $(notdir $@)
148 149
	@ar rv $@ $?
	@ranlib $@
Alan Mishchenko committed
150

Alan Mishchenko committed
151
docs:
152
	@echo "$(MSG_PREFIX)\`\` Building documentation." $(notdir $@)
153
	@doxygen doxygen.conf