-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (54 loc) · 1.32 KB
/
Makefile
File metadata and controls
66 lines (54 loc) · 1.32 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
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
# Makefile for building libipcrypt.a
# This Makefile is designed to work with both GNU Make and BSD Make
# Compiler settings
CC ?= cc
AR ?= ar
RANLIB ?= ranlib
CFLAGS ?= -O2
CFLAGS += -I./src/include
# Installation settings
PREFIX ?= /usr/local
LIBDIR = $(PREFIX)/lib
INCLUDEDIR = $(PREFIX)/include
INSTALL ?= install
INSTALL_DATA ?= $(INSTALL) -m 644
INSTALL_DIR ?= $(INSTALL) -d -m 755
RM ?= rm -f
# Source files
SRC_DIR = src
SRCS = $(SRC_DIR)/ipcrypt2.c
OBJS = $(SRCS:.c=.o)
# Library name
LIBNAME = libipcrypt2.a
# Default target
all: $(LIBNAME)
# Build the static library
$(LIBNAME): $(OBJS)
$(AR) rcs $@ $(OBJS)
$(RANLIB) $@
# Compile source files
.c.o:
$(CC) $(CFLAGS) -c $< -o $@
# Install the library and header files
install: $(LIBNAME)
$(INSTALL_DIR) $(DESTDIR)$(LIBDIR)
$(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR)
$(INSTALL_DATA) $(LIBNAME) $(DESTDIR)$(LIBDIR)/
$(INSTALL_DATA) $(SRC_DIR)/include/ipcrypt2.h $(DESTDIR)$(INCLUDEDIR)/
# Uninstall the library and header files
uninstall:
$(RM) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
$(RM) $(DESTDIR)$(INCLUDEDIR)/ipcrypt2.h
# Clean up
clean:
$(RM) $(OBJS) $(LIBNAME)
# Test target
test check:
@if command -v zig >/dev/null 2>&1; then \
zig build test; \
else \
echo "zig not found - skipping tests"; \
exit 0; \
fi
# Phony targets
.PHONY: all clean install uninstall test check