-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
50 lines (45 loc) · 1.15 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
CC=gcc
CFLAGS=-Wall -march=native -std=gnu99 -Ofast -minline-all-stringops -fopenmp -lm
CFLAGS_DBG=$(CFLAGS) -g -D DBG
C_FILES=$(shell find src -name "*.c" )
OBJ=$(patsubst %.c, %.o, $(C_FILES) )
OBJ_DBG=$(patsubst %.c, %.o.dbg, $(C_FILES) )
OBJ_FILE=$(shell find . -name "*.o*" )
MAIN = main.c
LIB = libhomogj.so
prefix=/opt/homogj
OUTPUT=homogj
.PHONY: all lib debug clean install uninstall
all: $(OUTPUT)
lib: $(LIB)
install: all
@echo Installing to $(prefix)
@mkdir -p $(prefix)/bin
@cp $(OUTPUT) $(prefix)/bin
@cp README.md $(prefix)
@echo done
uninstall:
@echo Uninstalling form $(prefix)
@-rm -r $(prefix)
@echo done
debug: $(OUTPUT).dbg
clean:
@echo Cleaning...
@-rm -f $(OBJ_FILE)
@-rm *$(OUTPUT)*
@echo Done
%.o: %.c
@echo Compiling and generating object $@
@$(CC) $(CFLAGS) -fPIC -c -o $@ $<
%.o.dbg: %.c
@echo Compiling and generating debugging object $@
@$(CC) $(CFLAGS_DBG) -c -o $@ $<
$(OUTPUT): $(MAIN) $(OBJ)
@echo Linking executable $@
@$(CC) $(CFLAGS) -o $@ $^
$(OUTPUT).dbg: $(MAIN) $(OBJ_DBG)
@echo Linking executable $@
@$(CC) $(CFLAGS_DBG) -o $@ $^
$(LIB): $(OBJ)
@echo Generating dynamic library $@
@$(CC) -shared -o $@ $<