aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 2b4168df4a758634f0d6025a0de5a4161b0176fa (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
CFLAGS=-O2 -Wall -Wextra -Wvla --std=c99

CC=gcc
AR=ar

PROG=   oving1 oving2


LIB_OBJS=stack.o queue.o llist.o io.o misc.o sort.o heap.o
LIB_FILE=libalgdat.a
LIB_H=structure.h misc.h io.h sort.h
LIBS = $(LIB_FILE)

LIB_PATH=/usr/local/lib
LIB_H_PATH=/usr/local/include/algdat

all: $(PROG)
debug: CFLAGS += -O0 -g
debug: clean all
lib: $(LIB_FILE)

$(LIB_FILE): $(LIB_OBJS)
	@echo \ [AR] $@
	@$(AR) rcs $@ $(LIB_OBJS)

%: %.c $(LIB_FILE)
	@echo \ [CC] $@
	@$(CC) $(CFLAGS) -o $@ $(filter %.c,$^) $(LIBS)

%.o: %.c $(LIB_H)
	@echo \ [CC] $@
	@$(CC) $(CFLAGS) -o $@ -c $<

.PHONY:
	clean install uninstall reinstall

install: lib
	cp $(LIB_FILE) $(LIB_PATH)
	mkdir -p $(LIB_H_PATH)
	cp $(LIB_H) $(LIB_H_PATH)

uninstall:
	rm -rf $(LIB_H_PATH)
	rm -f $(LIB_PATH)/$(LIB_FILE)

reinstall: uninstall install

clean:
	rm -rf *.o $(PROG) $(LIB_FILE) *.dSYM test a.out

backup: clean
	cd .. ; tar czvf algdat.tar.gz algdat