summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: d8858a4718090b620ab238fa2460c0eb5942490f (plain) (blame)
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
TARGET:=libts3db_postgres.so
TOP:=.

#32BIT=-m32
#DEBUG=-g

headers:=$(wildcard ${TOP}/*.h)
sources:=$(wildcard ${TOP}/*.c)
deps:=$(sources:.c=.d)
objects:=$(sources:.c=.o)

CFLAGS=-fPIC $(32BIT) $(DEBUG) -std=c99
CFLAGS+=-I$(shell pg_config --includedir)
LDFLAGS=-shared -Wl,-soname,$(TARGET) $(32BIT) -lpq -liniparser

##############################################################################

.PHONY:	all clean

all:	$(TARGET)

clean:
	-$(RM) -r $(TARGET) $(objects) $(deps)

ifneq ($(MAKECMDGOALS),clean)
-include $(deps)
endif

##############################################################################
# normal build

$(TARGET):	$(objects) $(deps)
	$(CC) $(LDFLAGS) -o $(TARGET) $(objects)

%.o:		%.c
	$(CC) $(CFLAGS) -MMD -c $< -o $@

%.d:		%.c
	$(CC) $(CFLAGS) -MM -c $< -MF $@