Fix .gitignore and add missing Makefiles

This commit is contained in:
Ilja Kartašov 2019-07-14 21:01:07 +02:00
parent 043d414df4
commit aff6ab6fb2
4 changed files with 240 additions and 26 deletions

32
.gitignore vendored
View File

@ -1,26 +1,6 @@
# Binaries
build/*
root/*
demo/*
bin/*
obj/*
webstuff-*
Makefile
tmp
tmp/*
*.tar.gz
*.zip
*.rar
*.gz
*.bz2
pkg/*
include/webstuff_bak
CMakeCache.txt
CMakeFiles/*
cmake_install.cmake
libaisl.dylib
demo/demo
build/
*.tar.gz
*.zip
*.rar
*.gz
*.bz2

31
Makefile Normal file
View File

@ -0,0 +1,31 @@
#
# Makefile
# Ilja Kartašov, 2019-03-02 17:32
#
#
OUT_DIR ?= build
.PHONY: library examples tool
all: library examples
library:
@cd library && make
examples: library
@cd examples && make
tool: library
@cd tool && make
clean:
$(info cleaning: build files)
@rm -Rf $(OUT_DIR)
@rm -Rf ./vgcore.*
install: library
cd library && make install
cd tool && make install
# vim:ft=make
#

115
library/Makefile Normal file
View File

@ -0,0 +1,115 @@
#
# Makefile
# Ilja Kartašov, 2019-07-13 14:51
#
.POSIX:
CC ?= gcc
AR ?= ar
PKG_CONFIG ?= pkg-config
PREFIX ?= /usr/local
DESTDIR ?=
LIB_DIR ?= lib
TARGET_NAME = aisl
OUT_DIR ?= ../build
SRC_DIR ?= .
# Version
VERSION_MAJOR = 1
VERSION_MINOR = 0
VERSION_TWEAK = 5
VERSION_LABEL = 0
# Source files
SOURCE_FILES := \
$(SRC_DIR)/instance.c \
$(SRC_DIR)/server.c \
$(SRC_DIR)/client.c \
$(SRC_DIR)/stream.c \
$(SRC_DIR)/http.c \
$(SRC_DIR)/ssl.c \
$(SRC_DIR)/list.c \
$(SRC_DIR)/str-utils.c \
$(SRC_DIR)/buffer.c \
$(SRC_DIR)/types.c \
# compilation macro options:
AISL_WITH_DEBUG ?= 0 # disable debug output
AISL_WITH_SSL ?= 1 # enable SSL support
AISL_WITH_STRINGIFIERS ?= 1 # enable *_to_string functions
CFLAGS := \
-std=c99 \
-pedantic \
-Wall \
-Wmissing-prototypes \
-Wstrict-prototypes \
-Wold-style-definition \
-O2 \
-s \
-fvisibility=hidden \
\
-I../ \
-I../include \
\
-D_POSIX_C_SOURCE=200809L \
-DAISL_WITH_DEBUG=$(AISL_WITH_DEBUG) \
-DAISL_WITH_SSL=$(AISL_WITH_SSL) \
-DAISL_WITH_STRINGIFIERS=$(AISL_WITH_STRINGIFIERS) \
\
`$(PKG_CONFIG) --cflags openssl` \
$(CFLAGS) \
LDFLAGS := \
`$(PKG_CONFIG) --libs openssl` \
# flags
SOURCE_LIST := $(wildcard $(SOURCE_FILES))
SHARED_OBJS := $(addsuffix .o, $(addprefix $(OUT_DIR)/shared/, ${SOURCE_LIST}))
STATIC_OBJS := $(addsuffix .o, $(addprefix $(OUT_DIR)/static/, ${SOURCE_LIST}))
all: lib$(TARGET_NAME).so lib$(TARGET_NAME).a
$(info AISL_WITH_DEBUG=$(AISL_WITH_DEBUG))
$(info AISL_WITH_SSL=$(AISL_WITH_SSL))
$(info AISL_WITH_STRINGIFIERS=$(AISL_WITH_STRINGIFIERS))
lib$(TARGET_NAME).so: $(SHARED_OBJS)
$(info building target: $@)
@$(CC) -shared -o $(OUT_DIR)/$@ $(SHARED_OBJS) $(LDFLAGS)
$(info done: $@)
lib$(TARGET_NAME).a: $(STATIC_OBJS)
$(info building target: $@)
@$(AR) rcs $(OUT_DIR)/$@ $(STATIC_OBJS)
$(info done: $@)
$(OUT_DIR)/shared/%.o: %
$(info compiling file: $<)
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) -fpic -c $< -o $@
$(OUT_DIR)/static/%.o: %
$(info compiling file: $<)
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) -c $< -o $@
install:lib$(TARGET_NAME).so lib$(TARGET_NAME).a
$(info installing files)
@mkdir -p $(DESTDIR)$(PREFIX)/$(LIB_DIR)
@mkdir -p $(DESTDIR)$(PREFIX)/include
@cp $(OUT_DIR)/lib$(LIBRARY_NAME).so $(DESTDIR)$(PREFIX)/$(LIB_DIR)
@cp $(OUT_DIR)/lib$(LIBRARY_NAME).a $(DESTDIR)$(PREFIX)/$(LIB_DIR)
@cp -R include/aisl $(DESTDIR)$(PREFIX)/include
# vim:ft=make
#

88
tool/Makefile Normal file
View File

@ -0,0 +1,88 @@
#
# Makefile
# Ilja Kartašov, 2019-07-13 14:51
#
.POSIX:
CC ?= gcc
PKG_CONFIG ?= pkg-config
PREFIX ?= /usr/local
DESTDIR ?=
BIN_DIR ?= bin
TARGET_NAME = aisl
OUT_DIR ?= ../build
SRC_DIR ?= .
SDK_DIR ?= ../sdk
CSTUFF_DIR ?= ../cStuff
# Version
VERSION_MAJOR = 0
VERSION_MINOR = 1
VERSION_TWEAK = 0
VERSION_LABEL = 0
# Source files
SOURCE_FILES := \
$(SRC_DIR)/main.c \
$(SRC_DIR)/option.c \
$(SRC_DIR)/compose.c \
\
$(SDK_DIR)/components/html.c \
\
$(CSTUFF_DIR)/list.c \
$(CSTUFF_DIR)/string.c \
# compilation macro options:
CFLAGS := \
-std=c99 \
-pedantic \
-Wall \
-Wmissing-prototypes \
-Wstrict-prototypes \
-Wold-style-definition \
-O2 \
-s \
\
-I../ \
-I$(SDK_DIR) \
\
-D_POSIX_C_SOURCE=200809L \
-DEXECUTABLE="$(TARGET_NAME)" \
-DVERSION_MAJOR=$(VERSION_MAJOR) \
-DVERSION_MINOR=$(VERSION_MINOR) \
-DVERSION_TWEAK=$(VERSION_TWEAK) \
-DVERSION_LABEL=$(VERSION_LABEL) \
\
$(CFLAGS) \
LDFLAGS :=
# flags
SOURCE_LIST := $(wildcard $(SOURCE_FILES))
OBJECT_LIST := $(addsuffix .o, $(addprefix $(OUT_DIR)/tool/, ${SOURCE_LIST}))
all: $(TARGET_NAME)
$(TARGET_NAME): $(OBJECT_LIST)
$(info building target: $@)
@$(CC) -o $(OUT_DIR)/$@ $(OBJECT_LIST) $(LDFLAGS)
$(info done: $@)
$(OUT_DIR)/tool/%.o: %
$(info compiling file: $<)
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) -c $< -o $@
install: $(TARGET_NAME)
$(info installing files)
@cp $(OUT_DIR)/$< $(DESTDIR)$(PREFIX)/$(BIN_DIR)
# vim:ft=make
#