-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
70 lines (54 loc) · 1.59 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
66
67
68
69
# This is a general use makefile for robotics cape projects written in C.
# Just change the target name to match your main source code filename.
SRCDIR := src
BINDIR := bin
BUILDDIR := build
INCLUDEDIR := include
TARGET := $(BINDIR)/rc_pilot
# file definitions for rules
SOURCES := $(shell find $(SRCDIR) -type f -name *.c)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(BUILDDIR)/%.o)
INCLUDES := $(shell find $(INCLUDEDIR) -name '*.h')
CC := gcc
LINKER := gcc
WFLAGS := -Wall -Wextra
CFLAGS := -I $(INCLUDEDIR)
OPT_FLAGS := -O1
LDFLAGS := -lm -lrt -pthread -lrobotcontrol -ljson-c
RM := rm -rf
INSTALL := install -m 4755
INSTALLDIR := install -d -m 755
LINK := ln -s -f
LINKDIR := /etc/robotcontrol
LINKNAME := link_to_startup_program
prefix ?= /usr
# linking Objects
$(TARGET): $(OBJECTS)
@mkdir -p $(BINDIR)
@$(LINKER) -o $(@) $(OBJECTS) $(LDFLAGS)
@echo "made: $(@)"
# rule for all other objects
$(BUILDDIR)/%.o : $(SRCDIR)/%.c $(INCLUDES)
@mkdir -p $(dir $(@))
@$(CC) -c $(CFLAGS) $(OPT_FLAGS) $(DEBUGFLAG) $< -o $(@)
@echo "made: $(@)"
all: $(TARGET)
debug:
$(MAKE) $(MAKEFILE) DEBUGFLAG="-g -D DEBUG"
@echo "$(TARGET) Make Debug Complete"
install:
@$(INSTALLDIR) $(DESTDIR)$(prefix)/bin
@$(INSTALL) $(TARGET) $(DESTDIR)$(prefix)/bin
@echo "$(TARGET) Install Complete"
clean:
@$(RM) $(BINDIR)
@$(RM) $(BUILDDIR)
@$(RM) docs/html
@echo "Library Clean Complete"
uninstall:
@$(RM) $(DESTDIR)$(prefix)/$(TARGET)
@echo "$(TARGET) Uninstall Complete"
runonboot:
@$(MAKE) install
@$(LINK) $(DESTDIR)$(prefix)/bin/$(TARGET) $(LINKDIR)/$(LINKNAME)
@echo "$(TARGET) Set to Run on Boot"