Skip to content

Commit

Permalink
1.0.0: added Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed Mar 19, 2021
1 parent 51b698a commit 559d2a4
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
PROJECT=sais
PLIBNAME=lib$(PROJECT)
PVER=1.0.0
PSOVER=1
ifeq ($(OS),Windows_NT)
PLIBSTATIC=$(PROJECT).a
PLIBSHARED=$(PROJECT)-$(PVER).dll
else
PLIBSTATIC=$(PLIBNAME).a
PLIBSHARED=$(PLIBNAME).so.$(PSOVER)
endif
PLIBS=$(PLIBSTATIC) $(PLIBSHARED)
CC=gcc
CFLAGS?=-Wall -O2
LDFLAGS?=-lm
AR?=ar
INSTALL?=install
RM?=rm -f
RMD?=$(RM) -r
PREFIX?=/usr/local
SRCS=src
DOCS?=share/doc/$(LIBNAME)
LIBS?=lib
INCLUDES?=include
MANS?=man/man1

all: $(PLIBS)

$(SRCS)/$(PLIBNAME).o: $(SRCS)/$(PLIBNAME).c
$(CC) $(CFLAGS) -c -o $@ $^

$(PLIBSTATIC): $(SRCS)/$(PLIBNAME).o
$(AR) rcs $@ $^

$(PLIBSHARED): $(SRCS)/$(PLIBNAME).o
$(CC) $(CFLAGS) -shared -Wl,-soname,$@ $^ -o $@

clean:
$(RM) $(SRCS)/$(PLIBNAME).o $(PLIBS)

install:
$(INSTALL) -d $(PREFIX)/$(LIBS)
$(INSTALL) -d $(PREFIX)/$(INCLUDES)
$(INSTALL) -d $(PREFIX)/$(MANS)
$(INSTALL) -d $(PREFIX)/$(DOCS)
$(INSTALL) -m 0644 $(PLIBS) $(PREFIX)/$(LIBS)
$(INSTALL) -m 0644 $(SRCS)/$(PLIBNAME).h $(PREFIX)/$(INCLUDES)
$(INSTALL) -m 0644 CHANGES LICENSE README.md VERSION $(PREFIX)/$(DOCS)

uninstall:
$(RM) $(PREFIX)/$(LIBS)/$(PLIBSTATIC)
$(RM) $(PREFIX)/$(LIBS)/$(PLIBSHARED)
$(RM) $(PREFIX)/$(INCLUDES)/$(SRCS)/$(PLIBNAME).h
$(RMD) $(PREFIX)/$(DOCS)
File renamed without changes.
File renamed without changes.

0 comments on commit 559d2a4

Please sign in to comment.