Skip to content

Commit

Permalink
nice
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammyueru committed Jan 7, 2024
1 parent a448450 commit 9972f6a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 26 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Samm YT
Smaller projects that don't need their own repositories specificately shown on YouTube

# build requirements
# Build Requirements
- MAKE
- GCC (I'm using Mingw64)

# Building
1. Find the folder name of the project you want to compile within the projects folder
2. Compile that project using the command ```make PROJECT=[project you want to compile] OS=[WIN, LINUX, or MACOS (although i've only tested WIN)] [optional: ARCH=[currently just x86 or x64] STATE=[RELEASE or DEBUG] TYPE=[just SOFTWARE for now]] one```

# Build Example
```make PROJECT=float_compress OS=WIN one```

# Note
none of these projects are done in fact I've been having trouble getting the makefile to work so this is a work in progress
58 changes: 34 additions & 24 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,46 @@
CC := gcc
CXX := g++

PROJECT ?= float_compress
PROJECT ?=float_compress
# WIN, LINUX, MACOS, UNIX, NONE
OS ?= WIN
OS ?=WIN
# RELEASE, DEBUG
STATE ?= RELEASE
STATE ?=RELEASE
# x86, x64, ARM, ARM64
ARCH ?= x64
ARCH ?=x64
# SOFTWARE, OS
TYPE ?= SOFTWARE
TYPE ?=SOFTWARE

SRC := ./projects/$(PROJECT)/
BUILD := ./build/$(PROJECT)/$(ARCH)/$(STATE)/
BUILD := ./build/$(PROJECT)/$(ARCH)_$(STATE)/
INCS := -I./shared/inc/
LIBS := -L./shared/lib/$(ARCH)/
LIBS := -L./shared/lib/$(ARCH)/ -lmingw32 -lSDL2main -lSDL2

ifeq ($(OS),WIN)
LIBS += -lversion -lgdi32 -limm32
endif

ifeq ($(ARCH),x86)
CFLAGS := -m32 $(INCS) -Wall
CXXFLAGS := -m32 $(INCS) -std=c++20 -Wall
ASFLAGS := -f elf
LDFLAGS := -m elf_i386 -T linker.ld
CFLAGS := -m32 $(INCS) -Wall
CXXFLAGS := -m32 $(INCS) -std=c++20 -Wall
ASFLAGS := -f elf
LDFLAGS :=
else ifeq ($(ARCH),x64)
CFLAGS := -m64 $(INCS) -Wall
CXXFLAGS := -m64 $(INCS) -std=c++20 -Wall
ASFLAGS := -f elf64
LDFLAGS := -m elf_x86_64 -T linker.ld
CFLAGS := -m64 $(INCS) -Wall
CXXFLAGS := -m64 $(INCS) -std=c++20 -Wall
ASFLAGS := -f elf64
LDFLAGS :=
endif
# LDFLAGS += -m elf_i386 -T linker.ld
# LDFLAGS += -m elf_x86_64 -T linker.ld

OUT := $(BUILD)$(PROJECT).exe
ifeq ($(OS),WIN)
OUT := $(BUILD)$(PROJECT).exe
else ifeq ($(OS),LINUX)
OUT := $(BUILD)$(PROJECT).out
else ifeq ($(OS),MACOS)
OUT := $(BUILD)$(PROJECT).app
OUT := $(BUILD)$(PROJECT).app
else
OUT := $(BUILD)$(PROJECT).bin
endif
Expand All @@ -48,23 +55,26 @@ ASM_OBJS = $(ASM_SOURCES:.asm=.o)
C_OBJS = $(C_SOURCES:.c=.o)
CXX_OBJS = $(CXX_SOURCES:.cpp=.o)

$(ASM_OBJS): $(ASM_SOURCES)
$(ASM_OBJS) : $(ASM_SOURCES)
$(CC) $(ASFLAGS) -o $@ $^

$(C_OBJS): $(C_SOURCES)
$(C_OBJS) : $(C_SOURCES)
$(CC) $(CFLAGS) $(INCS) -c -o $@ $^

$(CXX_OBJS): $(CXX_SOURCES)
$(CXX_OBJS) : $(CXX_SOURCES)
$(CXX) $(CXXFLAGS) $(INCS) -c -o $@ $^

$(OUT): $(ASM_OBJS) $(C_OBJS) $(CXX_OBJS)
create_directories:
mkdir -p $(BUILD)

$(OUT) : $(ASM_OBJS) $(C_OBJS) $(CXX_OBJS)
$(CXX) $(LDFLAGS) $(LIBS) -o $@ $^

one:
mkdir -p $(BUILD)
$(OUT)
.PHONY:

one: create_directories $(OUT)

rebuild: clean build
rebuild: clean create_directories one
clean:
rm -rf $(ASM_OBJS)
rm -rf $(C_OBJS)
Expand Down
4 changes: 3 additions & 1 deletion projects/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.unfinished
*_unfinished
*_unfinished
*.unreleased
*_unreleased

0 comments on commit 9972f6a

Please sign in to comment.