-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
41 lines (36 loc) · 1.18 KB
/
Makefile
File metadata and controls
41 lines (36 loc) · 1.18 KB
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
# Variables
CC = gcc
OPENRESTY_HOME ?= /usr/local/openresty
LUA_LIB_MAIN = $(OPENRESTY_HOME)/lualib/resty/markdown.lua
LUA_LIB_DIR = $(OPENRESTY_HOME)/lualib/resty/hoedown
LUA_SO_DIR = $(OPENRESTY_HOME)/lualib
CFLAGS = -O2 -fPIC -I./src
LDFLAGS = -shared
TARGET = libhoedown.so
SRC = $(wildcard src/*.c)
INSTALL = install
# Declare phony targets
.PHONY: all install clean
# Default target
all: $(TARGET)
# Compile the C code into a shared library
$(TARGET): $(SRC)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
# Install the Lua and C files
install:
$(INSTALL) -d $(LUA_LIB_DIR)
$(INSTALL) -m 644 lib/resty/markdown.lua $(LUA_LIB_MAIN)
$(INSTALL) -m 644 lib/resty/hoedown/*.lua $(LUA_LIB_DIR)
sed -i 's|return ffi_load "hoedown"|return ffi_load "$(OPENRESTY_HOME)/lualib/libhoedown.so"|' $(LUA_LIB_DIR)/library.lua
$(INSTALL) -m 755 $(TARGET) $(LUA_SO_DIR)
@echo "Installed $(TARGET) to $(LUA_SO_DIR)"
@echo "Installed Lua files to $(LUA_LIB_MAIN) and $(LUA_LIB_DIR)"
@echo "You should run 'openresty -s reload' to apply the changes."
@echo "Installation complete."
# Clean up build artifacts
clean:
rm -f $(LUA_LIB_MAIN)
rm -rf $(LUA_LIB_DIR)
rm -f $(LUA_SO_DIR)/$(TARGET)
rm -f src/*.o
rm -f $(TARGET)