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