Skip to content

Commit

Permalink
added .a .dll make rules
Browse files Browse the repository at this point in the history
  • Loading branch information
KDesp73 committed Jun 19, 2024
1 parent ef03503 commit bfa82fb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
39 changes: 19 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,49 +1,48 @@
CC = cc
CFLAGS = -Wall -ggdb -fPIC -Iinclude
LDFLAGS =

SRC_DIR = src
INCLUDE_DIR = include
BUILD_DIR = build

# List all the source files
SRC_FILES := $(filter-out $(SRC_DIR)/main.c, $(shell find $(SRC_DIR) -name '*.c'))

# Generate the corresponding object file names
SRC_FILES := $(shell find $(SRC_DIR) -name '*.c')
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRC_FILES))

# Target: the final executable (FOR TESTING)
TARGET = webc
# chmod 755 libwebc.so
LIB_NAME = libwebc.so

# Default target, build the executable
all: $(BUILD_DIR) library
# chmod 644 libwebc.a
STATIC_LIB_NAME = libwebc.a

# read access for all users
DLL_NAME = webc.dll

all: library

# Rule to create the build directory
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
mkdir -p $(BUILD_DIR)/core
mkdir -p $(BUILD_DIR)/ui
mkdir -p $(BUILD_DIR)/actions
mkdir -p $(BUILD_DIR)/server

# Rule to build the executable
$(TARGET): $(OBJ_FILES) $(BUILD_DIR)/main.o
$(CC) -o $@ $^ $(LFLAGS)

# Rule to build object files from source files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c -o $@ $<

library: $(OBJ_FILES)
library: $(BUILD_DIR) $(OBJ_FILES)
$(CC) -shared -o $(LIB_NAME) $(OBJ_FILES)

# Clean rule to remove generated files
static_library: $(BUILD_DIR) $(OBJ_FILES)
ar rcs $(STATIC_LIB_NAME) $(OBJ_FILES)

dll: $(BUILD_DIR) $(OBJ_FILES)
$(CC) -shared -o $(DLL_NAME) $(OBJ_FILES) -Wl,--out-implib,libwebc.dll.a

clean:
rm -rf $(BUILD_DIR) $(TARGET) $(LIB_NAME)
rm -rf $(BUILD_DIR) $(LIB_NAME) $(STATIC_LIB_NAME) $(DLL_NAME) libwebc.dll.a

compile_commands.json: $(SRC_FILES)
bear -- make

# Phony target to avoid conflicts with file names
.PHONY: all clean library

.PHONY: all clean library static_library dll
13 changes: 11 additions & 2 deletions include/webc-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,23 @@
#include "extern/httpd.h"

/**
* Serves a physical file tree starting from the root
* Serves the physical file tree exported from this program starting from the root
*
* @param port The port to start the server from
* @param root The root directory
* @param tree The virtual tree
*
* @return int Success code
*/
WEBCAPI int ServeExported(int port, Tree tree);

/**
* Serves a physical file tree starting from the root
*
* @param port The port to start the server from
* @param root The root directory to start serving from
*
* @return int Success code
*/
WEBCAPI int ServeExportedRoot(int port, Cstr root);

/**
Expand Down

0 comments on commit bfa82fb

Please sign in to comment.