Compare commits
1 Commits
test_frame
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 69861846a2 |
6
c_projects/linker_error_pg/a.h
Normal file
6
c_projects/linker_error_pg/a.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef A_H
|
||||||
|
#define A_H
|
||||||
|
|
||||||
|
int x = 42;
|
||||||
|
|
||||||
|
#endif
|
||||||
7
c_projects/linker_error_pg/b.c
Normal file
7
c_projects/linker_error_pg/b.c
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "b.h"
|
||||||
|
|
||||||
|
|
||||||
|
int b_print_x(){
|
||||||
|
printf("b.c: x = %d\n", x);
|
||||||
|
}
|
||||||
4
c_projects/linker_error_pg/b.h
Normal file
4
c_projects/linker_error_pg/b.h
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "a.h"
|
||||||
|
|
||||||
|
int b_print_x();
|
||||||
8
c_projects/linker_error_pg/c.c
Normal file
8
c_projects/linker_error_pg/c.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "c.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int c_print_x(){
|
||||||
|
printf("c.c: x = %d\n", x);
|
||||||
|
}
|
||||||
3
c_projects/linker_error_pg/c.h
Normal file
3
c_projects/linker_error_pg/c.h
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#include "a.h"
|
||||||
|
|
||||||
|
int c_print_x();
|
||||||
8
c_projects/linker_error_pg/d.c
Normal file
8
c_projects/linker_error_pg/d.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "b.h"
|
||||||
|
#include "c.h"
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
b_print_x();
|
||||||
|
c_print_x();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@ -1,67 +0,0 @@
|
|||||||
# MakeFile for placeholder
|
|
||||||
# Created mm/dd/yyyy
|
|
||||||
# Authored by: xavi
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------------
|
|
||||||
# | THIS IS A TEMPLATE |
|
|
||||||
# ----------------------
|
|
||||||
# TODO:
|
|
||||||
# %s/placeholder/project_name/g
|
|
||||||
# Change date file was created to today
|
|
||||||
# run make dirs to create project hierarchy
|
|
||||||
# Place headers in include and source files in src
|
|
||||||
# Delete this text
|
|
||||||
|
|
||||||
.POSIX:
|
|
||||||
|
|
||||||
# DIRECTORIES
|
|
||||||
SRC_DIR := src
|
|
||||||
INCLUDE_DIR := include
|
|
||||||
OBJ_DIR := obj
|
|
||||||
TESTS_DIR := tests
|
|
||||||
|
|
||||||
|
|
||||||
# C compiler settings
|
|
||||||
CC := gcc
|
|
||||||
CFLAGS := -ggdb -I$(INCLUDE_DIR) -Wall -Wextra -MMD -MP
|
|
||||||
DFLAGS :=
|
|
||||||
|
|
||||||
# Files
|
|
||||||
SRC := $(wildcard $(SRC_DIR)/*.c)
|
|
||||||
OBJ := $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
|
|
||||||
TESTS := $(wildcard $(TESTS_DIR)/*.c)
|
|
||||||
|
|
||||||
# Get Dependencies from gcc using -MMD and -MP
|
|
||||||
DEPENDENCIES := $(OBJ:%.o=%.d)
|
|
||||||
|
|
||||||
# Final Binary Name
|
|
||||||
PROJECT_NAME := placeholder
|
|
||||||
|
|
||||||
|
|
||||||
all: $(PROJECT_NAME)
|
|
||||||
|
|
||||||
|
|
||||||
$(TESTS:$(TESTS_DIR)/%.c=%): $(OBJ)
|
|
||||||
$(CC) $(CFLAGS) $(DFLAGS) -o $(@) $(^)
|
|
||||||
|
|
||||||
|
|
||||||
$(PROJECT_NAME): $(OBJ)
|
|
||||||
$(CC) $(CFLAGS) $(DFLAGS) -o $(@) $(^)
|
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
|
||||||
$(CC) $(CFLAGS) $(DFLAGS) -c -o $(@) $(<)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(PROJECT_NAME) $(OBJ_DIR)/* $(TESTS:$(TESTS_DIR)/%.c=%)
|
|
||||||
|
|
||||||
-include $(DEPENDENCIES)
|
|
||||||
|
|
||||||
.PHONY: clean all
|
|
||||||
|
|
||||||
# Create Project Hierarchy
|
|
||||||
|
|
||||||
dirs: $(SRC_DIR) $(OBJ_DIR) $(TESTS_DIR) $(INCLUDE_DIR)
|
|
||||||
|
|
||||||
$(SRC_DIR) $(OBJ_DIR) $(TESTS_DIR) $(INCLUDE_DIR):
|
|
||||||
mkdir -p $(@)
|
|
||||||
Loading…
Reference in New Issue
Block a user