summaryrefslogtreecommitdiff
path: root/Makefile
blob: ab67cbc4a6a3ee4e42bc6a31439bc1426e6ca1f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Buttress master makefile

# Requires a compiler with -MD support, currently

# `make' from top level will build in buttress.b
# `make BUILDDIR=foo' from top level will build in directory foo
ifndef REALBUILD
ifndef BUILDDIR
BUILDDIR := build
endif
all:
	@test -d $(BUILDDIR) || mkdir $(BUILDDIR)
	@make -C $(BUILDDIR) -f ../Makefile REALBUILD=yes
clean:
	@test -d $(BUILDDIR) || mkdir $(BUILDDIR)
	@make -C $(BUILDDIR) -f ../Makefile clean REALBUILD=yes
else

# The `real' makefile part.

CFLAGS += -Wall -W

ifdef LOGALLOC
CFLAGS += -DLOGALLOC
endif

ifdef RELEASE
ifndef VERSION
VERSION := $(RELEASE)
endif
else
CFLAGS += -g
endif

ifndef VER
ifdef VERSION
VER := $(VERSION)
endif
endif
ifdef VER
VDEF := -DVERSION=\"$(VER)\"
endif

SRC := ../

MODULES := main malloc ustring error help licence version misc
MODULES += input keywords contents index style biblio

OBJECTS := $(addsuffix .o,$(MODULES))
DEPS := $(addsuffix .d,$(MODULES))

buttress: $(OBJECTS)
	$(CC) $(LFLAGS) -o buttress $(OBJECTS)

%.o: $(SRC)%.c
	$(CC) $(CFLAGS) -MD -c $<

version.o: FORCE
	$(CC) $(VDEF) -MD -c $(SRC)version.c

clean::
	rm -f *.o buttress core

FORCE: # phony target to force version.o to be rebuilt every time

-include $(DEPS)

endif