Skip to content
Snippets Groups Projects
Commit 04776b08 authored by Tom Ryser's avatar Tom Ryser
Browse files

#3 add makefile with structure.

parent 714e23f4
No related branches found
No related tags found
1 merge request!3Resolve "add makefile with structure"
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.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
# stack # Stack
```
📦project
┣ 📂include
┃ ┗ 📜.h
┣ 📂Sources
┃ ┣ 📜main.c
┃ ┗ 📜.c
┣ 📜.gitignore
┣ 📜makefile
┗ 📜README.md
```
\ No newline at end of file
#include <stdio.h>
#include "../include/pile.h"
int main(void) {
helloworld();
return 0;
}
\ No newline at end of file
#include "../include/pile.h"
#include <stdio.h>
void helloworld(){
printf("helloworld\n");
}
\ No newline at end of file
#ifndef PILE_H
#define PILE_H
void helloworld();
#endif
\ No newline at end of file
makefile 0 → 100644
SRC_DIR := Sources
OBJ_DIR := obj
BIN_DIR := bin
EXE := $(BIN_DIR)/stack.exe #exe name
SRC := $(wildcard $(SRC_DIR)/*.c)
OBJ := $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
CPPFLAGS := -Iinclude -MMD -MP
CFLAGS := -Wall
LDFLAGS := -Llib
LDLIBS := -lm
.PHONY: all clean
all: $(EXE)
$(EXE): $(OBJ) | $(BIN_DIR)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(BIN_DIR) $(OBJ_DIR):
mkdir -p $@
clean:
@$(RM) -rv $(BIN_DIR) $(OBJ_DIR)
-include $(OBJ:.o=.d)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment