Skip to content

Commit fa61b47

Browse files
committed
chore: update makefile and readme
1 parent 4e604fb commit fa61b47

File tree

2 files changed

+106
-22
lines changed

2 files changed

+106
-22
lines changed

Makefile

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,61 @@
11
CC = gcc
2-
CFLAGS = -Wall -Wextra
3-
SRCS = src/main.c src/system_check.c src/key_management.c src/git_config.c
4-
OBJS = $(SRCS:.c=.o)
5-
TARGET = gitkeykit
2+
CFLAGS = -Wall -Wextra -I./src
63

4+
# Directories
5+
SRC_DIR = src
6+
BUILD_DIR = build
7+
BIN_DIR = bin
8+
9+
# Source files
10+
SRCS = $(wildcard $(SRC_DIR)/*.c) \
11+
$(wildcard $(SRC_DIR)/commands/*.c) \
12+
$(wildcard $(SRC_DIR)/utils/*.c)
13+
14+
# Object files
15+
OBJS = $(SRCS:%.c=$(BUILD_DIR)/%.o)
16+
17+
# Target executable
18+
TARGET = $(BIN_DIR)/gitkeykit
19+
20+
# Platform-specific settings
21+
ifeq ($(OS),Windows_NT)
22+
TARGET := $(TARGET).exe
23+
RM = del /Q /F
24+
MKDIR = mkdir
25+
else
26+
RM = rm -rf
27+
MKDIR = mkdir -p
28+
endif
29+
30+
# Default target
31+
all: directories $(TARGET)
32+
33+
# Create necessary directories
34+
directories:
35+
$(MKDIR) $(BUILD_DIR) $(BIN_DIR) \
36+
$(BUILD_DIR)/$(SRC_DIR) \
37+
$(BUILD_DIR)/$(SRC_DIR)/commands \
38+
$(BUILD_DIR)/$(SRC_DIR)/utils
39+
40+
# Link the final executable
741
$(TARGET): $(OBJS)
842
$(CC) $(OBJS) -o $(TARGET)
943

10-
%.o: %.c
44+
# Compile source files
45+
$(BUILD_DIR)/%.o: %.c
46+
$(MKDIR) $(dir $@)
1147
$(CC) $(CFLAGS) -c $< -o $@
1248

49+
# Clean build files
1350
clean:
14-
rm -f $(OBJS) $(TARGET)
51+
$(RM) $(BUILD_DIR) $(BIN_DIR)
52+
53+
# Install target (Unix-like systems only)
54+
install: all
55+
install -m 755 $(TARGET) /usr/local/bin/
56+
57+
# Phony targets
58+
.PHONY: all clean directories install
59+
60+
# Dependencies
61+
-include $(OBJS:.o=.d)

README.md

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,64 @@ Before using GitKeyKit, ensure you have:
2222
- macOS: `brew install gnupg`
2323
- Linux: `sudo apt-get install gnupg` (Ubuntu/Debian) or equivalent
2424

25+
2526
## Installation 🚀
2627

27-
### From Source
28+
### Unix-like systems
2829
```bash
29-
git clone https://github.com/yourusername/gitkeykit.git
3030
cd gitkeykit
31-
make
32-
bash
33-
gitkeykit create
34-
bash
35-
gitkeykit import path/to/key.asc
36-
bash
31+
sudo make install
32+
```
33+
34+
## Usage 📖
35+
36+
### Setup GPG key for signing commits
37+
```bash
38+
gitkeykit
39+
```
40+
41+
### Import PGP key from file
42+
```bash
43+
gitkeykit import <key_path>
44+
```
45+
46+
### Reset Git and GPG configurations
47+
```bash
3748
gitkeykit --reset
3849
```
3950

51+
## Building from Source 🛠️
52+
53+
### Compilation
54+
```bash
55+
make
56+
```
57+
58+
This will:
59+
- Compile the source files from `src/`, `src/commands/`, and `src/utils/` directories
60+
- Link object files and create the executable in `bin/` directory
61+
- Create necessary directories (`build/` and `bin/`) if they don't exist
62+
- Generate the executable `gitkeykit` (or `gitkeykit.exe` on Windows)
63+
64+
### Cleaning Up
65+
```bash
66+
make clean
67+
```
68+
This removes the `build/` and `bin/` directories along with all generated files.
69+
4070
## Error Codes 🚨
41-
- `0`: Success
42-
- `1`: GPG not found
43-
- `2`: Git not found
44-
- `3`: Invalid arguments
45-
- `4`: No secret keys found
46-
- `5`: Invalid input
47-
- `6`: Git configuration error
48-
- `7`: Key generation error
71+
72+
| Code | Description |
73+
|------|-------------|
74+
| 0 | Success |
75+
| 1 | GPG not found |
76+
| 2 | Git not found |
77+
| 3 | Invalid arguments |
78+
| 4 | No secret keys found |
79+
| 5 | Invalid input |
80+
| 6 | Git configuration error |
81+
| 7 | Key generation error |
82+
| 8 | Key import error |
83+
| 9 | Git configuration reset error |
84+
| 10 | GPG configuration reset error |
85+
| 11 | Home directory not found |

0 commit comments

Comments
 (0)