Added c files
This commit is contained in:
parent
c6f2d0e14b
commit
5b434b4e0e
61
c_dev/Makefile
Normal file
61
c_dev/Makefile
Normal file
@ -0,0 +1,61 @@
|
||||
# Compiler Flags
|
||||
CC := gcc
|
||||
CFLAGS := -g -Wall -Wextra -Werror -pedantic -fsanitize=address,undefined -fno-omit-frame-pointer
|
||||
|
||||
# Directory variables
|
||||
LIBDIR := lib
|
||||
OBJ := obj
|
||||
INC := include
|
||||
SRC := src
|
||||
TEST := tests
|
||||
|
||||
# Filepath Pattern Matching
|
||||
LIB := $(LIBDIR)/lib.a
|
||||
SRCS := $(wildcard $(SRC)/*.c)
|
||||
OBJS := $(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SRCS))
|
||||
TESTS := $(wildcard $(TEST)/*.c)
|
||||
TESTBINS := $(patsubst $(TEST)/%.c, $(TEST)/bin/%, $(TESTS))
|
||||
|
||||
# Commands must be labeled PHONY
|
||||
.PHONY: all release clean test
|
||||
|
||||
# Target for compilation.
|
||||
all: $(LIB)
|
||||
|
||||
# Compiler Release Flags
|
||||
release: CFLAGS := -Wall -Wextra -Werror -pedantic -fsanitize=address,undefined -fno-omit-frame-pointer -O2 -DNDEBUG
|
||||
release: clean $(LIB)
|
||||
|
||||
# Dependancies
|
||||
$(LIB): $(OBJS) | $(LIBDIR)
|
||||
$(RM) $(LIB)
|
||||
ar -cvrs $@ $^
|
||||
|
||||
$(OBJ)/%.o: $(SRC)/%.c $(SRC)/%.h | $(OBJ)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJ)/%.o: $(SRC)/%.c | $(OBJ)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(TEST)/bin/%: $(TEST)/%.c $(LIB) | $(TEST)/bin
|
||||
$(CC) $(CFLAGS) $< $(LIB) -o $@
|
||||
|
||||
# Make directories if none.
|
||||
$(LIBDIR):
|
||||
mkdir $@
|
||||
|
||||
$(INC):
|
||||
mkdir $@
|
||||
|
||||
$(OBJ):
|
||||
mkdir $@
|
||||
|
||||
$(TEST)/bin:
|
||||
mkdir $@
|
||||
|
||||
# Run the tests in the bin folder. Parent folder is working dir, not test | bin.
|
||||
test: $(LIB) $(TEST)/bin $(TESTBINS)
|
||||
for test in $(TESTBINS); do ./$$test ; done
|
||||
|
||||
clean:
|
||||
$(RM) -r $(LIBDIR) $(OBJ) $(TEST)/bin/
|
59
c_dev/gitignore_c
Normal file
59
c_dev/gitignore_c
Normal file
@ -0,0 +1,59 @@
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
# Ctags Folder
|
||||
tags/
|
||||
/tags
|
||||
|
||||
bin/
|
||||
/bin
|
7
c_dev/main.c
Normal file
7
c_dev/main.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
printf("There were %d arguments in %s\n", argc, argv[0]);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in New Issue
Block a user