Compare commits

..

No commits in common. "60d1edccccc55c81cb30a908a689922d731774f1" and "c1c27f91b61049d4729d11712070082f0c5107c6" have entirely different histories.

3 changed files with 32 additions and 16 deletions

1
.gitignore vendored
View File

@ -3,4 +3,3 @@
*.out
obj/
compile_commands.json
.cache

View File

@ -1,8 +1,9 @@
NAME = scl
CC = clang
CFLAGS = -Wall --std=c11
LDFLAGS =
CC = gcc
CFLAGS_REG = -Wall -O2
CFLAGS_DBG = -ggdb -fsanitize=address -O0
LDFLAGS = -lm
SRC_DIR = src
OBJ_DIR = obj
@ -11,19 +12,35 @@ TARGET = $(NAME).out
SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRC_FILES))
all: $(TARGET)
COL_BOLD = \x1b[37;1m
COL_CLEAR = \x1b[0m
$(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)
all: reg
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(SRC_DIR)/include/%.h
reg: CFLAGS = $(CFLAGS_REG)
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)
@ 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 $@
$(CC) $(CFLAGS) -c $< -o $@
clean:
@ echo -e "\x1b[32;1mCleaning up...\x1b[0m"
@ rm -rf $(OBJ_DIR) $(TARGET)
clean: msg_cleaning
rm -rf $(OBJ_DIR) $(TARGET) $(TARGET_DBG)
.PHONY: all clean
.PHONY: all clean reg dbg msg_compiling msg_linking msg_cleaning

View File

@ -1,6 +1,6 @@
#include <stdio.h>
int main(int argc, char** argv) {
printf("Hello, world!\n");
printf("Hello, world!");
return 0;
}