Skip to content

Commit

Permalink
makefile: build & install shared library (#84)
Browse files Browse the repository at this point in the history
Note that the objects must be built with -fPIC now.  Tested with both clang
and gcc.

Issue: #52
PR-URL: #84
Reviewed-By: Fedor Indutny <fedor@indutny.com>
  • Loading branch information
pallas authored Jan 29, 2021
1 parent b9d46bc commit aa07189
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
CLANG ?= clang
CFLAGS ?=

CFLAGS += -Os -g3 -Wall -Wextra -Wno-unused-parameter
CFLAGS += -Os -g3 -Wall -Wextra -Wno-unused-parameter -fPIC
INCLUDES += -Ibuild/

INSTALL ?= install
PREFIX ?= /usr/local
LIBDIR = $(PREFIX)/lib
INCLUDEDIR = $(PREFIX)/include

all: build/libllhttp.a
all: build/libllhttp.a build/libllhttp.so

clean:
rm -rf release/
rm -rf build/

build/libllhttp.so: build/c/llhttp.o build/native/api.o \
build/native/http.o
$(CLANG) -shared $^ -o $@

build/libllhttp.a: build/c/llhttp.o build/native/api.o \
build/native/http.o
$(AR) rcs $@ build/c/llhttp.o build/native/api.o build/native/http.o
Expand Down Expand Up @@ -57,8 +61,9 @@ postversion: release
generate:
npx ts-node bin/generate.ts

install: build/libllhttp.a
install: build/libllhttp.a build/libllhttp.so
$(INSTALL) build/llhttp.h $(DESTDIR)$(INCLUDEDIR)/llhttp.h
$(INSTALL) build/libllhttp.a $(DESTDIR)$(LIBDIR)/libllhttp.a
$(INSTALL) build/libllhttp.so $(DESTDIR)$(LIBDIR)/libllhttp.so

.PHONY: all generate clean release

0 comments on commit aa07189

Please sign in to comment.