forked from stephenwashington/convert
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile_for_powershell
More file actions
41 lines (32 loc) · 941 Bytes
/
Copy pathmakefile_for_powershell
File metadata and controls
41 lines (32 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Compiler
# rename file to makefile before use
CC := gcc
# Directories
SRCDIR := src
BUILDDIR := build
# Target Executable
TARGET := convert.exe # Windows executable
# Find all .c source files
SOURCES := $(wildcard $(SRCDIR)/*.c)
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.c=.o))
# Check if sources exist
ifeq ($(strip $(SOURCES)),)
$(error No source files found in $(SRCDIR))
endif
# Compiler Flags
CFLAGS := -std=c99 -Wall -Wextra -Wpedantic -Werror -Wshadow -Wstrict-overflow -fstack-protector -O2
LIBS := -lm -lpthread -Wl,-subsystem,console
INC := -I include
# Build everything
all: $(TARGET)
# Link the final executable
$(TARGET): $(OBJECTS)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS)
# Compile .c files into .o files
$(BUILDDIR)/%.o: $(SRCDIR)/%.c
@$(shell mkdir $(BUILDDIR) 2>nul || exit 0)
$(CC) $(CFLAGS) -c $< -o $@ $(INC)
# Clean build files
.PHONY: clean
clean:
@rm -rf $(BUILDDIR) $(TARGET)