xref: /libCEED/Makefile (revision bae895488eeeeb46dc9597542d9bc07686d3d353)
1CFLAGS = -std=c99 -Wall -Wextra -Wno-unused-parameter -fPIC -MMD -MP
2CFLAGS += $(if $(NDEBUG),-O2,-g)
3CPPFLAGS = -I.
4LDLIBS = -lm
5
6DARWIN := $(filter Darwin,$(shell uname -s))
7SO_EXT := $(if $(DARWIN),dylib,so)
8
9libceed := libceed.$(SO_EXT)
10libceed.c := $(wildcard ceed*.c)
11tests.c   := $(sort $(wildcard t[0-9][0-9]-*.c))
12tests     := $(tests.c:%.c=%)
13
14.SUFFIXES:
15.SUFFIXES: .c .o .d
16
17$(libceed) : $(libceed.c:%.c=%.o)
18	$(CC) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS)
19
20$(tests) : $(libceed)
21$(tests) : LDFLAGS += -Wl,-rpath,. -L.
22t% : t%.c $(libceed)
23
24run-t% : t%
25	@./tap.sh $<
26
27test : $(tests:%=run-%)
28
29.PHONY: clean print
30clean :
31	$(RM) *.o *.d $(libceed) $(tests.c:%.c=%)
32	$(RM) -r *.dSYM
33
34print :
35	@echo $(VAR)=$($(VAR))
36
37print-%:
38	$(info [ variable name]: $*)
39	$(info [        origin]: $(origin $*))
40	$(info [         value]: $(value $*))
41	$(info [expanded value]: $($*))
42	$(info )
43	@true
44
45-include $(libceed.c:%.c=%.d) $(tests.c:%.c=%.d)
46