-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
90 lines (73 loc) · 1.62 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#
# File:
# Makefile
#
# Description:
# Makefile for the SIMPLE library
#
# SVN: $Rev$
#
# Uncomment DEBUG line, to include some debugging info ( -g and -Wall)
BASENAME=simple
#
# Uncomment DEBUG line, to include some debugging info ( -g and -Wall)
DEBUG ?= 1
QUIET ?= 1
#
ifeq ($(QUIET),1)
Q = @
else
Q =
endif
# Defs and build for Linux
CC = gcc
AR = ar
RANLIB = ranlib
CFLAGS = -L.
INCS = -I.
LIBS = lib${BASENAME}.a lib${BASENAME}.so
ifdef DEBUG
CFLAGS += -Wall -g
else
CFLAGS += -O2
endif
SRC = ${BASENAME}Lib.c
HDRS = $(SRC:.c=.h)
OBJ = ${BASENAME}Lib.o
DEPS = $(SRC:.c=.d)
all: ${LIBS}
%.o: %.c
@echo " CC $@"
${Q}$(CC) $(CFLAGS) $(INCS) -c -o $@ $(SRC)
%.so: $(SRC)
@echo " CC $@"
${Q}$(CC) -fpic -shared $(CFLAGS) $(INCS) -o $(@:%.a=%.so) $(SRC)
%.a: $(OBJ)
@echo " AR $@"
${Q}$(AR) ru $@ $<
@echo " RANLIB $@"
${Q}$(RANLIB) $@
ifeq ($(OS),LINUX)
links: $(LIBS)
@echo " LN $<"
${Q}ln -sf $(PWD)/$< $(LINUXVME_LIB)/$<
${Q}ln -sf $(PWD)/$(<:%.a=%.so) $(LINUXVME_LIB)/$(<:%.a=%.so)
${Q}ln -sf ${PWD}/*Lib.h $(LINUXVME_INC)
install: $(LIBS)
@echo " CP $<"
${Q}cp $(PWD)/$< $(LINUXVME_LIB)/$<
@echo " CP $(<:%.a=%.so)"
${Q}cp $(PWD)/$(<:%.a=%.so) $(LINUXVME_LIB)/$(<:%.a=%.so)
@echo " CP ${BASENAME}Lib.h"
${Q}cp ${PWD}/${BASENAME}Lib.h $(LINUXVME_INC)
%.d: %.c
@echo " DEP $@"
${Q}set -e; rm -f $@; \
$(CC) -MM -shared $(INCS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
-include $(DEPS)
endif
clean:
@rm -vf ${BASENAME}Lib.{o,d} lib${BASENAME}.{a,so}
.PHONY: clean