Compare commits
2 Commits
c1c27f91b6
...
60d1edcccc
Author | SHA1 | Date | |
---|---|---|---|
60d1edcccc | |||
f674f47306 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@
|
|||||||
*.out
|
*.out
|
||||||
obj/
|
obj/
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
|
.cache
|
||||||
|
45
Makefile
45
Makefile
@ -1,9 +1,8 @@
|
|||||||
NAME = scl
|
NAME = scl
|
||||||
|
|
||||||
CC = gcc
|
CC = clang
|
||||||
CFLAGS_REG = -Wall -O2
|
CFLAGS = -Wall --std=c11
|
||||||
CFLAGS_DBG = -ggdb -fsanitize=address -O0
|
LDFLAGS =
|
||||||
LDFLAGS = -lm
|
|
||||||
|
|
||||||
SRC_DIR = src
|
SRC_DIR = src
|
||||||
OBJ_DIR = obj
|
OBJ_DIR = obj
|
||||||
@ -12,35 +11,19 @@ TARGET = $(NAME).out
|
|||||||
SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
|
SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
|
||||||
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRC_FILES))
|
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRC_FILES))
|
||||||
|
|
||||||
COL_BOLD = \x1b[37;1m
|
all: $(TARGET)
|
||||||
COL_CLEAR = \x1b[0m
|
|
||||||
|
|
||||||
all: reg
|
$(TARGET): $(OBJ_FILES)
|
||||||
|
@ echo -e "\x1b[32;1mLinking \x1b[0m\x1b[32m$(TARGET)\x1b[32;1m...\x1b[0m\x1b[37m $(CC) -o $(TARGET) $(OBJ_FILES) $(LDFLAGS)\x1b[0m"
|
||||||
|
@ $(CC) -o $(TARGET) $(OBJ_FILES) $(LDFLAGS)
|
||||||
|
|
||||||
reg: CFLAGS = $(CFLAGS_REG)
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(SRC_DIR)/include/%.h
|
||||||
reg: $(TARGET)
|
|
||||||
|
|
||||||
dbg: CFLAGS = $(CFLAGS_DBG)
|
|
||||||
dbg: clean
|
|
||||||
dbg: $(TARGET)
|
|
||||||
|
|
||||||
msg_compiling:
|
|
||||||
@ echo -e "$(COL_BOLD)Compiling...$(COL_CLEAR)"
|
|
||||||
|
|
||||||
msg_linking:
|
|
||||||
@ echo -e "$(COL_BOLD)Linking...$(COL_CLEAR)"
|
|
||||||
|
|
||||||
msg_cleaning:
|
|
||||||
@ echo -e "$(COL_BOLD)Cleaning up...$(COL_CLEAR)"
|
|
||||||
|
|
||||||
$(TARGET): msg_compiling $(OBJ_FILES) msg_linking
|
|
||||||
$(CC) $(LDFLAGS) $(OBJ_FILES) -o $@
|
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
|
||||||
@ mkdir -p $(OBJ_DIR)
|
@ mkdir -p $(OBJ_DIR)
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
@ echo -e "\x1b[32;1mCompiling \x1b[0m\x1b[32m$<\x1b[32;1m... \x1b[0m\x1b[37m$(CC) $(CFLAGS) -c $< -o $@\x1b[0m"
|
||||||
|
@ $(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
clean: msg_cleaning
|
clean:
|
||||||
rm -rf $(OBJ_DIR) $(TARGET) $(TARGET_DBG)
|
@ echo -e "\x1b[32;1mCleaning up...\x1b[0m"
|
||||||
|
@ rm -rf $(OBJ_DIR) $(TARGET)
|
||||||
|
|
||||||
.PHONY: all clean reg dbg msg_compiling msg_linking msg_cleaning
|
.PHONY: all clean
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
printf("Hello, world!");
|
printf("Hello, world!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user