-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
63 lines (54 loc) · 1.61 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
PNAME=smallfry
CC = gcc
CFLAGS+=-O3 -Wall
LDFLAGS+=-s
LIBS=-lm
ARC = ar rcs
LN = @ln -fsv
RM = @rm -fv
RMDIR = @rm -frv
PLIB = lib$(PNAME)
VERSION_MAJOR = 0
VERSION_MINOR = 2
VERSION_RELEASE = 0
PREFIX = /usr/local
INCPREFIX = $(PREFIX)/include
LIBPREFIX = $(PREFIX)/lib
DOCPREFIX = $(PREFIX)/share/doc/$(PLIB)$(VERSION_MAJOR)
INSTALL = install
SRCDIR=./src
SRC= $(SRCDIR)/smallfry.c
LIBOBJ = $(SRC:.c=.o)
ifneq ($(shell uname -m), i386)
CFLAGS += -fPIC
endif
all: lib
$(PLIB).a: $(LIBOBJ)
$(ARC) $@ $(LIBOBJ)
$(PLIB).so: $(LIBOBJ)
$(CC) $(CFLAGS) -shared -Wl,-soname,$@.$(VERSION_MAJOR) -o $@ $^ $(LDFLAGS) $(LIBS)
lib: $(PLIB).a $(PLIB).so
clean:
$(RM) $(SRCDIR)/*.o
$(RM) ./$(PLIB).a
$(RM) ./$(PLIB).so
install: lib
$(INSTALL) -d $(LIBPREFIX)
$(INSTALL) -m 0644 $(PLIB).a $(LIBPREFIX)/$(PLIB).a
$(INSTALL) -m 0644 $(PLIB).so $(LIBPREFIX)/$(PLIB).so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
$(LN) $(PLIB).so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE) $(LIBPREFIX)/$(PLIB).so.$(VERSION_MAJOR)
$(LN) $(PLIB).so.$(VERSION_MAJOR) $(LIBPREFIX)/$(PLIB).so
$(INSTALL) -d $(INCPREFIX)
$(INSTALL) -m 0644 $(SRCDIR)/$(PNAME).h $(INCPREFIX)
$(INSTALL) -d $(LIBPREFIX)/pkgconfig
$(INSTALL) -m 0644 $(PNAME).pc $(LIBPREFIX)/pkgconfig
$(INSTALL) -d $(DOCPREFIX)
$(INSTALL) -m 0644 LICENSE README.md $(DOCPREFIX)
uninstall:
$(RM) $(LIBPREFIX)/$(PLIB).a
$(RM) $(LIBPREFIX)/$(PLIB).so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
$(RM) $(LIBPREFIX)/$(PLIB).so.$(VERSION_MAJOR)
$(RM) $(LIBPREFIX)/$(PLIB).so
$(RM) $(LIBPREFIX)/pkgconfig/$(PNAME).pc
$(RM) $(INCPREFIX)/$(PNAME).h
$(RMDIR) $(DOCPREFIX)