/
Makefile
66 lines (50 loc) · 1.54 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
60
61
62
63
64
65
# This is a general use makefile for librobotcontrol projects written in C.
# Just change the target name to match your main source code filename.
TARGET = Madgwick6DOFDemo
# compiler and linker binaries
CC := gcc
LINKER := gcc
# compiler and linker flags
WFLAGS := -Wall -Wextra -Werror=float-equal -Wuninitialized -Wunused-variable -Wdouble-promotion
CFLAGS := -g -c -Wall
LDFLAGS := -pthread -lm -lrt -l:librobotcontrol.so.1
SOURCES := $(wildcard *.c)
INCLUDES := $(wildcard *.h)
OBJECTS := $(SOURCES:$%.c=$%.o)
prefix := /usr/local
RM := rm -f
INSTALL := install -m 4755
INSTALLDIR := install -d -m 755
SYMLINK := ln -s -f
SYMLINKDIR := /etc/robotcontrol
SYMLINKNAME := link_to_startup_program
# linking Objects
$(TARGET): $(OBJECTS)
@$(LINKER) -o $@ $(OBJECTS) $(LDFLAGS)
@echo "Made: $@"
# compiling command
$(OBJECTS): %.o : %.c $(INCLUDES)
@$(CC) $(CFLAGS) $(WFLAGS) $(DEBUGFLAG) $< -o $@
@echo "Compiled: $@"
all: $(TARGET)
debug:
$(MAKE) $(MAKEFILE) DEBUGFLAG="-g -D DEBUG"
@echo " "
@echo "$(TARGET) Make Debug Complete"
@echo " "
install:
@$(MAKE) --no-print-directory
@$(INSTALLDIR) $(DESTDIR)$(prefix)/bin
@$(INSTALL) $(TARGET) $(DESTDIR)$(prefix)/bin
@echo "$(TARGET) Install Complete"
clean:
@$(RM) $(OBJECTS)
@$(RM) $(TARGET)
@echo "$(TARGET) Clean Complete"
uninstall:
@$(RM) $(DESTDIR)$(prefix)/bin/$(TARGET)
@echo "$(TARGET) Uninstall Complete"
runonboot:
@$(MAKE) install --no-print-directory
@$(SYMLINK) $(DESTDIR)$(prefix)/bin/$(TARGET) $(SYMLINKDIR)/$(SYMLINKNAME)
@echo "$(TARGET) Set to Run on Boot"