-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
executable file
·51 lines (37 loc) · 1.05 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
# the compiler
CC = gcc
RM = rm
CP = cp
CHMOD = chmod
# Where to install the program?
BINDIR = /usr/bin
# Init script
INITSCRIPT = template/mbserver-initscript
# Where to put the init script?
INITSCRIPTDIR = /etc/init.d
# compiler flags:
# -g adds debugging information to the executable file
# -Wall turns on most, but not all, compiler warnings
CFLAGS = -g -Wall
# list all include directories
INCDIRS += /usr/local/include/modbus # for RPi
#INCDIRS += /usr/include/modbus # for Ubuntu
# list all library directories
LIBDIRS += /usr/local/lib
# list all libraries
LIBS += pthread modbus
# the build target executable:
TARGET = mbserver
CPPFLAGS += $(INCDIRS:%=-I %)
LDFLAGS += $(LIBDIRS:%=-L %)
LDFLAGS += $(LIBS:%=-l %)
.PHONY: clean install
all: $(TARGET)
$(TARGET): src/$(TARGET).c
$(CC) $(CFLAGS) $(CPPFLAGS) -o $(TARGET) src/$(TARGET).c $(LDFLAGS)
clean:
$(RM) $(TARGET)
install:
$(CP) $(TARGET) $(BINDIR)
$(CP) $(INITSCRIPT) $(INITSCRIPTDIR)/$(TARGET)
$(CHMOD) +x $(INITSCRIPTDIR)/$(TARGET)