aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-11-13 23:55:37 +0100
committerMattias Andrée <maandree@operamail.com>2014-11-13 23:55:37 +0100
commiteb0760ad4ce0f0b81a9ee38f3342d0bf5e40ed53 (patch)
tree2a03f52b81aa8ac4e6bd8ccf22781c7ab3c8dc8a /Makefile
parentupdate manual (diff)
downloadlibpassphrase-eb0760ad4ce0f0b81a9ee38f3342d0bf5e40ed53.tar.gz
libpassphrase-eb0760ad4ce0f0b81a9ee38f3342d0bf5e40ed53.tar.bz2
libpassphrase-eb0760ad4ce0f0b81a9ee38f3342d0bf5e40ed53.tar.xz
m + compile static lib
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile53
1 files changed, 39 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index 002d37c..48b78fb 100644
--- a/Makefile
+++ b/Makefile
@@ -60,11 +60,11 @@ WARN = -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissi
# The C standard for C code compilation
STD = gnu99
# C preprocessor flags
-CPPFLAGS_ = $(foreach D, $(OPTIONS), -D'$(D)=1') $(CPPFLAGS)
+CPPFLAGS_ = $(foreach D, $(OPTIONS), -D'$(D)=1')
# C compiling flags
-CFLAGS_ = -std=$(STD) $(WARN) $(CFLAGS)
+CFLAGS_ = -std=$(STD) $(WARN)
# Linking flags
-LDFLAGS_ = $(LDFLAGS)
+LDFLAGS_ =
# Flags to use when compiling and assembling
CC_FLAGS = $(CPPFLAGS_) $(CFLAGS_) $(OPTIMISE)
@@ -74,34 +74,47 @@ LD_FLAGS = $(LDFLAGS_) $(CFLAGS_) $(OPTIMISE)
.PHONY: default
-default: libpassphrase info
+default: lib info
.PHONY: all
-all: libpassphrase test doc
+all: lib test doc
.PHONY: doc
doc: info pdf ps dvi
+.PHONY: lib
+lib: libpassphrase
+
.PHONY: libpassphrase
-libpassphrase: bin/libpassphrase.so
+libpassphrase: so a
+
+.PHONY: so
+so: bin/libpassphrase.so
+
+.PHONY: a
+a: bin/libpassphrase.a
.PHONY: test
test: bin/test
bin/libpassphrase.so: obj/passphrase.o
@mkdir -p bin
- $(CC) $(LD_FLAGS) -shared -o "$@" $^
+ $(CC) $(LD_FLAGS) -shared -o "$@" $^ $(LDFLAGS)
+
+bin/libpassphrase.a: obj/passphrase.o
+ @mkdir -p bin
+ ar rcs "$@" $^
bin/test: bin/libpassphrase.so obj/test.o
- $(CC) $(LD_FLAGS) -L bin -lpassphrase -o "$@" obj/test.o
+ $(CC) $(LD_FLAGS) -Lbin -lpassphrase -o "$@" obj/test.o $(LDFLAGS)
obj/passphrase.o: src/passphrase.c src/passphrase.h
@mkdir -p "$(shell dirname "$@")"
- $(CC) $(CC_FLAGS) -fPIC -o "$@" -c "$<"
+ $(CC) $(CC_FLAGS) -fPIC -o "$@" -c "$<" $(CFLAGS) $(CPPFLAGS)
obj/test.o: src/test.c src/test.h
@mkdir -p "$(shell dirname "$@")"
- $(CC) $(CC_FLAGS) -o "$@" -c "$<"
+ $(CC) $(CC_FLAGS) -o "$@" -c "$<" $(CFLAGS) $(CPPFLAGS)
.PHONY: info
info: libpassphrase.info
@@ -137,13 +150,24 @@ install: install-base install-info
install-all: install-base install-doc
.PHONY: install-base
-install-base: install-lib install-license
+install-base: install-so install-a install-header install-license
.PHONY: install-lib
-install-lib: bin/libpassphrase.so libpassphrase.info
+install-lib: install-so install-a install-header
+
+.PHONY: install-so
+install-so: bin/libpassphrase.so
install -dm755 -- "$(DESTDIR)$(LIBDIR)"
- install -dm755 -- "$(DESTDIR)$(INCLUDEDIR)"
install -m755 -- bin/libpassphrase.so "$(DESTDIR)$(LIBDIR)"
+
+.PHONY: install-a
+install-a: bin/libpassphrase.a
+ install -dm755 -- "$(DESTDIR)$(LIBDIR)"
+ install -m644 -- bin/libpassphrase.a "$(DESTDIR)$(LIBDIR)"
+
+.PHONY: install-header
+install-header:
+ install -dm755 -- "$(DESTDIR)$(INCLUDEDIR)"
install -m755 -- src/passphrase.h "$(DESTDIR)$(INCLUDEDIR)"
.PHONY: install-license
@@ -178,6 +202,7 @@ install-dvi: libpassphrase.dvi
.PHONY: uninstall
uninstall:
-rm -- "$(DESTDIR)$(LIBDIR)/libpassphrase.so"
+ -rm -- "$(DESTDIR)$(LIBDIR)/libpassphrase.a"
-rm -- "$(DESTDIR)$(INCLUDEDIR)/passphrase.h"
-rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING"
-rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE"
@@ -190,5 +215,5 @@ uninstall:
.PHONY: clean
clean:
- -rm -r bin obj libpassphrase.{info,pdf,ps,dvi}
+ -rm -r bin obj *.info *.pdf *.ps *.dvi