Skip to content

Commit

Permalink
chore: update makefile and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
phukon committed Nov 13, 2024
1 parent 4e604fb commit fa61b47
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 22 deletions.
59 changes: 53 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,61 @@
CC = gcc
CFLAGS = -Wall -Wextra
SRCS = src/main.c src/system_check.c src/key_management.c src/git_config.c
OBJS = $(SRCS:.c=.o)
TARGET = gitkeykit
CFLAGS = -Wall -Wextra -I./src

# Directories
SRC_DIR = src
BUILD_DIR = build
BIN_DIR = bin

# Source files
SRCS = $(wildcard $(SRC_DIR)/*.c) \
$(wildcard $(SRC_DIR)/commands/*.c) \
$(wildcard $(SRC_DIR)/utils/*.c)

# Object files
OBJS = $(SRCS:%.c=$(BUILD_DIR)/%.o)

# Target executable
TARGET = $(BIN_DIR)/gitkeykit

# Platform-specific settings
ifeq ($(OS),Windows_NT)
TARGET := $(TARGET).exe
RM = del /Q /F
MKDIR = mkdir
else
RM = rm -rf
MKDIR = mkdir -p
endif

# Default target
all: directories $(TARGET)

# Create necessary directories
directories:
$(MKDIR) $(BUILD_DIR) $(BIN_DIR) \
$(BUILD_DIR)/$(SRC_DIR) \
$(BUILD_DIR)/$(SRC_DIR)/commands \
$(BUILD_DIR)/$(SRC_DIR)/utils

# Link the final executable
$(TARGET): $(OBJS)
$(CC) $(OBJS) -o $(TARGET)

%.o: %.c
# Compile source files
$(BUILD_DIR)/%.o: %.c
$(MKDIR) $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@

# Clean build files
clean:
rm -f $(OBJS) $(TARGET)
$(RM) $(BUILD_DIR) $(BIN_DIR)

# Install target (Unix-like systems only)
install: all
install -m 755 $(TARGET) /usr/local/bin/

# Phony targets
.PHONY: all clean directories install

# Dependencies
-include $(OBJS:.o=.d)
69 changes: 53 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,64 @@ Before using GitKeyKit, ensure you have:
- macOS: `brew install gnupg`
- Linux: `sudo apt-get install gnupg` (Ubuntu/Debian) or equivalent


## Installation 🚀

### From Source
### Unix-like systems
```bash
git clone https://github.com/yourusername/gitkeykit.git
cd gitkeykit
make
bash
gitkeykit create
bash
gitkeykit import path/to/key.asc
bash
sudo make install
```

## Usage 📖

### Setup GPG key for signing commits
```bash
gitkeykit
```

### Import PGP key from file
```bash
gitkeykit import <key_path>
```

### Reset Git and GPG configurations
```bash
gitkeykit --reset
```

## Building from Source 🛠️

### Compilation
```bash
make
```

This will:
- Compile the source files from `src/`, `src/commands/`, and `src/utils/` directories
- Link object files and create the executable in `bin/` directory
- Create necessary directories (`build/` and `bin/`) if they don't exist
- Generate the executable `gitkeykit` (or `gitkeykit.exe` on Windows)

### Cleaning Up
```bash
make clean
```
This removes the `build/` and `bin/` directories along with all generated files.

## Error Codes 🚨
- `0`: Success
- `1`: GPG not found
- `2`: Git not found
- `3`: Invalid arguments
- `4`: No secret keys found
- `5`: Invalid input
- `6`: Git configuration error
- `7`: Key generation error

| Code | Description |
|------|-------------|
| 0 | Success |
| 1 | GPG not found |
| 2 | Git not found |
| 3 | Invalid arguments |
| 4 | No secret keys found |
| 5 | Invalid input |
| 6 | Git configuration error |
| 7 | Key generation error |
| 8 | Key import error |
| 9 | Git configuration reset error |
| 10 | GPG configuration reset error |
| 11 | Home directory not found |

0 comments on commit fa61b47

Please sign in to comment.