rosettacode-c/Makefile

32 lines
913 B
Makefile
Raw Normal View History

2016-05-15 20:56:38 +00:00
2016-05-18 07:29:03 +00:00
SRC = $(wildcard src/*.c)
DEPS = $(wildcard deps/**/*.c)
LIBS = $(wildcard lib/**/*.c)
OBJS = $(patsubst %.c,%.o,$(DEPS) $(LIBS))
BINS = $(patsubst src/%,bin/%,$(patsubst %.c,%,$(SRC)))
TEST_SRC = $(wildcard test/*.c)
TEST_BINS = $(patsubst test/%,bin/%,$(patsubst %.c,%.test,$(TEST_SRC)))
2016-05-15 20:56:38 +00:00
2016-05-15 23:51:37 +00:00
# CFLAGS = -std=c99 -Ideps -Wall -Wno-unused-function -U__STRICT_ANSI__
CFLAGS = -ggdb -std=c99 -Ideps -Ilib -Wall -Wno-unused-function -pedantic -D_POSIX_C_SOURCE=200112L
2016-05-15 20:56:38 +00:00
2016-05-18 07:29:03 +00:00
all: $(BINS) $(TEST_BINS)
2016-05-15 23:51:37 +00:00
echo "BINS=$(BINS)"
2016-05-18 07:29:03 +00:00
echo "TESTS=$(TEST_BINS)"
2016-05-15 20:56:38 +00:00
$(BINS): $(SRC) $(OBJS)
2016-05-15 23:53:40 +00:00
$(CC) $(CFLAGS) -o $@ src/$(notdir $@).c $(OBJS) $(LDFLAGS)
2016-05-15 20:56:38 +00:00
2016-05-18 07:29:03 +00:00
$(TEST_BINS): $(TEST_SRC) $(OBJS)
$(CC) $(CFLAGS) -o $@ test/$(notdir $(patsubst %.test,%.c,$@)) $(OBJS) $(LDFLAGS)
2016-05-15 20:56:38 +00:00
%.o: %.c
$(CC) $< -c -o $@ $(CFLAGS)
clean:
2016-05-15 23:51:37 +00:00
$(foreach c, $(BINS), rm -f $(c);)
2016-05-18 07:29:03 +00:00
$(foreach c, $(TEST_BINS), rm -f $(c);)
2016-05-15 23:51:37 +00:00
rm -f $(OBJS)