-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
32 lines (27 loc) · 866 Bytes
/
Makefile
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
LIBS=$(wildcard libs/*)
INCLUDE_PATH=libs/
CC = gcc
CFLAGS := -g -std=gnu99 -Wall -pedantic
SQLFLAGS := $(shell mysql_config --cflags)
SQLLIBS := $(shell mysql_config --libs)
all: tests mains clean
mains: src/*.[ch]
for main in $(wildcard src/*.c); do\
exec=`echo $$main | cut -d"." -f1`;\
$(CC) $(CFLAGS) $(SQLFLAGS) $$main $(wildcard libraries/*) -I$(INCLUDE_PATH) $(SQLLIBS) -lfcgi -lpthread -lm -o $$exec.out; \
done;
tests: libraries tests/*.c
for test in $(wildcard tests/*.c); do\
exec=`echo $$test | cut -d"." -f1`;\
$(CC) $(CFLAGS) $(SQLFLAGS) $$test $(wildcard libraries/*) -I$(INCLUDE_PATH) -o $$exec.out $(SQLLIBS);\
done;
libraries:
mkdir libraries/
for dir in $(LIBS); do \
cd $$dir; \
$(CC) $(CFLAGS) $(SQLFLAGS) -I../ -c *.c ; \
mv *.o ../../libraries; \
cd -; \
done;
clean:
rm -rf libraries/