1##
2##  Makefile for Standard, Profile, Debug, Release, and Release-static versions of MiniSat
3##
4##    eg: "make rs" for a statically linked release version.
5##        "make d"  for a debug version (no optimizations).
6##        "make"    for the standard version (optimized, but with debug information and assertions active)
7
8CSRCS     = $(wildcard *.C)
9CHDRS     = $(wildcard *.h)
10COBJS     = $(addsuffix .o, $(basename $(CSRCS)))
11
12PCOBJS    = $(addsuffix p,  $(COBJS))
13DCOBJS    = $(addsuffix d,  $(COBJS))
14RCOBJS    = $(addsuffix r,  $(COBJS))
15
16EXEC      = minisat
17
18CXX       = g++
19CFLAGS    = -Wall -ffloat-store -fno-strict-aliasing
20COPTIMIZE = -O3
21
22
23.PHONY : s p d r build clean depend
24
25r:	WAY=release
26s:	WAY=standard
27p:	WAY=profile
28d:	WAY=debug
29rs:	WAY=release static
30
31r:	CFLAGS+=$(COPTIMIZE) -D NDEBUG
32s:	CFLAGS+=$(COPTIMIZE) -ggdb -D DEBUG
33p:	CFLAGS+=$(COPTIMIZE) -pg -ggdb -D DEBUG
34d:	CFLAGS+=-O0 -ggdb -D DEBUG
35rs:	CFLAGS+=$(COPTIMIZE) -D NDEBUG
36
37r:	build $(EXEC)
38s:	build $(EXEC)_standard
39p:	build $(EXEC)_profile
40d:	build $(EXEC)_debug
41rs:	build $(EXEC)_static
42
43build:
44	@echo Building $(EXEC) "("$(WAY)")"
45
46clean:
47	@rm -f $(EXEC)_standard $(EXEC)_profile $(EXEC)_debug $(EXEC) $(EXEC)_static \
48	  $(COBJS) $(PCOBJS) $(DCOBJS) $(RCOBJS) depend.mak
49
50## Build rule
51%.o %.op %.od %.or:	%.C
52	@echo Compiling: $<
53	@$(CXX) $(CFLAGS) -c -o $@ $<
54
55## Linking rules (standard/profile/debug/release)
56$(EXEC): $(COBJS)
57	@echo Linking $(EXEC)
58	@$(CXX) $(COBJS)  -ggdb -Wall -o $@ 
59
60$(EXEC)_profile: $(PCOBJS)
61	@echo Linking $@
62	@$(CXX) $(PCOBJS) -ggdb -Wall -pg -o $@
63
64$(EXEC)_debug:	$(DCOBJS)
65	@echo Linking $@
66	@$(CXX) $(DCOBJS) -ggdb -Wall -o $@
67
68$(EXEC)_release: $(RCOBJS)
69	@echo Linking $@
70	@$(CXX) $(RCOBJS)  -Wall -o $@
71
72$(EXEC)_static: $(RCOBJS)
73	@echo Linking $@
74	@$(CXX) --static $(RCOBJS)  -Wall -o $@
75
76
77## Make dependencies
78depend:	depend.mak
79depend.mak: $(CSRCS) $(CHDRS)
80	@echo Making dependencies ...
81	@$(CXX) -MM $(CSRCS) > depend.mak
82	@cp depend.mak /tmp/depend.mak.tmp
83	@sed "s/o:/op:/" /tmp/depend.mak.tmp >> depend.mak
84	@sed "s/o:/od:/" /tmp/depend.mak.tmp >> depend.mak
85	@sed "s/o:/or:/" /tmp/depend.mak.tmp >> depend.mak
86	@rm /tmp/depend.mak.tmp
87
88include depend.mak
89