-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
65 lines (53 loc) · 1.68 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
PROJECT=pifacedigital
SOURCES=src/pifacedigital.c
LIBRARY=static
INCPATHS=../libmcp23s17/src/
LIBPATHS=../libmcp23s17/
LDFLAGS=
CFLAGS=-c -Wall
CC=gcc
SWIG=swig
# ------------ MAGIC BEGINS HERE -------------
# Automatic generation of some important lists
OBJECTS=$(SOURCES:.c=.o)
INCFLAGS=$(foreach TMP,$(INCPATHS),-I$(TMP))
LIBFLAGS=$(foreach TMP,$(LIBPATHS),-L$(TMP))
# Set up the output file names for the different output types
ifeq "$(LIBRARY)" "shared"
BINARY=lib$(PROJECT).so
LDFLAGS += -shared
else ifeq "$(LIBRARY)" "static"
BINARY=lib$(PROJECT).a
else
BINARY=$(PROJECT)
endif
all: $(SOURCES) $(BINARY)
$(BINARY): $(OBJECTS)
# Link the object files, or archive into a static library
ifeq "$(LIBRARY)" "static"
ar rcs $(BINARY) $(OBJECTS)
else
$(CC) $(LIBFLAGS) $(OBJECTS) $(LDFLAGS) -o $@
endif
.c.o:
$(CC) $(INCFLAGS) $(CFLAGS) -fPIC $< -o $@
distclean: clean
rm -f $(BINARY)
example: example.c
gcc -o example example.c -Isrc/ -L. -lpifacedigital -L../libmcp23s17/ -lmcp23s17
pifacedigital: util/pifacedigital-cmd.c
gcc -o pifacedigital util/pifacedigital-cmd.c -Isrc/ -I../libmcp23s17/src/ -L. -lpifacedigital -L../libmcp23s17/ -lmcp23s17
clean:
rm -f $(OBJECTS)
install: $(BINARY)
install src/pifacedigital.h /usr/local/include
install $(BINARY) /usr/local/lib
bindings: src/pifacedigital.h src/pifacedigital.i
mkdir -p bindings/java
$(SWIG) -java -outdir bindings/java src/pifacedigital.i
mkdir -p bindings/python
$(SWIG) -python -outdir bindings/python src/pifacedigital.i
mkdir -p bindings/node
$(SWIG) -javascript -node -outdir bindings/node src/pifacedigital.i
mkdir -p bindings/lua
$(SWIG) -lua -outdir bindings/lua src/pifacedigital.i