-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
59 lines (46 loc) · 1.24 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
LIBA := libpluto.a
CC = gcc
CPPC = g++
LIBSRCDIR = src
INSTDIR = /usr/lib
EXDIR := examples
LIBSRCS := $(wildcard src/*.c)
#EXSRCS := $(shell find $(EXDIR) -name '*.c' -o -name '*.cpp')
EXSRCS := $(wildcard examples/*.c)
EXSRCS += $(wildcard examples/*.cpp)
LIBOBJS := $(addsuffix .o, $(basename $(LIBSRCS)))
EXBINS := $(addsuffix .e, $(basename $(EXSRCS)))
CFLAGS = -Wall -Wextra -Werror -O3
LIBCFLAGS = $(CFLAGS)
.PHONY: clean
all: $(LIBA)
exp: $(EXBINS)
%.math.e: %.math.c $(LIBA)
@echo "Compiling example [m] $<"
@$(CC) -o $@ $< $(CFLAGS) -L. -lpluto -lm
%.e: %.c $(LIBA)
@echo "Compiling example $<"
@$(CC) -o $@ $< $(CFLAGS) -L. -lpluto
%.e: %.cpp $(LIBA)
@echo "Compiling example $<"
@$(CPPC) -o $@ $< $(CFLAGS) -L. -lpluto -lX11 -std=c++11
%.o: %.c
@echo "Compiling object $<"
@$(CC) $(LIBCFLAGS) -c $< -o $@
$(LIBA): $(LIBOBJS)
@echo "Generating $@"
@$(AR) rcs $@ $(LIBOBJS)
eclean:
@$(RM) $(EXBINS)
lclean:
@$(RM) $(LIBOBJS) $(LIBA)
clean: eclean lclean
install: $(LIBA)
@cp $(LIBA) $(INSTDIR)
@cp $(LIBSRCDIR)/pluto.h /usr/include/
@echo "Copied header to /usr/include/ and libpluto.a to $(INSTDIR)"
uninstall:
@$(RM) $(INSTDIR)/$(LIBA)
@$(RM) $(INSTDIR)/pluto.h
@echo "Uninstalled pluto"
reinstall: uninstall clean $(LIBA) install